From 0aa12310772327826eebce86bab069d9202e471f Mon Sep 17 00:00:00 2001 From: John Hughes Date: Tue, 12 Sep 2023 11:58:29 +0200 Subject: [PATCH 1/6] Support Bazel Modules --- MODULE.bazel | 26 +++++++++++++++++++++++ WORKSPACE.bzlmod | 0 appimage/private/tool/mkappimage.py | 8 +++---- deps.bzl | 33 +++++++++++++++++++++++++++++ 4 files changed, 63 insertions(+), 4 deletions(-) create mode 100644 MODULE.bazel create mode 100644 WORKSPACE.bzlmod diff --git a/MODULE.bazel b/MODULE.bazel new file mode 100644 index 0000000..264b76e --- /dev/null +++ b/MODULE.bazel @@ -0,0 +1,26 @@ +module(name = "rules_appimage", version = "") + +bazel_dep(name = "bazel_skylib", version = "1.4.2") +bazel_dep(name = "rules_python", version = "0.25.0", dev_dependency = True) +bazel_dep(name = "rules_cc", version = "0.0.8") +bazel_dep(name = "platforms", version = "0.0.7") + +python = use_extension("@rules_python//python/extensions:python.bzl", "python", dev_dependency = True) +pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip", dev_dependency = True) +pip.parse( + hub_name = "rules_appimage_py_deps", + python_version = "3.11", + requirements_lock = "//:requirements.txt", +) +use_repo(pip, "rules_appimage_py_deps") + +non_module_deps = use_extension("//:deps.bzl", "non_module_deps") +use_repo(non_module_deps, "squashfs-tools") +use_repo(non_module_deps, "zstd") +use_repo(non_module_deps, "appimagetool.png") +use_repo(non_module_deps, "appimage_runtime_aarch64") +use_repo(non_module_deps, "appimage_runtime_armhf") +use_repo(non_module_deps, "appimage_runtime_i686") +use_repo(non_module_deps, "appimage_runtime_x86_64") + +# -- bazel_dep definitions -- # diff --git a/WORKSPACE.bzlmod b/WORKSPACE.bzlmod new file mode 100644 index 0000000..e69de29 diff --git a/appimage/private/tool/mkappimage.py b/appimage/private/tool/mkappimage.py index ba52b9c..2532ea7 100644 --- a/appimage/private/tool/mkappimage.py +++ b/appimage/private/tool/mkappimage.py @@ -9,15 +9,15 @@ from pathlib import Path from typing import Dict, Iterable, List, NamedTuple, Optional, Tuple -import rules_python.python.runfiles.runfiles +from python.runfiles import runfiles def _get_path_or_raise(path: str) -> Path: """Return a Path to a file in the runfiles, or raise FileNotFoundError.""" - runfiles = rules_python.python.runfiles.runfiles.Create() - if not runfiles: + files = runfiles.Create() + if not files: raise FileNotFoundError("Could not find runfiles") - runfile = runfiles.Rlocation(path) + runfile = files.Rlocation(path) if not runfile: raise FileNotFoundError(f"Could not find {path} in runfiles") return Path(runfile) diff --git a/deps.bzl b/deps.bzl index dcf6cbf..3bad2e7 100644 --- a/deps.bzl +++ b/deps.bzl @@ -57,3 +57,36 @@ def rules_appimage_deps(): strip_prefix = "zstd-1.5.5", url = "https://github.com/facebook/zstd/releases/download/v1.5.5/zstd-1.5.5.tar.gz", ) + +def _non_module_deps_impl(ctx): + """Fetch non-bzlmod-enabled dependencies.""" + + http_archive( + name = "squashfs-tools", + url = "https://github.com/plougher/squashfs-tools/archive/refs/tags/4.6.1.tar.gz", + sha256 = "94201754b36121a9f022a190c75f718441df15402df32c2b520ca331a107511c", + strip_prefix = "squashfs-tools-4.6.1/squashfs-tools", + build_file = "//third_party:squashfs-tools.BUILD", + ) + http_archive( + name = "zstd", + url = "https://github.com/facebook/zstd/releases/download/v1.5.5/zstd-1.5.5.tar.gz", + sha256 = "9c4396cc829cfae319a6e2615202e82aad41372073482fce286fac78646d3ee4", + strip_prefix = "zstd-1.5.5", + build_file = "//third_party:zstd.BUILD", + ) + for arch in ("aarch64", "armhf", "i686", "x86_64"): + name = "appimage_runtime_" + arch + http_file( + name = name, + executable = True, + sha256 = _SHAS[name], + urls = ["https://github.com/lalten/type2-runtime/releases/download/build-2022-10-03-c5c7b07/runtime-{}".format(arch)], + ) + http_file( + name = "appimagetool.png", + sha256 = "0c23daaf7665216a8e8f9754c904ec18b2dfa376af2479601a571e504239fae6", + urls = ["https://raw.githubusercontent.com/AppImage/AppImageKit/b51f685/resources/appimagetool.png"], + ) + +non_module_deps = module_extension(implementation = _non_module_deps_impl) \ No newline at end of file From 37aa463dbf40190c7298e968fed6c8126fe3179a Mon Sep 17 00:00:00 2001 From: John Hughes Date: Tue, 12 Sep 2023 12:15:57 +0200 Subject: [PATCH 2/6] Added version --- MODULE.bazel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MODULE.bazel b/MODULE.bazel index 264b76e..681c17f 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -1,4 +1,4 @@ -module(name = "rules_appimage", version = "") +module(name = "rules_appimage", version = "1.2.0") bazel_dep(name = "bazel_skylib", version = "1.4.2") bazel_dep(name = "rules_python", version = "0.25.0", dev_dependency = True) From 2f081da383230eacd046ebb558219a9784595624 Mon Sep 17 00:00:00 2001 From: John Hughes Date: Fri, 15 Sep 2023 14:17:30 +0200 Subject: [PATCH 3/6] Lint fixup --- deps.bzl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deps.bzl b/deps.bzl index 3bad2e7..d9c8c7f 100644 --- a/deps.bzl +++ b/deps.bzl @@ -58,7 +58,7 @@ def rules_appimage_deps(): url = "https://github.com/facebook/zstd/releases/download/v1.5.5/zstd-1.5.5.tar.gz", ) -def _non_module_deps_impl(ctx): +def _non_module_deps_impl(_ctx): """Fetch non-bzlmod-enabled dependencies.""" http_archive( @@ -89,4 +89,4 @@ def _non_module_deps_impl(ctx): urls = ["https://raw.githubusercontent.com/AppImage/AppImageKit/b51f685/resources/appimagetool.png"], ) -non_module_deps = module_extension(implementation = _non_module_deps_impl) \ No newline at end of file +non_module_deps = module_extension(implementation = _non_module_deps_impl) From bd278d5d6467e97ff5895b51649c14cc35d1030a Mon Sep 17 00:00:00 2001 From: John Hughes Date: Fri, 15 Sep 2023 14:22:18 +0200 Subject: [PATCH 4/6] Added test step with bzlmod enabled --- .github/workflows/ci.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3ed40e8..ac99e3f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -36,6 +36,9 @@ jobs: - name: Run tests run: bazel test --test_env=NO_CLEANUP=1 //... + - name: Run tests (bzlmod enabled) + run: bazel test --test_env=NO_CLEANUP=1 --enable_bzlmod //... + lint: runs-on: ubuntu-latest permissions: From 55f3b31d4e41e02339ed135fdf73d45bb5078f36 Mon Sep 17 00:00:00 2001 From: John Hughes Date: Fri, 15 Sep 2023 14:44:52 +0200 Subject: [PATCH 5/6] fixes --- MODULE.bazel | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/MODULE.bazel b/MODULE.bazel index 681c17f..c6db76e 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -1,11 +1,13 @@ module(name = "rules_appimage", version = "1.2.0") bazel_dep(name = "bazel_skylib", version = "1.4.2") -bazel_dep(name = "rules_python", version = "0.25.0", dev_dependency = True) +bazel_dep(name = "rules_python", version = "0.25.0") bazel_dep(name = "rules_cc", version = "0.0.8") bazel_dep(name = "platforms", version = "0.0.7") -python = use_extension("@rules_python//python/extensions:python.bzl", "python", dev_dependency = True) +python = use_extension("@rules_python//python/extensions:python.bzl", "python") + +# These pip deps are only used for the tests, hence the dev_dependency = True pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip", dev_dependency = True) pip.parse( hub_name = "rules_appimage_py_deps", From 99e2ba58a37fd65d783cbd36db4ee3fed3d0b2f3 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Wed, 25 Oct 2023 20:35:01 +0200 Subject: [PATCH 6/6] Don't test w/ bzlmod for Bazel 5 --- .github/workflows/ci.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index ac99e3f..a01afbb 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -37,6 +37,7 @@ jobs: run: bazel test --test_env=NO_CLEANUP=1 //... - name: Run tests (bzlmod enabled) + if: ${{ matrix.bazel-version != '5.x' }} run: bazel test --test_env=NO_CLEANUP=1 --enable_bzlmod //... lint: