about summary refs log tree commit diff
path: root/pkgs/build-support
diff options
context:
space:
mode:
authorgithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>2021-01-12 18:47:24 +0000
committerGitHub <noreply@github.com>2021-01-12 18:47:24 +0000
commitf47a1ddfe402ef8a687ddfb0e36ff9f4fe790bbd (patch)
tree2ec2293d4e982b023fa909844233d004355c777b /pkgs/build-support
parentf1bb6c74f98333b035feb6cf843916db59328aad (diff)
parente350b35cceb44bb17a44ac3f5a9d5704329214f6 (diff)
downloadnixlib-f47a1ddfe402ef8a687ddfb0e36ff9f4fe790bbd.tar
nixlib-f47a1ddfe402ef8a687ddfb0e36ff9f4fe790bbd.tar.gz
nixlib-f47a1ddfe402ef8a687ddfb0e36ff9f4fe790bbd.tar.bz2
nixlib-f47a1ddfe402ef8a687ddfb0e36ff9f4fe790bbd.tar.lz
nixlib-f47a1ddfe402ef8a687ddfb0e36ff9f4fe790bbd.tar.xz
nixlib-f47a1ddfe402ef8a687ddfb0e36ff9f4fe790bbd.tar.zst
nixlib-f47a1ddfe402ef8a687ddfb0e36ff9f4fe790bbd.zip
Merge master into staging-next
Diffstat (limited to 'pkgs/build-support')
-rw-r--r--pkgs/build-support/kernel/modules-closure.sh3
-rw-r--r--pkgs/build-support/writers/default.nix32
-rw-r--r--pkgs/build-support/writers/test.nix6
3 files changed, 35 insertions, 6 deletions
diff --git a/pkgs/build-support/kernel/modules-closure.sh b/pkgs/build-support/kernel/modules-closure.sh
index 3f895d9cfed9..3b3a38ea1d33 100644
--- a/pkgs/build-support/kernel/modules-closure.sh
+++ b/pkgs/build-support/kernel/modules-closure.sh
@@ -81,7 +81,8 @@ for module in $(cat closure); do
     for i in $(modinfo -b $kernel --set-version "$version" -F firmware $module | grep -v '^name:'); do
         mkdir -p "$out/lib/firmware/$(dirname "$i")"
         echo "firmware for $module: $i"
-        cp "$firmware/lib/firmware/$i" "$out/lib/firmware/$i" 2>/dev/null || if test -z "$allowMissing"; then exit 1; fi
+        cp "$firmware/lib/firmware/$i" "$out/lib/firmware/$i" 2>/dev/null \
+            || echo "WARNING: missing firmware $i for module $module"
     done
 done
 
diff --git a/pkgs/build-support/writers/default.nix b/pkgs/build-support/writers/default.nix
index 9c709921d210..89edbd513d50 100644
--- a/pkgs/build-support/writers/default.nix
+++ b/pkgs/build-support/writers/default.nix
@@ -63,7 +63,7 @@ rec {
   #
   # Examples:
   #   writeSimpleC = makeBinWriter { compileScript = name: "gcc -o $out $contentPath"; }
-  makeBinWriter = { compileScript }: nameOrPath: content:
+  makeBinWriter = { compileScript, strip ? true }: nameOrPath: content:
     assert lib.or (types.path.check nameOrPath) (builtins.match "([0-9A-Za-z._])[0-9A-Za-z._-]*" nameOrPath != null);
     assert lib.or (types.path.check content) (types.str.check content);
     let
@@ -76,6 +76,8 @@ rec {
       contentPath = content;
     }) ''
       ${compileScript}
+      ${lib.optionalString strip
+         "${pkgs.binutils-unwrapped}/bin/strip --strip-unneeded $out"}
       ${optionalString (types.path.check nameOrPath) ''
         mv $out tmp
         mkdir -p $out/$(dirname "${nameOrPath}")
@@ -109,7 +111,10 @@ rec {
   #        return 0;
   #      }
   #    ''
-  writeC = name: { libraries ? [] }:
+  writeC = name: {
+    libraries ? [],
+    strip ? true
+  }:
     makeBinWriter {
       compileScript = ''
         PATH=${makeBinPath [
@@ -131,8 +136,8 @@ rec {
             -Wall \
             -x c \
             "$contentPath"
-        strip --strip-unneeded "$out"
       '';
+      inherit strip;
     } name;
 
   # writeCBin takes the same arguments as writeC but outputs a directory (like writeScriptBin)
@@ -165,21 +170,38 @@ rec {
   writeHaskell = name: {
     libraries ? [],
     ghc ? pkgs.ghc,
-    ghcArgs ? []
+    ghcArgs ? [],
+    strip ? true
   }:
     makeBinWriter {
       compileScript = ''
         cp $contentPath tmp.hs
         ${ghc.withPackages (_: libraries )}/bin/ghc ${lib.escapeShellArgs ghcArgs} tmp.hs
         mv tmp $out
-        ${pkgs.binutils-unwrapped}/bin/strip --strip-unneeded "$out"
       '';
+      inherit strip;
     } name;
 
   # writeHaskellBin takes the same arguments as writeHaskell but outputs a directory (like writeScriptBin)
   writeHaskellBin = name:
     writeHaskell "/bin/${name}";
 
+  writeRust = name: {
+      rustc ? pkgs.rustc,
+      rustcArgs ? [],
+      strip ? true
+  }:
+    makeBinWriter {
+      compileScript = ''
+        cp "$contentPath" tmp.rs
+        PATH=${makeBinPath [pkgs.gcc]} ${lib.getBin rustc}/bin/rustc ${lib.escapeShellArgs rustcArgs} -o "$out" tmp.rs
+      '';
+      inherit strip;
+    } name;
+
+  writeRustBin = name:
+    writeRust "/bin/${name}";
+
   # writeJS takes a name an attributeset with libraries and some JavaScript sourcecode and
   # returns an executable
   #
diff --git a/pkgs/build-support/writers/test.nix b/pkgs/build-support/writers/test.nix
index d284bda43d05..0febad2929a0 100644
--- a/pkgs/build-support/writers/test.nix
+++ b/pkgs/build-support/writers/test.nix
@@ -31,6 +31,12 @@ let
      test '~' = '~' && echo 'success'
     '';
 
+    rust = writeRustBin "test_writers" {} ''
+      fn main(){
+        println!("success")
+      }
+    '';
+
     haskell = writeHaskellBin "test_writers" { libraries = [ haskellPackages.acme-default ]; } ''
       import Data.Default