From 0c17414e25bd72654a6797ff554f862cf9b441f5 Mon Sep 17 00:00:00 2001 From: Josh Peterson Date: Mon, 20 Aug 2018 14:57:28 -0400 Subject: [PATCH] Use LF line endings on all perl build scripts --- external/buildscripts/build.pl | 3620 ++++++++--------- external/buildscripts/build_all_linux.pl | 52 +- external/buildscripts/build_all_win.pl | 52 +- external/buildscripts/build_classlibs_osx.pl | 80 +- external/buildscripts/build_classlibs_wsl.pl | 106 +- external/buildscripts/build_ios_xwin.pl | 36 +- .../buildscripts/build_runtime_android.pl | 64 +- external/buildscripts/build_runtime_iphone.pl | 134 +- external/buildscripts/build_runtime_linux.pl | 46 +- external/buildscripts/build_runtime_osx.pl | 22 +- external/buildscripts/build_runtime_vs.pl | 104 +- external/buildscripts/build_runtime_win.pl | 28 +- external/buildscripts/build_runtime_win64.pl | 28 +- external/buildscripts/build_runtime_wsl.pl | 26 +- .../build_unityscript_bareminimum_win.pl | 318 +- external/buildscripts/build_us_and_boo.pl | 316 +- external/buildscripts/build_win_no_cygwin.pl | 562 +-- external/buildscripts/build_win_wrapper.pl | 436 +- external/buildscripts/collect_allbuilds.pl | 132 +- 19 files changed, 3081 insertions(+), 3081 deletions(-) diff --git a/external/buildscripts/build.pl b/external/buildscripts/build.pl index eee3432411fa..3578d474d357 100644 --- a/external/buildscripts/build.pl +++ b/external/buildscripts/build.pl @@ -1,1810 +1,1810 @@ -use Cwd; -use Cwd 'abs_path'; -use Getopt::Long; -use File::Basename; -use File::Path; -use lib ('external/buildscripts', "../../Tools/perl_lib","perl_lib", 'external/buildscripts/perl_lib'); -use Tools qw(InstallNameTool); - -print ">>> PATH in Build All = $ENV{PATH}\n\n"; - -my $currentdir = getcwd(); - -my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); -my $monoroot = abs_path($monoroot); - -my $buildscriptsdir = "$monoroot/external/buildscripts"; -my $addtoresultsdistdir = "$buildscriptsdir/add_to_build_results/monodistribution"; -my $buildsroot = "$monoroot/builds"; -my $includesroot = "$buildsroot/include"; -my $sourcesroot = "$buildsroot/source"; -my $distdir = "$buildsroot/monodistribution"; -my $buildMachine = $ENV{UNITY_THISISABUILDMACHINE}; - -# This script should not be ran on windows, if it is, kindly call the wrapper -# to switch over to cygwin -if ($^O eq "MSWin32") -{ - print(">>> build.pl called from Windows. Switching over to cygwin\n"); - system("perl", "$buildscriptsdir/build_win_wrapper.pl", @ARGV) eq 0 or die("\n"); - exit 0; -} - -system("source","~/.profile"); - -my $build=0; -my $clean=0; -my $jobs=8; -my $test=0; -my $artifact=0; -my $debug=0; -my $disableMcs=0; -my $mcsOnly=0; -my $buildUsAndBoo=0; -my $artifactsCommon=0; -my $artifactsRuntime=1; -my $runRuntimeTests=1; -my $runClasslibTests=1; -my $checkoutOnTheFly=0; -my $forceDefaultBuildDeps=0; -my $existingMonoRootPath = ''; -my $sdk = ''; -my $arch32 = 0; -my $winPerl = ""; -my $winMonoRoot = ""; -my $msBuildVersion = "14.0"; -my $buildDeps = ""; -my $android=0; -my $androidArch = ""; -my $iphone=0; -my $iphoneArch = ""; -my $iphoneCross=0; -my $iphoneSimulator=0; -my $iphoneSimulatorArch=""; -my $tizen=0; -my $tizenEmulator=0; -my $windowsSubsystemForLinux=0; - -# Handy troubleshooting/niche options -my $skipMonoMake=0; - -# The prefix hack probably isn't needed anymore. Let's disable it by default and see how things go -my $shortPrefix=1; - -# Disabled by default for now. causes more problems than it's worth when actively making changes to the build scripts. -# Would be okay to turn on once the build scripts stabilize and you just want to rebuild code changes -my $enableCacheFile=0; - -# Linux toolchain setup needs this -my @commandPrefix = (); - -print(">>> Build All Args = @ARGV\n"); - -GetOptions( - 'build=i'=>\$build, - 'clean=i'=>\$clean, - 'test=i'=>\$test, - 'artifact=i'=>\$artifact, - 'artifactscommon=i'=>\$artifactsCommon, - 'artifactsruntime=i'=>\$artifactsRuntime, - 'debug=i'=>\$debug, - 'disablemcs=i'=>\$disableMcs, - 'mcsonly=i'=>\$mcsOnly, - 'buildusandboo=i'=>\$buildUsAndBoo, - 'runtimetests=i'=>\$runRuntimeTests, - 'classlibtests=i'=>\$runClasslibTests, - 'arch32=i'=>\$arch32, - 'jobs=i'=>\$jobs, - 'sdk=s'=>\$sdk, - 'existingmono=s'=>\$existingMonoRootPath, - 'skipmonomake=i'=>\$skipMonoMake, - 'shortprefix=i'=>\$shortPrefix, - 'winperl=s'=>\$winPerl, - 'winmonoroot=s'=>\$winMonoRoot, - 'msbuildversion=s'=>\$msBuildVersion, - 'checkoutonthefly=i'=>\$checkoutOnTheFly, - 'builddeps=s'=>\$buildDeps, - 'forcedefaultbuilddeps=i'=>\$forceDefaultBuildDeps, - 'android=i'=>\$android, - 'androidarch=s'=>\$androidArch, - 'iphone=i'=>\$iphone, - 'iphonearch=s'=>\$iphoneArch, - 'iphonecross=i'=>\$iphoneCross, - 'iphonesimulator=i'=>\$iphoneSimulator, - 'tizen=i'=>\$tizen, - 'tizenemulator=i'=>\$tizenEmulator, - 'windowssubsystemforlinux=i'=>\$windowsSubsystemForLinux, - 'enablecachefile=i'=>\$enableCacheFile, -) or die ("illegal cmdline options"); - -print ">>> Mono checkout = $monoroot\n"; - -print(">> System Info : \n"); -system("uname", "-a"); - -my $monoRevision = `git rev-parse HEAD`; -chdir("$buildscriptsdir") eq 1 or die ("failed to chdir : $buildscriptsdir\n"); -my $buildScriptsRevision = `git rev-parse HEAD`; -chdir("$monoroot") eq 1 or die ("failed to chdir : $monoroot\n"); - -print(">>> Mono Revision = $monoRevision\n"); -print(">>> Build Scripts Revision = $buildScriptsRevision\n"); - -if ($androidArch ne "") -{ - $android = 1; -} - -if ($iphoneArch ne "") -{ - $iphone = 1; -} - -if($iphoneSimulator) -{ - if ($arch32) - { - $iphoneSimulatorArch = "i386"; - } - else - { - $iphoneSimulatorArch = "x86_64"; - } -} - -my $isDesktopBuild = 1; -if ($android || $iphone || $iphoneCross || $iphoneSimulator || $tizen || $tizenEmulator) -{ - $isDesktopBuild = 0; - - # Disable building of the class libraries by default when building the android runtime - # since we don't care about a class library build in this situation (as of writing this at least) - # but only if the test flag is not set. If the test flag was set, we'd need to build the classlibs - # in order to run the tests - $disableMcs = 1 if(!($test)); -} - -# Do any settings agnostic per-platform stuff -my $externalBuildDeps = ""; - -if ($buildDeps ne "" && not $forceDefaultBuildDeps) -{ - $externalBuildDeps = $buildDeps; -} -else -{ - $externalBuildDeps = "$monoroot/../../mono-build-deps/build"; -} - -# Only clean up the path if the directory exists, if it doesn't exist, -# abs_path ends up returning an empty string -$externalBuildDeps = abs_path($externalBuildDeps) if (-d $externalBuildDeps); - -my $extraBuildTools = "$monoroot/../../mono-build-tools-extra/build"; - -my $existingExternalMonoRoot = "$externalBuildDeps/MonoBleedingEdge"; -my $existingExternalMono = ""; -my $existingExternalMonoBinDir = ""; -my $monoHostArch = ""; -my $monoprefix = "$monoroot/tmp"; -my $runningOnWindows=0; -if($^O eq "linux") -{ - $monoHostArch = $arch32 ? "i686" : "x86_64"; - $existingExternalMono = "$existingExternalMonoRoot"; - $existingExternalMonoBinDir = "bin-linux64"; -} -elsif($^O eq 'darwin') -{ - $monoHostArch = $arch32 ? "i386" : "x86_64"; - $existingExternalMono = "$existingExternalMonoRoot"; - $existingExternalMonoBinDir = "bin"; - - # From Massi: I was getting failures in install_name_tool about space - # for the commands being too small, and adding here things like - # $ENV{LDFLAGS} = '-headerpad_max_install_names' and - # $ENV{LDFLAGS} = '-headerpad=0x40000' did not help at all (and also - # adding them to our final gcc invocation to make the bundle). - # Lucas noticed that I was lacking a Mono prefix, and having a long - # one would give us space, so here is this silly looong prefix. - if (not $shortPrefix) - { - $monoprefix = "$monoroot/tmp/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting"; - } -} -else -{ - $monoHostArch = "i686"; - $existingExternalMono = "$existingExternalMonoRoot"; - $existingExternalMonoBinDir = "bin-x64"; - $runningOnWindows = 1; - - # We only care about an existing mono if we need to build. - # So only do this path clean up if we are building. - if ($build) - { - if ($existingMonoRootPath ne "" && not $existingMonoRootPath =~ /^\/cygdrive/) - { - $existingMonoRootPath = `cygpath -u $existingMonoRootPath`; - chomp($existingMonoRootPath); - } - - $existingMonoRootPath =~ tr/\\//d; - } -} - -if ($runningOnWindows) -{ - # Fixes a line ending issue that happens on windows when we try to run autogen.sh - $ENV{'SHELLOPTS'} = "igncr"; -} - -print(">>> Existing Mono = $existingMonoRootPath\n"); -print(">>> Mono Arch = $monoHostArch\n"); - -if ($build) -{ - my $platformflags = ''; - my $host = ''; - my $mcs = ''; - - my $iphoneCrossAbi = "arm-apple-darwin10"; - my $iphoneCrossMonoBinToUse = "$monoroot/builds/monodistribution/bin"; - - my @configureparams = (); - - push @configureparams, "--disable-mcs-build" if($disableMcs); - push @configureparams, "--with-glib=embedded"; - push @configureparams, "--disable-nls"; #this removes the dependency on gettext package - push @configureparams, "--disable-btls"; #this removes the dependency on cmake to build btls for now - push @configureparams, "--with-mcs-docs=no"; - push @configureparams, "--prefix=$monoprefix"; - - if(!($disableMcs)) - { - push @configureparams, "--with-unityjit=yes"; - push @configureparams, "--with-unityaot=yes"; - } - - if ($isDesktopBuild) - { - push @configureparams, "--with-monotouch=no"; - } - - if (!(-d "$extraBuildTools")) - { - # Check out on the fly - print(">>> Checking out mono build tools extra to : $extraBuildTools\n"); - my $repo = 'git@gitlab.internal.unity3d.com:vm/mono-build-tools-extra.git'; - print(">>> Cloning $repo at $extraBuildTools\n"); - my $checkoutResult = system("git", "clone", "--recurse-submodules", $repo, "$extraBuildTools"); - - if ($checkoutResult ne 0) - { - die("Failed to checkout mono build tools extra\n"); - } - - # Only clean up if the dir exists. Otherwise abs_path will return empty string - $extraBuildTools = abs_path($extraBuildTools) if (-d $extraBuildTools); - } - - if ($existingMonoRootPath eq "") - { - print(">>> No existing mono supplied. Checking for external...\n"); - - if (!(-d "$externalBuildDeps")) - { - if (not $checkoutonthefly) - { - print(">>> No external build deps found. Might as well try to check them out. If it fails, we'll continue and trust mono is in your PATH\n"); - } - - # Check out on the fly - print(">>> Checking out mono build dependencies to : $externalBuildDeps\n"); - my $repo = "https://ono.unity3d.com/unity-extra/mono-build-deps"; - print(">>> Cloning $repo at $externalBuildDeps\n"); - my $checkoutResult = system("hg", "clone", $repo, "$externalBuildDeps"); - - if ($checkoutOnTheFly && $checkoutResult ne 0) - { - die("failed to checkout mono build dependencies\n"); - } - - # Only clean up if the dir exists. Otherwise abs_path will return empty string - $externalBuildDeps = abs_path($externalBuildDeps) if (-d $externalBuildDeps); - } - - if (-d "$existingExternalMono") - { - print(">>> External mono found at : $existingExternalMono\n"); - - if (-d "$existingExternalMono/builds") - { - print(">>> Mono already extracted at : $existingExternalMono/builds\n"); - } - - if (!(-d "$existingExternalMono/builds")) - { - # We need to extract builds.zip - print(">>> Extracting mono builds.zip...\n"); - system("unzip", "$existingExternalMono/builds.zip", "-d", "$existingExternalMono/builds") eq 0 or die("failed to extract mono builds.zip\n"); - } - - $existingMonoRootPath = "$existingExternalMono/builds/monodistribution"; - } - else - { - print(">>> No external mono found. Trusting a new enough mono is in your PATH.\n"); - } - } - - if ($existingMonoRootPath ne "" && !(-d $existingMonoRootPath)) - { - die("Existing mono not found at : $existingMonoRootPath\n"); - } - - if ($externalBuildDeps ne "") - { - print "\n"; - print ">>> Building autoconf, texinfo, automake, and libtool if needed...\n"; - my $autoconfVersion = "2.69"; - my $texinfoVersion = "4.8"; - my $automakeVersion = "1.15"; - my $libtoolVersion = "2.4.6"; - my $autoconfDir = "$externalBuildDeps/autoconf-$autoconfVersion"; - my $texinfoDir = "$externalBuildDeps/texinfo-$texinfoVersion"; - my $automakeDir = "$externalBuildDeps/automake-$automakeVersion"; - my $libtoolDir = "$externalBuildDeps/libtool-$libtoolVersion"; - my $builtToolsDir = "$externalBuildDeps/built-tools"; - - $ENV{PATH} = "$builtToolsDir/bin:$ENV{PATH}"; - - if (!(-d "$autoconfDir")) - { - chdir("$externalBuildDeps") eq 1 or die ("failed to chdir to external directory\n"); - system("tar xzf autoconf-$autoconfVersion.tar.gz") eq 0 or die ("failed to extract autoconf\n"); - - chdir("$autoconfDir") eq 1 or die ("failed to chdir to autoconf directory\n"); - system("./configure --prefix=$builtToolsDir") eq 0 or die ("failed to configure autoconf\n"); - system("make") eq 0 or die ("failed to make autoconf\n"); - system("make install") eq 0 or die ("failed to make install autoconf\n"); - - chdir("$monoroot") eq 1 or die ("failed to chdir to $monoroot\n"); - } - - if (!(-d "$texinfoDir") and $windowsSubsystemForLinux) - { - chdir("$externalBuildDeps") eq 1 or die ("failed to chdir to external directory\n"); - system("tar xzf texinfo-$texinfoVersion.tar.gz") eq 0 or die ("failed to extract texinfo\n"); - - chdir($texinfoDir) eq 1 or die ("failed to chdir to texinfo directory\n"); - system("./configure --prefix=$builtToolsDir") eq 0 or die ("failed to configure texinfo\n"); - system("make") eq 0 or die ("failed to make texinfo\n"); - system("make install") eq 0 or die ("failed to make install texinfo\n"); - - chdir("$monoroot") eq 1 or die ("failed to chdir to $monoroot\n"); - } - - if (!(-d "$automakeDir")) - { - my $automakeMakeFlags = ""; - chdir("$externalBuildDeps") eq 1 or die ("failed to chdir to external directory\n"); - system("tar xzf automake-$automakeVersion.tar.gz") eq 0 or die ("failed to extract automake\n"); - - chdir("$automakeDir") eq 1 or die ("failed to chdir to automake directory\n"); - if($windowsSubsystemForLinux) - { - #Windows subsystem needs to run bootstrap, and make needs to be run with -i due to one doc failing to build - system("./bootstrap.sh") eq 0 or die ("failed to bootstrap automake\n"); - $automakeMakeFlags = "-i"; - } - system("./configure --prefix=$builtToolsDir") eq 0 or die ("failed to configure automake\n"); - system("make $automakeMakeFlags") eq 0 or die ("failed to make automake\n"); - system("make install"); - chdir("$monoroot") eq 1 or die ("failed to chdir to $monoroot\n"); - } - - if (!(-d "$libtoolDir")) - { - chdir("$externalBuildDeps") eq 1 or die ("failed to chdir to external directory\n"); - system("tar xzf libtool-$libtoolVersion.tar.gz") eq 0 or die ("failed to extract libtool\n"); - - chdir("$libtoolDir") eq 1 or die ("failed to chdir to libtool directory\n"); - system("./configure --prefix=$builtToolsDir") eq 0 or die ("failed to configure libtool\n"); - system("make") eq 0 or die ("failed to make libtool\n"); - system("make install") eq 0 or die ("failed to make install libtool\n"); - - chdir("$monoroot") eq 1 or die ("failed to chdir to $monoroot\n"); - } - - $ENV{'LIBTOOLIZE'} = "$builtToolsDir/bin/libtoolize"; - $ENV{'LIBTOOL'} = "$builtToolsDir/bin/libtool"; - } - - my $macSdkPath = ""; - my $macversion = '10.8'; - my $darwinVersion = "10"; - if ($^O eq 'darwin') - { - if ($sdk eq '') - { - $sdk='10.11'; - } - - my $macBuildEnvDir = "$externalBuildDeps/MacBuildEnvironment"; - $macSdkPath = "$macBuildEnvDir/builds/MacOSX$sdk.sdk"; - if (! -d $macSdkPath) - { - print(">>> Unzipping mac build toolchain\n"); - system("$externalBuildDeps/unzip", '-qd', "$macBuildEnvDir", "$macBuildEnvDir/builds.zip") eq 0 or die ("failed unzipping mac build toolchain\n"); - } - } - - if ($iphone || $iphoneSimulator) - { - if ($runningOnWindows) - { - die("This build is not supported on Windows\n"); - } - - my $iosBuildEnvDir = "$externalBuildDeps/iOSBuildEnvironment"; - my $iosXcodeDefaultToolchainRoot = "$iosBuildEnvDir/builds/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain"; - - if (! -d "$iosBuildEnvDir/builds") - { - print(">>> Unzipping ios build toolchain\n"); - system("$externalBuildDeps/unzip", '-qd', "$iosBuildEnvDir/builds", "$iosBuildEnvDir/builds.zip") eq 0 or die ("failed unzipping ios build toolchain\n"); - } - - $ENV{PATH} = "$iosXcodeDefaultToolchainRoot/usr/bin:$iosBuildEnvDir/builds/Xcode.app/Contents/Developer/usr/bin:$ENV{PATH}"; - # Need to keep our libtool in front - $ENV{PATH} = "$externalBuildDeps/built-tools/bin:$ENV{PATH}"; - - push @configureparams, "--cache-file=iphone-$iphoneArch.cache" if ($enableCacheFile); - - my $iosMinimalCommon = "com,remoting,shared_perfcounters,appdomains"; - my $iosCFlagsCommon = "-DMONOTOUCH -DHOST_IOS -DDISABLE_POLICY_EVIDENCE=1 -DDISABLE_PROCESS_HANDLING=1"; - - push @configureparams, "--with-tls=pthread"; - push @configureparams, "--without-ikvm-native"; - push @configureparams, "--disable-executables"; - push @configureparams, "--disable-visibility-hidden"; - - if ($iphone) - { - my $iosSdkVersion = "9.3"; - my $iphoneOsMinVersion = "3.0"; - my $iosSdkRoot = "$iosBuildEnvDir/builds/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS$iosSdkVersion.sdk"; - - print(">>> iOS Build Environment = $iosBuildEnvDir\n"); - print(">>> iOS SDK Version = $iosSdkVersion\n"); - print(">>> iOS SDK Root = $iosSdkRoot\n"); - print(">>> iPhone Arch = $iphoneArch\n"); - - $ENV{PATH} = "$iosSdkRoot/usr/bin:$ENV{PATH}"; - - $ENV{C_INCLUDE_PATH} = "$iosSdkRoot/usr/include"; - $ENV{CPLUS_INCLUDE_PATH} = "$iosSdkRoot/usr/include"; - - $ENV{CC} = "$iosBuildEnvDir/builds/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch $iphoneArch"; - $ENV{CXX} = "$iosBuildEnvDir/builds/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch $iphoneArch"; - $ENV{LD} = "$iosBuildEnvDir/builds/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld"; - - $ENV{CFLAGS} = "$iosCFlagsCommon -gdwarf-2 -DSMALL_CONFIG -DHAVE_LARGE_FILE_SUPPORT=1 -DHAVE_ARMV6=1 -DARM_FPU_VFP=1 -Wl,-application_extension -miphoneos-version-min=$iphoneOsMinVersion -mno-thumb -Os -isysroot $iosSdkRoot"; - - # Unity defines - $ENV{CFLAGS} = "-DPLATFORM_IPHONE $ENV{CFLAGS}"; - - $ENV{CXXFLAGS} = "$ENV{CFLAGS} -U__powerpc__ -U__i386__ -D__arm__"; - $ENV{CPPFLAGS} = $ENV{CXXFLAGS}; - - $ENV{LDFLAGS} = "-arch $iphoneArch -liconv -lobjc -lc++ -Wl,-syslibroot,$iosSdkRoot"; - - print "\n"; - print ">>> Environment:\n"; - print ">>> \tCC = $ENV{CC}\n"; - print ">>> \tCXX = $ENV{CXX}\n"; - print ">>> \tLD = $ENV{LD}\n"; - print ">>> \tCFLAGS = $ENV{CFLAGS}\n"; - print ">>> \tCXXFLAGS = $ENV{CXXFLAGS}\n"; - print ">>> \tCPPFLAGS = $ENV{CPPFLAGS}\n"; - print ">>> \tLDFLAGS = $ENV{LDFLAGS}\n"; - print ">>> \tCPLUS_INCLUDE_PATH = $ENV{CPLUS_INCLUDE_PATH}\n"; - print ">>> \tC_INCLUDE_PATH = $ENV{C_INCLUDE_PATH}\n"; - - push @configureparams, "--host=arm-apple-darwin$darwinVersion"; - - push @configureparams, "--with-sigaltstack=no"; - push @configureparams, "--disable-shared-handles"; - push @configureparams, "--with-monotouch"; - - push @configureparams, "--enable-llvm-runtime"; - push @configureparams, "--with-bitcode=yes"; - - push @configureparams, "--with-lazy-gc-thread-creation=yes"; - push @configureparams, "--enable-icall-export"; - push @configureparams, "--enable-dtrace=no"; - - push @configureparams, "--enable-minimal=$iosMinimalCommon,ssa,jit,reflection_emit_save,reflection_emit,portability,assembly_remapping,attach,verifier,full_messages,security,sgen_remset,sgen_marksweep_par,sgen_marksweep_fixed,sgen_marksweep_fixed_par,sgen_copying,logging"; - - push @configureparams, "mono_cv_uscore=yes"; - push @configureparams, "cv_mono_sizeof_sunpath=104"; - push @configureparams, "ac_cv_func_posix_getpwuid_r=yes"; - push @configureparams, "ac_cv_func_backtrace_symbols=no"; - push @configureparams, "ac_cv_func_finite=no"; - push @configureparams, "ac_cv_header_curses_h=no"; - } - elsif ($iphoneSimulator) - { - my $iosSdkVersion = "9.3"; - my $iosSimMinVersion = "4.3"; - my $iosSdkRoot = "$iosBuildEnvDir/builds/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator$iosSdkVersion.sdk"; - - print(">>> iOS Sim Build Environment = $iosBuildEnvDir\n"); - print(">>> iOS Sim SDK Version = $iosSdkVersion\n"); - print(">>> iOS Sim SDK Root = $iosSdkRoot\n"); - print(">>> iOS Sim Arch = $iphoneSimulatorArch\n"); - - $ENV{PATH} = "$iosSdkRoot/usr/bin:$ENV{PATH}"; - - $ENV{MACSDKOPTIONS} = "$iosCFlagsCommon -D_XOPEN_SOURCE=1 -g -O0 -DTARGET_IPHONE_SIMULATOR -mios-simulator-version-min=$iosSimMinVersion -isysroot $iosSdkRoot"; - $ENV{CFLAGS} = "-arch $iphoneSimulatorArch $ENV{MACSDKOPTIONS}"; - $ENV{CXXFLAGS} = "$ENV{CFLAGS}"; - $ENV{CPPFLAGS} = "$ENV{CFLAGS}"; - $ENV{CC} = "$iosBuildEnvDir/builds/Xcode.app/Contents/Developer/usr/bin/gcc"; - $ENV{CXX} = "$iosBuildEnvDir/builds/Xcode.app/Contents/Developer/usr/bin/g++"; - - print "\n"; - print ">>> Environment:\n"; - print ">>> \tCC = $ENV{CC}\n"; - print ">>> \tCXX = $ENV{CXX}\n"; - print ">>> \tLD = $ENV{LD}\n"; - print ">>> \tCFLAGS = $ENV{CFLAGS}\n"; - print ">>> \tCXXFLAGS = $ENV{CXXFLAGS}\n"; - print ">>> \tCPPFLAGS = $ENV{CPPFLAGS}\n"; - print ">>> \tMACSDKOPTIONS = $ENV{MACSDKOPTIONS}\n"; - - push @configureparams, "--host=$iphoneSimulatorArch-apple-darwin$darwinVersion"; - push @configureparams, "--enable-minimal=$iosMinimalCommon"; - - push @configureparams, "mono_cv_uscore=yes"; - push @configureparams, "ac_cv_func_clock_nanosleep=no"; - } - else - { - die("This should not be hit\n"); - } - } - elsif ($iphoneCross) - { - if ($runningOnWindows) - { - die("Not implemented\n"); - } - else - { - $ENV{CFLAGS} = "-DMONOTOUCH -DARM_FPU_VFP=1 -DUSE_MUNMAP -DPLATFORM_IPHONE_XCOMP -mmacosx-version-min=$macversion"; - $ENV{CXXFLAGS} = "-mmacosx-version-min=$macversion -stdlib=libc++"; - $ENV{CPPFLAGS} = "$ENV{CFLAGS} -mmacosx-version-min=$macversion"; - - $ENV{CC} = "$macSdkPath/../usr/bin/clang -arch i386"; - $ENV{CXX} = "$macSdkPath/../usr/bin/clang++ -arch i386"; - $ENV{CPP} = "$ENV{CC} -E"; - $ENV{LD} = $ENV{CC}; - $ENV{LDFLAGS} = "-stdlib=libc++"; - $ENV{MACSDKOPTIONS} = "-mmacosx-version-min=$macversion -isysroot $macSdkPath"; - - print "\n"; - print ">>> Environment:\n"; - print ">>> \tCC = $ENV{CC}\n"; - print ">>> \tCXX = $ENV{CXX}\n"; - print ">>> \tLD = $ENV{LD}\n"; - print ">>> \tCFLAGS = $ENV{CFLAGS}\n"; - print ">>> \tCXXFLAGS = $ENV{CXXFLAGS}\n"; - print ">>> \tCPPFLAGS = $ENV{CPPFLAGS}\n"; - print ">>> \tLDFLAGS = $ENV{LDFLAGS}\n"; - print ">>> \tMACSDKOPTIONS = $ENV{MACSDKOPTIONS}\n"; - - push @configureparams, "--cache-file=iphone-cross.cache" if ($enableCacheFile); - - push @configureparams, "--with-sigaltstack=no"; - push @configureparams, "--disable-shared-handles"; - push @configureparams, "--with-tls=pthread"; - - push @configureparams, "--target=arm-darwin"; - push @configureparams, "--with-macversion=$macversion"; - push @configureparams, "--with-cross-offsets=$iphoneCrossAbi.h"; - - push @configureparams, "--build=i386-apple-darwin10"; - push @configureparams, "--disable-libraries"; - push @configureparams, "--enable-icall-symbol-map"; - push @configureparams, "--enable-minimal=com,remoting"; - - #push @configureparams, "--enable-llvm"; - #push @configureparams, "--with-llvm=llvm/usr"; - - my @mcsArgs = (); - push @mcsArgs, "$monoroot/tools/offsets-tool/MonoAotOffsetsDumper.cs"; - push @mcsArgs, "$monoroot/mcs/class/Mono.Options/Mono.Options/Options.cs"; - push @mcsArgs, "/r:$externalBuildDeps/CppSharpBinaries/CppSharp.AST.dll"; - push @mcsArgs, "/r:$externalBuildDeps/CppSharpBinaries/CppSharp.Generator.dll"; - push @mcsArgs, "/r:$externalBuildDeps/CppSharpBinaries/CppSharp.Parser.CSharp.dll"; - push @mcsArgs, "/r:$externalBuildDeps/CppSharpBinaries/CppSharp.Parser.dll"; - push @mcsArgs, "/r:$externalBuildDeps/CppSharpBinaries/CppSharp.dll"; - push @mcsArgs, "/debug"; - push @mcsArgs, "/nowarn:0436"; - push @mcsArgs, "/out:$monoroot/tools/offsets-tool/MonoAotOffsetsDumper.exe"; - - print ">>> Compiling MonoAotOffsetDumper : $iphoneCrossMonoBinToUse/mcs @mcsArgs\n"; - system("$iphoneCrossMonoBinToUse/mcs", @mcsArgs) eq 0 or die("failed to compile MonoAotOffsetsDumper\n"); - - # clean up any pre-existing offset header just in case - if (-f "$monoroot/$iphoneCrossAbi.h") - { - system("rm", "-rf", "$iphoneCrossAbi.h"); - } - } - } - elsif ($android) - { - if (!(-d $externalBuildDeps)) - { - die("mono build deps are required and the directory was not found : $externalBuildDeps\n"); - } - - my $ndkVersion = "r13b"; - my $isArmArch = 1; - my $toolchainName = ""; - my $platformRootPostfix = ""; - my $useKraitPatch = 1; - my $kraitPatchPath = "$monoroot/../../android_krait_signal_handler/build"; - my $toolChainExtension = ""; - - $isArmArch = 0 if ($androidArch eq "x86"); - - $ENV{ANDROID_PLATFORM} = "android-9"; - $ENV{GCC_VERSION} = "4.9"; - - if ($isArmArch) - { - $ENV{GCC_PREFIX} = "arm-linux-androideabi-"; - $toolchainName = "$ENV{GCC_PREFIX}$ENV{GCC_VERSION}"; - $platformRootPostfix = "arm"; - } - else - { - $ENV{GCC_PREFIX} = "i686-linux-android-"; - $toolchainName = "x86-$ENV{GCC_VERSION}"; - $platformRootPostfix = "x86"; - $useKraitPatch = 0; - } - - if ($^O eq "linux") - { - $ENV{HOST_ENV} = "linux"; - } - elsif ($^O eq 'darwin') - { - $ENV{HOST_ENV} = "darwin"; - } - else - { - $ENV{HOST_ENV} = "windows"; - } - - print "\n"; - print(">>> Android Platform = $ENV{ANDROID_PLATFORM}\n"); - print(">>> Android NDK Version = $ndkVersion\n"); - print(">>> Android GCC Prefix = $ENV{GCC_PREFIX}\n"); - print(">>> Android GCC Version = $ENV{GCC_VERSION}\n"); - - my $ndkName = ""; - if($^O eq "linux") - { - $ndkName = "android-ndk-$ndkVersion-linux-x86_64.zip"; - } - elsif($^O eq "darwin") - { - $ndkName = "android-ndk-$ndkVersion-darwin-x86_64.zip"; - } - else - { - $ndkName = "android-ndk-$ndkVersion-windows-x86.zip"; - } - - my $depsNdkArchive = "$externalBuildDeps/$ndkName"; - my $depsNdkFinal = "$externalBuildDeps/android-ndk-$ndkVersion"; - - print(">>> Android NDK Archive = $depsNdkArchive\n"); - print(">>> Android NDK Extraction Destination = $depsNdkFinal\n"); - print("\n"); - - $ENV{ANDROID_NDK_ROOT} = "$depsNdkFinal"; - - if (-d $depsNdkFinal) - { - print(">>> Android NDK already extracted\n"); - } - else - { - print(">>> Android NDK needs to be extracted\n"); - - if ($runningOnWindows) - { - my $sevenZip = "$externalBuildDeps/7z/win64/7za.exe"; - my $winDepsNdkArchive = `cygpath -w $depsNdkArchive`; - my $winDepsNdkExtract = `cygpath -w $externalBuildDeps`; - - # clean up trailing new lines that end up in the output from cygpath. If left, they cause problems down the line - # for 7zip - $winDepsNdkArchive =~ s/\n+$//; - $winDepsNdkExtract =~ s/\n+$//; - - system($sevenZip, "x", "$winDepsNdkArchive", "-o$winDepsNdkExtract"); - } - else - { - my ($name,$path,$suffix) = fileparse($depsNdkArchive, qr/\.[^.]*/); - - print(">>> Android NDK Extension = $suffix\n"); - - # Versions after r11 use .zip extension. Currently we use r10e, but let's support the .zip extension in case - # we upgrade down the road - if (lc $suffix eq '.zip') - { - system("unzip", "-q", $depsNdkArchive, "-d", $externalBuildDeps); - } - elsif (lc $suffix eq '.bin') - { chmod(0755, $depsNdkArchive); - system($depsNdkArchive, "-o$externalBuildDeps"); - } - else - { - die "Unknown file extension '" . $suffix . "'\n"; - } - } - } - - if (!(-f "$ENV{ANDROID_NDK_ROOT}/ndk-build")) - { - die("Something went wrong with the NDK extraction\n"); - } - - my $androidNdkRoot = $ENV{ANDROID_NDK_ROOT}; - my $androidPlatformRoot = "$androidNdkRoot/platforms/$ENV{ANDROID_PLATFORM}/arch-$platformRootPostfix"; - my $androidToolchain = "$androidNdkRoot/toolchains/$toolchainName/prebuilt/$ENV{HOST_ENV}"; - - if (!(-d "$androidToolchain")) - { - if (-d "$androidToolchain-x86") - { - $androidToolchain = "$androidToolchain-x86"; - } - else - { - $androidToolchain = "$androidToolchain-x86_64"; - } - } - - if ($runningOnWindows) - { - $toolChainExtension = ".exe"; - - $androidPlatformRoot = `cygpath -w $androidPlatformRoot`; - # clean up trailing new lines that end up in the output from cygpath. - $androidPlatformRoot =~ s/\n+$//; - # Switch over to forward slashes. They propagate down the toolchain correctly - $androidPlatformRoot =~ s/\\/\//g; - - # this will get passed as a path to the linker, so we need to windows-ify the path - $kraitPatchPath = `cygpath -w $kraitPatchPath`; - $kraitPatchPath =~ s/\n+$//; - $kraitPatchPath =~ s/\\/\//g; - } - - print(">>> Android Arch = $androidArch\n"); - print(">>> Android NDK Root = $androidNdkRoot\n"); - print(">>> Android Platform Root = $androidPlatformRoot\n"); - print(">>> Android Toolchain = $androidToolchain\n"); - - if (!(-d "$androidToolchain")) - { - die("Failed to locate android toolchain\n"); - } - - if (!(-d "$androidPlatformRoot")) - { - die("Failed to locate android platform root\n"); - } - - if ("$androidArch" eq 'armv5') - { - $ENV{CFLAGS} = "-DARM_FPU_NONE=1 -march=armv5te -mtune=xscale -msoft-float"; - } - elsif ("$androidArch" eq 'armv6_vfp') - { - $ENV{CFLAGS} = "-DARM_FPU_VFP=1 -march=armv6 -mtune=xscale -msoft-float -mfloat-abi=softfp -mfpu=vfp -DHAVE_ARMV6=1"; - } - elsif ("$androidArch" eq 'armv7a') - { - $ENV{CFLAGS} = "-DARM_FPU_VFP=1 -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -DHAVE_ARMV6=1"; - $ENV{LDFLAGS} = "-Wl,--fix-cortex-a8"; - } - elsif ("$androidArch" eq 'x86') - { - $ENV{LDFLAGS} = "-lgcc" - } - else - { - die("Unsupported android arch : $androidArch\n"); - } - - if ($isArmArch) - { - $ENV{CFLAGS} = "-funwind-tables $ENV{CFLAGS}"; - $ENV{LDFLAGS} = "-Wl,-rpath-link=$androidPlatformRoot/usr/lib $ENV{LDFLAGS}"; - } - - $ENV{PATH} = "$androidToolchain/bin:$ENV{PATH}"; - $ENV{CC} = "$androidToolchain/bin/$ENV{GCC_PREFIX}gcc$toolChainExtension --sysroot=$androidPlatformRoot"; - $ENV{CXX} = "$androidToolchain/bin/$ENV{GCC_PREFIX}g++$toolChainExtension --sysroot=$androidPlatformRoot"; - $ENV{CPP} = "$androidToolchain/bin/$ENV{GCC_PREFIX}cpp$toolChainExtension"; - $ENV{CXXCPP} = "$androidToolchain/bin/$ENV{GCC_PREFIX}cpp$toolChainExtension"; - $ENV{CPATH} = "$androidPlatformRoot/usr/include"; - $ENV{LD} = "$androidToolchain/bin/$ENV{GCC_PREFIX}ld$toolChainExtension"; - $ENV{AS} = "$androidToolchain/bin/$ENV{GCC_PREFIX}as$toolChainExtension"; - $ENV{AR} = "$androidToolchain/bin/$ENV{GCC_PREFIX}ar$toolChainExtension"; - $ENV{RANLIB} = "$androidToolchain/bin/$ENV{GCC_PREFIX}ranlib$toolChainExtension"; - $ENV{STRIP} = "$androidToolchain/bin/$ENV{GCC_PREFIX}strip$toolChainExtension"; - - $ENV{CFLAGS} = "-DANDROID -DPLATFORM_ANDROID -DLINUX -D__linux__ -DHAVE_USR_INCLUDE_MALLOC_H -DPAGE_SIZE=0x1000 -D_POSIX_PATH_MAX=256 -DS_IWRITE=S_IWUSR -DHAVE_PTHREAD_MUTEX_TIMEDLOCK -fpic -g -ffunction-sections -fdata-sections $ENV{CFLAGS}"; - $ENV{CXXFLAGS} = $ENV{CFLAGS}; - $ENV{CPPFLAGS} = $ENV{CFLAGS}; - - if ($useKraitPatch) - { - $ENV{LDFLAGS} = "-Wl,--wrap,sigaction -L$kraitPatchPath/obj/local/armeabi -lkrait-signal-handler $ENV{LDFLAGS}"; - } - - $ENV{LDFLAGS} = "-Wl,--no-undefined -Wl,--gc-sections -ldl -lm -llog -lc $ENV{LDFLAGS}"; - - print "\n"; - print ">>> Environment:\n"; - print ">>> \tCC = $ENV{CC}\n"; - print ">>> \tCXX = $ENV{CXX}\n"; - print ">>> \tCPP = $ENV{CPP}\n"; - print ">>> \tCXXCPP = $ENV{CXXCPP}\n"; - print ">>> \tCPATH = $ENV{CPATH}\n"; - print ">>> \tLD = $ENV{LD}\n"; - print ">>> \tAS = $ENV{AS}\n"; - print ">>> \tAR = $ENV{AR}\n"; - print ">>> \tRANLIB = $ENV{RANLIB}\n"; - print ">>> \tSTRIP = $ENV{STRIP}\n"; - print ">>> \tCFLAGS = $ENV{CFLAGS}\n"; - print ">>> \tCXXFLAGS = $ENV{CXXFLAGS}\n"; - print ">>> \tCPPFLAGS = $ENV{CPPFLAGS}\n"; - print ">>> \tLDFLAGS = $ENV{LDFLAGS}\n"; - - if ($useKraitPatch) - { - my $kraitPatchRepo = "git://github.com/Unity-Technologies/krait-signal-handler.git"; - if (-d "$kraitPatchPath") - { - print ">>> Krait patch repository already cloned\n"; - } - else - { - system("git", "clone", "--branch", "master", "$kraitPatchRepo", "$kraitPatchPath") eq 0 or die ('failing cloning Krait patch'); - } - - chdir("$kraitPatchPath") eq 1 or die ("failed to chdir to krait patch directory\n"); - system('$ANDROID_NDK_ROOT/ndk-build clean') eq 0 or die ('failing to clean Krait patch'); - system('$ANDROID_NDK_ROOT/ndk-build') eq 0 or die ('failing to build Krait patch'); - chdir("$monoroot") eq 1 or die ("failed to chdir to $monoroot\n"); - } - - if ($isArmArch) - { - push @configureparams, "--host=armv5-linux-androideabi"; - } - elsif ("$androidArch" eq 'x86') - { - push @configureparams, "--host=i686-linux-android"; - } - else - { - die("Unsupported android arch : $androidArch\n"); - } - - push @configureparams, "--cache-file=android-$androidArch.cache" if ($enableCacheFile); - - push @configureparams, "--disable-parallel-mark"; - push @configureparams, "--disable-shared-handles"; - push @configureparams, "--with-sigaltstack=no"; - push @configureparams, "--with-tls=pthread"; - push @configureparams, "--disable-visibility-hidden"; - push @configureparams, "mono_cv_uscore=yes"; - push @configureparams, "ac_cv_header_zlib_h=no" if($runningOnWindows); - } - elsif ($tizen) - { - if (!(-d $externalBuildDeps)) - { - die("mono build deps are required and the directory was not found : $externalBuildDeps\n"); - } - - my $sdkVersion = "2.4.0r1"; - my $isArmArch = 1; - - $isArmArch = 0 if ($tizenEmulator); - - $ENV{TIZEN_PLATFORM} = "tizen-2.4"; - - if ($tizenEmulator) - { - $ENV{TIZEN_ROOTSTRAP} = "mobile-2.4-emulator.core"; - } - else - { - $ENV{TIZEN_ROOTSTRAP} = "mobile-2.4-device.core"; - } - - if ($^O eq "linux") - { - $ENV{HOST_ENV} = "linux"; - } - elsif ($^O eq 'darwin') - { - $ENV{HOST_ENV} = "darwin"; - } - else - { - $ENV{HOST_ENV} = "windows"; - } - - print "\n"; - print(">>> Tizen Platform = $ENV{TIZEN_PLATFORM}\n"); - print(">>> Tizen SDK Version = $sdkVersion\n"); - - my $sdkName = "tizen-$sdkVersion-$ENV{HOST_ENV}.tar.bz2"; - my $depsSdkArchive = "$externalBuildDeps/$sdkName"; - my $depsSdkFinal = "$externalBuildDeps/tizen-$sdkVersion-$ENV{HOST_ENV}"; - - print(">>> Tizen SDK Archive = $depsSdkArchive\n"); - print(">>> Tizen SDK Extraction Destination = $depsSdkFinal\n"); - print("\n"); - - $ENV{TIZEN_SDK_ROOT} = "$depsSdkFinal"; - - if (-d $depsSdkFinal) - { - print(">>> Tizen SDK already extracted\n"); - } - else - { - print(">>> Tizen SDK needs to be extracted\n"); - - if ($runningOnWindows) - { - my $sevenZip = "$externalBuildDeps/7z/win64/7za.exe"; - my $winDepsSdkArchive = `cygpath -w $depsSdkArchive`; - my $winDepsSdkExtract = `cygpath -w $externalBuildDeps`; - - # clean up trailing new lines that end up in the output from cygpath. If left, they cause problems down the line - # for 7zip - $winDepsSdkArchive =~ s/\n+$//; - $winDepsSdkExtract =~ s/\n+$//; - - system($sevenZip, "x", "$winDepsSdkArchive", "-o$winDepsSdkExtract"); - } - else - { - my ($name,$path,$suffix) = fileparse($depsSdkArchive, qr/\.[^.]*/); - - print(">>> Tizen SDK Extension = $suffix\n"); - - if (lc $suffix eq '.bz2') - { chmod(0755, $depsSdkArchive); - system("tar xjf $depsSdkArchive -C $externalBuildDeps") eq 0 or die ("failed to extract Tizen SDK\n"); - } - else - { - die "Unknown file extension '" . $suffix . "'\n"; - } - } - } - - if (!(-f "$ENV{TIZEN_SDK_ROOT}/tools/sdb")) - { - die("Something went wrong with the SDK extraction\n"); - } - - my $tizenSdkRoot = $ENV{TIZEN_SDK_ROOT}; - my $tizenPlatformRoot = "$tizenSdkRoot/platforms/$ENV{TIZEN_PLATFORM}/mobile/rootstraps/$ENV{TIZEN_ROOTSTRAP}"; - my $tizenToolchain = "$tizenSdkRoot/tools/llvm-3.6/bin"; - - if ($runningOnWindows) - { - $toolChainExtension = ".exe"; - - $tizenPlatformRoot = `cygpath -w $tizenPlatformRoot`; - # clean up trailing new lines that end up in the output from cygpath. - $tizenPlatformRoot =~ s/\n+$//; - # Switch over to forward slashes. They propagate down the toolchain correctly - $tizenPlatformRoot =~ s/\\/\//g; - } - - if ($tizenEmulator) - { - $tizenToolchain = "$tizenSdkRoot/tools/i386-linux-gnueabi-gcc-4.9/bin/i386"; - $ENV{CFLAGS} = "-Os -g -march=i686 -msse2 -mfpmath=sse"; - } - else - { - $tizenToolchain = "$tizenSdkRoot/tools/arm-linux-gnueabi-gcc-4.9/bin/arm"; - $ENV{CFLAGS} = "-Os -g -march=armv7-a -mfpu=vfp -mfloat-abi=softfp -DARM_FPU_VFP=1 -DHAVE_ARMV6=1"; - $ENV{LDFLAGS} = "-Wl,-rpath-link=$tizenPlatformRoot/usr/lib -L$tizenPlatformRoot/usr/lib $ENV{LDFLAGS}"; - } - - print(">>> Tizen SDK Root = $tizenSdkRoot\n"); - print(">>> Tizen Platform Root = $tizenPlatformRoot\n"); - print(">>> Tizen Toolchain Prefix = $tizenToolchain\n"); - - if (!(-d "$tizenPlatformRoot")) - { - die("Failed to locate Tizen platform root\n"); - } - - $ENV{PATH} = "$tizenToolchain/bin:$ENV{PATH}"; - $ENV{CC} = "$tizenToolchain-linux-gnueabi-gcc --sysroot=$tizenPlatformRoot"; - $ENV{CXX} = "$tizenToolchain-linux-gnueabi-g++ --sysroot=$tizenPlatformRoot"; - $ENV{CPP} = "$tizenToolchain-linux-gnueabi-cpp"; - $ENV{CXXCPP} = "$tizenToolchain-linux-gnueabi-cpp"; - $ENV{CPATH} = "$tizenPlatformRoot/usr/include"; - $ENV{LD} = "$tizenToolchain-linux-gnueabi-ld --sysroot=$tizenPlatformRoot"; - $ENV{AS} = "$tizenToolchain-linux-gnueabi-as"; - $ENV{STRIP} = "$tizenToolchain-linux-gnueabi-strip"; - - if ($tizenEmulator) - { - $ENV{AR} = "$ENV{TIZEN_SDK_ROOT}/tools/i386-linux-gnueabi-gcc-4.9/bin/i386-linux-gnueabi-ar"; - $ENV{RANLIB} = "$ENV{TIZEN_SDK_ROOT}/tools/i386-linux-gnueabi-gcc-4.9/bin/i386-linux-gnueabi-ranlib"; - } - else - { - $ENV{AR} = "$ENV{TIZEN_SDK_ROOT}/tools/arm-linux-gnueabi-gcc-4.9/bin/arm-linux-gnueabi-ar"; - $ENV{RANLIB} = "$ENV{TIZEN_SDK_ROOT}/tools/arm-linux-gnueabi-gcc-4.9/bin/arm-linux-gnueabi-ranlib"; - } - - $ENV{CFLAGS} = "-DTIZEN -DLINUX -D__linux__ -DHAVE_USR_INCLUDE_MALLOC_H -DPAGE_SIZE=0x1000 -D_POSIX_PATH_MAX=256 -DS_IWRITE=S_IWUSR -DHAVE_PTHREAD_MUTEX_TIMEDLOCK -fpic -g -ffunction-sections -fdata-sections $ENV{CFLAGS}"; - $ENV{CXXFLAGS} = $ENV{CFLAGS}; - $ENV{CPPFLAGS} = $ENV{CFLAGS}; - $ENV{LDFLAGS} = "-Wl,--no-undefined -ldlog -shared -Xlinker --as-needed $ENV{LDFLAGS}"; - - print "\n"; - print ">>> Environment:\n"; - print ">>> \tCC = $ENV{CC}\n"; - print ">>> \tCXX = $ENV{CXX}\n"; - print ">>> \tCPP = $ENV{CPP}\n"; - print ">>> \tCXXCPP = $ENV{CXXCPP}\n"; - print ">>> \tCPATH = $ENV{CPATH}\n"; - print ">>> \tLD = $ENV{LD}\n"; - print ">>> \tAS = $ENV{AS}\n"; - print ">>> \tAR = $ENV{AR}\n"; - print ">>> \tRANLIB = $ENV{RANLIB}\n"; - print ">>> \tSTRIP = $ENV{STRIP}\n"; - print ">>> \tCFLAGS = $ENV{CFLAGS}\n"; - print ">>> \tCXXFLAGS = $ENV{CXXFLAGS}\n"; - print ">>> \tCPPFLAGS = $ENV{CPPFLAGS}\n"; - print ">>> \tLDFLAGS = $ENV{LDFLAGS}\n"; - - if ($tizenEmulator) - { - push @configureparams, "--host=i386-tizen-linux-gnueabi"; - } - else - { - push @configureparams, "--host=arm-tizen-linux-gnueabi"; - } - - push @configureparams, "--cache-file=tizen-cross.cache" if ($enableCacheFile); - push @configureparams, "--disable-parallel-mark"; - push @configureparams, "--disable-shared-handles"; - push @configureparams, "--with-sigaltstack=no"; - push @configureparams, "--with-tls=pthread"; - push @configureparams, "--disable-visibility-hidden"; - push @configureparams, "--disable-executables"; - push @configureparams, "--with-gnu-ld=yes"; - push @configureparams, "mono_cv_uscore=yes"; - push @configureparams, "ac_cv_header_zlib_h=no" if($runningOnWindows); - } - elsif($^O eq "linux") - { - if (!(-d $externalBuildDeps)) - { - die("mono build deps are required and the directory was not found : $externalBuildDeps\n"); - } - - if($ENV{UNITY_THISISABUILDMACHINE} || $ENV{UNITY_USE_LINUX_SDK}) - { - my $sdkVersion = '20170609'; - my $schroot = "LinuxBuildEnvironment-$sdkVersion"; - my @linuxToolchain = ('schroot', '-c', $schroot, '--'); - - print "\n"; - print(">>> Linux SDK Version = $sdkVersion\n"); - - my $sdkName = "linux-sdk-$sdkVersion.tar.bz2"; - my $depsSdkArchive = "$externalBuildDeps/$sdkName"; - my $depsSdkFinal = "$externalBuildDeps/linux-sdk-$sdkVersion"; - - print(">>> Linux SDK Archive = $depsSdkArchive\n"); - print(">>> Linux SDK Extraction Destination = $depsSdkFinal\n"); - print("\n"); - - my $linuxSdkRoot = $depsSdkFinal; - - if (-d $depsSdkFinal) - { - print(">>> Linux SDK already extracted\n"); - } - else - { - print(">>> Linux SDK needs to be extracted\n"); - system('mkdir', '-p', $depsSdkFinal); - system('tar', 'xaf', $depsSdkArchive, '-C', $depsSdkFinal) eq 0 or die ("failed to extract Linux SDK\n"); - system('sudo', 'cp', '-R', "$depsSdkFinal/linux-sdk-$sdkVersion", '/etc/schroot'); - system("sed 's,^directory=.*,directory=$depsSdkFinal/$schroot,' \"$depsSdkFinal/$schroot.conf\" | sudo tee /etc/schroot/chroot.d/$schroot.conf") eq 0 or die ("failed to deploy Linux SDK\n"); - } - - @commandPrefix = @linuxToolchain; - print(">>> Linux SDK Root = $linuxSdkRoot\n"); - print(">>> Linux Toolchain Command Prefix = " . join(' ', @commandPrefix) . "\n"); - } - - push @configureparams, "--host=$monoHostArch-pc-linux-gnu"; - - push @configureparams, "--disable-parallel-mark"; #this causes crashes - - my $archflags = ''; - if ($arch32) - { - $archflags = '-m32'; - } - else - { - $archflags = '-fPIC'; - } - - if ($debug) - { - $ENV{CFLAGS} = "$archflags -g -O0"; - } - else - { - $ENV{CFLAGS} = "$archflags -Os"; #optimize for size - } - } - elsif($^O eq 'darwin') - { - # Set up mono for bootstrapping - if ($existingMonoRootPath eq "") - { - # Find the latest mono version and use that for boostrapping - my $monoInstalls = '/Library/Frameworks/Mono.framework/Versions'; - my @monoVersions = (); - - opendir( my $DIR, $monoInstalls ); - while ( my $entry = readdir $DIR ) - { - next unless -d $monoInstalls . '/' . $entry; - next if $entry eq '.' or $entry eq '..' or $entry eq 'Current'; - push @monoVersions, $entry; - } - closedir $DIR; - @monoVersions = sort @monoVersions; - my $monoVersionToUse = pop @monoVersions; - $existingMonoRootPath = "$monoInstalls/$monoVersionToUse"; - } - - $mcs = "EXTERNAL_MCS=$existingMonoRootPath/bin/mcs"; - - $ENV{'CC'} = "$macSdkPath/../usr/bin/clang"; - $ENV{'CXX'} = "$macSdkPath/../usr/bin/clang++"; - $ENV{'CFLAGS'} = $ENV{MACSDKOPTIONS} = "-D_XOPEN_SOURCE -I$macBuildEnvDir/builds/usr/include -mmacosx-version-min=$macversion -isysroot $macSdkPath"; - - $ENV{CFLAGS} = "$ENV{CFLAGS} -g -O0" if $debug; - $ENV{CFLAGS} = "$ENV{CFLAGS} -Os" if not $debug; #optimize for size - - $ENV{CC} = "$ENV{CC} -arch $monoHostArch"; - $ENV{CXX} = "$ENV{CXX} -arch $monoHostArch"; - - # Add OSX specific autogen args - push @configureparams, "--host=$monoHostArch-apple-darwin12.2.0"; - - # Need to define because Apple's SIP gets in the way of us telling mono where to find this - push @configureparams, "--with-libgdiplus=$addtoresultsdistdir/lib/libgdiplus.dylib"; - push @configureparams, "--enable-minimal=shared_perfcounters"; - - print "\n"; - print ">>> Setting environment:\n"; - print ">>> PATH = ".$ENV{PATH}."\n"; - print ">>> C_INCLUDE_PATH = ".$ENV{C_INCLUDE_PATH}."\n"; - print ">>> CPLUS_INCLUDE_PATH = ".$ENV{CPLUS_INCLUDE_PATH}."\n"; - print ">>> CFLAGS = ".$ENV{CFLAGS}."\n"; - print ">>> CXXFLAGS = ".$ENV{CXXFLAGS}."\n"; - print ">>> CC = ".$ENV{CC}."\n"; - print ">>> CXX = ".$ENV{CXX}."\n"; - print ">>> CPP = ".$ENV{CPP}."\n"; - print ">>> CXXPP = ".$ENV{CXXPP}."\n"; - print ">>> LD = ".$ENV{LD}."\n"; - print ">>> LDFLAGS = ".$ENV{LDFLAGS}."\n"; - print "\n"; - } - else - { - push @configureparams, "--host=$monoHostArch-pc-mingw32"; - } - - if ($isDesktopBuild) - { - my $cacheArch = $arch32 ? "i386" : "x86_64"; - push @configureparams, "--cache-file=desktop-$cacheArch.cache" if ($enableCacheFile); - } - - print ">>> Existing Mono : $existingMonoRootPath\n\n"; - $ENV{'PATH'} = "$existingMonoRootPath/$existingExternalMonoBinDir:$ENV{'PATH'}"; - - print ">>> PATH before Build = $ENV{PATH}\n\n"; - - print(">>> mcs Information : \n"); - system(@commandPrefix, ("which", "mcs")); - system(@commandPrefix, ("mcs", "--version")); - print("\n"); - - print ">>> Checking on some tools...\n"; - system(@commandPrefix, ("which", "autoconf")); - system(@commandPrefix, ("autoconf", "--version")); - - system(@commandPrefix, ("which", "texi2dvi")); - system(@commandPrefix, ("texi2dvi", "--version")); - - system(@commandPrefix, ("which", "automake")); - system(@commandPrefix, ("automake", "--version")); - - system(@commandPrefix, ("which", "libtool")); - system(@commandPrefix, ("libtool", "--version")); - - system(@commandPrefix, ("which", "libtoolize")); - system(@commandPrefix, ("libtoolize", "--version")); - print("\n"); - - print ">>> LIBTOOLIZE before Build = $ENV{LIBTOOLIZE}\n"; - print ">>> LIBTOOL before Build = $ENV{LIBTOOL}\n"; - - chdir("$monoroot") eq 1 or die ("failed to chdir 2\n"); - - if (not $skipMonoMake) - { - if ($clean) - { - if (!($mcsOnly)) - { - print(">>> Cleaning $monoprefix\n"); - rmtree($monoprefix); - } - - # Avoid "source directory already configured" ... - system(@commandPrefix, ('rm', '-f', 'config.status', 'eglib/config.status', 'libgc/config.status')); - - print("\n>>> Calling autogen in mono\n"); - print("\n"); - print("\n>>> Configure parameters are : @configureparams\n"); - print("\n"); - - system(@commandPrefix, ('./autogen.sh', @configureparams)) eq 0 or die ('failing autogenning mono'); - - if ($mcsOnly) - { - print("\n>>> Calling make clean in mcs\n"); - chdir("$monoroot/mcs"); - system(@commandPrefix, ("make","clean")) eq 0 or die ("failed to make clean\n"); - chdir("$monoroot"); - } - else - { - print("\n>>> Calling make clean in mono\n"); - system(@commandPrefix, ("make","clean")) eq 0 or die ("failed to make clean\n"); - } - } - - # this step needs to run after configure - if ($iphoneCross || $iphone || $android || $tizen) - { - # This step generates the arm_dpimacros.h file, which is needed by the offset dumper - chdir("$monoroot/mono/arch/arm"); - system("make") eq 0 or die("failed to make in $monoroot/mono/arch/arm\n"); - chdir("$monoroot"); - } - - if ($iphoneCross) - { - my @monoArgs = (); - push @monoArgs, "$monoroot/tools/offsets-tool/MonoAotOffsetsDumper.exe"; - push @monoArgs, "--abi"; - push @monoArgs, "$iphoneCrossAbi"; - push @monoArgs, "--out"; - push @monoArgs, "$monoroot"; - push @monoArgs, "--mono"; - push @monoArgs, "$monoroot"; - push @monoArgs, "--maccore"; - push @monoArgs, "$monoroot"; - - $ENV{MONO_PATH} = "$externalBuildDeps/CppSharpBinaries"; - # Need to use 32bit mono because there is a native CppSharp dylib that will be used and there's only a 32bit version of it - print ">>> Running MonoAotOffsetDumper : arch -i386 $iphoneCrossMonoBinToUse/mono @monoArgs\n"; - system("arch", "-i386", "$iphoneCrossMonoBinToUse/mono", @monoArgs) eq 0 or die("failed to run MonoAotOffsetsDumper\n"); - } - - if ($mcsOnly) - { - print("\n>>> Calling make in mcs\n"); - chdir("$monoroot/mcs"); - my @makeCommand = (@commandPrefix, ('make', "-j$jobs")); - if($mcs ne '') - { - push(@makeCommand, $mcs); - } - system(@makeCommand) eq 0 or die ("Failed to make\n"); - chdir("$monoroot"); - } - else - { - print("\n>>> Calling make\n"); - my @makeCommand = (@commandPrefix, ('make', "-j$jobs")); - if($mcs ne '') - { - push(@makeCommand, $mcs); - } - system(@makeCommand) eq 0 or die ("Failed to make\n"); - } - - if ($isDesktopBuild) - { - print("\n>>> Calling make install\n"); - system(@commandPrefix, ('make', 'install')) eq 0 or die ("Failed to make install\n"); - } - else - { - if ($disableMcs) - { - print(">>> Skipping make install. We don't need to run this step when building the runtime on non-desktop platforms.\n"); - } - else - { - # Note by Mike : make install on Windows for android runtime runs into more cygwin path issues. The one I hit was related to ranlib.exe being passed cygwin linux paths - # and as a result not being able to find stuff. The previous build scripts didn't run make install for android or iOS, so I think we are fine to skip this step. - # However, if we were to build the class libs for these cases, then we probably would need to run make install. If that day comes, we'll have to figure out what to do here. - print(">>> Attempting to build class libs for a non-desktop platform. The `make install` step is probably needed, but it has cygwin path related problems on Windows for android\n"); - die("Blocking this code path until we need it. It probably should be looked at more closely before letting it proceed\n"); - } - } - } - - if ($isDesktopBuild) - { - if ($^O eq "cygwin") - { - system("$winPerl", "$winMonoRoot/external/buildscripts/build_runtime_vs.pl", "--build=$build", "--arch32=$arch32", "--msbuildversion=$msBuildVersion", "--clean=$clean", "--debug=$debug") eq 0 or die ('failed building mono with VS\n'); - - # Copy over the VS built stuff that we want to use instead into the prefix directory - my $archNameForBuild = $arch32 ? 'Win32' : 'x64'; - my $config = $debug ? "Debug" : "Release"; - system("cp $monoroot/msvc/$archNameForBuild/bin/$config/mono.exe $monoprefix/bin/.") eq 0 or die ("failed copying mono.exe\n"); - system("cp $monoroot/msvc/$archNameForBuild/bin/$config/mono-2.0.dll $monoprefix/bin/.") eq 0 or die ("failed copying mono-2.0.dll\n"); - system("cp $monoroot/msvc/$archNameForBuild/bin/$config/mono-2.0.pdb $monoprefix/bin/.") eq 0 or die ("failed copying mono-2.0.pdb\n"); - } - - system("cp -R $addtoresultsdistdir/bin/. $monoprefix/bin/") eq 0 or die ("Failed copying $addtoresultsdistdir/bin to $monoprefix/bin\n"); - } - - if(!($disableMcs)) - { - my @additionalProfiles = (); - push @additionalProfiles, "unityjit"; - push @additionalProfiles, "unityaot"; - - chdir("$monoroot/mcs"); - foreach my $profileName(@additionalProfiles) - { - print(">>> Making profile : $profileName\n"); - system("make", "PROFILE=$profileName") eq 0 or die ("Failed to make $profileName profile in mcs\n"); - - my $profileDestDir = "$monoprefix/lib/mono/$profileName"; - print(">>> Copying $profileName to $profileDestDir directory\n"); - - print(">>> Cleaning $profileDestDir\n"); - system("rm -rf $profileDestDir"); - - system("mkdir -p $profileDestDir") eq 0 or die("failed to make directory $profileDestDir\n"); - system("mkdir -p $profileDestDir/Facades") eq 0 or die("failed to make directory $profileDestDir/Facades\n"); - - system("cp $monoroot/mcs/class/lib/$profileName/*.dll $profileDestDir") eq 0 or die("Failed copying dlls from $monoroot/mcs/class/lib/$profileName to $profileDestDir\n"); - system("cp $monoroot/mcs/class/lib/$profileName/Facades/*.dll $profileDestDir/Facades") eq 0 or die("Failed copying dlls from $monoroot/mcs/class/lib/$profileName/Facades to $profileDestDir/Facades\n"); - } - - chdir("$monoroot"); - - my $stubResult = system("perl", "$buildscriptsdir/stub_classlibs.pl"); - - if ($stubResult ne 0) - { - die("Failed to run the profile stubber\n"); - } - } -} -else -{ - print(">>> Skipping build\n"); -} - -if ($buildUsAndBoo) -{ - print(">>> Building Unity Script and Boo...\n"); - if($windowsSubsystemForLinux) - { - #boo scripts expect a bin-platform folder, but we haven't built them that way - system("ln -s $monoprefix/bin $monoprefix/bin-linux64"); - system("ln -s $monoprefix/bin $monoprefix/bin-linux32"); - } - - system(@commandPrefix, ("perl", "$buildscriptsdir/build_us_and_boo.pl", "--monoprefix=$monoprefix")) eq 0 or die ("Failed building Unity Script and Boo\n"); - - print(">>> Copying Unity Script and Boo *.Lang.dll's from 4.5 profile to unityjit profile...\n"); - system("cp $monoprefix/lib/mono/4.5/Boo*.dll $monoprefix/lib/mono/unityjit/.") eq 0 or die("Failed copying Boo*.dll\n"); - system("cp $monoprefix/lib/mono/4.5/UnityScript*.dll $monoprefix/lib/mono/unityjit/.") eq 0 or die("Failed copying UnityScript*.dll\n"); - system("cp $monoprefix/lib/mono/4.5/booc.exe $monoprefix/lib/mono/unityjit/.") eq 0 or die("Failed copying booc.exe\n"); - system("cp $monoprefix/lib/mono/4.5/us.exe $monoprefix/lib/mono/unityjit/.") eq 0 or die("Failed copying us.exe\n"); -} -else -{ - print(">>> Skipping build Unity Script and Boo\n"); -} - -if ($artifact) -{ - print(">>> Creating artifact...\n"); - - if ($artifactsCommon) - { - print(">>> Creating common artifacts...\n"); - print(">>> distribution directory = $distdir\n"); - - if (!(-d "$distdir")) - { - system("mkdir -p $distdir") eq 0 or die("failed to make directory $distdir\n"); - } - - $File::Copy::Recursive::CopyLink = 0; #make sure we copy files as files and not as symlinks, as TC unfortunately doesn't pick up symlinks. - - my $distdirlibmono = "$distdir/lib/mono"; - - print(">>> Cleaning $distdir/lib\n"); - system("rm -rf $distdir/lib"); - system("mkdir -p $distdir/lib"); - - print(">>> Creating normal profile artifacts...\n"); - system("cp -R $addtoresultsdistdir/. $distdir/") eq 0 or die ("Failed copying $addtoresultsdistdir to $distdir\n"); - - system("cp -r $monoprefix/lib/mono $distdir/lib"); - - if($^O ne 'darwin') - { - # On OSX we build a universal binary for 32-bit and 64-bit in the mono executable. The class library build - # only creates the 64-bit slice, so we don't want to end up with a single slice binary in the output. - # If we do, it will step on the universal binary produced but the OSX runtime build. - system("cp -r $monoprefix/bin $distdir/") eq 0 or die ("failed copying bin folder\n"); - } - system("cp -r $monoprefix/etc $distdir/") eq 0 or die("failed copying etc folder\n"); - - system("cp -R $externalBuildDeps/reference-assemblies/unity $distdirlibmono/unity"); - system("cp -R $externalBuildDeps/reference-assemblies/unity_web $distdirlibmono/unity_web"); - - system("cp -R $externalBuildDeps/reference-assemblies/unity/Boo*.dll $distdirlibmono/2.0-api"); - system("cp -R $externalBuildDeps/reference-assemblies/unity/UnityScript*.dll $distdirlibmono/2.0-api"); - - system("cp -R $externalBuildDeps/reference-assemblies/unity/Boo*.dll $distdirlibmono/4.0-api"); - system("cp -R $externalBuildDeps/reference-assemblies/unity/UnityScript*.dll $distdirlibmono/4.0-api"); - - system("cp -R $externalBuildDeps/reference-assemblies/unity/Boo*.dll $distdirlibmono/4.5-api"); - system("cp -R $externalBuildDeps/reference-assemblies/unity/UnityScript*.dll $distdirlibmono/4.5-api"); - - # now remove nunit from a couple places (but not all, we need some of them) - # linux tar is not happy these are removed(at least on wsl), so don't remove them for now - if(not $windowsSubsystemForLinux) - { - system("rm -rf $distdirlibmono/2.0/nunit*"); - system("rm -rf $distdirlibmono/gac/nunit*"); - } - - # Remove a self referencing sym link that causes problems - system("rm -rf $monoprefix/bin/bin"); - - if (-f "$monoroot/ZippedClasslibs.tar.gz") - { - system("rm -f $monoroot/ZippedClasslibs.tar.gz") eq 0 or die("Failed to clean existing ZippedClasslibs.tar.gz\n"); - } - - print(">>> Creating ZippedClasslibs.tar.gz\n"); - print(">>> Changing directory to : $buildsroot\n"); - chdir("$buildsroot"); - system("tar -hpczf ../ZippedClasslibs.tar.gz *") eq 0 or die("Failed to zip up classlibs\n"); - print(">>> Changing directory back to : $currentdir\n"); - chdir("$currentdir"); - } - - # Do the platform specific logic to create the builds output structure that we want - - my $embedDirRoot = "$buildsroot/embedruntimes"; - my $embedDirArchDestination = ""; - my $distDirArchBin = ""; - my $versionsOutputFile = ""; - my $crossCompilerRoot = "$buildsroot/crosscompiler"; - my $crossCompilerDestination = ""; - - if ($iphone) - { - $embedDirArchDestination = "$embedDirRoot/iphone/$iphoneArch"; - $versionsOutputFile = "$buildsroot/versions-iphone-$iphoneArch.txt"; - } - elsif ($iphoneCross) - { - $crossCompilerDestination = "$buildsroot/crosscompiler/iphone"; - $versionsOutputFile = "$buildsroot/versions-iphone-xcompiler.txt"; - } - elsif ($iphoneSimulator) - { - $embedDirArchDestination = "$embedDirRoot/iphone/$iphoneSimulatorArch"; - $versionsOutputFile = "$buildsroot/versions-iphone-$iphoneSimulatorArch.txt"; - } - elsif ($android) - { - $embedDirArchDestination = "$embedDirRoot/android/$androidArch"; - $versionsOutputFile = "$buildsroot/versions-android-$androidArch.txt"; - } - elsif ($tizenEmulator) - { - $embedDirArchDestination = "$embedDirRoot/tizenemulator/"; - $versionsOutputFile = "$buildsroot/versions-tizenemulator.txt"; - } - elsif ($tizen) - { - $embedDirArchDestination = "$embedDirRoot/tizen/"; - $versionsOutputFile = "$buildsroot/versions-tizen.txt"; - } - elsif($^O eq "linux") - { - $embedDirArchDestination = $arch32 ? "$embedDirRoot/linux32" : "$embedDirRoot/linux64"; - $distDirArchBin = $arch32 ? "$distdir/bin-linux32" : "$distdir/bin-linux64"; - $versionsOutputFile = $arch32 ? "$buildsroot/versions-linux32.txt" : "$buildsroot/versions-linux64.txt"; - } - elsif($^O eq 'darwin') - { - # Note these tmp directories will get merged into a single 'osx' directory later by a parent script - $embedDirArchDestination = "$embedDirRoot/osx-tmp-$monoHostArch"; - $distDirArchBin = "$distdir/bin-osx-tmp-$monoHostArch"; - $versionsOutputFile = $arch32 ? "$buildsroot/versions-osx32.txt" : "$buildsroot/versions-osx64.txt"; - } - else - { - $embedDirArchDestination = $arch32 ? "$embedDirRoot/win32" : "$embedDirRoot/win64"; - $distDirArchBin = $arch32 ? "$distdir/bin" : "$distdir/bin-x64"; - $versionsOutputFile = $arch32 ? "$buildsroot/versions-win32.txt" : "$buildsroot/versions-win64.txt"; - } - - # Make sure the directory for our architecture is clean before we copy stuff into it - if (-d "$embedDirArchDestination") - { - print(">>> Cleaning $embedDirArchDestination\n"); - rmtree($embedDirArchDestination); - } - - if (-d "$distDirArchBin") - { - print(">>> Cleaning $distDirArchBin\n"); - rmtree($distDirArchBin); - } - - if ($artifactsRuntime) - { - system("mkdir -p $embedDirArchDestination") if ($embedDirArchDestination ne ""); - system("mkdir -p $distDirArchBin") if ($distDirArchBin ne ""); - system("mkdir -p $crossCompilerDestination") if ($crossCompilerDestination ne ""); - - # embedruntimes directory setup - print(">>> Creating embedruntimes directory : $embedDirArchDestination\n"); - if ($iphone || $iphoneSimulator) - { - for my $file ('libmonosgen-2.0.a','libmonobdwgc-2.0.a') - { - print ">>> Copying $file\n"; - system("cp", "$monoroot/mono/mini/.libs/$file","$embedDirArchDestination/$file") eq 0 or die ("failed copying $file\n"); - } - } - elsif ($iphoneCross) - { - # Nothing to do - } - elsif ($android) - { - for my $file ('libmonosgen-2.0.so','libmonobdwgc-2.0.so') - { - print ">>> Copying $file\n"; - system("cp", "$monoroot/mono/mini/.libs/$file","$embedDirArchDestination/$file") eq 0 or die ("failed copying $file\n"); - } - print ">>> Copying libMonoPosixHelper.so\n"; - system("cp", "$monoroot/support/.libs/libMonoPosixHelper.so","$embedDirArchDestination/libMonoPosixHelper.so") eq 0 or die ("failed copying libMonoPosixHelper.so\n"); - } - elsif ($tizen || $tizenEmulator) - { - for my $file ('libmonosgen-2.0.so','libmonobdwgc-2.0.so') - { - print ">>> Copying $file\n"; - system("cp", "$monoroot/mono/mini/.libs/$file","$embedDirArchDestination/$file") eq 0 or die ("failed copying $file\n"); - } - } - elsif($^O eq "linux") - { - print ">>> Copying libmonosgen-2.0\n"; - system("cp", "$monoroot/mono/mini/.libs/libmonobdwgc-2.0.so","$embedDirArchDestination/libmonobdwgc-2.0.so") eq 0 or die ("failed copying libmonobdwgc-2.0.so\n"); - system("cp", "$monoroot/mono/mini/.libs/libmonosgen-2.0.so","$embedDirArchDestination/libmonosgen-2.0.so") eq 0 or die ("failed copying libmonosgen-2.0.so\n"); - - print ">>> Copying libMonoPosixHelper.so\n"; - system("cp", "$monoroot/support/.libs/libMonoPosixHelper.so","$embedDirArchDestination/libMonoPosixHelper.so") eq 0 or die ("failed copying libMonoPosixHelper.so\n"); - - if ($buildMachine) - { - system("strip $embedDirArchDestination/libmonobdwgc-2.0.so") eq 0 or die("failed to strip libmonobdwgc-2.0.so (shared)\n"); - system("strip $embedDirArchDestination/libmonosgen-2.0.so") eq 0 or die("failed to strip libmonosgen-2.0.so (shared)\n"); - system("strip $embedDirArchDestination/libMonoPosixHelper.so") eq 0 or die("failed to strip libMonoPosixHelper (shared)\n"); - } - } - elsif($^O eq 'darwin') - { - # embedruntimes directory setup - print ">>> Hardlinking libmonosgen-2.0\n"; - - system("ln","-f", "$monoroot/mono/mini/.libs/libmonobdwgc-2.0.dylib","$embedDirArchDestination/libmonobdwgc-2.0.dylib") eq 0 or die ("failed symlinking libmonobdwgc-2.0.dylib\n"); - system("ln","-f", "$monoroot/mono/mini/.libs/libmonosgen-2.0.dylib","$embedDirArchDestination/libmonosgen-2.0.dylib") eq 0 or die ("failed symlinking libmonosgen-2.0.dylib\n"); - - print "Hardlinking libMonoPosixHelper.dylib\n"; - system("ln","-f", "$monoroot/support/.libs/libMonoPosixHelper.dylib","$embedDirArchDestination/libMonoPosixHelper.dylib") eq 0 or die ("failed symlinking $libtarget/libMonoPosixHelper.dylib\n"); - - InstallNameTool("$embedDirArchDestination/libmonobdwgc-2.0.dylib", "\@executable_path/../Frameworks/MonoEmbedRuntime/osx/libmonobdwgc-2.0.dylib"); - InstallNameTool("$embedDirArchDestination/libmonosgen-2.0.dylib", "\@executable_path/../Frameworks/MonoEmbedRuntime/osx/libmonosgen-2.0.dylib"); - InstallNameTool("$embedDirArchDestination/libMonoPosixHelper.dylib", "\@executable_path/../Frameworks/MonoEmbedRuntime/osx/libMonoPosixHelper.dylib"); - - print ">>> Copying mono public headers\n"; - system("mkdir -p $includesroot/mono"); - system("cp -R $monoprefix/include/mono-2.0/mono $includesroot/mono"); - } - else - { - # embedruntimes directory setup - system("cp", "$monoprefix/bin/mono-2.0-bdwgc.dll", "$embedDirArchDestination/mono-2.0-bdwgc.dll") eq 0 or die ("failed copying mono-2.0-bdwgc.dll\n"); - system("cp", "$monoprefix/bin/mono-2.0-bdwgc.pdb", "$embedDirArchDestination/mono-2.0-bdwgc.pdb") eq 0 or die ("failed copying mono-2.0-bdwgc.pdb\n"); - - system("cp", "$monoprefix/bin/mono-2.0-sgen.dll", "$embedDirArchDestination/mono-2.0-sgen.dll") eq 0 or die ("failed copying mono-2.0-sgen.dll\n"); - system("cp", "$monoprefix/bin/mono-2.0-sgen.pdb", "$embedDirArchDestination/mono-2.0-sgen.pdb") eq 0 or die ("failed copying mono-2.0-sgen.pdb\n"); - } - - # monodistribution directory setup - print(">>> Creating monodistribution directory\n"); - if ($android || $iphone || $iphoneCross || $iphoneSimulator || $tizen || $tizenEmulator) - { - # Nothing to do - } - elsif($^O eq "linux") - { - my $distDirArchEtc = $arch32 ? "$distdir/etc-linux32" : "$distdir/etc-linux64"; - - if (-d "$distDirArchEtc") - { - print(">>> Cleaning $distDirArchEtc\n"); - rmtree($distDirArchEtc); - } - - system("mkdir -p $distDirArchBin"); - system("mkdir -p $distDirArchEtc"); - system("mkdir -p $distDirArchEtc/mono"); - - system("ln", "-f", "$monoroot/mono/mini/mono-sgen","$distDirArchBin/mono") eq 0 or die("failed symlinking mono executable\n"); - system("ln", "-f", "$monoroot/tools/pedump/pedump","$distDirArchBin/pedump") eq 0 or die("failed symlinking pedump executable\n"); - system('cp', "$monoroot/data/config","$distDirArchEtc/mono/config") eq 0 or die("failed to copy config\n"); - } - elsif($^O eq 'darwin') - { - system("ln", "-f", "$monoroot/mono/mini/mono","$distDirArchBin/mono") eq 0 or die("failed hardlinking mono executable\n"); - system("ln", "-f", "$monoroot/tools/pedump/pedump","$distDirArchBin/pedump") eq 0 or die("failed hardlinking pedump executable\n"); - } - else - { - system("cp", "$monoprefix/bin/mono-2.0.dll", "$distDirArchBin/mono-2.0.dll") eq 0 or die ("failed copying mono-2.0.dll\n"); - system("cp", "$monoprefix/bin/mono-2.0.pdb", "$distDirArchBin/mono-2.0.pdb") eq 0 or die ("failed copying mono-2.0.pdb\n"); - system("cp", "$monoprefix/bin/mono.exe", "$distDirArchBin/mono.exe") eq 0 or die ("failed copying mono.exe\n"); - } - } - - # cross compiler directory setup - if ($iphoneCross) - { - print ">>> Copying mono-xcompiler\n"; - if($runningOnWindows) - { - die("Not implemented\n"); - } - else - { - system("cp", "$monoroot/mono/mini/mono","$crossCompilerDestination/mono-xcompiler") eq 0 or die ("failed copying mono-xcompiler\n"); - } - } - - # Not all build configurations output to the distro dir, so only chmod it if it exists - system("chmod", "-R", "755", $distDirArchBin) if (-d "$distDirArchBin"); - - # Output version information - print(">>> Creating version file : $versionsOutputFile\n"); - system("echo \"mono-version =\" > $versionsOutputFile"); - - # Not all build configurations output to the distro dir, only try to output version info if there is a distro dir - system("$distDirArchBin/mono --version >> $versionsOutputFile") if (-d "$distDirArchBin"); - - system("echo \"unity-mono-revision = $monoRevision\" >> $versionsOutputFile"); - system("echo \"unity-mono-build-scripts-revision = $buildScriptsRevision\" >> $versionsOutputFile"); - my $tmp = `date`; - system("echo \"build-date = $tmp\" >> $versionsOutputFile"); -} -else -{ - print(">>> Skipping artifact creation\n"); -} - -if ($test) -{ - if ($runRuntimeTests) - { - my $runtimeTestsDir = "$monoroot/mono/mini"; - chdir("$runtimeTestsDir") eq 1 or die ("failed to chdir"); - print("\n>>> Calling make check in $runtimeTestsDir\n\n"); - system("make","check") eq 0 or die ("runtime tests failed\n"); - } - else - { - print(">>> Skipping runtime unit tests\n"); - } - - if ($runClasslibTests) - { - if ($disableMcs) - { - print(">>> Skipping classlib unit tests because building the class libs was disabled\n"); - } - else - { - my $classlibTestsDir = "$monoroot/mcs/class"; - chdir("$classlibTestsDir") eq 1 or die ("failed to chdir"); - print("\n>>> Calling make run-test in $runtimeTestsDir\n\n"); - system("make","run-test") eq 0 or die ("classlib tests failed\n"); - } - } - else - { - print(">>> Skipping classlib unit tests\n"); - } -} -else -{ - print(">>> Skipping unit tests\n"); -} - -chdir ($currentdir); +use Cwd; +use Cwd 'abs_path'; +use Getopt::Long; +use File::Basename; +use File::Path; +use lib ('external/buildscripts', "../../Tools/perl_lib","perl_lib", 'external/buildscripts/perl_lib'); +use Tools qw(InstallNameTool); + +print ">>> PATH in Build All = $ENV{PATH}\n\n"; + +my $currentdir = getcwd(); + +my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); +my $monoroot = abs_path($monoroot); + +my $buildscriptsdir = "$monoroot/external/buildscripts"; +my $addtoresultsdistdir = "$buildscriptsdir/add_to_build_results/monodistribution"; +my $buildsroot = "$monoroot/builds"; +my $includesroot = "$buildsroot/include"; +my $sourcesroot = "$buildsroot/source"; +my $distdir = "$buildsroot/monodistribution"; +my $buildMachine = $ENV{UNITY_THISISABUILDMACHINE}; + +# This script should not be ran on windows, if it is, kindly call the wrapper +# to switch over to cygwin +if ($^O eq "MSWin32") +{ + print(">>> build.pl called from Windows. Switching over to cygwin\n"); + system("perl", "$buildscriptsdir/build_win_wrapper.pl", @ARGV) eq 0 or die("\n"); + exit 0; +} + +system("source","~/.profile"); + +my $build=0; +my $clean=0; +my $jobs=8; +my $test=0; +my $artifact=0; +my $debug=0; +my $disableMcs=0; +my $mcsOnly=0; +my $buildUsAndBoo=0; +my $artifactsCommon=0; +my $artifactsRuntime=1; +my $runRuntimeTests=1; +my $runClasslibTests=1; +my $checkoutOnTheFly=0; +my $forceDefaultBuildDeps=0; +my $existingMonoRootPath = ''; +my $sdk = ''; +my $arch32 = 0; +my $winPerl = ""; +my $winMonoRoot = ""; +my $msBuildVersion = "14.0"; +my $buildDeps = ""; +my $android=0; +my $androidArch = ""; +my $iphone=0; +my $iphoneArch = ""; +my $iphoneCross=0; +my $iphoneSimulator=0; +my $iphoneSimulatorArch=""; +my $tizen=0; +my $tizenEmulator=0; +my $windowsSubsystemForLinux=0; + +# Handy troubleshooting/niche options +my $skipMonoMake=0; + +# The prefix hack probably isn't needed anymore. Let's disable it by default and see how things go +my $shortPrefix=1; + +# Disabled by default for now. causes more problems than it's worth when actively making changes to the build scripts. +# Would be okay to turn on once the build scripts stabilize and you just want to rebuild code changes +my $enableCacheFile=0; + +# Linux toolchain setup needs this +my @commandPrefix = (); + +print(">>> Build All Args = @ARGV\n"); + +GetOptions( + 'build=i'=>\$build, + 'clean=i'=>\$clean, + 'test=i'=>\$test, + 'artifact=i'=>\$artifact, + 'artifactscommon=i'=>\$artifactsCommon, + 'artifactsruntime=i'=>\$artifactsRuntime, + 'debug=i'=>\$debug, + 'disablemcs=i'=>\$disableMcs, + 'mcsonly=i'=>\$mcsOnly, + 'buildusandboo=i'=>\$buildUsAndBoo, + 'runtimetests=i'=>\$runRuntimeTests, + 'classlibtests=i'=>\$runClasslibTests, + 'arch32=i'=>\$arch32, + 'jobs=i'=>\$jobs, + 'sdk=s'=>\$sdk, + 'existingmono=s'=>\$existingMonoRootPath, + 'skipmonomake=i'=>\$skipMonoMake, + 'shortprefix=i'=>\$shortPrefix, + 'winperl=s'=>\$winPerl, + 'winmonoroot=s'=>\$winMonoRoot, + 'msbuildversion=s'=>\$msBuildVersion, + 'checkoutonthefly=i'=>\$checkoutOnTheFly, + 'builddeps=s'=>\$buildDeps, + 'forcedefaultbuilddeps=i'=>\$forceDefaultBuildDeps, + 'android=i'=>\$android, + 'androidarch=s'=>\$androidArch, + 'iphone=i'=>\$iphone, + 'iphonearch=s'=>\$iphoneArch, + 'iphonecross=i'=>\$iphoneCross, + 'iphonesimulator=i'=>\$iphoneSimulator, + 'tizen=i'=>\$tizen, + 'tizenemulator=i'=>\$tizenEmulator, + 'windowssubsystemforlinux=i'=>\$windowsSubsystemForLinux, + 'enablecachefile=i'=>\$enableCacheFile, +) or die ("illegal cmdline options"); + +print ">>> Mono checkout = $monoroot\n"; + +print(">> System Info : \n"); +system("uname", "-a"); + +my $monoRevision = `git rev-parse HEAD`; +chdir("$buildscriptsdir") eq 1 or die ("failed to chdir : $buildscriptsdir\n"); +my $buildScriptsRevision = `git rev-parse HEAD`; +chdir("$monoroot") eq 1 or die ("failed to chdir : $monoroot\n"); + +print(">>> Mono Revision = $monoRevision\n"); +print(">>> Build Scripts Revision = $buildScriptsRevision\n"); + +if ($androidArch ne "") +{ + $android = 1; +} + +if ($iphoneArch ne "") +{ + $iphone = 1; +} + +if($iphoneSimulator) +{ + if ($arch32) + { + $iphoneSimulatorArch = "i386"; + } + else + { + $iphoneSimulatorArch = "x86_64"; + } +} + +my $isDesktopBuild = 1; +if ($android || $iphone || $iphoneCross || $iphoneSimulator || $tizen || $tizenEmulator) +{ + $isDesktopBuild = 0; + + # Disable building of the class libraries by default when building the android runtime + # since we don't care about a class library build in this situation (as of writing this at least) + # but only if the test flag is not set. If the test flag was set, we'd need to build the classlibs + # in order to run the tests + $disableMcs = 1 if(!($test)); +} + +# Do any settings agnostic per-platform stuff +my $externalBuildDeps = ""; + +if ($buildDeps ne "" && not $forceDefaultBuildDeps) +{ + $externalBuildDeps = $buildDeps; +} +else +{ + $externalBuildDeps = "$monoroot/../../mono-build-deps/build"; +} + +# Only clean up the path if the directory exists, if it doesn't exist, +# abs_path ends up returning an empty string +$externalBuildDeps = abs_path($externalBuildDeps) if (-d $externalBuildDeps); + +my $extraBuildTools = "$monoroot/../../mono-build-tools-extra/build"; + +my $existingExternalMonoRoot = "$externalBuildDeps/MonoBleedingEdge"; +my $existingExternalMono = ""; +my $existingExternalMonoBinDir = ""; +my $monoHostArch = ""; +my $monoprefix = "$monoroot/tmp"; +my $runningOnWindows=0; +if($^O eq "linux") +{ + $monoHostArch = $arch32 ? "i686" : "x86_64"; + $existingExternalMono = "$existingExternalMonoRoot"; + $existingExternalMonoBinDir = "bin-linux64"; +} +elsif($^O eq 'darwin') +{ + $monoHostArch = $arch32 ? "i386" : "x86_64"; + $existingExternalMono = "$existingExternalMonoRoot"; + $existingExternalMonoBinDir = "bin"; + + # From Massi: I was getting failures in install_name_tool about space + # for the commands being too small, and adding here things like + # $ENV{LDFLAGS} = '-headerpad_max_install_names' and + # $ENV{LDFLAGS} = '-headerpad=0x40000' did not help at all (and also + # adding them to our final gcc invocation to make the bundle). + # Lucas noticed that I was lacking a Mono prefix, and having a long + # one would give us space, so here is this silly looong prefix. + if (not $shortPrefix) + { + $monoprefix = "$monoroot/tmp/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting"; + } +} +else +{ + $monoHostArch = "i686"; + $existingExternalMono = "$existingExternalMonoRoot"; + $existingExternalMonoBinDir = "bin-x64"; + $runningOnWindows = 1; + + # We only care about an existing mono if we need to build. + # So only do this path clean up if we are building. + if ($build) + { + if ($existingMonoRootPath ne "" && not $existingMonoRootPath =~ /^\/cygdrive/) + { + $existingMonoRootPath = `cygpath -u $existingMonoRootPath`; + chomp($existingMonoRootPath); + } + + $existingMonoRootPath =~ tr/\\//d; + } +} + +if ($runningOnWindows) +{ + # Fixes a line ending issue that happens on windows when we try to run autogen.sh + $ENV{'SHELLOPTS'} = "igncr"; +} + +print(">>> Existing Mono = $existingMonoRootPath\n"); +print(">>> Mono Arch = $monoHostArch\n"); + +if ($build) +{ + my $platformflags = ''; + my $host = ''; + my $mcs = ''; + + my $iphoneCrossAbi = "arm-apple-darwin10"; + my $iphoneCrossMonoBinToUse = "$monoroot/builds/monodistribution/bin"; + + my @configureparams = (); + + push @configureparams, "--disable-mcs-build" if($disableMcs); + push @configureparams, "--with-glib=embedded"; + push @configureparams, "--disable-nls"; #this removes the dependency on gettext package + push @configureparams, "--disable-btls"; #this removes the dependency on cmake to build btls for now + push @configureparams, "--with-mcs-docs=no"; + push @configureparams, "--prefix=$monoprefix"; + + if(!($disableMcs)) + { + push @configureparams, "--with-unityjit=yes"; + push @configureparams, "--with-unityaot=yes"; + } + + if ($isDesktopBuild) + { + push @configureparams, "--with-monotouch=no"; + } + + if (!(-d "$extraBuildTools")) + { + # Check out on the fly + print(">>> Checking out mono build tools extra to : $extraBuildTools\n"); + my $repo = 'git@gitlab.internal.unity3d.com:vm/mono-build-tools-extra.git'; + print(">>> Cloning $repo at $extraBuildTools\n"); + my $checkoutResult = system("git", "clone", "--recurse-submodules", $repo, "$extraBuildTools"); + + if ($checkoutResult ne 0) + { + die("Failed to checkout mono build tools extra\n"); + } + + # Only clean up if the dir exists. Otherwise abs_path will return empty string + $extraBuildTools = abs_path($extraBuildTools) if (-d $extraBuildTools); + } + + if ($existingMonoRootPath eq "") + { + print(">>> No existing mono supplied. Checking for external...\n"); + + if (!(-d "$externalBuildDeps")) + { + if (not $checkoutonthefly) + { + print(">>> No external build deps found. Might as well try to check them out. If it fails, we'll continue and trust mono is in your PATH\n"); + } + + # Check out on the fly + print(">>> Checking out mono build dependencies to : $externalBuildDeps\n"); + my $repo = "https://ono.unity3d.com/unity-extra/mono-build-deps"; + print(">>> Cloning $repo at $externalBuildDeps\n"); + my $checkoutResult = system("hg", "clone", $repo, "$externalBuildDeps"); + + if ($checkoutOnTheFly && $checkoutResult ne 0) + { + die("failed to checkout mono build dependencies\n"); + } + + # Only clean up if the dir exists. Otherwise abs_path will return empty string + $externalBuildDeps = abs_path($externalBuildDeps) if (-d $externalBuildDeps); + } + + if (-d "$existingExternalMono") + { + print(">>> External mono found at : $existingExternalMono\n"); + + if (-d "$existingExternalMono/builds") + { + print(">>> Mono already extracted at : $existingExternalMono/builds\n"); + } + + if (!(-d "$existingExternalMono/builds")) + { + # We need to extract builds.zip + print(">>> Extracting mono builds.zip...\n"); + system("unzip", "$existingExternalMono/builds.zip", "-d", "$existingExternalMono/builds") eq 0 or die("failed to extract mono builds.zip\n"); + } + + $existingMonoRootPath = "$existingExternalMono/builds/monodistribution"; + } + else + { + print(">>> No external mono found. Trusting a new enough mono is in your PATH.\n"); + } + } + + if ($existingMonoRootPath ne "" && !(-d $existingMonoRootPath)) + { + die("Existing mono not found at : $existingMonoRootPath\n"); + } + + if ($externalBuildDeps ne "") + { + print "\n"; + print ">>> Building autoconf, texinfo, automake, and libtool if needed...\n"; + my $autoconfVersion = "2.69"; + my $texinfoVersion = "4.8"; + my $automakeVersion = "1.15"; + my $libtoolVersion = "2.4.6"; + my $autoconfDir = "$externalBuildDeps/autoconf-$autoconfVersion"; + my $texinfoDir = "$externalBuildDeps/texinfo-$texinfoVersion"; + my $automakeDir = "$externalBuildDeps/automake-$automakeVersion"; + my $libtoolDir = "$externalBuildDeps/libtool-$libtoolVersion"; + my $builtToolsDir = "$externalBuildDeps/built-tools"; + + $ENV{PATH} = "$builtToolsDir/bin:$ENV{PATH}"; + + if (!(-d "$autoconfDir")) + { + chdir("$externalBuildDeps") eq 1 or die ("failed to chdir to external directory\n"); + system("tar xzf autoconf-$autoconfVersion.tar.gz") eq 0 or die ("failed to extract autoconf\n"); + + chdir("$autoconfDir") eq 1 or die ("failed to chdir to autoconf directory\n"); + system("./configure --prefix=$builtToolsDir") eq 0 or die ("failed to configure autoconf\n"); + system("make") eq 0 or die ("failed to make autoconf\n"); + system("make install") eq 0 or die ("failed to make install autoconf\n"); + + chdir("$monoroot") eq 1 or die ("failed to chdir to $monoroot\n"); + } + + if (!(-d "$texinfoDir") and $windowsSubsystemForLinux) + { + chdir("$externalBuildDeps") eq 1 or die ("failed to chdir to external directory\n"); + system("tar xzf texinfo-$texinfoVersion.tar.gz") eq 0 or die ("failed to extract texinfo\n"); + + chdir($texinfoDir) eq 1 or die ("failed to chdir to texinfo directory\n"); + system("./configure --prefix=$builtToolsDir") eq 0 or die ("failed to configure texinfo\n"); + system("make") eq 0 or die ("failed to make texinfo\n"); + system("make install") eq 0 or die ("failed to make install texinfo\n"); + + chdir("$monoroot") eq 1 or die ("failed to chdir to $monoroot\n"); + } + + if (!(-d "$automakeDir")) + { + my $automakeMakeFlags = ""; + chdir("$externalBuildDeps") eq 1 or die ("failed to chdir to external directory\n"); + system("tar xzf automake-$automakeVersion.tar.gz") eq 0 or die ("failed to extract automake\n"); + + chdir("$automakeDir") eq 1 or die ("failed to chdir to automake directory\n"); + if($windowsSubsystemForLinux) + { + #Windows subsystem needs to run bootstrap, and make needs to be run with -i due to one doc failing to build + system("./bootstrap.sh") eq 0 or die ("failed to bootstrap automake\n"); + $automakeMakeFlags = "-i"; + } + system("./configure --prefix=$builtToolsDir") eq 0 or die ("failed to configure automake\n"); + system("make $automakeMakeFlags") eq 0 or die ("failed to make automake\n"); + system("make install"); + chdir("$monoroot") eq 1 or die ("failed to chdir to $monoroot\n"); + } + + if (!(-d "$libtoolDir")) + { + chdir("$externalBuildDeps") eq 1 or die ("failed to chdir to external directory\n"); + system("tar xzf libtool-$libtoolVersion.tar.gz") eq 0 or die ("failed to extract libtool\n"); + + chdir("$libtoolDir") eq 1 or die ("failed to chdir to libtool directory\n"); + system("./configure --prefix=$builtToolsDir") eq 0 or die ("failed to configure libtool\n"); + system("make") eq 0 or die ("failed to make libtool\n"); + system("make install") eq 0 or die ("failed to make install libtool\n"); + + chdir("$monoroot") eq 1 or die ("failed to chdir to $monoroot\n"); + } + + $ENV{'LIBTOOLIZE'} = "$builtToolsDir/bin/libtoolize"; + $ENV{'LIBTOOL'} = "$builtToolsDir/bin/libtool"; + } + + my $macSdkPath = ""; + my $macversion = '10.8'; + my $darwinVersion = "10"; + if ($^O eq 'darwin') + { + if ($sdk eq '') + { + $sdk='10.11'; + } + + my $macBuildEnvDir = "$externalBuildDeps/MacBuildEnvironment"; + $macSdkPath = "$macBuildEnvDir/builds/MacOSX$sdk.sdk"; + if (! -d $macSdkPath) + { + print(">>> Unzipping mac build toolchain\n"); + system("$externalBuildDeps/unzip", '-qd', "$macBuildEnvDir", "$macBuildEnvDir/builds.zip") eq 0 or die ("failed unzipping mac build toolchain\n"); + } + } + + if ($iphone || $iphoneSimulator) + { + if ($runningOnWindows) + { + die("This build is not supported on Windows\n"); + } + + my $iosBuildEnvDir = "$externalBuildDeps/iOSBuildEnvironment"; + my $iosXcodeDefaultToolchainRoot = "$iosBuildEnvDir/builds/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain"; + + if (! -d "$iosBuildEnvDir/builds") + { + print(">>> Unzipping ios build toolchain\n"); + system("$externalBuildDeps/unzip", '-qd', "$iosBuildEnvDir/builds", "$iosBuildEnvDir/builds.zip") eq 0 or die ("failed unzipping ios build toolchain\n"); + } + + $ENV{PATH} = "$iosXcodeDefaultToolchainRoot/usr/bin:$iosBuildEnvDir/builds/Xcode.app/Contents/Developer/usr/bin:$ENV{PATH}"; + # Need to keep our libtool in front + $ENV{PATH} = "$externalBuildDeps/built-tools/bin:$ENV{PATH}"; + + push @configureparams, "--cache-file=iphone-$iphoneArch.cache" if ($enableCacheFile); + + my $iosMinimalCommon = "com,remoting,shared_perfcounters,appdomains"; + my $iosCFlagsCommon = "-DMONOTOUCH -DHOST_IOS -DDISABLE_POLICY_EVIDENCE=1 -DDISABLE_PROCESS_HANDLING=1"; + + push @configureparams, "--with-tls=pthread"; + push @configureparams, "--without-ikvm-native"; + push @configureparams, "--disable-executables"; + push @configureparams, "--disable-visibility-hidden"; + + if ($iphone) + { + my $iosSdkVersion = "9.3"; + my $iphoneOsMinVersion = "3.0"; + my $iosSdkRoot = "$iosBuildEnvDir/builds/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS$iosSdkVersion.sdk"; + + print(">>> iOS Build Environment = $iosBuildEnvDir\n"); + print(">>> iOS SDK Version = $iosSdkVersion\n"); + print(">>> iOS SDK Root = $iosSdkRoot\n"); + print(">>> iPhone Arch = $iphoneArch\n"); + + $ENV{PATH} = "$iosSdkRoot/usr/bin:$ENV{PATH}"; + + $ENV{C_INCLUDE_PATH} = "$iosSdkRoot/usr/include"; + $ENV{CPLUS_INCLUDE_PATH} = "$iosSdkRoot/usr/include"; + + $ENV{CC} = "$iosBuildEnvDir/builds/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch $iphoneArch"; + $ENV{CXX} = "$iosBuildEnvDir/builds/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch $iphoneArch"; + $ENV{LD} = "$iosBuildEnvDir/builds/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld"; + + $ENV{CFLAGS} = "$iosCFlagsCommon -gdwarf-2 -DSMALL_CONFIG -DHAVE_LARGE_FILE_SUPPORT=1 -DHAVE_ARMV6=1 -DARM_FPU_VFP=1 -Wl,-application_extension -miphoneos-version-min=$iphoneOsMinVersion -mno-thumb -Os -isysroot $iosSdkRoot"; + + # Unity defines + $ENV{CFLAGS} = "-DPLATFORM_IPHONE $ENV{CFLAGS}"; + + $ENV{CXXFLAGS} = "$ENV{CFLAGS} -U__powerpc__ -U__i386__ -D__arm__"; + $ENV{CPPFLAGS} = $ENV{CXXFLAGS}; + + $ENV{LDFLAGS} = "-arch $iphoneArch -liconv -lobjc -lc++ -Wl,-syslibroot,$iosSdkRoot"; + + print "\n"; + print ">>> Environment:\n"; + print ">>> \tCC = $ENV{CC}\n"; + print ">>> \tCXX = $ENV{CXX}\n"; + print ">>> \tLD = $ENV{LD}\n"; + print ">>> \tCFLAGS = $ENV{CFLAGS}\n"; + print ">>> \tCXXFLAGS = $ENV{CXXFLAGS}\n"; + print ">>> \tCPPFLAGS = $ENV{CPPFLAGS}\n"; + print ">>> \tLDFLAGS = $ENV{LDFLAGS}\n"; + print ">>> \tCPLUS_INCLUDE_PATH = $ENV{CPLUS_INCLUDE_PATH}\n"; + print ">>> \tC_INCLUDE_PATH = $ENV{C_INCLUDE_PATH}\n"; + + push @configureparams, "--host=arm-apple-darwin$darwinVersion"; + + push @configureparams, "--with-sigaltstack=no"; + push @configureparams, "--disable-shared-handles"; + push @configureparams, "--with-monotouch"; + + push @configureparams, "--enable-llvm-runtime"; + push @configureparams, "--with-bitcode=yes"; + + push @configureparams, "--with-lazy-gc-thread-creation=yes"; + push @configureparams, "--enable-icall-export"; + push @configureparams, "--enable-dtrace=no"; + + push @configureparams, "--enable-minimal=$iosMinimalCommon,ssa,jit,reflection_emit_save,reflection_emit,portability,assembly_remapping,attach,verifier,full_messages,security,sgen_remset,sgen_marksweep_par,sgen_marksweep_fixed,sgen_marksweep_fixed_par,sgen_copying,logging"; + + push @configureparams, "mono_cv_uscore=yes"; + push @configureparams, "cv_mono_sizeof_sunpath=104"; + push @configureparams, "ac_cv_func_posix_getpwuid_r=yes"; + push @configureparams, "ac_cv_func_backtrace_symbols=no"; + push @configureparams, "ac_cv_func_finite=no"; + push @configureparams, "ac_cv_header_curses_h=no"; + } + elsif ($iphoneSimulator) + { + my $iosSdkVersion = "9.3"; + my $iosSimMinVersion = "4.3"; + my $iosSdkRoot = "$iosBuildEnvDir/builds/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator$iosSdkVersion.sdk"; + + print(">>> iOS Sim Build Environment = $iosBuildEnvDir\n"); + print(">>> iOS Sim SDK Version = $iosSdkVersion\n"); + print(">>> iOS Sim SDK Root = $iosSdkRoot\n"); + print(">>> iOS Sim Arch = $iphoneSimulatorArch\n"); + + $ENV{PATH} = "$iosSdkRoot/usr/bin:$ENV{PATH}"; + + $ENV{MACSDKOPTIONS} = "$iosCFlagsCommon -D_XOPEN_SOURCE=1 -g -O0 -DTARGET_IPHONE_SIMULATOR -mios-simulator-version-min=$iosSimMinVersion -isysroot $iosSdkRoot"; + $ENV{CFLAGS} = "-arch $iphoneSimulatorArch $ENV{MACSDKOPTIONS}"; + $ENV{CXXFLAGS} = "$ENV{CFLAGS}"; + $ENV{CPPFLAGS} = "$ENV{CFLAGS}"; + $ENV{CC} = "$iosBuildEnvDir/builds/Xcode.app/Contents/Developer/usr/bin/gcc"; + $ENV{CXX} = "$iosBuildEnvDir/builds/Xcode.app/Contents/Developer/usr/bin/g++"; + + print "\n"; + print ">>> Environment:\n"; + print ">>> \tCC = $ENV{CC}\n"; + print ">>> \tCXX = $ENV{CXX}\n"; + print ">>> \tLD = $ENV{LD}\n"; + print ">>> \tCFLAGS = $ENV{CFLAGS}\n"; + print ">>> \tCXXFLAGS = $ENV{CXXFLAGS}\n"; + print ">>> \tCPPFLAGS = $ENV{CPPFLAGS}\n"; + print ">>> \tMACSDKOPTIONS = $ENV{MACSDKOPTIONS}\n"; + + push @configureparams, "--host=$iphoneSimulatorArch-apple-darwin$darwinVersion"; + push @configureparams, "--enable-minimal=$iosMinimalCommon"; + + push @configureparams, "mono_cv_uscore=yes"; + push @configureparams, "ac_cv_func_clock_nanosleep=no"; + } + else + { + die("This should not be hit\n"); + } + } + elsif ($iphoneCross) + { + if ($runningOnWindows) + { + die("Not implemented\n"); + } + else + { + $ENV{CFLAGS} = "-DMONOTOUCH -DARM_FPU_VFP=1 -DUSE_MUNMAP -DPLATFORM_IPHONE_XCOMP -mmacosx-version-min=$macversion"; + $ENV{CXXFLAGS} = "-mmacosx-version-min=$macversion -stdlib=libc++"; + $ENV{CPPFLAGS} = "$ENV{CFLAGS} -mmacosx-version-min=$macversion"; + + $ENV{CC} = "$macSdkPath/../usr/bin/clang -arch i386"; + $ENV{CXX} = "$macSdkPath/../usr/bin/clang++ -arch i386"; + $ENV{CPP} = "$ENV{CC} -E"; + $ENV{LD} = $ENV{CC}; + $ENV{LDFLAGS} = "-stdlib=libc++"; + $ENV{MACSDKOPTIONS} = "-mmacosx-version-min=$macversion -isysroot $macSdkPath"; + + print "\n"; + print ">>> Environment:\n"; + print ">>> \tCC = $ENV{CC}\n"; + print ">>> \tCXX = $ENV{CXX}\n"; + print ">>> \tLD = $ENV{LD}\n"; + print ">>> \tCFLAGS = $ENV{CFLAGS}\n"; + print ">>> \tCXXFLAGS = $ENV{CXXFLAGS}\n"; + print ">>> \tCPPFLAGS = $ENV{CPPFLAGS}\n"; + print ">>> \tLDFLAGS = $ENV{LDFLAGS}\n"; + print ">>> \tMACSDKOPTIONS = $ENV{MACSDKOPTIONS}\n"; + + push @configureparams, "--cache-file=iphone-cross.cache" if ($enableCacheFile); + + push @configureparams, "--with-sigaltstack=no"; + push @configureparams, "--disable-shared-handles"; + push @configureparams, "--with-tls=pthread"; + + push @configureparams, "--target=arm-darwin"; + push @configureparams, "--with-macversion=$macversion"; + push @configureparams, "--with-cross-offsets=$iphoneCrossAbi.h"; + + push @configureparams, "--build=i386-apple-darwin10"; + push @configureparams, "--disable-libraries"; + push @configureparams, "--enable-icall-symbol-map"; + push @configureparams, "--enable-minimal=com,remoting"; + + #push @configureparams, "--enable-llvm"; + #push @configureparams, "--with-llvm=llvm/usr"; + + my @mcsArgs = (); + push @mcsArgs, "$monoroot/tools/offsets-tool/MonoAotOffsetsDumper.cs"; + push @mcsArgs, "$monoroot/mcs/class/Mono.Options/Mono.Options/Options.cs"; + push @mcsArgs, "/r:$externalBuildDeps/CppSharpBinaries/CppSharp.AST.dll"; + push @mcsArgs, "/r:$externalBuildDeps/CppSharpBinaries/CppSharp.Generator.dll"; + push @mcsArgs, "/r:$externalBuildDeps/CppSharpBinaries/CppSharp.Parser.CSharp.dll"; + push @mcsArgs, "/r:$externalBuildDeps/CppSharpBinaries/CppSharp.Parser.dll"; + push @mcsArgs, "/r:$externalBuildDeps/CppSharpBinaries/CppSharp.dll"; + push @mcsArgs, "/debug"; + push @mcsArgs, "/nowarn:0436"; + push @mcsArgs, "/out:$monoroot/tools/offsets-tool/MonoAotOffsetsDumper.exe"; + + print ">>> Compiling MonoAotOffsetDumper : $iphoneCrossMonoBinToUse/mcs @mcsArgs\n"; + system("$iphoneCrossMonoBinToUse/mcs", @mcsArgs) eq 0 or die("failed to compile MonoAotOffsetsDumper\n"); + + # clean up any pre-existing offset header just in case + if (-f "$monoroot/$iphoneCrossAbi.h") + { + system("rm", "-rf", "$iphoneCrossAbi.h"); + } + } + } + elsif ($android) + { + if (!(-d $externalBuildDeps)) + { + die("mono build deps are required and the directory was not found : $externalBuildDeps\n"); + } + + my $ndkVersion = "r13b"; + my $isArmArch = 1; + my $toolchainName = ""; + my $platformRootPostfix = ""; + my $useKraitPatch = 1; + my $kraitPatchPath = "$monoroot/../../android_krait_signal_handler/build"; + my $toolChainExtension = ""; + + $isArmArch = 0 if ($androidArch eq "x86"); + + $ENV{ANDROID_PLATFORM} = "android-9"; + $ENV{GCC_VERSION} = "4.9"; + + if ($isArmArch) + { + $ENV{GCC_PREFIX} = "arm-linux-androideabi-"; + $toolchainName = "$ENV{GCC_PREFIX}$ENV{GCC_VERSION}"; + $platformRootPostfix = "arm"; + } + else + { + $ENV{GCC_PREFIX} = "i686-linux-android-"; + $toolchainName = "x86-$ENV{GCC_VERSION}"; + $platformRootPostfix = "x86"; + $useKraitPatch = 0; + } + + if ($^O eq "linux") + { + $ENV{HOST_ENV} = "linux"; + } + elsif ($^O eq 'darwin') + { + $ENV{HOST_ENV} = "darwin"; + } + else + { + $ENV{HOST_ENV} = "windows"; + } + + print "\n"; + print(">>> Android Platform = $ENV{ANDROID_PLATFORM}\n"); + print(">>> Android NDK Version = $ndkVersion\n"); + print(">>> Android GCC Prefix = $ENV{GCC_PREFIX}\n"); + print(">>> Android GCC Version = $ENV{GCC_VERSION}\n"); + + my $ndkName = ""; + if($^O eq "linux") + { + $ndkName = "android-ndk-$ndkVersion-linux-x86_64.zip"; + } + elsif($^O eq "darwin") + { + $ndkName = "android-ndk-$ndkVersion-darwin-x86_64.zip"; + } + else + { + $ndkName = "android-ndk-$ndkVersion-windows-x86.zip"; + } + + my $depsNdkArchive = "$externalBuildDeps/$ndkName"; + my $depsNdkFinal = "$externalBuildDeps/android-ndk-$ndkVersion"; + + print(">>> Android NDK Archive = $depsNdkArchive\n"); + print(">>> Android NDK Extraction Destination = $depsNdkFinal\n"); + print("\n"); + + $ENV{ANDROID_NDK_ROOT} = "$depsNdkFinal"; + + if (-d $depsNdkFinal) + { + print(">>> Android NDK already extracted\n"); + } + else + { + print(">>> Android NDK needs to be extracted\n"); + + if ($runningOnWindows) + { + my $sevenZip = "$externalBuildDeps/7z/win64/7za.exe"; + my $winDepsNdkArchive = `cygpath -w $depsNdkArchive`; + my $winDepsNdkExtract = `cygpath -w $externalBuildDeps`; + + # clean up trailing new lines that end up in the output from cygpath. If left, they cause problems down the line + # for 7zip + $winDepsNdkArchive =~ s/\n+$//; + $winDepsNdkExtract =~ s/\n+$//; + + system($sevenZip, "x", "$winDepsNdkArchive", "-o$winDepsNdkExtract"); + } + else + { + my ($name,$path,$suffix) = fileparse($depsNdkArchive, qr/\.[^.]*/); + + print(">>> Android NDK Extension = $suffix\n"); + + # Versions after r11 use .zip extension. Currently we use r10e, but let's support the .zip extension in case + # we upgrade down the road + if (lc $suffix eq '.zip') + { + system("unzip", "-q", $depsNdkArchive, "-d", $externalBuildDeps); + } + elsif (lc $suffix eq '.bin') + { chmod(0755, $depsNdkArchive); + system($depsNdkArchive, "-o$externalBuildDeps"); + } + else + { + die "Unknown file extension '" . $suffix . "'\n"; + } + } + } + + if (!(-f "$ENV{ANDROID_NDK_ROOT}/ndk-build")) + { + die("Something went wrong with the NDK extraction\n"); + } + + my $androidNdkRoot = $ENV{ANDROID_NDK_ROOT}; + my $androidPlatformRoot = "$androidNdkRoot/platforms/$ENV{ANDROID_PLATFORM}/arch-$platformRootPostfix"; + my $androidToolchain = "$androidNdkRoot/toolchains/$toolchainName/prebuilt/$ENV{HOST_ENV}"; + + if (!(-d "$androidToolchain")) + { + if (-d "$androidToolchain-x86") + { + $androidToolchain = "$androidToolchain-x86"; + } + else + { + $androidToolchain = "$androidToolchain-x86_64"; + } + } + + if ($runningOnWindows) + { + $toolChainExtension = ".exe"; + + $androidPlatformRoot = `cygpath -w $androidPlatformRoot`; + # clean up trailing new lines that end up in the output from cygpath. + $androidPlatformRoot =~ s/\n+$//; + # Switch over to forward slashes. They propagate down the toolchain correctly + $androidPlatformRoot =~ s/\\/\//g; + + # this will get passed as a path to the linker, so we need to windows-ify the path + $kraitPatchPath = `cygpath -w $kraitPatchPath`; + $kraitPatchPath =~ s/\n+$//; + $kraitPatchPath =~ s/\\/\//g; + } + + print(">>> Android Arch = $androidArch\n"); + print(">>> Android NDK Root = $androidNdkRoot\n"); + print(">>> Android Platform Root = $androidPlatformRoot\n"); + print(">>> Android Toolchain = $androidToolchain\n"); + + if (!(-d "$androidToolchain")) + { + die("Failed to locate android toolchain\n"); + } + + if (!(-d "$androidPlatformRoot")) + { + die("Failed to locate android platform root\n"); + } + + if ("$androidArch" eq 'armv5') + { + $ENV{CFLAGS} = "-DARM_FPU_NONE=1 -march=armv5te -mtune=xscale -msoft-float"; + } + elsif ("$androidArch" eq 'armv6_vfp') + { + $ENV{CFLAGS} = "-DARM_FPU_VFP=1 -march=armv6 -mtune=xscale -msoft-float -mfloat-abi=softfp -mfpu=vfp -DHAVE_ARMV6=1"; + } + elsif ("$androidArch" eq 'armv7a') + { + $ENV{CFLAGS} = "-DARM_FPU_VFP=1 -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -DHAVE_ARMV6=1"; + $ENV{LDFLAGS} = "-Wl,--fix-cortex-a8"; + } + elsif ("$androidArch" eq 'x86') + { + $ENV{LDFLAGS} = "-lgcc" + } + else + { + die("Unsupported android arch : $androidArch\n"); + } + + if ($isArmArch) + { + $ENV{CFLAGS} = "-funwind-tables $ENV{CFLAGS}"; + $ENV{LDFLAGS} = "-Wl,-rpath-link=$androidPlatformRoot/usr/lib $ENV{LDFLAGS}"; + } + + $ENV{PATH} = "$androidToolchain/bin:$ENV{PATH}"; + $ENV{CC} = "$androidToolchain/bin/$ENV{GCC_PREFIX}gcc$toolChainExtension --sysroot=$androidPlatformRoot"; + $ENV{CXX} = "$androidToolchain/bin/$ENV{GCC_PREFIX}g++$toolChainExtension --sysroot=$androidPlatformRoot"; + $ENV{CPP} = "$androidToolchain/bin/$ENV{GCC_PREFIX}cpp$toolChainExtension"; + $ENV{CXXCPP} = "$androidToolchain/bin/$ENV{GCC_PREFIX}cpp$toolChainExtension"; + $ENV{CPATH} = "$androidPlatformRoot/usr/include"; + $ENV{LD} = "$androidToolchain/bin/$ENV{GCC_PREFIX}ld$toolChainExtension"; + $ENV{AS} = "$androidToolchain/bin/$ENV{GCC_PREFIX}as$toolChainExtension"; + $ENV{AR} = "$androidToolchain/bin/$ENV{GCC_PREFIX}ar$toolChainExtension"; + $ENV{RANLIB} = "$androidToolchain/bin/$ENV{GCC_PREFIX}ranlib$toolChainExtension"; + $ENV{STRIP} = "$androidToolchain/bin/$ENV{GCC_PREFIX}strip$toolChainExtension"; + + $ENV{CFLAGS} = "-DANDROID -DPLATFORM_ANDROID -DLINUX -D__linux__ -DHAVE_USR_INCLUDE_MALLOC_H -DPAGE_SIZE=0x1000 -D_POSIX_PATH_MAX=256 -DS_IWRITE=S_IWUSR -DHAVE_PTHREAD_MUTEX_TIMEDLOCK -fpic -g -ffunction-sections -fdata-sections $ENV{CFLAGS}"; + $ENV{CXXFLAGS} = $ENV{CFLAGS}; + $ENV{CPPFLAGS} = $ENV{CFLAGS}; + + if ($useKraitPatch) + { + $ENV{LDFLAGS} = "-Wl,--wrap,sigaction -L$kraitPatchPath/obj/local/armeabi -lkrait-signal-handler $ENV{LDFLAGS}"; + } + + $ENV{LDFLAGS} = "-Wl,--no-undefined -Wl,--gc-sections -ldl -lm -llog -lc $ENV{LDFLAGS}"; + + print "\n"; + print ">>> Environment:\n"; + print ">>> \tCC = $ENV{CC}\n"; + print ">>> \tCXX = $ENV{CXX}\n"; + print ">>> \tCPP = $ENV{CPP}\n"; + print ">>> \tCXXCPP = $ENV{CXXCPP}\n"; + print ">>> \tCPATH = $ENV{CPATH}\n"; + print ">>> \tLD = $ENV{LD}\n"; + print ">>> \tAS = $ENV{AS}\n"; + print ">>> \tAR = $ENV{AR}\n"; + print ">>> \tRANLIB = $ENV{RANLIB}\n"; + print ">>> \tSTRIP = $ENV{STRIP}\n"; + print ">>> \tCFLAGS = $ENV{CFLAGS}\n"; + print ">>> \tCXXFLAGS = $ENV{CXXFLAGS}\n"; + print ">>> \tCPPFLAGS = $ENV{CPPFLAGS}\n"; + print ">>> \tLDFLAGS = $ENV{LDFLAGS}\n"; + + if ($useKraitPatch) + { + my $kraitPatchRepo = "git://github.com/Unity-Technologies/krait-signal-handler.git"; + if (-d "$kraitPatchPath") + { + print ">>> Krait patch repository already cloned\n"; + } + else + { + system("git", "clone", "--branch", "master", "$kraitPatchRepo", "$kraitPatchPath") eq 0 or die ('failing cloning Krait patch'); + } + + chdir("$kraitPatchPath") eq 1 or die ("failed to chdir to krait patch directory\n"); + system('$ANDROID_NDK_ROOT/ndk-build clean') eq 0 or die ('failing to clean Krait patch'); + system('$ANDROID_NDK_ROOT/ndk-build') eq 0 or die ('failing to build Krait patch'); + chdir("$monoroot") eq 1 or die ("failed to chdir to $monoroot\n"); + } + + if ($isArmArch) + { + push @configureparams, "--host=armv5-linux-androideabi"; + } + elsif ("$androidArch" eq 'x86') + { + push @configureparams, "--host=i686-linux-android"; + } + else + { + die("Unsupported android arch : $androidArch\n"); + } + + push @configureparams, "--cache-file=android-$androidArch.cache" if ($enableCacheFile); + + push @configureparams, "--disable-parallel-mark"; + push @configureparams, "--disable-shared-handles"; + push @configureparams, "--with-sigaltstack=no"; + push @configureparams, "--with-tls=pthread"; + push @configureparams, "--disable-visibility-hidden"; + push @configureparams, "mono_cv_uscore=yes"; + push @configureparams, "ac_cv_header_zlib_h=no" if($runningOnWindows); + } + elsif ($tizen) + { + if (!(-d $externalBuildDeps)) + { + die("mono build deps are required and the directory was not found : $externalBuildDeps\n"); + } + + my $sdkVersion = "2.4.0r1"; + my $isArmArch = 1; + + $isArmArch = 0 if ($tizenEmulator); + + $ENV{TIZEN_PLATFORM} = "tizen-2.4"; + + if ($tizenEmulator) + { + $ENV{TIZEN_ROOTSTRAP} = "mobile-2.4-emulator.core"; + } + else + { + $ENV{TIZEN_ROOTSTRAP} = "mobile-2.4-device.core"; + } + + if ($^O eq "linux") + { + $ENV{HOST_ENV} = "linux"; + } + elsif ($^O eq 'darwin') + { + $ENV{HOST_ENV} = "darwin"; + } + else + { + $ENV{HOST_ENV} = "windows"; + } + + print "\n"; + print(">>> Tizen Platform = $ENV{TIZEN_PLATFORM}\n"); + print(">>> Tizen SDK Version = $sdkVersion\n"); + + my $sdkName = "tizen-$sdkVersion-$ENV{HOST_ENV}.tar.bz2"; + my $depsSdkArchive = "$externalBuildDeps/$sdkName"; + my $depsSdkFinal = "$externalBuildDeps/tizen-$sdkVersion-$ENV{HOST_ENV}"; + + print(">>> Tizen SDK Archive = $depsSdkArchive\n"); + print(">>> Tizen SDK Extraction Destination = $depsSdkFinal\n"); + print("\n"); + + $ENV{TIZEN_SDK_ROOT} = "$depsSdkFinal"; + + if (-d $depsSdkFinal) + { + print(">>> Tizen SDK already extracted\n"); + } + else + { + print(">>> Tizen SDK needs to be extracted\n"); + + if ($runningOnWindows) + { + my $sevenZip = "$externalBuildDeps/7z/win64/7za.exe"; + my $winDepsSdkArchive = `cygpath -w $depsSdkArchive`; + my $winDepsSdkExtract = `cygpath -w $externalBuildDeps`; + + # clean up trailing new lines that end up in the output from cygpath. If left, they cause problems down the line + # for 7zip + $winDepsSdkArchive =~ s/\n+$//; + $winDepsSdkExtract =~ s/\n+$//; + + system($sevenZip, "x", "$winDepsSdkArchive", "-o$winDepsSdkExtract"); + } + else + { + my ($name,$path,$suffix) = fileparse($depsSdkArchive, qr/\.[^.]*/); + + print(">>> Tizen SDK Extension = $suffix\n"); + + if (lc $suffix eq '.bz2') + { chmod(0755, $depsSdkArchive); + system("tar xjf $depsSdkArchive -C $externalBuildDeps") eq 0 or die ("failed to extract Tizen SDK\n"); + } + else + { + die "Unknown file extension '" . $suffix . "'\n"; + } + } + } + + if (!(-f "$ENV{TIZEN_SDK_ROOT}/tools/sdb")) + { + die("Something went wrong with the SDK extraction\n"); + } + + my $tizenSdkRoot = $ENV{TIZEN_SDK_ROOT}; + my $tizenPlatformRoot = "$tizenSdkRoot/platforms/$ENV{TIZEN_PLATFORM}/mobile/rootstraps/$ENV{TIZEN_ROOTSTRAP}"; + my $tizenToolchain = "$tizenSdkRoot/tools/llvm-3.6/bin"; + + if ($runningOnWindows) + { + $toolChainExtension = ".exe"; + + $tizenPlatformRoot = `cygpath -w $tizenPlatformRoot`; + # clean up trailing new lines that end up in the output from cygpath. + $tizenPlatformRoot =~ s/\n+$//; + # Switch over to forward slashes. They propagate down the toolchain correctly + $tizenPlatformRoot =~ s/\\/\//g; + } + + if ($tizenEmulator) + { + $tizenToolchain = "$tizenSdkRoot/tools/i386-linux-gnueabi-gcc-4.9/bin/i386"; + $ENV{CFLAGS} = "-Os -g -march=i686 -msse2 -mfpmath=sse"; + } + else + { + $tizenToolchain = "$tizenSdkRoot/tools/arm-linux-gnueabi-gcc-4.9/bin/arm"; + $ENV{CFLAGS} = "-Os -g -march=armv7-a -mfpu=vfp -mfloat-abi=softfp -DARM_FPU_VFP=1 -DHAVE_ARMV6=1"; + $ENV{LDFLAGS} = "-Wl,-rpath-link=$tizenPlatformRoot/usr/lib -L$tizenPlatformRoot/usr/lib $ENV{LDFLAGS}"; + } + + print(">>> Tizen SDK Root = $tizenSdkRoot\n"); + print(">>> Tizen Platform Root = $tizenPlatformRoot\n"); + print(">>> Tizen Toolchain Prefix = $tizenToolchain\n"); + + if (!(-d "$tizenPlatformRoot")) + { + die("Failed to locate Tizen platform root\n"); + } + + $ENV{PATH} = "$tizenToolchain/bin:$ENV{PATH}"; + $ENV{CC} = "$tizenToolchain-linux-gnueabi-gcc --sysroot=$tizenPlatformRoot"; + $ENV{CXX} = "$tizenToolchain-linux-gnueabi-g++ --sysroot=$tizenPlatformRoot"; + $ENV{CPP} = "$tizenToolchain-linux-gnueabi-cpp"; + $ENV{CXXCPP} = "$tizenToolchain-linux-gnueabi-cpp"; + $ENV{CPATH} = "$tizenPlatformRoot/usr/include"; + $ENV{LD} = "$tizenToolchain-linux-gnueabi-ld --sysroot=$tizenPlatformRoot"; + $ENV{AS} = "$tizenToolchain-linux-gnueabi-as"; + $ENV{STRIP} = "$tizenToolchain-linux-gnueabi-strip"; + + if ($tizenEmulator) + { + $ENV{AR} = "$ENV{TIZEN_SDK_ROOT}/tools/i386-linux-gnueabi-gcc-4.9/bin/i386-linux-gnueabi-ar"; + $ENV{RANLIB} = "$ENV{TIZEN_SDK_ROOT}/tools/i386-linux-gnueabi-gcc-4.9/bin/i386-linux-gnueabi-ranlib"; + } + else + { + $ENV{AR} = "$ENV{TIZEN_SDK_ROOT}/tools/arm-linux-gnueabi-gcc-4.9/bin/arm-linux-gnueabi-ar"; + $ENV{RANLIB} = "$ENV{TIZEN_SDK_ROOT}/tools/arm-linux-gnueabi-gcc-4.9/bin/arm-linux-gnueabi-ranlib"; + } + + $ENV{CFLAGS} = "-DTIZEN -DLINUX -D__linux__ -DHAVE_USR_INCLUDE_MALLOC_H -DPAGE_SIZE=0x1000 -D_POSIX_PATH_MAX=256 -DS_IWRITE=S_IWUSR -DHAVE_PTHREAD_MUTEX_TIMEDLOCK -fpic -g -ffunction-sections -fdata-sections $ENV{CFLAGS}"; + $ENV{CXXFLAGS} = $ENV{CFLAGS}; + $ENV{CPPFLAGS} = $ENV{CFLAGS}; + $ENV{LDFLAGS} = "-Wl,--no-undefined -ldlog -shared -Xlinker --as-needed $ENV{LDFLAGS}"; + + print "\n"; + print ">>> Environment:\n"; + print ">>> \tCC = $ENV{CC}\n"; + print ">>> \tCXX = $ENV{CXX}\n"; + print ">>> \tCPP = $ENV{CPP}\n"; + print ">>> \tCXXCPP = $ENV{CXXCPP}\n"; + print ">>> \tCPATH = $ENV{CPATH}\n"; + print ">>> \tLD = $ENV{LD}\n"; + print ">>> \tAS = $ENV{AS}\n"; + print ">>> \tAR = $ENV{AR}\n"; + print ">>> \tRANLIB = $ENV{RANLIB}\n"; + print ">>> \tSTRIP = $ENV{STRIP}\n"; + print ">>> \tCFLAGS = $ENV{CFLAGS}\n"; + print ">>> \tCXXFLAGS = $ENV{CXXFLAGS}\n"; + print ">>> \tCPPFLAGS = $ENV{CPPFLAGS}\n"; + print ">>> \tLDFLAGS = $ENV{LDFLAGS}\n"; + + if ($tizenEmulator) + { + push @configureparams, "--host=i386-tizen-linux-gnueabi"; + } + else + { + push @configureparams, "--host=arm-tizen-linux-gnueabi"; + } + + push @configureparams, "--cache-file=tizen-cross.cache" if ($enableCacheFile); + push @configureparams, "--disable-parallel-mark"; + push @configureparams, "--disable-shared-handles"; + push @configureparams, "--with-sigaltstack=no"; + push @configureparams, "--with-tls=pthread"; + push @configureparams, "--disable-visibility-hidden"; + push @configureparams, "--disable-executables"; + push @configureparams, "--with-gnu-ld=yes"; + push @configureparams, "mono_cv_uscore=yes"; + push @configureparams, "ac_cv_header_zlib_h=no" if($runningOnWindows); + } + elsif($^O eq "linux") + { + if (!(-d $externalBuildDeps)) + { + die("mono build deps are required and the directory was not found : $externalBuildDeps\n"); + } + + if($ENV{UNITY_THISISABUILDMACHINE} || $ENV{UNITY_USE_LINUX_SDK}) + { + my $sdkVersion = '20170609'; + my $schroot = "LinuxBuildEnvironment-$sdkVersion"; + my @linuxToolchain = ('schroot', '-c', $schroot, '--'); + + print "\n"; + print(">>> Linux SDK Version = $sdkVersion\n"); + + my $sdkName = "linux-sdk-$sdkVersion.tar.bz2"; + my $depsSdkArchive = "$externalBuildDeps/$sdkName"; + my $depsSdkFinal = "$externalBuildDeps/linux-sdk-$sdkVersion"; + + print(">>> Linux SDK Archive = $depsSdkArchive\n"); + print(">>> Linux SDK Extraction Destination = $depsSdkFinal\n"); + print("\n"); + + my $linuxSdkRoot = $depsSdkFinal; + + if (-d $depsSdkFinal) + { + print(">>> Linux SDK already extracted\n"); + } + else + { + print(">>> Linux SDK needs to be extracted\n"); + system('mkdir', '-p', $depsSdkFinal); + system('tar', 'xaf', $depsSdkArchive, '-C', $depsSdkFinal) eq 0 or die ("failed to extract Linux SDK\n"); + system('sudo', 'cp', '-R', "$depsSdkFinal/linux-sdk-$sdkVersion", '/etc/schroot'); + system("sed 's,^directory=.*,directory=$depsSdkFinal/$schroot,' \"$depsSdkFinal/$schroot.conf\" | sudo tee /etc/schroot/chroot.d/$schroot.conf") eq 0 or die ("failed to deploy Linux SDK\n"); + } + + @commandPrefix = @linuxToolchain; + print(">>> Linux SDK Root = $linuxSdkRoot\n"); + print(">>> Linux Toolchain Command Prefix = " . join(' ', @commandPrefix) . "\n"); + } + + push @configureparams, "--host=$monoHostArch-pc-linux-gnu"; + + push @configureparams, "--disable-parallel-mark"; #this causes crashes + + my $archflags = ''; + if ($arch32) + { + $archflags = '-m32'; + } + else + { + $archflags = '-fPIC'; + } + + if ($debug) + { + $ENV{CFLAGS} = "$archflags -g -O0"; + } + else + { + $ENV{CFLAGS} = "$archflags -Os"; #optimize for size + } + } + elsif($^O eq 'darwin') + { + # Set up mono for bootstrapping + if ($existingMonoRootPath eq "") + { + # Find the latest mono version and use that for boostrapping + my $monoInstalls = '/Library/Frameworks/Mono.framework/Versions'; + my @monoVersions = (); + + opendir( my $DIR, $monoInstalls ); + while ( my $entry = readdir $DIR ) + { + next unless -d $monoInstalls . '/' . $entry; + next if $entry eq '.' or $entry eq '..' or $entry eq 'Current'; + push @monoVersions, $entry; + } + closedir $DIR; + @monoVersions = sort @monoVersions; + my $monoVersionToUse = pop @monoVersions; + $existingMonoRootPath = "$monoInstalls/$monoVersionToUse"; + } + + $mcs = "EXTERNAL_MCS=$existingMonoRootPath/bin/mcs"; + + $ENV{'CC'} = "$macSdkPath/../usr/bin/clang"; + $ENV{'CXX'} = "$macSdkPath/../usr/bin/clang++"; + $ENV{'CFLAGS'} = $ENV{MACSDKOPTIONS} = "-D_XOPEN_SOURCE -I$macBuildEnvDir/builds/usr/include -mmacosx-version-min=$macversion -isysroot $macSdkPath"; + + $ENV{CFLAGS} = "$ENV{CFLAGS} -g -O0" if $debug; + $ENV{CFLAGS} = "$ENV{CFLAGS} -Os" if not $debug; #optimize for size + + $ENV{CC} = "$ENV{CC} -arch $monoHostArch"; + $ENV{CXX} = "$ENV{CXX} -arch $monoHostArch"; + + # Add OSX specific autogen args + push @configureparams, "--host=$monoHostArch-apple-darwin12.2.0"; + + # Need to define because Apple's SIP gets in the way of us telling mono where to find this + push @configureparams, "--with-libgdiplus=$addtoresultsdistdir/lib/libgdiplus.dylib"; + push @configureparams, "--enable-minimal=shared_perfcounters"; + + print "\n"; + print ">>> Setting environment:\n"; + print ">>> PATH = ".$ENV{PATH}."\n"; + print ">>> C_INCLUDE_PATH = ".$ENV{C_INCLUDE_PATH}."\n"; + print ">>> CPLUS_INCLUDE_PATH = ".$ENV{CPLUS_INCLUDE_PATH}."\n"; + print ">>> CFLAGS = ".$ENV{CFLAGS}."\n"; + print ">>> CXXFLAGS = ".$ENV{CXXFLAGS}."\n"; + print ">>> CC = ".$ENV{CC}."\n"; + print ">>> CXX = ".$ENV{CXX}."\n"; + print ">>> CPP = ".$ENV{CPP}."\n"; + print ">>> CXXPP = ".$ENV{CXXPP}."\n"; + print ">>> LD = ".$ENV{LD}."\n"; + print ">>> LDFLAGS = ".$ENV{LDFLAGS}."\n"; + print "\n"; + } + else + { + push @configureparams, "--host=$monoHostArch-pc-mingw32"; + } + + if ($isDesktopBuild) + { + my $cacheArch = $arch32 ? "i386" : "x86_64"; + push @configureparams, "--cache-file=desktop-$cacheArch.cache" if ($enableCacheFile); + } + + print ">>> Existing Mono : $existingMonoRootPath\n\n"; + $ENV{'PATH'} = "$existingMonoRootPath/$existingExternalMonoBinDir:$ENV{'PATH'}"; + + print ">>> PATH before Build = $ENV{PATH}\n\n"; + + print(">>> mcs Information : \n"); + system(@commandPrefix, ("which", "mcs")); + system(@commandPrefix, ("mcs", "--version")); + print("\n"); + + print ">>> Checking on some tools...\n"; + system(@commandPrefix, ("which", "autoconf")); + system(@commandPrefix, ("autoconf", "--version")); + + system(@commandPrefix, ("which", "texi2dvi")); + system(@commandPrefix, ("texi2dvi", "--version")); + + system(@commandPrefix, ("which", "automake")); + system(@commandPrefix, ("automake", "--version")); + + system(@commandPrefix, ("which", "libtool")); + system(@commandPrefix, ("libtool", "--version")); + + system(@commandPrefix, ("which", "libtoolize")); + system(@commandPrefix, ("libtoolize", "--version")); + print("\n"); + + print ">>> LIBTOOLIZE before Build = $ENV{LIBTOOLIZE}\n"; + print ">>> LIBTOOL before Build = $ENV{LIBTOOL}\n"; + + chdir("$monoroot") eq 1 or die ("failed to chdir 2\n"); + + if (not $skipMonoMake) + { + if ($clean) + { + if (!($mcsOnly)) + { + print(">>> Cleaning $monoprefix\n"); + rmtree($monoprefix); + } + + # Avoid "source directory already configured" ... + system(@commandPrefix, ('rm', '-f', 'config.status', 'eglib/config.status', 'libgc/config.status')); + + print("\n>>> Calling autogen in mono\n"); + print("\n"); + print("\n>>> Configure parameters are : @configureparams\n"); + print("\n"); + + system(@commandPrefix, ('./autogen.sh', @configureparams)) eq 0 or die ('failing autogenning mono'); + + if ($mcsOnly) + { + print("\n>>> Calling make clean in mcs\n"); + chdir("$monoroot/mcs"); + system(@commandPrefix, ("make","clean")) eq 0 or die ("failed to make clean\n"); + chdir("$monoroot"); + } + else + { + print("\n>>> Calling make clean in mono\n"); + system(@commandPrefix, ("make","clean")) eq 0 or die ("failed to make clean\n"); + } + } + + # this step needs to run after configure + if ($iphoneCross || $iphone || $android || $tizen) + { + # This step generates the arm_dpimacros.h file, which is needed by the offset dumper + chdir("$monoroot/mono/arch/arm"); + system("make") eq 0 or die("failed to make in $monoroot/mono/arch/arm\n"); + chdir("$monoroot"); + } + + if ($iphoneCross) + { + my @monoArgs = (); + push @monoArgs, "$monoroot/tools/offsets-tool/MonoAotOffsetsDumper.exe"; + push @monoArgs, "--abi"; + push @monoArgs, "$iphoneCrossAbi"; + push @monoArgs, "--out"; + push @monoArgs, "$monoroot"; + push @monoArgs, "--mono"; + push @monoArgs, "$monoroot"; + push @monoArgs, "--maccore"; + push @monoArgs, "$monoroot"; + + $ENV{MONO_PATH} = "$externalBuildDeps/CppSharpBinaries"; + # Need to use 32bit mono because there is a native CppSharp dylib that will be used and there's only a 32bit version of it + print ">>> Running MonoAotOffsetDumper : arch -i386 $iphoneCrossMonoBinToUse/mono @monoArgs\n"; + system("arch", "-i386", "$iphoneCrossMonoBinToUse/mono", @monoArgs) eq 0 or die("failed to run MonoAotOffsetsDumper\n"); + } + + if ($mcsOnly) + { + print("\n>>> Calling make in mcs\n"); + chdir("$monoroot/mcs"); + my @makeCommand = (@commandPrefix, ('make', "-j$jobs")); + if($mcs ne '') + { + push(@makeCommand, $mcs); + } + system(@makeCommand) eq 0 or die ("Failed to make\n"); + chdir("$monoroot"); + } + else + { + print("\n>>> Calling make\n"); + my @makeCommand = (@commandPrefix, ('make', "-j$jobs")); + if($mcs ne '') + { + push(@makeCommand, $mcs); + } + system(@makeCommand) eq 0 or die ("Failed to make\n"); + } + + if ($isDesktopBuild) + { + print("\n>>> Calling make install\n"); + system(@commandPrefix, ('make', 'install')) eq 0 or die ("Failed to make install\n"); + } + else + { + if ($disableMcs) + { + print(">>> Skipping make install. We don't need to run this step when building the runtime on non-desktop platforms.\n"); + } + else + { + # Note by Mike : make install on Windows for android runtime runs into more cygwin path issues. The one I hit was related to ranlib.exe being passed cygwin linux paths + # and as a result not being able to find stuff. The previous build scripts didn't run make install for android or iOS, so I think we are fine to skip this step. + # However, if we were to build the class libs for these cases, then we probably would need to run make install. If that day comes, we'll have to figure out what to do here. + print(">>> Attempting to build class libs for a non-desktop platform. The `make install` step is probably needed, but it has cygwin path related problems on Windows for android\n"); + die("Blocking this code path until we need it. It probably should be looked at more closely before letting it proceed\n"); + } + } + } + + if ($isDesktopBuild) + { + if ($^O eq "cygwin") + { + system("$winPerl", "$winMonoRoot/external/buildscripts/build_runtime_vs.pl", "--build=$build", "--arch32=$arch32", "--msbuildversion=$msBuildVersion", "--clean=$clean", "--debug=$debug") eq 0 or die ('failed building mono with VS\n'); + + # Copy over the VS built stuff that we want to use instead into the prefix directory + my $archNameForBuild = $arch32 ? 'Win32' : 'x64'; + my $config = $debug ? "Debug" : "Release"; + system("cp $monoroot/msvc/$archNameForBuild/bin/$config/mono.exe $monoprefix/bin/.") eq 0 or die ("failed copying mono.exe\n"); + system("cp $monoroot/msvc/$archNameForBuild/bin/$config/mono-2.0.dll $monoprefix/bin/.") eq 0 or die ("failed copying mono-2.0.dll\n"); + system("cp $monoroot/msvc/$archNameForBuild/bin/$config/mono-2.0.pdb $monoprefix/bin/.") eq 0 or die ("failed copying mono-2.0.pdb\n"); + } + + system("cp -R $addtoresultsdistdir/bin/. $monoprefix/bin/") eq 0 or die ("Failed copying $addtoresultsdistdir/bin to $monoprefix/bin\n"); + } + + if(!($disableMcs)) + { + my @additionalProfiles = (); + push @additionalProfiles, "unityjit"; + push @additionalProfiles, "unityaot"; + + chdir("$monoroot/mcs"); + foreach my $profileName(@additionalProfiles) + { + print(">>> Making profile : $profileName\n"); + system("make", "PROFILE=$profileName") eq 0 or die ("Failed to make $profileName profile in mcs\n"); + + my $profileDestDir = "$monoprefix/lib/mono/$profileName"; + print(">>> Copying $profileName to $profileDestDir directory\n"); + + print(">>> Cleaning $profileDestDir\n"); + system("rm -rf $profileDestDir"); + + system("mkdir -p $profileDestDir") eq 0 or die("failed to make directory $profileDestDir\n"); + system("mkdir -p $profileDestDir/Facades") eq 0 or die("failed to make directory $profileDestDir/Facades\n"); + + system("cp $monoroot/mcs/class/lib/$profileName/*.dll $profileDestDir") eq 0 or die("Failed copying dlls from $monoroot/mcs/class/lib/$profileName to $profileDestDir\n"); + system("cp $monoroot/mcs/class/lib/$profileName/Facades/*.dll $profileDestDir/Facades") eq 0 or die("Failed copying dlls from $monoroot/mcs/class/lib/$profileName/Facades to $profileDestDir/Facades\n"); + } + + chdir("$monoroot"); + + my $stubResult = system("perl", "$buildscriptsdir/stub_classlibs.pl"); + + if ($stubResult ne 0) + { + die("Failed to run the profile stubber\n"); + } + } +} +else +{ + print(">>> Skipping build\n"); +} + +if ($buildUsAndBoo) +{ + print(">>> Building Unity Script and Boo...\n"); + if($windowsSubsystemForLinux) + { + #boo scripts expect a bin-platform folder, but we haven't built them that way + system("ln -s $monoprefix/bin $monoprefix/bin-linux64"); + system("ln -s $monoprefix/bin $monoprefix/bin-linux32"); + } + + system(@commandPrefix, ("perl", "$buildscriptsdir/build_us_and_boo.pl", "--monoprefix=$monoprefix")) eq 0 or die ("Failed building Unity Script and Boo\n"); + + print(">>> Copying Unity Script and Boo *.Lang.dll's from 4.5 profile to unityjit profile...\n"); + system("cp $monoprefix/lib/mono/4.5/Boo*.dll $monoprefix/lib/mono/unityjit/.") eq 0 or die("Failed copying Boo*.dll\n"); + system("cp $monoprefix/lib/mono/4.5/UnityScript*.dll $monoprefix/lib/mono/unityjit/.") eq 0 or die("Failed copying UnityScript*.dll\n"); + system("cp $monoprefix/lib/mono/4.5/booc.exe $monoprefix/lib/mono/unityjit/.") eq 0 or die("Failed copying booc.exe\n"); + system("cp $monoprefix/lib/mono/4.5/us.exe $monoprefix/lib/mono/unityjit/.") eq 0 or die("Failed copying us.exe\n"); +} +else +{ + print(">>> Skipping build Unity Script and Boo\n"); +} + +if ($artifact) +{ + print(">>> Creating artifact...\n"); + + if ($artifactsCommon) + { + print(">>> Creating common artifacts...\n"); + print(">>> distribution directory = $distdir\n"); + + if (!(-d "$distdir")) + { + system("mkdir -p $distdir") eq 0 or die("failed to make directory $distdir\n"); + } + + $File::Copy::Recursive::CopyLink = 0; #make sure we copy files as files and not as symlinks, as TC unfortunately doesn't pick up symlinks. + + my $distdirlibmono = "$distdir/lib/mono"; + + print(">>> Cleaning $distdir/lib\n"); + system("rm -rf $distdir/lib"); + system("mkdir -p $distdir/lib"); + + print(">>> Creating normal profile artifacts...\n"); + system("cp -R $addtoresultsdistdir/. $distdir/") eq 0 or die ("Failed copying $addtoresultsdistdir to $distdir\n"); + + system("cp -r $monoprefix/lib/mono $distdir/lib"); + + if($^O ne 'darwin') + { + # On OSX we build a universal binary for 32-bit and 64-bit in the mono executable. The class library build + # only creates the 64-bit slice, so we don't want to end up with a single slice binary in the output. + # If we do, it will step on the universal binary produced but the OSX runtime build. + system("cp -r $monoprefix/bin $distdir/") eq 0 or die ("failed copying bin folder\n"); + } + system("cp -r $monoprefix/etc $distdir/") eq 0 or die("failed copying etc folder\n"); + + system("cp -R $externalBuildDeps/reference-assemblies/unity $distdirlibmono/unity"); + system("cp -R $externalBuildDeps/reference-assemblies/unity_web $distdirlibmono/unity_web"); + + system("cp -R $externalBuildDeps/reference-assemblies/unity/Boo*.dll $distdirlibmono/2.0-api"); + system("cp -R $externalBuildDeps/reference-assemblies/unity/UnityScript*.dll $distdirlibmono/2.0-api"); + + system("cp -R $externalBuildDeps/reference-assemblies/unity/Boo*.dll $distdirlibmono/4.0-api"); + system("cp -R $externalBuildDeps/reference-assemblies/unity/UnityScript*.dll $distdirlibmono/4.0-api"); + + system("cp -R $externalBuildDeps/reference-assemblies/unity/Boo*.dll $distdirlibmono/4.5-api"); + system("cp -R $externalBuildDeps/reference-assemblies/unity/UnityScript*.dll $distdirlibmono/4.5-api"); + + # now remove nunit from a couple places (but not all, we need some of them) + # linux tar is not happy these are removed(at least on wsl), so don't remove them for now + if(not $windowsSubsystemForLinux) + { + system("rm -rf $distdirlibmono/2.0/nunit*"); + system("rm -rf $distdirlibmono/gac/nunit*"); + } + + # Remove a self referencing sym link that causes problems + system("rm -rf $monoprefix/bin/bin"); + + if (-f "$monoroot/ZippedClasslibs.tar.gz") + { + system("rm -f $monoroot/ZippedClasslibs.tar.gz") eq 0 or die("Failed to clean existing ZippedClasslibs.tar.gz\n"); + } + + print(">>> Creating ZippedClasslibs.tar.gz\n"); + print(">>> Changing directory to : $buildsroot\n"); + chdir("$buildsroot"); + system("tar -hpczf ../ZippedClasslibs.tar.gz *") eq 0 or die("Failed to zip up classlibs\n"); + print(">>> Changing directory back to : $currentdir\n"); + chdir("$currentdir"); + } + + # Do the platform specific logic to create the builds output structure that we want + + my $embedDirRoot = "$buildsroot/embedruntimes"; + my $embedDirArchDestination = ""; + my $distDirArchBin = ""; + my $versionsOutputFile = ""; + my $crossCompilerRoot = "$buildsroot/crosscompiler"; + my $crossCompilerDestination = ""; + + if ($iphone) + { + $embedDirArchDestination = "$embedDirRoot/iphone/$iphoneArch"; + $versionsOutputFile = "$buildsroot/versions-iphone-$iphoneArch.txt"; + } + elsif ($iphoneCross) + { + $crossCompilerDestination = "$buildsroot/crosscompiler/iphone"; + $versionsOutputFile = "$buildsroot/versions-iphone-xcompiler.txt"; + } + elsif ($iphoneSimulator) + { + $embedDirArchDestination = "$embedDirRoot/iphone/$iphoneSimulatorArch"; + $versionsOutputFile = "$buildsroot/versions-iphone-$iphoneSimulatorArch.txt"; + } + elsif ($android) + { + $embedDirArchDestination = "$embedDirRoot/android/$androidArch"; + $versionsOutputFile = "$buildsroot/versions-android-$androidArch.txt"; + } + elsif ($tizenEmulator) + { + $embedDirArchDestination = "$embedDirRoot/tizenemulator/"; + $versionsOutputFile = "$buildsroot/versions-tizenemulator.txt"; + } + elsif ($tizen) + { + $embedDirArchDestination = "$embedDirRoot/tizen/"; + $versionsOutputFile = "$buildsroot/versions-tizen.txt"; + } + elsif($^O eq "linux") + { + $embedDirArchDestination = $arch32 ? "$embedDirRoot/linux32" : "$embedDirRoot/linux64"; + $distDirArchBin = $arch32 ? "$distdir/bin-linux32" : "$distdir/bin-linux64"; + $versionsOutputFile = $arch32 ? "$buildsroot/versions-linux32.txt" : "$buildsroot/versions-linux64.txt"; + } + elsif($^O eq 'darwin') + { + # Note these tmp directories will get merged into a single 'osx' directory later by a parent script + $embedDirArchDestination = "$embedDirRoot/osx-tmp-$monoHostArch"; + $distDirArchBin = "$distdir/bin-osx-tmp-$monoHostArch"; + $versionsOutputFile = $arch32 ? "$buildsroot/versions-osx32.txt" : "$buildsroot/versions-osx64.txt"; + } + else + { + $embedDirArchDestination = $arch32 ? "$embedDirRoot/win32" : "$embedDirRoot/win64"; + $distDirArchBin = $arch32 ? "$distdir/bin" : "$distdir/bin-x64"; + $versionsOutputFile = $arch32 ? "$buildsroot/versions-win32.txt" : "$buildsroot/versions-win64.txt"; + } + + # Make sure the directory for our architecture is clean before we copy stuff into it + if (-d "$embedDirArchDestination") + { + print(">>> Cleaning $embedDirArchDestination\n"); + rmtree($embedDirArchDestination); + } + + if (-d "$distDirArchBin") + { + print(">>> Cleaning $distDirArchBin\n"); + rmtree($distDirArchBin); + } + + if ($artifactsRuntime) + { + system("mkdir -p $embedDirArchDestination") if ($embedDirArchDestination ne ""); + system("mkdir -p $distDirArchBin") if ($distDirArchBin ne ""); + system("mkdir -p $crossCompilerDestination") if ($crossCompilerDestination ne ""); + + # embedruntimes directory setup + print(">>> Creating embedruntimes directory : $embedDirArchDestination\n"); + if ($iphone || $iphoneSimulator) + { + for my $file ('libmonosgen-2.0.a','libmonobdwgc-2.0.a') + { + print ">>> Copying $file\n"; + system("cp", "$monoroot/mono/mini/.libs/$file","$embedDirArchDestination/$file") eq 0 or die ("failed copying $file\n"); + } + } + elsif ($iphoneCross) + { + # Nothing to do + } + elsif ($android) + { + for my $file ('libmonosgen-2.0.so','libmonobdwgc-2.0.so') + { + print ">>> Copying $file\n"; + system("cp", "$monoroot/mono/mini/.libs/$file","$embedDirArchDestination/$file") eq 0 or die ("failed copying $file\n"); + } + print ">>> Copying libMonoPosixHelper.so\n"; + system("cp", "$monoroot/support/.libs/libMonoPosixHelper.so","$embedDirArchDestination/libMonoPosixHelper.so") eq 0 or die ("failed copying libMonoPosixHelper.so\n"); + } + elsif ($tizen || $tizenEmulator) + { + for my $file ('libmonosgen-2.0.so','libmonobdwgc-2.0.so') + { + print ">>> Copying $file\n"; + system("cp", "$monoroot/mono/mini/.libs/$file","$embedDirArchDestination/$file") eq 0 or die ("failed copying $file\n"); + } + } + elsif($^O eq "linux") + { + print ">>> Copying libmonosgen-2.0\n"; + system("cp", "$monoroot/mono/mini/.libs/libmonobdwgc-2.0.so","$embedDirArchDestination/libmonobdwgc-2.0.so") eq 0 or die ("failed copying libmonobdwgc-2.0.so\n"); + system("cp", "$monoroot/mono/mini/.libs/libmonosgen-2.0.so","$embedDirArchDestination/libmonosgen-2.0.so") eq 0 or die ("failed copying libmonosgen-2.0.so\n"); + + print ">>> Copying libMonoPosixHelper.so\n"; + system("cp", "$monoroot/support/.libs/libMonoPosixHelper.so","$embedDirArchDestination/libMonoPosixHelper.so") eq 0 or die ("failed copying libMonoPosixHelper.so\n"); + + if ($buildMachine) + { + system("strip $embedDirArchDestination/libmonobdwgc-2.0.so") eq 0 or die("failed to strip libmonobdwgc-2.0.so (shared)\n"); + system("strip $embedDirArchDestination/libmonosgen-2.0.so") eq 0 or die("failed to strip libmonosgen-2.0.so (shared)\n"); + system("strip $embedDirArchDestination/libMonoPosixHelper.so") eq 0 or die("failed to strip libMonoPosixHelper (shared)\n"); + } + } + elsif($^O eq 'darwin') + { + # embedruntimes directory setup + print ">>> Hardlinking libmonosgen-2.0\n"; + + system("ln","-f", "$monoroot/mono/mini/.libs/libmonobdwgc-2.0.dylib","$embedDirArchDestination/libmonobdwgc-2.0.dylib") eq 0 or die ("failed symlinking libmonobdwgc-2.0.dylib\n"); + system("ln","-f", "$monoroot/mono/mini/.libs/libmonosgen-2.0.dylib","$embedDirArchDestination/libmonosgen-2.0.dylib") eq 0 or die ("failed symlinking libmonosgen-2.0.dylib\n"); + + print "Hardlinking libMonoPosixHelper.dylib\n"; + system("ln","-f", "$monoroot/support/.libs/libMonoPosixHelper.dylib","$embedDirArchDestination/libMonoPosixHelper.dylib") eq 0 or die ("failed symlinking $libtarget/libMonoPosixHelper.dylib\n"); + + InstallNameTool("$embedDirArchDestination/libmonobdwgc-2.0.dylib", "\@executable_path/../Frameworks/MonoEmbedRuntime/osx/libmonobdwgc-2.0.dylib"); + InstallNameTool("$embedDirArchDestination/libmonosgen-2.0.dylib", "\@executable_path/../Frameworks/MonoEmbedRuntime/osx/libmonosgen-2.0.dylib"); + InstallNameTool("$embedDirArchDestination/libMonoPosixHelper.dylib", "\@executable_path/../Frameworks/MonoEmbedRuntime/osx/libMonoPosixHelper.dylib"); + + print ">>> Copying mono public headers\n"; + system("mkdir -p $includesroot/mono"); + system("cp -R $monoprefix/include/mono-2.0/mono $includesroot/mono"); + } + else + { + # embedruntimes directory setup + system("cp", "$monoprefix/bin/mono-2.0-bdwgc.dll", "$embedDirArchDestination/mono-2.0-bdwgc.dll") eq 0 or die ("failed copying mono-2.0-bdwgc.dll\n"); + system("cp", "$monoprefix/bin/mono-2.0-bdwgc.pdb", "$embedDirArchDestination/mono-2.0-bdwgc.pdb") eq 0 or die ("failed copying mono-2.0-bdwgc.pdb\n"); + + system("cp", "$monoprefix/bin/mono-2.0-sgen.dll", "$embedDirArchDestination/mono-2.0-sgen.dll") eq 0 or die ("failed copying mono-2.0-sgen.dll\n"); + system("cp", "$monoprefix/bin/mono-2.0-sgen.pdb", "$embedDirArchDestination/mono-2.0-sgen.pdb") eq 0 or die ("failed copying mono-2.0-sgen.pdb\n"); + } + + # monodistribution directory setup + print(">>> Creating monodistribution directory\n"); + if ($android || $iphone || $iphoneCross || $iphoneSimulator || $tizen || $tizenEmulator) + { + # Nothing to do + } + elsif($^O eq "linux") + { + my $distDirArchEtc = $arch32 ? "$distdir/etc-linux32" : "$distdir/etc-linux64"; + + if (-d "$distDirArchEtc") + { + print(">>> Cleaning $distDirArchEtc\n"); + rmtree($distDirArchEtc); + } + + system("mkdir -p $distDirArchBin"); + system("mkdir -p $distDirArchEtc"); + system("mkdir -p $distDirArchEtc/mono"); + + system("ln", "-f", "$monoroot/mono/mini/mono-sgen","$distDirArchBin/mono") eq 0 or die("failed symlinking mono executable\n"); + system("ln", "-f", "$monoroot/tools/pedump/pedump","$distDirArchBin/pedump") eq 0 or die("failed symlinking pedump executable\n"); + system('cp', "$monoroot/data/config","$distDirArchEtc/mono/config") eq 0 or die("failed to copy config\n"); + } + elsif($^O eq 'darwin') + { + system("ln", "-f", "$monoroot/mono/mini/mono","$distDirArchBin/mono") eq 0 or die("failed hardlinking mono executable\n"); + system("ln", "-f", "$monoroot/tools/pedump/pedump","$distDirArchBin/pedump") eq 0 or die("failed hardlinking pedump executable\n"); + } + else + { + system("cp", "$monoprefix/bin/mono-2.0.dll", "$distDirArchBin/mono-2.0.dll") eq 0 or die ("failed copying mono-2.0.dll\n"); + system("cp", "$monoprefix/bin/mono-2.0.pdb", "$distDirArchBin/mono-2.0.pdb") eq 0 or die ("failed copying mono-2.0.pdb\n"); + system("cp", "$monoprefix/bin/mono.exe", "$distDirArchBin/mono.exe") eq 0 or die ("failed copying mono.exe\n"); + } + } + + # cross compiler directory setup + if ($iphoneCross) + { + print ">>> Copying mono-xcompiler\n"; + if($runningOnWindows) + { + die("Not implemented\n"); + } + else + { + system("cp", "$monoroot/mono/mini/mono","$crossCompilerDestination/mono-xcompiler") eq 0 or die ("failed copying mono-xcompiler\n"); + } + } + + # Not all build configurations output to the distro dir, so only chmod it if it exists + system("chmod", "-R", "755", $distDirArchBin) if (-d "$distDirArchBin"); + + # Output version information + print(">>> Creating version file : $versionsOutputFile\n"); + system("echo \"mono-version =\" > $versionsOutputFile"); + + # Not all build configurations output to the distro dir, only try to output version info if there is a distro dir + system("$distDirArchBin/mono --version >> $versionsOutputFile") if (-d "$distDirArchBin"); + + system("echo \"unity-mono-revision = $monoRevision\" >> $versionsOutputFile"); + system("echo \"unity-mono-build-scripts-revision = $buildScriptsRevision\" >> $versionsOutputFile"); + my $tmp = `date`; + system("echo \"build-date = $tmp\" >> $versionsOutputFile"); +} +else +{ + print(">>> Skipping artifact creation\n"); +} + +if ($test) +{ + if ($runRuntimeTests) + { + my $runtimeTestsDir = "$monoroot/mono/mini"; + chdir("$runtimeTestsDir") eq 1 or die ("failed to chdir"); + print("\n>>> Calling make check in $runtimeTestsDir\n\n"); + system("make","check") eq 0 or die ("runtime tests failed\n"); + } + else + { + print(">>> Skipping runtime unit tests\n"); + } + + if ($runClasslibTests) + { + if ($disableMcs) + { + print(">>> Skipping classlib unit tests because building the class libs was disabled\n"); + } + else + { + my $classlibTestsDir = "$monoroot/mcs/class"; + chdir("$classlibTestsDir") eq 1 or die ("failed to chdir"); + print("\n>>> Calling make run-test in $runtimeTestsDir\n\n"); + system("make","run-test") eq 0 or die ("classlib tests failed\n"); + } + } + else + { + print(">>> Skipping classlib unit tests\n"); + } +} +else +{ + print(">>> Skipping unit tests\n"); +} + +chdir ($currentdir); diff --git a/external/buildscripts/build_all_linux.pl b/external/buildscripts/build_all_linux.pl index d124f2b19cce..a975f5e7b668 100644 --- a/external/buildscripts/build_all_linux.pl +++ b/external/buildscripts/build_all_linux.pl @@ -1,27 +1,27 @@ -use Cwd; -use Cwd 'abs_path'; -use Getopt::Long; -use File::Basename; -use File::Path; - -my $currentdir = getcwd(); - -my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); -my $monoroot = abs_path($monoroot); -my $buildscriptsdir = "$monoroot/external/buildscripts"; - -my @passAlongArgs = (); -foreach my $arg (@ARGV) -{ - # Filter out --clean if someone uses it. We have to clean since we are doing two builds - if (not $arg =~ /^--clean=/) - { - push @passAlongArgs, $arg; - } -} - -print(">>> Building i386\n"); -system("perl", "$buildscriptsdir/build.pl", "--arch32=1", "--clean=1", "--classlibtests=0", @passAlongArgs) eq 0 or die ('failing building i386'); - -print(">>> Building x86_64\n"); +use Cwd; +use Cwd 'abs_path'; +use Getopt::Long; +use File::Basename; +use File::Path; + +my $currentdir = getcwd(); + +my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); +my $monoroot = abs_path($monoroot); +my $buildscriptsdir = "$monoroot/external/buildscripts"; + +my @passAlongArgs = (); +foreach my $arg (@ARGV) +{ + # Filter out --clean if someone uses it. We have to clean since we are doing two builds + if (not $arg =~ /^--clean=/) + { + push @passAlongArgs, $arg; + } +} + +print(">>> Building i386\n"); +system("perl", "$buildscriptsdir/build.pl", "--arch32=1", "--clean=1", "--classlibtests=0", @passAlongArgs) eq 0 or die ('failing building i386'); + +print(">>> Building x86_64\n"); system("perl", "$buildscriptsdir/build.pl", "--clean=1", "--classlibtests=0", @passAlongArgs) eq 0 or die ('failing building x86_64'); \ No newline at end of file diff --git a/external/buildscripts/build_all_win.pl b/external/buildscripts/build_all_win.pl index 3c282f5f9993..65e099b4bec2 100644 --- a/external/buildscripts/build_all_win.pl +++ b/external/buildscripts/build_all_win.pl @@ -1,27 +1,27 @@ -use Cwd; -use Cwd 'abs_path'; -use Getopt::Long; -use File::Basename; -use File::Path; - -my $currentdir = getcwd(); - -my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); -my $monoroot = abs_path($monoroot); -my $buildscriptsdir = "$monoroot/external/buildscripts"; - -my @passAlongArgs = (); -foreach my $arg (@ARGV) -{ - # Filter out --clean if someone uses it. We have to clean since we are doing two builds - if (not $arg =~ /^--clean=/) - { - push @passAlongArgs, $arg; - } -} - -print(">>> Building i686\n"); -system("perl", "$buildscriptsdir/build_win_wrapper.pl", "--arch32=1", "--clean=1", "--classlibtests=0", @passAlongArgs) eq 0 or die ('failing building win32'); - -print(">>> Building x86_64\n"); +use Cwd; +use Cwd 'abs_path'; +use Getopt::Long; +use File::Basename; +use File::Path; + +my $currentdir = getcwd(); + +my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); +my $monoroot = abs_path($monoroot); +my $buildscriptsdir = "$monoroot/external/buildscripts"; + +my @passAlongArgs = (); +foreach my $arg (@ARGV) +{ + # Filter out --clean if someone uses it. We have to clean since we are doing two builds + if (not $arg =~ /^--clean=/) + { + push @passAlongArgs, $arg; + } +} + +print(">>> Building i686\n"); +system("perl", "$buildscriptsdir/build_win_wrapper.pl", "--arch32=1", "--clean=1", "--classlibtests=0", @passAlongArgs) eq 0 or die ('failing building win32'); + +print(">>> Building x86_64\n"); system("perl", "$buildscriptsdir/build_win_wrapper.pl", "--clean=1", "--classlibtests=0", @passAlongArgs) eq 0 or die ('failing building x64'); \ No newline at end of file diff --git a/external/buildscripts/build_classlibs_osx.pl b/external/buildscripts/build_classlibs_osx.pl index b1a47d9fef8d..fa96cc74cf32 100644 --- a/external/buildscripts/build_classlibs_osx.pl +++ b/external/buildscripts/build_classlibs_osx.pl @@ -1,40 +1,40 @@ -use Cwd; -use Cwd 'abs_path'; -use Getopt::Long; -use File::Basename; -use File::Path; - -my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); -my $monoroot = abs_path($monoroot); -my $buildScriptsRoot = "$monoroot/external/buildscripts"; - -my $build = 1; -my $clean = 1; -my $mcsOnly = 0; -my $skipMonoMake = 0; - -# Handy troubleshooting/niche options - -# The prefix hack probably isn't needed anymore. Let's disable it by default and see how things go -my $shortPrefix = 1; - -GetOptions( - "build=i"=>\$build, - "clean=i"=>\$clean, - "mcsOnly=i"=>\$mcsOnly, - 'skipmonomake=i'=>\$skipMonoMake, - 'shortprefix=i'=>\$shortPrefix, -) or die ("illegal cmdline options"); - -system( - "perl", - "$buildScriptsRoot/build.pl", - "--build=$build", - "--clean=$clean", - "--mcsonly=$mcsOnly", - "--skipmonomake=$skipMonoMake", - "--artifact=1", - "--artifactscommon=1", - "--buildusandboo=1", - "--forcedefaultbuilddeps=1", - "--shortprefix=$shortPrefix") eq 0 or die ("Failed building mono\n"); +use Cwd; +use Cwd 'abs_path'; +use Getopt::Long; +use File::Basename; +use File::Path; + +my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); +my $monoroot = abs_path($monoroot); +my $buildScriptsRoot = "$monoroot/external/buildscripts"; + +my $build = 1; +my $clean = 1; +my $mcsOnly = 0; +my $skipMonoMake = 0; + +# Handy troubleshooting/niche options + +# The prefix hack probably isn't needed anymore. Let's disable it by default and see how things go +my $shortPrefix = 1; + +GetOptions( + "build=i"=>\$build, + "clean=i"=>\$clean, + "mcsOnly=i"=>\$mcsOnly, + 'skipmonomake=i'=>\$skipMonoMake, + 'shortprefix=i'=>\$shortPrefix, +) or die ("illegal cmdline options"); + +system( + "perl", + "$buildScriptsRoot/build.pl", + "--build=$build", + "--clean=$clean", + "--mcsonly=$mcsOnly", + "--skipmonomake=$skipMonoMake", + "--artifact=1", + "--artifactscommon=1", + "--buildusandboo=1", + "--forcedefaultbuilddeps=1", + "--shortprefix=$shortPrefix") eq 0 or die ("Failed building mono\n"); diff --git a/external/buildscripts/build_classlibs_wsl.pl b/external/buildscripts/build_classlibs_wsl.pl index 750b21d646f6..9d65f1b7e2b3 100644 --- a/external/buildscripts/build_classlibs_wsl.pl +++ b/external/buildscripts/build_classlibs_wsl.pl @@ -1,53 +1,53 @@ -use Cwd; -use Cwd 'abs_path'; -use Getopt::Long; -use File::Basename; -use File::Path; - -my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); -my $monoroot = abs_path($monoroot); -my $buildScriptsRoot = "$monoroot/external/buildscripts"; - -my $build = 1; -my $clean = 1; -my $mcsOnly = 0; -my $skipMonoMake = 0; - -# Handy troubleshooting/niche options - -# The prefix hack probably isn't needed anymore. Let's disable it by default and see how things go -my $shortPrefix = 1; - -# This script should not be ran on windows, if it is, kindly switch over to wsl -if ($^O eq "MSWin32") -{ - print(">>> Called from Windows. Switching over to wsl\n"); - my $monoRootInBash = `bash -c pwd`; - chomp $monoRootInBash; - print(">>> monoRootInBash = $monoRootInBash\n"); - my $cmdForBash = "$monoRootInBash/external/buildscripts/build_classlibs_wsl.pl @ARGV"; - system("bash", "-c", "\"perl $cmdForBash\"") eq 0 or die("\n"); - exit 0; -} - -GetOptions( - "build=i"=>\$build, - "clean=i"=>\$clean, - "mcsOnly=i"=>\$mcsOnly, - 'skipmonomake=i'=>\$skipMonoMake, - 'shortprefix=i'=>\$shortPrefix, -) or die ("illegal cmdline options"); - -system( - "perl", - "$buildScriptsRoot/build.pl", - "--build=$build", - "--clean=$clean", - "--mcsonly=$mcsOnly", - "--skipmonomake=$skipMonoMake", - "--artifact=1", - "--artifactscommon=1", - "--buildusandboo=1", - "--forcedefaultbuilddeps=1", - "--windowssubsystemforlinux=1", - "--shortprefix=$shortPrefix") eq 0 or die ("Failed building mono\n"); +use Cwd; +use Cwd 'abs_path'; +use Getopt::Long; +use File::Basename; +use File::Path; + +my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); +my $monoroot = abs_path($monoroot); +my $buildScriptsRoot = "$monoroot/external/buildscripts"; + +my $build = 1; +my $clean = 1; +my $mcsOnly = 0; +my $skipMonoMake = 0; + +# Handy troubleshooting/niche options + +# The prefix hack probably isn't needed anymore. Let's disable it by default and see how things go +my $shortPrefix = 1; + +# This script should not be ran on windows, if it is, kindly switch over to wsl +if ($^O eq "MSWin32") +{ + print(">>> Called from Windows. Switching over to wsl\n"); + my $monoRootInBash = `bash -c pwd`; + chomp $monoRootInBash; + print(">>> monoRootInBash = $monoRootInBash\n"); + my $cmdForBash = "$monoRootInBash/external/buildscripts/build_classlibs_wsl.pl @ARGV"; + system("bash", "-c", "\"perl $cmdForBash\"") eq 0 or die("\n"); + exit 0; +} + +GetOptions( + "build=i"=>\$build, + "clean=i"=>\$clean, + "mcsOnly=i"=>\$mcsOnly, + 'skipmonomake=i'=>\$skipMonoMake, + 'shortprefix=i'=>\$shortPrefix, +) or die ("illegal cmdline options"); + +system( + "perl", + "$buildScriptsRoot/build.pl", + "--build=$build", + "--clean=$clean", + "--mcsonly=$mcsOnly", + "--skipmonomake=$skipMonoMake", + "--artifact=1", + "--artifactscommon=1", + "--buildusandboo=1", + "--forcedefaultbuilddeps=1", + "--windowssubsystemforlinux=1", + "--shortprefix=$shortPrefix") eq 0 or die ("Failed building mono\n"); diff --git a/external/buildscripts/build_ios_xwin.pl b/external/buildscripts/build_ios_xwin.pl index d20844d1ef25..a8d2cde8ec22 100644 --- a/external/buildscripts/build_ios_xwin.pl +++ b/external/buildscripts/build_ios_xwin.pl @@ -1,18 +1,18 @@ -use Cwd; -use Cwd 'abs_path'; -use Getopt::Long; -use File::Basename; -use File::Path; - -my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); -my $monoroot = abs_path($monoroot); -my $buildScriptsRoot = "$monoroot/external/buildscripts"; - -my $clean = 1; - -GetOptions( - "clean=i"=>\$clean, -) or die ("illegal cmdline options"); - - -system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=$clean", "--artifact=1", "--arch32=1", "--iphonecross=1", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building iphone cross compiler\n"); +use Cwd; +use Cwd 'abs_path'; +use Getopt::Long; +use File::Basename; +use File::Path; + +my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); +my $monoroot = abs_path($monoroot); +my $buildScriptsRoot = "$monoroot/external/buildscripts"; + +my $clean = 1; + +GetOptions( + "clean=i"=>\$clean, +) or die ("illegal cmdline options"); + + +system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=$clean", "--artifact=1", "--arch32=1", "--iphonecross=1", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building iphone cross compiler\n"); diff --git a/external/buildscripts/build_runtime_android.pl b/external/buildscripts/build_runtime_android.pl index b827b191968e..baf687dc9034 100644 --- a/external/buildscripts/build_runtime_android.pl +++ b/external/buildscripts/build_runtime_android.pl @@ -1,32 +1,32 @@ -use Cwd; -use Cwd 'abs_path'; -use Getopt::Long; -use File::Basename; -use File::Path; - -my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); -my $monoroot = abs_path($monoroot); -my $buildScriptsRoot = "$monoroot/external/buildscripts"; - -my $androidArch = ""; -my $clean = 1; -my $windowsSubsystemForLinux = 0; - -GetOptions( - "androidarch=s"=>\$androidArch, - "clean=i"=>\$clean, - "windowssubsystemforlinux=i"=>\$windowsSubsystemForLinux, -) or die ("illegal cmdline options"); - -# By default, build runtime for all the variants we need. But allow something to specify an individual variation to build -if ($androidArch eq "") -{ - system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--artifact=1", "--arch32=1", "--androidarch=armv5", "--forcedefaultbuilddeps=1", "--windowssubsystemforlinux=$windowsSubsystemForLinux") eq 0 or die ("Failed building mono for armv5\n"); - system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--artifact=1", "--arch32=1", "--androidarch=armv6_vfp", "--forcedefaultbuilddeps=1", "--windowssubsystemforlinux=$windowsSubsystemForLinux") eq 0 or die ("Failed building mono for armv6_vfp\n"); - system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--artifact=1", "--arch32=1", "--androidarch=armv7a", "--forcedefaultbuilddeps=1", "--windowssubsystemforlinux=$windowsSubsystemForLinux") eq 0 or die ("Failed building mono for armv7a\n"); - system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--artifact=1", "--arch32=1", "--androidarch=x86", "--forcedefaultbuilddeps=1", "--windowssubsystemforlinux=$windowsSubsystemForLinux") eq 0 or die ("Failed building mono for x86\n"); -} -else -{ - system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=$clean", "--artifact=1", "--arch32=1", "--androidarch=$androidArch", "--forcedefaultbuilddeps=1", "--windowssubsystemforlinux=$windowsSubsystemForLinux") eq 0 or die ("Failed building mono for $androidArch\n"); -} +use Cwd; +use Cwd 'abs_path'; +use Getopt::Long; +use File::Basename; +use File::Path; + +my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); +my $monoroot = abs_path($monoroot); +my $buildScriptsRoot = "$monoroot/external/buildscripts"; + +my $androidArch = ""; +my $clean = 1; +my $windowsSubsystemForLinux = 0; + +GetOptions( + "androidarch=s"=>\$androidArch, + "clean=i"=>\$clean, + "windowssubsystemforlinux=i"=>\$windowsSubsystemForLinux, +) or die ("illegal cmdline options"); + +# By default, build runtime for all the variants we need. But allow something to specify an individual variation to build +if ($androidArch eq "") +{ + system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--artifact=1", "--arch32=1", "--androidarch=armv5", "--forcedefaultbuilddeps=1", "--windowssubsystemforlinux=$windowsSubsystemForLinux") eq 0 or die ("Failed building mono for armv5\n"); + system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--artifact=1", "--arch32=1", "--androidarch=armv6_vfp", "--forcedefaultbuilddeps=1", "--windowssubsystemforlinux=$windowsSubsystemForLinux") eq 0 or die ("Failed building mono for armv6_vfp\n"); + system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--artifact=1", "--arch32=1", "--androidarch=armv7a", "--forcedefaultbuilddeps=1", "--windowssubsystemforlinux=$windowsSubsystemForLinux") eq 0 or die ("Failed building mono for armv7a\n"); + system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--artifact=1", "--arch32=1", "--androidarch=x86", "--forcedefaultbuilddeps=1", "--windowssubsystemforlinux=$windowsSubsystemForLinux") eq 0 or die ("Failed building mono for x86\n"); +} +else +{ + system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=$clean", "--artifact=1", "--arch32=1", "--androidarch=$androidArch", "--forcedefaultbuilddeps=1", "--windowssubsystemforlinux=$windowsSubsystemForLinux") eq 0 or die ("Failed building mono for $androidArch\n"); +} diff --git a/external/buildscripts/build_runtime_iphone.pl b/external/buildscripts/build_runtime_iphone.pl index 7c0b93e9df2e..0c4b5bce4568 100644 --- a/external/buildscripts/build_runtime_iphone.pl +++ b/external/buildscripts/build_runtime_iphone.pl @@ -1,67 +1,67 @@ -use Cwd; -use Cwd 'abs_path'; -use Getopt::Long; -use File::Basename; -use File::Path; - -my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); -my $monoroot = abs_path($monoroot); -my $buildScriptsRoot = "$monoroot/external/buildscripts"; - -my $clean = 1; -my $runtime = 0; -my $xcomp = 0; -my $simulator = 0; - -GetOptions( - "clean=i"=>\$clean, - "runtime=i"=>\$runtime, - "xcomp=i"=>\$xcomp, - "simulator=i"=>\$simulator, -) or die ("illegal cmdline options"); - -# Build everything by default -if ($runtime == 0 && $xcomp == 0 && $simulator == 0) -{ - print ">>> All iphone related builds will be ran\n"; - $runtime = 1; - $xcomp = 1; - $simulator = 1; -} - -if ($runtime) -{ - print ">>> Building iphone runtime\n"; - system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=$clean", "--artifact=1", "--arch32=1", "--iphoneArch=armv7", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building mono for iphone\n"); -} - -if ($xcomp) -{ - # TODO : This is a horrible waste of time, and we should fix it, but for now it gets things working. - # The mono we have in the build deps for bootstrapping doesn't have a 32bit slice, which we need in order to run the MonoAotOffsetsDumper. - # To get around this for the moment, we'll build the runtime & classlibs first, and then use that to run the MonoAotOffsetsDumper. - # Once we update the mono in the build deps, we can remove this. - if(!(-f "$monoroot/builds/monodistribution/bin/mono")) - { - print ">>> Building mono to use for bootstrapping. The version in mono build deps is missing the 32bit slice and we need a 32bit version to run the MonoAotOffsetsDumper\n"; - #system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--arch32=1", "--clean=$clean", "--classlibtests=0", "--artifact=1", "--artifactscommon=1", "--forcedefaultbuilddeps=1") eq 0 or die ("failing building mono 32bit for bootstrapping\n"); - #system("perl", "$buildScriptsRoot/build_all_osx.pl", "--build=1", "--artifact=1", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building mono\n"); - system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--artifact=1", "--arch32=1", "--artifactscommon=1", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building mono\n"); - - system("cp", "$monoroot/builds/monodistribution/bin-osx-tmp-i386/mono", "$monoroot/builds/monodistribution/bin/.") eq 0 or die ("failed to copy mono over from bin-osx-tmp-i386 to bin\n"); - system("chmod", "+x", "$monoroot/builds/monodistribution/bin/mono") eq 0 or die("Failed to chmod mono\n"); - - # Need to clean up the tmp build folder so that we don't pollute the final artifact - rmtree("$monoroot/builds/monodistribution/bin-osx-tmp-i386"); - rmtree("$monoroot/builds/embedruntimes/osx-tmp-i386"); - } - - print ">>> Building iphone cross compiler\n"; - system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=$clean", "--artifact=1", "--arch32=1", "--iphonecross=1", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building iphone cross compiler\n"); -} - -if ($simulator) -{ - print ">>> Building iphone simulator\n"; - system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=$clean", "--artifact=1", "--arch32=1", "--iphonesimulator=1", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building iphone simulator\n"); -} +use Cwd; +use Cwd 'abs_path'; +use Getopt::Long; +use File::Basename; +use File::Path; + +my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); +my $monoroot = abs_path($monoroot); +my $buildScriptsRoot = "$monoroot/external/buildscripts"; + +my $clean = 1; +my $runtime = 0; +my $xcomp = 0; +my $simulator = 0; + +GetOptions( + "clean=i"=>\$clean, + "runtime=i"=>\$runtime, + "xcomp=i"=>\$xcomp, + "simulator=i"=>\$simulator, +) or die ("illegal cmdline options"); + +# Build everything by default +if ($runtime == 0 && $xcomp == 0 && $simulator == 0) +{ + print ">>> All iphone related builds will be ran\n"; + $runtime = 1; + $xcomp = 1; + $simulator = 1; +} + +if ($runtime) +{ + print ">>> Building iphone runtime\n"; + system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=$clean", "--artifact=1", "--arch32=1", "--iphoneArch=armv7", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building mono for iphone\n"); +} + +if ($xcomp) +{ + # TODO : This is a horrible waste of time, and we should fix it, but for now it gets things working. + # The mono we have in the build deps for bootstrapping doesn't have a 32bit slice, which we need in order to run the MonoAotOffsetsDumper. + # To get around this for the moment, we'll build the runtime & classlibs first, and then use that to run the MonoAotOffsetsDumper. + # Once we update the mono in the build deps, we can remove this. + if(!(-f "$monoroot/builds/monodistribution/bin/mono")) + { + print ">>> Building mono to use for bootstrapping. The version in mono build deps is missing the 32bit slice and we need a 32bit version to run the MonoAotOffsetsDumper\n"; + #system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--arch32=1", "--clean=$clean", "--classlibtests=0", "--artifact=1", "--artifactscommon=1", "--forcedefaultbuilddeps=1") eq 0 or die ("failing building mono 32bit for bootstrapping\n"); + #system("perl", "$buildScriptsRoot/build_all_osx.pl", "--build=1", "--artifact=1", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building mono\n"); + system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--artifact=1", "--arch32=1", "--artifactscommon=1", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building mono\n"); + + system("cp", "$monoroot/builds/monodistribution/bin-osx-tmp-i386/mono", "$monoroot/builds/monodistribution/bin/.") eq 0 or die ("failed to copy mono over from bin-osx-tmp-i386 to bin\n"); + system("chmod", "+x", "$monoroot/builds/monodistribution/bin/mono") eq 0 or die("Failed to chmod mono\n"); + + # Need to clean up the tmp build folder so that we don't pollute the final artifact + rmtree("$monoroot/builds/monodistribution/bin-osx-tmp-i386"); + rmtree("$monoroot/builds/embedruntimes/osx-tmp-i386"); + } + + print ">>> Building iphone cross compiler\n"; + system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=$clean", "--artifact=1", "--arch32=1", "--iphonecross=1", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building iphone cross compiler\n"); +} + +if ($simulator) +{ + print ">>> Building iphone simulator\n"; + system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=$clean", "--artifact=1", "--arch32=1", "--iphonesimulator=1", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building iphone simulator\n"); +} diff --git a/external/buildscripts/build_runtime_linux.pl b/external/buildscripts/build_runtime_linux.pl index 073b6fb5ea76..836b7407d10a 100644 --- a/external/buildscripts/build_runtime_linux.pl +++ b/external/buildscripts/build_runtime_linux.pl @@ -1,23 +1,23 @@ -use Cwd; -use Cwd 'abs_path'; -use Getopt::Long; -use File::Basename; -use File::Path; - -my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); -my $monoroot = abs_path($monoroot); -my $buildScriptsRoot = "$monoroot/external/buildscripts"; - -my $build64 = 0; - -GetOptions( - "build64=i"=>\$build64, -) or die ("illegal cmdline options"); - -my $arch32 = 1; -if ($build64) -{ - $arch32 = 0; -} - -system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--test=1", "--artifact=1", "--arch32=$arch32", "--classlibtests=0", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building mono\n"); +use Cwd; +use Cwd 'abs_path'; +use Getopt::Long; +use File::Basename; +use File::Path; + +my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); +my $monoroot = abs_path($monoroot); +my $buildScriptsRoot = "$monoroot/external/buildscripts"; + +my $build64 = 0; + +GetOptions( + "build64=i"=>\$build64, +) or die ("illegal cmdline options"); + +my $arch32 = 1; +if ($build64) +{ + $arch32 = 0; +} + +system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--test=1", "--artifact=1", "--arch32=$arch32", "--classlibtests=0", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building mono\n"); diff --git a/external/buildscripts/build_runtime_osx.pl b/external/buildscripts/build_runtime_osx.pl index 42009e295b51..82b9d5f64b3b 100644 --- a/external/buildscripts/build_runtime_osx.pl +++ b/external/buildscripts/build_runtime_osx.pl @@ -1,11 +1,11 @@ -use Cwd; -use Cwd 'abs_path'; -use Getopt::Long; -use File::Basename; -use File::Path; - -my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); -my $monoroot = abs_path($monoroot); -my $buildScriptsRoot = "$monoroot/external/buildscripts"; - -system("perl", "$buildScriptsRoot/build_all_osx.pl", "--build=1", "--artifact=1", "--test=1", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building mono\n"); +use Cwd; +use Cwd 'abs_path'; +use Getopt::Long; +use File::Basename; +use File::Path; + +my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); +my $monoroot = abs_path($monoroot); +my $buildScriptsRoot = "$monoroot/external/buildscripts"; + +system("perl", "$buildScriptsRoot/build_all_osx.pl", "--build=1", "--artifact=1", "--test=1", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building mono\n"); diff --git a/external/buildscripts/build_runtime_vs.pl b/external/buildscripts/build_runtime_vs.pl index ee41343ede20..5460b34408ba 100644 --- a/external/buildscripts/build_runtime_vs.pl +++ b/external/buildscripts/build_runtime_vs.pl @@ -1,52 +1,52 @@ -sub CompileVCProj; -use Cwd 'abs_path'; -use Getopt::Long; -use File::Spec; -use File::Basename; -use File::Copy; -use File::Path; - -print ">>> PATH in Build VS = $ENV{PATH}\n\n"; - -my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); -my $monoroot = abs_path($monoroot); -my $buildsroot = "$monoroot/builds"; -my $buildMachine = $ENV{UNITY_THISISABUILDMACHINE}; - -my $build = 0; -my $clean = 0; -my $arch32 = 0; -my $debug = 0; -my $gc = "bdwgc"; -my $msBuildVersion = ""; - -GetOptions( - 'build=i'=>\$build, - 'clean=i'=>\$clean, - 'arch32=i'=>\$arch32, - 'debug=i'=>\$debug, - 'msbuildversion=s'=>\$msBuildVersion, - 'gc=s'=>\$gc, -) or die ("illegal cmdline options"); - -if ($build) -{ - CompileVCProj("$monoroot/msvc/mono.sln"); -} - -sub CompileVCProj -{ - my $sln = shift; - my $config; - - my $msbuild = $ENV{"ProgramFiles(x86)"}."/MSBuild/$msBuildVersion/Bin/MSBuild.exe"; - - $config = $debug ? "Debug" : "Release"; - my $arch = $arch32 ? "Win32" : "x64"; - my $target = $clean ? "/t:Clean,Build" :"/t:Build"; - my $properties = "/p:Configuration=$config;Platform=$arch;MONO_TARGET_GC=$gc"; - - print ">>> $msbuild $properties $target $sln\n\n"; - system($msbuild, $properties, $target, $sln) eq 0 - or die("MSBuild failed to build $sln\n"); -} +sub CompileVCProj; +use Cwd 'abs_path'; +use Getopt::Long; +use File::Spec; +use File::Basename; +use File::Copy; +use File::Path; + +print ">>> PATH in Build VS = $ENV{PATH}\n\n"; + +my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); +my $monoroot = abs_path($monoroot); +my $buildsroot = "$monoroot/builds"; +my $buildMachine = $ENV{UNITY_THISISABUILDMACHINE}; + +my $build = 0; +my $clean = 0; +my $arch32 = 0; +my $debug = 0; +my $gc = "bdwgc"; +my $msBuildVersion = ""; + +GetOptions( + 'build=i'=>\$build, + 'clean=i'=>\$clean, + 'arch32=i'=>\$arch32, + 'debug=i'=>\$debug, + 'msbuildversion=s'=>\$msBuildVersion, + 'gc=s'=>\$gc, +) or die ("illegal cmdline options"); + +if ($build) +{ + CompileVCProj("$monoroot/msvc/mono.sln"); +} + +sub CompileVCProj +{ + my $sln = shift; + my $config; + + my $msbuild = $ENV{"ProgramFiles(x86)"}."/MSBuild/$msBuildVersion/Bin/MSBuild.exe"; + + $config = $debug ? "Debug" : "Release"; + my $arch = $arch32 ? "Win32" : "x64"; + my $target = $clean ? "/t:Clean,Build" :"/t:Build"; + my $properties = "/p:Configuration=$config;Platform=$arch;MONO_TARGET_GC=$gc"; + + print ">>> $msbuild $properties $target $sln\n\n"; + system($msbuild, $properties, $target, $sln) eq 0 + or die("MSBuild failed to build $sln\n"); +} diff --git a/external/buildscripts/build_runtime_win.pl b/external/buildscripts/build_runtime_win.pl index f8dda725c262..9022ed3f5413 100644 --- a/external/buildscripts/build_runtime_win.pl +++ b/external/buildscripts/build_runtime_win.pl @@ -1,14 +1,14 @@ -use Cwd; -use Cwd 'abs_path'; -use Getopt::Long; -use File::Basename; -use File::Path; - -my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); -my $monoroot = abs_path($monoroot); -my $buildScriptsRoot = "$monoroot/external/buildscripts"; - -# Note : Ideally we can switch back to this build approach once the random cygwin hangs on the build machines are sorted out -#system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--test=1", "--artifact=1", "--arch32=1", "--classlibtests=0", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building mono\n"); - -system("perl", "$buildScriptsRoot/build_win_no_cygwin.pl", "--build=1", "--clean=1", "--artifact=1", "--arch32=1", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building mono\n"); +use Cwd; +use Cwd 'abs_path'; +use Getopt::Long; +use File::Basename; +use File::Path; + +my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); +my $monoroot = abs_path($monoroot); +my $buildScriptsRoot = "$monoroot/external/buildscripts"; + +# Note : Ideally we can switch back to this build approach once the random cygwin hangs on the build machines are sorted out +#system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--test=1", "--artifact=1", "--arch32=1", "--classlibtests=0", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building mono\n"); + +system("perl", "$buildScriptsRoot/build_win_no_cygwin.pl", "--build=1", "--clean=1", "--artifact=1", "--arch32=1", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building mono\n"); diff --git a/external/buildscripts/build_runtime_win64.pl b/external/buildscripts/build_runtime_win64.pl index fd36d86bfd35..24bf9821282d 100644 --- a/external/buildscripts/build_runtime_win64.pl +++ b/external/buildscripts/build_runtime_win64.pl @@ -1,14 +1,14 @@ -use Cwd; -use Cwd 'abs_path'; -use Getopt::Long; -use File::Basename; -use File::Path; - -my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); -my $monoroot = abs_path($monoroot); -my $buildScriptsRoot = "$monoroot/external/buildscripts"; - -# Note : Ideally we can switch back to this build approach once the random cygwin hangs on the build machines are sorted out -#system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--test=1", "--artifact=1", "--classlibtests=0", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building mono\n"); - -system("perl", "$buildScriptsRoot/build_win_no_cygwin.pl", "--build=1", "--clean=1", "--artifact=1", "--arch32=0", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building mono\n"); +use Cwd; +use Cwd 'abs_path'; +use Getopt::Long; +use File::Basename; +use File::Path; + +my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); +my $monoroot = abs_path($monoroot); +my $buildScriptsRoot = "$monoroot/external/buildscripts"; + +# Note : Ideally we can switch back to this build approach once the random cygwin hangs on the build machines are sorted out +#system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--test=1", "--artifact=1", "--classlibtests=0", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building mono\n"); + +system("perl", "$buildScriptsRoot/build_win_no_cygwin.pl", "--build=1", "--clean=1", "--artifact=1", "--arch32=0", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building mono\n"); diff --git a/external/buildscripts/build_runtime_wsl.pl b/external/buildscripts/build_runtime_wsl.pl index fabedcff1774..ba8169be68e9 100644 --- a/external/buildscripts/build_runtime_wsl.pl +++ b/external/buildscripts/build_runtime_wsl.pl @@ -1,13 +1,13 @@ -use Cwd; -use Cwd 'abs_path'; -use Getopt::Long; -use File::Basename; -use File::Path; - -my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); -my $monoroot = abs_path($monoroot); -my $buildScriptsRoot = "$monoroot/external/buildscripts"; - -#Windows Subsystem for Linux currently does not support 32-bit, so the option is 64-bit only - -system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--test=1", "--artifact=1", "--arch32=0", "--classlibtests=0", "--forcedefaultbuilddeps=1", "--windowssubsystemforlinux=1") eq 0 or die ("Failed building mono\n"); +use Cwd; +use Cwd 'abs_path'; +use Getopt::Long; +use File::Basename; +use File::Path; + +my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); +my $monoroot = abs_path($monoroot); +my $buildScriptsRoot = "$monoroot/external/buildscripts"; + +#Windows Subsystem for Linux currently does not support 32-bit, so the option is 64-bit only + +system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--test=1", "--artifact=1", "--arch32=0", "--classlibtests=0", "--forcedefaultbuilddeps=1", "--windowssubsystemforlinux=1") eq 0 or die ("Failed building mono\n"); diff --git a/external/buildscripts/build_unityscript_bareminimum_win.pl b/external/buildscripts/build_unityscript_bareminimum_win.pl index 753cf408dd62..8214e906a8dd 100644 --- a/external/buildscripts/build_unityscript_bareminimum_win.pl +++ b/external/buildscripts/build_unityscript_bareminimum_win.pl @@ -1,159 +1,159 @@ -use lib ('.', 'perl_lib', 'external/buildscripts/perl_lib'); -use Cwd; -use File::Path; - -use File::Copy::Recursive qw(dircopy); -use Getopt::Long; -use File::Basename; - -my $root = getcwd(); - -my $monodistro = "$root/builds/monodistribution"; -my $libmono = "$monodistro/lib/mono"; - -sub AddDotNetFolderToPath() { - - my @netFrameworkLocations = ( - $ENV{"SYSTEMROOT"}."/Microsoft.NET/Framework/v4.0.30319", - $ENV{"SYSTEMROOT"}."/Microsoft.NET/Framework/v3.5" - ); - - my $netFrameworkLocation = ""; - my $checkedLocations = ""; - - find_framework: - foreach my $current (@netFrameworkLocations) - { - if (-e $current) { - $netFrameworkLocation = $current; - last find_framework; - } - - $checkedLocations = $checkedLocations . ", " . $current; - } - - if ($netFrameworkLocation eq '') { - die("Could not find dotnet framework folder. Checked: $checkedLocations"); - } - - print("Using .Net framework: $netFrameworkLocation"); - $ENV{PATH} = "$netFrameworkLocation;$ENV{PATH}"; -} - -AddDotNetFolderToPath(); - -my $output = Win32::GetLongPathName("$ENV{TEMP}") . "/output/BareMinimum"; - -print("\nEnvironment Path: $ENV{PATH}\n"); - -my $booCheckout = "$root/../../boo/build"; -my $usCheckout = "$root/../../unityscript/build"; - -my $skipbuild=0; -GetOptions( - "skipbuild=i"=>\$skipbuild, -) or die ("illegal cmdline options"); - -my $monodistroLibMono = "$monodistro/lib/mono"; -my $monodistroUnity = "$monodistroLibMono/unity"; - -sub UnityBooc -{ - my $commandLine = shift; - system("$output/wsa/booc -debug- $commandLine") eq 0 or die("booc failed to execute: $commandLine"); -} - -sub BuildUnityScriptForUnity -{ - # Build system is handling this - if (!$ENV{UNITY_THISISABUILDMACHINE}) { - GitClone("git://github.com/Unity-Technologies/boo.git", $booCheckout); - } - - my $commonDefines = "NO_SERIALIZATION_INFO,NO_SYSTEM_PROCESS,NO_ICLONEABLE,MSBUILD,IGNOREKEYFILE"; - - Build("$booCheckout/src/booc/Booc.csproj", undef, "/property:TargetFrameworkVersion=4.0 /property:DefineConstants=\"" . $commonDefines . "\" /property:OutputPath=$output/wp8"); - Build("$booCheckout/src/booc/Booc.csproj", undef, "/property:TargetFrameworkVersion=4.0 /property:DefineConstants=\"" . $commonDefines . ",NO_SYSTEM_REFLECTION_EMIT\" /property:OutputPath=$output/wsa"); - - if (!$ENV{UNITY_THISISABUILDMACHINE}) { - GitClone("git://github.com/Unity-Technologies/unityscript.git", $usCheckout); - } - - UnityBooc("-out:$output/wsa/Boo.Lang.Extensions.dll -srcdir:$booCheckout/src/Boo.Lang.Extensions -r:$output/wsa/Boo.Lang.dll -r:$output/wsa/Boo.Lang.Compiler.dll"); - UnityBooc("-out:$output/wsa/Boo.Lang.Useful.dll -srcdir:$booCheckout/src/Boo.Lang.Useful -r:$output/wsa/Boo.Lang.Parser"); - UnityBooc("-out:$output/wsa/Boo.Lang.PatternMatching.dll -srcdir:$booCheckout/src/Boo.Lang.PatternMatching"); - - my $UnityScriptLangDLL = "$output/UnityScript.Lang.dll"; - UnityBooc("-out:$UnityScriptLangDLL -srcdir:$usCheckout/src/UnityScript.Lang -r:$output/wsa/Boo.Lang.Extensions.dll"); -} - -sub Build -{ - my $projectFile = shift; - - my $optionalConfiguration = shift; - my $configuration = defined($optionalConfiguration) ? $optionalConfiguration : "Release"; - - my $optionalCustomArguments = shift; - my $customArguments = defined($optionalCustomArguments) ? $optionalCustomArguments : ""; - - my $target = "Rebuild"; - my $commandLine = "MSBuild $projectFile /p:AssemblyOriginatorKeyFile= /p:SignAssembly=false /p:MonoTouch=True /t:$target /p:Configuration=$configuration $customArguments"; - - system($commandLine) eq 0 or die("Failed to xbuild '$projectFile' for unity"); -} - -sub GitClone -{ - my $repo = shift; - my $localFolder = shift; - my $branch = shift; - $branch = defined($branch)?$branch:master; - - if (-d $localFolder) { - return; - } - system("git clone --branch $branch $repo $localFolder") eq 0 or die("git clone $repo $localFolder failed!"); -} - -sub NormalizePath { - my $path = shift; - $path =~ s/\//\\/g; - - return $path; -} - -sub cp -{ - my $cmdLine = shift; - $cmdLine = NormalizePath($cmdLine); - - system("xcopy $cmdLine /s /y") eq 0 or die("failed to copy '$cmdLine'"); - print "Copied: $cmdLine\n"; -} - -rmtree("$root/builds"); -rmtree("$output"); - -BuildUnityScriptForUnity(); - -cp("$output/wsa/Boo.Lang.dll $libmono/bare-minimum/wsa/Boo.Lang.dll*"); -cp("$output/wsa/Boo.Lang.pdb $libmono/bare-minimum/wsa/Boo.Lang.pdb*"); -cp("$output/wp8/Boo.Lang.dll $libmono/bare-minimum/wp8/Boo.Lang.dll*"); -cp("$output/wp8/Boo.Lang.pdb $libmono/bare-minimum/wp8/Boo.Lang.pdb*"); -cp("$output/UnityScript.Lang.* $libmono/bare-minimum/UnityScript.Lang.*"); - -if($ENV{UNITY_THISISABUILDMACHINE}) -{ - my %checkouts = ( - 'mono-classlibs' => 'BUILD_VCS_NUMBER_Mono____Mono2_6_x_Unity3_x', - 'boo' => 'BUILD_VCS_NUMBER_Boo', - 'unityscript' => 'BUILD_VCS_NUMBER_UnityScript', - 'cecil' => 'BUILD_VCS_NUMBER_Cecil' - ); - - system("echo '' > $root/builds/versions.txt"); - for my $key (keys %checkouts) { - system("echo \"$key = $ENV{$checkouts{$key}}\" >> $root/builds/versions.txt"); - } -} +use lib ('.', 'perl_lib', 'external/buildscripts/perl_lib'); +use Cwd; +use File::Path; + +use File::Copy::Recursive qw(dircopy); +use Getopt::Long; +use File::Basename; + +my $root = getcwd(); + +my $monodistro = "$root/builds/monodistribution"; +my $libmono = "$monodistro/lib/mono"; + +sub AddDotNetFolderToPath() { + + my @netFrameworkLocations = ( + $ENV{"SYSTEMROOT"}."/Microsoft.NET/Framework/v4.0.30319", + $ENV{"SYSTEMROOT"}."/Microsoft.NET/Framework/v3.5" + ); + + my $netFrameworkLocation = ""; + my $checkedLocations = ""; + + find_framework: + foreach my $current (@netFrameworkLocations) + { + if (-e $current) { + $netFrameworkLocation = $current; + last find_framework; + } + + $checkedLocations = $checkedLocations . ", " . $current; + } + + if ($netFrameworkLocation eq '') { + die("Could not find dotnet framework folder. Checked: $checkedLocations"); + } + + print("Using .Net framework: $netFrameworkLocation"); + $ENV{PATH} = "$netFrameworkLocation;$ENV{PATH}"; +} + +AddDotNetFolderToPath(); + +my $output = Win32::GetLongPathName("$ENV{TEMP}") . "/output/BareMinimum"; + +print("\nEnvironment Path: $ENV{PATH}\n"); + +my $booCheckout = "$root/../../boo/build"; +my $usCheckout = "$root/../../unityscript/build"; + +my $skipbuild=0; +GetOptions( + "skipbuild=i"=>\$skipbuild, +) or die ("illegal cmdline options"); + +my $monodistroLibMono = "$monodistro/lib/mono"; +my $monodistroUnity = "$monodistroLibMono/unity"; + +sub UnityBooc +{ + my $commandLine = shift; + system("$output/wsa/booc -debug- $commandLine") eq 0 or die("booc failed to execute: $commandLine"); +} + +sub BuildUnityScriptForUnity +{ + # Build system is handling this + if (!$ENV{UNITY_THISISABUILDMACHINE}) { + GitClone("git://github.com/Unity-Technologies/boo.git", $booCheckout); + } + + my $commonDefines = "NO_SERIALIZATION_INFO,NO_SYSTEM_PROCESS,NO_ICLONEABLE,MSBUILD,IGNOREKEYFILE"; + + Build("$booCheckout/src/booc/Booc.csproj", undef, "/property:TargetFrameworkVersion=4.0 /property:DefineConstants=\"" . $commonDefines . "\" /property:OutputPath=$output/wp8"); + Build("$booCheckout/src/booc/Booc.csproj", undef, "/property:TargetFrameworkVersion=4.0 /property:DefineConstants=\"" . $commonDefines . ",NO_SYSTEM_REFLECTION_EMIT\" /property:OutputPath=$output/wsa"); + + if (!$ENV{UNITY_THISISABUILDMACHINE}) { + GitClone("git://github.com/Unity-Technologies/unityscript.git", $usCheckout); + } + + UnityBooc("-out:$output/wsa/Boo.Lang.Extensions.dll -srcdir:$booCheckout/src/Boo.Lang.Extensions -r:$output/wsa/Boo.Lang.dll -r:$output/wsa/Boo.Lang.Compiler.dll"); + UnityBooc("-out:$output/wsa/Boo.Lang.Useful.dll -srcdir:$booCheckout/src/Boo.Lang.Useful -r:$output/wsa/Boo.Lang.Parser"); + UnityBooc("-out:$output/wsa/Boo.Lang.PatternMatching.dll -srcdir:$booCheckout/src/Boo.Lang.PatternMatching"); + + my $UnityScriptLangDLL = "$output/UnityScript.Lang.dll"; + UnityBooc("-out:$UnityScriptLangDLL -srcdir:$usCheckout/src/UnityScript.Lang -r:$output/wsa/Boo.Lang.Extensions.dll"); +} + +sub Build +{ + my $projectFile = shift; + + my $optionalConfiguration = shift; + my $configuration = defined($optionalConfiguration) ? $optionalConfiguration : "Release"; + + my $optionalCustomArguments = shift; + my $customArguments = defined($optionalCustomArguments) ? $optionalCustomArguments : ""; + + my $target = "Rebuild"; + my $commandLine = "MSBuild $projectFile /p:AssemblyOriginatorKeyFile= /p:SignAssembly=false /p:MonoTouch=True /t:$target /p:Configuration=$configuration $customArguments"; + + system($commandLine) eq 0 or die("Failed to xbuild '$projectFile' for unity"); +} + +sub GitClone +{ + my $repo = shift; + my $localFolder = shift; + my $branch = shift; + $branch = defined($branch)?$branch:master; + + if (-d $localFolder) { + return; + } + system("git clone --branch $branch $repo $localFolder") eq 0 or die("git clone $repo $localFolder failed!"); +} + +sub NormalizePath { + my $path = shift; + $path =~ s/\//\\/g; + + return $path; +} + +sub cp +{ + my $cmdLine = shift; + $cmdLine = NormalizePath($cmdLine); + + system("xcopy $cmdLine /s /y") eq 0 or die("failed to copy '$cmdLine'"); + print "Copied: $cmdLine\n"; +} + +rmtree("$root/builds"); +rmtree("$output"); + +BuildUnityScriptForUnity(); + +cp("$output/wsa/Boo.Lang.dll $libmono/bare-minimum/wsa/Boo.Lang.dll*"); +cp("$output/wsa/Boo.Lang.pdb $libmono/bare-minimum/wsa/Boo.Lang.pdb*"); +cp("$output/wp8/Boo.Lang.dll $libmono/bare-minimum/wp8/Boo.Lang.dll*"); +cp("$output/wp8/Boo.Lang.pdb $libmono/bare-minimum/wp8/Boo.Lang.pdb*"); +cp("$output/UnityScript.Lang.* $libmono/bare-minimum/UnityScript.Lang.*"); + +if($ENV{UNITY_THISISABUILDMACHINE}) +{ + my %checkouts = ( + 'mono-classlibs' => 'BUILD_VCS_NUMBER_Mono____Mono2_6_x_Unity3_x', + 'boo' => 'BUILD_VCS_NUMBER_Boo', + 'unityscript' => 'BUILD_VCS_NUMBER_UnityScript', + 'cecil' => 'BUILD_VCS_NUMBER_Cecil' + ); + + system("echo '' > $root/builds/versions.txt"); + for my $key (keys %checkouts) { + system("echo \"$key = $ENV{$checkouts{$key}}\" >> $root/builds/versions.txt"); + } +} diff --git a/external/buildscripts/build_us_and_boo.pl b/external/buildscripts/build_us_and_boo.pl index ecbbd0da07e9..3242a6430d6e 100644 --- a/external/buildscripts/build_us_and_boo.pl +++ b/external/buildscripts/build_us_and_boo.pl @@ -1,158 +1,158 @@ -use Cwd; -use Cwd 'abs_path'; -use Getopt::Long; -use File::Basename; -use File::Path; -use File::Copy; -use lib ('.', 'perl_lib', 'external/buildscripts/perl_lib'); -use Tools qw(GitClone); - -system("source","~/.profile"); -print ">>> My Path: $ENV{PATH}\n"; - -my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); -my $monoroot = abs_path($monoroot); -my $buildscriptsdir = "$monoroot/external/buildscripts"; -my $monoprefix = "$monoroot/tmp/monoprefix"; -my $buildsroot = "$monoroot/builds"; -my $buildMachine = $ENV{UNITY_THISISABUILDMACHINE}; - -GetOptions( - 'monoprefix=s'=>\$monoprefix, -) or die ("illegal cmdline options"); - -my $xbuildPath = "$monoprefix/bin/xbuild"; -my $monoprefix45 = "$monoprefix/lib/mono/4.5"; - -if (!(-f "$xbuildPath")) -{ - die("Unable to locate xbuild at : $xbuildPath\n"); -} - -BuildUnityScriptFor45(); - -sub XBuild -{ - print(">>> Running : $monoprefix/bin/xbuild @_\n"); - system("$monoprefix/bin/xbuild", @_) eq 0 or die("Failed to xbuild @_\n"); -} - -sub Booc45 -{ - my $commandLine = shift; - - system("$monoprefix/bin/mono $monoprefix45/booc.exe -debug- $commandLine") eq 0 or die("booc failed to execute: $monoprefix/bin/booc -debug- $commandLine\n"); -} - -sub BuildUnityScriptFor45 -{ - my $booCheckout = "$monoroot/../../boo/build"; - print(">>> Using mono prefix $monoprefix45\n"); - - # Build host is handling this - if (!$buildMachine) - { - if (!(-d "$booCheckout")) - { - print(">>> Checking out boo\n"); - GitClone("git://github.com/Unity-Technologies/boo.git", $booCheckout, "unity-trunk"); - } - } - - my $usCheckout = "$monoroot/../../unityscript/build"; - if (!$buildMachine) - { - if (!(-d "$usCheckout")) - { - print(">>> Checking out unity script\n"); - GitClone("git://github.com/Unity-Technologies/unityscript.git", $usCheckout, "unity-trunk"); - } - } - - my $boocCsproj = "$booCheckout/src/booc/booc.csproj"; - if (!(-f "$boocCsproj")) - { - die("Unable to locate : $boocCsproj\n"); - } - - XBuild("$boocCsproj", "/t:Rebuild"); - - print(">>> Mono Prefix 4.5 = $monoprefix45\n"); - foreach my $file (glob "$booCheckout/ide-build/Boo.Lang*.dll") - { - print(">>> Copying $file to $monoprefix45\n"); - copy($file, "$monoprefix45/."); - } - - copy("$booCheckout/ide-build/booc.exe", "$monoprefix45/."); - - foreach my $file (glob "$buildscriptsdir/add_to_build_results/monodistribution/lib/mono/4.5/*") - { - print(">>> Copying $file to $monoprefix45\n"); - copy($file, "$monoprefix45/."); - my $nameOnly = basename($file); - system("chmod", "755", "$monoprefix45/$nameOnly"); - } - - Booc45("-out:$monoprefix45/Boo.Lang.Extensions.dll -noconfig -nostdlib -srcdir:$booCheckout/src/Boo.Lang.Extensions -r:System.dll -r:System.Core.dll -r:mscorlib.dll -r:Boo.Lang.dll -r:Boo.Lang.Compiler.dll"); - Booc45("-out:$monoprefix45/Boo.Lang.Useful.dll -srcdir:$booCheckout/src/Boo.Lang.Useful -r:Boo.Lang.Parser"); - Booc45("-out:$monoprefix45/Boo.Lang.PatternMatching.dll -srcdir:$booCheckout/src/Boo.Lang.PatternMatching"); - - my $UnityScriptLangDLL = "$monoprefix45/UnityScript.Lang.dll"; - Booc45("-out:$UnityScriptLangDLL -srcdir:$usCheckout/src/UnityScript.Lang"); - - my $UnityScriptDLL = "$monoprefix45/UnityScript.dll"; - Booc45("-out:$UnityScriptDLL -srcdir:$usCheckout/src/UnityScript -r:$UnityScriptLangDLL -r:Boo.Lang.Parser.dll -r:Boo.Lang.PatternMatching.dll"); - Booc45("-out:$monoprefix45/us.exe -srcdir:$usCheckout/src/us -r:$UnityScriptLangDLL -r:$UnityScriptDLL -r:Boo.Lang.Useful.dll"); - - # # unityscript test suite - # my $UnityScriptTestsCSharpDLL = "$usCheckout/src/UnityScript.Tests.CSharp/bin/Debug/UnityScript.Tests.CSharp.dll"; - # XBuild("$usCheckout/src/UnityScript.Tests.CSharp/UnityScript.Tests.CSharp.csproj", "/t:Rebuild"); - - my $usBuildDir = "$usCheckout/build"; - - if (!(-d "$usBuildDir")) - { - rmtree($usBuildDir); - } - - mkdir($usBuildDir); - - # my $UnityScriptTestsDLL = <$usBuildDir/UnityScript.Tests.dll>; - # Booc("-out:$UnityScriptTestsDLL -srcdir:$usCheckout/src/UnityScript.Tests -r:$UnityScriptLangDLL -r:$UnityScriptDLL -r:$UnityScriptTestsCSharpDLL -r:Boo.Lang.Compiler.dll -r:Boo.Lang.Useful.dll"); - - # cp("$UnityScriptTestsCSharpDLL $usBuildDir/"); - print(">>> Populating Unity Script Build Directory : $usBuildDir\n"); - foreach my $file (glob "$monoprefix45/Boo.*") - { - print(">>> Copying $file to $usBuildDir\n"); - copy($file, "$usBuildDir/."); - } - - foreach my $file (glob "$monoprefix45/UnityScript.*") - { - print(">>> Copying $file to $usBuildDir\n"); - copy($file, "$usBuildDir/."); - } - - print(">>> Copying $monoprefix45/us.exe to $usBuildDir\n"); - copy("$monoprefix45/us.exe", "$usBuildDir/."); - print(">>> Copying $monoprefix45/booc.exe to $usBuildDir\n"); - copy("$monoprefix45/booc.exe", "$usBuildDir/."); - # put unityscript and boo into their own directories that we can reference for compilation only in Unity - my $usLibDir = "$monoprefix/lib/mono/unityscript"; - - if (!(-d "$usLibDir")) - { - print(">>> Removing directory $usLibDir\n"); - rmtree($usLibDir); - } - - mkdir($usLibDir); - - foreach my $file (glob "$usBuildDir/*") - { - print(">>> Copying $file to $usLibDir\n"); - copy($file, "$usLibDir/."); - } -} +use Cwd; +use Cwd 'abs_path'; +use Getopt::Long; +use File::Basename; +use File::Path; +use File::Copy; +use lib ('.', 'perl_lib', 'external/buildscripts/perl_lib'); +use Tools qw(GitClone); + +system("source","~/.profile"); +print ">>> My Path: $ENV{PATH}\n"; + +my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); +my $monoroot = abs_path($monoroot); +my $buildscriptsdir = "$monoroot/external/buildscripts"; +my $monoprefix = "$monoroot/tmp/monoprefix"; +my $buildsroot = "$monoroot/builds"; +my $buildMachine = $ENV{UNITY_THISISABUILDMACHINE}; + +GetOptions( + 'monoprefix=s'=>\$monoprefix, +) or die ("illegal cmdline options"); + +my $xbuildPath = "$monoprefix/bin/xbuild"; +my $monoprefix45 = "$monoprefix/lib/mono/4.5"; + +if (!(-f "$xbuildPath")) +{ + die("Unable to locate xbuild at : $xbuildPath\n"); +} + +BuildUnityScriptFor45(); + +sub XBuild +{ + print(">>> Running : $monoprefix/bin/xbuild @_\n"); + system("$monoprefix/bin/xbuild", @_) eq 0 or die("Failed to xbuild @_\n"); +} + +sub Booc45 +{ + my $commandLine = shift; + + system("$monoprefix/bin/mono $monoprefix45/booc.exe -debug- $commandLine") eq 0 or die("booc failed to execute: $monoprefix/bin/booc -debug- $commandLine\n"); +} + +sub BuildUnityScriptFor45 +{ + my $booCheckout = "$monoroot/../../boo/build"; + print(">>> Using mono prefix $monoprefix45\n"); + + # Build host is handling this + if (!$buildMachine) + { + if (!(-d "$booCheckout")) + { + print(">>> Checking out boo\n"); + GitClone("git://github.com/Unity-Technologies/boo.git", $booCheckout, "unity-trunk"); + } + } + + my $usCheckout = "$monoroot/../../unityscript/build"; + if (!$buildMachine) + { + if (!(-d "$usCheckout")) + { + print(">>> Checking out unity script\n"); + GitClone("git://github.com/Unity-Technologies/unityscript.git", $usCheckout, "unity-trunk"); + } + } + + my $boocCsproj = "$booCheckout/src/booc/booc.csproj"; + if (!(-f "$boocCsproj")) + { + die("Unable to locate : $boocCsproj\n"); + } + + XBuild("$boocCsproj", "/t:Rebuild"); + + print(">>> Mono Prefix 4.5 = $monoprefix45\n"); + foreach my $file (glob "$booCheckout/ide-build/Boo.Lang*.dll") + { + print(">>> Copying $file to $monoprefix45\n"); + copy($file, "$monoprefix45/."); + } + + copy("$booCheckout/ide-build/booc.exe", "$monoprefix45/."); + + foreach my $file (glob "$buildscriptsdir/add_to_build_results/monodistribution/lib/mono/4.5/*") + { + print(">>> Copying $file to $monoprefix45\n"); + copy($file, "$monoprefix45/."); + my $nameOnly = basename($file); + system("chmod", "755", "$monoprefix45/$nameOnly"); + } + + Booc45("-out:$monoprefix45/Boo.Lang.Extensions.dll -noconfig -nostdlib -srcdir:$booCheckout/src/Boo.Lang.Extensions -r:System.dll -r:System.Core.dll -r:mscorlib.dll -r:Boo.Lang.dll -r:Boo.Lang.Compiler.dll"); + Booc45("-out:$monoprefix45/Boo.Lang.Useful.dll -srcdir:$booCheckout/src/Boo.Lang.Useful -r:Boo.Lang.Parser"); + Booc45("-out:$monoprefix45/Boo.Lang.PatternMatching.dll -srcdir:$booCheckout/src/Boo.Lang.PatternMatching"); + + my $UnityScriptLangDLL = "$monoprefix45/UnityScript.Lang.dll"; + Booc45("-out:$UnityScriptLangDLL -srcdir:$usCheckout/src/UnityScript.Lang"); + + my $UnityScriptDLL = "$monoprefix45/UnityScript.dll"; + Booc45("-out:$UnityScriptDLL -srcdir:$usCheckout/src/UnityScript -r:$UnityScriptLangDLL -r:Boo.Lang.Parser.dll -r:Boo.Lang.PatternMatching.dll"); + Booc45("-out:$monoprefix45/us.exe -srcdir:$usCheckout/src/us -r:$UnityScriptLangDLL -r:$UnityScriptDLL -r:Boo.Lang.Useful.dll"); + + # # unityscript test suite + # my $UnityScriptTestsCSharpDLL = "$usCheckout/src/UnityScript.Tests.CSharp/bin/Debug/UnityScript.Tests.CSharp.dll"; + # XBuild("$usCheckout/src/UnityScript.Tests.CSharp/UnityScript.Tests.CSharp.csproj", "/t:Rebuild"); + + my $usBuildDir = "$usCheckout/build"; + + if (!(-d "$usBuildDir")) + { + rmtree($usBuildDir); + } + + mkdir($usBuildDir); + + # my $UnityScriptTestsDLL = <$usBuildDir/UnityScript.Tests.dll>; + # Booc("-out:$UnityScriptTestsDLL -srcdir:$usCheckout/src/UnityScript.Tests -r:$UnityScriptLangDLL -r:$UnityScriptDLL -r:$UnityScriptTestsCSharpDLL -r:Boo.Lang.Compiler.dll -r:Boo.Lang.Useful.dll"); + + # cp("$UnityScriptTestsCSharpDLL $usBuildDir/"); + print(">>> Populating Unity Script Build Directory : $usBuildDir\n"); + foreach my $file (glob "$monoprefix45/Boo.*") + { + print(">>> Copying $file to $usBuildDir\n"); + copy($file, "$usBuildDir/."); + } + + foreach my $file (glob "$monoprefix45/UnityScript.*") + { + print(">>> Copying $file to $usBuildDir\n"); + copy($file, "$usBuildDir/."); + } + + print(">>> Copying $monoprefix45/us.exe to $usBuildDir\n"); + copy("$monoprefix45/us.exe", "$usBuildDir/."); + print(">>> Copying $monoprefix45/booc.exe to $usBuildDir\n"); + copy("$monoprefix45/booc.exe", "$usBuildDir/."); + # put unityscript and boo into their own directories that we can reference for compilation only in Unity + my $usLibDir = "$monoprefix/lib/mono/unityscript"; + + if (!(-d "$usLibDir")) + { + print(">>> Removing directory $usLibDir\n"); + rmtree($usLibDir); + } + + mkdir($usLibDir); + + foreach my $file (glob "$usBuildDir/*") + { + print(">>> Copying $file to $usLibDir\n"); + copy($file, "$usLibDir/."); + } +} diff --git a/external/buildscripts/build_win_no_cygwin.pl b/external/buildscripts/build_win_no_cygwin.pl index 17c0d6927a92..3249c10c959b 100644 --- a/external/buildscripts/build_win_no_cygwin.pl +++ b/external/buildscripts/build_win_no_cygwin.pl @@ -1,281 +1,281 @@ -use Cwd; -use Cwd 'abs_path'; -use Getopt::Long; -use File::Basename; -use File::Path; -use File::Copy; -use lib ('external/buildscripts', "../../Tools/perl_lib","perl_lib", 'external/buildscripts/perl_lib'); -use Tools qw(InstallNameTool); - -print ">>> PATH in Build All = $ENV{PATH}\n\n"; - -my $currentdir = getcwd(); - -my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); -my $monoroot = abs_path($monoroot); - -$monoroot =~ tr{/}{\\}; - -print ">>> monoroot = $monoroot\n"; - -my $buildscriptsdir = "$monoroot\\external\\buildscripts"; -my $addtoresultsdistdir = "$buildscriptsdir\\add_to_build_results\\monodistribution"; -my $monoprefix = "$monoroot\\tmp\\monoprefix"; -my $buildsroot = "$monoroot\\builds"; -my $distdir = "$buildsroot\\monodistribution"; -my $buildMachine = $ENV{UNITY_THISISABUILDMACHINE}; - -my $build=0; -my $clean=0; -my $artifact=0; -my $debug=0; -my $checkoutOnTheFly=0; -my $forceDefaultBuildDeps=0; -my $existingMonoRootPath = ''; -my $arch32 = 0; -my $winPerl = "perl"; -my $winMonoRoot = $monoroot; -my $msBuildVersion = "14.0"; -my $buildDeps = ""; - -print(">>> Build All Args = @ARGV\n"); - -GetOptions( - 'build=i'=>\$build, - 'clean=i'=>\$clean, - 'artifact=i'=>\$artifact, - 'debug=i'=>\$debug, - 'arch32=i'=>\$arch32, - 'existingmono=s'=>\$existingMonoRootPath, - 'winperl=s'=>\$winPerl, - 'winmonoroot=s'=>\$winMonoRoot, - 'msbuildversion=s'=>\$msBuildVersion, - 'checkoutonthefly=i'=>\$checkoutOnTheFly, - 'builddeps=s'=>\$buildDeps, - 'forcedefaultbuilddeps=i'=>\$forceDefaultBuildDeps, -) or die ("illegal cmdline options"); - -my $monoRevision = `git rev-parse HEAD`; -chdir("$buildscriptsdir") eq 1 or die ("failed to chdir : $buildscriptsdir\n"); -my $buildScriptsRevision = `git rev-parse HEAD`; -chdir("$monoroot") eq 1 or die ("failed to chdir : $monoroot\n"); - -print(">>> Mono Revision = $monoRevision\n"); -print(">>> Build Scripts Revision = $buildScriptsRevision\n"); - -# Do any settings agnostic per-platform stuff -my $externalBuildDeps = ""; - -if ($buildDeps ne "" && not $forceDefaultBuildDeps) -{ - $externalBuildDeps = $buildDeps; -} -else -{ - $externalBuildDeps = "$monoroot/../../mono-build-deps/build"; -} - -my $existingExternalMonoRoot = "$externalBuildDeps\\mono"; -my $existingExternalMono = "$existingExternalMonoRoot\\win"; - -if ($clean) -{ - print(">>> Cleaning $monoprefix\n"); - rmtree($monoprefix); -} - -# ******************* Build Stage ************************** - -if ($build) -{ - if ($existingMonoRootPath eq "") - { - print(">>> No existing mono supplied. Checking for external...\n"); - - if (!(-d "$externalBuildDeps")) - { - if (not $checkoutonthefly) - { - print(">>> No external build deps found. Might as well try to check them out. If it fails, we'll continue and trust mono is in your PATH\n"); - } - - # Check out on the fly - print(">>> Checking out mono build dependencies to : $externalBuildDeps\n"); - my $repo = "https://ono.unity3d.com/unity-extra/mono-build-deps"; - print(">>> Cloning $repo at $externalBuildDeps\n"); - my $checkoutResult = system("hg", "clone", $repo, "$externalBuildDeps"); - - if ($checkoutOnTheFly && $checkoutResult ne 0) - { - die("failed to checkout mono build dependencies\n"); - } - } - - if (-d "$existingExternalMono") - { - print(">>> External mono found at : $existingExternalMono\n"); - - if (-d "$existingExternalMono/builds") - { - print(">>> Mono already extracted at : $existingExternalMono/builds\n"); - } - - if (!(-d "$existingExternalMono/builds")) - { - # We need to extract builds.zip - print(">>> Extracting mono builds.zip...\n"); - my $SevenZip = "$externalBuildDeps/7z/win64/7za.exe"; - print(">>> Using 7z : $SevenZip\n"); - system("$SevenZip", "x", "$existingExternalMono/builds.zip", "-o$existingExternalMono") eq 0 or die("Failed extracting mono builds.zip\n"); - } - - $existingMonoRootPath = "$existingExternalMono/builds"; - } - else - { - print(">>> No external mono found. Trusting a new enough mono is in your PATH.\n"); - } - } - - if ($existingMonoRootPath ne "" && !(-d $existingMonoRootPath)) - { - die("Existing mono not found at : $existingMonoRootPath\n"); - } - - system("$winPerl", "$winMonoRoot/external/buildscripts/build_runtime_vs.pl", "--build=$build", "--arch32=$arch32", "--msbuildversion=$msBuildVersion", "--clean=$clean", "--debug=$debug", "--gc=bdwgc") eq 0 or die ('failed building mono bdwgc with VS\n'); - system("$winPerl", "$winMonoRoot/external/buildscripts/build_runtime_vs.pl", "--build=$build", "--arch32=$arch32", "--msbuildversion=$msBuildVersion", "--clean=$clean", "--debug=$debug", "--gc=sgen") eq 0 or die ('failed building mono sgen with VS\n'); - - if (!(-d "$monoroot\\tmp")) - { - print(">>> Creating directory $monoroot\\tmp\n"); - system("mkdir $monoroot\\tmp") eq 0 or die ("failing creating $monoroot\\tmp\n");; - } - - if (!(-d "$monoprefix")) - { - print(">>> Creating directory $monoprefix\n"); - system("mkdir $monoprefix") eq 0 or die ("failing creating $monoprefix\n");; - } - - if (!(-d "$monoprefix\\bin")) - { - print(">>> Creating directory $monoprefix\\bin\n"); - system("mkdir $monoprefix\\bin") eq 0 or die ("failing creating $monoprefix\\bin\n");; - } - - # Copy over the VS built stuff that we want to use instead into the prefix directory - my $archNameForBuild = $arch32 ? 'Win32' : 'x64'; - my $configDirName = $debug ? "Debug" : "Release"; - - copy("$monoroot/msvc/build/bdwgc/$archNameForBuild/bin/$configDirName/mono-bdwgc.exe", "$monoprefix/bin/.") or die ("failed copying mono-bdwgc.exe\n"); - copy("$monoroot/msvc/build/bdwgc/$archNameForBuild/bin/$configDirName/mono-2.0-bdwgc.dll", "$monoprefix/bin/.") or die ("failed copying mono-2.0-bdwgc.dll\n"); - copy("$monoroot/msvc/build/bdwgc/$archNameForBuild/bin/$configDirName/mono-2.0-bdwgc.pdb", "$monoprefix/bin/.") or die ("failed copying mono-2.0-bdwgc.pdb\n"); - - copy("$monoroot/msvc/build/sgen/$archNameForBuild/bin/$configDirName/mono-sgen.exe", "$monoprefix/bin/.") or die ("failed copying mono-sgen.exe\n"); - copy("$monoroot/msvc/build/sgen/$archNameForBuild/bin/$configDirName/mono-2.0-sgen.dll", "$monoprefix/bin/.") or die ("failed copying mono-2.0-sgen.dll\n"); - copy("$monoroot/msvc/build/sgen/$archNameForBuild/bin/$configDirName/mono-2.0-sgen.pdb", "$monoprefix/bin/.") or die ("failed copying mono-2.0-sgen.pdb\n"); - - # sgen as default exe - copy("$monoroot/msvc/build/sgen/$archNameForBuild/bin/$configDirName/mono-sgen.exe", "$monoprefix/bin/mono.exe") or die ("failed copying mono-sgen.exe to mono.exe\n"); - - copy("$monoroot/msvc/build/bdwgc/$archNameForBuild/bin/$configDirName/MonoPosixHelper.dll", "$monoprefix/bin/.") or die ("failed copying MonoPosixHelper.dll\n"); - copy("$monoroot/msvc/build/bdwgc/$archNameForBuild/bin/$configDirName/MonoPosixHelper.pdb", "$monoprefix/bin/.") or die ("failed copying MonoPosixHelper.pdb\n"); - - system("xcopy /y /f $addtoresultsdistdir\\bin\\*.* $monoprefix\\bin\\") eq 0 or die ("Failed copying $addtoresultsdistdir/bin to $monoprefix/bin\n"); -} - -# ******************* Artifact Stage ************************** - -if ($artifact) -{ - print(">>> Creating artifact...\n"); - - # Do the platform specific logic to create the builds output structure that we want - - my $embedDirRoot = "$buildsroot\\embedruntimes"; - - my $embedDirArchDestination = $arch32 ? "$embedDirRoot\\win32" : "$embedDirRoot\\win64"; - my $distDirArchBin = $arch32 ? "$distdir\\bin" : "$distdir\\bin-x64"; - my $versionsOutputFile = $arch32 ? "$buildsroot\\versions-win32.txt" : "$buildsroot\\versions-win64.txt"; - - # Make sure the directory for our architecture is clean before we copy stuff into it - if (-d "$embedDirArchDestination") - { - print(">>> Cleaning $embedDirArchDestination\n"); - rmtree($embedDirArchDestination); - } - - if (-d "$distDirArchBin") - { - print(">>> Cleaning $distDirArchBin\n"); - rmtree($distDirArchBin); - } - - if (!(-d "$buildsroot")) - { - print(">>> Creating directory $buildsroot\n"); - system("mkdir $buildsroot") eq 0 or die("failed to create directory $buildsroot\n"); - } - - if (!(-d "$embedDirRoot")) - { - print(">>> Creating directory $embedDirRoot\n"); - system("mkdir $embedDirRoot") eq 0 or die("failed to create directory $embedDirRoot\n"); - } - - if (!(-d "$distdir")) - { - print(">>> Creating directory $distdir\n"); - system("mkdir $distdir") eq 0 or die("failed to create directory $distdir\n"); - } - - print(">>> Creating directory $embedDirArchDestination\n"); - system("mkdir $embedDirArchDestination") eq 0 or die("failed to create directory $embedDirArchDestination\n"); - - print(">>> Creating directory $distDirArchBin\n"); - system("mkdir $distDirArchBin") eq 0 or die("failed to create directory $distDirArchBin\n"); - - # embedruntimes directory setup - print(">>> Creating embedruntimes directory : $embedDirArchDestination\n"); - - copy("$monoprefix/bin/mono-2.0-bdwgc.dll", "$embedDirArchDestination/.") or die ("failed copying mono-2.0-bdwgc.dll\n"); - copy("$monoprefix/bin/mono-2.0-bdwgc.pdb", "$embedDirArchDestination/.") or die ("failed copying mono-2.0-bdwgc.pdb\n"); - - copy("$monoprefix/bin/mono-2.0-sgen.dll", "$embedDirArchDestination/.") or die ("failed copying mono-2.0-sgen.dll\n"); - copy("$monoprefix/bin/mono-2.0-sgen.pdb", "$embedDirArchDestination/.") or die ("failed copying mono-2.0-sgen.pdb\n"); - - copy("$monoprefix/bin/MonoPosixHelper.dll", "$embedDirArchDestination/.") or die ("failed copying MonoPosixHelper.dll\n"); - copy("$monoprefix/bin/MonoPosixHelper.pdb", "$embedDirArchDestination/.") or die ("failed copying MonoPosixHelper.pdb\n"); - - # monodistribution directory setup - print(">>> Creating monodistribution directory\n"); - copy("$monoprefix/bin/mono-2.0-bdwgc.dll", "$distDirArchBin/.") or die ("failed copying mono-2.0-bdwgc.dll\n"); - copy("$monoprefix/bin/mono-2.0-bdwgc.pdb", "$distDirArchBin/.") or die ("failed copying mono-2.0-bdwgc.pdb\n"); - - copy("$monoprefix/bin/mono-2.0-sgen.dll", "$distDirArchBin/.") or die ("failed copying mono-2.0-sgen.dll\n"); - copy("$monoprefix/bin/mono-2.0-sgen.pdb", "$distDirArchBin/.") or die ("failed copying mono-2.0-sgen.pdb\n"); - - copy("$monoprefix/bin/mono-sgen.exe", "$distDirArchBin/.") or die ("failed copying mono-sgen.exe\n"); - copy("$monoprefix/bin/mono-bdwgc.exe", "$distDirArchBin/.") or die ("failed copying mono-bdwgc.exe\n"); - copy("$monoprefix/bin/mono.exe", "$distDirArchBin/.") or die ("failed copying mono.exe\n"); - - copy("$monoprefix/bin/MonoPosixHelper.dll", "$distDirArchBin/.") or die ("failed copying MonoPosixHelper.dll\n"); - copy("$monoprefix/bin/MonoPosixHelper.pdb", "$distDirArchBin/.") or die ("failed copying MonoPosixHelper.pdb\n"); - - - # Output version information - print(">>> Creating version file : $versionsOutputFile\n"); - open(my $fh, '>', $versionsOutputFile) or die "Could not open file '$versionsOutputFile' $!"; - say $fh "mono-version ="; - my $monoVersionInfo = `$distDirArchBin\\mono --version`; - say $fh "$monoVersionInfo"; - say $fh "unity-mono-revision = $monoRevision"; - say $fh "unity-mono-build-scripts-revision = $buildScriptsRevision"; - my $tmp = `date /T`; - say $fh "$tmp"; - close $fh; -} -else -{ - print(">>> Skipping artifact creation\n"); -} +use Cwd; +use Cwd 'abs_path'; +use Getopt::Long; +use File::Basename; +use File::Path; +use File::Copy; +use lib ('external/buildscripts', "../../Tools/perl_lib","perl_lib", 'external/buildscripts/perl_lib'); +use Tools qw(InstallNameTool); + +print ">>> PATH in Build All = $ENV{PATH}\n\n"; + +my $currentdir = getcwd(); + +my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); +my $monoroot = abs_path($monoroot); + +$monoroot =~ tr{/}{\\}; + +print ">>> monoroot = $monoroot\n"; + +my $buildscriptsdir = "$monoroot\\external\\buildscripts"; +my $addtoresultsdistdir = "$buildscriptsdir\\add_to_build_results\\monodistribution"; +my $monoprefix = "$monoroot\\tmp\\monoprefix"; +my $buildsroot = "$monoroot\\builds"; +my $distdir = "$buildsroot\\monodistribution"; +my $buildMachine = $ENV{UNITY_THISISABUILDMACHINE}; + +my $build=0; +my $clean=0; +my $artifact=0; +my $debug=0; +my $checkoutOnTheFly=0; +my $forceDefaultBuildDeps=0; +my $existingMonoRootPath = ''; +my $arch32 = 0; +my $winPerl = "perl"; +my $winMonoRoot = $monoroot; +my $msBuildVersion = "14.0"; +my $buildDeps = ""; + +print(">>> Build All Args = @ARGV\n"); + +GetOptions( + 'build=i'=>\$build, + 'clean=i'=>\$clean, + 'artifact=i'=>\$artifact, + 'debug=i'=>\$debug, + 'arch32=i'=>\$arch32, + 'existingmono=s'=>\$existingMonoRootPath, + 'winperl=s'=>\$winPerl, + 'winmonoroot=s'=>\$winMonoRoot, + 'msbuildversion=s'=>\$msBuildVersion, + 'checkoutonthefly=i'=>\$checkoutOnTheFly, + 'builddeps=s'=>\$buildDeps, + 'forcedefaultbuilddeps=i'=>\$forceDefaultBuildDeps, +) or die ("illegal cmdline options"); + +my $monoRevision = `git rev-parse HEAD`; +chdir("$buildscriptsdir") eq 1 or die ("failed to chdir : $buildscriptsdir\n"); +my $buildScriptsRevision = `git rev-parse HEAD`; +chdir("$monoroot") eq 1 or die ("failed to chdir : $monoroot\n"); + +print(">>> Mono Revision = $monoRevision\n"); +print(">>> Build Scripts Revision = $buildScriptsRevision\n"); + +# Do any settings agnostic per-platform stuff +my $externalBuildDeps = ""; + +if ($buildDeps ne "" && not $forceDefaultBuildDeps) +{ + $externalBuildDeps = $buildDeps; +} +else +{ + $externalBuildDeps = "$monoroot/../../mono-build-deps/build"; +} + +my $existingExternalMonoRoot = "$externalBuildDeps\\mono"; +my $existingExternalMono = "$existingExternalMonoRoot\\win"; + +if ($clean) +{ + print(">>> Cleaning $monoprefix\n"); + rmtree($monoprefix); +} + +# ******************* Build Stage ************************** + +if ($build) +{ + if ($existingMonoRootPath eq "") + { + print(">>> No existing mono supplied. Checking for external...\n"); + + if (!(-d "$externalBuildDeps")) + { + if (not $checkoutonthefly) + { + print(">>> No external build deps found. Might as well try to check them out. If it fails, we'll continue and trust mono is in your PATH\n"); + } + + # Check out on the fly + print(">>> Checking out mono build dependencies to : $externalBuildDeps\n"); + my $repo = "https://ono.unity3d.com/unity-extra/mono-build-deps"; + print(">>> Cloning $repo at $externalBuildDeps\n"); + my $checkoutResult = system("hg", "clone", $repo, "$externalBuildDeps"); + + if ($checkoutOnTheFly && $checkoutResult ne 0) + { + die("failed to checkout mono build dependencies\n"); + } + } + + if (-d "$existingExternalMono") + { + print(">>> External mono found at : $existingExternalMono\n"); + + if (-d "$existingExternalMono/builds") + { + print(">>> Mono already extracted at : $existingExternalMono/builds\n"); + } + + if (!(-d "$existingExternalMono/builds")) + { + # We need to extract builds.zip + print(">>> Extracting mono builds.zip...\n"); + my $SevenZip = "$externalBuildDeps/7z/win64/7za.exe"; + print(">>> Using 7z : $SevenZip\n"); + system("$SevenZip", "x", "$existingExternalMono/builds.zip", "-o$existingExternalMono") eq 0 or die("Failed extracting mono builds.zip\n"); + } + + $existingMonoRootPath = "$existingExternalMono/builds"; + } + else + { + print(">>> No external mono found. Trusting a new enough mono is in your PATH.\n"); + } + } + + if ($existingMonoRootPath ne "" && !(-d $existingMonoRootPath)) + { + die("Existing mono not found at : $existingMonoRootPath\n"); + } + + system("$winPerl", "$winMonoRoot/external/buildscripts/build_runtime_vs.pl", "--build=$build", "--arch32=$arch32", "--msbuildversion=$msBuildVersion", "--clean=$clean", "--debug=$debug", "--gc=bdwgc") eq 0 or die ('failed building mono bdwgc with VS\n'); + system("$winPerl", "$winMonoRoot/external/buildscripts/build_runtime_vs.pl", "--build=$build", "--arch32=$arch32", "--msbuildversion=$msBuildVersion", "--clean=$clean", "--debug=$debug", "--gc=sgen") eq 0 or die ('failed building mono sgen with VS\n'); + + if (!(-d "$monoroot\\tmp")) + { + print(">>> Creating directory $monoroot\\tmp\n"); + system("mkdir $monoroot\\tmp") eq 0 or die ("failing creating $monoroot\\tmp\n");; + } + + if (!(-d "$monoprefix")) + { + print(">>> Creating directory $monoprefix\n"); + system("mkdir $monoprefix") eq 0 or die ("failing creating $monoprefix\n");; + } + + if (!(-d "$monoprefix\\bin")) + { + print(">>> Creating directory $monoprefix\\bin\n"); + system("mkdir $monoprefix\\bin") eq 0 or die ("failing creating $monoprefix\\bin\n");; + } + + # Copy over the VS built stuff that we want to use instead into the prefix directory + my $archNameForBuild = $arch32 ? 'Win32' : 'x64'; + my $configDirName = $debug ? "Debug" : "Release"; + + copy("$monoroot/msvc/build/bdwgc/$archNameForBuild/bin/$configDirName/mono-bdwgc.exe", "$monoprefix/bin/.") or die ("failed copying mono-bdwgc.exe\n"); + copy("$monoroot/msvc/build/bdwgc/$archNameForBuild/bin/$configDirName/mono-2.0-bdwgc.dll", "$monoprefix/bin/.") or die ("failed copying mono-2.0-bdwgc.dll\n"); + copy("$monoroot/msvc/build/bdwgc/$archNameForBuild/bin/$configDirName/mono-2.0-bdwgc.pdb", "$monoprefix/bin/.") or die ("failed copying mono-2.0-bdwgc.pdb\n"); + + copy("$monoroot/msvc/build/sgen/$archNameForBuild/bin/$configDirName/mono-sgen.exe", "$monoprefix/bin/.") or die ("failed copying mono-sgen.exe\n"); + copy("$monoroot/msvc/build/sgen/$archNameForBuild/bin/$configDirName/mono-2.0-sgen.dll", "$monoprefix/bin/.") or die ("failed copying mono-2.0-sgen.dll\n"); + copy("$monoroot/msvc/build/sgen/$archNameForBuild/bin/$configDirName/mono-2.0-sgen.pdb", "$monoprefix/bin/.") or die ("failed copying mono-2.0-sgen.pdb\n"); + + # sgen as default exe + copy("$monoroot/msvc/build/sgen/$archNameForBuild/bin/$configDirName/mono-sgen.exe", "$monoprefix/bin/mono.exe") or die ("failed copying mono-sgen.exe to mono.exe\n"); + + copy("$monoroot/msvc/build/bdwgc/$archNameForBuild/bin/$configDirName/MonoPosixHelper.dll", "$monoprefix/bin/.") or die ("failed copying MonoPosixHelper.dll\n"); + copy("$monoroot/msvc/build/bdwgc/$archNameForBuild/bin/$configDirName/MonoPosixHelper.pdb", "$monoprefix/bin/.") or die ("failed copying MonoPosixHelper.pdb\n"); + + system("xcopy /y /f $addtoresultsdistdir\\bin\\*.* $monoprefix\\bin\\") eq 0 or die ("Failed copying $addtoresultsdistdir/bin to $monoprefix/bin\n"); +} + +# ******************* Artifact Stage ************************** + +if ($artifact) +{ + print(">>> Creating artifact...\n"); + + # Do the platform specific logic to create the builds output structure that we want + + my $embedDirRoot = "$buildsroot\\embedruntimes"; + + my $embedDirArchDestination = $arch32 ? "$embedDirRoot\\win32" : "$embedDirRoot\\win64"; + my $distDirArchBin = $arch32 ? "$distdir\\bin" : "$distdir\\bin-x64"; + my $versionsOutputFile = $arch32 ? "$buildsroot\\versions-win32.txt" : "$buildsroot\\versions-win64.txt"; + + # Make sure the directory for our architecture is clean before we copy stuff into it + if (-d "$embedDirArchDestination") + { + print(">>> Cleaning $embedDirArchDestination\n"); + rmtree($embedDirArchDestination); + } + + if (-d "$distDirArchBin") + { + print(">>> Cleaning $distDirArchBin\n"); + rmtree($distDirArchBin); + } + + if (!(-d "$buildsroot")) + { + print(">>> Creating directory $buildsroot\n"); + system("mkdir $buildsroot") eq 0 or die("failed to create directory $buildsroot\n"); + } + + if (!(-d "$embedDirRoot")) + { + print(">>> Creating directory $embedDirRoot\n"); + system("mkdir $embedDirRoot") eq 0 or die("failed to create directory $embedDirRoot\n"); + } + + if (!(-d "$distdir")) + { + print(">>> Creating directory $distdir\n"); + system("mkdir $distdir") eq 0 or die("failed to create directory $distdir\n"); + } + + print(">>> Creating directory $embedDirArchDestination\n"); + system("mkdir $embedDirArchDestination") eq 0 or die("failed to create directory $embedDirArchDestination\n"); + + print(">>> Creating directory $distDirArchBin\n"); + system("mkdir $distDirArchBin") eq 0 or die("failed to create directory $distDirArchBin\n"); + + # embedruntimes directory setup + print(">>> Creating embedruntimes directory : $embedDirArchDestination\n"); + + copy("$monoprefix/bin/mono-2.0-bdwgc.dll", "$embedDirArchDestination/.") or die ("failed copying mono-2.0-bdwgc.dll\n"); + copy("$monoprefix/bin/mono-2.0-bdwgc.pdb", "$embedDirArchDestination/.") or die ("failed copying mono-2.0-bdwgc.pdb\n"); + + copy("$monoprefix/bin/mono-2.0-sgen.dll", "$embedDirArchDestination/.") or die ("failed copying mono-2.0-sgen.dll\n"); + copy("$monoprefix/bin/mono-2.0-sgen.pdb", "$embedDirArchDestination/.") or die ("failed copying mono-2.0-sgen.pdb\n"); + + copy("$monoprefix/bin/MonoPosixHelper.dll", "$embedDirArchDestination/.") or die ("failed copying MonoPosixHelper.dll\n"); + copy("$monoprefix/bin/MonoPosixHelper.pdb", "$embedDirArchDestination/.") or die ("failed copying MonoPosixHelper.pdb\n"); + + # monodistribution directory setup + print(">>> Creating monodistribution directory\n"); + copy("$monoprefix/bin/mono-2.0-bdwgc.dll", "$distDirArchBin/.") or die ("failed copying mono-2.0-bdwgc.dll\n"); + copy("$monoprefix/bin/mono-2.0-bdwgc.pdb", "$distDirArchBin/.") or die ("failed copying mono-2.0-bdwgc.pdb\n"); + + copy("$monoprefix/bin/mono-2.0-sgen.dll", "$distDirArchBin/.") or die ("failed copying mono-2.0-sgen.dll\n"); + copy("$monoprefix/bin/mono-2.0-sgen.pdb", "$distDirArchBin/.") or die ("failed copying mono-2.0-sgen.pdb\n"); + + copy("$monoprefix/bin/mono-sgen.exe", "$distDirArchBin/.") or die ("failed copying mono-sgen.exe\n"); + copy("$monoprefix/bin/mono-bdwgc.exe", "$distDirArchBin/.") or die ("failed copying mono-bdwgc.exe\n"); + copy("$monoprefix/bin/mono.exe", "$distDirArchBin/.") or die ("failed copying mono.exe\n"); + + copy("$monoprefix/bin/MonoPosixHelper.dll", "$distDirArchBin/.") or die ("failed copying MonoPosixHelper.dll\n"); + copy("$monoprefix/bin/MonoPosixHelper.pdb", "$distDirArchBin/.") or die ("failed copying MonoPosixHelper.pdb\n"); + + + # Output version information + print(">>> Creating version file : $versionsOutputFile\n"); + open(my $fh, '>', $versionsOutputFile) or die "Could not open file '$versionsOutputFile' $!"; + say $fh "mono-version ="; + my $monoVersionInfo = `$distDirArchBin\\mono --version`; + say $fh "$monoVersionInfo"; + say $fh "unity-mono-revision = $monoRevision"; + say $fh "unity-mono-build-scripts-revision = $buildScriptsRevision"; + my $tmp = `date /T`; + say $fh "$tmp"; + close $fh; +} +else +{ + print(">>> Skipping artifact creation\n"); +} diff --git a/external/buildscripts/build_win_wrapper.pl b/external/buildscripts/build_win_wrapper.pl index bbe16f80b94b..1b40fc71af15 100644 --- a/external/buildscripts/build_win_wrapper.pl +++ b/external/buildscripts/build_win_wrapper.pl @@ -1,218 +1,218 @@ -use Cwd; -use Cwd 'abs_path'; -use Getopt::Long; -use File::Basename; -use File::Path; -use Config; - -print ">>> My Path: $ENV{PATH}\n\n"; - -my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); -my $monoroot = abs_path($monoroot); -my $buildScriptsRoot = "$monoroot/external/buildscripts"; -print ">>> Mono checkout found in $monoroot\n\n"; - -my $cygwinRootWindows = ""; -my $monoInstallLinux = ""; -my $checkoutOnTheFly=0; -my $buildDeps = ""; -my $forceDefaultBuildDeps = 0; - -my @thisScriptArgs = (); -my @passAlongArgs = (); -foreach my $arg (@ARGV) -{ - push @backupArgs, $arg; - - if ($arg =~ /^--cygwin=/) - { - push @thisScriptArgs, $arg; - } - elsif ($arg =~ /^--existingmono=/) - { - push @thisScriptArgs, $arg; - } - elsif ($arg =~ /^--checkoutonthefly=/) - { - push @thisScriptArgs, $arg; - push @passAlongArgs, $arg; - } - elsif ($arg =~ /^--builddeps=/) - { - push @thisScriptArgs, $arg; - push @passAlongArgs, $arg; - } - elsif ($arg =~ /^--forcedefaultbuilddeps=/) - { - push @thisScriptArgs, $arg; - push @passAlongArgs, $arg; - } - else - { - push @passAlongArgs, $arg; - } -} - -print(">>> This Script Args = @thisScriptArgs\n"); -print(">>> Pass Along Args = @passAlongArgs\n"); - -@ARGV = @thisScriptArgs; -GetOptions( - 'cygwin=s'=>\$cygwinRootWindows, - 'existingmono=s'=>\$monoInstallLinux, - 'checkoutonthefly=i'=>\$checkoutOnTheFly, - 'builddeps=s'=>\$buildDeps, - 'forcedefaultbuilddeps=i'=>\$forceDefaultBuildDeps, -); - -my $externalBuildDeps = ""; - -if ($buildDeps ne "") -{ - $externalBuildDeps = $buildDeps; -} -else -{ - if (-d "$monoroot/../../mono-build-deps/build" || $forceDefaultBuildDeps) - { - $externalBuildDeps = "$monoroot/../../mono-build-deps/build"; - } - - if (!(-d "$externalBuildDeps")) - { - if (not $checkoutonthefly && $cygwinRootWindows eq "") - { - print(">>> No external build deps found and --cygwin not used. Might as well try to check them out. If the checkout fails, we'll continue, but the build will probably fail\n"); - } - - # Check out on the fly - print(">>> Checking out mono build dependencies to : $externalBuildDeps\n"); - my $repo = "https://ono.unity3d.com/unity-extra/mono-build-deps"; - print(">>> Cloning $repo at $externalBuildDeps\n"); - my $checkoutResult = system("hg", "clone", $repo, "$externalBuildDeps"); - - if ($checkoutOnTheFly && $checkoutResult ne 0) - { - die("failed to checkout mono build dependencies\n"); - } - } -} - -print(">>> externalBuildDeps = $externalBuildDeps\n"); - -my $SevenZip = "$externalBuildDeps/7z/win64/7za.exe"; - -# Attempt to find common default cygwin install locations -if ($cygwinRootWindows eq "") -{ - print(">>> No cygwin install specified. Looking for defaults...\n"); - - my $externalCygwin = "$externalBuildDeps/cygwin64/builds"; - my $externalCygwinZip = "$externalBuildDeps/cygwin64/builds.zip"; - - if (-d "$externalCygwin") - { - $cygwinRootWindows = $externalCygwin; - print(">>> Found Cygwin at : $cygwinRootWindows\n"); - } - elsif(-f "$externalCygwinZip") - { - print(">>> Found unextracted cygwin builds.zip : $externalCygwinZip\n"); - print(">>> Using 7z : $SevenZip\n"); - print(">>> Extracting...\n"); - system("$SevenZip", "x", "$externalCygwinZip", "-o$externalBuildDeps/cygwin64") eq 0 or die("Failed extracting cygwin\n"); - $cygwinRootWindows = $externalCygwin; - } - else - { - if ($forceDefaultBuildDeps) - { - die("\nCould not fined Cygwin in default external build deps location : $externalBuildDeps\n") - } - else - { - if (-d "C:\\Cygwin64") - { - $cygwinRootWindows = "C:\\Cygwin64"; - print(">>> Found Cygwin at : $cygwinRootWindows\n"); - } - elsif (-d "C:\\Cygwin") - { - $cygwinRootWindows = "C:\\Cygwin"; - print(">>> Found Cygwin at : $cygwinRootWindows\n"); - } - else - { - die("\nCould not fined Cygwin. Define path using --cygwin=\n") - } - } - } -} -else -{ - print(">>> Cygwin Path = $cygwinRootWindows\n"); -} - -if ($monoInstallLinux eq "") -{ - print(">>> No mono install specified. Looking for defaults...\n"); - - my $externalMono = "$externalBuildDeps/mono/win/builds"; - my $externalMonoZip = "$externalBuildDeps/mono/win/builds.zip"; - - if (-d "$externalMono") - { - $monoInstallLinux = $externalMono; - $monoInstallLinux =~ s/\\/\//g; - print(">>> Found Mono at : $monoInstallLinux\n"); - } - elsif(-f "$externalMonoZip") - { - print(">>> Found unextracted mono builds.zip : $externalMonoZip\n"); - print(">>> Using 7z : $SevenZip\n"); - print(">>> Extracting...\n"); - system("$SevenZip", "x", "$externalMonoZip", "-o$externalBuildDeps/mono/win") eq 0 or die("Failed extracting mono\n"); - $monoInstallLinux = $externalMono; - $monoInstallLinux =~ s/\\/\//g; - print(">>> Found Mono at : $monoInstallLinux\n"); - } - else - { - if ($forceDefaultBuildDeps) - { - die("\nCould not fined mono in default external build deps location : $externalBuildDeps\n") - } - else - { - if (-d "C:\\Program Files (x86)\\Mono") - { - # Pass over the cygwin format since I already have it escaped correctly to survive - # crossing over the shell - $monoInstallLinux = "/cygdrive/c/Program\\ Files\\ \\(x86\\)/Mono"; - print(">>> Found Mono at : $monoInstallLinux\n"); - } - else - { - die("\n--existingmono= is required and should be in the cygwin path format\n"); - } - } - } -} -else -{ - $monoInstallLinux =~ s/\\/\//g; - print(">>> Linux Mono Path = $monoInstallLinux\n"); -} - -push @passAlongArgs, "--existingmono=$monoInstallLinux" if $monoInstallLinux ne ""; - -my $windowsPerl = $Config{perlpath}; -print ">>> Perl Exe = $windowsPerl\n"; -push @passAlongArgs, "--winperl=$windowsPerl"; -push @passAlongArgs, "--winmonoroot=$monoroot"; - -# In some cases the file gets windowsified, use SHELLOPTS to avoid issues instead of dos2unixing the file, which will cause it to show up as modified by source control -$ENV{'SHELLOPTS'} = "igncr"; - -print ">>> Calling $cygwinRootWindows\\bin\\sh.exe with @passAlongArgs"; -system("$cygwinRootWindows\\bin\\sh.exe", "$monoroot/external/buildscripts/build_win_wrapper.sh", @passAlongArgs) eq 0 or die("failed building mono\n"); +use Cwd; +use Cwd 'abs_path'; +use Getopt::Long; +use File::Basename; +use File::Path; +use Config; + +print ">>> My Path: $ENV{PATH}\n\n"; + +my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); +my $monoroot = abs_path($monoroot); +my $buildScriptsRoot = "$monoroot/external/buildscripts"; +print ">>> Mono checkout found in $monoroot\n\n"; + +my $cygwinRootWindows = ""; +my $monoInstallLinux = ""; +my $checkoutOnTheFly=0; +my $buildDeps = ""; +my $forceDefaultBuildDeps = 0; + +my @thisScriptArgs = (); +my @passAlongArgs = (); +foreach my $arg (@ARGV) +{ + push @backupArgs, $arg; + + if ($arg =~ /^--cygwin=/) + { + push @thisScriptArgs, $arg; + } + elsif ($arg =~ /^--existingmono=/) + { + push @thisScriptArgs, $arg; + } + elsif ($arg =~ /^--checkoutonthefly=/) + { + push @thisScriptArgs, $arg; + push @passAlongArgs, $arg; + } + elsif ($arg =~ /^--builddeps=/) + { + push @thisScriptArgs, $arg; + push @passAlongArgs, $arg; + } + elsif ($arg =~ /^--forcedefaultbuilddeps=/) + { + push @thisScriptArgs, $arg; + push @passAlongArgs, $arg; + } + else + { + push @passAlongArgs, $arg; + } +} + +print(">>> This Script Args = @thisScriptArgs\n"); +print(">>> Pass Along Args = @passAlongArgs\n"); + +@ARGV = @thisScriptArgs; +GetOptions( + 'cygwin=s'=>\$cygwinRootWindows, + 'existingmono=s'=>\$monoInstallLinux, + 'checkoutonthefly=i'=>\$checkoutOnTheFly, + 'builddeps=s'=>\$buildDeps, + 'forcedefaultbuilddeps=i'=>\$forceDefaultBuildDeps, +); + +my $externalBuildDeps = ""; + +if ($buildDeps ne "") +{ + $externalBuildDeps = $buildDeps; +} +else +{ + if (-d "$monoroot/../../mono-build-deps/build" || $forceDefaultBuildDeps) + { + $externalBuildDeps = "$monoroot/../../mono-build-deps/build"; + } + + if (!(-d "$externalBuildDeps")) + { + if (not $checkoutonthefly && $cygwinRootWindows eq "") + { + print(">>> No external build deps found and --cygwin not used. Might as well try to check them out. If the checkout fails, we'll continue, but the build will probably fail\n"); + } + + # Check out on the fly + print(">>> Checking out mono build dependencies to : $externalBuildDeps\n"); + my $repo = "https://ono.unity3d.com/unity-extra/mono-build-deps"; + print(">>> Cloning $repo at $externalBuildDeps\n"); + my $checkoutResult = system("hg", "clone", $repo, "$externalBuildDeps"); + + if ($checkoutOnTheFly && $checkoutResult ne 0) + { + die("failed to checkout mono build dependencies\n"); + } + } +} + +print(">>> externalBuildDeps = $externalBuildDeps\n"); + +my $SevenZip = "$externalBuildDeps/7z/win64/7za.exe"; + +# Attempt to find common default cygwin install locations +if ($cygwinRootWindows eq "") +{ + print(">>> No cygwin install specified. Looking for defaults...\n"); + + my $externalCygwin = "$externalBuildDeps/cygwin64/builds"; + my $externalCygwinZip = "$externalBuildDeps/cygwin64/builds.zip"; + + if (-d "$externalCygwin") + { + $cygwinRootWindows = $externalCygwin; + print(">>> Found Cygwin at : $cygwinRootWindows\n"); + } + elsif(-f "$externalCygwinZip") + { + print(">>> Found unextracted cygwin builds.zip : $externalCygwinZip\n"); + print(">>> Using 7z : $SevenZip\n"); + print(">>> Extracting...\n"); + system("$SevenZip", "x", "$externalCygwinZip", "-o$externalBuildDeps/cygwin64") eq 0 or die("Failed extracting cygwin\n"); + $cygwinRootWindows = $externalCygwin; + } + else + { + if ($forceDefaultBuildDeps) + { + die("\nCould not fined Cygwin in default external build deps location : $externalBuildDeps\n") + } + else + { + if (-d "C:\\Cygwin64") + { + $cygwinRootWindows = "C:\\Cygwin64"; + print(">>> Found Cygwin at : $cygwinRootWindows\n"); + } + elsif (-d "C:\\Cygwin") + { + $cygwinRootWindows = "C:\\Cygwin"; + print(">>> Found Cygwin at : $cygwinRootWindows\n"); + } + else + { + die("\nCould not fined Cygwin. Define path using --cygwin=\n") + } + } + } +} +else +{ + print(">>> Cygwin Path = $cygwinRootWindows\n"); +} + +if ($monoInstallLinux eq "") +{ + print(">>> No mono install specified. Looking for defaults...\n"); + + my $externalMono = "$externalBuildDeps/mono/win/builds"; + my $externalMonoZip = "$externalBuildDeps/mono/win/builds.zip"; + + if (-d "$externalMono") + { + $monoInstallLinux = $externalMono; + $monoInstallLinux =~ s/\\/\//g; + print(">>> Found Mono at : $monoInstallLinux\n"); + } + elsif(-f "$externalMonoZip") + { + print(">>> Found unextracted mono builds.zip : $externalMonoZip\n"); + print(">>> Using 7z : $SevenZip\n"); + print(">>> Extracting...\n"); + system("$SevenZip", "x", "$externalMonoZip", "-o$externalBuildDeps/mono/win") eq 0 or die("Failed extracting mono\n"); + $monoInstallLinux = $externalMono; + $monoInstallLinux =~ s/\\/\//g; + print(">>> Found Mono at : $monoInstallLinux\n"); + } + else + { + if ($forceDefaultBuildDeps) + { + die("\nCould not fined mono in default external build deps location : $externalBuildDeps\n") + } + else + { + if (-d "C:\\Program Files (x86)\\Mono") + { + # Pass over the cygwin format since I already have it escaped correctly to survive + # crossing over the shell + $monoInstallLinux = "/cygdrive/c/Program\\ Files\\ \\(x86\\)/Mono"; + print(">>> Found Mono at : $monoInstallLinux\n"); + } + else + { + die("\n--existingmono= is required and should be in the cygwin path format\n"); + } + } + } +} +else +{ + $monoInstallLinux =~ s/\\/\//g; + print(">>> Linux Mono Path = $monoInstallLinux\n"); +} + +push @passAlongArgs, "--existingmono=$monoInstallLinux" if $monoInstallLinux ne ""; + +my $windowsPerl = $Config{perlpath}; +print ">>> Perl Exe = $windowsPerl\n"; +push @passAlongArgs, "--winperl=$windowsPerl"; +push @passAlongArgs, "--winmonoroot=$monoroot"; + +# In some cases the file gets windowsified, use SHELLOPTS to avoid issues instead of dos2unixing the file, which will cause it to show up as modified by source control +$ENV{'SHELLOPTS'} = "igncr"; + +print ">>> Calling $cygwinRootWindows\\bin\\sh.exe with @passAlongArgs"; +system("$cygwinRootWindows\\bin\\sh.exe", "$monoroot/external/buildscripts/build_win_wrapper.sh", @passAlongArgs) eq 0 or die("failed building mono\n"); diff --git a/external/buildscripts/collect_allbuilds.pl b/external/buildscripts/collect_allbuilds.pl index d6316e937504..1dbb19dd7987 100644 --- a/external/buildscripts/collect_allbuilds.pl +++ b/external/buildscripts/collect_allbuilds.pl @@ -1,66 +1,66 @@ -use lib ('external/buildscripts/perl_lib'); -use Cwd 'abs_path'; -use File::Basename; -use File::Copy::Recursive qw(dircopy rmove); -use File::Path; -use Tools qw(InstallNameTool); - - -my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); -my $monoroot = abs_path($monoroot); - -my $path = "incomingbuilds/"; - -rmtree("collectedbuilds"); -mkpath("collectedbuilds"); - -my @folders = (); -opendir(DIR, $path) or die "cant find $path: $!"; -# Sort the directories alphabetically so that classlibs comes before the -# OSX universal runtime (in the osx-i386 directory). Both builds produce the same -# files in some cases (notably libMonoPosixHelper.dylib), and we need the -# universal runtime build to be second, since it produces a universal binary -# and the classlibs build produces a 32-bit binary only. -my @files = sort readdir(DIR); -while (defined(my $file = shift @files)) { - - next if $file =~ /^\.\.?$/; - if (-d "$path$file"){ - if (-f "$path$file/versions.txt") { - system("cat $path$file/versions.txt >> collectedbuilds/versions-aggregated.txt"); - } - dircopy("$path$file","collectedbuilds/") or die ("failed copying $path$file"); - push @folders,"$path$file"; - } -} -closedir(DIR); - -system("find collectedbuilds -type f -name mono -exec chmod +x {} \\;") eq 0 or die("Failed chmodding"); -system("find collectedbuilds -type f -name mono-sgen -exec chmod +x {} \\;") eq 0 or die("Failed chmodding"); -system("find collectedbuilds -type f -name pedump -exec chmod +x {} \\;") eq 0 or die("Failed chmodding"); - -chdir("collectedbuilds"); - -rmove('versions-aggregated.txt', 'versions.txt'); - -open(MYFILE,">built_by_teamcity.txt"); -print MYFILE "These builds were created by teamcity from svn revision $ENV{BUILD_VCS_NUMBER}\n"; -print MYFILE "TC projectname was: $ENV{TEAMCITY_PROJECT_NAME}\n"; -print MYFILE "TC buildconfigname was: $ENV{TEAMCITY_BUILDCONF_NAME}\n"; -close(MYFILE); - -system("zip -r builds.zip *") eq 0 or die("failed zipping up builds"); - -if($^O eq "linux") -{ - system("$monoroot/../../mono-build-deps/build/7z/linux64/7za a builds.7z * -x!builds.zip") eq 0 or die("failed 7z up builds"); -} -elsif($^O eq 'darwin') -{ - system("$monoroot/../../mono-build-deps/build/7z/osx/7za a builds.7z * -x!builds.zip") eq 0 or die("failed 7z up builds"); -} -else -{ - die("Unsupported platform for build collection.") -} - +use lib ('external/buildscripts/perl_lib'); +use Cwd 'abs_path'; +use File::Basename; +use File::Copy::Recursive qw(dircopy rmove); +use File::Path; +use Tools qw(InstallNameTool); + + +my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); +my $monoroot = abs_path($monoroot); + +my $path = "incomingbuilds/"; + +rmtree("collectedbuilds"); +mkpath("collectedbuilds"); + +my @folders = (); +opendir(DIR, $path) or die "cant find $path: $!"; +# Sort the directories alphabetically so that classlibs comes before the +# OSX universal runtime (in the osx-i386 directory). Both builds produce the same +# files in some cases (notably libMonoPosixHelper.dylib), and we need the +# universal runtime build to be second, since it produces a universal binary +# and the classlibs build produces a 32-bit binary only. +my @files = sort readdir(DIR); +while (defined(my $file = shift @files)) { + + next if $file =~ /^\.\.?$/; + if (-d "$path$file"){ + if (-f "$path$file/versions.txt") { + system("cat $path$file/versions.txt >> collectedbuilds/versions-aggregated.txt"); + } + dircopy("$path$file","collectedbuilds/") or die ("failed copying $path$file"); + push @folders,"$path$file"; + } +} +closedir(DIR); + +system("find collectedbuilds -type f -name mono -exec chmod +x {} \\;") eq 0 or die("Failed chmodding"); +system("find collectedbuilds -type f -name mono-sgen -exec chmod +x {} \\;") eq 0 or die("Failed chmodding"); +system("find collectedbuilds -type f -name pedump -exec chmod +x {} \\;") eq 0 or die("Failed chmodding"); + +chdir("collectedbuilds"); + +rmove('versions-aggregated.txt', 'versions.txt'); + +open(MYFILE,">built_by_teamcity.txt"); +print MYFILE "These builds were created by teamcity from svn revision $ENV{BUILD_VCS_NUMBER}\n"; +print MYFILE "TC projectname was: $ENV{TEAMCITY_PROJECT_NAME}\n"; +print MYFILE "TC buildconfigname was: $ENV{TEAMCITY_BUILDCONF_NAME}\n"; +close(MYFILE); + +system("zip -r builds.zip *") eq 0 or die("failed zipping up builds"); + +if($^O eq "linux") +{ + system("$monoroot/../../mono-build-deps/build/7z/linux64/7za a builds.7z * -x!builds.zip") eq 0 or die("failed 7z up builds"); +} +elsif($^O eq 'darwin') +{ + system("$monoroot/../../mono-build-deps/build/7z/osx/7za a builds.7z * -x!builds.zip") eq 0 or die("failed 7z up builds"); +} +else +{ + die("Unsupported platform for build collection.") +} +