Skip to content

Commit 3ee4bd9

Browse files
committed
CI: Enable the verbose mode in the mkmf.rb.
Enable the verbose option in mkmf.rb to print the compiling commands in the process of the `rake compile`. Because it's helpful to see what compiler warnings are checked. The script only runs in Linux and macOS. Not Windows. Because the sh script doesn't work in Windows. For the syntax, see the reference.[1] Right now there is a way to configure Ruby with `--enable-mkmf-verbose` in this purpose. But there is no formal way to enable the verbose mode in runtime of Ruby. My intention is that this commit is a workaround for this purpose. [1] https://docs.github.com/en/actions/learn-github-actions/variables * Default environment variables - RUNNER_OS * Detecting the operating system
1 parent 08b0ed7 commit 3ee4bd9

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

.github/workflows/test.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ jobs:
4242
- name: depends
4343
run: bundle install
4444

45+
# Enable the verbose option in mkmf.rb to print the compiling commands.
46+
- name: enable mkmf verbose
47+
run: tool/enable-mkmf-verbose
48+
if: runner.os == 'Linux' || runner.os == 'macOS'
49+
4550
- name: compile
4651
run: rake compile -- --enable-debug
4752

@@ -129,6 +134,10 @@ jobs:
129134
- name: depends
130135
run: bundle install
131136

137+
- name: enable mkmf verbose
138+
run: tool/enable-mkmf-verbose
139+
if: runner.os == 'Linux' || runner.os == 'macOS'
140+
132141
- name: compile
133142
run: rake compile -- --enable-debug --with-openssl-dir=$HOME/.openssl/${{ matrix.openssl }}
134143

tool/enable-mkmf-verbose

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/sh -eu
2+
3+
set -x
4+
5+
gem_home="$(gem environment home)"
6+
mkmf_rb_path="$(find "${gem_home}"/../.. -name mkmf.rb)"
7+
8+
# Backup the original file.
9+
cp -p "${mkmf_rb_path}" "${mkmf_rb_path}.orig"
10+
11+
# Replace the target line to set the verbose option.
12+
sed -i -e 's/^V = .*/V = 1/' "${mkmf_rb_path}"
13+
14+
# Print the difference between the original and modified file. This is useful
15+
# to debug when the `mkmf.rb` may change in the future. And check if the
16+
#`mkmf.rb` was modified. Because the `sed` command returns the exit status 0 no
17+
# matter it replaces successfully or not.
18+
if diff "${mkmf_path}.orig" "${mkmf_path}"; then
19+
echo "error: ${mkmf_path} was not modified." 1>&2
20+
exit 1
21+
fi

0 commit comments

Comments
 (0)