-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: full nix refactor -- all targets!
now this repo can, through Nix, cross-compile to all major targets. this was only tested in a nix-darwin environment, but cross-compilation to all other targets (except MacOS, because... Apple) should work on NixOS and such.
- Loading branch information
Showing
6 changed files
with
153 additions
and
64 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 |
---|---|---|
@@ -1,7 +1,8 @@ | ||
/target | ||
target/ | ||
.DS_Store | ||
test*.db* | ||
*.o | ||
local.db | ||
example | ||
result | ||
.direnv/ |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,43 @@ | ||
{ lib | ||
, stdenv | ||
, craneLib | ||
, pkg-config | ||
, cmake | ||
, apple-sdk | ||
}: | ||
let target = lib.strings.toUpper (builtins.replaceStrings [ "-" ] [ "_" ] stdenv.targetPlatform.config); | ||
in | ||
craneLib.buildPackage { | ||
src = lib.fileset.toSource rec { | ||
root = ./.; | ||
fileset = lib.fileset.unions [ | ||
(craneLib.fileset.commonCargoSources root) | ||
(lib.fileset.fileFilter (file: file.hasExt "h") root) | ||
]; | ||
}; | ||
|
||
strictDeps = true; | ||
doCheck = false; | ||
|
||
nativeBuildInputs = [ | ||
pkg-config | ||
cmake | ||
stdenv.cc | ||
]; | ||
|
||
nativeInput = lib.optionals stdenv.isDarwin [ apple-sdk ]; | ||
|
||
CARGO_BUILD_TARGET = stdenv.targetPlatform.config; | ||
|
||
"CARGO_TARGET_${target}_LINKER" = "${stdenv.cc.targetPrefix}cc"; | ||
|
||
RUSTFLAGS = "-C target-feature=-crt-static"; | ||
|
||
HOST_CC = "${stdenv.cc.nativePrefix}cc"; | ||
TARGET_CC = "${stdenv.cc.targetPrefix}cc"; | ||
|
||
BINDGEN_EXTRA_CLANG_ARGS = | ||
if stdenv.isDarwin | ||
then "-isystem ${apple-sdk.sdkroot}/usr/include" | ||
else "-isystem ${stdenv.cc.libc.dev}/include"; | ||
} |
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,8 +1,14 @@ | ||
[toolchain] | ||
channel = "stable" | ||
targets = [ | ||
"aarch64-apple-darwin", | ||
"x86_64-apple-darwin", | ||
"aarch64-apple-darwin", | ||
|
||
"x86_64-unknown-linux-gnu", | ||
"aarch64-unknown-linux-gnu", | ||
|
||
"x86_64-unknown-linux-musl", | ||
"x86_64-pc-windows-gnullvm", | ||
"aarch64-unknown-linux-musl", | ||
|
||
"x86_64-pc-windows-gnu", | ||
] |