spec_helper.cr needs access to the cxxflags variable which is determined when the clang tool (subdir clang/ runs).
Currently, the tool dumps variables to Makefile.variables, in Makefile format, and spec_helper reads it in a basic way.
diff --git a/spec/clang/spec_helper.cr b/spec/clang/spec_helper.cr
index 71e0bd0..672c502 100644
--- a/spec/clang/spec_helper.cr
+++ b/spec/clang/spec_helper.cr
@@ -18,8 +18,17 @@ def clang_tool(cpp_code, arguments, **checks)
tool = ENV["BINDGEN_BIN"]? || Bindgen::Parser::Runner::BINARY_PATH
+ cxx_flags = "-std=c++11 -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS"
+ makefile_vars = File.join(__DIR__, "../../clang/Makefile.variables")
+ if File.exists?(makefile_vars)
+ File.read_lines(makefile_vars).each do |line|
+ if line =~ /^LLVM_CXX_FLAGS/
+ cxx_flags = line.split(" := ").last.chomp
+ end
+ end
+ end
command = "#{tool} #{file.path} #{arguments} -- " \
- "-x c++ -std=c++11 -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS " \
+ "-x c++ #{cxx_flags} " \
"-Wno-implicitly-unsigned-literal"
We should change this to pass this data in a more formal way. One possible way to do it would be for the clang tool to read some (existing or new) file in YAML or Crystal format.
spec_helper.cr needs access to the cxxflags variable which is determined when the clang tool (subdir
clang/
runs). Currently, the tool dumps variables toMakefile.variables
, in Makefile format, and spec_helper reads it in a basic way.We should change this to pass this data in a more formal way. One possible way to do it would be for the clang tool to read some (existing or new) file in YAML or Crystal format.