<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/0afc1970b504f98a2d8c986fd8c7265edd83c8a5">https://github.com/macports/macports-ports/commit/0afc1970b504f98a2d8c986fd8c7265edd83c8a5</a></p>
<pre style="white-space: pre; background: #F8F8F8"><span style='display:block; white-space:pre;color:#808000;'>commit 0afc1970b504f98a2d8c986fd8c7265edd83c8a5
</span>Author: Chris Jones <jonesc@macports.org>
AuthorDate: Mon May 3 12:44:39 2021 +0100
<span style='display:block; white-space:pre;color:#404040;'> bazel PG: Improvements to the handling of SDKs
</span>---
_resources/port1.0/group/bazel-1.0.tcl | 71 +++++++++++++++-------------------
1 file changed, 32 insertions(+), 39 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 e8c7a572031..9fb06dd18c8 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;'>@@ -16,7 +16,7 @@ options bazel.min_xcode
</span> default bazel.min_xcode 12.2
options bazel.build_cmd
<span style='display:block; white-space:pre;background:#ffe0e0;'>-default bazel.build_cmd {[bazel::get_bazel_executable_name]}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+default bazel.build_cmd {[bazel::get_bazel_executable]}
</span>
options bazel.build_cmd_opts
default bazel.build_cmd_opts {[bazel::get_cmd_opts]}
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -27,6 +27,9 @@ 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:#e0ffe0;'>+options bazel.run_bazel_fetch
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+default bazel.run_bazel_fetch yes
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> options bazel.post_build_cmd
default bazel.post_build_cmd ""
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -60,6 +63,9 @@ default bazel.configure_pre_args ""
</span> options bazel.cxx_standard
default bazel.cxx_standard 2014
<span style='display:block; white-space:pre;background:#e0ffe0;'>+options bazel.path
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+default bazel.path {}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> # Required java version
java.version 11+
# LTS JDK port to install if required java not found
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -72,6 +78,9 @@ configure.env-append JAVA_HOME=${java.home}
</span> build.env-append JAVA_HOME=${java.home}
destroot.env-append JAVA_HOME=${java.home}
<span style='display:block; white-space:pre;background:#e0ffe0;'>+# Always force the use of the un-versioned SDK
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+configure.sdk_version
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> # Require c++ standard
proc bazel::set_standards {} {
global compiler.cxx_standard
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -93,7 +102,7 @@ if { [bazel::use_mp_clang] } {
</span> compiler.blacklist-append {clang}
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>-proc bazel::get_bazel_executable_name { } {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+proc bazel::get_bazel_name { } {
</span> if { [option bazel.version] eq "latest" } {
return bazel
} else {
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -101,13 +110,18 @@ proc bazel::get_bazel_executable_name { } {
</span> }
}
<span style='display:block; white-space:pre;background:#e0ffe0;'>+proc bazel::get_bazel_executable { } {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ global prefix
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return ${prefix}/libexec/[bazel::get_bazel_name]/bin/bazel
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> proc bazel::get_bazel_build_area { } {
global workpath
return ${workpath}/bazel_build
}
proc bazel::set_dep { } {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set bz_dep [bazel::get_bazel_executable_name]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set bz_dep [bazel::get_bazel_name]
</span> ui_debug "Defining bazel dependency port:${bz_dep}"
depends_build-append port:${bz_dep}
}
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -143,26 +157,23 @@ if {![variant_isset native]} {
</span> customized for your machine, use the +native variant"
}
<span style='display:block; white-space:pre;background:#e0ffe0;'>+proc bazel::add_to_envs { var } {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach phase {configure build destroot} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ${phase}.env-append ${var}
</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;'>+
</span> proc bazel::set_env {} {
global prefix env
ui_debug "Setting Bazel Env"
<span style='display:block; white-space:pre;background:#ffe0e0;'>- # if { [bazel::use_mp_clang] } {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # configure.env-append BAZEL_USE_CPP_ONLY_TOOLCHAIN=1
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # build.env-append BAZEL_USE_CPP_ONLY_TOOLCHAIN=1
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # destroot.env-append BAZEL_USE_CPP_ONLY_TOOLCHAIN=1
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- proc add_to_envs { var } {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- foreach phase {configure build destroot} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- ${phase}.env-append ${var}
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span> # https://github.com/bazelbuild/bazel/issues/2852
<span style='display:block; white-space:pre;background:#ffe0e0;'>- add_to_envs BAZEL_SH=/bin/bash
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # patch PATH to find correct 'bazel' version
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- add_to_envs "PATH=${prefix}/libexec/[bazel::get_bazel_executable_name]/bin:$env(PATH)"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ bazel::add_to_envs BAZEL_SH=/bin/bash
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # patch PATH
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ bazel.path-append [option prefix]/libexec/[bazel::get_bazel_name]/bin
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ bazel::add_to_envs PATH=[string map {" " ":"} [option bazel.path]]:$env(PATH)
</span> # ccache dir
if { [option configure.ccache] } {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- add_to_envs CCACHE_DIR=[bazel::get_ccache_dir]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ bazel::add_to_envs CCACHE_DIR=[bazel::get_ccache_dir]
</span> }
}
port::register_callback bazel::set_env
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -219,7 +230,7 @@ pre-build {
</span> ui_error "Once the build is complete, you can safely re-select your preferred gcc."
return -code error "build error"
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if { [option bazel.build_cmd] ne "" && [file exists ${worksrcpath}] } {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if { [option bazel.run_bazel_fetch] && [option bazel.build_cmd] ne "" && [file exists ${worksrcpath}] } {
</span> # Create compiler wrappers
set wrapdir ${workpath}/bazelwrap
xinstall -m 755 -d ${wrapdir}
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -239,7 +250,8 @@ pre-build {
</span> close ${f}
}
# Run fetch
<span style='display:block; white-space:pre;background:#ffe0e0;'>- system -W ${worksrcpath} "[bazel::get_build_env] [option bazel.build_cmd] [option bazel.build_cmd_opts] fetch [option bazel.build_target]"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set addpath [string map {" " ":"} [option bazel.path]]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ system -W ${worksrcpath} "PATH=${addpath}:$env(PATH) [bazel::get_build_env] [option bazel.build_cmd] [option bazel.build_cmd_opts] fetch [option bazel.build_target]"
</span> # Patch the bazel clang wrapper script to use MacPorts compiler selection and support ccache
foreach f [ exec find [bazel::get_bazel_build_area] -name "wrapped_clang.cc" ] {
# Switch to selected compiler
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -264,7 +276,7 @@ proc bazel::get_cmd_opts {} {
</span>
proc bazel::get_build_opts {} {
global build.jobs configure.cc configure.cxx configure.cflags configure.cxxflags configure.ldflags
<span style='display:block; white-space:pre;background:#ffe0e0;'>- global configure.sdk_version use_parallel_build bazel.limit_build_jobs workpath
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ global use_parallel_build bazel.limit_build_jobs workpath
</span> # Bazel build options
# See https://docs.bazel.build/versions/master/memory-saving-mode.html
set bazel_build_opts "--subcommands --compilation_mode=opt --verbose_failures --nouse_action_cache --discard_analysis_cache --notrack_incremental_state --nokeep_state_after_build "
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -301,19 +313,6 @@ proc bazel::get_build_opts {} {
</span> foreach opt [list {*}${configure.ldflags} ] {
set bazel_build_opts "${bazel_build_opts} --linkopt \"${opt}\""
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- # if { [bazel::use_mp_clang] } {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # if { [option bazel.build_cmd] ne "" } {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # set wrapdir ${workpath}/bazelwrap
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # set bazel_build_opts "${bazel_build_opts} --action_env CC=${wrapdir}/cc --action_env CXX=${wrapdir}/cxx"
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # } else {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # set bazel_build_opts "${bazel_build_opts} --action_env CC=${configure.cc} --action_env CXX=${configure.cxx}"
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # } else {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # # Explicitly pass SDK https://github.com/bazelbuild/rules_go/issues/1554
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # # Check versioned SDK actually exists... https://trac.macports.org/ticket/60317
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # # Incorrect SDK choice https://trac.macports.org/ticket/62570
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # # set bazel_build_opts "${bazel_build_opts} --macos_sdk_version=${configure.sdk_version}"
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # }
</span> if {![variant_isset native]} {
set base_march [bazel::get_base_arch]
set bazel_build_opts "${bazel_build_opts} --copt=${base_march}"
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -329,11 +328,6 @@ proc bazel::get_build_opts {} {
</span>
proc bazel::get_build_env { } {
set bazel_build_env ""
<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_build_env "BAZEL_USE_CPP_ONLY_TOOLCHAIN=1 ${bazel_build_env}"
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # } else {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # #set bazel_build_env "SDKROOT=${configure.sdkroot} ${bazel_build_env}"
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # }
</span> if {![variant_isset native]} {
set base_march [bazel::get_base_arch]
set bazel_build_env "CC_OPT_FLAGS=${base_march} ${bazel_build_env}"
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -350,7 +344,6 @@ proc bazel::get_build_env { } {
</span> proc bazel::configure_build {} {
if { [option bazel.build_cmd] ne "" } {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- global configure.sdkroot worksrcpath
</span> global bazel.build_cmd bazel.build_opts bazel.build_target
global build.jobs build.cmd build.args build.post_args
</pre><pre style='margin:0'>
</pre>