Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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: 2 additions & 1 deletion appimage/private/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def _appimage_impl(ctx):
identity = ctx.actions.declare_file(ctx.label.name + ".AppImage.identity.json")

args = ctx.actions.args()
args.add("appimage_packer")
args.add(appimagetool[0].dirname)
args.add(runtime)
args.add(name)
Expand Down Expand Up @@ -102,7 +103,7 @@ _appimage_package = rule(
"libs": attr.label_list(doc = "Shared libraries placed under usr/lib.", allow_files = True),
"notice": attr.label_list(doc = "License and NOTICE files placed under usr/share/licenses/<name>.", allow_files = True, mandatory = True, allow_empty = False),
"version": attr.string(doc = "Application version.", mandatory = True),
"_build": attr.label(default = "//appimage/private/tools/packer:appimage_packer", executable = True, cfg = "exec"),
"_build": attr.label(default = "@dx_prebuilt//:dx", executable = True, cfg = "exec"),
"_runtime_aarch64": attr.label(default = "@dx_appimage_tools//:runtime_aarch64", allow_single_file = True),
"_runtime_x86_64": attr.label(default = "@dx_appimage_tools//:runtime_x86_64", allow_single_file = True),
"_tools": attr.label(doc = "The appimagetool closure.", cfg = "exec", default = "@dx_appimage_tools//:tools"),
Expand Down
28 changes: 9 additions & 19 deletions appimage/private/tools/packer/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# gazelle:ignore
load("@crates//:crates.bzl", "aliases", "all_crate_deps")
load("//core/quality:fixtures.bzl", "real_source_target")
load("//rust:defs.bzl", "rust_binary", "rust_library", "rust_test")
load("//rust:defs.bzl", "rust_library", "rust_test")

package(default_visibility = ["//appimage:__subpackages__"])

Expand All @@ -16,7 +16,14 @@ rust_library(
),
crate_name = "appimage_packer",
crate_root = "src/lib.rs",
target_compatible_with = _LINUX,
target_compatible_with = select({
"@platforms//os:windows": ["@platforms//:incompatible"],
"//conditions:default": [],
}),
visibility = [
"//appimage:__subpackages__",
"//cli/cli:__pkg__",
],
deps = all_crate_deps(
package_name = "appimage/private/tools/appimage_packer",
normal = True,
Expand All @@ -26,22 +33,6 @@ rust_library(
],
)

rust_binary(
name = "appimage_packer",
srcs = ["src/main.rs"],
aliases = aliases(
package_name = "appimage/private/tools/appimage_packer",
normal = True,
),
crate_name = "appimage_packer",
crate_root = "src/main.rs",
target_compatible_with = _LINUX,
deps = all_crate_deps(
package_name = "appimage/private/tools/appimage_packer",
normal = True,
) + [":appimage_packer_lib"],
)

rust_test(
name = "appimage_packer_test",
aliases = aliases(
Expand Down Expand Up @@ -75,7 +66,6 @@ real_source_target(
exports_files(
[
"src/lib.rs",
"src/main.rs",
],
visibility = [
"//core/quality:__pkg__",
Expand Down
4 changes: 0 additions & 4 deletions appimage/private/tools/packer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,3 @@ serde_json = "1"

[dev-dependencies]
tempfile = "3"

[[bin]]
name = "appimage_packer"
path = "src/main.rs"
33 changes: 17 additions & 16 deletions appimage/private/tools/packer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,9 @@ fn pack_in(request: &Request, work: &Path) -> Result<(), String> {
"image_sha256": hash_file(&request.image)?,
"files": Value::Object(digests),
});
let text = serde_json::to_string_pretty(&identity).map_err(|e| e.to_string())?;
dx_atomic_fs::write_scratch(&request.identity, (text + "\n").as_bytes())
let mut text = serde_json::to_string_pretty(&identity).map_err(|e| e.to_string())?;
text.push('\n');
dx_atomic_fs::write_scratch(&request.identity, text.as_bytes())
.map_err(|e| format!("write identity: {e}"))
}

Expand All @@ -346,19 +347,19 @@ fn check_desktop(desktop: &Path, name: &str) -> Result<(), String> {
}
}

/// The `file` command appimagetool finds on its PATH: dx itself, which answers to that name.
pub const FILE_COMMAND: &str = "file";

/// Runs as `file`; appimagetool calls it only when ARCH is unset or appstream checks run.
#[must_use]
pub fn run(invoked: &str, args: &[String]) -> u8 {
if Path::new(invoked)
.file_name()
.is_some_and(|name| name == FILE_COMMAND)
{
eprintln!(
"dx_appimage: the file command is not provided; set ARCH and pass --no-appstream"
);
return 2;
}
pub fn refuse_file() -> u8 {
eprintln!("dx_appimage: the file command is not provided; set ARCH and pass --no-appstream");
2
}

/// Runs `dx appimage_packer ARG...`: packs one AppImage and writes its identity file.
#[must_use]
pub fn run(args: &[String]) -> u8 {
match parse(args).and_then(|request| pack(&request)) {
Ok(()) => 0,
Err(message) => {
Expand Down Expand Up @@ -750,8 +751,8 @@ mod tests {

#[test]
fn run_refuses_the_file_command_and_reports_failures() {
assert_eq!(run("/work/path/file", &[]), 2);
assert_eq!(run("dx_appimage", &[]), 1);
assert_eq!(refuse_file(), 2);
assert_eq!(run(&[]), 1);
let fixture = Fixture::new(WRITE_IMAGE);
let request = fixture.request();
let mut args: Vec<String> = [
Expand All @@ -772,8 +773,8 @@ mod tests {
.iter()
.map(|p| p.display().to_string())
.collect();
assert_eq!(run("dx_appimage", &args), 0);
assert_eq!(run(&args), 0);
args.push("bogus:x".into());
assert_eq!(run("dx_appimage", &args), 1);
assert_eq!(run(&args), 1);
}
}
9 changes: 0 additions & 9 deletions appimage/private/tools/packer/src/main.rs

This file was deleted.

2 changes: 1 addition & 1 deletion appimage/tests/cell_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def _action_impl(ctx):
action = [a for a in analysistest.target_actions(env) if a.mnemonic == "DxAppImage"][0]
asserts.equals(env, None, action.env.get("PATH"))
asserts.equals(env, "C", action.env.get("LC_ALL"))
asserts.true(env, action.argv[0].endswith("/appimage_packer"), "action runs " + action.argv[0])
asserts.equals(env, "appimage_packer", action.argv[1])
asserts.true(env, ctx.attr.arch in action.argv, "arch " + ctx.attr.arch + " missing from " + str(action.argv))
runtimes = [f.basename for f in action.inputs.to_list() if f.basename.startswith("runtime-")]
asserts.equals(env, ["runtime-" + ctx.attr.arch], runtimes)
Expand Down
1 change: 1 addition & 0 deletions cli/cli/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ rust_binary(
] + select({
"@platforms//os:windows": [],
"//conditions:default": [
"//appimage/private/tools/packer:appimage_packer_lib",
"//apple/private/tools/ops",
"//cli/os_sys:dx_os_sys",
],
Expand Down
6 changes: 5 additions & 1 deletion cli/cli/src/exec/quality_probe_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ fn probed_shards_narrow_the_build_aspects() {
assert_eq!(builds.len(), 1);
assert_eq!(
aspects_of(&builds[0]),
vec!["real_lint_aspect", "real_rust_lint_aspect"]
vec![
"real_lint_aspect",
"android_sdk_aspect",
"real_rust_lint_aspect"
]
);
let probe = &harness.probe_argv.borrow()[0];
let expected: Vec<String> = dx_plan::plan::spec(dx_plan::args::Command::Lint)
Expand Down
4 changes: 4 additions & 0 deletions cli/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@ fn run_as_tool() -> Option<i32> {
Tool::AndroidOps => i32::from(dx_android_ops::run(&lossy(args))),
#[cfg(not(windows))]
Tool::AppleOps => i32::from(dx_apple_ops::run(&lossy(args))),
#[cfg(not(windows))]
Tool::AppimagePacker => i32::from(appimage_packer::run(&lossy(args))),
#[cfg(not(windows))]
Tool::AppimageFile => i32::from(appimage_packer::refuse_file()),
Tool::QtRustBridge => qt_rust_bridge::run_process(&lossy(args)),
Tool::BeamExtract => dx_docs_beam_extract::run_process(&lossy(args)),
Tool::CcExtract => dx_docs_cc_extract::run_process(&lossy(args)),
Expand Down
17 changes: 16 additions & 1 deletion cli/cli/src/multicall.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
//! `dx` runs a bundled tool when started under that tool's name, so the prebuilt hub can ship one
//! binary and expose it as `quality_runner`, `quality_markdown`, `quality_notebook`, `lsp_check`,
//! `collect_native`, `env_shard_writer`, `codegen_shard_writer`, `deploy_tool` and the
//! `conda-ocaml-{ar,as,cc,ld,mkdll,mkexe,ranlib}` names the OCaml compiler calls. Rule helpers
//! `conda-ocaml-{ar,as,cc,ld,mkdll,mkexe,ranlib}` names the OCaml compiler calls, and `file`, which
//! `dx appimage_packer` puts on appimagetool's PATH. Rule helpers
//! that need no alias run as `dx <tool> [ARG]...`, so a host without symlinks keeps one copy of dx.

use std::ffi::OsStr;
Expand Down Expand Up @@ -37,6 +38,10 @@ pub enum Tool {
AndroidOps,
#[cfg(not(windows))]
AppleOps,
#[cfg(not(windows))]
AppimagePacker,
#[cfg(not(windows))]
AppimageFile,
QtRustBridge,
BeamExtract,
CcExtract,
Expand Down Expand Up @@ -104,6 +109,8 @@ pub fn tool_for(argv0: &OsStr) -> Option<Tool> {
| "conda-ocaml-mkdll" | "conda-ocaml-mkexe" | "conda-ocaml-ranlib" => {
Some(Tool::OcamlCcDriver)
}
#[cfg(not(windows))]
"file" => Some(Tool::AppimageFile),
_ => None,
}
}
Expand Down Expand Up @@ -132,6 +139,8 @@ pub fn subcommand_for(arg1: &OsStr) -> Option<Tool> {
"android_ops" => Some(Tool::AndroidOps),
#[cfg(not(windows))]
"apple_ops" => Some(Tool::AppleOps),
#[cfg(not(windows))]
"appimage_packer" => Some(Tool::AppimagePacker),
"qt_rust_bridge" => Some(Tool::QtRustBridge),
"beam_extract" => Some(Tool::BeamExtract),
"cc_extract" => Some(Tool::CcExtract),
Expand Down Expand Up @@ -211,6 +220,8 @@ mod tests {
("deploy_tool.exe", Tool::DeployTool),
("conda-ocaml-cc", Tool::OcamlCcDriver),
("x/bin/conda-ocaml-ranlib.exe", Tool::OcamlCcDriver),
#[cfg(not(windows))]
("work/path/file", Tool::AppimageFile),
] {
assert_eq!(tool_for(OsStr::new(name)), Some(tool), "{name}");
}
Expand Down Expand Up @@ -269,6 +280,8 @@ mod tests {
("android_ops", Tool::AndroidOps),
#[cfg(not(windows))]
("apple_ops", Tool::AppleOps),
#[cfg(not(windows))]
("appimage_packer", Tool::AppimagePacker),
("qt_rust_bridge", Tool::QtRustBridge),
("beam_extract", Tool::BeamExtract),
("cc_extract", Tool::CcExtract),
Expand Down Expand Up @@ -342,6 +355,7 @@ mod tests {
"zig_extract",
"android_ops",
"apple_ops",
"appimage_packer",
"qt_rust_bridge",
"beam_extract",
"cc_extract",
Expand Down Expand Up @@ -398,6 +412,7 @@ mod tests {
"quality_runner",
"deploy_tool",
"conda-ocaml-cc",
"file",
"capture.exe",
"test",
"check",
Expand Down
5 changes: 2 additions & 3 deletions tools/testing/consumer/fixtures.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ JAVA_GUARD_LANGS = [
IN_GRAPH_GUARD_LANGS = [
"android",
"ansible",
"appimage",
"asciidoc",
"astro",
"bicep",
Expand Down Expand Up @@ -138,9 +139,7 @@ WINDOWS_IN_GRAPH_GUARD_LANGS = [
]

# The consumer fixtures no prebuilt guard covers yet.
GUARD_PENDING = [
"appimage", # appimage_packer is a rust_binary
]
GUARD_PENDING = []

# The fixtures whose test is the consumer evidence of the support matrix row of the same name.
CONSUMER_ROWS = [
Expand Down
Loading