Skip to content

Commit

Permalink
Added unit entry points to individual builders
Browse files Browse the repository at this point in the history
Also removes the need for the "ensure used" marker
  • Loading branch information
Thesola10 committed Feb 24, 2025
1 parent ba3baa9 commit d81fdb5
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ __pycache__
result
nixie/output/nix-wrapped.sh.in
src/docs
src/*.sh
src/**/*.sh
14 changes: 7 additions & 7 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions src/builders/autoconf.ab
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,21 @@ pub fun build_autoconf_dep(lib_name: Text, var_name: Text,
trust env_var_set("{var_name}_CFLAGS", "-I{my_source}/{inc_prefix}/include")
trust $export {var_name}_LIBS {var_name}_CFLAGS$
}

main(cmdl)
{
if len(cmdl) < 5 {
echo "Usage: ./autoconf.sh <package> <var_name> <lib_prefix> <inc_prefix>"
echo ""
echo "See builders/autoconf.ab and builders.ab for more info"
exit 1
}

let lib_name = cmdl[1]
let var_name = cmdl[2]
let lib_prefix = cmdl[3]
let inc_prefix = cmdl[4]

trust env_var_set("_NIXIE_TESTING_SKIP_TARBALL", "1")
build_autoconf_dep(lib_name, var_name, lib_prefix, inc_prefix)?
}
8 changes: 4 additions & 4 deletions src/builders/boost.ab
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ pub fun build_boost()
trust $export BOOST_ROOT$
}

// Quick mark-as-used workaround
if false {
exit 300
trust build_boost_inner()
main(cmdl)
{
trust env_var_set("_NIXIE_TESTING_SKIP_TARBALL", "1")
build_boost()?
}
8 changes: 4 additions & 4 deletions src/builders/lowdown.ab
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ pub fun build_lowdown()
trust env_var_set("LOWDOWN_CFLAGS", "-I{source_root}/lowdown")
}

// Quick mark-as-used workaround
if false {
exit 300
trust build_lowdown_inner()
main(cmdl)
{
trust env_var_set("_NIXIE_TESTING_SKIP_TARBALL", "1")
build_lowdown()?
}
11 changes: 7 additions & 4 deletions src/builders/nix.ab
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,12 @@ pub fun build_nix()
trust mv "{source_root}/nix/src/nix/nix" "{cache_root}/nix-static"
}

main(cmdl)
{
echo "This builder only makes sense in the wrapper context,"
echo "where all dependencies were built and/or resolved."
echo ""
echo "Use ./nix --nixie-no-precompiled to test the full build chain."

// Quick mark-as-used workaround
if false {
exit 300
trust build_nix_inner()
exit 1
}
6 changes: 6 additions & 0 deletions src/builders/nlohmann_json.ab
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,9 @@ pub fun build_nlohmann_json()
trust env_var_set("NLOHMANN_JSON_CFLAGS", "{source_root}/nlohmann_json/single_include")
trust $export NLOHMANN_JSON_LIBS NLOHMANN_JSON_CFLAGS$
}

main(cmdl)
{
trust env_var_set("_NIXIE_TESTING_SKIP_TARBALL", "1")
build_nlohmann_json()?
}
9 changes: 5 additions & 4 deletions src/builders/openssl.ab
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ pub fun build_openssl()
trust $export OPENSSL_LIBS OPENSSL_CFLAGS$
}

// Quick mark-as-used workaround
if false {
exit 300
trust build_openssl_inner()
main(cmdl)
{
trust env_var_set("_NIXIE_TESTING_SKIP_TARBALL", "1")
build_openssl()?
}

29 changes: 24 additions & 5 deletions src/resources.ab
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
// Resource retrieval from tarball or Cachix

import { file_download } from "std/http"
import { env_var_get } from "std/env"
import { file_exists } from "std/fs"
import { env_var_get, env_var_test } from "std/env"

import { untar } from "./common.ab"

Expand All @@ -18,14 +19,32 @@ pub fun pull_source_file(member: Text, dest: Text): Null?
{
let SOURCE_DERIVATION = trust env_var_get("SOURCE_DERIVATION")

let where = trust untar("sources/{member}")
if status != 0 {
let where = ""
let my_status = 1
if not env_var_test("_NIXIE_TESTING_SKIP_TARBALL") {
where = trust untar("sources/{member}")
my_status = status
}

if env_var_test("_NIXIE_TESTING_SOURCES_DIR") and my_status != 0 {
let srcdir = trust env_var_get("_NIXIE_TESTING_SOURCES_DIR")
let tmpd = trust $mktemp -t -d nixie_{member}_XXXXXXXX$

if file_exists("{srcdir}/{member}.tar.gz") {
trust $gzip -d -c {srcdir}/{member}.tar.gz | tar -x -C {tmpd}$
my_status = status
where = "{tmpd}/{member}"
} else {
my_status = 1
}
}

if my_status != 0 {
let tmpf = trust $mktemp -t nixie_src_XXXXXXXX.tgz$
let tmpd = trust $mktemp -t -d nixie_{member}_XXXXXXXX$

if not file_download(cachix_url(SOURCE_DERIVATION, "{member}.tar.gz"), tmpf) {
if not file_download(cachix_url(SOURCE_DERIVATION, "{member}.tar.gz"), tmpf):
fail 1
}

$gzip -d -c {tmpf} | tar -x -C {tmpd}$?

Expand Down

0 comments on commit d81fdb5

Please sign in to comment.