[meta-tensorflow,22/25] bazel-native/bazel.bbclass: support bazel build without limitation

Submitted by Hongxu Jia on Dec. 16, 2020, 1:08 p.m. | Patch ID: 178927

Details

Message ID 20201216130822.28476-23-hongxu.jia@windriver.com
State New
Headers show

Commit Message

Hongxu Jia Dec. 16, 2020, 1:08 p.m.
Set BAZEL_JOBS and BAZEL_MEM with empty string to make bazel build without
limitation

Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
---
 classes/bazel.bbclass                        | 9 ++++++++-
 recipes-devtools/bazel/bazel-native_3.7.1.bb | 6 +++---
 2 files changed, 11 insertions(+), 4 deletions(-)

Patch hide | download patch | download mbox

diff --git a/classes/bazel.bbclass b/classes/bazel.bbclass
index 8a3dadf..f5dc597 100644
--- a/classes/bazel.bbclass
+++ b/classes/bazel.bbclass
@@ -77,13 +77,20 @@  def bazel_get_flags(d):
         flags += "# From TOOLCHAIN_OPTIONS\n"
         flags += "build --linkopt=%s\n" % i
 
+    if d.getVar("BAZEL_JOBS"):
+        flags += "# From BAZEL_JOBS\n"
+        flags += "build --jobs=%s --local_cpu_resources=%s\n" % (d.getVar("BAZEL_JOBS"), d.getVar("BAZEL_JOBS"))
+
+    if d.getVar("BAZEL_MEM"):
+        flags += "# From BAZEL_MEM\n"
+        flags += "build --local_ram_resources=%s\n" % (d.getVar("BAZEL_MEM"))
+
     return flags
 
 bazel_do_configure () {
     cat > "${S}/bazelrc" <<-EOF
 build --verbose_failures
 build --spawn_strategy=standalone --genrule_strategy=standalone
-build --jobs=${BAZEL_JOBS} --local_ram_resources=${BAZEL_MEM} --local_cpu_resources=${BAZEL_JOBS}
 test --verbose_failures --verbose_test_summary
 test --spawn_strategy=standalone --genrule_strategy=standalone
 
diff --git a/recipes-devtools/bazel/bazel-native_3.7.1.bb b/recipes-devtools/bazel/bazel-native_3.7.1.bb
index 03cff37..4f2e28b 100644
--- a/recipes-devtools/bazel/bazel-native_3.7.1.bb
+++ b/recipes-devtools/bazel/bazel-native_3.7.1.bb
@@ -30,9 +30,9 @@  inherit bazel-base
 EXTRA_BAZEL_ARGS = " \
     --host_javabase=@local_jdk//:jdk \
     --python_path=python3 \
-    --jobs=${BAZEL_JOBS} \
-    --local_ram_resources=${BAZEL_MEM} \
-    --local_cpu_resources=${BAZEL_JOBS} \
+    ${@oe.utils.conditional("BAZEL_JOBS", "", "", "--jobs=${BAZEL_JOBS}", d )} \
+    ${@oe.utils.conditional("BAZEL_JOBS", "", "", "--local_cpu_resources=${BAZEL_JOBS}", d )} \
+    ${@oe.utils.conditional("BAZEL_MEM", "", "", "--local_ram_resources=${BAZEL_MEM}", d )} \
 "
 
 do_compile () {