xcbuild: cleanup

This commit is contained in:
Matthew Bauer 2018-07-11 11:45:23 -04:00
parent 0edb441a0e
commit b5d529d52f
4 changed files with 48 additions and 42 deletions

View file

@ -294,8 +294,7 @@ runCommand "Platforms" {} ''
install -D ${writeText "PackageTypes.xcspec" (toPlist {} PackageTypes)} $platform/Developer/Library/Xcode/Specifications/PackageTypes.xcspec
install -D ${writeText "ProductTypes.xcspec" (toPlist {} ProductTypes)} $platform/Developer/Library/Xcode/Specifications/ProductTypes.xcspec
# per-platform bins go here
mkdir -p $platform/usr/bin
ln -s $platform $platform/usr
mkdir -p $platform/Developer
ln -s ${sdks} $platform/Developer/SDKs

View file

@ -1,4 +1,5 @@
{ runCommand, lib, toolchainName, sdkName, writeText, version, xcodePlatform }:
{ stdenv, runCommand, lib, toolchainName, sdkName
, writeText, version, xcodePlatform, libcxx, symlinkJoin }:
let
inherit (lib.generators) toPlist;
@ -18,11 +19,11 @@ let
};
in
runCommand "SDKs" {
inherit version;
} ''
runCommand "SDKs" {} ''
sdk=$out/${sdkName}.sdk
install -D ${writeText "SDKSettings.plist" (toPlist {} SDKSettings)} $sdk/SDKSettings.plist
install -D ${writeText "SystemVersion.plist" (toPlist {} SystemVersion)} $sdk/System/Library/CoreServices/SystemVersion.plist
ln -s $sdk $sdk/usr
ln -s $sdk $out/${xcodePlatform}.sdk
''

View file

