Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 1 addition & 13 deletions pkgs/by-name/hp/hplip/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,6 @@ let

in

assert
withPlugin
->
builtins.elem hplipArch pluginArches
|| throw "HPLIP plugin not supported on ${stdenv.hostPlatform.system}";

python3Packages.buildPythonApplication {
inherit pname version;
format = "other";
Expand Down Expand Up @@ -361,13 +355,7 @@ python3Packages.buildPythonApplication {
bsd2
gpl2Plus
];
platforms = [
"i686-linux"
"x86_64-linux"
"armv6l-linux"
"armv7l-linux"
"aarch64-linux"
];
platforms = lib.attrNames hplipPlatforms;
maintainers = with maintainers; [ ttuegel ];
};
}
239 changes: 124 additions & 115 deletions pkgs/development/androidndk-pkgs/androidndk-pkgs.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
config,
lib,
stdenv,
makeWrapper,
Expand All @@ -21,7 +22,7 @@ let
# some builds need that clarity.
#
ndkBuildInfoFun =
{ config, ... }:
fallback:
{
x86_64-apple-darwin = {
double = "darwin-x86_64";
Expand All @@ -30,10 +31,10 @@ let
double = "linux-x86_64";
};
}
.${config} or (throw "Android NDK doesn't support building on ${config}, as far as we know");
.${stdenv.buildPlatform.config} or fallback;

ndkTargetInfoFun =
{ config, ... }:
fallback:
{
i686-unknown-linux-android = {
triple = "i686-linux-android";
Expand All @@ -52,10 +53,14 @@ let
triple = "aarch64-linux-android";
};
}
.${config} or (throw "Android NDK doesn't support targetting ${config}, as far as we know");
.${stdenv.targetPlatform.config} or fallback;

buildInfo = ndkBuildInfoFun stdenv.buildPlatform;
targetInfo = ndkTargetInfoFun stdenv.targetPlatform;
buildInfo = ndkBuildInfoFun (
throw "Android NDK doesn't support building on ${stdenv.buildPlatform.config}, as far as we know"
);
targetInfo = ndkTargetInfoFun (
throw "Android NDK doesn't support targetting ${stdenv.targetPlatform.config}, as far as we know"
);

androidSdkVersion =
if
Expand All @@ -74,119 +79,123 @@ let
);
in

