cgo_library referred by cgo_deps is not built
Created by: linzhp
I have a BUCK file as follows:
go_library(
name='lib',
package_name='github.com/shirou/gopsutil/cpu',
srcs=["cpu.go", "cpu_darwin.go"],
deps=["//vendor/github.com/shirou/gopsutil/internal/common:lib"],
cgo_deps=[":cgo_lib"],
visibility=['PUBLIC'],
tests=[':all_tests']
)
cgo_library(
name='cgo_lib',
srcs=['cpu_darwin_cgo.go']
)
go_test(
name='all_tests',
srcs=["cpu_test.go"],
deps=["//vendor/github.com/shirou/gopsutil/internal/common:lib"],
library=':lib'
)
When I try to do buck build //vendor/github.com/shirou/gopsutil/cpu:all_tests -v 3
, "cgo_lib" is not built, so the compiler can't find "perCPUTimes" and "allCPUTimes", which are defined in the cgo file:
PARSING BUCK FILES: FINISHED IN 0.0s
CREATING ACTION GRAPH: FINISHED IN 0.0s
FOUND 1/14 JOBS 0.0s //vendor/github.com/shirou/gopsutil/internal/common:lib#darwin_amd64
FOUND 2/14 JOBS 0.0s //vendor/github.com/shirou/gopsutil/cpu:all_tests#test-main,transitive-symlink-tree
FOUND 3/14 JOBS 0.0s //vendor/github.com/shirou/gopsutil/cpu:all_tests#darwin_amd64,symlink-tree,test-library
FOUND 4/14 JOBS 0.0s //vendor/github.com/shirou/gopsutil/internal/common:lib
FOUND 5/14 JOBS 0.0s //vendor/github.com/shirou/gopsutil/cpu:lib
mkdir -p buck-out/gen/vendor/github.com/shirou/gopsutil/cpu/all_tests#darwin_amd64,test-library
(cd /Users/zplin/gocode/src/buck_go_examples && GOROOT=/usr/local/Cellar/go/1.9.2/libexec GOOS=darwin GOARCH=amd64 /usr/local/Cellar/go/1.9.2/libexec/pkg/tool/darwin_amd64/compile -p github.com/shirou/gopsutil/cpu -pack -trimpath /Users/zplin/gocode/src/buck_go_examples -nolocalimports -o buck-out/gen/vendor/github.com/shirou/gopsutil/cpu/all_tests#darwin_amd64,test-library/all_tests.a -I /Users/zplin/gocode/src/buck_go_examples/buck-out/bin/vendor/github.com/shirou/gopsutil/cpu/__all_tests#darwin_amd64,symlink-tree,test-library__tree -complete /Users/zplin/gocode/src/buck_go_examples/vendor/github.com/shirou/gopsutil/cpu/cpu.go /Users/zplin/gocode/src/buck_go_examples/vendor/github.com/shirou/gopsutil/cpu/cpu_darwin.go /Users/zplin/gocode/src/buck_go_examples/vendor/github.com/shirou/gopsutil/cpu/cpu_test.go)
FOUND 6/13 JOBS 0.0s //vendor/github.com/shirou/gopsutil/cpu:all_tests#compile,darwin_amd64,symlink-tree,test-main
FOUND 7/13 JOBS 0.0s //vendor/github.com/shirou/gopsutil/cpu:all_tests#test-main-src
FOUND 8/13 JOBS 0.0s //vendor/github.com/shirou/gopsutil/cpu:all_tests#test-library
FOUND 9/13 JOBS 0.2s //vendor/golang.org/x/sys/unix:lib#darwin_amd64
/Users/zplin/gocode/src/buck_go_examples/vendor/github.com/shirou/gopsutil/cpu/cpu_darwin.go:26:10: undefined: perCPUTimes
/Users/zplin/gocode/src/buck_go_examples/vendor/github.com/shirou/gopsutil/cpu/cpu_darwin.go:29:9: undefined: allCPUTimes
Build failed: Command failed with exit code 2.
stderr:
When running <(cd /Users/zplin/gocode/src/buck_go_examples && GOROOT=/usr/local/Cellar/go/1.9.2/libexec GOOS=darwin GOARCH=amd64 /usr/local/Cellar/go/1.9.2/libexec/pkg/tool/darwin_amd64/compile -p github.com/shirou/gopsutil/cpu -pack -trimpath /Users/zplin/gocode/src/buck_go_examples -nolocalimports -o buck-out/gen/vendor/github.com/shirou/gopsutil/cpu/all_tests#darwin_amd64,test-library/all_tests.a -I /Users/zplin/gocode/src/buck_go_examples/buck-out/bin/vendor/github.com/shirou/gopsutil/cpu/__all_tests#darwin_amd64,symlink-tree,test-library__tree -complete /Users/zplin/gocode/src/buck_go_examples/vendor/github.com/shirou/gopsutil/cpu/cpu.go /Users/zplin/gocode/src/buck_go_examples/vendor/github.com/shirou/gopsutil/cpu/cpu_darwin.go /Users/zplin/gocode/src/buck_go_examples/vendor/github.com/shirou/gopsutil/cpu/cpu_test.go)>.
When building rule //vendor/github.com/shirou/gopsutil/cpu:all_tests#darwin_amd64,test-library.
DOWNLOADED 0 ARTIFACTS, 0.00 BYTES
BUILDING: FINISHED IN 0.4s (100%) 10/13 JOBS, 1 UPDATED, 7.7% CACHE MISS
BUILD FAILED
The project can be found here