boringssl: build shared library on non-static stdenv
This commit is contained in:
@@ -6,6 +6,8 @@
|
||||
ninja,
|
||||
perl,
|
||||
gitUpdater,
|
||||
|
||||
withShared ? !stdenv.hostPlatform.isStatic,
|
||||
}:
|
||||
|
||||
# reference: https://boringssl.googlesource.com/boringssl/+/refs/tags/0.20250818.0/BUILDING.md
|
||||
@@ -30,6 +32,10 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
perl
|
||||
];
|
||||
|
||||
cmakeFlags = [
|
||||
(lib.cmakeBool "BUILD_SHARED_LIBS" withShared)
|
||||
];
|
||||
|
||||
env.NIX_CFLAGS_COMPILE = toString (
|
||||
lib.optionals stdenv.cc.isGNU [
|
||||
# Needed with GCC 12 but breaks on darwin (with clang)
|
||||
@@ -47,7 +53,10 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
"dev"
|
||||
];
|
||||
|
||||
passthru.updateScript = gitUpdater { };
|
||||
passthru = {
|
||||
updateScript = gitUpdater { };
|
||||
isShared = withShared;
|
||||
};
|
||||
|
||||
meta = {
|
||||
description = "Free TLS/SSL implementation";
|
||||
|
||||
@@ -21,6 +21,12 @@ rustPlatform.buildRustPackage (finalAttrs: {
|
||||
hash = "sha256-xffBXvq1ikesIjw6cXfphnTIiyuMiUcY8h0pzSgfD8U=";
|
||||
};
|
||||
|
||||
postPatch = lib.optionalString boringssl.passthru.isShared ''
|
||||
substituteInPlace $cargoDepsCopy/boring-sys-*/build/main.rs \
|
||||
--replace-fail "cargo:rustc-link-lib=static=crypto" "cargo:rustc-link-lib=dylib=crypto" \
|
||||
--replace-fail "cargo:rustc-link-lib=static=ssl" "cargo:rustc-link-lib=dylib=ssl"
|
||||
'';
|
||||
|
||||
nativeBuildInputs = [
|
||||
protobuf
|
||||
rustPlatform.bindgenHook
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
{
|
||||
lib,
|
||||
stdenv,
|
||||
rustPlatform,
|
||||
fetchNpmDeps,
|
||||
@@ -60,6 +61,11 @@ rustPlatform.buildRustPackage (finalAttrs: {
|
||||
--replace-fail "'prebuilds'" "'$out/lib'" \
|
||||
--replace-fail "objcopy = shutil.which('%s-linux-gnu-objcopy' % cargo_target.split('-')[0]) or 'objcopy'" \
|
||||
"objcopy = os.getenv('OBJCOPY', 'objcopy')"
|
||||
''
|
||||
+ lib.optionalString boringssl.passthru.isShared ''
|
||||
substituteInPlace $cargoDepsCopy/*/boring-sys-*/build/main.rs \
|
||||
--replace-fail "cargo:rustc-link-lib=static=crypto" "cargo:rustc-link-lib=dylib=crypto" \
|
||||
--replace-fail "cargo:rustc-link-lib=static=ssl" "cargo:rustc-link-lib=dylib=ssl"
|
||||
'';
|
||||
|
||||
buildPhase = ''
|
||||
|
||||
Reference in New Issue
Block a user