diff --git a/doc/catalog-format-spec.md b/doc/catalog-format-spec.md index 40a153d4b..2307460d6 100644 --- a/doc/catalog-format-spec.md +++ b/doc/catalog-format-spec.md @@ -455,6 +455,12 @@ static, i.e. they cannot depend on the context. several crates from the same repository (sometimes referred to as a *monorepo*). + - `binary`: optional (defauts to false) boolean used to design the origin + as binary. Binary origins are not compiled and can use dynamic + expressions to narrow down the platform to which they apply. An origin + using a dynamic expression is implicitly tagged as binary; see the + example below. + Examples of origin tables: ```toml @@ -479,6 +485,13 @@ static, i.e. they cannot depend on the context. subdir = "examples" ``` + ```toml + # A binary origin denoting a compiler + [origin."case(os)".linux."case(host-arch)".x86-64] + url = "https://github.com/alire-project/GNAT-FSF-builds/releases/download/gnat-12.1.0-1/gnat-x86_64-linux-12.1.0-1.tar.gz" + hashes = ["sha256:df1f36b306359d528799b1de8629a793523347a90c9d4b72efd23c62a7279555"] + ``` + - `available`: optional dynamic boolean expression. If it evaluates to `false`, the package is not available for the current platform. diff --git a/testsuite/tests/index/origin-binary-explicit/my_index/crates/libhello_1.0.0.tgz b/testsuite/tests/index/origin-binary-explicit/my_index/crates/libhello_1.0.0.tgz new file mode 100644 index 000000000..e0add12ef Binary files /dev/null and b/testsuite/tests/index/origin-binary-explicit/my_index/crates/libhello_1.0.0.tgz differ diff --git a/testsuite/tests/index/origin-binary-explicit/my_index/index/he/hello_world/hello_world-0.1.0.toml b/testsuite/tests/index/origin-binary-explicit/my_index/index/he/hello_world/hello_world-0.1.0.toml new file mode 100644 index 000000000..9f485f14f --- /dev/null +++ b/testsuite/tests/index/origin-binary-explicit/my_index/index/he/hello_world/hello_world-0.1.0.toml @@ -0,0 +1,11 @@ +description = "\"Hello, world!\" demonstration project" +name = "hello_world" +version = "0.1.0" +licenses = "GPL-3.0-only" +maintainers = ["user@example.com"] +maintainers-logins = ["mylogin"] + +[origin] +url = "../../../crates/libhello_1.0.0.tgz" +hashes = ["sha256:c17d6ce87c6997c5f68ea4bfe6134c318073fed38ec0f81ccb1ae2bfdcc0187a"] +binary = true diff --git a/testsuite/tests/index/origin-binary-explicit/my_index/index/index.toml b/testsuite/tests/index/origin-binary-explicit/my_index/index/index.toml new file mode 100644 index 000000000..bad265e4f --- /dev/null +++ b/testsuite/tests/index/origin-binary-explicit/my_index/index/index.toml @@ -0,0 +1 @@ +version = "1.1" diff --git a/testsuite/tests/index/origin-binary-explicit/test.py b/testsuite/tests/index/origin-binary-explicit/test.py new file mode 100644 index 000000000..4164694d5 --- /dev/null +++ b/testsuite/tests/index/origin-binary-explicit/test.py @@ -0,0 +1,37 @@ +""" +Test that origins explicitly marked as binary are interpreted as such, even if +they do not use a dynamic expression. +""" + +from glob import glob +import os +from drivers import builds +from drivers.alr import alr_config_dir, alr_with, run_alr, init_local_crate +from drivers.asserts import assert_match +from drivers.helpers import contents + +# Check basic loading +p = run_alr('show', 'hello_world') +assert "Origin: binary archive" in p.out, \ + "Unexpected output: " + p.out + +init_local_crate() +alr_with("hello_world") +run_alr("build") + +# Check deployment location +if builds.are_shared(): + # Build dir of a binary crate should not exist, as it is used directly from + # its download location + assert len(glob(f"{builds.path()}/hello_world*")) ==0 , \ + "Unexpected build dir: " + str(contents(builds.path())) +else: + # Config should not have been generated for a binary crate during build + assert os.path.exists(os.path.join("alire", "cache", "dependencies", + "hello_world_0.1.0_c17d6ce8")) + assert not os.path.exists(os.path.join("alire", "cache", "dependencies", + "hello_world_0.1.0_c17d6ce8", + "config")), \ + "Unexpected config dir: " + str(contents("alire")) + +print('SUCCESS') diff --git a/testsuite/tests/index/origin-binary-explicit/test.yaml b/testsuite/tests/index/origin-binary-explicit/test.yaml new file mode 100644 index 000000000..9f4d48305 --- /dev/null +++ b/testsuite/tests/index/origin-binary-explicit/test.yaml @@ -0,0 +1,5 @@ +driver: python-script +build_mode: both +indexes: + my_index: + in_fixtures: false