Skip to content

Commit

Permalink
[std] Fix some issues with libraries in std.toolchain() (#118)
Browse files Browse the repository at this point in the history
* Fix typo in `$PERL5LIB` env var in `std.toolchain()`

* Fix broken lib symlinks in `std.toolchain()`

* Patch pkg-config files to use relative paths in `std.toolchain()`
  • Loading branch information
kylewlacy authored Oct 6, 2024
1 parent 0ce7123 commit 344ba81
Showing 1 changed file with 52 additions and 1 deletion.
53 changes: 52 additions & 1 deletion packages/std/toolchain/native/index.bri
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,28 @@ export const toolchain = std.memo(
// Add a symlink for the C compiler
toolchain = toolchain.insert("bin/cc", std.symlink({ target: "gcc" }));

// Fix broken library symlinks
toolchain = toolchain.insert(
"lib/libuuid.so",
std.symlink({ target: "libuuid.so.1" }),
);
toolchain = toolchain.insert(
"lib/libblkid.so",
std.symlink({ target: "libblk.id.so.1" }),
);
toolchain = toolchain.insert(
"lib/libsmartcols.so",
std.symlink({ target: "libsmartcols.so.1" }),
);
toolchain = toolchain.insert(
"lib/libfdisk.so",
std.symlink({ target: "libfdisk.so.1" }),
);
toolchain = toolchain.insert(
"lib/libmount.so",
std.symlink({ target: "libmount.so.1" }),
);

// Add a symlink that libtool needs
toolchain = toolchain.insert(
"share/libtool/m4",
Expand All @@ -204,7 +226,7 @@ export const toolchain = std.memo(

// Perl library paths
PERL5LIB: {
append: [{ path: "share/autconf" }, { path: "share/automake-1.16" }],
append: [{ path: "share/autoconf" }, { path: "share/automake-1.16" }],
},

// pkg-config search paths
Expand Down Expand Up @@ -261,6 +283,8 @@ export const toolchain = std.memo(

toolchain = fixShebangs(toolchain);

toolchain = makePkgConfigPathsRelative(toolchain);

toolchain = std.sync(toolchain);

return toolchain;
Expand Down Expand Up @@ -350,3 +374,30 @@ function fixShebangs(
})
.toDirectory();
}

function makePkgConfigPathsRelative(
recipe: std.AsyncRecipe<std.Directory>,
): std.Recipe<std.Directory> {
// Replaces things that look like absolute paths in pkg-config files with
// relative paths (using the `${pcfiledir}` variable)
return std
.process({
command: std.tpl`${stage2()}/bin/bash`,
args: [
"-c",
std.indoc`
set -euo pipefail
find "$BRIOCHE_OUTPUT"/lib/pkgconfig -name '*.pc' -type f -print0 \
| while IFS= read -r -d $'\\0' file; do
sed -i 's|=/|=\${pcfiledir}/../../|' "$file"
done
`,
],
env: {
PATH: std.tpl`${stage2()}/bin`,
},
outputScaffold: recipe,
})
.toDirectory();
}

0 comments on commit 344ba81

Please sign in to comment.