Buck expects import paths in cgo files to be relative to the Buck project root instead of the file's current directory
Created by: monty-uber
I have an example of this here: https://github.com/monty-uber/cgo-buck-example/tree/master/go-calls-c
All of the files are in the same directory, therefore the cgo_source.go file's import should be // #include "call_from_go.h"
. However, Buck complains that it cannot find the header file in that case. Changing it to be relative to the project root like so: // #include "go-calls-c/call_from_go.h"
makes the Buck build succeed.
This makes these cgo files incompatible with the go toolchain as go build
expects the import paths to be relative to the file itself.
This is also apparent in the integration tests in Buck: https://github.com/facebook/buck/tree/master/test/com/facebook/buck/go/testdata/cgo/src/cgo_test. It's the same scenario, the go code that references C is in cgosrc.go, which has the include path of "src/cgo_test/lib.h" even though lib.h is in the same directory.