@ -1,4 +1,4 @@
{ runCommand, toolchainName, fetchurl, makeWrapper, stdenv
{ runCommand, toolchainName, fetchurl, stdenv
, buildPackages, lib, writeText }:
let
@ -20,52 +20,52 @@ let
};
in
runCommand "Toolchains" {
nativeBuildInputs = [ makeWrapper ];
} (''
runCommand "Toolchains" {} (''
toolchain=$out/XcodeDefault.xctoolchain
mkdir -p $toolchain
install -D ${writeText "ToolchainInfo.plist" (toPlist {} ToolchainInfo)} $toolchain/ToolchainInfo.plist
mkdir -p $toolchain/usr/include
mkdir -p $toolchain/usr/lib
mkdir -p $toolchain/usr/libexec
mkdir -p $toolchain/usr/share
mkdir -p $toolchain/usr/bin
ln -s $toolchain $toolchain/usr
mkdir -p $toolchain/include
mkdir -p $toolchain/lib
mkdir -p $toolchain/libexec
mkdir -p $toolchain/share
mkdir -p $toolchain/bin
for bin in ${getBin stdenv.cc}/bin/*; do
ln -s $bin $toolchain/usr/bin
ln -s $bin $toolchain/bin
done
for bin in ${getBin stdenv.cc.bintools.bintools}/bin/*; do
if ! [ -e "$toolchain/usr/bin/$(basename $bin)" ]; then
ln -s $bin $toolchain/usr/bin
if ! [ -e "$toolchain/bin/$(basename $bin)" ]; then
ln -s $bin $toolchain/bin
fi
done
ln -s ${buildPackages.yacc}/bin/yacc $toolchain/usr/bin/yacc
ln -s ${buildPackages.yacc}/bin/bison $toolchain/usr/bin/bison
ln -s ${buildPackages.flex}/bin/flex $toolchain/usr/bin/flex
ln -s ${buildPackages.flex}/bin/flex++ $toolchain/usr/bin/flex++
ln -s $toolchain/bin/flex $toolchain/usr/bin/lex
ln -s ${buildPackages.yacc}/bin/yacc $toolchain/bin/yacc
ln -s ${buildPackages.yacc}/bin/bison $toolchain/bin/bison
ln -s ${buildPackages.flex}/bin/flex $toolchain/bin/flex
ln -s ${buildPackages.flex}/bin/flex++ $toolchain/bin/flex++
ln -s $toolchain/bin/flex $toolchain/bin/lex
ln -s ${buildPackages.m4}/bin/m4 $toolchain/usr/bin/m4
ln -s $toolchain/usr/bin/m4 $toolchain/usr/bin/gm4
ln -s ${buildPackages.m4}/bin/m4 $toolchain/bin/m4
ln -s $toolchain/bin/m4 $toolchain/bin/gm4
ln -s ${buildPackages.unifdef}/bin/unifdef $toolchain/usr/bin/unifdef
ln -s ${buildPackages.unifdef}/bin/unifdefall $toolchain/usr/bin/unifdefall
ln -s ${buildPackages.unifdef}/bin/unifdef $toolchain/bin/unifdef
ln -s ${buildPackages.unifdef}/bin/unifdefall $toolchain/bin/unifdefall
ln -s ${buildPackages.gperf}/bin/gperf $toolchain/usr/bin/gperf
ln -s ${buildPackages.indent}/bin/indent $toolchain/usr/bin/indent
ln -s ${buildPackages.ctags}/bin/ctags $toolchain/usr/bin/ctags
ln -s ${buildPackages.gperf}/bin/gperf $toolchain/bin/gperf
ln -s ${buildPackages.indent}/bin/indent $toolchain/bin/indent
ln -s ${buildPackages.ctags}/bin/ctags $toolchain/bin/ctags
'' + optionalString stdenv.isDarwin ''
for bin in ${getBin buildPackages.darwin.cctools}/bin/*; do
if ! [ -e "$toolchain/usr/bin/$(basename $bin)" ]; then
ln -s $bin $toolchain/usr/bin
if ! [ -e "$toolchain/bin/$(basename $bin)" ]; then
ln -s $bin $toolchain/bin
fi
done
ln -s ${buildPackages.darwin.bootstrap_cmds}/bin/mig $toolchain/usr/bin
ln -s ${mkdep-darwin-src} $toolchain/usr/bin/mkdep
ln -s ${buildPackages.darwin.bootstrap_cmds}/bin/mig $toolchain/bin
ln -s ${mkdep-darwin-src} $toolchain/bin/mkdep
'')

View file

@ -1,4 +1,5 @@
{ lib, buildPackages, makeWrapper, writeText, runCommand
{ stdenv, lib, buildPackages, makeWrapper, writeText, runCommand
, bash
, CoreServices, ImageIO, CoreGraphics
, targetPlatform
, xcodePlatform ? targetPlatform.xcodePlatform or "MacOSX"
@ -36,7 +37,7 @@ let
'';
xcode-select = writeText "xcode-select" ''
#!/usr/bin/env sh
#!${bash}/bin/sh
while [ $# -gt 0 ]; do
case "$1" in
-h | --help) ;; # noop
@ -51,7 +52,7 @@ done
'';
xcrun = writeText "xcrun" ''
#!/usr/bin/env sh
#!${bash}/bin/sh
while [ $# -gt 0 ]; do
case "$1" in
--sdk | -sdk) shift ;;
@ -86,16 +87,20 @@ runCommand "xcodebuild-${xcbuild.version}" {
inherit (xcbuild) meta;
# ensure that the toolchain goes in PATH
propagatedBuildInputs = [ "${toolchains}/XcodeDefault.xctoolchain/usr" ];
propagatedBuildInputs = [ "${toolchains}/XcodeDefault.xctoolchain" ];
passthru = { inherit xcbuild; };
passthru = {
inherit xcbuild;
toolchain = "${toolchains}/XcodeDefault.xctoolchain";
sdk = "${sdks}/${sdkName}";
platform = "${platforms}/${xcodePlatform}.platform";
};
preferLocalBuild = true;
} ''
mkdir -p $out/bin
mkdir -p $out/usr
ln -s $out/bin $out/usr/bin
ln -s $out $out/usr
mkdir -p $out/Library/Xcode
ln -s ${xcbuild}/Library/Xcode/Specifications $out/Library/Xcode/Specifications
@ -108,7 +113,8 @@ runCommand "xcodebuild-${xcbuild.version}" {
--add-flags "DERIVED_DATA_DIR=." \
--set DEVELOPER_DIR "$out" \
--set SDKROOT ${sdkName} \
--run '[ "$1" = "-version" ] && (echo Xcode ${xcodeVer}; echo Build version ${sdkBuildVersion}) && exit 0'
--run '[ "$1" = "-version" ] && (echo Xcode ${xcodeVer}; echo Build version ${sdkBuildVersion}) && exit 0' \
--run '[ "$1" = "-license" ] && exit 0'
substitute ${xcode-select} $out/bin/xcode-select \
--subst-var-by DEVELOPER_DIR $out