Skip to content

Commit dd24e37

Browse files
authored
consequences of llvm/gcc getting cc symlinks (#181)
1 parent 4acc450 commit dd24e37

File tree

15 files changed

+84
-65
lines changed

15 files changed

+84
-65
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ jobs:
3535
- run: pkg build ${{matrix.pkgs}}
3636
id: build
3737

38-
- if: always()
39-
run: cat ${{ steps.build.outputs.build-dir }}/config.log || true
40-
4138
- run: test -n '${{ steps.build.outputs.pkgs }}'
4239
- run: test -n '${{ steps.build.outputs.relative-paths }}'
4340

bin/pkg-build

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
#!/usr/bin/env -S pkgx bash -eo pipefail
1+
#!/usr/bin/env -S pkgx bash
22
# shellcheck shell=bash
33

4+
set -eo pipefail
5+
46
PKGX_DIR=${PKGX_DIR:-"$HOME/.pkgx"}
57

68
if pwd | grep -q ' '; then
@@ -32,7 +34,7 @@ if test -n "$PKGX_DOCKER"; then
3234
exec "$d"/bin/pkg-docker build "$PKGS"
3335
fi
3436

35-
if ! available.ts "$PKGS"; then
37+
if ! available.ts $PKGS; then
3638
echo "warning: not supported on current platform" >&2
3739
exit 0
3840
fi

bin/pkg-clean

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
#!/usr/bin/env -S pkgx bash -eo pipefail
1+
#!/usr/bin/env -S pkgx bash
22
# shellcheck shell=bash
33

4+
set -eo pipefail
5+
46
d="$(cd "$(dirname "$0")"/.. && pwd)"
57
PATH="$d/libexec:$PATH"
68

bin/pkg-docker

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ if test "$arg0" = docker; then
1818
exit 1
1919
elif shift; then
2020
# ensure this brewkit is used
21-
CMD="pkgx +deno.land ""$d/bin/pkg-$arg0"
21+
CMD="$d/bin/pkg-$arg0"
2222
ADDARGS="--volume ""$d"":""$d"
2323
else
2424
# we were invoked as `pkg -L` by itself

bin/pkg-edit

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
#!/usr/bin/env -S pkgx bash -eo pipefail
1+
#!/usr/bin/env -S pkgx bash
22
# shellcheck shell=bash
33

4-
set -e
4+
set -eo pipefail
55

66
d="$(cd "$(dirname "$0")"/.. && pwd)"
77
PATH="$d/libexec:$PATH"

bin/pkg-fetch

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
#!/usr/bin/env -S pkgx bash -eo pipefail
1+
#!/usr/bin/env -S pkgx bash
22
# shellcheck shell=bash
33

4+
set -eo pipefail
5+
46
d="$(cd "$(dirname "$0")"/.. && pwd)"
57
PATH="$d/libexec:$PATH"
68

bin/pkg-fixup

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
#!/usr/bin/env -S pkgx bash -eo pipefail
1+
#!/usr/bin/env -S pkgx bash
22
# shellcheck shell=bash
33

4+
set -eo pipefail
5+
46
d="$(cd "$(dirname "$0")"/.. && pwd)"
57
PATH="$d/libexec:$PATH"
68

bin/pkg-test

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
#!/usr/bin/env -S pkgx bash -eo pipefail
1+
#!/usr/bin/env -S pkgx bash
22
# shellcheck shell=bash
33

4+
set -eo pipefail
5+
46
d="$(cd "$(dirname "$0")"/.. && pwd)"
57
PATH="$d/libexec:$PATH"
68

libexec/find.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
#!/usr/bin/env -S pkgx deno run --allow-read --allow-env
22

3-
import { hooks } from "pkgx"
3+
import { hooks, utils } from "pkgx"
44
const { find } = hooks.usePantry()
55

66
for (const arg of Deno.args) {
7-
const rv = await find(arg)
7+
8+
const {project, constraint} = utils.pkg.parse(arg)
9+
10+
const rv = await find(project)
811

912
if (rv.length > 1) {
1013
console.error("multiple matches: " + rv.map(({project}) => project).join(' '))
@@ -18,6 +21,7 @@ for (const arg of Deno.args) {
1821
if (Deno.env.get("_PATHS")) {
1922
console.info(rv[0].path.string)
2023
} else {
21-
console.info(rv[0].project)
24+
const pkg = {project: rv[0].project, constraint}
25+
console.info(utils.pkg.str(pkg))
2226
}
2327
}

libexec/stage-test.ts

Lines changed: 25 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { parseFlags } from "cliffy/flags/mod.ts"
44
import { hooks, utils, Path } from "pkgx"
55
import undent from "outdent"
6+
import host from "libpkgx/utils/host.ts";
67

78
const { usePantry, useCellar, useConfig, useShellEnv } = hooks
89
const { pkg: pkgutils, panic } = utils
@@ -31,10 +32,20 @@ const deps = await (() => {
3132
return Promise.all(pp)
3233
})()
3334
const dstdir = new Path(flags.dstdir)
34-
const yml = await pantry.project(pkg).yaml()
35+
const project = pantry.project(pkg)
36+
const yml = await project.yaml()
3537
const installations = [...deps]
3638
if (deps.find(x => x.pkg.project == self.pkg.project) === undefined) installations.push(self)
3739

40+
/// try to find `pkgx` since we deliberately withold it from the PATH for tests
41+
/// since it needs to be an explicit dependency
42+
const pkgx = (PATH => {
43+
for (const path of PATH.split(":")) {
44+
const f = Path.abs(path)?.join("pkgx").isExecutableFile()
45+
if (f) return f.string
46+
}
47+
})(Deno.env.get("PATH") ?? '') ?? 'pkgx'
48+
3849
Deno.env.set("HOME", dstdir.string) //lol side-effects beware!
3950
const env = await useShellEnv().map({ installations })
4051

@@ -43,44 +54,20 @@ if (!yml.test) throw "no `test` node in package.yml"
4354
env['PATH'] ??= []
4455
env['PATH'].push("/usr/bin:/bin")
4556

46-
if (!deps.find(({pkg}) => pkg.project == 'llvm.org' || pkg.project == 'gnu.org/gcc')) {
47-
/// add our helper cc toolchain unless the package has picked its own toolchain
48-
env['PATH'].unshift(new Path(new URL(import.meta.url).pathname).parent().parent().join("share/toolchain/bin").string)
49-
50-
//COPY PASTA from stage.ts
51-
const d = dstdir.join('dev.pkgx.bin').mkdir()
52-
const symlink = (names: string[], {to}: {to: string}) => {
53-
for (const name of names) {
54-
const path = d.join(name)
55-
if (path.exists()) continue
56-
const target = useConfig().prefix.join('llvm.org/v*/bin', to)
57-
path.ln('s', { target })
58-
}
59-
}
60-
61-
symlink(["ar"], {to: "llvm-ar"})
62-
symlink(["as"], {to: "llvm-as"})
63-
symlink(["cc", "gcc", "clang"], {to: "clang"})
64-
symlink(["c++", "g++", "clang++"], {to: "clang++"})
65-
symlink(["cpp"], {to: "clang-cpp"})
66-
symlink(["ld"], {to: "lld"})
67-
symlink(["lld"], {to: "lld"})
68-
symlink(["ld64.lld"], {to: "ld64.lld"})
69-
symlink(["lld-link"], {to: "lld-link"})
70-
symlink(["objcopy"], {to: "llvm-objcopy"})
71-
symlink(["readelf"], {to: "llvm-readelf"})
72-
symlink(["strip"], {to: "llvm-strip"})
73-
symlink(["nm"], {to: "llvm-nm"})
74-
symlink(["ranlib"], {to: "llvm-ranlib"})
75-
symlink(["strings"], {to: "llvm-strings"})
76-
}
77-
7857
let text = undent`
79-
#!/usr/bin/env bash
80-
81-
set -e
82-
set -o pipefail
83-
set -x
58+
#!/usr/bin/env -S pkgx bash
59+
60+
set -exo pipefail
61+
62+
command_not_found_handle() {
63+
echo "::warning::\\\`$1\\\` is not an explicit dependency!"
64+
case $1 in
65+
cc|c++|ld)
66+
${pkgx} +llvm.org -- "$@";;
67+
*)
68+
${pkgx} -- "$@";;
69+
esac
70+
}
8471
8572
export PKGX_DIR="${useConfig().prefix}"
8673
export HOME="${dstdir}"

0 commit comments

Comments
 (0)