Carnix 0.7
This commit is contained in:
parent
cee2c50748
commit
29a3059746
@ -47,7 +47,7 @@ let makeDeps = dependencies:
|
||||
'';
|
||||
|
||||
configureCrate =
|
||||
{ crateName, crateVersion, crateAuthors, build, libName, crateFeatures, colors, libPath, release, buildDependencies, completeDeps, completeBuildDeps, verbose, dependencies }:
|
||||
{ crateName, crateVersion, crateAuthors, build, libName, crateFeatures, colors, libPath, release, buildDependencies, completeDeps, completeBuildDeps, verbose, dependencies, workspace_member }:
|
||||
let version_ = lib.splitString "-" crateVersion;
|
||||
versionPre = if lib.tail version_ == [] then "" else builtins.elemAt version_ 1;
|
||||
version = lib.splitString "." (lib.head version_);
|
||||
@ -58,6 +58,7 @@ let makeDeps = dependencies:
|
||||
completeDepsDir = lib.concatStringsSep " " completeDeps;
|
||||
completeBuildDepsDir = lib.concatStringsSep " " completeBuildDeps;
|
||||
in ''
|
||||
cd ${workspace_member}
|
||||
runHook preConfigure
|
||||
${echo_build_heading colors}
|
||||
${noisily colors verbose}
|
||||
@ -146,10 +147,15 @@ let makeDeps = dependencies:
|
||||
mkdir -p $OUT_DIR
|
||||
target/build/${crateName}/build_script_build > target/build/${crateName}.opt
|
||||
set +e
|
||||
EXTRA_BUILD=$(sed -n "s/^cargo:rustc-flags=\(.*\)/\1/p" target/build/${crateName}.opt | tr '\n' ' ')
|
||||
EXTRA_BUILD=$(sed -n "s/^cargo:rustc-flags=\(.*\)/\1/p" target/build/${crateName}.opt | tr '\n' ' ' | sort -u)
|
||||
EXTRA_FEATURES=$(sed -n "s/^cargo:rustc-cfg=\(.*\)/--cfg \1/p" target/build/${crateName}.opt | tr '\n' ' ')
|
||||
EXTRA_LINK=$(sed -n "s/^cargo:rustc-link-lib=\(.*\)/\1/p" target/build/${crateName}.opt | tr '\n' ' ')
|
||||
EXTRA_LINK_SEARCH=$(sed -n "s/^cargo:rustc-link-search=\(.*\)/\1/p" target/build/${crateName}.opt | tr '\n' ' ')
|
||||
EXTRA_LINK=$(sed -n "s/^cargo:rustc-link-lib=\(.*\)/\1/p" target/build/${crateName}.opt | tr '\n' ' ' | sort -u)
|
||||
EXTRA_LINK_SEARCH=$(sed -n "s/^cargo:rustc-link-search=\(.*\)/\1/p" target/build/${crateName}.opt | tr '\n' ' ' | sort -u)
|
||||
|
||||
for env in $(sed -n "s/^cargo:rustc-env=\(.*\)/\1/p" target/build/${crateName}.opt); do
|
||||
export $env
|
||||
done
|
||||
|
||||
CRATENAME=$(echo ${crateName} | sed -e "s/\(.*\)-sys$/\U\1/")
|
||||
grep -P "^cargo:(?!(rustc-|warning=|rerun-if-changed=|rerun-if-env-changed))" target/build/${crateName}.opt \
|
||||
| sed -e "s/cargo:\([^=]*\)=\(.*\)/export DEP_$(echo $CRATENAME)_\U\1\E=\2/" > target/env
|
||||
@ -171,8 +177,7 @@ let makeDeps = dependencies:
|
||||
dependencies, completeDeps, completeBuildDeps,
|
||||
crateFeatures, libName, build, release, libPath,
|
||||
crateType, metadata, crateBin, finalBins,
|
||||
extraRustcOpts,
|
||||
verbose, colors }:
|
||||
extraRustcOpts, verbose, colors }:
|
||||
|
||||
let depsDir = lib.concatStringsSep " " dependencies;
|
||||
completeDepsDir = lib.concatStringsSep " " completeDeps;
|
||||
@ -221,12 +226,12 @@ let makeDeps = dependencies:
|
||||
build_bin() {
|
||||
crate_name=$1
|
||||
crate_name_=$(echo $crate_name | sed -e "s/-/_/g")
|
||||
main_file=""
|
||||
if [[ ! -z $2 ]]; then
|
||||
main_file=""
|
||||
if [[ ! -z $2 ]]; then
|
||||
main_file=$2
|
||||
fi
|
||||
echo_build_heading $@
|
||||
noisily rustc --crate-name $crate_name_ $main_file --crate-type bin ${rustcOpts}\
|
||||
fi
|
||||
echo_build_heading $@
|
||||
noisily rustc --crate-name $crate_name_ $main_file --crate-type bin ${rustcOpts}\
|
||||
${crateFeatures} --out-dir target/bin --emit=dep-info,link -L dependency=target/deps \
|
||||
$LINK ${deps}$EXTRA_LIB --cap-lints allow \
|
||||
$BUILD_OUT_DIR $EXTRA_BUILD $EXTRA_FEATURES --color ${colors}
|
||||
@ -374,7 +379,7 @@ stdenv.mkDerivation (rec {
|
||||
);
|
||||
|
||||
crateFeatures = if crate ? features then
|
||||
lib.concatMapStringsSep " " (f: "--cfg feature=\\\"${f}\\\"") (crate.features ++ features)
|
||||
lib.concatMapStringsSep " " (f: "--cfg feature=\\\"${f}\\\"") (crate.features ++ features) #"
|
||||
else "";
|
||||
|
||||
libName = if crate ? libName then crate.libName else crate.crateName;
|
||||
@ -407,24 +412,26 @@ stdenv.mkDerivation (rec {
|
||||
) "" crate.crateBin
|
||||
else "";
|
||||
|
||||
build = if crate ? build then crate.build else "";
|
||||
build = crate.build or "";
|
||||
workspace_member = crate.workspace_member or ".";
|
||||
crateVersion = crate.version;
|
||||
crateAuthors = if crate ? authors && lib.isList crate.authors then crate.authors else [];
|
||||
crateType =
|
||||
if lib.attrByPath ["procMacro"] false crate then "proc-macro" else
|
||||
if lib.attrByPath ["plugin"] false crate then "dylib" else
|
||||
if crate ? type then crate.type else "lib";
|
||||
(crate.type or "lib");
|
||||
colors = lib.attrByPath [ "colors" ] "always" crate;
|
||||
configurePhase = configureCrate {
|
||||
inherit crateName dependencies buildDependencies completeDeps completeBuildDeps
|
||||
crateFeatures libName build release libPath crateVersion
|
||||
crateFeatures libName build workspace_member release libPath crateVersion
|
||||
crateAuthors verbose colors;
|
||||
};
|
||||
extraRustcOpts = if crate ? extraRustcOpts then crate.extraRustcOpts else [];
|
||||
buildPhase = buildCrate {
|
||||
inherit crateName dependencies completeDeps completeBuildDeps
|
||||
crateFeatures libName build release libPath crateType crateVersion
|
||||
crateAuthors metadata crateBin finalBins verbose colors extraRustcOpts;
|
||||
crateFeatures libName build release libPath crateType
|
||||
crateVersion crateAuthors metadata crateBin finalBins verbose colors
|
||||
extraRustcOpts;
|
||||
};
|
||||
installPhase = installCrate crateName metadata;
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user