Skip to content

Commit a52cdb1

Browse files
authored
Add {{srcroot}}, {{props}} (#241)
* Pass through some other vars like `LANG`. This fixes some ruby issues
1 parent 1176454 commit a52cdb1

File tree

6 files changed

+29
-22
lines changed

6 files changed

+29
-22
lines changed

.github/workflows/ci.cli.yml

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ jobs:
2929
- pyapp.com/2
3030
- stark.com/foo@1.2.3
3131
- git-clone.com
32+
- pc-cmake.com
33+
3234
runs-on: ${{ matrix.platform.os }}
3335
container: ${{ matrix.platform.img }}
3436
steps:
@@ -78,13 +80,3 @@ jobs:
7880
set +e
7981
bin/bk build unavailable.com
8082
test $? -eq 2
81-
82-
fix-up:
83-
runs-on: ubuntu-latest
84-
steps:
85-
- uses: actions/checkout@v4
86-
- uses: pkgxdev/setup@v2
87-
- run: pkgx --sync
88-
- run: bin/bk build pc-cmake.com
89-
- run: bin/bk test pc-cmake.com
90-
- run: bin/bk audit pc-cmake.com

bin/cmd/build

Lines changed: 2 additions & 2 deletions
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 {
@@ -100,7 +100,7 @@ const env: Record<string, string> = {
100100
PATH: '/usr/bin:/bin:/usr/sbin:/sbin',
101101
PKGX_DIR: useConfig().prefix.string
102102
}
103-
for (const key of ['HOME', 'PKGX_PANTRY_PATH', 'XDG_DATA_HOME', 'GITHUB_TOKEN']) {
103+
for (const key of ['HOME', 'PKGX_PANTRY_PATH', 'XDG_DATA_HOME', 'GITHUB_TOKEN', 'LANG', 'LOGNAME', 'USER']) {
104104
const value = Deno.env.get(key)
105105
if (value) env[key] = value
106106
}

bin/cmd/test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const gum_ = find_in_PATH('gum')
3333
const depstr = (deps: (PackageRequirement | Package)[]) => deps.map(x => `"+${utils.pkg.str(x)}"`).join(' ')
3434
const env_plus = `${depstr([config.pkg])} ${depstr(config.deps.dry.runtime)} ${depstr(config.deps.dry.test)}`.trim()
3535

36-
const user_script = await usePantry().getScript(config.pkg, 'test', config.deps.gas, config.path.install)
36+
const user_script = await usePantry().getScript(config.pkg, 'test', config.deps.gas, config)
3737

3838
const script_text = undent`
3939
#!${bash}
@@ -87,7 +87,7 @@ script.write({ force: true, text: script_text }).chmod(0o755)
8787
await gum("test")
8888

8989
const env: Record<string, string> = {PATH: '/usr/bin:/bin:/usr/sbin:/sbin'}
90-
for (const key of ['HOME', 'PKGX_PANTRY_PATH', 'XDG_DATA_HOME', 'GITHUB_TOKEN']) {
90+
for (const key of ['HOME', 'PKGX_PANTRY_PATH', 'XDG_DATA_HOME', 'GITHUB_TOKEN', 'LANG', 'LOGNAME', 'USER']) {
9191
const value = Deno.env.get(key)
9292
if (value) env[key] = value
9393
}

lib/hooks/usePantry.getScript.ts

Lines changed: 14 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 { Config as 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,27 @@ 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) => {
12+
const install_path = key == 'build' ? config.path.build_install : config.path.install
1113
const yml = await hooks.usePantry().project(pkg).yaml()
1214
const node = yml[key]
1315

1416
const mm = useMoustaches()
1517
const tokens = mm.tokenize.all(pkg, deps)
1618
tokens.push({
17-
from: "pkgx.dir", to: useConfig().prefix.string
19+
from: "pkgx.dir", to: usePkgxConfig().prefix.string
1820
})
21+
if (key == 'build') {
22+
tokens.push({
23+
from: "srcroot", to: config.path.build.string
24+
}, {
25+
from: "props", to: config.path.build.join("props").string
26+
})
27+
}
1928

2029
for (const [index, token] of tokens.entries()) {
2130
if (token.from == "prefix") {
22-
tokens[index] = { from: "prefix", to: install_prefix.string }
31+
tokens[index] = { from: "prefix", to: install_path.string }
2332
}
2433
}
2534

@@ -87,7 +96,7 @@ export const getScript = async (pkg: Package, key: 'build' | 'test', deps: Insta
8796
const rv = []
8897
for (const token of tokens) {
8998
if (token.from == "prefix") {
90-
rv.push({from: "prefix", to: install_prefix.string})
99+
rv.push({from: "prefix", to: install_path.string})
91100
} else {
92101
rv.push(token)
93102
}

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)