Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions .github/workflows/ci.cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
matrix:
platform:
- os: ubuntu-latest
img: debian:buster-slim
img: debian:bullseye-slim
tag: linux
- os: macos-latest
tag: mac
Expand All @@ -35,6 +35,9 @@ jobs:
- uses: actions/checkout@v4
- uses: pkgxdev/setup@v2

# otherwise, we're getting some weird race conditions on CI
- run: pkgx --sync

- run: bin/bk build ${{matrix.pkg}}
- run: bin/bk test ${{matrix.pkg}}
- run: bin/bk audit ${{matrix.pkg}}
Expand All @@ -53,14 +56,13 @@ jobs:
# check build can run twice, see https://github.com/pkgxdev/brewkit/issues/303
- run: bin/bk build


unit-tests:
runs-on: ubuntu-latest
env:
PKGX_PANTRY_PATH: null
steps:
- uses: actions/checkout@v4
- uses: pkgxdev/dev@v0
- uses: pkgxdev/dev@v1
- run: deno test --allow-env --allow-net --ignore=.data
working-directory: lib

Expand All @@ -69,7 +71,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: pkgxdev/setup@v2
- run: pkgx --sync # FIXME PKGX_PANTRY_PATH causes auto sync to fail
- run: pkgx --sync # FIXME PKGX_PANTRY_PATH causes auto sync to fail
- name: build
run: |
set +e
Expand Down
65 changes: 65 additions & 0 deletions lib/porcelain/fix-up.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ export default async function finish(config: Config) {
await fix_rpaths(prefix, config.pkg, config.path.cache, config.deps.gas)
await fix_pc_files(prefix, config.path.build_install)
await fix_cmake_files(prefix, config.path.build_install)
await remove_la_files(prefix)
if (host().platform == 'linux') {
await consolidate_lib64(prefix)
}
await flatten_headers(prefix)
}

//////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -100,3 +105,63 @@ async function fix_cmake_files(pkg_prefix: Path, build_prefix: Path) {
}
}
}

async function remove_la_files(pkg_prefix: Path) {
// libtool .la files contain hardcoded paths and cause more problems than they solve
const lib = pkg_prefix.join("lib").isDirectory()
if (!lib) return
for await (const [path, { isFile }] of lib.walk()) {
if (isFile && path.extname() == ".la") {
console.log({ removing: path })
Deno.removeSync(path.string)
}
}
}

async function consolidate_lib64(pkg_prefix: Path) {
// some build systems install to lib64 on x86-64 Linux; we standardize on lib
const lib64 = pkg_prefix.join("lib64")
if (!lib64.isDirectory()) return

const lib = pkg_prefix.join("lib")
lib.mkpath()

for await (const [path, { isFile, isSymlink }] of lib64.ls()) {
const dest = lib.join(path.basename())
if (isFile || isSymlink) {
Deno.renameSync(path.string, dest.string)
}
}

Deno.removeSync(lib64.string, { recursive: true })
Deno.symlinkSync("lib", lib64.string)
}

async function flatten_headers(pkg_prefix: Path) {
// if include/ contains exactly one subdirectory and no loose files, flatten it
// eg. include/foo/*.h → include/*.h with include/foo → symlink to .
const include = pkg_prefix.join("include").isDirectory()
if (!include) return

const entries: Path[] = []
const subdirs: Path[] = []

for await (const [path, { isDirectory }] of include.ls()) {
entries.push(path)
if (isDirectory) subdirs.push(path)
}

if (subdirs.length == 1 && entries.length == 1) {
const subdir = subdirs[0]
const name = subdir.basename()

// move all contents up
for await (const [path] of subdir.ls()) {
Deno.renameSync(path.string, include.join(path.basename()).string)
}

Deno.removeSync(subdir.string, { recursive: true })
Deno.symlinkSync(".", include.join(name).string)
console.log({ flattened_headers: name })
}
}
9 changes: 9 additions & 0 deletions share/toolchain/shim
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,17 @@ if [ "$(uname)" != Darwin ]; then
set -a
eval "$("$pkgx" +llvm.org)"

if printf "%s\n" "$@" | grep -qxF -- '-shared'; then
has_shared=1
fi

filtered_args=()
for arg in "$@"; do
# -shared and -pie conflict. libs aren't executables, so accept the -shared
if [ "$arg" = "-pie" ] && [ "$has_shared" = "1" ]; then
continue
fi

if [ "$arg" != -Werror ]; then
filtered_args+=("$arg")
fi
Expand Down
Loading