<pre style='margin:0'>
Chris Jones (cjones051073) pushed a commit to branch master
in repository macports-ports.
</pre>
<p><a href="https://github.com/macports/macports-ports/commit/3bf786c81679be4c22b5726464b6edf788c00bdc">https://github.com/macports/macports-ports/commit/3bf786c81679be4c22b5726464b6edf788c00bdc</a></p>
<pre style="white-space: pre; background: #F8F8F8"><span style='display:block; white-space:pre;color:#808000;'>commit 3bf786c81679be4c22b5726464b6edf788c00bdc
</span>Author: Chris Jones <jonesc@macports.org>
AuthorDate: Tue Mar 23 23:21:18 2021 +0000
<span style='display:block; white-space:pre;color:#404040;'> bazel PG: Updates to support other port builds
</span>---
_resources/port1.0/group/bazel-1.0.tcl | 78 +++++++++++++++++++---------------
1 file changed, 44 insertions(+), 34 deletions(-)
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/_resources/port1.0/group/bazel-1.0.tcl b/_resources/port1.0/group/bazel-1.0.tcl
</span><span style='display:block; white-space:pre;color:#808080;'>index 2d114055c6c..541a49b4c5c 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/_resources/port1.0/group/bazel-1.0.tcl
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/_resources/port1.0/group/bazel-1.0.tcl
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -10,11 +10,11 @@ namespace eval bazel { }
</span> options bazel.min_xcode
default bazel.min_xcode 10.2
<span style='display:block; white-space:pre;background:#ffe0e0;'>-options bazel.build_cmd
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-default bazel.build_cmd {[bazel::get_cmd]}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+options bazel.cmd_opts
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+default bazel.cmd_opts {[bazel::get_cmd_opts]}
</span>
options bazel.build_opts
<span style='display:block; white-space:pre;background:#ffe0e0;'>-default bazel.build_opts {[bazel::get_opts]}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+default bazel.build_opts {[bazel::get_build_opts]}
</span>
options bazel.build_target
default bazel.build_target ""
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -40,6 +40,9 @@ default bazel.limit_build_jobs yes
</span> options bazel.extra_build_opts
default bazel.extra_build_opts ""
<span style='display:block; white-space:pre;background:#e0ffe0;'>+options bazel.define_build_phase
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+default bazel.define_build_phase yes
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> proc bazel::use_mp_clang {} {
global configure.compiler xcodeversion
return [ expr ( [ string match macports-clang-* ${configure.compiler} ] || [ vercmp ${xcodeversion} [option bazel.min_xcode] ] < 0 ) ]
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -55,6 +58,7 @@ license_noconflict ${java.fallback}
</span> # append to envs
configure.env-append JAVA_HOME=${java.home}
build.env-append JAVA_HOME=${java.home}
<span style='display:block; white-space:pre;background:#e0ffe0;'>+destroot.env-append JAVA_HOME=${java.home}
</span>
proc bazel::set_dep { } {
ui_debug "Defining bazel port dependency"
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -154,25 +158,20 @@ pre-build {
</span> # Bazel handles parallel builds its own way..
use_parallel_build no
<span style='display:block; white-space:pre;background:#ffe0e0;'>-proc bazel::get_cmd {} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+proc bazel::get_cmd_opts {} {
</span> global bazel.max_idle_secs workpath
# Generate the bazel build command
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set bazel_cmd "bazel --max_idle_secs=${bazel.max_idle_secs} --output_user_root=${workpath}"
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if { [bazel::use_mp_clang] } {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set bazel_cmd "BAZEL_USE_CPP_ONLY_TOOLCHAIN=1 ${bazel_cmd}"
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if {![variant_isset native]} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set base_march [bazel::get_base_arch]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set bazel_cmd "CC_OPT_FLAGS=${base_march} ${bazel_cmd}"
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- ui_debug "Defined Bazel build command ${bazel_cmd}"
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- return ${bazel_cmd}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set bazel_cmd_opts "--max_idle_secs=${bazel.max_idle_secs} --output_user_root=${workpath}/bazel_build"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ui_debug "Defined Bazel build command options ${bazel_cmd_opts}"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return ${bazel_cmd_opts}
</span> }
<span style='display:block; white-space:pre;background:#ffe0e0;'>-proc bazel::get_opts {} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+proc bazel::get_build_opts {} {
</span> global build.jobs configure.cc configure.cflags configure.cxxflags configure.ldflags
# Bazel build options
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set bazel_build_opts "-s -c opt --verbose_failures --config=opt --nouse_action_cache"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set bazel_build_opts "-s --verbose_failures --nouse_action_cache"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # Extra user defined build options
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set bazel_build_opts "${bazel_build_opts} [option bazel.extra_build_opts]"
</span> # Limit bazel resource utilisation
if { [option bazel.limit_build_jobs] } {
# Limit the number of parallel jobs to the number of physical, not logical, cpus.
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -189,17 +188,15 @@ proc bazel::get_opts {} {
</span> if { [option bazel.max_cpu_fraction] > 0 } {
set bazel_build_opts "${bazel_build_opts} --local_cpu_resources=HOST_CPUS*[option bazel.max_cpu_fraction]"
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- # Extra user defined build options
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set bazel_build_opts "${bazel_build_opts} [option bazel.extra_build_opts]"
</span> # hack to try and transfer MP c, c++ and ld options to bazel...
foreach opt [list {*}${configure.cflags} ] {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set bazel_build_opts "${bazel_build_opts} --conlyopt '${opt}'"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set bazel_build_opts "${bazel_build_opts} --conlyopt \"${opt}\""
</span> }
foreach opt [list {*}${configure.cxxflags} ] {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set bazel_build_opts "${bazel_build_opts} --cxxopt '${opt}'"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set bazel_build_opts "${bazel_build_opts} --cxxopt \"${opt}\""
</span> }
foreach opt [list {*}${configure.ldflags} ] {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set bazel_build_opts "${bazel_build_opts} --linkopt '${opt}'"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set bazel_build_opts "${bazel_build_opts} --linkopt \"${opt}\""
</span> }
if { [bazel::use_mp_clang] } {
set bazel_build_opts "${bazel_build_opts} --action_env CC=${configure.cc}"
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -216,19 +213,32 @@ proc bazel::get_opts {} {
</span> }
proc bazel::configure_build {} {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- global bazel.build_cmd bazel.build_opts bazel.build_target
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- global build.jobs build.cmd build.args build.post_args
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- ui_debug "Configuring bazel build command and arguments"
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- build.cmd "[option bazel.build_cmd]"
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- build.args "[option bazel.build_opts]"
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- build.post_args "[option bazel.build_target]"
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- ui_debug "Bazel build command : ${build.cmd}"
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- ui_debug "Bazel build options : ${build.args}"
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- ui_debug "Bazel build target : [option bazel.build_target]"
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- ui_debug "Bazel post-build cmd : [option bazel.post_build_cmd]"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if { [option bazel.define_build_phase] } {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ global bazel.build_cmd bazel.build_opts bazel.build_target
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ global build.jobs build.cmd build.args build.post_args
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ui_debug "Configuring bazel build command and arguments"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set bazel_build_env ""
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if { [bazel::use_mp_clang] } {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set bazel_build_env "BAZEL_USE_CPP_ONLY_TOOLCHAIN=1 ${bazel_build_env}"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {![variant_isset native]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set base_march [bazel::get_base_arch]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set bazel_build_env "CC_OPT_FLAGS=${base_march} ${bazel_build_env}"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ build.cmd "${bazel_build_env} bazel [option bazel.cmd_opts]"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ build.args "[option bazel.build_opts]"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ build.post_args "[option bazel.build_target]"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ui_debug "Bazel build command : ${build.cmd}"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ui_debug "Bazel build options : ${build.args}"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ui_debug "Bazel build target : [option bazel.build_target]"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ui_debug "Bazel post-build cmd : [option bazel.post_build_cmd]"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span> }
port::register_callback bazel::configure_build
</pre><pre style='margin:0'>
</pre>