Skip to content

Commit 0fe1acb

Browse files
committed
Add {{srcroot}}, {{props}}
1 parent 1176454 commit 0fe1acb

File tree

4 files changed

+20
-9
lines changed

4 files changed

+20
-9
lines changed

bin/cmd/build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ const yml = YAML.parse(await config.path.yaml.read()) as any
5858

5959
/// fetch
6060
await gum('fetch & extract')
61-
let fetched: undefined | 'git' | 'tarball'
61+
let fetched: Path | 'git' | 'tarball' | undefined
6262
if (yml.distributable) {
6363
fetched = await fetch(config)
6464
} else {

lib/hooks/usePantry.getScript.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import useConfig from "libpkgx/hooks/useConfig.ts"
1+
import usePkgxConfig from "libpkgx/hooks/useConfig.ts"
2+
import BrewkitConfig from "brewkit/config.ts"
23
import { SupportedPlatforms, SupportedArchitectures } from "libpkgx/utils/host.ts"
34
import { isArray, isString, isPlainObject, PlainObject, isPrimitive, isBoolean, isNumber } from "is-what"
45
import { Package, Installation, hooks, utils, semver, Path, PantryParseError } from "libpkgx"
@@ -7,19 +8,23 @@ import undent from "outdent"
78
const { validate, host } = utils
89
const { useMoustaches } = hooks
910

10-
export const getScript = async (pkg: Package, key: 'build' | 'test', deps: Installation[], install_prefix: Path) => {
11+
export const getScript = async (pkg: Package, key: 'build' | 'test', deps: Installation[], config: BrewkitConfig) => {
1112
const yml = await hooks.usePantry().project(pkg).yaml()
1213
const node = yml[key]
1314

1415
const mm = useMoustaches()
1516
const tokens = mm.tokenize.all(pkg, deps)
1617
tokens.push({
17-
from: "pkgx.dir", to: useConfig().prefix.string
18+
from: "pkgx.dir", to: usePkgxConfig().prefix.string
19+
}, {
20+
from: "srcroot", to: config.path.build.string
21+
}, {
22+
from: "props", to: config.path.build.join("props").string
1823
})
1924

2025
for (const [index, token] of tokens.entries()) {
2126
if (token.from == "prefix") {
22-
tokens[index] = { from: "prefix", to: install_prefix.string }
27+
tokens[index] = { from: "prefix", to: config.path.build_install.string }
2328
}
2429
}
2530

@@ -87,7 +92,7 @@ export const getScript = async (pkg: Package, key: 'build' | 'test', deps: Insta
8792
const rv = []
8893
for (const token of tokens) {
8994
if (token.from == "prefix") {
90-
rv.push({from: "prefix", to: install_prefix.string})
95+
rv.push({from: "prefix", to: config.path.build_install.string})
9196
} else {
9297
rv.push(token)
9398
}

lib/porcelain/build-script.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const { host } = utils
99
export default async function(config: Config, PATH?: Path): Promise<string> {
1010
const depstr = (deps: PackageRequirement[]) => deps.map(x => `"+${utils.pkg.str(x)}"`).join(' ')
1111
const env_plus = `${depstr(config.deps.dry.runtime)} ${depstr(config.deps.dry.build)}`.trim()
12-
const user_script = await usePantry().getScript(config.pkg, 'build', config.deps.gas, config.path.build_install)
12+
const user_script = await usePantry().getScript(config.pkg, 'build', config.deps.gas, config)
1313

1414
const pkgx = find_in_PATH('pkgx')
1515
const bash = find_in_PATH('bash')
@@ -45,7 +45,7 @@ export default async function(config: Config, PATH?: Path): Promise<string> {
4545
export FORCE_UNSAFE_CONFIGURE=1
4646
fi
4747
mkdir -p $HOME
48-
${FLAGS.join('\n')}
48+
${FLAGS.join('\n ')}
4949
5050
env -u GH_TOKEN -u GITHUB_TOKEN
5151

projects/stark.com/foo/package.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,13 @@ build:
1717
- test "$SRCROOT" = "$PWD"
1818

1919
# verify GNU sed (doesn’t require a backup file)
20-
- sed -i s/sup_bro/sup_unc/g props/package.yml
20+
- sed -i s/sup_bro/sup_unc/g {{props}}/package.yml
21+
22+
- |
23+
test {{props}} = $PWD/props
24+
test {{srcroot}} = $SRCROOT
25+
test {{srcroot}} = $PWD
26+
test -d {{pkgx.dir}}
2127
2228
# verify pkgx is not here
2329
- |

0 commit comments

Comments
 (0)