Skip to content

Commit 78e9197

Browse files
authored
Merge pull request #623 from junaruga/wip/enable-mkmf-verbose
CI: Enable the verbose mode in the mkmf.rb.
2 parents 08b0ed7 + a832f5c commit 78e9197

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-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: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/sh
2+
3+
set -eux
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_rb_path}.orig" "${mkmf_rb_path}"; then
19+
echo "error: ${mkmf_rb_path} was not modified." 1>&2
20+
exit 1
21+
elif [ "${?}" != 1 ]; then
22+
echo "error: diff was failed." 1>&2
23+
exit 1
24+
fi

0 commit comments

Comments
 (0)