Skip to content

Commit ac25ea8

Browse files
authored
examples: fix a few systemic problems (#1502)
1) `build_data = ["@m4"]` doesn't actually project m4 into the tools dir (`$EXT_BUILD_DEPS$$/bin`) and never has; instead, you have to use the more bazel-like `$$EXT_BUILD_ROOT/$(location @m4//:m4_exe)` 2) `$$EXT_BUILD_DEPS$$` might work (now that 208c7d4 is in) but it's better to follow the shell-variable convention and use `$$EXT_BUILD_DEPS` (without the trailing `$$`) 3) We were pulling perl and python deps from the host. Prefer to pull them from the toolchains. This also fixes everything but autoconf/automake on linux (autoconf builds but it's not actually usable, which the automake test shows). There's a lot more still disabled on darwin because openssl is broken there due to rpath problems that aren't debugged yet.
1 parent 413d7e5 commit ac25ea8

12 files changed

Lines changed: 80 additions & 44 deletions

examples/third_party/autotools/BUILD.autoconf.bazel

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@ filegroup(
1313
configure_make(
1414
name = "autoconf",
1515
build_data = [
16-
"@m4",
16+
"@m4//:m4_exe",
1717
],
18-
env = select({
18+
env = {
19+
"M4": "$$EXT_BUILD_ROOT/$(location @m4//:m4_exe)",
20+
"PERL": "$$EXT_BUILD_ROOT/$(PERL)",
21+
} | select({
1922
"@platforms//os:macos": {
2023
"AR": "",
21-
"M4": "$$EXT_BUILD_DEPS$$/bin/m4/bin/m4",
22-
},
23-
"//conditions:default": {
24-
"M4": "$$EXT_BUILD_DEPS$$/bin/m4/bin/m4",
2524
},
25+
"//conditions:default": {},
2626
}),
2727
lib_source = ":all_srcs",
2828
out_binaries = [
@@ -35,5 +35,12 @@ configure_make(
3535
"ifnames",
3636
],
3737
out_data_dirs = ["share"],
38-
target_compatible_with = ["@rules_foreign_cc_examples_third_party//:broken"],
38+
toolchains = ["@rules_perl//:current_toolchain"],
39+
)
40+
41+
filegroup(
42+
name = "gen_dir",
43+
srcs = [":autoconf"],
44+
output_group = "gen_dir",
45+
visibility = ["//visibility:public"],
3946
)

examples/third_party/autotools/BUILD.automake.bazel

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,33 @@ filegroup(
1313
configure_make(
1414
name = "automake",
1515
build_data = [
16-
"@autoconf",
17-
"@m4",
16+
"@autoconf//:gen_dir",
17+
"@m4//:m4_exe",
1818
],
1919
env = {
20-
"AC_MACRODIR": "$$EXT_BUILD_DEPS$$/bin/autoconf/share/autoconf",
21-
"AUTOM4TE": "$$EXT_BUILD_DEPS$$/bin/autoconf/bin/autom4te",
22-
"M4": "$$EXT_BUILD_DEPS$$/bin/m4/bin/m4",
23-
"PERL": "$$EXT_BUILD_ROOT$$/$(PERL)",
24-
"autom4te_perllibdir": "$$EXT_BUILD_DEPS$$/bin/autoconf/share/autoconf",
20+
"AC_MACRODIR": "$$EXT_BUILD_ROOT/$(location @autoconf//:gen_dir)/share/autoconf",
21+
"AUTOCONF": "$$EXT_BUILD_ROOT/$(location @autoconf//:gen_dir)/bin/autoconf",
22+
"AUTOHEADER": "$$EXT_BUILD_ROOT/$(location @autoconf//:gen_dir)/bin/autoheader",
23+
"AUTOM4TE": "$$EXT_BUILD_ROOT/$(location @autoconf//:gen_dir)/bin/autom4te",
24+
"AUTORECONF": "$$EXT_BUILD_ROOT/$(location @autoconf//:gen_dir)/bin/autoreconf)",
25+
"M4": "$$EXT_BUILD_ROOT/$(location @m4//:m4_exe)",
26+
"PATH": "$$EXT_BUILD_ROOT/$(location @autoconf//:gen_dir)/bin:$$PATH",
27+
"PERL": "$$EXT_BUILD_ROOT/$(PERL)",
28+
"autom4te_perllibdir": "$$EXT_BUILD_ROOT/$(location @autoconf//:gen_dir)/share/autoconf",
2529
},
2630
lib_source = ":all_srcs",
2731
out_binaries = [
32+
"aclocal",
2833
"automake",
2934
],
3035
# doesn't work on any platform currently, due to autoconf
3136
target_compatible_with = ["@rules_foreign_cc_examples_third_party//:broken"],
3237
toolchains = ["@rules_perl//:current_toolchain"],
3338
)
39+
40+
filegroup(
41+
name = "gen_dir",
42+
srcs = [":automake"],
43+
output_group = "gen_dir",
44+
visibility = ["//visibility:public"],
45+
)

examples/third_party/autotools/BUILD.libtool.bazel

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@ filegroup(
1313
configure_make(
1414
name = "libtool",
1515
build_data = [
16-
"@m4",
16+
"@m4//:m4_exe",
1717
],
18-
env = select({
18+
env = {
19+
"M4": "$$EXT_BUILD_ROOT/$(location @m4//:m4_exe)",
20+
} | select({
1921
"@platforms//os:macos": {
2022
"AR": "",
21-
"M4": "$$EXT_BUILD_DEPS$$/bin/m4/bin/m4",
2223
},
23-
"//conditions:default": {"M4": "$$EXT_BUILD_DEPS$$/bin/m4/bin/m4"},
24+
"//conditions:default": {},
2425
}),
2526
install_prefix = "install",
2627
lib_source = ":all_srcs",

examples/third_party/bison/BUILD.bison.bazel

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,14 @@ filegroup(
1414
configure_make(
1515
name = "bison",
1616
build_data = [
17-
"@m4",
17+
"@m4//:m4_exe",
1818
],
19-
env = select({
20-
"@platforms//os:linux": {
21-
"M4": "$$EXT_BUILD_DEPS$$/bin/m4/bin/m4",
22-
},
19+
env = {
20+
"M4": "$$EXT_BUILD_ROOT/$(location @m4//:m4_exe)",
21+
"PERL": "$$EXT_BUILD_ROOT/$(PERL)",
22+
} | select({
2323
"@platforms//os:macos": {
2424
"AR": "",
25-
"M4": "$$EXT_BUILD_DEPS$$/bin/m4/bin/m4",
2625
},
2726
"//conditions:default": {},
2827
}),
@@ -34,7 +33,12 @@ configure_make(
3433
# Bison depends on m4sugar.m4 in the "share" directory at runtime
3534
out_data_dirs = ["share"],
3635
out_static_libs = ["liby.a"],
37-
target_compatible_with = ["@rules_foreign_cc_examples_third_party//:broken"],
36+
target_compatible_with = select({
37+
"@platforms//os:macos": ["@rules_foreign_cc_examples_third_party//:broken"],
38+
"@platforms//os:windows": ["@platforms//:incompatible"],
39+
"//conditions:default": [],
40+
}),
41+
toolchains = ["@rules_perl//:current_toolchain"],
3842
)
3943

4044
filegroup(

examples/third_party/curl/BUILD.curl.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ _MACOS_CACHE_ENTRIES = dict(_CACHE_ENTRIES.items() + {
2424

2525
_LINUX_CACHE_ENTRIES = dict(_CACHE_ENTRIES.items() + {
2626
"CMAKE_C_FLAGS": "-fPIC",
27+
"PERL_EXECUTABLE": "$$EXT_BUILD_ROOT/$(PERL)",
2728
}.items())
2829

2930
cmake(
@@ -49,6 +50,7 @@ cmake(
4950
"@platforms//os:windows": ["libcurl.lib"],
5051
"//conditions:default": ["libcurl.a"],
5152
}),
53+
toolchains = ["@rules_perl//:current_toolchain"],
5254
visibility = ["//visibility:public"],
5355
deps = [
5456
"@examples_zlib//:zlib",

examples/third_party/glib/BUILD.glib.bazel

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,19 @@ meson(
2929
],
3030
"//conditions:default": [],
3131
}),
32-
env = select({
32+
env = {
33+
"PATH": "$$(dirname $$EXT_BUILD_ROOT/$(PYTHON3)):$$PATH",
34+
} | select({
3335
":msvc_compiler": {
3436
"INCLUDE": "$$EXT_BUILD_DEPS/include",
3537
"LIB": "$$EXT_BUILD_DEPS/lib",
36-
"PATH": "$$EXT_BUILD_DEPS/lib:$$(dirname $$EXT_BUILD_ROOT$$/$(PYTHON3)):$$PATH",
38+
"PATH": "$$EXT_BUILD_DEPS/lib:$$(dirname $$EXT_BUILD_ROOT/$(PYTHON3)):$$PATH",
3739
},
3840
"@platforms//os:macos": {
3941
"CPATH": "$$EXT_BUILD_DEPS/gettext/include",
4042
"LIBRARY_PATH": "$$EXT_BUILD_DEPS/gettext/lib",
41-
"PATH": "$$(dirname $$EXT_BUILD_ROOT$$/$(PYTHON3)):$$PATH",
42-
},
43-
"//conditions:default": {
44-
"PATH": "$$(dirname $$EXT_BUILD_ROOT$$/$(PYTHON3)):$$PATH",
4543
},
44+
"//conditions:default": {},
4645
}),
4746
lib_source = ":all_srcs",
4847
options = {

examples/third_party/mesa/BUILD.flex.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ configure_make(
2323
}),
2424
env = select({
2525
"@platforms//os:linux": {
26-
"PATH": "$$(dirname $$EXT_BUILD_ROOT$$/$(location @m4//:m4_exe)):$$PATH",
26+
"PATH": "$$(dirname $$EXT_BUILD_ROOT/$(location @m4//:m4_exe)):$$PATH",
2727
},
2828
"@platforms//os:macos": {
2929
"AR": "",
30-
"PATH": "$$(dirname $$EXT_BUILD_ROOT$$/$(location @m4//:m4_exe)):$$PATH",
30+
"PATH": "$$(dirname $$EXT_BUILD_ROOT/$(location @m4//:m4_exe)):$$PATH",
3131
},
3232
"//conditions:default": {},
3333
}),

examples/third_party/mesa/BUILD.libxcb.bazel

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,14 @@ configure_make(
2020
env = select({
2121
"@platforms//os:macos": {
2222
"AR": "",
23+
"PYTHON": "$$EXT_BUILD_ROOT/$(PYTHON3)",
24+
},
25+
"//conditions:default": {
26+
"PYTHON": "$$EXT_BUILD_ROOT/$(PYTHON3)",
2327
},
24-
"//conditions:default": {},
2528
}),
2629
lib_source = ":all_srcs",
30+
toolchains = ["@rules_python//python:current_py_toolchain"],
2731
deps = select({
2832
"@platforms//os:macos": DEPS + ["@libpthread-stubs"],
2933
"//conditions:default": DEPS,

examples/third_party/mesa/BUILD.mesa.bazel

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ meson_with_requirements(
3030
}),
3131
env = select({
3232
"@bazel_tools//src/conditions:host_windows": {
33-
"PATH": "$$(dirname $$EXT_BUILD_ROOT$$/$(location @winflexbison//:gen_dir))/winflexbison:$$(dirname $$EXT_BUILD_ROOT$$/$(PYTHON3)):$$PATH",
33+
"PATH": "$$(dirname $$EXT_BUILD_ROOT/$(location @winflexbison//:gen_dir))/winflexbison:$$(dirname $$EXT_BUILD_ROOT/$(PYTHON3)):$$PATH",
3434
},
3535
"//conditions:default": {
36-
"BISON_PKGDATADIR": "$$(dirname $$EXT_BUILD_ROOT$$/$(location @bison//:gen_dir))/bison/share/bison",
37-
"M4": "$$EXT_BUILD_ROOT$$/$(location @m4//:m4_exe)",
38-
"PATH": "$$(dirname $$EXT_BUILD_ROOT$$/$(location @bison//:gen_dir))/bison/bin:$$(dirname $$EXT_BUILD_ROOT$$/$(location @flex//:flex_exe)):$$EXT_BUILD_DEPS$$/bin/m4/bin/:$$(dirname $$EXT_BUILD_ROOT$$/$(PYTHON3)):$$PATH",
36+
"BISON_PKGDATADIR": "$$(dirname $$EXT_BUILD_ROOT/$(location @bison//:gen_dir))/bison/share/bison",
37+
"M4": "$$EXT_BUILD_ROOT/$(location @m4//:m4_exe)",
38+
"PATH": "$$(dirname $$EXT_BUILD_ROOT/$(location @bison//:gen_dir))/bison/bin:$$(dirname $$EXT_BUILD_ROOT/$(location @flex//:flex_exe)):$$(dirname $$EXT_BUILD_ROOT/$(location @m4//:m4_exe)):$$(dirname $$EXT_BUILD_ROOT/$(PYTHON3)):$$PATH",
3939
},
4040
}),
4141
lib_source = ":all_srcs",

examples/third_party/mesa/BUILD.xcb-proto.bazel

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@ filegroup(
1212

1313
configure_make(
1414
name = "xcb-proto",
15+
env = {
16+
"PYTHON": "$$EXT_BUILD_ROOT/$(PYTHON3)",
17+
},
1518
lib_source = ":all_srcs",
1619
# Dependents of xcb-proto require this lib dir to be present in the bazel sandbox
1720
out_data_dirs = ["lib"],
1821
out_headers_only = True,
22+
toolchains = ["@rules_python//python:current_py_toolchain"],
1923
)

0 commit comments

Comments
 (0)