Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Bazel Modules #78

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ jobs:
- name: Run tests
run: bazel test --test_env=NO_CLEANUP=1 //...

- name: Run tests (bzlmod enabled)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we'll need something like (untested):

Suggested change
- name: Run tests (bzlmod enabled)
- name: Run tests (bzlmod enabled)
if: ${{ matrix.bazel-version != '5.x' }}

To make CI green

run: bazel test --test_env=NO_CLEANUP=1 --enable_bzlmod //...

lint:
runs-on: ubuntu-latest
permissions:
Expand Down
28 changes: 28 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
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")
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")

# 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",
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 -- #
Empty file added WORKSPACE.bzlmod
Empty file.
8 changes: 4 additions & 4 deletions appimage/private/tool/mkappimage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is actually necessary -- Originally this worked by treating the rules_python external folder itself as a Py module, but this doesn't work with bzlmod since the external package names/folders have suffixes and stuff. So this is now "correct".



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)
Expand Down
33 changes: 33 additions & 0 deletions deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Loading