FFIG / ffig

Generate code to call C++ libraries from other languages
MIT License
29 stars 9 forks source link

Get bazel functioning on AppVeyor #467

Open philipcraig opened 5 years ago

philipcraig commented 5 years ago

The story so far. On Windows, bazel ffig builds fail. e.g. bazel build --verbose_failures //:Shape.net.src produces:

INFO: Invocation ID: 78291982-5704-4d99-af80-f6284f2862dd
Loading:
Loading: 0 packages loaded
Analyzing: target //:Shape.net.src (0 packages loaded, 0 targets configured)
INFO: Analysed target //:Shape.net.src (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
[0 / 2] [-----] Executing genrule //:Shape.net.src
[1 / 2] Executing genrule //:Shape.net.src; 1s local
ERROR: C:/work/ffig/BUILD:47:1: Executing genrule //:Shape.net.src failed (Exit 1): bash.exe failed: error executing command
  cd C:/users/philip/_bazel_philip/qj5frnln/execroot/__main__
  SET PATH=C:\tools\msys64\usr\bin;C:\tools\msys64\bin
  C:/tools/msys64/usr/bin/bash.exe -c source external/bazel_tools/tools/genrule/genrule-setup.sh; bazel-out/host/bin/ffig_py.exe -i tests/input/Shape.h -m Shape -o bazel-out/x64_windows-fastbuild/genfiles -b cs.tmpl --cflag=-Itests/input --cflag=-Iffig/include --cflag=-std=c++14 --cflag=-DShape_c_EXPORTS
Execution platform: @bazel_tools//platforms:host_platform

The errors in the above are related to not finding libclang.dll (as the path to LLVM has been removed from the path) and then (if this is manually corrected) not finding the <cmath> include file, as Visual Studio is also not being set by Bazel in the above. I suspect that on Linux/Darwin, gcc/clang have the location of their include files encoded into their binaries, so that they can always be found, whereas Windows doesn't.

Investigations continue into why bazel is shortening the path so much on Windows and how this can be cirvumvented

jbcoe commented 5 years ago

Nice work!

philipcraig commented 5 years ago

Also looked into what successful bazel windows builds (the one that ships with bazel) look like. bazel print_action //examples/cpp:hello-lib outputs a bunch of things. The main thing I notice is that Bazel knows which steps are doing C++ things (mnemonic: "CppCompile"), so sets up the PATH and INCLUDE variables correctly. Wonder if ffig bazel windows version needs to mark its tasks that use libClang as cpp tasks in some way.

philipcraig commented 5 years ago

Now also wondering if all this is because (at least) ffig.bzl has hard-coded Linux specific things

jbcoe commented 5 years ago

Which are the hard-coded Linux things?

philipcraig commented 5 years ago

Hi, to backtrack a little, perhaps the bazel task that runs FFIG.py should become a C++ Bazel task. This is so that the Bazel will set up the correct C++ environment on Windows, bringing the INCLUDE dir in. This could be done via something like here https://stackoverflow.com/q/52769846/105050, making the call to FFIG.py use the cc_common API.