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
1 change: 1 addition & 0 deletions .github/workflows/ci.cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
- pc-cmake.com
- fix-machos.com
- version-transformer.com
- fixups.org

runs-on: ${{ matrix.platform.os }}
container: ${{ matrix.platform.img }}
Expand Down
29 changes: 21 additions & 8 deletions lib/porcelain/fix-up.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,35 @@ const { host } = utils

export default async function finish(config: Config) {
const prefix = config.path.install
await fix_rpaths(prefix, config.pkg, config.path.cache, config.deps.gas)
const yml = await usePantry().project(config.pkg).yaml()
const skip = yml.build.skip ?? []
const skips = typeof skip === 'string' ? [skip] : skip

await fix_rpaths(prefix, config.pkg, config.path.cache, config.deps.gas, skips)
await fix_pc_files(prefix, config.path.build_install)
await fix_cmake_files(prefix, config.path.build_install)
await remove_la_files(prefix)
if (!skips.includes('libtool-cleanup')) {
await remove_la_files(prefix)
} else {
console.info(`skipping libtool cleanup for ${config.pkg.project}`)
}
if (host().platform == 'linux') {
await consolidate_lib64(prefix)
}
await flatten_headers(prefix)
if (!skips.includes('flatten-includes')) {
await flatten_headers(prefix)
} else {
console.info(`skipping header flattening for ${config.pkg.project}`)
}
}

//////////////////////////////////////////////////////////////////////////////////////
async function fix_rpaths(pkg_prefix: Path, pkg: Package, cache: Path, deps: Installation[]) {
async function fix_rpaths(pkg_prefix: Path, pkg: Package, cache: Path, deps: Installation[], skips: string[]) {
const bindir = new Path(new URL(import.meta.url).pathname).join("../../bin")
const yml = await usePantry().project(pkg).yaml()

switch (host().platform) {
case 'darwin': {
if (yml.build.skip === 'fix-machos' || yml.build.skip?.includes('fix-machos')) {
if (skips.includes('fix-machos')) {
console.info(`skipping rpath fixes for ${pkg.project}`)
break
}
Expand All @@ -40,7 +51,7 @@ async function fix_rpaths(pkg_prefix: Path, pkg: Package, cache: Path, deps: Ins
} break

case 'linux': {
if (yml.build.skip === 'fix-patchelf' || yml.build.skip?.includes('fix-patchelf')) {
if (skips.includes('fix-patchelf')) {
console.info(`skipping rpath fixes for ${pkg.project}`)
break
}
Expand Down Expand Up @@ -108,9 +119,11 @@ 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
// only remove top-level lib/*.la — subdirectory .la files may be module descriptors
// needed at runtime (eg. ImageMagick codec plugins)
const lib = pkg_prefix.join("lib").isDirectory()
if (!lib) return
for await (const [path, { isFile }] of lib.walk()) {
for await (const [path, { isFile }] of lib.ls()) {
if (isFile && path.extname() == ".la") {
console.log({ removing: path })
Deno.removeSync(path.string)
Expand Down
19 changes: 19 additions & 0 deletions projects/fixups.org/package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
versions:
- 1.0.0

build:
# test header flattening
- run: echo "// empty header" > fixups.h
working-directory: "{{prefix}}/include/fixups"
# test libtool sanitizer
- run: echo '# empty libtool' > fixups.la
working-directory: "{{prefix}}/lib"
# but don't clean up non-libtool .la files...
- run: echo '# non-libtool .la' > not-libtool.la
working-directory: "{{prefix}}/lib/plugins/modules"

test:
- test -f '{{prefix}}/include/fixups.h'
- test -f '{{prefix}}/include/fixups/fixups.h'
- test ! -f '{{prefix}}/lib/fixups.la'
- test -f '{{prefix}}/lib/plugins/modules/not-libtool.la'
Loading