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

Add meson support #986

Merged
merged 8 commits into from
Jun 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions .bazelci/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ tasks:
- "//:third_party_examples_linux_rbe_tests"
# Gives error: zipalign: error while loading shared libraries: /usr/local/lib/libc++.so: file too short
- "-//cmake_android/..."
# Python requirements not supported onUbuntu 16.04
- "-//:requirements_test"
build_targets: *rbe_targets
test_targets: *rbe_targets
macos_examples_standalone:
Expand Down Expand Up @@ -120,10 +122,6 @@ tasks:
windows_examples:
name: Examples
platform: windows
# Ping MSVC version to 2017, since LLVM 11.0.0 is not yet available on Bazel CI.
# TODO: remove after https://github.com/bazelbuild/continuous-integration/pull/1433 is deployed.
environment:
BAZEL_VC: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC"
working_directory: examples
windows_targets: &windows_targets
- "//..."
Expand Down Expand Up @@ -218,7 +216,7 @@ tasks:
- "--experimental_enable_aggregating_middleman=False"
min_supported_version_examples:
name: "Minimum Supported Version Examples"
bazel: "4.0.0"
bazel: "4.2.0"
skip_in_bazel_downstream_pipeline: "Bazel 4 required"
platform: ubuntu1804
working_directory: examples
Expand Down
3 changes: 3 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use_repo(
"cmake_3.23.2_toolchains",
"cmake_src",
"gnumake_src",
"meson_src",
"ninja_1.11.1_toolchains",
"ninja_build_src",
"pkgconfig_src",
Expand All @@ -31,6 +32,8 @@ register_toolchains(
"@rules_foreign_cc_framework_toolchain_macos//:toolchain",
"@rules_foreign_cc_framework_toolchain_windows//:toolchain",
"@rules_foreign_cc//toolchains:built_make_toolchain",
"@rules_foreign_cc//toolchains:built_meson_toolchain",
"@rules_foreign_cc//toolchains:built_pkgconfig_toolchain",
"@rules_foreign_cc//toolchains:preinstalled_autoconf_toolchain",
"@rules_foreign_cc//toolchains:preinstalled_automake_toolchain",
"@rules_foreign_cc//toolchains:preinstalled_m4_toolchain",
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Documentation for all rules and providers are available at: https://bazelbuild.g

## Bazel versions compatibility

Works with Bazel after 4.0.0.
Works with Bazel after 4.2.0.

The following flags are required in Bazel 4.x but not Bazel 5.x or newer:

Expand Down
4 changes: 4 additions & 0 deletions WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ python_register_toolchains(
python_version = "3.9",
)

load("//:docs/stardoc_repository.bzl", "stardoc_repository")

stardoc_repository()

http_archive(
name = "bazelci_rules",
sha256 = "eca21884e6f66a88c358e580fd67a6b148d30ab57b1680f62a96c00f9bc6a07e",
Expand Down
8 changes: 8 additions & 0 deletions docs/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ stardoc(
deps = ["@rules_foreign_cc//:bzl_srcs"],
)

stardoc(
name = "meson_docs",
out = "stardoc_meson.md",
header_template = "common_header.vm",
input = "@rules_foreign_cc//foreign_cc:meson.bzl",
deps = ["@rules_foreign_cc//:bzl_srcs"],
)

stardoc(
name = "providers_docs",
out = "stardoc_providers.md",
Expand Down
9 changes: 8 additions & 1 deletion examples/.bazelrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
# Required for Windows
# Required by Meson on Windows
build --action_env=PROCESSOR_ARCHITECTURE
build --action_env=USERPROFILE

# Required when using the built meson toolchain on windows
build --nobuild_python_zip

# Required by Meson and built pkg-config on Windows
build --enable_runfiles

# These are required otherwise paths are too long
Expand Down
8 changes: 8 additions & 0 deletions examples/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
load("@rules_python//python/pip_install:requirements.bzl", "compile_pip_requirements")

# TODO: This should not be necessary but there appears to be some inconsistent
# behavior with the use of `constraint_value`s in `select` statements. A support
# thread was started at the end of https://github.com/bazelbuild/bazel/pull/12071
Expand Down Expand Up @@ -39,3 +41,9 @@ test_suite(
tags = ["manual"],
tests = ["@rules_foreign_cc_examples_third_party//:windows_tests"],
)

compile_pip_requirements(
name = "requirements",
requirements_in = "requirements.txt",
requirements_txt = "requirements_lock.txt",
)
33 changes: 33 additions & 0 deletions examples/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,44 @@ local_path_override(
tools = use_extension("@rules_foreign_cc//foreign_cc:extensions.bzl", "tools")
tools.cmake(version = "3.23.1")
tools.ninja(version = "1.11.1")
use_repo(
tools,
"meson_src",
)

bazel_dep(name = "platforms", version = "0.0.6")
bazel_dep(name = "rules_swift", version = "1.6.0", repo_name = "build_bazel_rules_swift")
bazel_dep(name = "rules_apple", version = "2.1.0", repo_name = "build_bazel_rules_apple")
bazel_dep(name = "apple_support", version = "1.4.1", repo_name = "build_bazel_apple_support")
bazel_dep(name = "rules_python", version = "0.22.0")

python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(
name = "python3_9",
python_version = "3.9",
)
use_repo(python, "python3_9")
use_repo(python, "python3_9_toolchains")

register_toolchains(
"@python3_9_toolchains//:all",
)

interpreter = use_extension("@rules_python//python/extensions:interpreter.bzl", "interpreter")
interpreter.install(
name = "interpreter_python3_9",
python_name = "python3_9",
)
use_repo(interpreter, "interpreter_python3_9")

pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
pip.parse(
name = "pip",
python_interpreter_target = "@interpreter_python3_9//:python",
requirements_lock = "//:requirements_lock.txt",
requirements_windows = "//:requirements_windows.txt",
)
use_repo(pip, "pip")

# bazel_dep(name = "rules_android", version = "0.1.1")
# bazel_dep(name = "rules_jvm_external", version = "5.1")
Expand Down
20 changes: 20 additions & 0 deletions examples/WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,26 @@ load("//deps:deps_jvm_external.bzl", "deps_jvm_external")

deps_jvm_external()

load("@rules_python//python:repositories.bzl", "python_register_toolchains")

python_register_toolchains(
name = "python3_9",
python_version = "3.9",
)

load("@python3_9//:defs.bzl", py3_interpreter = "interpreter")
load("@rules_python//python:pip.bzl", "pip_parse")

pip_parse(
name = "pip",
python_interpreter_target = py3_interpreter,
requirements_lock = "//:requirements_lock.txt",
)

load("@pip//:requirements.bzl", "install_deps")

install_deps()

local_repository(
name = "rules_foreign_cc_examples_third_party",
path = "third_party",
Expand Down
1 change: 1 addition & 0 deletions examples/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mako==1.2.1
52 changes: 52 additions & 0 deletions examples/requirements_lock.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#
# This file is autogenerated by pip-compile with python 3.9
# To update, run:
#
# bazel run //:requirements.update
#
mako==1.2.1 \
--hash=sha256:df3921c3081b013c8a2d5ff03c18375651684921ae83fd12e64800b7da923257 \
--hash=sha256:f054a5ff4743492f1aa9ecc47172cb33b42b9d993cffcc146c9de17e717b0307
# via -r requirements.txt
markupsafe==2.1.1 \
--hash=sha256:0212a68688482dc52b2d45013df70d169f542b7394fc744c02a57374a4207003 \
--hash=sha256:089cf3dbf0cd6c100f02945abeb18484bd1ee57a079aefd52cffd17fba910b88 \
--hash=sha256:10c1bfff05d95783da83491be968e8fe789263689c02724e0c691933c52994f5 \
--hash=sha256:33b74d289bd2f5e527beadcaa3f401e0df0a89927c1559c8566c066fa4248ab7 \
--hash=sha256:3799351e2336dc91ea70b034983ee71cf2f9533cdff7c14c90ea126bfd95d65a \
--hash=sha256:3ce11ee3f23f79dbd06fb3d63e2f6af7b12db1d46932fe7bd8afa259a5996603 \
--hash=sha256:421be9fbf0ffe9ffd7a378aafebbf6f4602d564d34be190fc19a193232fd12b1 \
--hash=sha256:43093fb83d8343aac0b1baa75516da6092f58f41200907ef92448ecab8825135 \
--hash=sha256:46d00d6cfecdde84d40e572d63735ef81423ad31184100411e6e3388d405e247 \
--hash=sha256:4a33dea2b688b3190ee12bd7cfa29d39c9ed176bda40bfa11099a3ce5d3a7ac6 \
--hash=sha256:4b9fe39a2ccc108a4accc2676e77da025ce383c108593d65cc909add5c3bd601 \
--hash=sha256:56442863ed2b06d19c37f94d999035e15ee982988920e12a5b4ba29b62ad1f77 \
--hash=sha256:671cd1187ed5e62818414afe79ed29da836dde67166a9fac6d435873c44fdd02 \
--hash=sha256:694deca8d702d5db21ec83983ce0bb4b26a578e71fbdbd4fdcd387daa90e4d5e \
--hash=sha256:6a074d34ee7a5ce3effbc526b7083ec9731bb3cbf921bbe1d3005d4d2bdb3a63 \
--hash=sha256:6d0072fea50feec76a4c418096652f2c3238eaa014b2f94aeb1d56a66b41403f \
--hash=sha256:6fbf47b5d3728c6aea2abb0589b5d30459e369baa772e0f37a0320185e87c980 \
--hash=sha256:7f91197cc9e48f989d12e4e6fbc46495c446636dfc81b9ccf50bb0ec74b91d4b \
--hash=sha256:86b1f75c4e7c2ac2ccdaec2b9022845dbb81880ca318bb7a0a01fbf7813e3812 \
--hash=sha256:8dc1c72a69aa7e082593c4a203dcf94ddb74bb5c8a731e4e1eb68d031e8498ff \
--hash=sha256:8e3dcf21f367459434c18e71b2a9532d96547aef8a871872a5bd69a715c15f96 \
--hash=sha256:8e576a51ad59e4bfaac456023a78f6b5e6e7651dcd383bcc3e18d06f9b55d6d1 \
--hash=sha256:96e37a3dc86e80bf81758c152fe66dbf60ed5eca3d26305edf01892257049925 \
--hash=sha256:97a68e6ada378df82bc9f16b800ab77cbf4b2fada0081794318520138c088e4a \
--hash=sha256:99a2a507ed3ac881b975a2976d59f38c19386d128e7a9a18b7df6fff1fd4c1d6 \
--hash=sha256:a49907dd8420c5685cfa064a1335b6754b74541bbb3706c259c02ed65b644b3e \
--hash=sha256:b09bf97215625a311f669476f44b8b318b075847b49316d3e28c08e41a7a573f \
--hash=sha256:b7bd98b796e2b6553da7225aeb61f447f80a1ca64f41d83612e6139ca5213aa4 \
--hash=sha256:b87db4360013327109564f0e591bd2a3b318547bcef31b468a92ee504d07ae4f \
--hash=sha256:bcb3ed405ed3222f9904899563d6fc492ff75cce56cba05e32eff40e6acbeaa3 \
--hash=sha256:d4306c36ca495956b6d568d276ac11fdd9c30a36f1b6eb928070dc5360b22e1c \
--hash=sha256:d5ee4f386140395a2c818d149221149c54849dfcfcb9f1debfe07a8b8bd63f9a \
--hash=sha256:dda30ba7e87fbbb7eab1ec9f58678558fd9a6b8b853530e176eabd064da81417 \
--hash=sha256:e04e26803c9c3851c931eac40c695602c6295b8d432cbe78609649ad9bd2da8a \
--hash=sha256:e1c0b87e09fa55a220f058d1d49d3fb8df88fbfab58558f1198e08c1e1de842a \
--hash=sha256:e72591e9ecd94d7feb70c1cbd7be7b3ebea3f548870aa91e2732960fa4d57a37 \
--hash=sha256:e8c843bbcda3a2f1e3c2ab25913c80a3c5376cd00c6e8c4a86a89a28c8dc5452 \
--hash=sha256:efc1913fd2ca4f334418481c7e595c00aad186563bbc1ec76067848c7ca0a933 \
--hash=sha256:f121a1420d4e173a5d96e47e9a0c0dcff965afdf1626d28de1460815f7c4ee7a \
--hash=sha256:fc7b548b17d238737688817ab67deebb30e8073c95749d55538ed473130ec0c7
# via mako
9 changes: 9 additions & 0 deletions examples/third_party/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ test_suite(
"//curl:curl_test_suite",
"//gn:gn_launch_test",
"//gperftools:test",
"//glib:glib_build_test",
"//libgit2:libgit2_build_test",
"//iconv:iconv_linux_build_test",
"//libjpeg_turbo:libjpeg_turbo_build_test",
"//libpng:test_libpng",
"//libssh2:libssh2_build_test",
"//log4cxx:log4cxx_build_test",
"//mesa:mesa_build_test",
"//openssl:openssl_test_suite",
"//pcre:pcre_build_test",
"//python:python_tests",
Expand All @@ -48,13 +50,16 @@ test_suite(
# "//bison:bison_build_test",
"//cares:test_c_ares",
"//curl:curl_test_suite",
"//glib:glib_build_test",
# Attempts to access git sha during configure of build so fails
# "//gn:gn_launch_test",
"//gperftools:test",
"//libgit2:libgit2_build_test",
"//libjpeg_turbo:libjpeg_turbo_build_test",
"//libpng:test_libpng",
"//libssh2:libssh2_build_test",
# Missing new enough automake to build mesa
#"//mesa:mesa_build_test",
"//openssl:openssl_test_suite",
"//pcre:pcre_build_test",
"//python:python_tests",
Expand All @@ -80,6 +85,7 @@ test_suite(
"//cares:test_c_ares",
"//cares:test_c_ares_ios",
"//curl:curl_test_suite",
"//glib:glib_build_test",
"//gn:gn_launch_test",
"//gperftools:test",
"//iconv:iconv_macos_build_test",
Expand All @@ -88,6 +94,7 @@ test_suite(
"//libpng:test_libpng",
"//libssh2:libssh2_build_test",
"//log4cxx:log4cxx_build_test",
"//mesa:mesa_build_test",
"//openssl:openssl_test_suite",
"//pcre:pcre_build_test",
"//python:python_tests",
Expand All @@ -103,6 +110,8 @@ test_suite(
"//apr:apr_build_test",
"//curl:curl_test_suite",
"//openssl:openssl_test_suite",
"//glib:glib_build_test",
"//mesa:mesa_build_test",
# TODO: Add more windows tests
],
)
1 change: 1 addition & 0 deletions examples/third_party/apr_util/BUILD.expat.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ configure_make(
"--without-docbook",
"--without-examples",
"--without-tests",
"CFLAGS='-fPIC'",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't love that this is required. Does features=["pic"] work for this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried features=["pic"] and -fPIC was not added to the compiler command line args :(

],
env = select({
"@platforms//os:macos": {"AR": ""},
Expand Down
7 changes: 7 additions & 0 deletions examples/third_party/autotools/BUILD.m4.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,10 @@ configure_make(
"m4",
],
)

filegroup(
name = "m4_exe",
srcs = [":m4"],
output_group = "m4",
visibility = ["//visibility:public"],
)
22 changes: 19 additions & 3 deletions examples/third_party/bison/BUILD.bison.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,29 @@ configure_make(
build_data = [
"@m4",
],
env = {
"M4": "$$EXT_BUILD_DEPS$$/bin/m4/bin/m4",
},
env = select({
"@platforms//os:linux": {
"M4": "$$EXT_BUILD_DEPS$$/bin/m4/bin/m4",
},
"@platforms//os:macos": {
"AR": "",
"M4": "$$EXT_BUILD_DEPS$$/bin/m4/bin/m4",
},
"//conditions:default": {},
}),
lib_source = ":all_srcs",
out_binaries = [
"bison",
"yacc",
],
# Bison depends on m4sugar.m4 in the "share" directory at runtime
out_data_dirs = ["share"],
out_static_libs = ["liby.a"],
)

filegroup(
name = "gen_dir",
srcs = [":bison"],
output_group = "gen_dir",
visibility = ["//visibility:public"],
)
16 changes: 16 additions & 0 deletions examples/third_party/glib/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
load("@bazel_skylib//rules:build_test.bzl", "build_test")

exports_files(
[
"BUILD.glib.bazel",
],
visibility = ["//visibility:public"],
)

build_test(
name = "glib_build_test",
targets = [
"@glib//:glib",
],
visibility = ["//:__pkg__"],
)
Loading