-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5cbdabe
commit 0a2ad4b
Showing
4 changed files
with
215 additions
and
200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
lib, | ||
stdenv, | ||
zig, | ||
runCommand, | ||
makeWrapper, | ||
}: | ||
let | ||
targetPrefix = lib.optionalString ( | ||
stdenv.hostPlatform != stdenv.targetPlatform | ||
) "${stdenv.targetPlatform.config}-"; | ||
in | ||
runCommand "zig-bintools-${zig.version}" | ||
{ | ||
pname = "zig-bintools"; | ||
inherit (zig) version meta; | ||
|
||
nativeBuildInputs = [ makeWrapper ]; | ||
|
||
passthru = { | ||
isZig = true; | ||
inherit targetPrefix; | ||
}; | ||
|
||
inherit zig; | ||
} | ||
'' | ||
mkdir -p $out/bin | ||
for tool in ar objcopy; do | ||
makeWrapper "$zig/bin/zig" "$out/bin/${targetPrefix}$tool" \ | ||
--add-flags "$tool" \ | ||
--run "export ZIG_GLOBAL_CACHE_DIR=\$(mktemp -d)" | ||
done | ||
'' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,37 @@ | ||
{ | ||
lib, | ||
wrapCCWith, | ||
wrapBintoolsWith, | ||
makeWrapper, | ||
stdenv, | ||
runCommand, | ||
stdenv, | ||
targetPackages, | ||
zig, | ||
stdenv, | ||
makeWrapper, | ||
}: | ||
wrapCCWith { | ||
cc = | ||
runCommand "zig-cc-${zig.version}" | ||
{ | ||
pname = "zig-cc"; | ||
inherit (zig) version meta; | ||
|
||
nativeBuildInputs = [ makeWrapper ]; | ||
|
||
passthru.isZig = true; | ||
inherit zig; | ||
} | ||
'' | ||
mkdir -p $out/bin | ||
for tool in cc c++; do | ||
makeWrapper "$zig/bin/zig" "$out/bin/$tool" \ | ||
--add-flags "$tool" \ | ||
--run "export ZIG_GLOBAL_CACHE_DIR=\$(mktemp -d)" | ||
done | ||
mv $out/bin/c++ $out/bin/clang++ | ||
mv $out/bin/cc $out/bin/clang | ||
''; | ||
|
||
bintools = | ||
let | ||
targetPrefix = lib.optionalString ( | ||
stdenv.hostPlatform != stdenv.targetPlatform | ||
) "${stdenv.targetPlatform.config}-"; | ||
in | ||
wrapBintoolsWith { | ||
bintools = | ||
runCommand "zig-bintools-${zig.version}" | ||
{ | ||
pname = "zig-bintools"; | ||
inherit (zig) version meta; | ||
|
||
nativeBuildInputs = [ makeWrapper ]; | ||
|
||
passthru = { | ||
isZig = true; | ||
inherit targetPrefix; | ||
}; | ||
|
||
inherit zig; | ||
} | ||
'' | ||
mkdir -p $out/bin | ||
for tool in ar objcopy; do | ||
makeWrapper "$zig/bin/zig" "$out/bin/${targetPrefix}-$tool" \ | ||
--add-flags "$tool" \ | ||
--run "export ZIG_GLOBAL_CACHE_DIR=\$(mktemp -d)" | ||
done | ||
''; | ||
let | ||
targetPrefix = lib.optionalString ( | ||
stdenv.hostPlatform != stdenv.targetPlatform | ||
) "${stdenv.targetPlatform.config}-"; | ||
in | ||
runCommand "zig-cc-${zig.version}" | ||
{ | ||
pname = "zig-cc"; | ||
inherit (zig) version meta; | ||
|
||
nativeBuildInputs = [ makeWrapper ]; | ||
|
||
passthru = { | ||
isZig = true; | ||
inherit targetPrefix; | ||
}; | ||
|
||
nixSupport.cc-cflags = | ||
[ | ||
"-target" | ||
"${stdenv.targetPlatform.parsed.cpu.name}-${stdenv.targetPlatform.parsed.kernel.name}-${stdenv.targetPlatform.parsed.abi.name}" | ||
] | ||
++ lib.optional ( | ||
stdenv.targetPlatform.isLinux && !(targetPackages.isStatic or false) | ||
) "-Wl,-dynamic-linker=${targetPackages.stdenv.cc.bintools.dynamicLinker}"; | ||
} | ||
inherit zig; | ||
} | ||
'' | ||
mkdir -p $out/bin | ||
for tool in cc c++; do | ||
makeWrapper "$zig/bin/zig" "$out/bin/${targetPrefix}$tool" \ | ||
--add-flags "$tool" \ | ||
--run "export ZIG_GLOBAL_CACHE_DIR=\$(mktemp -d)" | ||
done | ||
mv $out/bin/c++ $out/bin/clang++ | ||
mv $out/bin/cc $out/bin/clang | ||
'' |
Oops, something went wrong.