pantry/scripts/build.ts
Max Howell 8a59338e83
Don’t use sort.ts in CI to pre-install
The `dry` packages end up being constraints for the whole graph which in cyclic situations prevents bootstrapping.

Eg. llvm^12 cannot be built because sort insists that it depends on llvm^12 which is not yet bottled.
2022-11-09 11:48:19 -05:00

60 lines
1.7 KiB
TypeScript
Executable file

#!/usr/bin/env -S tea -E
/*---
dependencies:
gnu.org/tar: 1
tukaani.org/xz: 5
sourceware.org/bzip2: 1
args:
- deno
- run
- --allow-net
- --allow-run
- --allow-read
- --allow-write={{tea.prefix}}
- --allow-env
- --unstable
- --import-map={{ srcroot }}/import-map.json
---*/
import { usePantry, useFlags, useCellar, useInventory, usePrefix } from "hooks"
import { hydrate, install, link } from "prefab"
import { str as pkgstr } from "utils/pkg.ts"
import * as ARGV from "./utils/args.ts"
import { panic } from "utils/error.ts"
import build, { BuildResult } from "./build/build.ts"
import { set_output } from "./utils/gha.ts";
useFlags()
const pantry = usePantry()
const cellar = useCellar()
const inventory = useInventory()
const raw = await ARGV.toArray(ARGV.pkgs())
const rv: BuildResult[] = []
for (const rq of raw) {
const dry = await pantry.getDeps(rq)
const wet = await hydrate([...dry.runtime, ...dry.build])
for (const pkg of wet.pkgs) {
if (!await cellar.has(pkg)) {
const version = await inventory.select(pkg) ?? panic(`${pkgstr(pkg)} not found`)
const installation = await install({ project: pkg.project, version })
await link(installation)
}
}
const pkg = await pantry.resolve(rq)
rv.push(await build(pkg))
await link(pkg)
}
const to = usePrefix()
await set_output("pkgs", rv.map(x => pkgstr(x.installation.pkg)))
await set_output("paths", rv.map(x => x.installation.path), '%0A')
await set_output("relative-paths", rv.map(x => x.installation.path.relative({ to })))
await set_output("srcs", rv.map(x => x.src?.relative({ to }) ?? "~"))
await set_output("srcs-relative-paths", rv.compact(x => x.src?.relative({ to })))