lib.recurseIntoAttrs rec {
# Misc tools
binaries = stdenv.mkDerivation {
pname = "${targetPrefix}ndk-toolchain";
inherit (androidndk) version;
nativeBuildInputs = [
makeWrapper
autoPatchelfHook
];
propagatedBuildInputs = [ androidndk ];
passthru = {
inherit targetPrefix;
isClang = true; # clang based cc, but bintools ld
inherit (llvmPackages.clang.cc) hardeningUnsupportedFlagsByTargetPlatform;
if !config.allowAliases && (ndkBuildInfoFun null == null || ndkTargetInfoFun null == null) then
# Don't throw without aliases to not break CI.
null
else
lib.recurseIntoAttrs rec {
# Misc tools
binaries = stdenv.mkDerivation {
pname = "${targetPrefix}ndk-toolchain";
inherit (androidndk) version;
nativeBuildInputs = [
makeWrapper
autoPatchelfHook
];
propagatedBuildInputs = [ androidndk ];
passthru = {
inherit targetPrefix;
isClang = true; # clang based cc, but bintools ld
inherit (llvmPackages.clang.cc) hardeningUnsupportedFlagsByTargetPlatform;
};
dontUnpack = true;
dontBuild = true;
dontStrip = true;
dontConfigure = true;
dontPatch = true;
autoPatchelfIgnoreMissingDeps = true;
installPhase = ''
# https://developer.android.com/ndk/guides/other_build_systems
mkdir -p $out
cp -r ${androidndk}/libexec/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/${buildInfo.double} $out/toolchain
find $out/toolchain -type d -exec chmod 777 {} \;

if [ ! -d $out/toolchain/sysroot/usr/lib/${targetInfo.triple}/${androidSdkVersion} ]; then
echo "NDK does not contain libraries for SDK version ${androidSdkVersion}";
exit 1
fi

ln -vfs $out/toolchain/sysroot/usr/lib $out/lib
ln -s $out/toolchain/sysroot/usr/lib/${targetInfo.triple}/*.so $out/lib/
ln -s $out/toolchain/sysroot/usr/lib/${targetInfo.triple}/*.a $out/lib/
chmod +w $out/lib/*
ln -s $out/toolchain/sysroot/usr/lib/${targetInfo.triple}/${androidSdkVersion}/*.so $out/lib/
ln -s $out/toolchain/sysroot/usr/lib/${targetInfo.triple}/${androidSdkVersion}/*.o $out/lib/

echo "INPUT(-lc++_static)" > $out/lib/libc++.a

ln -s $out/toolchain/bin $out/bin
ln -s $out/toolchain/${targetInfo.triple}/bin/* $out/bin/
for f in $out/bin/${targetInfo.triple}-*; do
ln -s $f ''${f/${targetInfo.triple}-/${targetPrefix}}
done
for f in $(find $out/toolchain -type d -name ${targetInfo.triple}); do
ln -s $f ''${f/${targetInfo.triple}/${targetPrefix}}
done

rm -f $out/bin/${targetPrefix}ld
ln -s $out/bin/lld $out/bin/${targetPrefix}ld

(cd $out/bin;
for tool in llvm-*; do
ln -sf $tool ${targetPrefix}$(echo $tool | sed 's/llvm-//')
ln -sf $tool $(echo $tool | sed 's/llvm-//')
done)

ln -sf $out/bin/yasm $out/bin/${targetPrefix}as
ln -sf $out/bin/yasm $out/bin/as

patchShebangs $out/bin
'';
meta = {
description = "The Android NDK toolchain, tuned for other platforms";
license = with lib.licenses; [ unfree ];
teams = [ lib.teams.android ];
};
};
dontUnpack = true;
dontBuild = true;
dontStrip = true;
dontConfigure = true;
dontPatch = true;
autoPatchelfIgnoreMissingDeps = true;
installPhase = ''
# https://developer.android.com/ndk/guides/other_build_systems
mkdir -p $out
cp -r ${androidndk}/libexec/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/${buildInfo.double} $out/toolchain
find $out/toolchain -type d -exec chmod 777 {} \;

if [ ! -d $out/toolchain/sysroot/usr/lib/${targetInfo.triple}/${androidSdkVersion} ]; then
echo "NDK does not contain libraries for SDK version ${androidSdkVersion}";
exit 1
fi

ln -vfs $out/toolchain/sysroot/usr/lib $out/lib
ln -s $out/toolchain/sysroot/usr/lib/${targetInfo.triple}/*.so $out/lib/
ln -s $out/toolchain/sysroot/usr/lib/${targetInfo.triple}/*.a $out/lib/
chmod +w $out/lib/*
ln -s $out/toolchain/sysroot/usr/lib/${targetInfo.triple}/${androidSdkVersion}/*.so $out/lib/
ln -s $out/toolchain/sysroot/usr/lib/${targetInfo.triple}/${androidSdkVersion}/*.o $out/lib/

echo "INPUT(-lc++_static)" > $out/lib/libc++.a

ln -s $out/toolchain/bin $out/bin
ln -s $out/toolchain/${targetInfo.triple}/bin/* $out/bin/
for f in $out/bin/${targetInfo.triple}-*; do
ln -s $f ''${f/${targetInfo.triple}-/${targetPrefix}}
done
for f in $(find $out/toolchain -type d -name ${targetInfo.triple}); do
ln -s $f ''${f/${targetInfo.triple}/${targetPrefix}}
done

rm -f $out/bin/${targetPrefix}ld
ln -s $out/bin/lld $out/bin/${targetPrefix}ld

(cd $out/bin;
for tool in llvm-*; do
ln -sf $tool ${targetPrefix}$(echo $tool | sed 's/llvm-//')
ln -sf $tool $(echo $tool | sed 's/llvm-//')
done)

ln -sf $out/bin/yasm $out/bin/${targetPrefix}as
ln -sf $out/bin/yasm $out/bin/as

patchShebangs $out/bin
'';
meta = {
description = "The Android NDK toolchain, tuned for other platforms";
license = with lib.licenses; [ unfree ];
teams = [ lib.teams.android ];
binutils = wrapBintoolsWith {
bintools = binaries;
libc = targetAndroidndkPkgs.libraries;
};
};

binutils = wrapBintoolsWith {
bintools = binaries;
libc = targetAndroidndkPkgs.libraries;
};

clang = wrapCCWith {
cc = binaries // {
# for packages expecting libcompiler-rt, etc. to come from here (stdenv.cc.cc.lib)
lib = targetAndroidndkPkgs.libraries;
clang = wrapCCWith {
cc = binaries // {
# for packages expecting libcompiler-rt, etc. to come from here (stdenv.cc.cc.lib)
lib = targetAndroidndkPkgs.libraries;
};
bintools = binutils;
libc = targetAndroidndkPkgs.libraries;
extraBuildCommands = ''
echo "-D__ANDROID_API__=${stdenv.targetPlatform.androidSdkVersion}" >> $out/nix-support/cc-cflags
# Android needs executables linked with -pie since version 5.0
# Use -fPIC for compilation, and link with -pie if no -shared flag used in ldflags
echo "-target ${targetInfo.triple} -fPIC" >> $out/nix-support/cc-cflags
echo "-z,noexecstack -z,relro -z,now -z,muldefs" >> $out/nix-support/cc-ldflags
echo 'expandResponseParams "$@"' >> $out/nix-support/add-flags.sh
echo 'if [[ ! (" ''${params[@]} " =~ " -shared ") && ! (" ''${params[@]} " =~ " -no-pie ") ]]; then NIX_LDFLAGS_${suffixSalt}+=" -pie"; fi' >> $out/nix-support/add-flags.sh
echo "-Xclang -mnoexecstack" >> $out/nix-support/cc-cxxflags
if [ ${targetInfo.triple} == arm-linux-androideabi ]; then
# https://android.googlesource.com/platform/external/android-cmake/+/refs/heads/cmake-master-dev/android.toolchain.cmake
echo "--fix-cortex-a8" >> $out/nix-support/cc-ldflags
fi
'';
};
bintools = binutils;
libc = targetAndroidndkPkgs.libraries;
extraBuildCommands = ''
echo "-D__ANDROID_API__=${stdenv.targetPlatform.androidSdkVersion}" >> $out/nix-support/cc-cflags
# Android needs executables linked with -pie since version 5.0
# Use -fPIC for compilation, and link with -pie if no -shared flag used in ldflags
echo "-target ${targetInfo.triple} -fPIC" >> $out/nix-support/cc-cflags
echo "-z,noexecstack -z,relro -z,now -z,muldefs" >> $out/nix-support/cc-ldflags
echo 'expandResponseParams "$@"' >> $out/nix-support/add-flags.sh
echo 'if [[ ! (" ''${params[@]} " =~ " -shared ") && ! (" ''${params[@]} " =~ " -no-pie ") ]]; then NIX_LDFLAGS_${suffixSalt}+=" -pie"; fi' >> $out/nix-support/add-flags.sh
echo "-Xclang -mnoexecstack" >> $out/nix-support/cc-cxxflags
if [ ${targetInfo.triple} == arm-linux-androideabi ]; then
# https://android.googlesource.com/platform/external/android-cmake/+/refs/heads/cmake-master-dev/android.toolchain.cmake
echo "--fix-cortex-a8" >> $out/nix-support/cc-ldflags

# Bionic lib C and other libraries.
#
# We use androidndk from the previous stage, else we waste time or get cycles
# cross-compiling packages to wrap incorrectly wrap binaries we don't include
# anyways.
libraries = runCommand "bionic-prebuilt" { } ''
lpath=${buildAndroidndk}/libexec/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/${buildInfo.double}/sysroot/usr/lib/${targetInfo.triple}/${androidSdkVersion}
if [ ! -d $lpath ]; then
echo "NDK does not contain libraries for SDK version ${androidSdkVersion} <$lpath>"
exit 1
fi
mkdir -p $out/lib
cp $lpath/*.so $lpath/*.a $out/lib
chmod +w $out/lib/*
cp $lpath/* $out/lib
'';
};

# Bionic lib C and other libraries.
#
# We use androidndk from the previous stage, else we waste time or get cycles
# cross-compiling packages to wrap incorrectly wrap binaries we don't include
# anyways.
libraries = runCommand "bionic-prebuilt" { } ''
lpath=${buildAndroidndk}/libexec/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/${buildInfo.double}/sysroot/usr/lib/${targetInfo.triple}/${androidSdkVersion}
if [ ! -d $lpath ]; then
echo "NDK does not contain libraries for SDK version ${androidSdkVersion} <$lpath>"
exit 1
fi
mkdir -p $out/lib
cp $lpath/*.so $lpath/*.a $out/lib
chmod +w $out/lib/*
cp $lpath/* $out/lib
'';
}
}
2 changes: 1 addition & 1 deletion pkgs/development/androidndk-pkgs/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ let
majorVersion = lib.versions.major ndkVersion;
in
import ./androidndk-pkgs.nix {
inherit lib;
inherit config lib;
inherit (buildPackages)
makeWrapper
autoPatchelfHook
Expand Down
Loading
Loading