Skip to content

Commit

Permalink
Hydrate pkg.deps to get build deps
Browse files Browse the repository at this point in the history
  • Loading branch information
mxcl committed Mar 1, 2023
1 parent c8e4222 commit d61f122
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
8 changes: 2 additions & 6 deletions bin/pkg-build
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,9 @@ if test -z "$GITHUB_TOKEN"; then
export GITHUB_TOKEN
fi

# should one of these depend on the other:
# ensure they are build in the correct order

# split on spaces
# shellcheck disable=SC2086
PKGS="$(sort.ts $PKGS --delimiter ' ')"
# ^^ ensures that pkgs build topologically

for PKG in $PKGS; do
PKG="$(resolve.ts "$PKG")"
Expand All @@ -53,8 +50,7 @@ for PKG in $PKGS; do

DEPS=$(deps.ts "$PKG" --build) # eg. nodejs.org^4

# split on spaces
# shellcheck disable=SC2086
# shellcheck disable=SC2086
DEPS=$(install.ts $DEPS) # eg. ~/.tea/nodejs.org/v4.3.2

mkdir -p "$SRCDIR"
Expand Down
1 change: 0 additions & 1 deletion bin/pkg-test
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ fi
for PKG in $PKGS; do
PKG="$(resolve.ts "$PKG" --cellar)"
DEPS="$(deps.ts "$PKG" --test)"
# We intend to split on spaces, so disable the shellcheck warning.
# shellcheck disable=2086
DEPS="$(install.ts $DEPS)"
DSTDIR="$(query.ts "$PKG" --testdir)"
Expand Down
17 changes: 11 additions & 6 deletions libexec/deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,20 @@ const { flags: { build, test }, unknown: [pkgname] } = parseFlags(Deno.args, {
const pkg = parse(pkgname)
const pantry = usePantry()

const rv = await hydrate([pkg], async (pkg, dry) => {
/// when building we don’t incorporate the target into the hydration graph
/// because we don’t want it yet: we”re about to build it

const dry = build
? (({ runtime, build }) => [...runtime, ...build])(await pantry.getDeps(pkg))
: [pkg]

const { pkgs: wet } = await hydrate(dry, async (pkg, dry) => {
const deps = await pantry.getDeps(pkg)
if (dry && build) {
return [...deps.build, ...deps.runtime]
} else if (dry && test) {
return [...deps.test, ...deps.runtime]
if (dry && test) {
return [...deps.runtime, ...deps.test]
} else {
return deps.runtime
}
})

console.log(rv.wet.map(str).join("\n"))
console.log(wet.map(str).join("\n"))

0 comments on commit d61f122

Please sign in to comment.