diff options
| -rw-r--r-- | guix-science/packages/bazel.scm | 157 |
1 files changed, 157 insertions, 0 deletions
diff --git a/guix-science/packages/bazel.scm b/guix-science/packages/bazel.scm index b609cc5..df5c891 100644 --- a/guix-science/packages/bazel.scm +++ b/guix-science/packages/bazel.scm | |||
| @@ -18,7 +18,9 @@ | |||
| 18 | #:use-module (guix packages) | 18 | #:use-module (guix packages) |
| 19 | #:use-module (guix gexp) | 19 | #:use-module (guix gexp) |
| 20 | #:use-module (guix download) | 20 | #:use-module (guix download) |
| 21 | #:use-module (guix git-download) | ||
| 21 | #:use-module (guix build-system gnu) | 22 | #:use-module (guix build-system gnu) |
| 23 | #:use-module (guix utils) | ||
| 22 | #:use-module (gnu packages) | 24 | #:use-module (gnu packages) |
| 23 | #:use-module (gnu packages base) | 25 | #:use-module (gnu packages base) |
| 24 | #:use-module (gnu packages bash) | 26 | #:use-module (gnu packages bash) |
| @@ -317,6 +319,161 @@ multiple platforms. Bazel supports large codebases across multiple | |||
| 317 | repositories, and large numbers of users.") | 319 | repositories, and large numbers of users.") |
| 318 | (license license:asl2.0))) | 320 | (license license:asl2.0))) |
| 319 | 321 | ||
| 322 | (define-public bazel-6.1 | ||
| 323 | (package | ||
| 324 | (inherit bazel-6) | ||
| 325 | (name "bazel") | ||
| 326 | (version "6.1.0") | ||
| 327 | (source (origin | ||
| 328 | (inherit (package-source bazel-6)) | ||
| 329 | (uri (string-append "https://github.com/bazelbuild/bazel/" | ||
| 330 | "releases/download/" version | ||
| 331 | "/bazel-" version "-dist.zip")) | ||
| 332 | (sha256 | ||
| 333 | (base32 | ||
| 334 | "0ci99xmwl82gg9hl6wjj087grifnznbl0lbirgknxxhwaismdf64")))) | ||
| 335 | (arguments | ||
| 336 | (substitute-keyword-arguments (package-arguments bazel-6) | ||
| 337 | ((#:phases phases) | ||
| 338 | #~(modify-phases #$phases | ||
| 339 | (replace 'build | ||
| 340 | (lambda _ | ||
| 341 | ;; Use local JDK only | ||
| 342 | (setenv "EXTRA_BAZEL_ARGS" | ||
| 343 | (string-append | ||
| 344 | "\ | ||
| 345 | --tool_java_runtime_version=local_jdk \ | ||
| 346 | --noremote_accept_cached \ | ||
| 347 | --verbose_failures \ | ||
| 348 | --subcommands \ | ||
| 349 | --action_env=PATH \ | ||
| 350 | --action_env=LIBRARY_PATH \ | ||
| 351 | --action_env=C_INCLUDE_PATH \ | ||
| 352 | --action_env=CPLUS_INCLUDE_PATH \ | ||
| 353 | --action_env=GUIX_LOCPATH \ | ||
| 354 | --host_action_env=PATH \ | ||
| 355 | --host_action_env=LIBRARY_PATH \ | ||
| 356 | --host_action_env=C_INCLUDE_PATH \ | ||
| 357 | --host_action_env=CPLUS_INCLUDE_PATH \ | ||
| 358 | --host_action_env=GUIX_LOCPATH \ | ||
| 359 | --define=distribution=debian | ||
| 360 | --override_repository=com_google_protobuf=" (getcwd) "/tools/distributions/debian/protobuf \ | ||
| 361 | --override_repository=remote_java_tools_linux=" (getcwd) "/mock_repos/remote_java_tools_linux \ | ||
| 362 | --override_repository=io_bazel_skydoc=" (getcwd) "/mock_repos/bazel_skydoc \ | ||
| 363 | --override_repository=rules_cc=" (getcwd) "/mock_repos/rules_cc \ | ||
| 364 | --override_repository=rules_java=" (getcwd) "/mock_repos/rules_java \ | ||
| 365 | --override_repository=rules_proto=" (getcwd) "/mock_repos/rules_proto \ | ||
| 366 | --override_repository=platforms=" #$(this-package-native-input "bazel-platforms"))) | ||
| 367 | (substitute* "third_party/py/mock/setup.py" | ||
| 368 | (("#! /usr/bin/env python") | ||
| 369 | (string-append "#!" (which "python")))) | ||
| 370 | (substitute* "tools/distributions/debian/deps.bzl" | ||
| 371 | (("/usr/include/google/protobuf") | ||
| 372 | (string-append #$(this-package-native-input "protobuf") | ||
| 373 | "/include/google/protobuf")) | ||
| 374 | ;; TODO: /usr/bin/grpc_java_plugin | ||
| 375 | ;; TODO: add all the java things | ||
| 376 | (("\"grpc_java_plugin.*") "") | ||
| 377 | (("/usr/bin/protoc") | ||
| 378 | (string-append #$(this-package-native-input "protobuf") | ||
| 379 | "/bin/protoc")) | ||
| 380 | (("/usr/bin/grpc_cpp_plugin") | ||
| 381 | (string-append #$(this-package-input "grpc") | ||
| 382 | "/bin/grpc_cpp_plugin")) | ||
| 383 | ;; Symlink the bundled jars in derived/jars to where | ||
| 384 | ;; we can use them in debian_java.BUILD. | ||
| 385 | (("\"java\": \"/usr/share/java\",") | ||
| 386 | (string-append "\"jars\": \"" (getcwd) | ||
| 387 | "/derived/jars\","))) | ||
| 388 | ;; XXX: do not override any jar locations, because we | ||
| 389 | ;; don't have all of them and we don't have any of them | ||
| 390 | ;; in the locations that debian uses. | ||
| 391 | (substitute* "tools/distributions/distribution_rules.bzl" | ||
| 392 | (("if \"debian\"") | ||
| 393 | "if \"shmebian\"")) | ||
| 394 | ;; Make this work with our version of protobuf. | ||
| 395 | (substitute* "third_party/grpc-java/compiler/src/java_plugin/cpp/java_generator.cpp" | ||
| 396 | (("google/protobuf/compiler/java/java_names.h") | ||
| 397 | "google/protobuf/compiler/java/names.h")) | ||
| 398 | ;; XXX: override the overrides for protobuf-util.jar and | ||
| 399 | ;; protobuf.jar, because we don't have them. | ||
| 400 | (substitute* "tools/distributions/debian/debian_java.BUILD" | ||
| 401 | (("\"java/protobuf-util.jar\",") | ||
| 402 | (string-append "\"" | ||
| 403 | "jars/com_google_protobuf/java/util/libutil.jar" | ||
| 404 | "\",")) | ||
| 405 | (("\"java/protobuf.jar\",") | ||
| 406 | (string-append "\"" | ||
| 407 | "jars/com_google_protobuf/java/core/libcore.jar" | ||
| 408 | "\",")) | ||
| 409 | (("jars = \\[\"java/protobuf-util.jar\"") | ||
| 410 | (string-append "jars = [\"" | ||
| 411 | "jars/com_google_protobuf/java/util/libutil.jar" | ||
| 412 | "\"")) | ||
| 413 | (("jars = \\[\"java/protobuf.jar\"") | ||
| 414 | (string-append "jars = [\"" | ||
| 415 | "jars/com_google_protobuf/java/core/libcore.jar" | ||
| 416 | "\", \"" | ||
| 417 | "jars/com_google_protobuf/java/core/liblite.jar" | ||
| 418 | "\","))) | ||
| 419 | ;; Make sure that "cp" is found. | ||
| 420 | (substitute* "third_party/grpc/build_defs.bzl" | ||
| 421 | (("command = \"cp" m) | ||
| 422 | (string-append "use_default_shell_env = True,\n" m))) | ||
| 423 | ;; XXX: we don't have a BUILD file in protobuf:/java/util | ||
| 424 | (substitute* "src/main/java/com/google/devtools/build/lib/BUILD" | ||
| 425 | (("\"@com_google_protobuf//java/util\",") "")) | ||
| 426 | ;; Ensure that "cat" can be found. | ||
| 427 | (substitute* "src/main/java/com/google/devtools/build/lib/runtime/commands/license/merge_licenses.bzl" | ||
| 428 | (("\"OUT\": ctx.outputs.out.path," m) | ||
| 429 | (string-append m "\n\"PATH\": \"" (getenv "PATH") "\","))) | ||
| 430 | (substitute* "scripts/bootstrap/compile.sh" | ||
| 431 | (("#!/bin/sh") | ||
| 432 | (string-append "#!" (which "sh")))) | ||
| 433 | |||
| 434 | ;; Do not force the use of /bin/bash for users of bazel. | ||
| 435 | ;; Users cannot override this, so we do that here. | ||
| 436 | (substitute* '("src/main/java/com/google/devtools/build/lib/analysis/BashCommandConstructor.java" | ||
| 437 | "tools/build_rules/java_rules_skylark.bzl" | ||
| 438 | "tools/build_rules/test_rules.bzl" | ||
| 439 | "tools/android/android_sdk_repository_template.bzl") | ||
| 440 | (("#!/bin/bash") | ||
| 441 | (string-append "#!" (which "bash")))) | ||
| 442 | (substitute* '("src/main/java/com/google/devtools/build/lib/analysis/CommandHelper.java" | ||
| 443 | "src/main/java/com/google/devtools/build/lib/analysis/ShellConfiguration.java" | ||
| 444 | "src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRuleClassProvider.java" | ||
| 445 | "src/main/java/com/google/devtools/build/lib/bazel/rules/sh/BazelShRuleClasses.java" | ||
| 446 | "src/main/java/com/google/devtools/build/lib/util/CommandBuilder.java") | ||
| 447 | (("\"/bin/bash\"") | ||
| 448 | (string-append "\"" (which "bash") "\""))) | ||
| 449 | |||
| 450 | ;; Same story for /usr/bin/env... | ||
| 451 | (substitute* '("src/main/java/com/google/devtools/build/lib/bazel/rules/python/BazelPythonSemantics.java" | ||
| 452 | "src/main/java/com/google/devtools/build/lib/starlarkbuildapi/python/PyRuntimeInfoApi.java" | ||
| 453 | "src/main/java/com/google/devtools/build/lib/bazel/rules/java/java_stub_template.txt" | ||
| 454 | "src/test/java/com/google/devtools/build/lib/standalone/StandaloneSpawnStrategyTest.java" | ||
| 455 | "src/test/java/com/google/devtools/build/lib/bazel/rules/python/BazelPyBinaryConfiguredTargetTest.java" | ||
| 456 | "tools/python/toolchain.bzl") | ||
| 457 | (("/usr/bin/env") (which "env"))) | ||
| 458 | (invoke "bash" "compile.sh"))))))) | ||
| 459 | (native-inputs | ||
| 460 | `(("protobuf" ,protobuf) | ||
| 461 | ("unzip" ,unzip) | ||
| 462 | ("util-linux" ,util-linux) | ||
| 463 | ("python-wrapper" ,python-wrapper) | ||
| 464 | ("which" ,which) | ||
| 465 | ("zip" ,zip) | ||
| 466 | ("bazel-platforms" | ||
| 467 | ,(origin | ||
| 468 | (method git-fetch) | ||
| 469 | (uri (git-reference | ||
| 470 | (url "https://github.com/bazelbuild/platforms") | ||
| 471 | (commit "0.0.8"))) | ||
| 472 | (file-name (git-file-name "bazel-platforms" "0.0.8")) | ||
| 473 | (sha256 | ||
| 474 | (base32 | ||
| 475 | "1wx2348w49vxr3z9kjfls5zsrwr0div6r3irbvdlawan87sx5yfs")))))))) | ||
| 476 | |||
| 320 | (define-public bazel-6.4 | 477 | (define-public bazel-6.4 |
| 321 | (package | 478 | (package |
| 322 | (inherit bazel-6) | 479 | (inherit bazel-6) |
