Skip to content

Commit ca6d240

Browse files
authored
Merge pull request #331 from Shopify/use-append-cflags
extconf.rb: use append_cflags
2 parents eb42b0f + 682092f commit ca6d240

1 file changed

Lines changed: 14 additions & 11 deletions

File tree

ext/msgpack/extconf.rb

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,18 @@
55
have_func("rb_enc_interned_str", "ruby.h") # Ruby 3.0+
66
have_func("rb_hash_new_capa", "ruby.h") # Ruby 3.2+
77

8-
$CFLAGS << " -fvisibility=hidden "
9-
10-
unless RUBY_PLATFORM.include? 'mswin'
11-
$CFLAGS << %[ -I.. -Wall -O3 #{RbConfig::CONFIG["debugflags"]} -std=gnu99]
12-
end
8+
append_cflags([
9+
"-fvisibility=hidden",
10+
"-I..",
11+
"-Wall",
12+
"-O3",
13+
"-std=gnu99"
14+
])
15+
append_cflags(RbConfig::CONFIG["debugflags"]) if RbConfig::CONFIG["debugflags"]
1316

1417
if RUBY_VERSION.start_with?('3.0.') && RUBY_VERSION <= '3.0.5'
1518
# https://bugs.ruby-lang.org/issues/18772
16-
$CFLAGS << ' -DRB_ENC_INTERNED_STR_NULL_CHECK=1 '
19+
append_cflags("-DRB_ENC_INTERNED_STR_NULL_CHECK=1")
1720
end
1821

1922
# checking if Hash#[]= (rb_hash_aset) dedupes string keys (Ruby 2.6+)
@@ -23,21 +26,21 @@
2326
h[%W(#{r}).join('')] = :foo
2427
x[%W(#{r}).join('')] = :foo
2528
if x.keys[0].equal?(h.keys[0])
26-
$CFLAGS << ' -DHASH_ASET_DEDUPE=1 '
29+
append_cflags("-DHASH_ASET_DEDUPE=1")
2730
else
28-
$CFLAGS << ' -DHASH_ASET_DEDUPE=0 '
31+
append_cflags("-DHASH_ASET_DEDUPE=0")
2932
end
3033

3134
# checking if String#-@ (str_uminus) directly interns frozen strings... ' (Ruby 3.0+)
3235
begin
3336
s = rand.to_s.freeze
3437
if (-s).equal?(s) && (-s.dup).equal?(s)
35-
$CFLAGS << ' -DSTR_UMINUS_DEDUPE_FROZEN=1 '
38+
append_cflags("-DSTR_UMINUS_DEDUPE_FROZEN=1")
3639
else
37-
$CFLAGS << ' -DSTR_UMINUS_DEDUPE_FROZEN=0 '
40+
append_cflags("-DSTR_UMINUS_DEDUPE_FROZEN=0")
3841
end
3942
rescue NoMethodError
40-
$CFLAGS << ' -DSTR_UMINUS_DEDUPE_FROZEN=0 '
43+
append_cflags("-DSTR_UMINUS_DEDUPE_FROZEN=0")
4144
end
4245

4346
if warnflags = CONFIG['warnflags']

0 commit comments

Comments
 (0)