Merge branch 'main' into apple_silicon_ci
This commit is contained in:
commit
c4c258f1f8
|
@ -30,13 +30,15 @@ tasks:
|
|||
- "//..."
|
||||
test_targets:
|
||||
- "//..."
|
||||
# TODO: https://github.com/bazelbuild/rules_foreign_cc/issues/495
|
||||
# TODO: https://github.com/bazel-contrib/rules_foreign_cc/issues/495
|
||||
- "-//test:shell_method_symlink_contents_to_dir_test"
|
||||
- "-//test:shell_script_inner_fun_test"
|
||||
build_flags:
|
||||
- "--noenable_bzlmod"
|
||||
- "--enable_workspace"
|
||||
test_flags:
|
||||
- "--noenable_bzlmod"
|
||||
- "--enable_workspace"
|
||||
ubuntu1804_examples_standalone:
|
||||
name: Examples (spawn_strategy=standalone)
|
||||
platform: ubuntu1804
|
||||
|
@ -50,12 +52,14 @@ tasks:
|
|||
- "dbg"
|
||||
- "--spawn_strategy=standalone"
|
||||
- "--noenable_bzlmod"
|
||||
- "--enable_workspace"
|
||||
test_targets: *linux_targets_standalone
|
||||
test_flags:
|
||||
- "-c"
|
||||
- "dbg"
|
||||
- "--spawn_strategy=standalone"
|
||||
- "--noenable_bzlmod"
|
||||
- "--enable_workspace"
|
||||
ubuntu2004_examples:
|
||||
name: Examples
|
||||
platform: ubuntu2004
|
||||
|
@ -67,8 +71,10 @@ tasks:
|
|||
test_targets: *linux_targets
|
||||
build_flags:
|
||||
- "--noenable_bzlmod"
|
||||
- "--enable_workspace"
|
||||
test_flags:
|
||||
- "--noenable_bzlmod"
|
||||
- "--enable_workspace"
|
||||
ubuntu2004_examples_bzlmod:
|
||||
name: Examples (bzlmod)
|
||||
platform: ubuntu2004
|
||||
|
@ -113,6 +119,7 @@ tasks:
|
|||
- "--spawn_strategy=standalone"
|
||||
- "--noincompatible_enable_cc_toolchain_resolution"
|
||||
- "--noenable_bzlmod"
|
||||
- "--enable_workspace"
|
||||
test_targets: *macos_targets_standalone
|
||||
test_flags:
|
||||
- "-c"
|
||||
|
@ -120,6 +127,7 @@ tasks:
|
|||
- "--spawn_strategy=standalone"
|
||||
- "--noincompatible_enable_cc_toolchain_resolution"
|
||||
- "--noenable_bzlmod"
|
||||
- "--enable_workspace"
|
||||
macos_arm64_examples:
|
||||
name: Examples (arm64)
|
||||
platform: macos_arm64
|
||||
|
@ -133,6 +141,10 @@ tasks:
|
|||
- "-@rules_foreign_cc_examples_third_party//openssl:openssl_test"
|
||||
build_targets: *macos_arm64_targets
|
||||
test_targets: *macos_arm64_targets
|
||||
build_flags:
|
||||
- "--enable_workspace"
|
||||
test_flags:
|
||||
- "--enable_workspace"
|
||||
macos_examples:
|
||||
name: Examples
|
||||
platform: macos
|
||||
|
@ -148,10 +160,12 @@ tasks:
|
|||
build_flags:
|
||||
- "--noincompatible_enable_cc_toolchain_resolution"
|
||||
- "--noenable_bzlmod"
|
||||
- "--enable_workspace"
|
||||
test_targets: *macos_targets
|
||||
test_flags:
|
||||
- "--noincompatible_enable_cc_toolchain_resolution"
|
||||
- "--noenable_bzlmod"
|
||||
- "--enable_workspace"
|
||||
windows_examples:
|
||||
name: Examples
|
||||
platform: windows
|
||||
|
@ -182,8 +196,10 @@ tasks:
|
|||
test_targets: *windows_targets
|
||||
build_flags:
|
||||
- "--noenable_bzlmod"
|
||||
- "--enable_workspace"
|
||||
test_flags:
|
||||
- "--noenable_bzlmod"
|
||||
- "--enable_workspace"
|
||||
rbe_ubuntu2004_flags:
|
||||
name: Flags
|
||||
platform: rbe_ubuntu2004
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
"name": "James Sharpe"
|
||||
}
|
||||
],
|
||||
"repository": ["github:bazelbuild/rules_foreign_cc"],
|
||||
"repository": ["github:bazel-contrib/rules_foreign_cc"],
|
||||
"versions": [],
|
||||
"yanked_versions": {}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
*.bazel linguist-language=Starlark
|
||||
|
||||
# TODO: remove once https://github.com/github-linguist/linguist/pull/7121 lands
|
||||
WORKSPACE.bzlmod linguist-language=Starlark
|
||||
|
||||
# .bazelrc are mostly a collection of the CLI arguments, so highlighting them
|
||||
# as shell scripts looks quite alright and makes them quite readable
|
||||
.bazelrc linguist-language=Shell
|
|
@ -21,7 +21,7 @@ index 0000000..5096728
|
|||
+title = "Rules ForeignCc"
|
||||
+
|
||||
+[output.html]
|
||||
+git-repository-url = "https://github.com/bazelbuild/rules_foreign_cc"
|
||||
+git-repository-url = "https://github.com/bazel-contrib/rules_foreign_cc"
|
||||
diff --git a/docs/src/SUMMARY.md b/docs/src/SUMMARY.md
|
||||
new file mode 100644
|
||||
index 0000000..69fbd4d
|
||||
|
@ -40,3 +40,16 @@ index 0000000..98bb722
|
|||
+"""A module represeting the version of rules_foreign_cc"""
|
||||
+
|
||||
+VERSION = "0.1.0"
|
||||
diff --git a/docs/.bazelrc b/docs/.bazelrc
|
||||
new file mode 100644
|
||||
index 0000000..9eb0697
|
||||
--- /dev/null
|
||||
+++ b/docs/.bazelrc
|
||||
@@ -0,0 +1,7 @@
|
||||
+# Bazel configuration flags for rules_foreign_cc_docs
|
||||
+
|
||||
+# https://github.com/bazelbuild/stardoc/issues/112
|
||||
+common --incompatible_allow_tags_propagation
|
||||
+
|
||||
+common --noenable_bzlmod
|
||||
+build --workspace_status_command=tools/workspace_status.sh
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
diff --git a/docs/.bazelrc b/docs/.bazelrc
|
||||
index dc6a3f7..9eb0697 100644
|
||||
--- a/docs/.bazelrc
|
||||
+++ b/docs/.bazelrc
|
||||
@@ -1,3 +1,7 @@
|
||||
-# Bazel configuration flags for rules_foregin_cc_docs
|
||||
+# Bazel configuration flags for rules_foreign_cc_docs
|
||||
|
||||
+# https://github.com/bazelbuild/stardoc/issues/112
|
||||
+common --incompatible_allow_tags_propagation
|
||||
+
|
||||
+common --noenable_bzlmod
|
||||
build --workspace_status_command=tools/workspace_status.sh
|
|
@ -21,7 +21,7 @@ index 0000000..5096728
|
|||
+title = "Rules ForeignCc"
|
||||
+
|
||||
+[output.html]
|
||||
+git-repository-url = "https://github.com/bazelbuild/rules_foreign_cc"
|
||||
+git-repository-url = "https://github.com/bazel-contrib/rules_foreign_cc"
|
||||
diff --git a/docs/src/SUMMARY.md b/docs/src/SUMMARY.md
|
||||
new file mode 100644
|
||||
index 0000000..69fbd4d
|
||||
|
@ -40,3 +40,16 @@ index 0000000..98bb722
|
|||
+"""A module represeting the version of rules_foreign_cc"""
|
||||
+
|
||||
+VERSION = "0.2.0"
|
||||
diff --git a/docs/.bazelrc b/docs/.bazelrc
|
||||
new file mode 100644
|
||||
index 0000000..9eb0697
|
||||
--- /dev/null
|
||||
+++ b/docs/.bazelrc
|
||||
@@ -0,0 +1,7 @@
|
||||
+# Bazel configuration flags for rules_foreign_cc_docs
|
||||
+
|
||||
+# https://github.com/bazelbuild/stardoc/issues/112
|
||||
+common --incompatible_allow_tags_propagation
|
||||
+
|
||||
+common --noenable_bzlmod
|
||||
+build --workspace_status_command=tools/workspace_status.sh
|
||||
|
|
|
@ -36,7 +36,7 @@ index 0000000..5096728
|
|||
+title = "Rules ForeignCc"
|
||||
+
|
||||
+[output.html]
|
||||
+git-repository-url = "https://github.com/bazelbuild/rules_foreign_cc"
|
||||
+git-repository-url = "https://github.com/bazel-contrib/rules_foreign_cc"
|
||||
diff --git a/docs/index.md b/docs/index.md
|
||||
index 3a91e41..14c8e3b 100644
|
||||
--- a/docs/index.md
|
||||
|
@ -47,13 +47,13 @@ index 3a91e41..14c8e3b 100644
|
|||
name = "rules_foreign_cc",
|
||||
- sha256 = "d54742ffbdc6924f222d2179f0e10e911c5c659c4ae74158e9fe827aad862ac6",
|
||||
- strip_prefix = "rules_foreign_cc-0.2.0",
|
||||
- url = "https://github.com/bazelbuild/rules_foreign_cc/archive/0.2.0.tar.gz",
|
||||
- url = "https://github.com/bazel-contrib/rules_foreign_cc/archive/0.2.0.tar.gz",
|
||||
+ # TODO: Get the latest sha256 value from the latest release on the releases page
|
||||
+ # https://github.com/bazelbuild/rules_foreign_cc/releases
|
||||
+ # https://github.com/bazel-contrib/rules_foreign_cc/releases
|
||||
+ #
|
||||
+ # sha256 = "...",
|
||||
+ strip_prefix = "rules_foreign_cc-0.3.0",
|
||||
+ url = "https://github.com/bazelbuild/rules_foreign_cc/archive/0.3.0.tar.gz",
|
||||
+ url = "https://github.com/bazel-contrib/rules_foreign_cc/archive/0.3.0.tar.gz",
|
||||
)
|
||||
|
||||
load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies")
|
||||
|
@ -80,3 +80,16 @@ index 0000000..98bb722
|
|||
+"""A module represeting the version of rules_foreign_cc"""
|
||||
+
|
||||
+VERSION = "0.3.0"
|
||||
diff --git a/docs/.bazelrc b/docs/.bazelrc
|
||||
new file mode 100644
|
||||
index 0000000..9eb0697
|
||||
--- /dev/null
|
||||
+++ b/docs/.bazelrc
|
||||
@@ -0,0 +1,7 @@
|
||||
+# Bazel configuration flags for rules_foreign_cc_docs
|
||||
+
|
||||
+# https://github.com/bazelbuild/stardoc/issues/112
|
||||
+common --incompatible_allow_tags_propagation
|
||||
+
|
||||
+common --noenable_bzlmod
|
||||
+build --workspace_status_command=tools/workspace_status.sh
|
||||
|
|
|
@ -11,3 +11,16 @@ index 2bdbf6e..418dd13 100644
|
|||
release="\\$${RELEASE}"
|
||||
fi
|
||||
mkdir -p \\$${BUILD_WORKSPACE_DIRECTORY}/src
|
||||
diff --git a/docs/.bazelrc b/docs/.bazelrc
|
||||
index dc6a3f7..9eb0697 100644
|
||||
--- a/docs/.bazelrc
|
||||
+++ b/docs/.bazelrc
|
||||
@@ -1,3 +1,7 @@
|
||||
-# Bazel configuration flags for rules_foregin_cc_docs
|
||||
+# Bazel configuration flags for rules_foreign_cc_docs
|
||||
|
||||
+# https://github.com/bazelbuild/stardoc/issues/112
|
||||
+common --incompatible_allow_tags_propagation
|
||||
+
|
||||
+common --noenable_bzlmod
|
||||
build --workspace_status_command=tools/workspace_status.sh
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
diff --git a/docs/.bazelrc b/docs/.bazelrc
|
||||
index dc6a3f7..9eb0697 100644
|
||||
--- a/docs/.bazelrc
|
||||
+++ b/docs/.bazelrc
|
||||
@@ -1,3 +1,7 @@
|
||||
-# Bazel configuration flags for rules_foregin_cc_docs
|
||||
+# Bazel configuration flags for rules_foreign_cc_docs
|
||||
|
||||
+# https://github.com/bazelbuild/stardoc/issues/112
|
||||
+common --incompatible_allow_tags_propagation
|
||||
+
|
||||
+common --noenable_bzlmod
|
||||
build --workspace_status_command=tools/workspace_status.sh
|
|
@ -0,0 +1,13 @@
|
|||
diff --git a/docs/.bazelrc b/docs/.bazelrc
|
||||
index dc6a3f7..9eb0697 100644
|
||||
--- a/docs/.bazelrc
|
||||
+++ b/docs/.bazelrc
|
||||
@@ -1,3 +1,7 @@
|
||||
-# Bazel configuration flags for rules_foregin_cc_docs
|
||||
+# Bazel configuration flags for rules_foreign_cc_docs
|
||||
|
||||
+# https://github.com/bazelbuild/stardoc/issues/112
|
||||
+common --incompatible_allow_tags_propagation
|
||||
+
|
||||
+common --noenable_bzlmod
|
||||
build --workspace_status_command=tools/workspace_status.sh
|
|
@ -0,0 +1,13 @@
|
|||
diff --git a/docs/.bazelrc b/docs/.bazelrc
|
||||
index dc6a3f7..9eb0697 100644
|
||||
--- a/docs/.bazelrc
|
||||
+++ b/docs/.bazelrc
|
||||
@@ -1,3 +1,7 @@
|
||||
-# Bazel configuration flags for rules_foregin_cc_docs
|
||||
+# Bazel configuration flags for rules_foreign_cc_docs
|
||||
|
||||
+# https://github.com/bazelbuild/stardoc/issues/112
|
||||
+common --incompatible_allow_tags_propagation
|
||||
+
|
||||
+common --noenable_bzlmod
|
||||
build --workspace_status_command=tools/workspace_status.sh
|
|
@ -0,0 +1,13 @@
|
|||
diff --git a/docs/.bazelrc b/docs/.bazelrc
|
||||
index dc6a3f7..9eb0697 100644
|
||||
--- a/docs/.bazelrc
|
||||
+++ b/docs/.bazelrc
|
||||
@@ -1,3 +1,7 @@
|
||||
-# Bazel configuration flags for rules_foregin_cc_docs
|
||||
+# Bazel configuration flags for rules_foreign_cc_docs
|
||||
|
||||
+# https://github.com/bazelbuild/stardoc/issues/112
|
||||
+common --incompatible_allow_tags_propagation
|
||||
+
|
||||
+common --noenable_bzlmod
|
||||
build --workspace_status_command=tools/workspace_status.sh
|
|
@ -0,0 +1,13 @@
|
|||
diff --git a/docs/.bazelrc b/docs/.bazelrc
|
||||
index dc6a3f7..9eb0697 100644
|
||||
--- a/docs/.bazelrc
|
||||
+++ b/docs/.bazelrc
|
||||
@@ -1,3 +1,7 @@
|
||||
-# Bazel configuration flags for rules_foregin_cc_docs
|
||||
+# Bazel configuration flags for rules_foreign_cc_docs
|
||||
|
||||
+# https://github.com/bazelbuild/stardoc/issues/112
|
||||
+common --incompatible_allow_tags_propagation
|
||||
+
|
||||
+common --noenable_bzlmod
|
||||
build --workspace_status_command=tools/workspace_status.sh
|
|
@ -0,0 +1,13 @@
|
|||
diff --git a/docs/.bazelrc b/docs/.bazelrc
|
||||
index dc6a3f7..9eb0697 100644
|
||||
--- a/docs/.bazelrc
|
||||
+++ b/docs/.bazelrc
|
||||
@@ -1,3 +1,7 @@
|
||||
-# Bazel configuration flags for rules_foregin_cc_docs
|
||||
+# Bazel configuration flags for rules_foreign_cc_docs
|
||||
|
||||
+# https://github.com/bazelbuild/stardoc/issues/112
|
||||
+common --incompatible_allow_tags_propagation
|
||||
+
|
||||
+common --noenable_bzlmod
|
||||
build --workspace_status_command=tools/workspace_status.sh
|
|
@ -0,0 +1,13 @@
|
|||
diff --git a/docs/.bazelrc b/docs/.bazelrc
|
||||
index dc6a3f7..9eb0697 100644
|
||||
--- a/docs/.bazelrc
|
||||
+++ b/docs/.bazelrc
|
||||
@@ -1,3 +1,7 @@
|
||||
-# Bazel configuration flags for rules_foregin_cc_docs
|
||||
+# Bazel configuration flags for rules_foreign_cc_docs
|
||||
|
||||
+# https://github.com/bazelbuild/stardoc/issues/112
|
||||
+common --incompatible_allow_tags_propagation
|
||||
+
|
||||
+common --noenable_bzlmod
|
||||
build --workspace_status_command=tools/workspace_status.sh
|
|
@ -17,6 +17,9 @@ jobs:
|
|||
# Create a job for release
|
||||
include:
|
||||
- ref: main
|
||||
- ref: "0.12.0"
|
||||
- ref: "0.11.1"
|
||||
- ref: "0.11.0"
|
||||
- ref: "0.10.1"
|
||||
- ref: "0.9.0"
|
||||
- ref: "0.8.0"
|
||||
|
@ -41,10 +44,19 @@ jobs:
|
|||
if: ${{ matrix.ref == 'main' }}
|
||||
- name: Patch older branches
|
||||
run: |
|
||||
ref="${{ matrix.ref }}"
|
||||
|
||||
[[ "$ref" == "main" ]] && exit
|
||||
|
||||
v_major="$(echo "$ref" | cut -d. -f1)"
|
||||
v_minor="$(echo "$ref" | cut -d. -f2)"
|
||||
v_patch="$(echo "$ref" | cut -d. -f3)"
|
||||
|
||||
[[ $v_minor -gt 10 ]] && exit
|
||||
|
||||
mkdir -p ${{ github.workspace }}/.github
|
||||
curl https://raw.githubusercontent.com/bazelbuild/rules_foreign_cc/main/.github/docs-${{ matrix.ref }}.patch > ${{ github.workspace }}/.github/docs-${{ matrix.ref }}.patch
|
||||
curl https://raw.githubusercontent.com/bazel-contrib/rules_foreign_cc/main/.github/docs-${{ matrix.ref }}.patch > ${{ github.workspace }}/.github/docs-${{ matrix.ref }}.patch
|
||||
git apply ${{ github.workspace }}/.github/docs-${{ matrix.ref }}.patch
|
||||
if: ${{ matrix.ref == '0.4.0' || matrix.ref == '0.3.0' || matrix.ref == '0.2.0' || matrix.ref == '0.1.0' }}
|
||||
- name: Install bazelisk
|
||||
run: |
|
||||
curl -LO "https://github.com/bazelbuild/bazelisk/releases/download/v1.9.0/bazelisk-linux-amd64"
|
||||
|
@ -67,7 +79,7 @@ jobs:
|
|||
run: ${{ github.workspace }}/bin/mdbook build
|
||||
working-directory: ${{ github.workspace }}/docs
|
||||
- name: Save the newly built book
|
||||
uses: actions/upload-artifact@v2
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: "${{ matrix.ref }}"
|
||||
path: ${{ github.workspace }}/docs/book
|
||||
|
@ -78,7 +90,7 @@ jobs:
|
|||
if: ${{ matrix.ref == 'main' }}
|
||||
working-directory: ${{ github.workspace }}/docs/root
|
||||
- name: Save the newly built book
|
||||
uses: actions/upload-artifact@v2
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: "${{ matrix.ref }}-root"
|
||||
path: ${{ github.workspace }}/docs/root/book
|
||||
|
|
|
@ -31,7 +31,7 @@ http_archive(
|
|||
name = "rules_foreign_cc",
|
||||
sha256 = "${SHA}",
|
||||
strip_prefix = "${PREFIX}",
|
||||
url = "https://github.com/bazelbuild/rules_foreign_cc/releases/download/${TAG}/${ARCHIVE}",
|
||||
url = "https://github.com/bazel-contrib/rules_foreign_cc/releases/download/${TAG}/${ARCHIVE}",
|
||||
)
|
||||
|
||||
load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies")
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
"bazelbuild/rules_foreign_cc"
|
||||
"bazel-contrib/rules_foreign_cc"
|
||||
|
||||
module(
|
||||
name = "rules_foreign_cc",
|
||||
|
@ -15,6 +15,10 @@ bazel_dep(name = "rules_python", version = "0.23.1")
|
|||
bazel_dep(name = "gazelle", version = "0.34.0", dev_dependency = True, repo_name = "bazel_gazelle")
|
||||
bazel_dep(name = "bazel_skylib_gazelle_plugin", version = "1.5.0", dev_dependency = True)
|
||||
bazel_dep(name = "stardoc", version = "0.5.6", dev_dependency = True, repo_name = "io_bazel_stardoc")
|
||||
bazel_dep(name = "bazel_ci_rules", version = "1.0.0", dev_dependency = True)
|
||||
|
||||
# note that this dev_dependency is only needed because bazel_ci_rules
|
||||
# depends on it. If you are not using bazel_ci_rules; ideally we'd be able to remove this.
|
||||
bazel_dep(name = "rules_cc", version = "0.0.9", dev_dependency = True)
|
||||
|
||||
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
|
||||
|
|
|
@ -9,7 +9,7 @@ This is **not an officially supported Google product**
|
|||
|
||||
## Documentation
|
||||
|
||||
Documentation for all rules and providers are available at: https://bazelbuild.github.io/rules_foreign_cc/
|
||||
Documentation for all rules and providers are available at: https://bazel-contrib.github.io/rules_foreign_cc/
|
||||
|
||||
## Bazel versions compatibility
|
||||
|
||||
|
@ -24,7 +24,7 @@ variable](https://bazel.build/reference/be/make-variables)
|
|||
## News
|
||||
|
||||
For more generalized updates, please see [NEWS.md](./NEWS.md) or checkout the
|
||||
[release notes](https://github.com/bazelbuild/rules_foreign_cc/releases) of current or previous releases
|
||||
[release notes](https://github.com/bazel-contrib/rules_foreign_cc/releases) of current or previous releases
|
||||
|
||||
## Design document
|
||||
|
||||
|
|
|
@ -1,15 +1,6 @@
|
|||
workspace(name = "rules_foreign_cc")
|
||||
|
||||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
||||
|
||||
http_archive(
|
||||
name = "bazelci_rules",
|
||||
sha256 = "eca21884e6f66a88c358e580fd67a6b148d30ab57b1680f62a96c00f9bc6a07e",
|
||||
strip_prefix = "bazelci_rules-1.0.0",
|
||||
url = "https://github.com/bazelbuild/continuous-integration/releases/download/rules-1.0.0/bazelci_rules-1.0.0.tar.gz",
|
||||
)
|
||||
|
||||
load("@bazelci_rules//:rbe_repo.bzl", "rbe_preconfig")
|
||||
load("@bazel_ci_rules//:rbe_repo.bzl", "rbe_preconfig")
|
||||
|
||||
# Creates a default toolchain config for RBE.
|
||||
# Use this as is if you are using the rbe_ubuntu16_04 container,
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
# Rules ForeignCc Docs
|
||||
|
||||
Up to date documentation can be found at: https://bazelbuild.github.io/rules_foreign_cc/
|
||||
Up to date documentation can be found at: https://bazel-contrib.github.io/rules_foreign_cc/
|
||||
|
||||
## Legacy documentation
|
||||
|
||||
|
|
|
@ -2,4 +2,4 @@
|
|||
title = "Rules ForeignCc"
|
||||
|
||||
[output.html]
|
||||
git-repository-url = "https://github.com/bazelbuild/rules_foreign_cc"
|
||||
git-repository-url = "https://github.com/bazel-contrib/rules_foreign_cc"
|
||||
|
|
|
@ -4,7 +4,7 @@ Rules for building C/C++ projects using foreign build systems (non Bazel) inside
|
|||
|
||||
| Release | Commit | Status |
|
||||
| --- | --------- | --- |
|
||||
| {release} | [{short_commit}](https://github.com/bazelbuild/rules_foreign_cc/commit/{commit}) | [![Build status](https://badge.buildkite.com/c28afbf846e2077715c753dda1f4b820cdcc46cc6cde16503c.svg?branch=main)](https://buildkite.com/bazel/rules-foreign-cc/builds?branch=main) |
|
||||
| {release} | [{short_commit}](https://github.com/bazel-contrib/rules_foreign_cc/commit/{commit}) | [![Build status](https://badge.buildkite.com/c28afbf846e2077715c753dda1f4b820cdcc46cc6cde16503c.svg?branch=main)](https://buildkite.com/bazel/rules-foreign-cc/builds?branch=main) |
|
||||
|
||||
## Overview
|
||||
|
||||
|
@ -26,11 +26,11 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
|||
http_archive(
|
||||
name = "rules_foreign_cc",
|
||||
# TODO: Get the latest sha256 value from a bazel debug message or the latest
|
||||
# release on the releases page: https://github.com/bazelbuild/rules_foreign_cc/releases
|
||||
# release on the releases page: https://github.com/bazel-contrib/rules_foreign_cc/releases
|
||||
#
|
||||
# sha256 = "...",
|
||||
strip_prefix = "rules_foreign_cc-{release_archive}",
|
||||
url = "https://github.com/bazelbuild/rules_foreign_cc/archive/{release_archive}.tar.gz",
|
||||
url = "https://github.com/bazel-contrib/rules_foreign_cc/archive/{release_archive}.tar.gz",
|
||||
)
|
||||
|
||||
load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies")
|
||||
|
|
|
@ -2,4 +2,4 @@
|
|||
title = "Rules ForeignCc"
|
||||
|
||||
[output.html]
|
||||
git-repository-url = "https://github.com/bazelbuild/rules_foreign_cc"
|
||||
git-repository-url = "https://github.com/bazel-contrib/rules_foreign_cc"
|
||||
|
|
|
@ -5,6 +5,9 @@ Rules for building C/C++ projects using foreign build systems (non Bazel) inside
|
|||
## Versions
|
||||
|
||||
- [main](main/index.md)
|
||||
- [0.12.0](0.12.0/index.md)
|
||||
- [0.11.1](0.11.1/index.md)
|
||||
- [0.11.0](0.11.0/index.md)
|
||||
- [0.10.1](0.10.1/index.md)
|
||||
- [0.9.0](0.9.0/index.md)
|
||||
- [0.8.0](0.8.0/index.md)
|
||||
|
|
|
@ -18,6 +18,7 @@ bazel_dep(name = "rules_apple", version = "3.4.0", repo_name = "build_bazel_rule
|
|||
bazel_dep(name = "apple_support", version = "1.12.0", repo_name = "build_bazel_apple_support")
|
||||
bazel_dep(name = "rules_python", version = "0.35.0")
|
||||
|
||||
|
||||
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
|
||||
python.toolchain(
|
||||
configure_coverage_tool = True,
|
||||
|
|
|
@ -39,6 +39,6 @@ A file containing a single macro `lib_repositories` that should define the desir
|
|||
`BUILD.lib.bazel` file will correctly be installed when the repository is setup. This macro will need to be
|
||||
loaded and called in [`third_party/repositories.bzl`](./third_party/repositories.bzl).
|
||||
|
||||
[cmake_external]: https://github.com/bazelbuild/rules_foreign_cc/tree/main/docs#cmake_external
|
||||
[configure_make]: https://github.com/bazelbuild/rules_foreign_cc/tree/main/docs#configure_make
|
||||
[cmake_external]: https://github.com/bazel-contrib/rules_foreign_cc/tree/main/docs#cmake_external
|
||||
[configure_make]: https://github.com/bazel-contrib/rules_foreign_cc/tree/main/docs#configure_make
|
||||
[test_suite]: https://docs.bazel.build/versions/master/be/general.html#test_suite
|
||||
|
|
|
@ -21,8 +21,8 @@ cmake(
|
|||
cmake(
|
||||
name = "lib_with_duplicate_transitive_bazel_deps",
|
||||
cache_entries = {
|
||||
"LIBA_DIR": "$$EXT_BUILD_DEPS$$",
|
||||
"LIBB_DIR": "$$EXT_BUILD_DEPS$$",
|
||||
"LIBA_DIR": "$$EXT_BUILD_DEPS",
|
||||
"LIBB_DIR": "$$EXT_BUILD_DEPS",
|
||||
},
|
||||
generate_args = ["-GNinja"],
|
||||
lib_name = "libc",
|
||||
|
|
|
@ -10,7 +10,7 @@ cmake(
|
|||
"CMAKE_DISABLE_FIND_PACKAGE_LIBA": "True",
|
||||
# as currently we copy all libraries, built with Bazel, into $EXT_BUILD_DEPS/lib
|
||||
# and the headers into $EXT_BUILD_DEPS/include
|
||||
"LIBA_DIR": "$EXT_BUILD_DEPS",
|
||||
"LIBA_DIR": "$$EXT_BUILD_DEPS",
|
||||
},
|
||||
generate_args = ["-GNinja"],
|
||||
lib_source = "//cmake_with_bazel_transitive/libb:b_srcs",
|
||||
|
|
|
@ -15,10 +15,10 @@ def apr_repositories():
|
|||
Label("//apr:windows_winnt.patch"),
|
||||
],
|
||||
sha256 = "",
|
||||
strip_prefix = "apr-1.7.4",
|
||||
strip_prefix = "apr-1.7.5",
|
||||
urls = [
|
||||
"https://mirror.bazel.build/www-eu.apache.org/dist/apr/apr-1.7.4.tar.gz",
|
||||
"https://dlcdn.apache.org/apr/apr-1.7.4.tar.gz",
|
||||
"https://www-eu.apache.org/dist/apr/apr-1.7.4.tar.gz",
|
||||
"https://mirror.bazel.build/www-eu.apache.org/dist/apr/apr-1.7.5.tar.gz",
|
||||
"https://dlcdn.apache.org/apr/apr-1.7.5.tar.gz",
|
||||
"https://www-eu.apache.org/dist/apr/apr-1.7.5.tar.gz",
|
||||
],
|
||||
)
|
||||
|
|
|
@ -12,11 +12,9 @@ _CACHE_ENTRIES = {
|
|||
"BUILD_CURL_EXE": "off",
|
||||
"BUILD_SHARED_LIBS": "off",
|
||||
"CMAKE_BUILD_TYPE": "RELEASE",
|
||||
"CMAKE_PREFIX_PATH": "$$EXT_BUILD_DEPS$$/openssl",
|
||||
"CMAKE_USE_OPENSSL": "on",
|
||||
# TODO: ldap should likely be enabled
|
||||
"CURL_DISABLE_LDAP": "on",
|
||||
"OPENSSL_ROOT_DIR": "$$EXT_BUILD_DEPS$$/openssl",
|
||||
}
|
||||
|
||||
_MACOS_CACHE_ENTRIES = dict(_CACHE_ENTRIES.items() + {
|
||||
|
|
|
@ -13,13 +13,12 @@ _CACHE_ENTRIES = {
|
|||
"BUILD_EXAMPLES": "off",
|
||||
"BUILD_FUZZERS": "off",
|
||||
"BUILD_SHARED_LIBS": "off",
|
||||
"CMAKE_PREFIX_PATH": "$EXT_BUILD_DEPS/pcre;$EXT_BUILD_DEPS/openssl;$EXT_BUILD_DEPS/libssh2;$EXT_BUILD_DEPS/zlib;${CMAKE_PREFIX_PATH:-}",
|
||||
"EMBED_SSH_PATH": "$(location @libssh2//:libssh2)",
|
||||
#"EMBED_SSH_PATH": "$(location @libssh2//:libssh2)",
|
||||
"USE_HTTPS": "on",
|
||||
}
|
||||
|
||||
_LINUX_CACHE_ENTRIES = dict(_CACHE_ENTRIES.items() + {
|
||||
"CMAKE_C_FLAGS": "${CMAKE_C_FLAGS:-} -fPIC",
|
||||
"CMAKE_C_FLAGS": "$${CMAKE_C_FLAGS:-} -fPIC",
|
||||
"REGEX_BACKEND": "pcre2",
|
||||
}.items())
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ cmake(
|
|||
cache_entries = {
|
||||
"CMAKE_BUILD_TYPE": "RELEASE",
|
||||
"CMAKE_POLICY_DEFAULT_CMP0074": "NEW",
|
||||
"ZLIB_ROOT": "$EXT_BUILD_DEPS/zlib",
|
||||
"ZLIB_ROOT": "$$EXT_BUILD_DEPS/zlib",
|
||||
},
|
||||
lib_source = "//:all_srcs",
|
||||
out_include_dir = "include/libpng16",
|
||||
|
|
|
@ -13,11 +13,10 @@ _CACHE_ENTRIES = {
|
|||
"BUILD_SHARED_LIBS": "off",
|
||||
"BUILD_TESTING": "off",
|
||||
"CMAKE_FIND_DEBUG_MODE": "on",
|
||||
"CMAKE_PREFIX_PATH": "${CMAKE_PREFIX_PATH:-};$EXT_BUILD_DEPS/openssl",
|
||||
}
|
||||
|
||||
_LINUX_CACHE_ENTRIES = dict(_CACHE_ENTRIES.items() + {
|
||||
"CMAKE_C_FLAGS": "${CMAKE_C_FLAGS:-} -fPIC",
|
||||
"CMAKE_C_FLAGS": "$${CMAKE_C_FLAGS:-} -fPIC",
|
||||
}.items())
|
||||
|
||||
cmake(
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
"""An openssl build file based on a snippet found in the github issue:
|
||||
https://github.com/bazelbuild/rules_foreign_cc/issues/337
|
||||
https://github.com/bazel-contrib/rules_foreign_cc/issues/337
|
||||
|
||||
Note that the $(PERL) "make variable" (https://docs.bazel.build/versions/main/be/make-variables.html)
|
||||
is populated by the perl toolchain provided by rules_perl.
|
||||
|
|
|
@ -15,7 +15,7 @@ filegroup(
|
|||
cmake(
|
||||
name = "pcre",
|
||||
cache_entries = {
|
||||
"CMAKE_C_FLAGS": "${CMAKE_C_FLAGS:-} -fPIC",
|
||||
"CMAKE_C_FLAGS": "$${CMAKE_C_FLAGS:-} -fPIC",
|
||||
},
|
||||
lib_source = ":all_srcs",
|
||||
out_static_libs = select({
|
||||
|
|
|
@ -15,7 +15,7 @@ cmake(
|
|||
name = "zlib",
|
||||
cache_entries = select({
|
||||
"@platforms//os:linux": {
|
||||
"CMAKE_C_FLAGS": "${CMAKE_C_FLAGS:-} -fPIC",
|
||||
"CMAKE_C_FLAGS": "$${CMAKE_C_FLAGS:-} -fPIC",
|
||||
},
|
||||
"//conditions:default": {},
|
||||
}),
|
||||
|
|
|
@ -61,7 +61,4 @@ boost_build = rule(
|
|||
"@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,
|
||||
)
|
||||
|
|
|
@ -88,7 +88,10 @@ def _pkgconfig_tool_impl(ctx):
|
|||
"%s install" % make_data.path,
|
||||
]
|
||||
|
||||
additional_tools = depset(transitive = [make_data.target.files])
|
||||
if make_data.target:
|
||||
additional_tools = depset(transitive = [make_data.target.files])
|
||||
else:
|
||||
additional_tools = depset()
|
||||
|
||||
return built_tool_rule_impl(
|
||||
ctx,
|
||||
|
@ -166,7 +169,7 @@ def pkgconfig_tool(name, srcs, **kwargs):
|
|||
"@platforms//os:windows": "cp release/x64/pkg-config.exe $$INSTALLDIR$$/bin",
|
||||
"//conditions:default": "",
|
||||
}),
|
||||
toolchain = "@rules_foreign_cc//toolchains:preinstalled_nmake_toolchain",
|
||||
toolchain = str(Label("//toolchains:preinstalled_nmake_toolchain")),
|
||||
tags = tags,
|
||||
**kwargs
|
||||
)
|
||||
|
|
|
@ -70,15 +70,13 @@ def built_tool_rule_impl(ctx, script_lines, out_dir, mnemonic, additional_tools
|
|||
|
||||
root = detect_root(ctx.attr.srcs)
|
||||
lib_name = ctx.attr.name
|
||||
env_prelude = get_env_prelude(ctx, lib_name, [], "")
|
||||
env_prelude = get_env_prelude(ctx, out_dir.path, [])
|
||||
|
||||
cc_toolchain = find_cpp_toolchain(ctx)
|
||||
|
||||
script = env_prelude + [
|
||||
script = [
|
||||
"##script_prelude##",
|
||||
"export EXT_BUILD_ROOT=##pwd##",
|
||||
"export INSTALLDIR=$$EXT_BUILD_ROOT$$/{}".format(out_dir.path),
|
||||
"export BUILD_TMPDIR=$$INSTALLDIR$$.build_tmpdir",
|
||||
] + env_prelude + [
|
||||
"##rm_rf## $$INSTALLDIR$$",
|
||||
"##rm_rf## $$BUILD_TMPDIR$$",
|
||||
"##mkdirs## $$INSTALLDIR$$",
|
||||
|
@ -97,7 +95,13 @@ def built_tool_rule_impl(ctx, script_lines, out_dir, mnemonic, additional_tools
|
|||
"",
|
||||
])
|
||||
|
||||
wrapped_outputs = wrap_outputs(ctx, lib_name, mnemonic, script_text)
|
||||
wrapped_outputs = wrap_outputs(
|
||||
ctx,
|
||||
lib_name = lib_name,
|
||||
configure_name = mnemonic,
|
||||
env_prelude = env_prelude,
|
||||
script_text = script_text,
|
||||
)
|
||||
|
||||
tools = depset(
|
||||
[wrapped_outputs.wrapper_script_file, wrapped_outputs.script_file],
|
||||
|
|
|
@ -28,13 +28,13 @@ http_archive(
|
|||
name = "rules_foreign_cc",
|
||||
sha256 = "c2cdcf55ffaf49366725639e45dedd449b8c3fe22b54e31625eb80ce3a240f1e",
|
||||
strip_prefix = "rules_foreign_cc-0.1.0",
|
||||
url = "https://github.com/bazelbuild/rules_foreign_cc/archive/0.1.0.zip",
|
||||
url = "https://github.com/bazel-contrib/rules_foreign_cc/archive/0.1.0.zip",
|
||||
)
|
||||
|
||||
load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies")
|
||||
|
||||
# This sets up some common toolchains for building targets. For more details, please see
|
||||
# https://github.com/bazelbuild/rules_foreign_cc/tree/main/docs#rules_foreign_cc_dependencies
|
||||
# https://github.com/bazel-contrib/rules_foreign_cc/tree/main/docs#rules_foreign_cc_dependencies
|
||||
rules_foreign_cc_dependencies()
|
||||
|
||||
_ALL_CONTENT = \"\"\"\\
|
||||
|
@ -264,13 +264,14 @@ def _create_configure_script(configureParameters):
|
|||
install_prefix = "$$INSTALLDIR$$",
|
||||
root = root,
|
||||
no_toolchain_file = no_toolchain_file,
|
||||
user_cache = dict(ctx.attr.cache_entries),
|
||||
user_cache = expand_locations_and_make_variables(ctx, ctx.attr.cache_entries, "cache_entries", data),
|
||||
user_env = expand_locations_and_make_variables(ctx, ctx.attr.env, "env", data),
|
||||
options = attrs.generate_args,
|
||||
cmake_commands = cmake_commands,
|
||||
cmake_prefix = prefix,
|
||||
include_dirs = inputs.include_dirs,
|
||||
is_debug_mode = is_debug_mode(ctx),
|
||||
ext_build_dirs = inputs.ext_build_dirs,
|
||||
)
|
||||
return configure_script
|
||||
|
||||
|
@ -420,9 +421,6 @@ cmake = rule(
|
|||
"@bazel_tools//tools/cpp:toolchain_type",
|
||||
],
|
||||
provides = [CcInfo],
|
||||
# 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 cmake_variant(name, toolchain, **kwargs):
|
||||
|
|
|
@ -246,9 +246,6 @@ configure_make = rule(
|
|||
"@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 configure_make_variant(name, toolchain, **kwargs):
|
||||
|
|
|
@ -132,9 +132,6 @@ make = rule(
|
|||
"@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 make_variant(name, toolchain, **kwargs):
|
||||
|
|
|
@ -198,9 +198,6 @@ meson = rule(
|
|||
"@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):
|
||||
|
|
|
@ -118,7 +118,4 @@ ninja = rule(
|
|||
"@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,
|
||||
)
|
||||
|
|
|
@ -306,6 +306,11 @@ def get_flags_info(ctx, link_output_file = None):
|
|||
),
|
||||
),
|
||||
)
|
||||
|
||||
if "set_file_prefix_map" in dir(ctx.attr) and ctx.attr.set_file_prefix_map:
|
||||
copts.append("-ffile-prefix-map=$EXT_BUILD_ROOT=.")
|
||||
cxxopts.append("-ffile-prefix-map=$EXT_BUILD_ROOT=.")
|
||||
|
||||
return CxxFlagsInfo(
|
||||
cc = _convert_flags(cc_toolchain_.compiler, _add_if_needed(flags.cc, copts)),
|
||||
cxx = _convert_flags(cc_toolchain_.compiler, _add_if_needed(flags.cxx, cxxopts)),
|
||||
|
@ -330,7 +335,7 @@ def _convert_flags(compiler, flags):
|
|||
list: The converted flags
|
||||
"""
|
||||
if compiler == "msvc-cl":
|
||||
return [flag.replace("/", "-") if flag.startswith("/") else flag for flag in flags]
|
||||
return [("-" + flag.removeprefix("/")) if flag.startswith("/") else flag for flag in flags]
|
||||
return flags
|
||||
|
||||
def _add_if_needed(arr, add_arr):
|
||||
|
|
|
@ -58,7 +58,8 @@ def create_cmake_script(
|
|||
cmake_commands,
|
||||
include_dirs = [],
|
||||
cmake_prefix = None,
|
||||
is_debug_mode = True):
|
||||
is_debug_mode = True,
|
||||
ext_build_dirs = []):
|
||||
"""Constructs CMake script to be passed to cc_external_rule_impl.
|
||||
|
||||
Args:
|
||||
|
@ -81,12 +82,13 @@ def create_cmake_script(
|
|||
include_dirs: Optional additional include directories. Defaults to [].
|
||||
cmake_prefix: Optional prefix before the cmake command (without the trailing space).
|
||||
is_debug_mode: If the compilation mode is `debug`. Defaults to True.
|
||||
ext_build_dirs: A list of gen_dirs for each foreign_cc dep.
|
||||
|
||||
Returns:
|
||||
list: Lines of bash which make up the build script
|
||||
"""
|
||||
|
||||
merged_prefix_path = _merge_prefix_path(user_cache, include_dirs)
|
||||
merged_prefix_path = _merge_prefix_path(user_cache, include_dirs, ext_build_dirs)
|
||||
|
||||
toolchain_dict = _fill_crossfile_from_toolchain(workspace_name, tools, flags)
|
||||
params = None
|
||||
|
@ -123,8 +125,8 @@ def create_cmake_script(
|
|||
|
||||
# Avoid CMake passing the wrong linker flags when cross compiling
|
||||
# by setting CMAKE_SYSTEM_NAME and CMAKE_SYSTEM_PROCESSOR,
|
||||
# see https://github.com/bazelbuild/rules_foreign_cc/issues/289,
|
||||
# and https://github.com/bazelbuild/rules_foreign_cc/pull/1062
|
||||
# see https://github.com/bazel-contrib/rules_foreign_cc/issues/289,
|
||||
# and https://github.com/bazel-contrib/rules_foreign_cc/pull/1062
|
||||
if target_os == "unknown":
|
||||
# buildifier: disable=print
|
||||
print("target_os is unknown, please update foreign_cc/private/framework/platform.bzl and foreign_cc/private/cmake_script.bzl; triggered by", current_label)
|
||||
|
@ -171,9 +173,12 @@ def _wipe_empty_values(cache, keys_with_empty_values_in_user_cache):
|
|||
cache.pop(key)
|
||||
|
||||
# From CMake documentation: ;-list of directories specifying installation prefixes to be searched...
|
||||
def _merge_prefix_path(user_cache, include_dirs):
|
||||
def _merge_prefix_path(user_cache, include_dirs, ext_build_dirs):
|
||||
user_prefix = user_cache.get("CMAKE_PREFIX_PATH")
|
||||
values = ["$$EXT_BUILD_DEPS$$"] + include_dirs
|
||||
for ext_dir in ext_build_dirs:
|
||||
values.append("$$EXT_BUILD_DEPS$$/{}".format(ext_dir.basename))
|
||||
|
||||
if user_prefix != None:
|
||||
# remove it, it is gonna be merged specifically
|
||||
user_cache.pop("CMAKE_PREFIX_PATH")
|
||||
|
|
|
@ -201,6 +201,14 @@ CC_EXTERNAL_RULE_ATTRIBUTES = {
|
|||
doc = "Optional part of the shell script to be added after the make commands",
|
||||
mandatory = False,
|
||||
),
|
||||
"set_file_prefix_map": attr.bool(
|
||||
doc = (
|
||||
"Use -ffile-prefix-map with the intention to remove the sandbox path from " +
|
||||
"debug symbols"
|
||||
),
|
||||
mandatory = False,
|
||||
default = False,
|
||||
),
|
||||
"targets": attr.string_list(
|
||||
doc = (
|
||||
"A list of targets with in the foreign build system to produce. An empty string (`\"\"`) will result in " +
|
||||
|
@ -290,14 +298,13 @@ dependencies.""",
|
|||
def _is_msvc_var(var):
|
||||
return var == "INCLUDE" or var == "LIB"
|
||||
|
||||
def get_env_prelude(ctx, lib_name, data_dependencies, target_root):
|
||||
def get_env_prelude(ctx, installdir, data_dependencies):
|
||||
"""Generate a bash snippet containing environment variable definitions
|
||||
|
||||
Args:
|
||||
ctx (ctx): The rule's context object
|
||||
lib_name (str): The name of the target being built
|
||||
installdir (str): The path from the root target's directory in the build output
|
||||
data_dependencies (list): A list of targets representing dependencies
|
||||
target_root (str): The path from the root target's directory in the build output
|
||||
|
||||
Returns:
|
||||
tuple: A list of environment variables to define in the build script and a dict
|
||||
|
@ -305,7 +312,7 @@ def get_env_prelude(ctx, lib_name, data_dependencies, target_root):
|
|||
"""
|
||||
env_snippet = [
|
||||
"export EXT_BUILD_ROOT=##pwd##",
|
||||
"export INSTALLDIR=$$EXT_BUILD_ROOT$$/" + target_root + "/" + lib_name,
|
||||
"export INSTALLDIR=$$EXT_BUILD_ROOT$$/" + installdir,
|
||||
"export BUILD_TMPDIR=$$INSTALLDIR$$.build_tmpdir",
|
||||
"export EXT_BUILD_DEPS=$$INSTALLDIR$$.ext_build_deps",
|
||||
]
|
||||
|
@ -439,7 +446,8 @@ def cc_external_rule_impl(ctx, attrs):
|
|||
# Also add legacy dependencies while they're still available
|
||||
data_dependencies += ctx.attr.tools_deps + ctx.attr.additional_tools
|
||||
|
||||
env_prelude = get_env_prelude(ctx, lib_name, data_dependencies, target_root)
|
||||
installdir = target_root + "/" + lib_name
|
||||
env_prelude = get_env_prelude(ctx, installdir, data_dependencies)
|
||||
|
||||
postfix_script = [attrs.postfix_script]
|
||||
if not attrs.postfix_script:
|
||||
|
@ -483,7 +491,13 @@ def cc_external_rule_impl(ctx, attrs):
|
|||
convert_shell_script(ctx, script_lines),
|
||||
"",
|
||||
])
|
||||
wrapped_outputs = wrap_outputs(ctx, lib_name, attrs.configure_name, script_text)
|
||||
wrapped_outputs = wrap_outputs(
|
||||
ctx,
|
||||
lib_name = lib_name,
|
||||
configure_name = attrs.configure_name,
|
||||
script_text = script_text,
|
||||
env_prelude = env_prelude,
|
||||
)
|
||||
|
||||
rule_outputs = outputs.declared_outputs + [installdir_copy.file]
|
||||
cc_toolchain = find_cpp_toolchain(ctx)
|
||||
|
@ -587,7 +601,7 @@ WrappedOutputs = provider(
|
|||
)
|
||||
|
||||
# buildifier: disable=function-docstring
|
||||
def wrap_outputs(ctx, lib_name, configure_name, script_text, build_script_file = None):
|
||||
def wrap_outputs(ctx, lib_name, configure_name, script_text, env_prelude, build_script_file = None):
|
||||
extension = script_extension(ctx)
|
||||
build_log_file = ctx.actions.declare_file("{}_foreign_cc/{}.log".format(lib_name, configure_name))
|
||||
build_script_file = ctx.actions.declare_file("{}_foreign_cc/build_script{}".format(lib_name, extension))
|
||||
|
@ -602,15 +616,13 @@ def wrap_outputs(ctx, lib_name, configure_name, script_text, build_script_file =
|
|||
cleanup_on_success_function = create_function(
|
||||
ctx,
|
||||
"cleanup_on_success",
|
||||
"rm -rf $BUILD_TMPDIR $EXT_BUILD_DEPS",
|
||||
"rm -rf $$BUILD_TMPDIR$$ $$EXT_BUILD_DEPS$$",
|
||||
)
|
||||
cleanup_on_failure_function = create_function(
|
||||
ctx,
|
||||
"cleanup_on_failure",
|
||||
"\n".join([
|
||||
"##echo## \"rules_foreign_cc: Build failed!\"",
|
||||
"##echo## \"rules_foreign_cc: Keeping temp build directory $$BUILD_TMPDIR$$ and dependencies directory $$EXT_BUILD_DEPS$$ for debug.\"",
|
||||
"##echo## \"rules_foreign_cc: Please note that the directories inside a sandbox are still cleaned unless you specify '--sandbox_debug' Bazel command line flag.\"",
|
||||
"##echo## \"rules_foreign_cc: Printing build logs:\"",
|
||||
"##echo## \"_____ BEGIN BUILD LOGS _____\"",
|
||||
"##cat## $$BUILD_LOG$$",
|
||||
|
@ -618,18 +630,24 @@ def wrap_outputs(ctx, lib_name, configure_name, script_text, build_script_file =
|
|||
"##echo## \"rules_foreign_cc: Build wrapper script location: $$BUILD_WRAPPER_SCRIPT$$\"",
|
||||
"##echo## \"rules_foreign_cc: Build script location: $$BUILD_SCRIPT$$\"",
|
||||
"##echo## \"rules_foreign_cc: Build log location: $$BUILD_LOG$$\"",
|
||||
"##echo## \"rules_foreign_cc: Keeping these below directories for debug, but note that the directories inside a sandbox\"",
|
||||
"##echo## \"rules_foreign_cc: are still cleaned unless you specify the '--sandbox_debug' Bazel command line flag.\"",
|
||||
"##echo## \"rules_foreign_cc: Build Dir: $$BUILD_TMPDIR$$\"",
|
||||
"##echo## \"rules_foreign_cc: Deps Dir: $$EXT_BUILD_DEPS$$\"",
|
||||
"##echo## \"\"",
|
||||
]),
|
||||
)
|
||||
trap_function = "##cleanup_function## cleanup_on_success cleanup_on_failure"
|
||||
|
||||
build_command_lines = [
|
||||
"##script_prelude##",
|
||||
"##assert_script_errors##",
|
||||
cleanup_on_success_function,
|
||||
cleanup_on_failure_function,
|
||||
# the call trap is defined inside, in a way how the shell function should be called
|
||||
# see, for instance, linux_commands.bzl
|
||||
trap_function,
|
||||
] + env_prelude + [
|
||||
"export BUILD_WRAPPER_SCRIPT=\"{}\"".format(wrapper_script_file.path),
|
||||
"export BUILD_SCRIPT=\"{}\"".format(build_script_file.path),
|
||||
"export BUILD_LOG=\"{}\"".format(build_log_file.path),
|
||||
|
|
|
@ -38,7 +38,6 @@ extra_toolchains_transitioned_foreign_cc_target = rule(
|
|||
default = "@bazel_tools//tools/allowlists/function_transition_allowlist",
|
||||
),
|
||||
},
|
||||
incompatible_use_toolchain_transition = True,
|
||||
)
|
||||
|
||||
def foreign_cc_rule_variant(name, rule, toolchain, **kwargs):
|
||||
|
|
|
@ -44,7 +44,7 @@ def runnable_binary(name, binary, foreign_cc_target, match_binary_name = False,
|
|||
|
||||
wrapper_cmd = """
|
||||
sed s@EXECUTABLE@$(rlocationpath {name})@g $(location @rules_foreign_cc//foreign_cc/private:runnable_binary_wrapper.sh) > tmp
|
||||
sed s@SH_BINARY_FILENAME@{sh_binary_filename}@g tmp > $@
|
||||
cp tmp $@
|
||||
"""
|
||||
|
||||
if hasattr(native, "package_relative_label"):
|
||||
|
@ -57,10 +57,7 @@ def runnable_binary(name, binary, foreign_cc_target, match_binary_name = False,
|
|||
name = name + "_wrapper",
|
||||
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 = fg_label, sh_binary_filename = binary + ".exe" if match_binary_name else name),
|
||||
"//conditions:default": wrapper_cmd.format(name = fg_label, sh_binary_filename = binary if match_binary_name else name),
|
||||
}),
|
||||
cmd = wrapper_cmd.format(name = fg_label),
|
||||
tags = tags + ["manual"],
|
||||
)
|
||||
|
||||
|
|
|
@ -260,8 +260,6 @@ def _pkgconfig_toolchain(version, register_toolchains):
|
|||
http_archive,
|
||||
name = "glib_dev",
|
||||
build_file_content = '''
|
||||
load("@rules_cc//cc:defs.bzl", "cc_library")
|
||||
|
||||
cc_import(
|
||||
name = "glib_dev",
|
||||
hdrs = glob(["include/**"]),
|
||||
|
|
|
@ -99,5 +99,4 @@ native_tool_toolchain = rule(
|
|||
allow_files = True,
|
||||
),
|
||||
},
|
||||
incompatible_use_toolchain_transition = True,
|
||||
)
|
||||
|
|
|
@ -52,7 +52,6 @@ current_cmake_toolchain = rule(
|
|||
attrs = {
|
||||
"_toolchain": attr.string(default = str(Label("//toolchains:cmake_toolchain"))),
|
||||
},
|
||||
incompatible_use_toolchain_transition = True,
|
||||
toolchains = [
|
||||
str(Label("//toolchains:cmake_toolchain")),
|
||||
],
|
||||
|
@ -63,7 +62,6 @@ current_make_toolchain = rule(
|
|||
attrs = {
|
||||
"_toolchain": attr.string(default = str(Label("//toolchains:make_toolchain"))),
|
||||
},
|
||||
incompatible_use_toolchain_transition = True,
|
||||
toolchains = [
|
||||
str(Label("//toolchains:make_toolchain")),
|
||||
],
|
||||
|
@ -74,7 +72,6 @@ current_ninja_toolchain = rule(
|
|||
attrs = {
|
||||
"_toolchain": attr.string(default = str(Label("//toolchains:ninja_toolchain"))),
|
||||
},
|
||||
incompatible_use_toolchain_transition = True,
|
||||
toolchains = [
|
||||
str(Label("//toolchains:ninja_toolchain")),
|
||||
],
|
||||
|
@ -85,7 +82,6 @@ current_meson_toolchain = rule(
|
|||
attrs = {
|
||||
"_toolchain": attr.string(default = str(Label("//toolchains:meson_toolchain"))),
|
||||
},
|
||||
incompatible_use_toolchain_transition = True,
|
||||
toolchains = [
|
||||
str(Label("//toolchains:meson_toolchain")),
|
||||
],
|
||||
|
@ -96,7 +92,6 @@ current_autoconf_toolchain = rule(
|
|||
attrs = {
|
||||
"_toolchain": attr.string(default = str(Label("//toolchains:autoconf_toolchain"))),
|
||||
},
|
||||
incompatible_use_toolchain_transition = True,
|
||||
toolchains = [
|
||||
str(Label("//toolchains:autoconf_toolchain")),
|
||||
],
|
||||
|
@ -107,7 +102,6 @@ current_automake_toolchain = rule(
|
|||
attrs = {
|
||||
"_toolchain": attr.string(default = str(Label("//toolchains:automake_toolchain"))),
|
||||
},
|
||||
incompatible_use_toolchain_transition = True,
|
||||
toolchains = [
|
||||
str(Label("//toolchains:automake_toolchain")),
|
||||
],
|
||||
|
@ -118,7 +112,6 @@ current_m4_toolchain = rule(
|
|||
attrs = {
|
||||
"_toolchain": attr.string(default = str(Label("//toolchains:m4_toolchain"))),
|
||||
},
|
||||
incompatible_use_toolchain_transition = True,
|
||||
toolchains = [
|
||||
str(Label("//toolchains:m4_toolchain")),
|
||||
],
|
||||
|
@ -129,7 +122,6 @@ current_pkgconfig_toolchain = rule(
|
|||
attrs = {
|
||||
"_toolchain": attr.string(default = str(Label("//toolchains:pkgconfig_toolchain"))),
|
||||
},
|
||||
incompatible_use_toolchain_transition = True,
|
||||
toolchains = [
|
||||
str(Label("//toolchains:pkgconfig_toolchain")),
|
||||
],
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
"""A module represeting the version of rules_foreign_cc"""
|
||||
|
||||
VERSION = "0.9.0"
|
||||
VERSION = "0.12.0"
|
||||
|
|
Loading…
Reference in New Issue