Merge pull request #16540 from matthewbauer/xcbuild
xcbuild: add wrapper
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
{ stdenv, cmake, fetchFromGitHub, zlib, libxml2, libpng, CoreServices, CoreGraphics, ImageIO }:
|
||||
{ stdenv, cmake, fetchFromGitHub, zlib, libxml2, libpng, CoreServices, CoreGraphics, ImageIO, ninja }:
|
||||
|
||||
let
|
||||
googletest = fetchFromGitHub {
|
||||
@@ -16,13 +16,13 @@ let
|
||||
};
|
||||
in stdenv.mkDerivation rec {
|
||||
name = "xcbuild-${stdenv.lib.substring 0 8 version}";
|
||||
version = "49f8a5923f1381f87ac03ad4c1b138d1d2b74369";
|
||||
version = "0ab861abcc11185a17d59608f96a015752a6fadc";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "facebook";
|
||||
repo = "xcbuild";
|
||||
rev = version;
|
||||
sha256 = "0l107xkh7dab2xc58dqyrrhpd1gp12cpzh0wrx0i9jbh0idbwnk0";
|
||||
sha256 = "12h0rn8v0js2vph2pwp5wvcrfkj12nz365i5qxw9miyfn4msnz26";
|
||||
};
|
||||
|
||||
prePatch = ''
|
||||
@@ -39,5 +39,6 @@ in stdenv.mkDerivation rec {
|
||||
rmdir $out/usr
|
||||
'';
|
||||
|
||||
buildInputs = [ cmake zlib libxml2 libpng CoreServices CoreGraphics ImageIO ];
|
||||
}
|
||||
buildInputs = [ cmake zlib libxml2 libpng ninja ]
|
||||
++ stdenv.lib.optionals stdenv.isDarwin [ CoreServices CoreGraphics ImageIO ];
|
||||
}
|
||||
|
||||
152
pkgs/development/tools/xcbuild/platform.nix
Normal file
152
pkgs/development/tools/xcbuild/platform.nix
Normal file
@@ -0,0 +1,152 @@
|
||||
{ stdenv, sdk, writeText, platformName, xcbuild }:
|
||||
|
||||
let
|
||||
|
||||
Info = {
|
||||
CFBundleIdentifier = platformName;
|
||||
Type = "Platform";
|
||||
Name = "macosx";
|
||||
};
|
||||
|
||||
Version = {
|
||||
ProjectName = "OSXPlatformSupport";
|
||||
};
|
||||
|
||||
# These files are all based off of Xcode spec fies found in
|
||||
# /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Xcode/Speciications/.
|
||||
|
||||
# Based off of the MacOSX Architectures.xcpsec file. All i386 stuff
|
||||
# is removed because NixPkgs only supports darwin-x86_64.
|
||||
Architectures = [
|
||||
{
|
||||
Identifier = "Standard";
|
||||
Type = "Architecture";
|
||||
Name = "Standard Architectures (64-bit Intel)";
|
||||
RealArchitectures = [ "x86_64" ];
|
||||
ArchitectureSetting = "ARCHS_STANDARD";
|
||||
}
|
||||
{
|
||||
Identifier = "Universal";
|
||||
Type = "Architecture";
|
||||
Name = "Universal (64-bit Intel)";
|
||||
RealArchitectures = [ "x86_64" ];
|
||||
ArchitectureSetting = "ARCHS_STANDARD_32_64_BIT";
|
||||
}
|
||||
{
|
||||
Identifier = "Native";
|
||||
Type = "Architecture";
|
||||
Name = "Native Architecture of Build Machine";
|
||||
ArchitectureSetting = "NATIVE_ARCH_ACTUAL";
|
||||
}
|
||||
{
|
||||
Identifier = "Standard64bit";
|
||||
Type = "Architecture";
|
||||
Name = "64-bit Intel";
|
||||
RealArchitectures = [ "x86_64" ];
|
||||
ArchitectureSetting = "ARCHS_STANDARD_64_BIT";
|
||||
}
|
||||
{
|
||||
Identifier = "x86_64";
|
||||
Type = "Architecture";
|
||||
Name = "Intel 64-bit";
|
||||
}
|
||||
{
|
||||
Identifier = "Standard_Including_64_bit";
|
||||
Type = "Architecture";
|
||||
Name = "Standard Architectures (including 64-bit)";
|
||||
RealArchitectures = [ "x86_64" ];
|
||||
ArchitectureSetting = "ARCHS_STANDARD_INCLUDING_64_BIT";
|
||||
}
|
||||
];
|
||||
|
||||
# Based off of the MacOSX Package Types.xcpsec file. Only keep the
|
||||
# bare minimum needed.
|
||||
PackageTypes = [
|
||||
{
|
||||
Identifier = "com.apple.package-type.mach-o-executable";
|
||||
Type = "PackageType";
|
||||
Name = "Mach-O Executable";
|
||||
DefaultBuildSettings = {
|
||||
EXECUTABLE_NAME = "$(EXECUTABLE_PREFIX)$(PRODUCT_NAME)$(EXECUTABLE_VARIANT_SUFFIX)$(EXECUTABLE_SUFFIX)";
|
||||
EXECUTABLE_PATH = "$(EXECUTABLE_NAME)";
|
||||
};
|
||||
ProductReference = {
|
||||
FileType = "compiled.mach-o.executable";
|
||||
Name = "$(EXECUTABLE_NAME)";
|
||||
};
|
||||
}
|
||||
{
|
||||
Identifier = "com.apple.package-type.mach-o-objfile";
|
||||
Type = "PackageType";
|
||||
Name = "Mach-O Object File";
|
||||
DefaultBuildSettings = {
|
||||
EXECUTABLE_NAME = "$(EXECUTABLE_PREFIX)$(PRODUCT_NAME)$(EXECUTABLE_VARIANT_SUFFIX)$(EXECUTABLE_SUFFIX)";
|
||||
EXECUTABLE_PATH = "$(EXECUTABLE_NAME)";
|
||||
};
|
||||
ProductReference = {
|
||||
FileType = "compiled.mach-o.objfile";
|
||||
Name = "$(EXECUTABLE_NAME)";
|
||||
};
|
||||
}
|
||||
{
|
||||
Identifier = "com.apple.package-type.mach-o-dylib";
|
||||
Type = "PackageType";
|
||||
Name = "Mach-O Dynamic Library";
|
||||
DefaultBuildSettings = {
|
||||
EXECUTABLE_NAME = "$(EXECUTABLE_PREFIX)$(PRODUCT_NAME)$(EXECUTABLE_VARIANT_SUFFIX)$(EXECUTABLE_SUFFIX)";
|
||||
EXECUTABLE_PATH = "$(EXECUTABLE_NAME)";
|
||||
};
|
||||
ProductReference = {
|
||||
FileType = "compiled.mach-o.dylib";
|
||||
Name = "$(EXECUTABLE_NAME)";
|
||||
};
|
||||
}
|
||||
];
|
||||
|
||||
# Based off of the MacOSX Product Types.xcpsec file. All
|
||||
# bundles/wrapper are removed, because we prefer dynamic products in
|
||||
# NixPkgs.
|
||||
ProductTypes = [
|
||||
{
|
||||
Identifier = "com.apple.product-type.tool";
|
||||
Type = "ProductType";
|
||||
Name = "Command-line Tool";
|
||||
PackageTypes = [ "com.apple.package-type.mach-o-executable" ];
|
||||
}
|
||||
{
|
||||
Identifier = "com.apple.product-type.objfile";
|
||||
Type = "ProductType";
|
||||
Name = "Object File";
|
||||
PackageTypes = [ "com.apple.package-type.mach-o-objfile" ];
|
||||
}
|
||||
{
|
||||
Identifier = "com.apple.product-type.library.dynamic";
|
||||
Type = "ProductType";
|
||||
Name = "Dynamic Library";
|
||||
PackageTypes = [ "com.apple.package-type.mach-o-dylib" ];
|
||||
}
|
||||
];
|
||||
|
||||
in
|
||||
|
||||
stdenv.mkDerivation {
|
||||
name = "nixpkgs.platform";
|
||||
buildInputs = [ xcbuild ];
|
||||
buildCommand = ''
|
||||
mkdir -p $out/
|
||||
cd $out/
|
||||
|
||||
plutil -convert xml1 -o Info.plist ${writeText "Info.plist" (builtins.toJSON Info)}
|
||||
plutil -convert xml1 -o version.plist ${writeText "version.plist" (builtins.toJSON Version)}
|
||||
|
||||
mkdir -p $out/Developer/Library/Xcode/Specifications/
|
||||
cd $out/Developer/Library/Xcode/Specifications/
|
||||
plutil -convert xml1 -o Architectures.xcspec ${writeText "Architectures.xcspec" (builtins.toJSON Architectures)}
|
||||
plutil -convert xml1 -o PackageTypes.xcspec ${writeText "PackageTypes.xcspec" (builtins.toJSON PackageTypes)}
|
||||
plutil -convert xml1 -o ProductTypes.xcspec ${writeText "ProductTypes.xcspec" (builtins.toJSON ProductTypes)}
|
||||
|
||||
mkdir -p $out/Developer/SDKs/
|
||||
cd $out/Developer/SDKs/
|
||||
ln -s ${sdk}
|
||||
'';
|
||||
}
|
||||
31
pkgs/development/tools/xcbuild/sdk.nix
Normal file
31
pkgs/development/tools/xcbuild/sdk.nix
Normal file
@@ -0,0 +1,31 @@
|
||||
{ stdenv, writeText, toolchainName, sdkName, xcbuild }:
|
||||
|
||||
let
|
||||
|
||||
SDKSettings = {
|
||||
CanonicalName = sdkName;
|
||||
DisplayName = sdkName;
|
||||
Toolchains = [ toolchainName ];
|
||||
Version = "10.10";
|
||||
MaximumDeploymentTarget = "10.10";
|
||||
isBaseSDK = "YES";
|
||||
};
|
||||
|
||||
SystemVersion = {
|
||||
ProductName = "Mac OS X";
|
||||
ProductVersion = "10.10";
|
||||
};
|
||||
|
||||
in
|
||||
|
||||
stdenv.mkDerivation {
|
||||
name = "nix.nixpkgs.sdk";
|
||||
buildInputs = [ xcbuild ];
|
||||
buildCommand = ''
|
||||
mkdir -p $out/
|
||||
plutil -convert xml1 -o $out/SDKSettings.plist ${writeText "SDKSettings.json" (builtins.toJSON SDKSettings)}
|
||||
|
||||
mkdir -p $out/System/Library/CoreServices/
|
||||
plutil -convert xml1 -o $out/System/Library/CoreServices/SystemVersion.plist ${writeText "SystemVersion.plist" (builtins.toJSON SystemVersion)}
|
||||
'';
|
||||
}
|
||||
31
pkgs/development/tools/xcbuild/setup-hook.sh
Normal file
31
pkgs/development/tools/xcbuild/setup-hook.sh
Normal file
@@ -0,0 +1,31 @@
|
||||
xcbuildBuildPhase() {
|
||||
export DSTROOT=$out
|
||||
|
||||
runHook preBuild
|
||||
|
||||
echo "running xcodebuild"
|
||||
|
||||
xcodebuild OTHER_CFLAGS="$NIX_CFLAGS_COMPILE" OTHER_CPLUSPLUSFLAGS="$NIX_CFLAGS_COMPILE" OTHER_LDFLAGS="$NIX_LDFLAGS" build
|
||||
|
||||
runHook postBuild
|
||||
}
|
||||
|
||||
xcbuildInstallPhase () {
|
||||
runHook preInstall
|
||||
|
||||
# not implemented
|
||||
# xcodebuild install
|
||||
|
||||
runHook postInstall
|
||||
}
|
||||
|
||||
if [ -z "$dontUseXcbuild" ]; then
|
||||
buildPhase=xcbuildBuildPhase
|
||||
if [ -z "$installPhase" ]; then
|
||||
installPhase=xcbuildInstallPhase
|
||||
fi
|
||||
fi
|
||||
|
||||
# if [ -d "*.xcodeproj" ]; then
|
||||
# buildPhase=xcbuildPhase
|
||||
# fi
|
||||
109
pkgs/development/tools/xcbuild/toolchain.nix
Normal file
109
pkgs/development/tools/xcbuild/toolchain.nix
Normal file
@@ -0,0 +1,109 @@
|
||||
{stdenv, writeText, toolchainName, xcbuild
|
||||
, llvm, cctools, gcc, bootstrap_cmds, binutils
|
||||
, yacc, flex, m4, unifdef, gperf, indent, ctags, makeWrapper}:
|
||||
|
||||
let
|
||||
|
||||
ToolchainInfo = {
|
||||
Identifier = toolchainName;
|
||||
};
|
||||
|
||||
in
|
||||
|
||||
stdenv.mkDerivation {
|
||||
name = "nixpkgs.xctoolchain";
|
||||
buildInputs = [ xcbuild makeWrapper ];
|
||||
|
||||
propagatedBuildInputs = [ llvm gcc yacc flex m4 unifdef gperf indent ]
|
||||
++ stdenv.lib.optionals stdenv.isDarwin [ cctools bootstrap_cmds binutils ];
|
||||
## cctools should build on Linux but it doesn't currentl
|
||||
|
||||
buildCommand = ''
|
||||
mkdir -p $out
|
||||
plutil -convert xml1 -o $out/ToolchainInfo.plist ${writeText "ToolchainInfo.plist" (builtins.toJSON ToolchainInfo)}
|
||||
|
||||
mkdir -p $out/usr/include
|
||||
mkdir -p $out/usr/lib
|
||||
mkdir -p $out/usr/libexec
|
||||
mkdir -p $out/usr/share
|
||||
|
||||
mkdir -p $out/usr/bin
|
||||
cd $out/usr/bin
|
||||
ln -s ${stdenv.cc}/bin/cpp
|
||||
ln -s ${stdenv.cc}/bin/c++
|
||||
ln -s ${stdenv.cc}/bin/cc
|
||||
ln -s c++ clang++
|
||||
ln -s cc clang
|
||||
|
||||
ln -s ${llvm}/bin/llvm-cov
|
||||
ln -s ${llvm}/bin/llvm-dsymutil
|
||||
ln -s ${llvm}/bin/llvm-dwarfdump
|
||||
ln -s ${llvm}/bin/llvm-nm
|
||||
ln -s ${llvm}/bin/llvm-objdump
|
||||
ln -s ${llvm}/bin/llvm-otool
|
||||
ln -s ${llvm}/bin/llvm-profdata
|
||||
ln -s ${llvm}/bin/llvm-size
|
||||
|
||||
ln -s ${yacc}/bin/yacc
|
||||
ln -s ${yacc}/bin/bison
|
||||
ln -s ${flex}/bin/flex
|
||||
ln -s ${flex}/bin/flex++
|
||||
|
||||
ln -s flex lex
|
||||
|
||||
ln -s ${m4}/bin/m4
|
||||
ln -s m4 gm4
|
||||
|
||||
ln -s ${unifdef}/bin/unifdef
|
||||
ln -s ${unifdef}/bin/unifdefall
|
||||
|
||||
ln -s ${gperf}/bin/gperf
|
||||
ln -s ${gcc}/bin/gcov
|
||||
ln -s ${gcc}/bin/mkdep
|
||||
ln -s ${indent}/bin/indent
|
||||
ln -s ${ctags}/bin/ctags
|
||||
'' + stdenv.lib.optionalString stdenv.isDarwin ''
|
||||
ln -s ${bootstrap_cmds}/bin/mig
|
||||
ln -s ${binutils}/bin/lipo
|
||||
|
||||
ln -s ${cctools}/bin/ar
|
||||
ln -s ${cctools}/bin/as
|
||||
ln -s ${cctools}/bin/nm
|
||||
ln -s ${cctools}/bin/nmedit
|
||||
ln -s ${cctools}/bin/ld
|
||||
ln -s ${cctools}/bin/libtool
|
||||
ln -s ${cctools}/bin/strings
|
||||
ln -s ${cctools}/bin/strip
|
||||
ln -s ${cctools}/bin/install_name_tool
|
||||
ln -s ${cctools}/bin/bitcode_strip
|
||||
ln -s ${cctools}/bin/codesign_allocate
|
||||
ln -s ${cctools}/bin/dsymutil
|
||||
ln -s ${cctools}/bin/dyldinfo
|
||||
ln -s ${cctools}/bin/otool
|
||||
ln -s ${cctools}/bin/unwinddump
|
||||
ln -s ${cctools}/bin/size
|
||||
ln -s ${cctools}/bin/segedit
|
||||
ln -s ${cctools}/bin/pagestuff
|
||||
ln -s ${cctools}/bin/ranlib
|
||||
ln -s ${cctools}/bin/redo_prebinding
|
||||
'';
|
||||
}
|
||||
|
||||
# other commands in /bin/
|
||||
# asa
|
||||
# cmpdylib (in cctools)
|
||||
# ctf_insert (in cctools)
|
||||
# dwarfdump
|
||||
# lorder
|
||||
# rebase
|
||||
# rpcgen (in developer_cmds)
|
||||
# what
|
||||
|
||||
|
||||
# swift: see #11463
|
||||
# swift
|
||||
# swift-compress
|
||||
# swift-demangle
|
||||
# swift-stdlib-tool
|
||||
# swift-update
|
||||
# swiftc
|
||||
72
pkgs/development/tools/xcbuild/wrapper.nix
Normal file
72
pkgs/development/tools/xcbuild/wrapper.nix
Normal file
@@ -0,0 +1,72 @@
|
||||
{ stdenv, callPackage, makeWrapper, writeText, CoreServices, ImageIO, CoreGraphics
|
||||
, cctools, bootstrap_cmds, binutils}:
|
||||
|
||||
let
|
||||
|
||||
toolchainName = "com.apple.dt.toolchain.XcodeDefault";
|
||||
platformName = "com.apple.platform.macosx";
|
||||
sdkName = "macosx10.10";
|
||||
|
||||
xcbuild = callPackage ./default.nix {
|
||||
inherit CoreServices ImageIO CoreGraphics;
|
||||
};
|
||||
|
||||
toolchain = callPackage ./toolchain.nix {
|
||||
inherit cctools bootstrap_cmds toolchainName xcbuild binutils stdenv;
|
||||
};
|
||||
|
||||
sdk = callPackage ./sdk.nix {
|
||||
inherit toolchainName sdkName xcbuild;
|
||||
};
|
||||
|
||||
platform = callPackage ./platform.nix {
|
||||
inherit sdk platformName xcbuild;
|
||||
};
|
||||
|
||||
xcconfig = writeText "nix.xcconfig" ''
|
||||
SDKROOT=${sdkName}
|
||||
'';
|
||||
|
||||
in
|
||||
|
||||
stdenv.mkDerivation {
|
||||
name = "xcbuild-wrapper";
|
||||
|
||||
buildInputs = [ xcbuild makeWrapper ];
|
||||
|
||||
setupHook = ./setup-hook.sh;
|
||||
|
||||
phases = [ "installPhase" "fixupPhase" ];
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
cd $out/bin/
|
||||
|
||||
for file in ${xcbuild}/bin/*; do
|
||||
ln -s $file
|
||||
done
|
||||
|
||||
mkdir -p $out/Library/Xcode/
|
||||
ln -s ${xcbuild}/Library/Xcode/Specifications $out/Library/Xcode/Specifications
|
||||
|
||||
mkdir -p $out/Platforms/
|
||||
ln -s ${platform} $out/Platforms/
|
||||
|
||||
mkdir -p $out/Toolchains/
|
||||
ln -s ${toolchain} $out/Toolchains/
|
||||
|
||||
wrapProgram $out/bin/xcodebuild \
|
||||
--add-flags "-xcconfig ${xcconfig}" \
|
||||
--add-flags "DERIVED_DATA_DIR=." \
|
||||
--set DEVELOPER_DIR "$out"
|
||||
wrapProgram $out/bin/xcrun \
|
||||
--add-flags "-sdk ${sdkName}" \
|
||||
--set DEVELOPER_DIR "$out"
|
||||
'';
|
||||
|
||||
passthru = {
|
||||
raw = xcbuild;
|
||||
};
|
||||
|
||||
preferLocalBuild = true;
|
||||
}
|
||||
Reference in New Issue
Block a user