From 58940971d188b608b3316984e7997233591260c4 Mon Sep 17 00:00:00 2001 From: Dylan Thacker-Smith Date: Tue, 10 Nov 2020 09:31:10 -0500 Subject: [PATCH] Remove error on compiler warnings by default, except on CI --- .github/workflows/liquid.yml | 2 ++ ext/liquid_c/extconf.rb | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/liquid.yml b/.github/workflows/liquid.yml index 041e785e..1a49ebe0 100644 --- a/.github/workflows/liquid.yml +++ b/.github/workflows/liquid.yml @@ -23,4 +23,6 @@ jobs: - run: bundle install --jobs=3 --retry=3 --path=vendor/bundle - run: bundle exec rake continue-on-error: ${{ matrix.entry.allowed-failure }} + env: + LIQUID_C_PEDANTIC: 'true' - run: bundle exec rubocop diff --git a/ext/liquid_c/extconf.rb b/ext/liquid_c/extconf.rb index 73d0b23f..a014cefc 100644 --- a/ext/liquid_c/extconf.rb +++ b/ext/liquid_c/extconf.rb @@ -1,7 +1,10 @@ # frozen_string_literal: true require 'mkmf' $CFLAGS << ' -std=c99 -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers' -if RbConfig::CONFIG['host_os'] !~ /linux/ || Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.7") +# In Ruby 2.6 and earlier, the Ruby headers did not have struct timespec defined +valid_headers = RbConfig::CONFIG['host_os'] !~ /linux/ || Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.7") +pedantic = !ENV['LIQUID_C_PEDANTIC'].to_s.empty? +if pedantic && valid_headers $CFLAGS << ' -Werror' end compiler = RbConfig::MAKEFILE_CONFIG['CC']