Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better cxxflags setting in spec/clang/spec_helper.cr #40

Open
docelic opened this issue May 12, 2020 · 0 comments
Open

Better cxxflags setting in spec/clang/spec_helper.cr #40

docelic opened this issue May 12, 2020 · 0 comments

Comments

@docelic
Copy link
Collaborator

docelic commented May 12, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant