Set BAZEL_JOBS and BAZEL_MEM with empty string to make bazel build without
limitation

Signed-off-by: Hongxu Jia <[email protected]>
---
 classes/bazel.bbclass                        | 9 ++++++++-
 recipes-devtools/bazel/bazel-native_3.7.1.bb | 6 +++---
 2 files changed, 11 insertions(+), 4 deletions(-)

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 () {
-- 
2.21.0

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#51788): https://lists.yoctoproject.org/g/yocto/message/51788
Mute This Topic: https://lists.yoctoproject.org/mt/78999789/21656
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to