Skip to content

Commit 67f36c3

Browse files
committed
tighten up libtool fixup; add tests and skip keys
1 parent 5986a2b commit 67f36c3

File tree

3 files changed

+41
-8
lines changed

3 files changed

+41
-8
lines changed

.github/workflows/ci.cli.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ jobs:
2828
- pc-cmake.com
2929
- fix-machos.com
3030
- version-transformer.com
31+
- fixups.org
3132

3233
runs-on: ${{ matrix.platform.os }}
3334
container: ${{ matrix.platform.img }}

lib/porcelain/fix-up.ts

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,35 @@ const { host } = utils
55

66
export default async function finish(config: Config) {
77
const prefix = config.path.install
8-
await fix_rpaths(prefix, config.pkg, config.path.cache, config.deps.gas)
8+
const yml = await usePantry().project(config.pkg).yaml()
9+
const skip = yml.build.skip ?? []
10+
const skips = typeof skip === 'string' ? [skip] : skip
11+
12+
await fix_rpaths(prefix, config.pkg, config.path.cache, config.deps.gas, skips)
913
await fix_pc_files(prefix, config.path.build_install)
1014
await fix_cmake_files(prefix, config.path.build_install)
11-
await remove_la_files(prefix)
15+
if (!skips.includes('libtool-cleanup')) {
16+
await remove_la_files(prefix)
17+
} else {
18+
console.info(`skipping libtool cleanup for ${config.pkg.project}`)
19+
}
1220
if (host().platform == 'linux') {
1321
await consolidate_lib64(prefix)
1422
}
15-
await flatten_headers(prefix)
23+
if (!skips.includes('flatten-includes')) {
24+
await flatten_headers(prefix)
25+
} else {
26+
console.info(`skipping header flattening for ${config.pkg.project}`)
27+
}
1628
}
1729

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

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

4253
case 'linux': {
43-
if (yml.build.skip === 'fix-patchelf' || yml.build.skip?.includes('fix-patchelf')) {
54+
if (skips.includes('fix-patchelf')) {
4455
console.info(`skipping rpath fixes for ${pkg.project}`)
4556
break
4657
}
@@ -108,9 +119,11 @@ async function fix_cmake_files(pkg_prefix: Path, build_prefix: Path) {
108119

109120
async function remove_la_files(pkg_prefix: Path) {
110121
// libtool .la files contain hardcoded paths and cause more problems than they solve
122+
// only remove top-level lib/*.la — subdirectory .la files may be module descriptors
123+
// needed at runtime (eg. ImageMagick codec plugins)
111124
const lib = pkg_prefix.join("lib").isDirectory()
112125
if (!lib) return
113-
for await (const [path, { isFile }] of lib.walk()) {
126+
for await (const [path, { isFile }] of lib.ls()) {
114127
if (isFile && path.extname() == ".la") {
115128
console.log({ removing: path })
116129
Deno.removeSync(path.string)

projects/fixups.org/package.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
versions:
2+
- 1.0.0
3+
4+
build:
5+
# test header flattening
6+
- run: echo "// empty header" > fixups.h
7+
working-directory: "{{prefix}}/include/fixups"
8+
# test libtool sanitizer
9+
- run: echo '# empty libtool' > fixups.la
10+
working-directory: "{{prefix}}/lib"
11+
# but don't clean up non-libtool .la files...
12+
- run: echo '# non-libtool .la' > not-libtool.la
13+
working-directory: "{{prefix}}/lib/plugins/modules"
14+
15+
test:
16+
- test -f '{{prefix}}/include/fixups.h'
17+
- test -f '{{prefix}}/include/fixups/fixups.h'
18+
- test ! -f '{{prefix}}/lib/fixups.la'
19+
- test -f '{{prefix}}/lib/plugins/modules/not-libtool.la'

0 commit comments

Comments
 (0)