|
| 1 | +module( |
| 2 | + name = "ape", |
| 3 | + version = "1.0.1", |
| 4 | + bazel_compatibility = [ |
| 5 | + ">=7.4.0", |
| 6 | + ], |
| 7 | + compatibility_level = 1, |
| 8 | +) |
| 9 | + |
| 10 | +bazel_dep(name = "bazel_skylib", version = "1.7.1") |
| 11 | +bazel_dep(name = "platforms", version = "0.0.10") |
| 12 | +bazel_dep(name = "toolchain_utils", version = "1.0.2") |
| 13 | +bazel_dep(name = "download_utils", version = "1.0.1") |
| 14 | +bazel_dep(name = "rules_license", version = "1.0.0") |
| 15 | +bazel_dep(name = "rules_python", version = "1.0.0") |
| 16 | + |
| 17 | +bazel_dep(name = "hermetic_cc_toolchain", version = "3.1.0", dev_dependency = True) |
| 18 | + |
| 19 | +python = use_extension("@rules_python//python/extensions:python.bzl", "python", dev_dependency = True) |
| 20 | +python.toolchain( |
| 21 | + configure_coverage_tool = True, |
| 22 | + # TODO: need hermetic `chmod`/`id`: https://github.com/bazelbuild/rules_python/pull/2024 |
| 23 | + ignore_root_user_error = True, |
| 24 | + python_version = "3.13", |
| 25 | +) |
| 26 | + |
| 27 | +download_archive = use_repo_rule("@download_utils//download/archive:defs.bzl", "download_archive") |
| 28 | + |
| 29 | +download_archive( |
| 30 | + name = "zig-0.11.0-arm64-darwin", |
| 31 | + srcs = [ |
| 32 | + "entrypoint", |
| 33 | + "zig", |
| 34 | + ], |
| 35 | + integrity = "sha256-xuv5J7sTpwfXQmdHSp9VMnTmSQb9Ib8cdaIL3oyt97I=", |
| 36 | + links = { |
| 37 | + "zig-macos-aarch64-0.11.0/zig": "zig", |
| 38 | + "zig": "entrypoint", |
| 39 | + }, |
| 40 | + urls = [ |
| 41 | + "https://gitlab.arm.com/api/v4/projects/bazel%2Fape/packages/generic/zig/0.11.0/zig-macos-aarch64-0.11.0.tar.xz", |
| 42 | + "https://ziglang.org/download/0.11.0/zig-macos-aarch64-0.11.0.tar.xz", |
| 43 | + ], |
| 44 | +) |
| 45 | + |
| 46 | +select = use_repo_rule("@toolchain_utils//toolchain/local/select:defs.bzl", "toolchain_local_select") |
| 47 | + |
| 48 | +select( |
| 49 | + name = "zig", |
| 50 | + map = { |
| 51 | + "@zig-0.11.0-arm64-darwin": "arm64-darwin", |
| 52 | + }, |
| 53 | +) |
| 54 | + |
| 55 | +download_file = use_repo_rule("@download_utils//download/file:defs.bzl", "download_file") |
| 56 | + |
| 57 | +download_file( |
| 58 | + name = "ape-m1.c", |
| 59 | + executable = False, |
| 60 | + integrity = "sha256-eK954gq7s/malzVZWbWb1YlJVkBkrbdU8DAuurtL96M=", |
| 61 | + output = "ape-m1.c", |
| 62 | + patches = [ |
| 63 | + "//:ape-m1.patch", |
| 64 | + ], |
| 65 | + urls = [ |
| 66 | + "https://gitlab.arm.com/api/v4/projects/bazel%2Fape/packages/generic/cosmos.zip/4.0.2/ape-m1.c", |
| 67 | + "https://raw.githubusercontent.com/jart/cosmopolitan/4.0.2/ape/ape-m1.c", |
| 68 | + ], |
| 69 | +) |
| 70 | + |
| 71 | +compile = use_repo_rule("//ape/compile:repository.bzl", "compile") |
| 72 | + |
| 73 | +compile( |
| 74 | + name = "ape-arm64.macho", |
| 75 | + srcs = ["@ape-m1.c"], |
| 76 | + links = { |
| 77 | + "entrypoint": "binary", |
| 78 | + }, |
| 79 | + output = "binary", |
| 80 | + target = "{cpu}-macos-none", |
| 81 | + zig = "@zig//:entrypoint", |
| 82 | +) |
| 83 | + |
| 84 | +pe = use_repo_rule("//ape/pe:repository.bzl", "pe") |
| 85 | + |
| 86 | +pe( |
| 87 | + name = "ape.pe", |
| 88 | + links = { |
| 89 | + "entrypoint": "binary", |
| 90 | + }, |
| 91 | + output = "binary", |
| 92 | +) |
| 93 | + |
| 94 | +select( |
| 95 | + name = "launcher", |
| 96 | + map = { |
| 97 | + "@ape-arm64.elf": "arm64-linux", |
| 98 | + "@ape-x86_64.elf": "amd64-linux", |
| 99 | + "@ape-x86_64.macho": "amd64-darwin", |
| 100 | + "@ape-arm64.macho": "arm64-darwin", |
| 101 | + "@ape.pe": "windows", |
| 102 | + }, |
| 103 | +) |
| 104 | + |
| 105 | +resolved = use_repo_rule("@toolchain_utils//toolchain/resolved:defs.bzl", "toolchain_resolved") |
| 106 | + |
| 107 | +resolved( |
| 108 | + name = "resolved-ape", |
| 109 | + toolchain_type = "//ape/toolchain/ape:type", |
| 110 | +) |
| 111 | + |
| 112 | +register_toolchains("//ape/toolchain/...") |
| 113 | + |
| 114 | +cosmos = use_extension("//ape/cosmos:defs.bzl", "ape_cosmos") |
| 115 | +cosmos.upload( |
| 116 | + template = "https://gitlab.arm.com/api/v4/projects/bazel%2Fape/packages/generic/cosmos.zip/{version}/{name}", |
| 117 | +) |
| 118 | + |
| 119 | +# TODO: enable this when we have unauthenticated access to `gitlab.arm.com` generic package registry (see #6) |
| 120 | +# cosmos.url( |
| 121 | +# template = "https://gitlab.arm.com/api/v4/projects/bazel%2Fape/packages/generic/cosmos.zip/{version}/{name}", |
| 122 | +# ) |
| 123 | +cosmos.url( |
| 124 | + template = "https://cosmo.zip/pub/cosmos/v/{version}/bin/{name}", |
| 125 | +) |
| 126 | +cosmos.download( |
| 127 | + lock = "//ape/cosmos:4.0.2.json", |
| 128 | + version = "4.0.2", |
| 129 | +) |
| 130 | +cosmos.download( |
| 131 | + lock = "//ape/cosmos:3.9.2.json", |
| 132 | + version = "3.9.2", |
| 133 | +) |
| 134 | +cosmos.download( |
| 135 | + lock = "//ape/cosmos:3.7.1.json", |
| 136 | + version = "3.7.1", |
| 137 | +) |
| 138 | +cosmos.download( |
| 139 | + lock = "//ape/cosmos:3.3.1.json", |
| 140 | + version = "3.3.1", |
| 141 | +) |
| 142 | +cosmos.download( |
| 143 | + lock = "//ape/cosmos:3.2.4.json", |
| 144 | + version = "3.2.4", |
| 145 | +) |
| 146 | + |
| 147 | +# https://github.com/ahgamut/superconfigure/issues/38 |
| 148 | +cosmos.override( |
| 149 | + basename = "pigz", |
| 150 | + version = "3.2.4", |
| 151 | +) |
| 152 | +cosmos.use( |
| 153 | + aliases = True, |
| 154 | + bootstrap = True, |
| 155 | + metadata = True, |
| 156 | + upload = True, |
| 157 | +) |
| 158 | +use_repo(cosmos, "aliases", "ape-aarch64.elf", "ape-arm64.elf", "ape-x86_64.elf", "ape-x86_64.macho", "assimilate", "assimilate-aarch64.elf", "assimilate-x86_64.elf", "assimilate-x86_64.macho", "metadata", "upload") |
0 commit comments