Add meson support (#986)
* Add meson support * Modify zlib to be detected via pkgconfig in dependent rules * Modify zlib and expat to be linked to shared libs in dependent rules * Add example usage of Meson rule This commit adds the glib library to the "examples" build. glib requires pcre2, so pcre and libgit2 (a dependent of pcre) have been updated/modified * Add example usage of meson_with_requirements macro This commit adds mesa to the "examples" build. This commit also changes the "examples" build to use the hermetic python toolchain provided by rules_foreign_cc. As such, the python toolchain built by rules_foreign_cc is no longer used, as it cannot be used in workspace rules, .e.g pip_parse(). As such, the python2 build has been removed from the examples as python2 is end-of-life. Until Bazel 4.2.0, the built-in android toolchain required Python 2. As such the minimum supported version has been upversioned to 4.2.0. Note that the BAZEL_VC env var was removed from CI as mesa requires MSVC 2019. * Set visibility for each target in foreign_cc_rule_variant * Apply formatting changes * Get meson examples working with bzlmod Note that a newer version of pkgconfig than that installed in ubuntu 20 must be used to build libxau, therefore the built_pkgconfig_toolchain is now registered
This commit is contained in:
parent
12ecb0419a
commit
3cbd0a9938
|
@ -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:
|
||||
|
@ -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
|
||||
- "//..."
|
||||
|
@ -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
|
||||
|
|
|
@ -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",
|
||||
|
@ -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",
|
||||
|
|
|
@ -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:
|
||||
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
@ -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",
|
||||
)
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
mako==1.2.1
|
|
@ -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
|
|
@ -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",
|
||||
|
@ -48,6 +50,7 @@ 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",
|
||||
|
@ -55,6 +58,8 @@ test_suite(
|
|||
"//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",
|
||||
|
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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
|
||||
],
|
||||
)
|
||||
|
|
|
@ -39,6 +39,7 @@ configure_make(
|
|||
"--without-docbook",
|
||||
"--without-examples",
|
||||
"--without-tests",
|
||||
"CFLAGS='-fPIC'",
|
||||
],
|
||||
env = select({
|
||||
"@platforms//os:macos": {"AR": ""},
|
||||
|
|
|
@ -21,3 +21,10 @@ configure_make(
|
|||
"m4",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "m4_exe",
|
||||
srcs = [":m4"],
|
||||
output_group = "m4",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
|
|
@ -16,13 +16,29 @@ configure_make(
|
|||
build_data = [
|
||||
"@m4",
|
||||
],
|
||||
env = {
|
||||
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"],
|
||||
)
|
||||
|
|
|
@ -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__"],
|
||||
)
|
|
@ -0,0 +1,48 @@
|
|||
load("@rules_foreign_cc//foreign_cc:defs.bzl", "configure_make")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
filegroup(
|
||||
name = "all_srcs",
|
||||
srcs = glob(
|
||||
include = ["**"],
|
||||
exclude = ["*.bazel"],
|
||||
),
|
||||
)
|
||||
|
||||
configure_make(
|
||||
name = "gettext",
|
||||
env = select({
|
||||
"@platforms//os:macos": {
|
||||
"AR": "",
|
||||
},
|
||||
"//conditions:default": {},
|
||||
}),
|
||||
lib_source = ":all_srcs",
|
||||
out_shared_libs = select({
|
||||
"@platforms//os:macos": [
|
||||
"libgettextlib.dylib",
|
||||
"libgettextpo.0.dylib",
|
||||
"libasprintf.dylib",
|
||||
"libgettextlib-0.21.1.dylib",
|
||||
"libintl.dylib",
|
||||
"libtextstyle.0.dylib",
|
||||
"libintl.8.dylib",
|
||||
"libasprintf.0.dylib",
|
||||
"libgettextsrc.dylib",
|
||||
"libtextstyle.dylib",
|
||||
"libgettextsrc-0.21.1.dylib",
|
||||
"libgettextpo.dylib",
|
||||
],
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
out_static_libs = select({
|
||||
"@platforms//os:macos": [
|
||||
"libasprintf.a",
|
||||
"libgettextpo.a",
|
||||
"libintl.a",
|
||||
"libtextstyle.a",
|
||||
],
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
)
|
|
@ -0,0 +1,17 @@
|
|||
load("@bazel_skylib//rules:copy_file.bzl", "copy_file")
|
||||
load("@rules_cc//cc:defs.bzl", "cc_import")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
copy_file(
|
||||
name = "libint_dll",
|
||||
src = "lib/libintl.dll.a",
|
||||
out = "libintl.dll",
|
||||
)
|
||||
|
||||
cc_import(
|
||||
name = "gettext",
|
||||
hdrs = glob(["include/**"]),
|
||||
interface_library = "lib/intl.lib",
|
||||
shared_library = ":libint_dll",
|
||||
)
|
|
@ -0,0 +1,87 @@
|
|||
load("@rules_foreign_cc//foreign_cc:defs.bzl", "meson")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
config_setting(
|
||||
name = "msvc_compiler",
|
||||
flag_values = {
|
||||
"@bazel_tools//tools/cpp:compiler": "msvc-cl",
|
||||
},
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all_srcs",
|
||||
srcs = glob(["**"]),
|
||||
)
|
||||
|
||||
DEPS = [
|
||||
"@libffi",
|
||||
"@pcre",
|
||||
"@zlib",
|
||||
]
|
||||
|
||||
meson(
|
||||
name = "glib",
|
||||
env = select({
|
||||
":msvc_compiler": {
|
||||
"INCLUDE": "$$EXT_BUILD_DEPS/include",
|
||||
"LIB": "$$EXT_BUILD_DEPS/lib",
|
||||
"PATH": "$$EXT_BUILD_DEPS/lib:$$(dirname $$EXT_BUILD_ROOT$$/$(PYTHON3)):$$PATH",
|
||||
},
|
||||
"@platforms//os:macos": {
|
||||
"CPATH": "$$EXT_BUILD_DEPS/gettext/include",
|
||||
"LIBRARY_PATH": "$$EXT_BUILD_DEPS/gettext/lib",
|
||||
"PATH": "$$(dirname $$EXT_BUILD_ROOT$$/$(PYTHON3)):$$PATH",
|
||||
},
|
||||
"//conditions:default": {
|
||||
"PATH": "$$(dirname $$EXT_BUILD_ROOT$$/$(PYTHON3)):$$PATH",
|
||||
},
|
||||
}),
|
||||
lib_source = ":all_srcs",
|
||||
options = {
|
||||
"tests": "false",
|
||||
},
|
||||
out_interface_libs = select({
|
||||
"@platforms//os:windows": [
|
||||
"gio-2.0.lib",
|
||||
"glib-2.0.lib",
|
||||
"gmodule-2.0.lib",
|
||||
"gobject-2.0.lib",
|
||||
"gthread-2.0.lib",
|
||||
],
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
out_lib_dir = select({
|
||||
"@platforms//os:linux": "lib/x86_64-linux-gnu",
|
||||
"//conditions:default": "lib",
|
||||
}),
|
||||
out_shared_libs = select({
|
||||
"@platforms//os:linux": [
|
||||
"libgio-2.0.so.0",
|
||||
"libglib-2.0.so.0",
|
||||
"libgmodule-2.0.so.0",
|
||||
"libgobject-2.0.so.0",
|
||||
"libgthread-2.0.so.0",
|
||||
],
|
||||
"@platforms//os:macos": [
|
||||
"libglib-2.0.dylib",
|
||||
"libgobject-2.0.dylib",
|
||||
"libgthread-2.0.dylib",
|
||||
"libgmodule-2.0.dylib",
|
||||
"libgio-2.0.dylib",
|
||||
],
|
||||
"@platforms//os:windows": [
|
||||
"gio-2.0-0.dll",
|
||||
"glib-2.0-0.dll",
|
||||
"gmodule-2.0-0.dll",
|
||||
"gobject-2.0-0.dll",
|
||||
"gthread-2.0-0.dll",
|
||||
],
|
||||
}),
|
||||
toolchains = ["@rules_python//python:current_py_toolchain"],
|
||||
deps = select({
|
||||
"@platforms//os:macos": DEPS + ["@gettext"],
|
||||
"@platforms//os:windows": DEPS + ["@gettext_win//:gettext"],
|
||||
"//conditions:default": DEPS,
|
||||
}),
|
||||
)
|
|
@ -0,0 +1,26 @@
|
|||
load("@rules_foreign_cc//foreign_cc:defs.bzl", "meson")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
filegroup(
|
||||
name = "all_srcs",
|
||||
srcs = glob(["**"]),
|
||||
)
|
||||
|
||||
meson(
|
||||
name = "libffi",
|
||||
lib_source = ":all_srcs",
|
||||
out_interface_libs = select({
|
||||
"@platforms//os:windows": ["ffi.lib"],
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
out_lib_dir = select({
|
||||
"@platforms//os:linux": "lib/x86_64-linux-gnu",
|
||||
"//conditions:default": "lib",
|
||||
}),
|
||||
out_shared_libs = select({
|
||||
"@platforms//os:linux": ["libffi.so.7.1.0"],
|
||||
"@platforms//os:macos": ["libffi.dylib"],
|
||||
"@platforms//os:windows": ["ffi-7.dll"],
|
||||
}),
|
||||
)
|
|
@ -0,0 +1,37 @@
|
|||
"""A module defining the third party dependency glib"""
|
||||
|
||||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
||||
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
|
||||
|
||||
def glib_repositories():
|
||||
maybe(
|
||||
http_archive,
|
||||
name = "glib",
|
||||
build_file = Label("//glib:BUILD.glib.bazel"),
|
||||
strip_prefix = "glib-2.75.0",
|
||||
sha256 = "6dde8e55cc4a2c83d96797120b08bcffb5f645b2e212164ae22d63c40e0e6360",
|
||||
url = "https://download.gnome.org/sources/glib/2.75/glib-2.75.0.tar.xz",
|
||||
)
|
||||
maybe(
|
||||
http_archive,
|
||||
name = "libffi",
|
||||
build_file = Label("//glib:BUILD.libffi.bazel"),
|
||||
strip_prefix = "libffi-meson-3.2.9999.3",
|
||||
sha256 = "0113d0f27ffe795158d06f56c9a7340fafc768586095b82a701c687ecb8e3672",
|
||||
url = "https://gitlab.freedesktop.org/gstreamer/meson-ports/libffi/-/archive/meson-3.2.9999.3/libffi-meson-3.2.9999.3.tar.gz",
|
||||
)
|
||||
maybe(
|
||||
http_archive,
|
||||
name = "gettext",
|
||||
build_file = Label("//glib:BUILD.gettext.bazel"),
|
||||
strip_prefix = "gettext-0.21.1",
|
||||
sha256 = "e8c3650e1d8cee875c4f355642382c1df83058bd5a11ee8555c0cf276d646d45",
|
||||
url = "https://ftp.gnu.org/gnu/gettext/gettext-0.21.1.tar.gz",
|
||||
)
|
||||
maybe(
|
||||
http_archive,
|
||||
name = "gettext_win",
|
||||
build_file = Label("//glib:BUILD.gettext_win.bazel"),
|
||||
sha256 = "0af0a6e2c26dd2c389b4cd5a473e121dad6ddf2f8dca38489c50858c7b8cdd9f",
|
||||
url = "https://download.gnome.org/binaries/win64/dependencies/gettext-runtime-dev_0.18.1.1-2_win64.zip",
|
||||
)
|
|
@ -20,7 +20,7 @@ _CACHE_ENTRIES = {
|
|||
|
||||
_LINUX_CACHE_ENTRIES = dict(_CACHE_ENTRIES.items() + {
|
||||
"CMAKE_C_FLAGS": "${CMAKE_C_FLAGS:-} -fPIC",
|
||||
"REGEX_BACKEND": "pcre",
|
||||
"REGEX_BACKEND": "pcre2",
|
||||
}.items())
|
||||
|
||||
cmake(
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
load("@bazel_skylib//rules:build_test.bzl", "build_test")
|
||||
|
||||
exports_files(
|
||||
[
|
||||
"BUILD.mesa.bazel",
|
||||
],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
build_test(
|
||||
name = "mesa_build_test",
|
||||
targets = [
|
||||
"@mesa//:mesa",
|
||||
],
|
||||
visibility = ["//:__pkg__"],
|
||||
)
|
|
@ -0,0 +1,42 @@
|
|||
load("@rules_foreign_cc//foreign_cc:defs.bzl", "configure_make")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
filegroup(
|
||||
name = "all_srcs",
|
||||
srcs = glob(
|
||||
include = ["**"],
|
||||
exclude = ["*.bazel"],
|
||||
),
|
||||
)
|
||||
|
||||
configure_make(
|
||||
name = "flex",
|
||||
build_data = select({
|
||||
"@platforms//os:windows": [],
|
||||
"//conditions:default": ["@m4//:m4_exe"],
|
||||
}),
|
||||
configure_options = select({
|
||||
# See https://github.com/westes/flex/issues/428#issuecomment-539277966
|
||||
"@platforms//os:linux": ["CFLAGS='-D_GNU_SOURCE'"],
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
env = select({
|
||||
"@platforms//os:linux": {
|
||||
"PATH": "$$(dirname $$EXT_BUILD_ROOT$$/$(location @m4//:m4_exe)):$$PATH",
|
||||
},
|
||||
"@platforms//os:macos": {
|
||||
"AR": "",
|
||||
"PATH": "$$(dirname $$EXT_BUILD_ROOT$$/$(location @m4//:m4_exe)):$$PATH",
|
||||
},
|
||||
"//conditions:default": {},
|
||||
}),
|
||||
lib_source = ":all_srcs",
|
||||
out_binaries = ["flex"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "flex_exe",
|
||||
srcs = [":flex"],
|
||||
output_group = "flex",
|
||||
)
|
|
@ -0,0 +1,26 @@
|
|||
load("@rules_foreign_cc//foreign_cc:defs.bzl", "meson")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
filegroup(
|
||||
name = "all_srcs",
|
||||
srcs = glob(["**"]),
|
||||
)
|
||||
|
||||
meson(
|
||||
name = "libdrm",
|
||||
lib_source = ":all_srcs",
|
||||
out_lib_dir = "lib/x86_64-linux-gnu",
|
||||
out_shared_libs = [
|
||||
"libdrm_amdgpu.so.1.0.0",
|
||||
"libdrm_intel.so.1.0.0",
|
||||
"libdrm_nouveau.so.2.0.0",
|
||||
"libdrm_nouveau.so",
|
||||
"libdrm_nouveau.so.2",
|
||||
"libdrm_radeon.so.1.0.1",
|
||||
"libdrm.so.2.4.0",
|
||||
"libdrm.so",
|
||||
"libdrm.so.2",
|
||||
],
|
||||
deps = ["@libpciaccess"],
|
||||
)
|
|
@ -0,0 +1,16 @@
|
|||
load("@rules_foreign_cc//foreign_cc:defs.bzl", "configure_make")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
filegroup(
|
||||
name = "all_srcs",
|
||||
srcs = glob(
|
||||
include = ["**"],
|
||||
exclude = ["*.bazel"],
|
||||
),
|
||||
)
|
||||
|
||||
configure_make(
|
||||
name = "libpciaccess",
|
||||
lib_source = ":all_srcs",
|
||||
)
|
|
@ -0,0 +1,17 @@
|
|||
load("@rules_foreign_cc//foreign_cc:defs.bzl", "configure_make")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
filegroup(
|
||||
name = "all_srcs",
|
||||
srcs = glob(
|
||||
include = ["**"],
|
||||
exclude = ["*.bazel"],
|
||||
),
|
||||
)
|
||||
|
||||
configure_make(
|
||||
name = "libpthread-stubs",
|
||||
lib_source = ":all_srcs",
|
||||
out_headers_only = True,
|
||||
)
|
|
@ -0,0 +1,29 @@
|
|||
load("@rules_foreign_cc//foreign_cc:defs.bzl", "configure_make")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
filegroup(
|
||||
name = "all_srcs",
|
||||
srcs = glob(
|
||||
include = ["**"],
|
||||
exclude = ["*.bazel"],
|
||||
),
|
||||
)
|
||||
|
||||
configure_make(
|
||||
name = "libx11",
|
||||
env = select({
|
||||
"@platforms//os:macos": {
|
||||
"AR": "",
|
||||
},
|
||||
"//conditions:default": {},
|
||||
}),
|
||||
lib_source = ":all_srcs",
|
||||
out_headers_only = True,
|
||||
deps = [
|
||||
"@libxau",
|
||||
"@libxcb",
|
||||
"@xorgproto",
|
||||
"@xtrans",
|
||||
],
|
||||
)
|
|
@ -0,0 +1,26 @@
|
|||
load("@rules_foreign_cc//foreign_cc:defs.bzl", "configure_make")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
filegroup(
|
||||
name = "all_srcs",
|
||||
srcs = glob(
|
||||
include = ["**"],
|
||||
exclude = ["*.bazel"],
|
||||
),
|
||||
)
|
||||
|
||||
configure_make(
|
||||
name = "libxau",
|
||||
env = select({
|
||||
"@platforms//os:macos": {
|
||||
"AR": "",
|
||||
},
|
||||
"//conditions:default": {},
|
||||
}),
|
||||
lib_source = ":all_srcs",
|
||||
out_headers_only = True,
|
||||
deps = [
|
||||
"@xorgproto",
|
||||
],
|
||||
)
|
|
@ -0,0 +1,31 @@
|
|||
load("@rules_foreign_cc//foreign_cc:defs.bzl", "configure_make")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
filegroup(
|
||||
name = "all_srcs",
|
||||
srcs = glob(
|
||||
include = ["**"],
|
||||
exclude = ["*.bazel"],
|
||||
),
|
||||
)
|
||||
|
||||
DEPS = [
|
||||
"@libxau",
|
||||
"@xcb-proto",
|
||||
]
|
||||
|
||||
configure_make(
|
||||
name = "libxcb",
|
||||
env = select({
|
||||
"@platforms//os:macos": {
|
||||
"AR": "",
|
||||
},
|
||||
"//conditions:default": {},
|
||||
}),
|
||||
lib_source = ":all_srcs",
|
||||
deps = select({
|
||||
"@platforms//os:macos": DEPS + ["@libpthread-stubs"],
|
||||
"//conditions:default": DEPS,
|
||||
}),
|
||||
)
|
|
@ -0,0 +1,20 @@
|
|||
load("@rules_foreign_cc//foreign_cc:defs.bzl", "configure_make")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
filegroup(
|
||||
name = "all_srcs",
|
||||
srcs = glob(
|
||||
include = ["**"],
|
||||
exclude = ["*.bazel"],
|
||||
),
|
||||
)
|
||||
|
||||
configure_make(
|
||||
name = "libxdmcp",
|
||||
lib_source = ":all_srcs",
|
||||
out_headers_only = True,
|
||||
deps = [
|
||||
"@xorgproto",
|
||||
],
|
||||
)
|
|
@ -0,0 +1,27 @@
|
|||
load("@rules_foreign_cc//foreign_cc:defs.bzl", "configure_make")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
filegroup(
|
||||
name = "all_srcs",
|
||||
srcs = glob(
|
||||
include = ["**"],
|
||||
exclude = ["*.bazel"],
|
||||
),
|
||||
)
|
||||
|
||||
configure_make(
|
||||
name = "libxext",
|
||||
env = select({
|
||||
"@platforms//os:macos": {
|
||||
"AR": "",
|
||||
},
|
||||
"//conditions:default": {},
|
||||
}),
|
||||
lib_source = ":all_srcs",
|
||||
out_headers_only = True,
|
||||
deps = [
|
||||
"@libx11",
|
||||
"@xorgproto",
|
||||
],
|
||||
)
|
|
@ -0,0 +1,29 @@
|
|||
load("@rules_foreign_cc//foreign_cc:defs.bzl", "configure_make")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
filegroup(
|
||||
name = "all_srcs",
|
||||
srcs = glob(
|
||||
include = ["**"],
|
||||
exclude = ["*.bazel"],
|
||||
),
|
||||
)
|
||||
|
||||
configure_make(
|
||||
name = "libxfixes",
|
||||
env = select({
|
||||
"@platforms//os:macos": {
|
||||
"AR": "",
|
||||
},
|
||||
"//conditions:default": {},
|
||||
}),
|
||||
lib_source = ":all_srcs",
|
||||
out_static_libs = [
|
||||
"libXfixes.a",
|
||||
],
|
||||
deps = [
|
||||
"@libx11",
|
||||
"@xorgproto",
|
||||
],
|
||||
)
|
|
@ -0,0 +1,23 @@
|
|||
load("@rules_foreign_cc//foreign_cc:defs.bzl", "configure_make")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
filegroup(
|
||||
name = "all_srcs",
|
||||
srcs = glob(
|
||||
include = ["**"],
|
||||
exclude = ["*.bazel"],
|
||||
),
|
||||
)
|
||||
|
||||
configure_make(
|
||||
name = "libxrandr",
|
||||
lib_source = ":all_srcs",
|
||||
out_headers_only = True,
|
||||
deps = [
|
||||
"@libx11",
|
||||
"@libxext",
|
||||
"@libxrender",
|
||||
"@renderproto",
|
||||
],
|
||||
)
|
|
@ -0,0 +1,21 @@
|
|||
load("@rules_foreign_cc//foreign_cc:defs.bzl", "configure_make")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
filegroup(
|
||||
name = "all_srcs",
|
||||
srcs = glob(
|
||||
include = ["**"],
|
||||
exclude = ["*.bazel"],
|
||||
),
|
||||
)
|
||||
|
||||
configure_make(
|
||||
name = "libxrender",
|
||||
lib_source = ":all_srcs",
|
||||
out_headers_only = True,
|
||||
deps = [
|
||||
"@libx11",
|
||||
"@renderproto",
|
||||
],
|
||||
)
|
|
@ -0,0 +1,19 @@
|
|||
load("@rules_foreign_cc//foreign_cc:defs.bzl", "configure_make")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
filegroup(
|
||||
name = "all_srcs",
|
||||
srcs = glob(
|
||||
include = ["**"],
|
||||
exclude = ["*.bazel"],
|
||||
),
|
||||
)
|
||||
|
||||
configure_make(
|
||||
name = "libxshmfence",
|
||||
lib_source = ":all_srcs",
|
||||
deps = [
|
||||
"@xorgproto",
|
||||
],
|
||||
)
|
|
@ -0,0 +1,121 @@
|
|||
load("@pip//:requirements.bzl", "requirement")
|
||||
load("@rules_foreign_cc//foreign_cc:defs.bzl", "meson_with_requirements")
|
||||
|
||||
filegroup(
|
||||
name = "all_srcs",
|
||||
srcs = glob(["**"]),
|
||||
)
|
||||
|
||||
config_setting(
|
||||
name = "msvc_compiler",
|
||||
flag_values = {
|
||||
"@bazel_tools//tools/cpp:compiler": "msvc-cl",
|
||||
},
|
||||
)
|
||||
|
||||
meson_with_requirements(
|
||||
name = "mesa",
|
||||
build_args = select({
|
||||
# Prevent parallel builds on when using winflexbison, due to issue https://github.com/lexxmark/winflexbison/issues/86
|
||||
"@bazel_tools//src/conditions:host_windows": ["-j 1"],
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
build_data = select({
|
||||
"@bazel_tools//src/conditions:host_windows": ["@winflexbison//:gen_dir"],
|
||||
"//conditions:default": [
|
||||
"@bison//:gen_dir",
|
||||
"@flex//:flex_exe",
|
||||
"@m4//:m4_exe",
|
||||
],
|
||||
}),
|
||||
env = select({
|
||||
"@bazel_tools//src/conditions:host_windows": {
|
||||
"PATH": "$$(dirname $$EXT_BUILD_ROOT$$/$(location @winflexbison//:gen_dir))/winflexbison:$$(dirname $$EXT_BUILD_ROOT$$/$(PYTHON3)):$$PATH",
|
||||
},
|
||||
"//conditions:default": {
|
||||
"BISON_PKGDATADIR": "$$(dirname $$EXT_BUILD_ROOT$$/$(location @bison//:gen_dir))/bison/share/bison",
|
||||
"M4": "$$EXT_BUILD_ROOT$$/$(location @m4//:m4_exe)",
|
||||
"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",
|
||||
},
|
||||
}),
|
||||
lib_source = ":all_srcs",
|
||||
options = select({
|
||||
"@platforms//os:linux": {
|
||||
# Disable LLVM support, as building LLVM in rules_foreign_cc CI would drastically increase the build time
|
||||
"gallium-drivers": "nouveau",
|
||||
"glx": "disabled",
|
||||
"llvm": "disabled",
|
||||
"platforms": "x11",
|
||||
"vulkan-drivers": "intel",
|
||||
},
|
||||
"//conditions:default": {},
|
||||
}),
|
||||
out_interface_libs = select({
|
||||
":msvc_compiler": [
|
||||
"libgallium_wgl.lib",
|
||||
"opengl32.lib",
|
||||
],
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
out_lib_dir = select({
|
||||
"@platforms//os:linux": "lib/x86_64-linux-gnu",
|
||||
"//conditions:default": "lib",
|
||||
}),
|
||||
out_shared_libs = select({
|
||||
":msvc_compiler": [
|
||||
"libgallium_wgl.dll",
|
||||
"opengl32.dll",
|
||||
],
|
||||
"@platforms//os:linux": [
|
||||
"libEGL.so",
|
||||
"libgbm.so",
|
||||
"libglapi.so",
|
||||
"libGLESv1_CM.so",
|
||||
"libGLESv2.so",
|
||||
"libvulkan_intel.so",
|
||||
"libxatracker.so",
|
||||
],
|
||||
"@platforms//os:macos": [
|
||||
"libGLESv1_CM.1.dylib",
|
||||
"libGL.dylib",
|
||||
"libGLESv1_CM.dylib",
|
||||
"libglapi.0.dylib",
|
||||
"libglapi.dylib",
|
||||
"libGLESv2.2.dylib",
|
||||
"libGL.1.dylib",
|
||||
"libGLESv2.dylib",
|
||||
],
|
||||
}),
|
||||
requirements = [
|
||||
requirement("mako"),
|
||||
],
|
||||
toolchains = ["@rules_python//python:current_py_toolchain"],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = select({
|
||||
"@platforms//os:linux": [
|
||||
"@bison",
|
||||
"@expat",
|
||||
"@libdrm",
|
||||
"@libpciaccess",
|
||||
"@libx11",
|
||||
"@libxau",
|
||||
"@libxcb",
|
||||
"@libxdmcp",
|
||||
"@libxext",
|
||||
"@libxrandr",
|
||||
"@libxrender",
|
||||
"@libxshmfence",
|
||||
"@xorgproto",
|
||||
"@zlib",
|
||||
],
|
||||
"@platforms//os:macos": [
|
||||
"@libx11",
|
||||
"@libxext",
|
||||
"@libxfixes",
|
||||
"@zlib",
|
||||
],
|
||||
"@platforms//os:windows": [
|
||||
"@zlib",
|
||||
],
|
||||
}),
|
||||
)
|
|
@ -0,0 +1,17 @@
|
|||
load("@rules_foreign_cc//foreign_cc:defs.bzl", "configure_make")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
filegroup(
|
||||
name = "all_srcs",
|
||||
srcs = glob(
|
||||
include = ["**"],
|
||||
exclude = ["*.bazel"],
|
||||
),
|
||||
)
|
||||
|
||||
configure_make(
|
||||
name = "renderproto",
|
||||
lib_source = ":all_srcs",
|
||||
out_headers_only = True,
|
||||
)
|
|
@ -0,0 +1,34 @@
|
|||
#load("@bazel_skylib//rules:native_binary.bzl", "native_binary")
|
||||
load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake")
|
||||
|
||||
filegroup(
|
||||
name = "all_srcs",
|
||||
# The winflexbison build outputs to the source tree, ignore the generated folder otherwise winflexbison will be rebuilt on every bazel invocation
|
||||
srcs = glob(
|
||||
include = ["**"],
|
||||
exclude = ["bin/**"],
|
||||
),
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
cmake(
|
||||
name = "winflexbison",
|
||||
generate_args = select({
|
||||
"@platforms//os:windows": ["-GNinja"],
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
lib_source = ":all_srcs",
|
||||
out_bin_dir = "",
|
||||
out_binaries = [
|
||||
"win_flex.exe",
|
||||
"win_bison.exe",
|
||||
],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "gen_dir",
|
||||
srcs = [":winflexbison"],
|
||||
output_group = "gen_dir",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
|
@ -0,0 +1,19 @@
|
|||
load("@rules_foreign_cc//foreign_cc:defs.bzl", "configure_make")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
filegroup(
|
||||
name = "all_srcs",
|
||||
srcs = glob(
|
||||
include = ["**"],
|
||||
exclude = ["*.bazel"],
|
||||
),
|
||||
)
|
||||
|
||||
configure_make(
|
||||
name = "xcb-proto",
|
||||
lib_source = ":all_srcs",
|
||||
# Dependents of xcb-proto require this lib dir to be present in the bazel sandbox
|
||||
out_data_dirs = ["lib"],
|
||||
out_headers_only = True,
|
||||
)
|
|
@ -0,0 +1,17 @@
|
|||
load("@rules_foreign_cc//foreign_cc:defs.bzl", "configure_make")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
filegroup(
|
||||
name = "all_srcs",
|
||||
srcs = glob(
|
||||
include = ["**"],
|
||||
exclude = ["*.bazel"],
|
||||
),
|
||||
)
|
||||
|
||||
configure_make(
|
||||
name = "xorgproto",
|
||||
lib_source = ":all_srcs",
|
||||
out_headers_only = True,
|
||||
)
|
|
@ -0,0 +1,17 @@
|
|||
load("@rules_foreign_cc//foreign_cc:defs.bzl", "configure_make")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
filegroup(
|
||||
name = "all_srcs",
|
||||
srcs = glob(
|
||||
include = ["**"],
|
||||
exclude = ["*.bazel"],
|
||||
),
|
||||
)
|
||||
|
||||
configure_make(
|
||||
name = "xtrans",
|
||||
lib_source = ":all_srcs",
|
||||
out_headers_only = True,
|
||||
)
|
|
@ -0,0 +1,19 @@
|
|||
--- meson.build 2022-07-15 18:42:47.000000000 +0100
|
||||
+++ meson.build 2022-11-30 17:26:50.607789896 +0000
|
||||
@@ -1002,7 +1002,7 @@
|
||||
]
|
||||
endif
|
||||
|
||||
-prog_python = import('python').find_installation('python3')
|
||||
+prog_python = import('python').find_installation()
|
||||
has_mako = run_command(
|
||||
prog_python, '-c',
|
||||
'''
|
||||
@@ -2033,6 +2033,7 @@
|
||||
endif
|
||||
|
||||
if with_platform_x11
|
||||
+ dep_x11 = dependency('x11')
|
||||
if with_glx == 'xlib' or with_glx == 'gallium-xlib'
|
||||
dep_x11 = dependency('x11')
|
||||
dep_xext = dependency('xext')
|
|
@ -0,0 +1,158 @@
|
|||
diff -uNr mesa-22.1.4/meson.build mesa-22.1.4.new/meson.build
|
||||
--- mesa-22.1.4/meson.build 2022-07-15 18:42:47.000000000 +0100
|
||||
+++ mesa-22.1.4.new/meson.build 2022-12-05 12:33:38.870379170 +0000
|
||||
@@ -1002,7 +1002,7 @@
|
||||
]
|
||||
endif
|
||||
|
||||
-prog_python = import('python').find_installation('python3')
|
||||
+prog_python = import('python').find_installation()
|
||||
has_mako = run_command(
|
||||
prog_python, '-c',
|
||||
'''
|
||||
@@ -2033,6 +2033,7 @@
|
||||
endif
|
||||
|
||||
if with_platform_x11
|
||||
+ dep_x11 = dependency('x11')
|
||||
if with_glx == 'xlib' or with_glx == 'gallium-xlib'
|
||||
dep_x11 = dependency('x11')
|
||||
dep_xext = dependency('xext')
|
||||
diff -uNr mesa-22.1.4/src/egl/meson.build mesa-22.1.4.new/src/egl/meson.build
|
||||
--- mesa-22.1.4/src/egl/meson.build 2022-07-15 18:42:47.000000000 +0100
|
||||
+++ mesa-22.1.4.new/src/egl/meson.build 2022-12-05 14:21:05.700235372 +0000
|
||||
@@ -106,7 +106,7 @@
|
||||
files_egl += files('drivers/dri2/platform_x11_dri3.c')
|
||||
link_for_egl += libloader_dri3_helper
|
||||
endif
|
||||
- deps_for_egl += [dep_x11_xcb, dep_xcb_dri2, dep_xcb_xfixes]
|
||||
+ deps_for_egl += [dep_x11_xcb, dep_xcb_dri2, dep_xcb_xfixes, dep_xlib_xrandr]
|
||||
endif
|
||||
if with_gbm and not with_platform_android
|
||||
files_egl += files('drivers/dri2/platform_drm.c')
|
||||
diff -uNr mesa-22.1.4/src/gallium/frontends/dri/dri_util.c mesa-22.1.4.new/src/gallium/frontends/dri/dri_util.c
|
||||
--- mesa-22.1.4/src/gallium/frontends/dri/dri_util.c 2022-07-15 18:42:47.000000000 +0100
|
||||
+++ mesa-22.1.4.new/src/gallium/frontends/dri/dri_util.c 2022-12-12 13:13:13.401778933 +0000
|
||||
@@ -171,6 +171,8 @@
|
||||
return psp;
|
||||
}
|
||||
|
||||
+#if defined(HAVE_LIBDRM)
|
||||
+
|
||||
static __DRIscreen *
|
||||
dri2CreateNewScreen(int scrn, int fd,
|
||||
const __DRIextension **extensions,
|
||||
@@ -191,6 +193,8 @@
|
||||
driver_configs, data);
|
||||
}
|
||||
|
||||
+#endif
|
||||
+
|
||||
/** swrast driver createNewScreen entrypoint. */
|
||||
static __DRIscreen *
|
||||
driSWRastCreateNewScreen(int scrn, const __DRIextension **extensions,
|
||||
@@ -808,6 +812,8 @@
|
||||
.unbindContext = driUnbindContext
|
||||
};
|
||||
|
||||
+#if defined(HAVE_LIBDRM)
|
||||
+
|
||||
/** DRI2 interface */
|
||||
const __DRIdri2Extension driDRI2Extension = {
|
||||
.base = { __DRI_DRI2, 4 },
|
||||
@@ -837,6 +843,8 @@
|
||||
.createNewScreen2 = driCreateNewScreen2,
|
||||
};
|
||||
|
||||
+#endif
|
||||
+
|
||||
const __DRIswrastExtension driSWRastExtension = {
|
||||
.base = { __DRI_SWRAST, 4 },
|
||||
|
||||
diff -uNr mesa-22.1.4/src/gallium/frontends/dri/meson.build mesa-22.1.4.new/src/gallium/frontends/dri/meson.build
|
||||
--- mesa-22.1.4/src/gallium/frontends/dri/meson.build 2022-07-15 18:42:47.000000000 +0100
|
||||
+++ mesa-22.1.4.new/src/gallium/frontends/dri/meson.build 2022-12-12 10:20:49.540287708 +0000
|
||||
@@ -71,6 +71,9 @@
|
||||
dependencies : [
|
||||
dep_libdrm,
|
||||
idep_mesautil,
|
||||
+ dep_xcb,
|
||||
+ dep_x11,
|
||||
+ dep_xlib_xrandr
|
||||
],
|
||||
)
|
||||
|
||||
diff -uNr mesa-22.1.4/src/gallium/targets/dri/meson.build mesa-22.1.4.new/src/gallium/targets/dri/meson.build
|
||||
--- mesa-22.1.4/src/gallium/targets/dri/meson.build 2022-07-15 18:42:47.000000000 +0100
|
||||
+++ mesa-22.1.4.new/src/gallium/targets/dri/meson.build 2022-12-05 14:02:15.710260576 +0000
|
||||
@@ -58,7 +58,7 @@
|
||||
driver_kmsro, driver_v3d, driver_vc4, driver_freedreno, driver_etnaviv,
|
||||
driver_tegra, driver_i915, driver_svga, driver_virgl,
|
||||
driver_panfrost, driver_iris, driver_lima, driver_zink, driver_d3d12,
|
||||
- driver_asahi, driver_crocus
|
||||
+ driver_asahi, driver_crocus, dep_xcb
|
||||
],
|
||||
# Will be deleted during installation, see install_megadrivers.py
|
||||
install : true,
|
||||
diff -uNr mesa-22.1.4/src/gbm/meson.build mesa-22.1.4.new/src/gbm/meson.build
|
||||
--- mesa-22.1.4/src/gbm/meson.build 2022-07-15 18:42:47.000000000 +0100
|
||||
+++ mesa-22.1.4.new/src/gbm/meson.build 2022-12-05 13:11:53.570327986 +0000
|
||||
@@ -44,6 +44,9 @@
|
||||
deps_gbm += dep_wayland_server
|
||||
incs_gbm += inc_wayland_drm
|
||||
endif
|
||||
+if with_platform_x11
|
||||
+ deps_gbm += dep_xcb dep_x11
|
||||
+endif
|
||||
|
||||
libgbm = shared_library(
|
||||
'gbm',
|
||||
diff -uNr mesa-22.1.4/src/glx/meson.build mesa-22.1.4.new/src/glx/meson.build
|
||||
--- mesa-22.1.4/src/glx/meson.build 2022-07-15 18:42:47.000000000 +0100
|
||||
+++ mesa-22.1.4.new/src/glx/meson.build 2022-12-12 09:36:07.300346991 +0000
|
||||
@@ -136,7 +136,7 @@
|
||||
],
|
||||
dependencies : [
|
||||
idep_mesautil, idep_xmlconfig,
|
||||
- dep_libdrm, dep_dri2proto, dep_glproto, dep_x11, dep_glvnd,
|
||||
+ dep_libdrm, dep_dri2proto, dep_glproto, dep_x11, dep_glvnd, dep_xext,
|
||||
],
|
||||
)
|
||||
|
||||
diff -uNr mesa-22.1.4/src/intel/vulkan/meson.build mesa-22.1.4.new/src/intel/vulkan/meson.build
|
||||
--- mesa-22.1.4/src/intel/vulkan/meson.build 2022-07-15 18:42:47.000000000 +0100
|
||||
+++ mesa-22.1.4.new/src/intel/vulkan/meson.build 2022-11-30 18:21:07.247725902 +0000
|
||||
@@ -95,7 +95,7 @@
|
||||
dependencies : [
|
||||
dep_libdrm, dep_valgrind, idep_nir_headers, idep_genxml,
|
||||
idep_vulkan_util_headers, idep_vulkan_wsi_headers,
|
||||
- idep_vulkan_runtime_headers, idep_intel_driver_ds_headers,
|
||||
+ idep_vulkan_runtime_headers, idep_intel_driver_ds_headers, dep_x11,
|
||||
],
|
||||
)
|
||||
endforeach
|
||||
diff -uNr mesa-22.1.4/src/loader/meson.build mesa-22.1.4.new/src/loader/meson.build
|
||||
--- mesa-22.1.4/src/loader/meson.build 2022-07-15 18:42:47.000000000 +0100
|
||||
+++ mesa-22.1.4.new/src/loader/meson.build 2022-11-30 17:26:20.047790496 +0000
|
||||
@@ -28,7 +28,7 @@
|
||||
include_directories : [inc_include, inc_src],
|
||||
dependencies : [
|
||||
dep_libdrm, dep_xcb_dri3, dep_xcb_present, dep_xcb_sync, dep_xshmfence,
|
||||
- dep_xcb_xfixes,
|
||||
+ dep_xcb_xfixes, dep_x11_xcb
|
||||
],
|
||||
build_by_default : false,
|
||||
)
|
||||
diff -uNr mesa-22.1.4/src/vulkan/util/meson.build mesa-22.1.4.new/src/vulkan/util/meson.build
|
||||
--- mesa-22.1.4/src/vulkan/util/meson.build 2022-07-15 18:42:47.000000000 +0100
|
||||
+++ mesa-22.1.4.new/src/vulkan/util/meson.build 2022-12-05 12:46:26.270362053 +0000
|
||||
@@ -105,7 +105,8 @@
|
||||
|
||||
idep_vulkan_util_headers = declare_dependency(
|
||||
sources : [vk_dispatch_table[1], vk_enum_to_str[1], vk_extensions[1]],
|
||||
- include_directories : include_directories('.')
|
||||
+ include_directories : include_directories('.'),
|
||||
+ dependencies : [dep_xcb, dep_x11, dep_xcb_xrandr]
|
||||
)
|
||||
|
||||
idep_vulkan_util = declare_dependency(
|
|
@ -0,0 +1,11 @@
|
|||
--- src/egl/meson.build 2022-07-15 18:42:47.000000000 +0100
|
||||
+++ src/egl/meson.build 2022-12-05 14:21:05.700235372 +0000
|
||||
@@ -106,7 +106,7 @@
|
||||
files_egl += files('drivers/dri2/platform_x11_dri3.c')
|
||||
link_for_egl += libloader_dri3_helper
|
||||
endif
|
||||
- deps_for_egl += [dep_x11_xcb, dep_xcb_dri2, dep_xcb_xfixes]
|
||||
+ deps_for_egl += [dep_x11_xcb, dep_xcb_dri2, dep_xcb_xfixes, dep_xlib_xrandr]
|
||||
endif
|
||||
if with_gbm and not with_platform_android
|
||||
files_egl += files('drivers/dri2/platform_drm.c')
|
|
@ -0,0 +1,38 @@
|
|||
--- src/gallium/frontends/dri/dri_util.c 2022-07-15 18:42:47.000000000 +0100
|
||||
+++ src/gallium/frontends/dri/dri_util.c 2022-12-12 12:58:00.161799118 +0000
|
||||
@@ -171,6 +171,8 @@
|
||||
return psp;
|
||||
}
|
||||
|
||||
+#if defined(HAVE_LIBDRM)
|
||||
+
|
||||
static __DRIscreen *
|
||||
dri2CreateNewScreen(int scrn, int fd,
|
||||
const __DRIextension **extensions,
|
||||
@@ -191,6 +193,8 @@
|
||||
driver_configs, data);
|
||||
}
|
||||
|
||||
+#endif
|
||||
+
|
||||
/** swrast driver createNewScreen entrypoint. */
|
||||
static __DRIscreen *
|
||||
driSWRastCreateNewScreen(int scrn, const __DRIextension **extensions,
|
||||
@@ -808,6 +812,8 @@
|
||||
.unbindContext = driUnbindContext
|
||||
};
|
||||
|
||||
+#if defined(HAVE_LIBDRM)
|
||||
+
|
||||
/** DRI2 interface */
|
||||
const __DRIdri2Extension driDRI2Extension = {
|
||||
.base = { __DRI_DRI2, 4 },
|
||||
@@ -837,6 +843,8 @@
|
||||
.createNewScreen2 = driCreateNewScreen2,
|
||||
};
|
||||
|
||||
+#endif
|
||||
+
|
||||
const __DRIswrastExtension driSWRastExtension = {
|
||||
.base = { __DRI_SWRAST, 4 },
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
--- src/gallium/frontends/dri/meson.build 2022-07-15 18:42:47.000000000 +0100
|
||||
+++ src/gallium/frontends/dri/meson.build 2022-12-05 13:22:50.210313339 +0000
|
||||
@@ -71,6 +71,9 @@
|
||||
dependencies : [
|
||||
dep_libdrm,
|
||||
idep_mesautil,
|
||||
+ dep_xcb,
|
||||
+ dep_x11,
|
||||
+ dep_xlib_xrandr
|
||||
],
|
||||
)
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
--- src/gallium/targets/dri/meson.build 2022-07-15 18:42:47.000000000 +0100
|
||||
+++ src/gallium/targets/dri/meson.build 2022-12-05 14:02:15.710260576 +0000
|
||||
@@ -58,7 +58,7 @@
|
||||
driver_kmsro, driver_v3d, driver_vc4, driver_freedreno, driver_etnaviv,
|
||||
driver_tegra, driver_i915, driver_svga, driver_virgl,
|
||||
driver_panfrost, driver_iris, driver_lima, driver_zink, driver_d3d12,
|
||||
- driver_asahi, driver_crocus
|
||||
+ driver_asahi, driver_crocus, dep_xcb, dep_x11, dep_xlib_xrandr
|
||||
],
|
||||
# Will be deleted during installation, see install_megadrivers.py
|
||||
install : true,
|
|
@ -0,0 +1,13 @@
|
|||
|
||||
--- src/gbm/meson.build 2022-07-15 18:42:47.000000000 +0100
|
||||
+++ src/gbm/meson.build 2022-12-05 13:01:49.660341456 +0000
|
||||
@@ -44,6 +44,9 @@
|
||||
deps_gbm += dep_wayland_server
|
||||
incs_gbm += inc_wayland_drm
|
||||
endif
|
||||
+if with_platform_x11
|
||||
+ deps_gbm += [dep_xcb, dep_x11, dep_xlib_xrandr]
|
||||
+endif
|
||||
|
||||
libgbm = shared_library(
|
||||
'gbm',
|
|
@ -0,0 +1,11 @@
|
|||
--- src/glx/meson.build 2022-07-15 18:42:47.000000000 +0100
|
||||
+++ src/glx/meson.build 2022-12-12 09:36:07.300346991 +0000
|
||||
@@ -136,7 +136,7 @@
|
||||
],
|
||||
dependencies : [
|
||||
idep_mesautil, idep_xmlconfig,
|
||||
- dep_libdrm, dep_dri2proto, dep_glproto, dep_x11, dep_glvnd,
|
||||
+ dep_libdrm, dep_dri2proto, dep_glproto, dep_x11, dep_glvnd, dep_xext,
|
||||
],
|
||||
)
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
--- src/intel/vulkan/meson.build 2022-07-15 18:42:47.000000000 +0100
|
||||
+++ src/intel/vulkan/meson.build 2022-11-30 18:21:07.247725902 +0000
|
||||
@@ -95,7 +95,7 @@
|
||||
dependencies : [
|
||||
dep_libdrm, dep_valgrind, idep_nir_headers, idep_genxml,
|
||||
idep_vulkan_util_headers, idep_vulkan_wsi_headers,
|
||||
- idep_vulkan_runtime_headers, idep_intel_driver_ds_headers,
|
||||
+ idep_vulkan_runtime_headers, idep_intel_driver_ds_headers, dep_x11,
|
||||
],
|
||||
)
|
||||
endforeach
|
|
@ -0,0 +1,11 @@
|
|||
--- src/loader/meson.build 2022-07-15 18:42:47.000000000 +0100
|
||||
+++ src/loader/meson.build 2022-11-30 17:26:20.047790496 +0000
|
||||
@@ -28,7 +28,7 @@
|
||||
include_directories : [inc_include, inc_src],
|
||||
dependencies : [
|
||||
dep_libdrm, dep_xcb_dri3, dep_xcb_present, dep_xcb_sync, dep_xshmfence,
|
||||
- dep_xcb_xfixes,
|
||||
+ dep_xcb_xfixes, dep_x11_xcb
|
||||
],
|
||||
build_by_default : false,
|
||||
)
|
|
@ -0,0 +1,12 @@
|
|||
--- src/vulkan/util/meson.build 2022-07-15 18:42:47.000000000 +0100
|
||||
+++ src/vulkan/util/meson.build 2022-11-30 17:35:23.627779815 +0000
|
||||
@@ -105,7 +105,8 @@
|
||||
|
||||
idep_vulkan_util_headers = declare_dependency(
|
||||
sources : [vk_dispatch_table[1], vk_enum_to_str[1], vk_extensions[1]],
|
||||
- include_directories : include_directories('.')
|
||||
+ include_directories : include_directories('.'),
|
||||
+ dependencies : [dep_xcb, dep_x11, dep_xlib_xrandr]
|
||||
)
|
||||
|
||||
idep_vulkan_util = declare_dependency(
|
|
@ -0,0 +1,192 @@
|
|||
"""A module defining the third party dependency mesa"""
|
||||
|
||||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
||||
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
|
||||
|
||||
# buildifier: disable=function-docstring
|
||||
def mesa_repositories():
|
||||
maybe(
|
||||
http_archive,
|
||||
name = "mesa",
|
||||
build_file = Label("//mesa:BUILD.mesa.bazel"),
|
||||
patches = [
|
||||
# This patch is required for meson to find the hermetic python interpreter
|
||||
Label("//mesa:mesa.meson.build.patch"),
|
||||
# The following patches are required so that dependencies are hermetically tracked by meson
|
||||
Label("//mesa:mesa.src_loader_meson.build.patch"),
|
||||
Label("//mesa:mesa.src_intel_vulkan_meson.build.patch"),
|
||||
Label("//mesa:mesa.src_vulkan_util_meson.build.patch"),
|
||||
Label("//mesa:mesa.src_gbm_meson.build.patch"),
|
||||
Label("//mesa:mesa.src_gallium_frontends_dri_meson.build.patch"),
|
||||
Label("//mesa:mesa.src_gallium_targets_dri_meson.build.patch"),
|
||||
Label("//mesa:mesa.src_egl_meson.build.patch"),
|
||||
Label("//mesa:mesa.src_glx_meson.build.patch"),
|
||||
# This patch is required for mesa to build on MacOS
|
||||
Label("//mesa:mesa.src_gallium_frontends_dri_dri_util.c.patch"),
|
||||
],
|
||||
sha256 = "670d8cbe8b72902a45ea2da68a9da4dc4a5d99c5953a926177adbce1b1640b76",
|
||||
strip_prefix = "mesa-22.1.4",
|
||||
url = "https://archive.mesa3d.org//mesa-22.1.4.tar.xz",
|
||||
)
|
||||
|
||||
maybe(
|
||||
http_archive,
|
||||
name = "libpciaccess",
|
||||
build_file = Label("//mesa:BUILD.libpciaccess.bazel"),
|
||||
sha256 = "84413553994aef0070cf420050aa5c0a51b1956b404920e21b81e96db6a61a27",
|
||||
strip_prefix = "libpciaccess-0.16",
|
||||
url = "https://www.x.org/archive//individual/lib/libpciaccess-0.16.tar.gz",
|
||||
)
|
||||
|
||||
maybe(
|
||||
http_archive,
|
||||
name = "libdrm",
|
||||
build_file = Label("//mesa:BUILD.libdrm.bazel"),
|
||||
sha256 = "00b07710bd09b35cd8d80eaf4f4497fe27f4becf467a9830f1f5e8324f8420ff",
|
||||
strip_prefix = "libdrm-2.4.112",
|
||||
url = "https://dri.freedesktop.org/libdrm/libdrm-2.4.112.tar.xz",
|
||||
)
|
||||
|
||||
maybe(
|
||||
http_archive,
|
||||
name = "flex",
|
||||
build_file = Label("//mesa:BUILD.flex.bazel"),
|
||||
sha256 = "e87aae032bf07c26f85ac0ed3250998c37621d95f8bd748b31f15b33c45ee995",
|
||||
strip_prefix = "flex-2.6.4",
|
||||
url = "https://github.com/westes/flex/releases/download/v2.6.4/flex-2.6.4.tar.gz",
|
||||
)
|
||||
|
||||
maybe(
|
||||
http_archive,
|
||||
name = "winflexbison",
|
||||
build_file = Label("//mesa:BUILD.winflexbison.bazel"),
|
||||
sha256 = "8e1b71e037b524ba3f576babb0cf59182061df1f19cd86112f085a882560f60b",
|
||||
strip_prefix = "winflexbison-2.5.25",
|
||||
url = "https://github.com/lexxmark/winflexbison/archive/refs/tags/v2.5.25.tar.gz",
|
||||
)
|
||||
|
||||
maybe(
|
||||
http_archive,
|
||||
name = "libxcb",
|
||||
build_file = Label("//mesa:BUILD.libxcb.bazel"),
|
||||
sha256 = "cc38744f817cf6814c847e2df37fcb8997357d72fa4bcbc228ae0fe47219a059",
|
||||
strip_prefix = "libxcb-1.15",
|
||||
url = "https://xcb.freedesktop.org/dist/libxcb-1.15.tar.xz",
|
||||
)
|
||||
|
||||
maybe(
|
||||
http_archive,
|
||||
name = "xcb-proto",
|
||||
build_file = Label("//mesa:BUILD.xcb-proto.bazel"),
|
||||
sha256 = "d34c3b264e8365d16fa9db49179cfa3e9952baaf9275badda0f413966b65955f",
|
||||
strip_prefix = "xcb-proto-1.15",
|
||||
url = "https://xcb.freedesktop.org/dist/xcb-proto-1.15.tar.xz",
|
||||
)
|
||||
|
||||
maybe(
|
||||
http_archive,
|
||||
name = "libxshmfence",
|
||||
build_file = Label("//mesa:BUILD.libxshmfence.bazel"),
|
||||
sha256 = "7eb3d46ad91bab444f121d475b11b39273142d090f7e9ac43e6a87f4ff5f902c",
|
||||
strip_prefix = "libxshmfence-1.3",
|
||||
url = "https://www.x.org/releases/individual/lib/libxshmfence-1.3.tar.gz",
|
||||
)
|
||||
|
||||
maybe(
|
||||
http_archive,
|
||||
name = "libxau",
|
||||
build_file = Label("//mesa:BUILD.libxau.bazel"),
|
||||
sha256 = "8be6f292334d2f87e5b919c001e149a9fdc27005d6b3e053862ac6ebbf1a0c0a",
|
||||
strip_prefix = "libXau-1.0.10",
|
||||
url = "https://www.x.org/pub/individual/lib/libXau-1.0.10.tar.xz",
|
||||
)
|
||||
|
||||
maybe(
|
||||
http_archive,
|
||||
name = "xorgproto",
|
||||
build_file = Label("//mesa:BUILD.xorgproto.bazel"),
|
||||
sha256 = "5d13dbf2be08f95323985de53352c4f352713860457b95ccaf894a647ac06b9e",
|
||||
strip_prefix = "xorgproto-2022.2",
|
||||
url = "https://xorg.freedesktop.org/archive/individual/proto/xorgproto-2022.2.tar.xz",
|
||||
)
|
||||
|
||||
maybe(
|
||||
http_archive,
|
||||
name = "libxdmcp",
|
||||
build_file = Label("//mesa:BUILD.libxdmcp.bazel"),
|
||||
sha256 = "2dce5cc317f8f0b484ec347d87d81d552cdbebb178bd13c5d8193b6b7cd6ad00",
|
||||
strip_prefix = "libXdmcp-1.1.4",
|
||||
url = "https://www.x.org/pub/individual/lib/libXdmcp-1.1.4.tar.xz",
|
||||
)
|
||||
|
||||
maybe(
|
||||
http_archive,
|
||||
name = "libx11",
|
||||
build_file = Label("//mesa:BUILD.libx11.bazel"),
|
||||
sha256 = "081bf42ebab023aa92cfdb20c7af8c5ae13d13e88a5e22f90f4453ef80bbdde4",
|
||||
strip_prefix = "libX11-1.8",
|
||||
url = "https://www.x.org/archive/individual/lib/libX11-1.8.tar.xz",
|
||||
)
|
||||
|
||||
maybe(
|
||||
http_archive,
|
||||
name = "libxrandr",
|
||||
build_file = Label("//mesa:BUILD.libxrandr.bazel"),
|
||||
sha256 = "897639014a78e1497704d669c5dd5682d721931a4452c89a7ba62676064eb428",
|
||||
strip_prefix = "libXrandr-1.5.3",
|
||||
url = "https://www.x.org/archive/individual/lib/libXrandr-1.5.3.tar.xz",
|
||||
)
|
||||
|
||||
maybe(
|
||||
http_archive,
|
||||
name = "libxext",
|
||||
build_file = Label("//mesa:BUILD.libxext.bazel"),
|
||||
sha256 = "db14c0c895c57ea33a8559de8cb2b93dc76c42ea4a39e294d175938a133d7bca",
|
||||
strip_prefix = "libXext-1.3.5",
|
||||
url = "https://www.x.org/archive/individual/lib/libXext-1.3.5.tar.xz",
|
||||
)
|
||||
|
||||
maybe(
|
||||
http_archive,
|
||||
name = "libxrender",
|
||||
build_file = Label("//mesa:BUILD.libxrender.bazel"),
|
||||
sha256 = "bc53759a3a83d1ff702fb59641b3d2f7c56e05051fa0cfa93501166fa782dc24",
|
||||
strip_prefix = "libXrender-0.9.11",
|
||||
url = "https://www.x.org/archive//individual/lib/libXrender-0.9.11.tar.xz",
|
||||
)
|
||||
|
||||
maybe(
|
||||
http_archive,
|
||||
name = "renderproto",
|
||||
build_file = Label("//mesa:BUILD.renderproto.bazel"),
|
||||
sha256 = "a0a4be3cad9381ae28279ba5582e679491fc2bec9aab8a65993108bf8dbce5fe",
|
||||
strip_prefix = "renderproto-0.11.1",
|
||||
url = "https://www.x.org/releases/individual/proto/renderproto-0.11.1.tar.gz",
|
||||
)
|
||||
|
||||
maybe(
|
||||
http_archive,
|
||||
name = "xtrans",
|
||||
build_file = Label("//mesa:BUILD.xtrans.bazel"),
|
||||
sha256 = "48ed850ce772fef1b44ca23639b0a57e38884045ed2cbb18ab137ef33ec713f9",
|
||||
strip_prefix = "xtrans-1.4.0",
|
||||
url = "https://www.x.org/archive/individual/lib/xtrans-1.4.0.tar.gz",
|
||||
)
|
||||
|
||||
maybe(
|
||||
http_archive,
|
||||
name = "libpthread-stubs",
|
||||
build_file = Label("//mesa:BUILD.libpthread-stubs.bazel"),
|
||||
sha256 = "f8f7ca635fa54bcaef372fd5fd9028f394992a743d73453088fcadc1dbf3a704",
|
||||
strip_prefix = "libpthread-stubs-0.1",
|
||||
url = "https://www.x.org/archive//individual/lib/libpthread-stubs-0.1.tar.gz",
|
||||
)
|
||||
|
||||
maybe(
|
||||
http_archive,
|
||||
name = "libxfixes",
|
||||
build_file = Label("//mesa:BUILD.libxfixes.bazel"),
|
||||
sha256 = "82045da5625350838390c9440598b90d69c882c324ca92f73af9f0e992cb57c7",
|
||||
strip_prefix = "libXfixes-6.0.0",
|
||||
url = "https://www.x.org/archive//individual/lib/libXfixes-6.0.0.tar.gz",
|
||||
)
|
|
@ -18,7 +18,10 @@ cmake(
|
|||
"CMAKE_C_FLAGS": "${CMAKE_C_FLAGS:-} -fPIC",
|
||||
},
|
||||
lib_source = ":all_srcs",
|
||||
out_static_libs = ["libpcre.a"],
|
||||
out_static_libs = select({
|
||||
"@platforms//os:windows": ["pcre2-8.lib"],
|
||||
"//conditions:default": ["libpcre2-8.a"],
|
||||
}),
|
||||
)
|
||||
|
||||
filegroup(
|
||||
|
|
|
@ -8,10 +8,9 @@ def pcre_repositories():
|
|||
http_archive,
|
||||
name = "pcre",
|
||||
build_file = Label("//pcre:BUILD.pcre.bazel"),
|
||||
strip_prefix = "pcre-8.45",
|
||||
sha256 = "4e6ce03e0336e8b4a3d6c2b70b1c5e18590a5673a98186da90d4f33c23defc09",
|
||||
strip_prefix = "pcre2-10.37",
|
||||
sha256 = "04e214c0c40a97b8a5c2b4ae88a3aa8a93e6f2e45c6b3534ddac351f26548577",
|
||||
urls = [
|
||||
"https://mirror.bazel.build/downloads.sourceforge.net/project/pcre/pcre/8.45/pcre-8.45.tar.gz",
|
||||
"https://downloads.sourceforge.net/project/pcre/pcre/8.45/pcre-8.45.tar.gz",
|
||||
"https://github.com/PCRE2Project/pcre2/releases/download/pcre2-10.37/pcre2-10.37.tar.gz",
|
||||
],
|
||||
)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
load("@rules_python//python:defs.bzl", "py_runtime", "py_runtime_pair", "py_test")
|
||||
load("@bazel_skylib//rules:build_test.bzl", "build_test")
|
||||
|
||||
exports_files(
|
||||
[
|
||||
|
@ -7,34 +7,18 @@ exports_files(
|
|||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
py_runtime(
|
||||
name = "py3_runtime",
|
||||
files = ["@python3"],
|
||||
interpreter = "@python3//:python3_bin",
|
||||
python_version = "PY3",
|
||||
)
|
||||
|
||||
py_runtime_pair(
|
||||
name = "py_runtime_pair",
|
||||
py3_runtime = ":py3_runtime",
|
||||
)
|
||||
|
||||
toolchain(
|
||||
name = "python_toolchain",
|
||||
toolchain = ":py_runtime_pair",
|
||||
toolchain_type = "@rules_python//python:toolchain_type",
|
||||
)
|
||||
|
||||
py_test(
|
||||
name = "python3_test",
|
||||
srcs = ["python3_test.py"],
|
||||
python_version = "PY3",
|
||||
build_test(
|
||||
name = "build_test",
|
||||
targets = [
|
||||
"@python3//:python3",
|
||||
],
|
||||
visibility = ["//:__pkg__"],
|
||||
)
|
||||
|
||||
test_suite(
|
||||
name = "python_tests",
|
||||
tests = [
|
||||
":python3_test",
|
||||
":build_test",
|
||||
],
|
||||
visibility = ["//:__pkg__"],
|
||||
)
|
||||
|
|
|
@ -38,9 +38,3 @@ configure_make(
|
|||
"@zlib",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "python3_bin",
|
||||
srcs = [":python3"],
|
||||
output_group = "python3.10",
|
||||
)
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
|
||||
import sys
|
||||
import platform
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
assert('python3_test.runfiles/python3/python3/bin/' in sys.executable)
|
||||
assert(platform.python_version() == "3.10.1")
|
|
@ -15,14 +15,3 @@ def python_repositories():
|
|||
],
|
||||
sha256 = "b76117670e7c5064344b9c138e141a377e686b9063f3a8a620ff674fa8ec90d3",
|
||||
)
|
||||
|
||||
maybe(
|
||||
http_archive,
|
||||
name = "rules_python",
|
||||
urls = [
|
||||
"https://github.com/bazelbuild/rules_python/releases/download/0.5.0/rules_python-0.5.0.tar.gz",
|
||||
],
|
||||
sha256 = "cd6730ed53a002c56ce4e2f396ba3b3be262fd7cb68339f0377a45e8227fe332",
|
||||
)
|
||||
|
||||
native.register_toolchains("@rules_foreign_cc_examples_third_party//python:python_toolchain")
|
||||
|
|
|
@ -8,6 +8,7 @@ load("//autotools:autotools_repositories.bzl", "autotools_repositories")
|
|||
load("//bison:bison_repositories.bzl", "bison_repositories")
|
||||
load("//cares:cares_repositories.bzl", "cares_repositories")
|
||||
load("//curl:curl_repositories.bzl", "curl_repositories")
|
||||
load("//glib:glib_repositories.bzl", "glib_repositories")
|
||||
load("//gn:gn_repositories.bzl", "gn_repositories")
|
||||
load("//gperftools:gperftools_repositories.bzl", "gperftools_repositories")
|
||||
load("//iconv:iconv_repositories.bzl", "iconv_repositories")
|
||||
|
@ -16,6 +17,7 @@ load("//libjpeg_turbo:libjpeg_turbo_repositories.bzl", "libjpeg_turbo_repositori
|
|||
load("//libpng:libpng_repositories.bzl", "libpng_repositories")
|
||||
load("//libssh2:libssh2_repositories.bzl", "libssh2_repositories")
|
||||
load("//log4cxx:log4cxx_repositories.bzl", "log4cxx_repositories")
|
||||
load("//mesa:mesa_repositories.bzl", "mesa_repositories")
|
||||
load("//openssl:openssl_repositories.bzl", "openssl_repositories")
|
||||
load("//pcre:pcre_repositories.bzl", "pcre_repositories")
|
||||
load("//python:python_repositories.bzl", "python_repositories")
|
||||
|
@ -32,6 +34,7 @@ def repositories():
|
|||
bison_repositories()
|
||||
cares_repositories()
|
||||
curl_repositories()
|
||||
glib_repositories()
|
||||
gn_repositories()
|
||||
gperftools_repositories()
|
||||
iconv_repositories()
|
||||
|
@ -40,6 +43,7 @@ def repositories():
|
|||
libpng_repositories()
|
||||
libssh2_repositories()
|
||||
log4cxx_repositories()
|
||||
mesa_repositories()
|
||||
openssl_repositories()
|
||||
pcre_repositories()
|
||||
python_repositories()
|
||||
|
|
|
@ -12,13 +12,19 @@ filegroup(
|
|||
|
||||
cmake(
|
||||
name = "zlib",
|
||||
cache_entries = select({
|
||||
"@platforms//os:linux": {
|
||||
"CMAKE_C_FLAGS": "${CMAKE_C_FLAGS:-} -fPIC",
|
||||
},
|
||||
"//conditions:default": {},
|
||||
}),
|
||||
generate_args = select({
|
||||
"@platforms//os:windows": ["-GNinja"],
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
lib_source = ":all_srcs",
|
||||
out_static_libs = select({
|
||||
"@platforms//os:windows": ["zlibstatic.lib"],
|
||||
"@platforms//os:windows": ["z.lib"],
|
||||
"//conditions:default": ["libz.a"],
|
||||
}),
|
||||
)
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
--- CMakeLists.txt 2022-10-13 06:06:55.000000000 +0100
|
||||
+++ CMakeLists.txt 2022-10-13 06:06:55.000000000 +0100
|
||||
@@ -147,8 +147,7 @@
|
||||
set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj)
|
||||
endif(MINGW)
|
||||
|
||||
-add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
|
||||
-add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
|
||||
+add_library(zlib ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
|
||||
set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL)
|
||||
set_target_properties(zlib PROPERTIES SOVERSION 1)
|
||||
|
||||
@@ -163,19 +162,18 @@
|
||||
set_target_properties(zlib PROPERTIES VERSION ${ZLIB_FULL_VERSION})
|
||||
endif()
|
||||
|
||||
-if(UNIX)
|
||||
# On unix-like platforms the library is almost always called libz
|
||||
- set_target_properties(zlib zlibstatic PROPERTIES OUTPUT_NAME z)
|
||||
- if(NOT APPLE)
|
||||
+ set_target_properties(zlib PROPERTIES OUTPUT_NAME z)
|
||||
+ if(UNIX AND NOT APPLE)
|
||||
set_target_properties(zlib PROPERTIES LINK_FLAGS "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib.map\"")
|
||||
endif()
|
||||
-elseif(BUILD_SHARED_LIBS AND WIN32)
|
||||
+if(BUILD_SHARED_LIBS AND WIN32)
|
||||
# Creates zlib1.dll when building shared library version
|
||||
set_target_properties(zlib PROPERTIES SUFFIX "1.dll")
|
||||
endif()
|
||||
|
||||
if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
|
||||
- install(TARGETS zlib zlibstatic
|
||||
+ install(TARGETS zlib
|
||||
RUNTIME DESTINATION "${INSTALL_BIN_DIR}"
|
||||
ARCHIVE DESTINATION "${INSTALL_LIB_DIR}"
|
||||
LIBRARY DESTINATION "${INSTALL_LIB_DIR}" )
|
|
@ -10,6 +10,11 @@ def zlib_repositories():
|
|||
build_file = Label("//zlib:BUILD.zlib.bazel"),
|
||||
sha256 = "b3a24de97a8fdbc835b9833169501030b8977031bcb54b3b3ac13740f846ab30",
|
||||
strip_prefix = "zlib-1.2.13",
|
||||
patches = [
|
||||
# This patch modifies zlib so that on windows the generated lib matches that stated in the generated pkgconfig pc file for consumption by dependent rules
|
||||
# Similar patches are used in vcpkg and conan to resolve the same issue
|
||||
Label("//zlib:zlib.patch"),
|
||||
],
|
||||
urls = [
|
||||
"https://zlib.net/zlib-1.2.13.tar.gz",
|
||||
"https://storage.googleapis.com/mirror.tensorflow.org/zlib.net/zlib-1.2.13.tar.gz",
|
||||
|
|
|
@ -15,5 +15,6 @@ bzl_library(
|
|||
"@bazel_skylib//lib:collections",
|
||||
"@bazel_skylib//lib:paths",
|
||||
"@bazel_skylib//lib:versions",
|
||||
"@rules_python//docs:defs",
|
||||
],
|
||||
)
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
""" Rule for building meson from source. """
|
||||
|
||||
load("@rules_python//python:defs.bzl", "py_binary")
|
||||
|
||||
def meson_tool(name, main, data, requirements = [], **kwargs):
|
||||
py_binary(
|
||||
name = name,
|
||||
srcs = [main],
|
||||
data = data,
|
||||
deps = requirements,
|
||||
python_version = "PY3",
|
||||
main = main,
|
||||
**kwargs
|
||||
)
|
|
@ -4,6 +4,7 @@ load(":boost_build.bzl", _boost_build = "boost_build")
|
|||
load(":cmake.bzl", _cmake = "cmake", _cmake_variant = "cmake_variant")
|
||||
load(":configure.bzl", _configure_make = "configure_make", _configure_make_variant = "configure_make_variant")
|
||||
load(":make.bzl", _make = "make", _make_variant = "make_variant")
|
||||
load(":meson.bzl", _meson = "meson", _meson_with_requirements = "meson_with_requirements")
|
||||
load(":ninja.bzl", _ninja = "ninja")
|
||||
load(":utils.bzl", _runnable_binary = "runnable_binary")
|
||||
|
||||
|
@ -14,5 +15,7 @@ configure_make = _configure_make
|
|||
configure_make_variant = _configure_make_variant
|
||||
make_variant = _make_variant
|
||||
make = _make
|
||||
meson = _meson
|
||||
ninja = _ninja
|
||||
meson_with_requirements = _meson_with_requirements
|
||||
runnable_binary = _runnable_binary
|
||||
|
|
|
@ -0,0 +1,202 @@
|
|||
"""A rule for building projects using the [Meson](https://mesonbuild.com/) build system"""
|
||||
|
||||
load("//foreign_cc:utils.bzl", "full_label")
|
||||
load("//foreign_cc/built_tools:meson_build.bzl", "meson_tool")
|
||||
load(
|
||||
"//foreign_cc/private:detect_root.bzl",
|
||||
"detect_root",
|
||||
)
|
||||
load(
|
||||
"//foreign_cc/private:framework.bzl",
|
||||
"CC_EXTERNAL_RULE_ATTRIBUTES",
|
||||
"CC_EXTERNAL_RULE_FRAGMENTS",
|
||||
"cc_external_rule_impl",
|
||||
"create_attrs",
|
||||
"expand_locations_and_make_variables",
|
||||
)
|
||||
load("//foreign_cc/private:make_script.bzl", "pkgconfig_script")
|
||||
load("//foreign_cc/private:transitions.bzl", "foreign_cc_rule_variant")
|
||||
load("//toolchains/native_tools:native_tools_toolchain.bzl", "native_tool_toolchain")
|
||||
load("//toolchains/native_tools:tool_access.bzl", "get_cmake_data", "get_meson_data", "get_ninja_data", "get_pkgconfig_data")
|
||||
|
||||
def _meson_impl(ctx):
|
||||
"""The implementation of the `meson` rule
|
||||
|
||||
Args:
|
||||
ctx (ctx): The rule's context object
|
||||
|
||||
Returns:
|
||||
list: A list of providers. See `cc_external_rule_impl`
|
||||
"""
|
||||
|
||||
meson_data = get_meson_data(ctx)
|
||||
cmake_data = get_cmake_data(ctx)
|
||||
ninja_data = get_ninja_data(ctx)
|
||||
pkg_config_data = get_pkgconfig_data(ctx)
|
||||
|
||||
tools_data = [meson_data, cmake_data, ninja_data, pkg_config_data]
|
||||
|
||||
attrs = create_attrs(
|
||||
ctx.attr,
|
||||
configure_name = "Meson",
|
||||
create_configure_script = _create_meson_script,
|
||||
tools_data = tools_data,
|
||||
meson_path = meson_data.path,
|
||||
cmake_path = cmake_data.path,
|
||||
ninja_path = ninja_data.path,
|
||||
pkg_config_path = pkg_config_data.path,
|
||||
)
|
||||
return cc_external_rule_impl(ctx, attrs)
|
||||
|
||||
def _create_meson_script(configureParameters):
|
||||
"""Creates the bash commands for invoking commands to build meson projects
|
||||
|
||||
Args:
|
||||
configureParameters (struct): See `ConfigureParameters`
|
||||
|
||||
Returns:
|
||||
str: A string representing a section of a bash script
|
||||
"""
|
||||
ctx = configureParameters.ctx
|
||||
attrs = configureParameters.attrs
|
||||
inputs = configureParameters.inputs
|
||||
|
||||
script = pkgconfig_script(inputs.ext_build_dirs)
|
||||
|
||||
script.append("##export_var## CMAKE {}".format(attrs.cmake_path))
|
||||
script.append("##export_var## NINJA {}".format(attrs.ninja_path))
|
||||
script.append("##export_var## PKG_CONFIG {}".format(attrs.pkg_config_path))
|
||||
|
||||
root = detect_root(ctx.attr.lib_source)
|
||||
data = ctx.attr.data + ctx.attr.build_data
|
||||
|
||||
# Generate a list of arguments for meson
|
||||
options_str = " ".join([
|
||||
"-D{}=\"{}\"".format(key, ctx.attr.options[key])
|
||||
for key in ctx.attr.options
|
||||
])
|
||||
|
||||
prefix = "{} ".format(expand_locations_and_make_variables(ctx, attrs.tool_prefix, "tool_prefix", data)) if attrs.tool_prefix else ""
|
||||
|
||||
script.append("{prefix}{meson} --prefix={install_dir} {options} {source_dir}".format(
|
||||
prefix = prefix,
|
||||
meson = attrs.meson_path,
|
||||
install_dir = "$$INSTALLDIR$$",
|
||||
options = options_str,
|
||||
source_dir = "$$EXT_BUILD_ROOT$$/" + root,
|
||||
))
|
||||
|
||||
build_args = [] + ctx.attr.build_args
|
||||
build_args_str = " ".join([
|
||||
ctx.expand_location(arg, data)
|
||||
for arg in build_args
|
||||
])
|
||||
|
||||
script.append("{prefix}{meson} compile {args}".format(
|
||||
prefix = prefix,
|
||||
meson = attrs.meson_path,
|
||||
args = build_args_str,
|
||||
))
|
||||
|
||||
if ctx.attr.install:
|
||||
install_args = " ".join([
|
||||
ctx.expand_location(arg, data)
|
||||
for arg in ctx.attr.install_args
|
||||
])
|
||||
script.append("{prefix}{meson} install {args}".format(
|
||||
prefix = prefix,
|
||||
meson = attrs.meson_path,
|
||||
args = install_args,
|
||||
))
|
||||
|
||||
return script
|
||||
|
||||
def _attrs():
|
||||
"""Modifies the common set of attributes used by rules_foreign_cc and sets Meson specific attrs
|
||||
|
||||
Returns:
|
||||
dict: Attributes of the `meson` rule
|
||||
"""
|
||||
attrs = dict(CC_EXTERNAL_RULE_ATTRIBUTES)
|
||||
|
||||
attrs.update({
|
||||
"build_args": attr.string_list(
|
||||
doc = "Arguments for the Meson build command",
|
||||
mandatory = False,
|
||||
),
|
||||
"install": attr.bool(
|
||||
doc = "If True, the `meson install` comand will be performed after a build",
|
||||
default = True,
|
||||
),
|
||||
"install_args": attr.string_list(
|
||||
doc = "Arguments for the meson install command",
|
||||
mandatory = False,
|
||||
),
|
||||
"options": attr.string_dict(
|
||||
doc = (
|
||||
"Meson option entries to initialize (they will be passed with `-Dkey=value`)"
|
||||
),
|
||||
mandatory = False,
|
||||
default = {},
|
||||
),
|
||||
})
|
||||
return attrs
|
||||
|
||||
meson = rule(
|
||||
doc = (
|
||||
"Rule for building external libraries with [Meson](https://mesonbuild.com/)."
|
||||
),
|
||||
attrs = _attrs(),
|
||||
fragments = CC_EXTERNAL_RULE_FRAGMENTS,
|
||||
output_to_genfiles = True,
|
||||
implementation = _meson_impl,
|
||||
toolchains = [
|
||||
"@rules_foreign_cc//toolchains:meson_toolchain",
|
||||
"@rules_foreign_cc//toolchains:cmake_toolchain",
|
||||
"@rules_foreign_cc//toolchains:ninja_toolchain",
|
||||
"@rules_foreign_cc//toolchains:pkgconfig_toolchain",
|
||||
"@rules_foreign_cc//foreign_cc/private/framework:shell_toolchain",
|
||||
"@bazel_tools//tools/cpp:toolchain_type",
|
||||
],
|
||||
# TODO: Remove once https://github.com/bazelbuild/bazel/issues/11584 is closed and the min supported
|
||||
# version is updated to a release of Bazel containing the new default for this setting.
|
||||
incompatible_use_toolchain_transition = True,
|
||||
)
|
||||
|
||||
def meson_with_requirements(name, requirements, **kwargs):
|
||||
""" Wrapper macro around Meson rule to add Python libraries required by the Meson build.
|
||||
|
||||
Args:
|
||||
name: The target name
|
||||
requirements: List of Python "requirements", see https://github.com/bazelbuild/rules_python/tree/00545742ad2450863aeb82353d4275a1e5ed3f24#using-third_party-packages-as-dependencies
|
||||
**kwargs: Remaining keyword arguments
|
||||
"""
|
||||
tags = kwargs.pop("tags", [])
|
||||
|
||||
meson_tool(
|
||||
name = "meson_tool_for_{}".format(name),
|
||||
main = "@meson_src//:meson.py",
|
||||
data = ["@meson_src//:runtime"],
|
||||
requirements = requirements,
|
||||
tags = tags + ["manual"],
|
||||
)
|
||||
|
||||
native_tool_toolchain(
|
||||
name = "built_meson_for_{}".format(name),
|
||||
env = {"MESON": "$(execpath :meson_tool_for_{})".format(name)},
|
||||
path = "$(execpath :meson_tool_for_{})".format(name),
|
||||
target = ":meson_tool_for_{}".format(name),
|
||||
)
|
||||
|
||||
native.toolchain(
|
||||
name = "built_meson_toolchain_for_{}".format(name),
|
||||
toolchain = "built_meson_for_{}".format(name),
|
||||
toolchain_type = "@rules_foreign_cc//toolchains:meson_toolchain",
|
||||
)
|
||||
|
||||
foreign_cc_rule_variant(
|
||||
name = name,
|
||||
rule = meson,
|
||||
toolchain = full_label("built_meson_toolchain_for_{}".format(name)),
|
||||
**kwargs
|
||||
)
|
|
@ -54,10 +54,12 @@ def foreign_cc_rule_variant(name, rule, toolchain, **kwargs):
|
|||
foreign_cc_rule_target_name = name + "_"
|
||||
|
||||
tags = kwargs.pop("tags", [])
|
||||
visibility = kwargs.pop("visibility", [])
|
||||
|
||||
rule(
|
||||
name = foreign_cc_rule_target_name,
|
||||
tags = tags + ["manual"],
|
||||
visibility = visibility,
|
||||
**kwargs
|
||||
)
|
||||
|
||||
|
@ -66,4 +68,5 @@ def foreign_cc_rule_variant(name, rule, toolchain, **kwargs):
|
|||
extra_toolchains = [toolchain],
|
||||
target = foreign_cc_rule_target_name,
|
||||
tags = tags,
|
||||
visibility = visibility,
|
||||
)
|
||||
|
|
|
@ -12,6 +12,7 @@ def rules_foreign_cc_dependencies(
|
|||
cmake_version = "3.23.2",
|
||||
make_version = "4.4",
|
||||
ninja_version = "1.11.1",
|
||||
meson_version = "0.63.0",
|
||||
pkgconfig_version = "0.29.2",
|
||||
register_preinstalled_tools = True,
|
||||
register_built_tools = True,
|
||||
|
@ -40,6 +41,8 @@ def rules_foreign_cc_dependencies(
|
|||
ninja_version: The target version of the ninja toolchain if `register_default_tools`
|
||||
or `register_built_tools` is set to `True`.
|
||||
|
||||
meson_version: The target version of the meson toolchain if `register_built_tools` is set to `True`.
|
||||
|
||||
pkgconfig_version: The target version of the pkg_config toolchain if `register_built_tools` is set to `True`.
|
||||
|
||||
register_preinstalled_tools: If true, toolchains will be registered for the native built tools
|
||||
|
@ -71,6 +74,7 @@ def rules_foreign_cc_dependencies(
|
|||
cmake_version = cmake_version,
|
||||
make_version = make_version,
|
||||
ninja_version = ninja_version,
|
||||
meson_version = meson_version,
|
||||
pkgconfig_version = pkgconfig_version,
|
||||
register_toolchains = register_toolchains,
|
||||
register_built_pkgconfig_toolchain = register_built_pkgconfig_toolchain,
|
||||
|
@ -92,7 +96,7 @@ def rules_foreign_cc_dependencies(
|
|||
maybe(
|
||||
http_archive,
|
||||
name = "rules_python",
|
||||
sha256 = "5fa3c738d33acca3b97622a13a741129f67ef43f5fdfcec63b29374cc0574c29",
|
||||
strip_prefix = "rules_python-0.9.0",
|
||||
url = "https://github.com/bazelbuild/rules_python/archive/refs/tags/0.9.0.tar.gz",
|
||||
sha256 = "a3a6e99f497be089f81ec082882e40246bfd435f52f4e82f37e89449b04573f6",
|
||||
strip_prefix = "rules_python-0.10.2",
|
||||
url = "https://github.com/bazelbuild/rules_python/archive/refs/tags/0.10.2.tar.gz",
|
||||
)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
""" This file contains useful utilities """
|
||||
|
||||
def _full_label(label):
|
||||
def full_label(label):
|
||||
return native.repository_name() + "//" + native.package_name() + ":" + label
|
||||
|
||||
def runnable_binary(name, binary, foreign_cc_target, match_binary_name = False, **kwargs):
|
||||
|
@ -50,8 +50,8 @@ def runnable_binary(name, binary, foreign_cc_target, match_binary_name = False,
|
|||
srcs = ["@rules_foreign_cc//foreign_cc/private:runnable_binary_wrapper.sh", name + "_fg"],
|
||||
outs = [name + "_wrapper.sh"],
|
||||
cmd = select({
|
||||
"@platforms//os:windows": wrapper_cmd.format(name = _full_label(name + "_fg"), sh_binary_filename = binary + ".exe" if match_binary_name else name),
|
||||
"//conditions:default": wrapper_cmd.format(name = _full_label(name + "_fg"), sh_binary_filename = binary if match_binary_name else name),
|
||||
"@platforms//os:windows": wrapper_cmd.format(name = full_label(name + "_fg"), sh_binary_filename = binary + ".exe" if match_binary_name else name),
|
||||
"//conditions:default": wrapper_cmd.format(name = full_label(name + "_fg"), sh_binary_filename = binary if match_binary_name else name),
|
||||
}),
|
||||
tags = tags + ["manual"],
|
||||
)
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
|
||||
load("//foreign_cc/built_tools:cmake_build.bzl", "cmake_tool")
|
||||
load("//foreign_cc/built_tools:make_build.bzl", "make_tool")
|
||||
load("//foreign_cc/built_tools:meson_build.bzl", "meson_tool")
|
||||
load("//foreign_cc/built_tools:ninja_build.bzl", "ninja_tool")
|
||||
load("//foreign_cc/built_tools:pkgconfig_build.bzl", "pkgconfig_tool")
|
||||
load("//toolchains:toolchains.bzl", "current_autoconf_toolchain", "current_automake_toolchain", "current_cmake_toolchain", "current_m4_toolchain", "current_make_toolchain", "current_ninja_toolchain", "current_pkgconfig_toolchain")
|
||||
load("//toolchains:toolchains.bzl", "current_autoconf_toolchain", "current_automake_toolchain", "current_cmake_toolchain", "current_m4_toolchain", "current_make_toolchain", "current_meson_toolchain", "current_ninja_toolchain", "current_pkgconfig_toolchain")
|
||||
load("//toolchains/native_tools:native_tools_toolchain.bzl", "native_tool_toolchain")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
@ -20,6 +21,10 @@ toolchain_type(
|
|||
name = "make_toolchain",
|
||||
)
|
||||
|
||||
toolchain_type(
|
||||
name = "meson_toolchain",
|
||||
)
|
||||
|
||||
toolchain_type(
|
||||
name = "pkgconfig_toolchain",
|
||||
)
|
||||
|
@ -44,6 +49,10 @@ current_ninja_toolchain(
|
|||
name = "current_ninja_toolchain",
|
||||
)
|
||||
|
||||
current_meson_toolchain(
|
||||
name = "current_meson_toolchain",
|
||||
)
|
||||
|
||||
current_m4_toolchain(
|
||||
name = "current_m4_toolchain",
|
||||
)
|
||||
|
@ -82,6 +91,12 @@ toolchain(
|
|||
toolchain_type = ":make_toolchain",
|
||||
)
|
||||
|
||||
toolchain(
|
||||
name = "built_meson_toolchain",
|
||||
toolchain = ":built_meson",
|
||||
toolchain_type = ":meson_toolchain",
|
||||
)
|
||||
|
||||
toolchain(
|
||||
name = "built_pkgconfig_toolchain",
|
||||
toolchain = ":built_pkgconfig",
|
||||
|
@ -215,6 +230,34 @@ native_tool_toolchain(
|
|||
target = ":ninja_tool",
|
||||
)
|
||||
|
||||
toolchain(
|
||||
name = "preinstalled_meson_toolchain",
|
||||
toolchain = ":preinstalled_meson",
|
||||
toolchain_type = ":meson_toolchain",
|
||||
)
|
||||
|
||||
native_tool_toolchain(
|
||||
name = "preinstalled_meson",
|
||||
path = select({
|
||||
"@platforms//os:windows": "meson.exe",
|
||||
"//conditions:default": "meson",
|
||||
}),
|
||||
)
|
||||
|
||||
meson_tool(
|
||||
name = "meson_tool",
|
||||
data = ["@meson_src//:runtime"],
|
||||
main = "@meson_src//:meson.py",
|
||||
tags = ["manual"],
|
||||
)
|
||||
|
||||
native_tool_toolchain(
|
||||
name = "built_meson",
|
||||
env = {"MESON": "$(execpath :meson_tool)"},
|
||||
path = "$(execpath :meson_tool)",
|
||||
target = ":meson_tool",
|
||||
)
|
||||
|
||||
toolchain(
|
||||
name = "preinstalled_autoconf_toolchain",
|
||||
toolchain = ":preinstalled_autoconf",
|
||||
|
|
|
@ -15,8 +15,18 @@ filegroup(
|
|||
)
|
||||
"""
|
||||
|
||||
_MESON_BUILD_FILE_CONTENT = """\
|
||||
exports_files(["meson.py"])
|
||||
|
||||
filegroup(
|
||||
name = "runtime",
|
||||
srcs = glob(["mesonbuild/**"]),
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
"""
|
||||
|
||||
# buildifier: disable=unnamed-macro
|
||||
def built_toolchains(cmake_version, make_version, ninja_version, pkgconfig_version, register_toolchains, register_built_pkgconfig_toolchain):
|
||||
def built_toolchains(cmake_version, make_version, ninja_version, meson_version, pkgconfig_version, register_toolchains, register_built_pkgconfig_toolchain):
|
||||
"""
|
||||
Register toolchains for built tools that will be built from source
|
||||
|
||||
|
@ -28,6 +38,8 @@ def built_toolchains(cmake_version, make_version, ninja_version, pkgconfig_versi
|
|||
|
||||
ninja_version: The Ninja version to build
|
||||
|
||||
meson_version: The Meson version to build
|
||||
|
||||
pkgconfig_version: The pkg-config version to build
|
||||
|
||||
register_toolchains: If true, registers the toolchains via native.register_toolchains. Used by bzlmod
|
||||
|
@ -37,6 +49,7 @@ def built_toolchains(cmake_version, make_version, ninja_version, pkgconfig_versi
|
|||
_cmake_toolchain(cmake_version, register_toolchains)
|
||||
_make_toolchain(make_version, register_toolchains)
|
||||
_ninja_toolchain(ninja_version, register_toolchains)
|
||||
_meson_toolchain(meson_version, register_toolchains)
|
||||
|
||||
if register_built_pkgconfig_toolchain:
|
||||
_pkgconfig_toolchain(pkgconfig_version, register_toolchains)
|
||||
|
@ -143,6 +156,24 @@ def _ninja_toolchain(version, register_toolchains):
|
|||
|
||||
fail("Unsupported ninja version: " + str(version))
|
||||
|
||||
def _meson_toolchain(version, register_toolchains):
|
||||
if register_toolchains:
|
||||
native.register_toolchains(
|
||||
"@rules_foreign_cc//toolchains:built_meson_toolchain",
|
||||
)
|
||||
if version == "0.63.0":
|
||||
maybe(
|
||||
http_archive,
|
||||
name = "meson_src",
|
||||
build_file_content = _MESON_BUILD_FILE_CONTENT,
|
||||
sha256 = "3b51d451744c2bc71838524ec8d96cd4f8c4793d5b8d5d0d0a9c8a4f7c94cd6f",
|
||||
strip_prefix = "meson-0.63.0",
|
||||
url = "https://github.com/mesonbuild/meson/releases/download/0.63.0/meson-0.63.0.tar.gz",
|
||||
)
|
||||
return
|
||||
|
||||
fail("Unsupported meson version: " + str(version))
|
||||
|
||||
def _pkgconfig_toolchain(version, register_toolchains):
|
||||
if register_toolchains:
|
||||
native.register_toolchains(
|
||||
|
|
|
@ -35,6 +35,9 @@ def get_make_data(ctx):
|
|||
def get_ninja_data(ctx):
|
||||
return _access_and_expect_label_copied(Label("//toolchains:ninja_toolchain"), ctx)
|
||||
|
||||
def get_meson_data(ctx):
|
||||
return _access_and_expect_label_copied(Label("//toolchains:meson_toolchain"), ctx)
|
||||
|
||||
def get_pkgconfig_data(ctx):
|
||||
return _access_and_expect_label_copied(Label("//toolchains:pkgconfig_toolchain"), ctx)
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ def preinstalled_toolchains():
|
|||
"@rules_foreign_cc//toolchains:preinstalled_cmake_toolchain",
|
||||
"@rules_foreign_cc//toolchains:preinstalled_make_toolchain",
|
||||
"@rules_foreign_cc//toolchains:preinstalled_ninja_toolchain",
|
||||
"@rules_foreign_cc//toolchains:preinstalled_meson_toolchain",
|
||||
"@rules_foreign_cc//toolchains:preinstalled_autoconf_toolchain",
|
||||
"@rules_foreign_cc//toolchains:preinstalled_automake_toolchain",
|
||||
"@rules_foreign_cc//toolchains:preinstalled_m4_toolchain",
|
||||
|
@ -79,6 +80,17 @@ current_ninja_toolchain = rule(
|
|||
],
|
||||
)
|
||||
|
||||
current_meson_toolchain = rule(
|
||||
implementation = _current_toolchain_impl,
|
||||
attrs = {
|
||||
"_toolchain": attr.string(default = str(Label("//toolchains:meson_toolchain"))),
|
||||
},
|
||||
incompatible_use_toolchain_transition = True,
|
||||
toolchains = [
|
||||
str(Label("//toolchains:meson_toolchain")),
|
||||
],
|
||||
)
|
||||
|
||||
current_autoconf_toolchain = rule(
|
||||
implementation = _current_toolchain_impl,
|
||||
attrs = {
|
||||
|
|
Loading…
Reference in New Issue