Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[std] Fix some issues with libraries in std.toolchain() #118

Merged
merged 3 commits into from
Oct 6, 2024
Merged
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
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();
}