diff --git a/.yamato/build_linux_x64_debug.yml b/.yamato/build_linux_x64_debug.yml index 99b2c7013e42b9..5bc76bf73fcb37 100644 --- a/.yamato/build_linux_x64_debug.yml +++ b/.yamato/build_linux_x64_debug.yml @@ -11,7 +11,7 @@ variables: ARTIFACT_FILENAME: {{globals.artifact_base_name}}-linux-x64.7z commands: - - ./.yamato/scripts/build_linux.sh Debug + - ./.yamato/scripts/build_yamato.sh --config=Debug artifacts: 7z-archives: diff --git a/.yamato/build_linux_x64_release.yml b/.yamato/build_linux_x64_release.yml index 7dcb3bcad4418b..14d28e73233c46 100644 --- a/.yamato/build_linux_x64_release.yml +++ b/.yamato/build_linux_x64_release.yml @@ -11,7 +11,7 @@ variables: ARTIFACT_FILENAME: {{globals.artifact_base_name}}-linux-x64.7z commands: - - ./.yamato/scripts/build_linux.sh Release + - ./.yamato/scripts/build_yamato.sh --config=Release artifacts: 7z-archives: diff --git a/.yamato/build_osx_arm64_debug.yml b/.yamato/build_osx_arm64_debug.yml index d92477c1b9b372..8a6e4b74c09d24 100644 --- a/.yamato/build_osx_arm64_debug.yml +++ b/.yamato/build_osx_arm64_debug.yml @@ -11,7 +11,7 @@ variables: ARTIFACT_FILENAME: {{globals.artifact_base_name}}-osx-arm64.7z commands: - - ./.yamato/scripts/build_osx.sh arm64 Debug + - ./.yamato/scripts/build_yamato.sh --arch=arm64 --config=Debug artifacts: 7z-archives: diff --git a/.yamato/build_osx_arm64_release.yml b/.yamato/build_osx_arm64_release.yml index c3e3cb7cc3ce20..a92b78ea84bd28 100644 --- a/.yamato/build_osx_arm64_release.yml +++ b/.yamato/build_osx_arm64_release.yml @@ -11,7 +11,7 @@ variables: ARTIFACT_FILENAME: {{globals.artifact_base_name}}-osx-arm64.7z commands: - - ./.yamato/scripts/build_osx.sh arm64 Release + - ./.yamato/scripts/build_yamato.sh --arch=arm64 --config=Release artifacts: 7z-archives: diff --git a/.yamato/build_osx_x64_debug.yml b/.yamato/build_osx_x64_debug.yml index 4647f5d38353a5..8de67a9a0ea5a7 100644 --- a/.yamato/build_osx_x64_debug.yml +++ b/.yamato/build_osx_x64_debug.yml @@ -11,7 +11,7 @@ variables: ARTIFACT_FILENAME: {{globals.artifact_base_name}}-osx-x64.7z commands: - - ./.yamato/scripts/build_osx.sh x64 Debug + - ./.yamato/scripts/build_yamato.sh --arch=x64 --config=Debug artifacts: 7z-archives: diff --git a/.yamato/build_osx_x64_release.yml b/.yamato/build_osx_x64_release.yml index 72b73c1c4a98cf..470f6cb42d76f8 100644 --- a/.yamato/build_osx_x64_release.yml +++ b/.yamato/build_osx_x64_release.yml @@ -11,7 +11,7 @@ variables: ARTIFACT_FILENAME: {{globals.artifact_base_name}}-osx-x64.7z commands: - - ./.yamato/scripts/build_osx.sh x64 Release + - ./.yamato/scripts/build_yamato.sh --arch=x64 --config=Release artifacts: 7z-archives: diff --git a/.yamato/build_windows_x64_debug.yml b/.yamato/build_windows_x64_debug.yml index 8a6b5a19e9b5d6..19af6c570395f8 100644 --- a/.yamato/build_windows_x64_debug.yml +++ b/.yamato/build_windows_x64_debug.yml @@ -4,17 +4,14 @@ name: Build Windows x64 Debug agent: type: Unity::VM - image: burst/burst-base:1.0.8-1195360 + image: platform-foundation/coreclr-windows:v0.0.1-1276296 flavor: b1.xlarge variables: ARTIFACT_FILENAME: {{globals.artifact_base_name}}-win-x64.7z commands: - - .yamato/scripts/build_windows.cmd x64 Debug - - powershell .yamato\scripts\download_7z.ps1 - - copy LICENSE.md artifacts\bin\microsoft.netcore.app.runtime.win-x64\Debug\runtimes\win-x64 - - artifacts\7za-win-x64\7za.exe a artifacts\unity\%ARTIFACT_FILENAME% .\artifacts\bin\microsoft.netcore.app.runtime.win-x64\Debug\runtimes\win-x64\* + - .yamato/scripts/build_yamato.cmd --arch=x64 --config=Debug artifacts: 7z-archives: diff --git a/.yamato/build_windows_x64_release.yml b/.yamato/build_windows_x64_release.yml index ffd331554f18da..10a525b40e4c90 100644 --- a/.yamato/build_windows_x64_release.yml +++ b/.yamato/build_windows_x64_release.yml @@ -4,17 +4,14 @@ name: Build Windows x64 Release agent: type: Unity::VM - image: burst/burst-base:1.0.8-1195360 + image: platform-foundation/coreclr-windows:v0.0.1-1276296 flavor: b1.xlarge variables: ARTIFACT_FILENAME: {{globals.artifact_base_name}}-win-x64.7z commands: - - .yamato/scripts/build_windows.cmd x64 Release - - powershell .yamato\scripts\download_7z.ps1 - - copy LICENSE.md artifacts\bin\microsoft.netcore.app.runtime.win-x64\Release\runtimes\win-x64 - - artifacts\7za-win-x64\7za.exe a artifacts\unity\%ARTIFACT_FILENAME% .\artifacts\bin\microsoft.netcore.app.runtime.win-x64\Release\runtimes\win-x64\* + - .yamato/scripts/build_yamato.cmd --arch=x64 --config=Release artifacts: 7z-archives: diff --git a/.yamato/build_windows_x86_debug.yml b/.yamato/build_windows_x86_debug.yml index 8eb742a8be5e63..fd32e4422be8ad 100644 --- a/.yamato/build_windows_x86_debug.yml +++ b/.yamato/build_windows_x86_debug.yml @@ -4,17 +4,14 @@ name: Build Windows x86 Debug agent: type: Unity::VM - image: burst/burst-base:1.0.8-1195360 + image: platform-foundation/coreclr-windows:v0.0.1-1276296 flavor: b1.xlarge variables: ARTIFACT_FILENAME: {{globals.artifact_base_name}}-win-x86.7z commands: - - .yamato/scripts/build_windows.cmd x86 Debug - - powershell .yamato\scripts\download_7z.ps1 - - copy LICENSE.md artifacts\bin\microsoft.netcore.app.runtime.win-x86\Debug\runtimes\win-x86 - - artifacts\7za-win-x64\7za.exe a artifacts\unity\%ARTIFACT_FILENAME% .\artifacts\bin\microsoft.netcore.app.runtime.win-x86\Debug\runtimes\win-x86\* + - .yamato/scripts/build_yamato.cmd --arch=x86 --config=Debug artifacts: 7z-archives: diff --git a/.yamato/build_windows_x86_release.yml b/.yamato/build_windows_x86_release.yml index c09240f65024c8..d3454e5a44bb3a 100644 --- a/.yamato/build_windows_x86_release.yml +++ b/.yamato/build_windows_x86_release.yml @@ -4,17 +4,14 @@ name: Build Windows x86 Release agent: type: Unity::VM - image: burst/burst-base:1.0.8-1195360 + image: platform-foundation/coreclr-windows:v0.0.1-1276296 flavor: b1.xlarge variables: ARTIFACT_FILENAME: {{globals.artifact_base_name}}-win-x86.7z commands: - - .yamato/scripts/build_windows.cmd x86 Release - - powershell .yamato\scripts\download_7z.ps1 - - copy LICENSE.md artifacts\bin\microsoft.netcore.app.runtime.win-x86\Release\runtimes\win-x86 - - artifacts\7za-win-x64\7za.exe a artifacts\unity\%ARTIFACT_FILENAME% .\artifacts\bin\microsoft.netcore.app.runtime.win-x86\Release\runtimes\win-x86\* + - .yamato/scripts/build_yamato.cmd --arch=x86 --config=Release artifacts: 7z-archives: diff --git a/.yamato/scripts/build_linux.sh b/.yamato/scripts/build_linux.sh deleted file mode 100755 index e3ac080ffd2a23..00000000000000 --- a/.yamato/scripts/build_linux.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/sh -set -e - -# Usage: build_linux.cmd -# -# Configuration is one of Debug or Release - Release is the default is not specified - -if [ "$1" = "" ]; then - configuration=Release -else - configuration=$1 -fi - -echo "*****************************" -echo "Unity: Starting CoreCLR build" -echo " Platform: Linux" -echo " Architecture: x64" -echo " Configuration: $configuration" -echo "*****************************" - -echo -echo "************************" -echo "Unity: Downloading 7-zip" -echo "************************" -echo -mkdir -p artifacts -curl https://public-stevedore.unity3d.com/r/public/7za-linux-x64/e6c75fb7ffda_e6a295cdcae3f74d315361883cf53f75141be2e739c020035f414a449d4876af.zip --output artifacts/7za-linux-x64.zip -unzip artifacts/7za-linux-x64.zip -d artifacts/7za-linux-x64 - -echo -echo "******************************" -echo "Unity: Building embedding host" -echo "******************************" -echo -./dotnet.sh build unity/managed.sln -c $configuration - -echo -echo "***********************" -echo "Unity: Building Null GC" -echo "***********************" -echo -cd unity/unitygc -mkdir -p $configuration -cd $configuration -cmake -DCMAKE_BUILD_TYPE=$configuration .. -cmake --build . -cd ../../../ - -echo -echo "*******************************" -echo "Unity: Building CoreCLR runtime" -echo "*******************************" -echo -./build.sh -subset clr+libs+libs -a x64 -c $configuration -ci -ninja - -echo -echo "*******************************" -echo "Unity: Copying built artifacts" -echo "*******************************" -echo -cp unity/unitygc/$configuration/libunitygc.so artifacts/bin/microsoft.netcore.app.runtime.linux-x64/$configuration/runtimes/linux-x64/native -cp unity/unity-embed-host/bin/$configuration/net7.0/unity-embed-host.dll artifacts/bin/microsoft.netcore.app.runtime.linux-x64/$configuration/runtimes/linux-x64/lib/net7.0 -cp unity/unity-embed-host/bin/$configuration/net7.0/unity-embed-host.dll artifacts/bin/microsoft.netcore.app.runtime.linux-x64/$configuration/runtimes/linux-x64/lib/net7.0 -cp LICENSE.md artifacts/bin/microsoft.netcore.app.runtime.linux-x64/$configuration/runtimes/linux-x64/. -artifacts/7za-linux-x64/7za a artifacts/unity/$ARTIFACT_FILENAME ./artifacts/bin/microsoft.netcore.app.runtime.linux-x64/$configuration/runtimes/linux-x64/* - -echo -echo "*********************************" -echo "Unity: Built CoreCLR successfully" -echo "*********************************" diff --git a/.yamato/scripts/build_osx.sh b/.yamato/scripts/build_osx.sh deleted file mode 100755 index ef12db7ab16ac0..00000000000000 --- a/.yamato/scripts/build_osx.sh +++ /dev/null @@ -1,95 +0,0 @@ -#!/bin/sh -set -e - -# Usage: build_osx.cmd -# -# Architecture is one of arm64 or x64 - the local machine architecture is the default if not specified -# Configuration is one of Debug or Release - Release is the default is not specified -# -# To specify Configuration, Architecture must be specified as well. - -if [ "$1" = "" ]; then - # Since the architecture was not specified, check the architecture - # of the host machine and use it. - if [ `uname -p` = "i386" ]; then - architecture=x64 - else - architecture=arm64 - fi -else - architecture=$1 -fi - -if [ "$2" = "" ]; then - configuration=Release -else - configuration=$2 -fi - -echo "*****************************" -echo "Unity: Starting CoreCLR build" -echo " Platform: macOS" -echo " Architecture: $architecture" -echo " Configuration: $configuration" -echo "*****************************" - -echo -echo "************************" -echo "Unity: Downloading 7-zip" -echo "************************" -echo -mkdir -p artifacts -curl https://public-stevedore.unity3d.com/r/public/7za-mac-x64/e6c75fb7ffda_5bd76652986a0e3756d1cfd7e84ce056a9e1dbfc5f70f0514a001f724c0fbad2.zip --output artifacts/7za-mac-x64.zip -unzip -o artifacts/7za-mac-x64.zip -d artifacts/7za-mac-x64 - -echo -echo "******************************" -echo "Unity: Building embedding host" -echo "******************************" -echo -./dotnet.sh build unity/managed.sln -c $configuration - -echo -echo "***********************" -echo "Unity: Building Null GC" -echo "***********************" -echo -cd unity/unitygc -mkdir -p $configuration -cd $configuration -if [ "$architecture" = "arm64" ]; then - extra_architecture_define=-DCMAKE_OSX_ARCHITECTURES=$architecture -else - extra_architecture_define= -fi -cmake $extra_architecture_define -DCMAKE_BUILD_TYPE=$configuration .. -cmake --build . -cd ../../../ - -echo -echo "*******************************" -echo "Unity: Building CoreCLR runtime" -echo "*******************************" -echo -if [ "$architecture" = "arm64" -a `uname -p` = "i386" ]; then - cross_build=true -else - cross_build=false -fi -LD_LIBRARY_PATH=/usr/local/opt/openssl/lib ./build.sh -subset clr+libs -a $architecture -c $configuration -ci -ninja /p:CrossBuild=$cross_build - -echo -echo "*******************************" -echo "Unity: Copying built artifacts" -echo "*******************************" -echo -cp unity/unitygc/$configuration/libunitygc.dylib artifacts/bin/microsoft.netcore.app.runtime.osx-$architecture/$configuration/runtimes/osx-$architecture/native -cp unity/unity-embed-host/bin/$configuration/net7.0/unity-embed-host.dll artifacts/bin/microsoft.netcore.app.runtime.osx-$architecture/$configuration/runtimes/osx-$architecture/lib/net7.0 -cp unity/unity-embed-host/bin/$configuration/net7.0/unity-embed-host.pdb artifacts/bin/microsoft.netcore.app.runtime.osx-$architecture/$configuration/runtimes/osx-$architecture/lib/net7.0 -cp LICENSE.md artifacts/bin/microsoft.netcore.app.runtime.osx-$architecture/$configuration/runtimes/osx-$architecture/. -artifacts/7za-mac-x64/7za a artifacts/unity/$ARTIFACT_FILENAME ./artifacts/bin/microsoft.netcore.app.runtime.osx-$architecture/$configuration/runtimes/osx-$architecture/* - -echo -echo "*********************************" -echo "Unity: Built CoreCLR successfully" -echo "*********************************" diff --git a/.yamato/scripts/build_windows.cmd b/.yamato/scripts/build_windows.cmd deleted file mode 100644 index c407c1f2054b62..00000000000000 --- a/.yamato/scripts/build_windows.cmd +++ /dev/null @@ -1,79 +0,0 @@ -@echo off - -rem Usage: build_windows.cmd -rem -rem Architecture is one of x86 or x64 - x64 is the default if not specified -rem Configuration is one of Debug or Release - Release is the default is not specified -rem -rem To specify Configuration, Architecture must be specified as well. - -if "%~1"=="" goto :default_architecture -set architecture=%1 -goto :set_configuration -:default_architecture -set architecture=x64 - -:set_configuration -if "%~2"=="" goto :default_configuration -set configuration=%2 -goto :run_build -:default_configuration -set configuration=Release - -:run_build - -echo ***************************** -echo Unity: Starting CoreCLR build -echo Platform: Windows -echo Architecture: %architecture% -echo Configuration: %configuration% -echo ***************************** - -echo. -echo ****************************** -echo Unity: Building embedding host -echo ****************************** -echo. -call dotnet build unity\managed.sln -c %configuration% || goto :error - -echo. -echo *********************** -echo Unity: Building Null GC -echo *********************** -echo. -if "%architecture%"=="x86" (set cmake_architecture=Win32) else (set cmake_architecture=x64) -cd unity\unitygc || goto :error -cmake . -A %cmake_architecture% || goto :error -cmake --build . --config %configuration% || goto :error -cd ../../ || goto :error - -echo. -echo ******************************* -echo Unity: Building CoreCLR runtime -echo ******************************* -echo. -call build.cmd -subset clr+libs -a %architecture% -c %configuration% -ci || goto :error - -echo. -echo ****************************** -echo Unity: Copying built artifacts -echo ****************************** -echo. -copy unity\unitygc\%configuration%\unitygc.dll artifacts\bin\microsoft.netcore.app.runtime.win-%architecture%\%configuration%\runtimes\win-%architecture%\native || goto :error -copy unity\unity-embed-host\bin\%configuration%\net7.0\unity-embed-host.dll artifacts\bin\microsoft.netcore.app.runtime.win-%architecture%\%configuration%\runtimes\win-%architecture%\lib\net7.0 || goto :error -copy unity\unity-embed-host\bin\%configuration%\net7.0\unity-embed-host.pdb artifacts\bin\microsoft.netcore.app.runtime.win-%architecture%\%configuration%\runtimes\win-%architecture%\lib\net7.0 || goto :error - -rem Every thing succeeded - jump to the end of the file and return a 0 exit code -echo. -echo ********************************* -echo Unity: Built CoreCLR successfully -echo ********************************* -goto :EOF - -rem If we get here, one of the commands above failed -:error -echo. -echo ****************************** -echo Unity: Failed to build CoreCLR -echo ****************************** -exit /b %errorlevel% diff --git a/.yamato/scripts/build_yamato.cmd b/.yamato/scripts/build_yamato.cmd new file mode 100644 index 00000000000000..3633c100d57651 --- /dev/null +++ b/.yamato/scripts/build_yamato.cmd @@ -0,0 +1,3 @@ +@echo off + +%~dp0../../dotnet.cmd run --project %~dp0../../unity/CITools/BuildDriver/BuildDriver.csproj -- %* \ No newline at end of file diff --git a/.yamato/scripts/build_yamato.sh b/.yamato/scripts/build_yamato.sh new file mode 100755 index 00000000000000..d9bd2f11f98648 --- /dev/null +++ b/.yamato/scripts/build_yamato.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +BASEDIR=$(dirname $0) +$BASEDIR/../../dotnet.sh run --project $BASEDIR/../../unity/CITools/BuildDriver/BuildDriver.csproj -- "$@" \ No newline at end of file diff --git a/.yamato/scripts/test_linux.sh b/.yamato/scripts/test_linux.sh deleted file mode 100755 index 510d4ee614801d..00000000000000 --- a/.yamato/scripts/test_linux.sh +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/sh -set -e - -# Usage: test_linux.cmd -# -# Configuration is one of Debug or Release - Release is the default is not specified - -if [ "$1" = "" ]; then - configuration=Release -else - configuration=$1 -fi - -echo "*****************************" -echo "Unity: Starting CoreCLR tests" -echo " Platform: Linux" -echo " Architecture: x64" -echo " Configuration: $configuration" -echo "*****************************" - -echo -echo "******************************" -echo "Unity: Building embedding host" -echo "******************************" -echo -./dotnet.sh build unity/managed.sln -c $configuration - -echo -echo "***********************************" -echo "Unity: Running embedding API tests" -echo "***********************************" -echo -cd unity/embed_api_tests -cmake -DCMAKE_BUILD_TYPE=$configuration . -cmake --build . -./mono_test_app -cd ../../ - -echo -echo "**********************************" -echo "Unity: Running class library tests" -echo "**********************************" -echo -./build.sh -subset libs.tests -test /p:RunSmokeTestsOnly=true -a x64 -c $configuration -ci -ninja - -echo -echo "****************************" -echo "Unity: Running runtime tests" -echo "****************************" -echo -./src/tests/build.sh x64 $configuration /p:LibrariesConfiguration=$configuration ci -tree:baseservices -tree:interop -tree:reflection -./src/tests/run.sh x64 $configuration - -echo -echo "************************" -echo "Unity: Running PAL tests" -echo "************************" -echo -./build.sh clr.paltests -./artifacts/bin/coreclr/$(uname).x64.Debug/paltests/runpaltests.sh $(pwd)/artifacts/bin/coreclr/$(uname).x64.Debug/paltests - -echo -echo "**********************************" -echo "Unity: Tested CoreCLR successfully" -echo "**********************************" diff --git a/.yamato/scripts/test_osx.sh b/.yamato/scripts/test_osx.sh deleted file mode 100755 index 9a1623cd78d2cb..00000000000000 --- a/.yamato/scripts/test_osx.sh +++ /dev/null @@ -1,71 +0,0 @@ -#!/bin/sh -set -e - -# Usage: test_osx.cmd -# -# Architecture is one of arm64 or x64 - x64 is the default if not specified -# Configuration is one of Debug or Release - Release is the default is not specified -# -# To specify Configuration, Architecture must be specified as well. - -if [ "$1" = "" ]; then - architecture=x64 -else - architecture=$1 -fi - -if [ "$2" = "" ]; then - configuration=Release -else - configuration=$2 -fi - -echo "*****************************" -echo "Unity: Starting CoreCLR tests" -echo "*****************************" - -echo -echo "******************************" -echo "Unity: Building embedding host" -echo "******************************" -echo -./dotnet.sh build unity/managed.sln -c $configuration - -echo -echo "**********************************" -echo "Unity: Running embedding API tests" -echo "**********************************" -echo -cd unity/embed_api_tests -cmake -DCMAKE_BUILD_TYPE=$configuration . -cmake --build . -./mono_test_app -cd ../../ - -echo -echo "**********************************" -echo "Unity: Running class library tests" -echo "**********************************" -echo -LD_LIBRARY_PATH=/usr/local/opt/openssl/lib ./build.sh -subset libs.tests -test /p:RunSmokeTestsOnly=true -a $architecture -c $configuration -ci -ninja - -echo -echo "****************************" -echo "Unity: Running runtime tests" -echo "****************************" -echo -./src/tests/build.sh $architecture $configuration ci /p:LibrariesConfiguration=$configuration -tree:baseservices -tree:interop -tree:reflection -./src/tests/run.sh $architecture $configuration - -echo -echo "************************" -echo "Unity: Running PAL tests" -echo "************************" -echo -./build.sh clr.paltests -./artifacts/bin/coreclr/OSX.$architecture.Debug/paltests/runpaltests.sh $(pwd)/artifacts/bin/coreclr/OSX.$architecture.Debug/paltests - -echo -echo "**********************************" -echo "Unity: Tested CoreCLR successfully" -echo "**********************************" diff --git a/.yamato/scripts/test_windows.cmd b/.yamato/scripts/test_windows.cmd deleted file mode 100644 index 25d3d946469e79..00000000000000 --- a/.yamato/scripts/test_windows.cmd +++ /dev/null @@ -1,96 +0,0 @@ -@echo off - -rem Usage: test_windows.cmd -rem -rem Architecture is one of x86 or x64 - x64 is the default if not specified -rem Configuration is one of Debug or Release - Release is the default is not specified -rem -rem To specify Configuration, Architecture must be specified as well. - -if "%~1"=="" goto :default_architecture -set architecture=%1 -goto :set_configuration -:default_architecture -set architecture=x64 - -:set_configuration -if "%~2"=="" goto :default_configuration -set configuration=%2 -goto :run_test -:default_configuration -set configuration=Release - -:run_test - -echo ***************************** -echo Unity: Starting CoreCLR tests -echo Platform: Windows -echo Architecture: %architecture% -echo Configuration: %configuration% -echo ***************************** - -echo. -echo ****************************** -echo Unity: Building embedding host -echo ****************************** -echo. -call dotnet build unity\managed.sln -c %configuration% || goto :error - -echo. -echo ***************************************************** -echo Unity: Running managed embedding API tests -echo ***************************************************** -echo. -call dotnet test unity/managed.sln -c %configuration% || goto :error - -if "%architecture%"=="x86" goto :skip_embedding_tests_x86 -echo. -echo ***************************************************** -echo Unity: Running embedding API tests -echo ***************************************************** -echo. -if "%architecture%"=="x86" (set cmake_architecture=Win32) else (set cmake_architecture=x64) -cd unity\embed_api_tests || goto :error -cmake . -A %cmake_architecture% || goto :error -cmake --build . --config %configuration% || goto :error -%configuration%\mono_test_app.exe || goto :error -cd ../../ || goto :error -goto :run_class_library_tests - -:skip_embedding_tests_x86 -echo. -echo ***************************************************** -echo Unity: Skipping embedding API tests on x86 -echo ***************************************************** -echo. - -:run_class_library_tests -echo. -echo ********************************** -echo Unity: Running class library tests -echo ********************************** -echo. -call build.cmd libs.tests -test /p:RunSmokeTestsOnly=true -a %architecture% -c %configuration% -ci || goto :error - -echo. -echo **************************** -echo Unity: Running runtime tests -echo **************************** -echo. -call src\tests\build.cmd %architecture% %configuration% ci tree baseservices tree interop tree reflection -- /p:LibrariesConfiguration=%configuration% || goto :error -call src\tests\run.cmd %architecture% %configuration% || goto :error - -rem Every thing succeeded - jump to the end of the file and return a 0 exit code -echo. -echo ********************************** -echo Unity: Tested CoreCLR successfully -echo ********************************** -goto :EOF - -rem If we get here, one of the commands above failed -:error -echo. -echo *************************** -echo Unity: CoreCLR tests failed -echo *************************** -exit /b %errorlevel% diff --git a/.yamato/test_linux_x64_debug.yml b/.yamato/test_linux_x64_debug.yml index 6a3f0f9a0acd02..f5319a1974a24d 100644 --- a/.yamato/test_linux_x64_debug.yml +++ b/.yamato/test_linux_x64_debug.yml @@ -11,5 +11,5 @@ dependencies: - path: .yamato/build_linux_x64_debug.yml commands: - - ./.yamato/scripts/test_linux.sh Debug + - ./.yamato/scripts/build_yamato.sh --config=Debug --test diff --git a/.yamato/test_linux_x64_release.yml b/.yamato/test_linux_x64_release.yml index baae7c88ed0def..133ca3a9fb60d7 100644 --- a/.yamato/test_linux_x64_release.yml +++ b/.yamato/test_linux_x64_release.yml @@ -11,5 +11,5 @@ dependencies: - path: .yamato/build_linux_x64_release.yml commands: - - ./.yamato/scripts/test_linux.sh Release + - ./.yamato/scripts/build_yamato.sh --config=Release --test diff --git a/.yamato/test_osx_arm64_debug.yml b/.yamato/test_osx_arm64_debug.yml index fd40fa1b7c7d7d..0447b5ebbbdbcd 100644 --- a/.yamato/test_osx_arm64_debug.yml +++ b/.yamato/test_osx_arm64_debug.yml @@ -12,4 +12,4 @@ dependencies: commands: # build/run tests - - ./.yamato/scripts/test_osx.sh arm64 Debug + - ./.yamato/scripts/build_yamato.sh --arch=arm64 --config=Debug --test diff --git a/.yamato/test_osx_arm64_release.yml b/.yamato/test_osx_arm64_release.yml index 334cc0fa0b4bb7..db97afd461993f 100644 --- a/.yamato/test_osx_arm64_release.yml +++ b/.yamato/test_osx_arm64_release.yml @@ -12,4 +12,4 @@ dependencies: commands: # build/run tests - - ./.yamato/scripts/test_osx.sh arm64 Release + - ./.yamato/scripts/build_yamato.sh --arch=arm64 --config=Release --test diff --git a/.yamato/test_osx_x64_debug.yml b/.yamato/test_osx_x64_debug.yml index 22bdc3fe7cd197..21288c6b087f00 100644 --- a/.yamato/test_osx_x64_debug.yml +++ b/.yamato/test_osx_x64_debug.yml @@ -12,4 +12,4 @@ dependencies: commands: # build/run tests - - ./.yamato/scripts/test_osx.sh x64 Debug + - ./.yamato/scripts/build_yamato.sh --arch=x64 --config=Debug --test diff --git a/.yamato/test_osx_x64_release.yml b/.yamato/test_osx_x64_release.yml index 59a9bbf8c1d56f..48e59cb6f3c888 100644 --- a/.yamato/test_osx_x64_release.yml +++ b/.yamato/test_osx_x64_release.yml @@ -12,4 +12,4 @@ dependencies: commands: # build/run tests - - ./.yamato/scripts/test_osx.sh x64 Release + - ./.yamato/scripts/build_yamato.sh --arch=x64 --config=Release --test diff --git a/.yamato/test_windows_x64_debug.yml b/.yamato/test_windows_x64_debug.yml index b3d23fd826566a..a6b235fef8570f 100644 --- a/.yamato/test_windows_x64_debug.yml +++ b/.yamato/test_windows_x64_debug.yml @@ -4,7 +4,7 @@ name: Test Windows x64 Debug agent: type: Unity::VM - image: burst/burst-base:1.0.8-1195360 + image: platform-foundation/coreclr-windows:v0.0.1-1276296 flavor: b1.xlarge dependencies: @@ -12,5 +12,5 @@ dependencies: commands: # build/run tests - - .yamato/scripts/test_windows.cmd x64 Debug + - .yamato/scripts/build_yamato.cmd --arch=x64 --config=Debug --test diff --git a/.yamato/test_windows_x64_release.yml b/.yamato/test_windows_x64_release.yml index 48568773d7d37c..de2da91295f77f 100644 --- a/.yamato/test_windows_x64_release.yml +++ b/.yamato/test_windows_x64_release.yml @@ -4,7 +4,7 @@ name: Test Windows x64 Release agent: type: Unity::VM - image: burst/burst-base:1.0.8-1195360 + image: platform-foundation/coreclr-windows:v0.0.1-1276296 flavor: b1.xlarge dependencies: @@ -12,5 +12,5 @@ dependencies: commands: # build/run tests - - .yamato/scripts/test_windows.cmd x64 Release + - .yamato/scripts/build_yamato.cmd --arch=x64 --config=Release --test diff --git a/.yamato/test_windows_x86_debug.yml b/.yamato/test_windows_x86_debug.yml index 028ef562282140..8fcf805796d808 100644 --- a/.yamato/test_windows_x86_debug.yml +++ b/.yamato/test_windows_x86_debug.yml @@ -4,11 +4,11 @@ name: Test Windows x86 Debug agent: type: Unity::VM - image: burst/burst-base:1.0.8-1195360 + image: platform-foundation/coreclr-windows:v0.0.1-1276296 flavor: b1.xlarge dependencies: - path: .yamato/build_windows_x86_debug.yml commands: - - .yamato/scripts/test_windows.cmd x86 Debug + - .yamato/scripts/build_yamato.cmd --arch=x86 --config=Debug --test diff --git a/.yamato/test_windows_x86_release.yml b/.yamato/test_windows_x86_release.yml index dff7c5f606407d..100f67d210cef2 100644 --- a/.yamato/test_windows_x86_release.yml +++ b/.yamato/test_windows_x86_release.yml @@ -4,11 +4,11 @@ name: Test Windows x86 Release agent: type: Unity::VM - image: burst/burst-base:1.0.8-1195360 + image: platform-foundation/coreclr-windows:v0.0.1-1276296 flavor: b1.xlarge dependencies: - path: .yamato/build_windows_x86_release.yml commands: - - .yamato/scripts/test_windows.cmd x86 Release + - .yamato/scripts/build_yamato.cmd --arch=x86 --config=Release --test diff --git a/unity/CITools/BuildDriver/BuildDriver.csproj b/unity/CITools/BuildDriver/BuildDriver.csproj new file mode 100644 index 00000000000000..21e8152652dfa7 --- /dev/null +++ b/unity/CITools/BuildDriver/BuildDriver.csproj @@ -0,0 +1,11 @@ + + + + Exe + net7.0 + enable + enable + preview + + + diff --git a/unity/CITools/BuildDriver/CoreCLR.cs b/unity/CITools/BuildDriver/CoreCLR.cs new file mode 100644 index 00000000000000..fd36078a61eafe --- /dev/null +++ b/unity/CITools/BuildDriver/CoreCLR.cs @@ -0,0 +1,82 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Diagnostics; +using System.Runtime.InteropServices; +using NiceIO; + +namespace BuildDriver; +public class CoreCLR +{ + private static NPath BuildScript => Paths.RepoRoot.Combine(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "build.cmd" : "build.sh"); + + public static void Build(GlobalConfig gConfig) + { + Console.WriteLine("******************************"); + Console.WriteLine("Unity: Building CoreCLR runtime"); + Console.WriteLine("******************************"); + + string crossbuild = string.Empty; + if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) && gConfig.Architecture.Equals("arm64") && + RuntimeInformation.OSArchitecture != Architecture.Arm64) + crossbuild = " /p:CrossBuild=true"; + + ProcessStartInfo sInfo = new() + { + FileName = BuildScript, + Arguments = $"-subset clr+libs -a {gConfig.Architecture} -c {gConfig.Configuration} -ci -ninja{crossbuild}", + WorkingDirectory = Paths.RepoRoot + }; + + Utils.RunProcess(sInfo, gConfig); + } + + public static void Test(GlobalConfig gConfig) + { + Console.WriteLine("******************************"); + Console.WriteLine("Unity: Running class library tests"); + Console.WriteLine("******************************"); + + ProcessStartInfo psi = new(); + psi.FileName = BuildScript; + psi.Arguments = $"-subset libs.tests -test /p:RunSmokeTestsOnly=true -a {gConfig.Architecture} -c {gConfig.Configuration} -ci -ninja"; + psi.WorkingDirectory = Paths.RepoRoot; + if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + psi.Environment.Add("LD_LIBRARY_PATH", "/usr/local/opt/openssl/lib"); + Utils.RunProcess(psi, gConfig); + + Console.WriteLine("******************************"); + Console.WriteLine("Unity: Running runtime tests"); + Console.WriteLine("******************************"); + psi.FileName = Paths.RepoRoot.Combine("src", "tests", BuildScript.FileName); + psi.Arguments = $"{gConfig.Architecture} {gConfig.Configuration} ci"; + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + psi.Arguments = + $"{psi.Arguments} tree baseservices tree interop tree reflection -- /p:LibrariesConfiguration={gConfig.Configuration}"; + else + psi.Arguments = + $"{psi.Arguments} /p:LibrariesConfiguration={gConfig.Configuration} -tree:baseservices -tree:interop -tree:reflection"; + psi.Environment.Remove("LD_LIBRARY_PATH"); // just in case + Utils.RunProcess(psi, gConfig); + + psi.FileName = Paths.RepoRoot.Combine("src", "tests", "run").ChangeExtension(BuildScript.ExtensionWithDot); + psi.Arguments = $"{gConfig.Architecture} {gConfig.Configuration}"; + Utils.RunProcess(psi, gConfig); + + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + return; + + Console.WriteLine("******************************"); + Console.WriteLine("Unity: Running PAL tests"); + Console.WriteLine("******************************"); + psi.FileName = BuildScript; + psi.Arguments = "clr.paltests"; + Utils.RunProcess(psi, gConfig); + + string osString = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "OSX" : "Linux"; + NPath paltests = Paths.Artifacts.Combine("bin", "coreclr", $"{osString}.{gConfig.Architecture}.Debug", "paltests"); + psi.FileName = paltests.Combine("runpaltests.sh"); + psi.Arguments = paltests; + Utils.RunProcess(psi, gConfig); + } +} diff --git a/unity/CITools/BuildDriver/EmbeddingHost.cs b/unity/CITools/BuildDriver/EmbeddingHost.cs new file mode 100644 index 00000000000000..3b5feca548091c --- /dev/null +++ b/unity/CITools/BuildDriver/EmbeddingHost.cs @@ -0,0 +1,69 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Diagnostics; +using System.Runtime.InteropServices; + +namespace BuildDriver; + +public class EmbeddingHost +{ + private static string DotNet => + RuntimeInformation.IsOSPlatform(OSPlatform.OSX) || RuntimeInformation.IsOSPlatform(OSPlatform.Linux) + ? "dotnet.sh" + : "dotnet.cmd"; + + public static void Build(GlobalConfig gConfig, bool test = false) + { + string type = test ? "test" : "build"; + Console.WriteLine("******************************"); + Console.WriteLine($"Unity: {type} embedding host"); + Console.WriteLine("******************************"); + + ProcessStartInfo psi = new(); + psi.FileName = Paths.RepoRoot.Combine(DotNet); + psi.Arguments = $"{type} unity/managed.sln -c {gConfig.Configuration}"; + psi.WorkingDirectory = Paths.RepoRoot; + + Utils.RunProcess(psi, gConfig); + } + + public static void Test(GlobalConfig gConfig) + { + // Run managed first + Build(gConfig, true); + + // Tests fail on x86 currently, most likely due to not using the real GC yet. + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && + gConfig.Architecture.Equals("x86")) + { + Console.WriteLine("******************************"); + Console.WriteLine($"Skipping native embedding API tests on x86"); + Console.WriteLine("******************************"); + return; + } + + // now native + string args = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) + ? $". -A {Utils.WinArchitecture(gConfig.Architecture)}" + : $"-DCMAKE_BUILD_TYPE={gConfig.Configuration}"; + ProcessStartInfo psi = new(); + psi.FileName = "cmake"; + psi.Arguments = args; + psi.WorkingDirectory = Paths.UnityEmbedApiTests; + + Utils.RunProcess(psi, gConfig); + + psi.Arguments = "--build ."; + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + psi.Arguments = $"--build . --config {gConfig.Configuration}"; + Utils.RunProcess(psi, gConfig); + + + psi.FileName = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) + ? Paths.UnityEmbedApiTests.Combine(gConfig.Configuration, "mono_test_app.exe") + : Paths.UnityEmbedApiTests.Combine("mono_test_app"); + psi.Arguments = string.Empty; + Utils.RunProcess(psi, gConfig); + } +} diff --git a/unity/CITools/BuildDriver/GlobalConfig.cs b/unity/CITools/BuildDriver/GlobalConfig.cs new file mode 100644 index 00000000000000..190d0f6a1d8d66 --- /dev/null +++ b/unity/CITools/BuildDriver/GlobalConfig.cs @@ -0,0 +1,11 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace BuildDriver; + +public class GlobalConfig +{ + public required string Architecture; + public required string Configuration; + public required bool Silent; +} diff --git a/unity/CITools/BuildDriver/NiceIO.cs b/unity/CITools/BuildDriver/NiceIO.cs new file mode 100644 index 00000000000000..e84aadb23a297f --- /dev/null +++ b/unity/CITools/BuildDriver/NiceIO.cs @@ -0,0 +1,922 @@ +// The MIT License(MIT) +// ===================== +// +// Copyright © `2015-2017` `Lucas Meijer` +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; + +namespace NiceIO +{ + public class NPath : IEquatable, IComparable + { + private static readonly StringComparison PathStringComparison = IsLinux() ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase; + + private readonly string[] _elements; + private readonly bool _isRelative; + private readonly string _driveLetter; + + #region construction + + public NPath(string path) + { + if (path == null) + throw new ArgumentNullException(); + + path = ParseDriveLetter(path, out _driveLetter); + + if (path == "/") + { + _isRelative = false; + _elements = new string[] {}; + } + else + { + var split = path.Split('/', '\\'); + + _isRelative = _driveLetter == null && IsRelativeFromSplitString(split); + + _elements = ParseSplitStringIntoElements(split.Where(s => s.Length > 0).ToArray()); + } + } + + private NPath(string[] elements, bool isRelative, string driveLetter) + { + _elements = elements; + _isRelative = isRelative; + _driveLetter = driveLetter; + } + + private string[] ParseSplitStringIntoElements(IEnumerable inputs) + { + var stack = new List(); + + foreach (var input in inputs.Where(input => input.Length != 0)) + { + if (input == ".") + { + if ((stack.Count > 0) && (stack.Last() != ".")) + continue; + } + else if (input == "..") + { + if (HasNonDotDotLastElement(stack)) + { + stack.RemoveAt(stack.Count - 1); + continue; + } + if (!_isRelative) + throw new ArgumentException("You cannot create a path that tries to .. past the root"); + } + stack.Add(input); + } + return stack.ToArray(); + } + + private static bool HasNonDotDotLastElement(List stack) + { + return stack.Count > 0 && stack[stack.Count - 1] != ".."; + } + + private string ParseDriveLetter(string path, out string driveLetter) + { + if (path.Length >= 2 && path[1] == ':') + { + driveLetter = path[0].ToString(); + return path.Substring(2); + } + + driveLetter = null; + return path; + } + + private static bool IsRelativeFromSplitString(string[] split) + { + if (split.Length < 2) + return true; + + return split[0].Length != 0 || !split.Any(s => s.Length > 0); + } + + public NPath Combine(params string[] append) + { + return Combine(append.Select(a => new NPath(a)).ToArray()); + } + + public NPath Combine(params NPath[] append) + { + if (!append.All(p => p.IsRelative)) + throw new ArgumentException("You cannot .Combine a non-relative path"); + + return new NPath(ParseSplitStringIntoElements(_elements.Concat(append.SelectMany(p => p._elements))), _isRelative, _driveLetter); + } + + public NPath Parent + { + get + { + if (_elements.Length == 0) + throw new InvalidOperationException ("Parent is called on an empty path"); + + var newElements = _elements.Take (_elements.Length - 1).ToArray (); + + return new NPath (newElements, _isRelative, _driveLetter); + } + } + + public NPath RelativeTo(NPath path) + { + if (!IsChildOf(path)) + { + if (!IsRelative && !path.IsRelative && _driveLetter != path._driveLetter) + throw new ArgumentException("Path.RelativeTo() was invoked with two paths that are on different volumes. invoked on: " + ToString() + " asked to be made relative to: " + path); + + NPath commonParent = null; + foreach (var parent in RecursiveParents) + { + commonParent = path.RecursiveParents.FirstOrDefault(otherParent => otherParent == parent); + + if (commonParent != null) + break; + } + + if (commonParent == null) + throw new ArgumentException("Path.RelativeTo() was unable to find a common parent between " + ToString() + " and " + path); + + if (IsRelative && path.IsRelative && commonParent.IsEmpty()) + throw new ArgumentException("Path.RelativeTo() was invoked with two relative paths that do not share a common parent. Invoked on: " + ToString() + " asked to be made relative to: " + path); + + var depthDiff = path.Depth - commonParent.Depth; + return new NPath(Enumerable.Repeat("..", depthDiff).Concat(_elements.Skip(commonParent.Depth)).ToArray(), true, null); + } + + return new NPath(_elements.Skip(path._elements.Length).ToArray(), true, null); + } + + public NPath ChangeExtension(string extension) + { + ThrowIfRoot(); + + var newElements = (string[])_elements.Clone(); + newElements[newElements.Length - 1] = Path.ChangeExtension(_elements[_elements.Length - 1], WithDot(extension)); + if (extension == string.Empty) + newElements[newElements.Length - 1] = newElements[newElements.Length - 1].TrimEnd('.'); + return new NPath(newElements, _isRelative, _driveLetter); + } + #endregion construction + + #region inspection + + public bool IsRelative + { + get { return _isRelative; } + } + + public string FileName + { + get + { + ThrowIfRoot(); + + return _elements.Last(); + } + } + + public string FileNameWithoutExtension + { + get { return Path.GetFileNameWithoutExtension (FileName); } + } + + public IEnumerable Elements + { + get { return _elements; } + } + + public int Depth + { + get { return _elements.Length; } + } + + public bool Exists(string append = "") + { + return Exists(new NPath(append)); + } + + public bool Exists(NPath append) + { + return FileExists(append) || DirectoryExists(append); + } + + public bool DirectoryExists(string append = "") + { + return DirectoryExists(new NPath(append)); + } + + public bool DirectoryExists(NPath append) + { + return Directory.Exists(Combine(append).ToString()); + } + + public bool FileExists(string append = "") + { + return FileExists(new NPath(append)); + } + + public bool FileExists(NPath append) + { + return File.Exists(Combine(append).ToString()); + } + + public string ExtensionWithDot + { + get + { + if (IsRoot) + throw new ArgumentException("A root directory does not have an extension"); + + var last = _elements.Last(); + var index = last.LastIndexOf("."); + if (index < 0) return String.Empty; + return last.Substring(index); + } + } + + public string InQuotes() + { + return "\"" + ToString() + "\""; + } + + public string InQuotes(SlashMode slashMode) + { + return "\"" + ToString(slashMode) + "\""; + } + + public override string ToString() + { + return ToString(SlashMode.Native); + } + + public string ToString(SlashMode slashMode) + { + // Check if it's linux root / + if (IsRoot && string.IsNullOrEmpty(_driveLetter)) + return Slash(slashMode).ToString(); + + if (_isRelative && _elements.Length == 0) + return "."; + + var sb = new StringBuilder(); + if (_driveLetter != null) + { + sb.Append(_driveLetter); + sb.Append(":"); + } + if (!_isRelative) + sb.Append(Slash(slashMode)); + var first = true; + foreach (var element in _elements) + { + if (!first) + sb.Append(Slash(slashMode)); + + sb.Append(element); + first = false; + } + return sb.ToString(); + } + + public static implicit operator string(NPath path) + { + return path.ToString(); + } + + static char Slash(SlashMode slashMode) + { + switch (slashMode) + { + case SlashMode.Backward: + return '\\'; + case SlashMode.Forward: + return '/'; + default: + return Path.DirectorySeparatorChar; + } + } + + public override bool Equals(Object obj) + { + if (obj == null) + return false; + + // If parameter cannot be cast to Point return false. + var p = obj as NPath; + if ((Object)p == null) + return false; + + return Equals(p); + } + + public bool Equals(NPath p) + { + if (p._isRelative != _isRelative) + return false; + + if (!string.Equals(p._driveLetter, _driveLetter, PathStringComparison)) + return false; + + if (p._elements.Length != _elements.Length) + return false; + + for (var i = 0; i != _elements.Length; i++) + if (!string.Equals(p._elements[i], _elements[i], PathStringComparison)) + return false; + + return true; + } + + public static bool operator ==(NPath a, NPath b) + { + // If both are null, or both are same instance, return true. + if (ReferenceEquals(a, b)) + return true; + + // If one is null, but not both, return false. + if (((object)a == null) || ((object)b == null)) + return false; + + // Return true if the fields match: + return a.Equals(b); + } + + public override int GetHashCode() + { + unchecked + { + int hash = 17; + // Suitable nullity checks etc, of course :) + hash = hash * 23 + _isRelative.GetHashCode(); + foreach (var element in _elements) + hash = hash * 23 + element.GetHashCode(); + if (_driveLetter != null) + hash = hash * 23 + _driveLetter.GetHashCode(); + return hash; + } + } + + public int CompareTo(object obj) + { + if (obj == null) + return -1; + + return this.ToString().CompareTo(((NPath)obj).ToString()); + } + + public static bool operator !=(NPath a, NPath b) + { + return !(a == b); + } + + public bool HasExtension(params string[] extensions) + { + var extensionWithDotLower = ExtensionWithDot.ToLower(); + return extensions.Any(e => WithDot(e).ToLower() == extensionWithDotLower); + } + + private static string WithDot(string extension) + { + return extension.StartsWith(".") ? extension : "." + extension; + } + + private bool IsEmpty() + { + return _elements.Length == 0; + } + + public bool IsRoot + { + get { return _elements.Length == 0 && !_isRelative; } + } + + #endregion inspection + + #region directory enumeration + + public IEnumerable Files(string filter, bool recurse = false) + { + return Directory.GetFiles(ToString(), filter, recurse ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly).Select(s => new NPath(s)); + } + + public IEnumerable Files(bool recurse = false) + { + return Files("*", recurse); + } + + public IEnumerable Contents(string filter, bool recurse = false) + { + return Files(filter, recurse).Concat(Directories(filter, recurse)); + } + + public IEnumerable Contents(bool recurse = false) + { + return Contents("*", recurse); + } + + public IEnumerable Directories(string filter, bool recurse = false) + { + return Directory.GetDirectories(ToString(), filter, recurse ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly).Select(s => new NPath(s)); + } + + public IEnumerable Directories(bool recurse = false) + { + return Directories("*", recurse); + } + + #endregion + + #region filesystem writing operations + public NPath CreateFile() + { + ThrowIfRelative(); + ThrowIfRoot(); + EnsureParentDirectoryExists(); + File.WriteAllBytes(ToString(), new byte[0]); + return this; + } + + public NPath CreateFile(string file) + { + return CreateFile(new NPath(file)); + } + + public NPath CreateFile(NPath file) + { + if (!file.IsRelative) + throw new ArgumentException("You cannot call CreateFile() on an existing path with a non relative argument"); + return Combine(file).CreateFile(); + } + + public NPath CreateDirectory() + { + ThrowIfRelative(); + + if (IsRoot) + throw new NotSupportedException("CreateDirectory is not supported on a root level directory because it would be dangerous:" + ToString()); + + Directory.CreateDirectory(ToString()); + return this; + } + + public NPath CreateDirectory(string directory) + { + return CreateDirectory(new NPath(directory)); + } + + public NPath CreateDirectory(NPath directory) + { + if (!directory.IsRelative) + throw new ArgumentException("Cannot call CreateDirectory with an absolute argument"); + + return Combine(directory).CreateDirectory(); + } + + public NPath Copy(string dest) + { + return Copy(new NPath(dest)); + } + + public NPath Copy(string dest, Func fileFilter) + { + return Copy(new NPath(dest), fileFilter); + } + + public NPath Copy(NPath dest) + { + return Copy(dest, p => true); + } + + public NPath Copy(NPath dest, Func fileFilter) + { + ThrowIfRelative(); + if (dest.IsRelative) + dest = Parent.Combine(dest); + + if (dest.DirectoryExists()) + return CopyWithDeterminedDestination(dest.Combine(FileName), fileFilter); + + return CopyWithDeterminedDestination (dest, fileFilter); + } + + public NPath MakeAbsolute() + { + if (!IsRelative) + return this; + + return NPath.CurrentDirectory.Combine (this); + } + + NPath CopyWithDeterminedDestination(NPath absoluteDestination, Func fileFilter) + { + if (absoluteDestination.IsRelative) + throw new ArgumentException ("absoluteDestination must be absolute"); + + if (FileExists()) + { + if (!fileFilter(absoluteDestination)) + return null; + + absoluteDestination.EnsureParentDirectoryExists(); + + File.Copy(ToString(), absoluteDestination.ToString(), true); + return absoluteDestination; + } + + if (DirectoryExists()) + { + absoluteDestination.EnsureDirectoryExists(); + foreach (var thing in Contents()) + thing.CopyWithDeterminedDestination(absoluteDestination.Combine(thing.RelativeTo(this)), fileFilter); + return absoluteDestination; + } + + throw new ArgumentException("Copy() called on path that doesnt exist: " + ToString()); + } + + public void Delete(DeleteMode deleteMode = DeleteMode.Normal) + { + ThrowIfRelative(); + + if (IsRoot) + throw new NotSupportedException("Delete is not supported on a root level directory because it would be dangerous:" + ToString()); + + if (FileExists()) + File.Delete(ToString()); + else if (DirectoryExists()) + try + { + Directory.Delete(ToString(), true); + } + catch (IOException) + { + if (deleteMode == DeleteMode.Normal) + throw; + } + else + throw new InvalidOperationException("Trying to delete a path that does not exist: " + ToString()); + } + + public void DeleteIfExists(DeleteMode deleteMode = DeleteMode.Normal) + { + ThrowIfRelative(); + + if (FileExists() || DirectoryExists()) + Delete(deleteMode); + } + + public NPath DeleteContents() + { + ThrowIfRelative(); + + if (IsRoot) + throw new NotSupportedException("DeleteContents is not supported on a root level directory because it would be dangerous:" + ToString()); + + if (FileExists()) + throw new InvalidOperationException("It is not valid to perform this operation on a file"); + + if (DirectoryExists()) + { + try + { + Files().Delete(); + Directories().Delete(); + } + catch (IOException) + { + if (Files(true).Any()) + throw; + } + + return this; + } + + return EnsureDirectoryExists(); + } + + public static NPath CreateTempDirectory(string myprefix) + { + var random = new Random(); + while (true) + { + var candidate = new NPath(Path.GetTempPath() + "/" + myprefix + "_" + random.Next()); + if (!candidate.Exists()) + return candidate.CreateDirectory(); + } + } + + public NPath Move(string dest) + { + return Move(new NPath(dest)); + } + + public NPath Move(NPath dest) + { + ThrowIfRelative(); + + if (IsRoot) + throw new NotSupportedException("Move is not supported on a root level directory because it would be dangerous:" + ToString()); + + if (dest.IsRelative) + return Move(Parent.Combine(dest)); + + if (dest.DirectoryExists()) + return Move(dest.Combine(FileName)); + + if (FileExists()) + { + dest.EnsureParentDirectoryExists(); + File.Move(ToString(), dest.ToString()); + return dest; + } + + if (DirectoryExists()) + { + Directory.Move(ToString(), dest.ToString()); + return dest; + } + + throw new ArgumentException("Move() called on a path that doesn't exist: " + ToString()); + } + + #endregion + + #region special paths + + public static NPath CurrentDirectory + { + get + { + return new NPath(Directory.GetCurrentDirectory()); + } + } + + public static NPath HomeDirectory + { + get + { + if (Path.DirectorySeparatorChar == '\\') + return new NPath(Environment.GetEnvironmentVariable("USERPROFILE")); + return new NPath(Environment.GetEnvironmentVariable("HOME")); + } + } + + public static NPath SystemTemp + { + get + { + return new NPath(Path.GetTempPath()); + } + } + + #endregion + + private void ThrowIfRelative() + { + if (_isRelative) + throw new ArgumentException("You are attempting an operation on a Path that requires an absolute path, but the path is relative"); + } + + private void ThrowIfRoot() + { + if (IsRoot) + throw new ArgumentException("You are attempting an operation that is not valid on a root level directory"); + } + + public NPath EnsureDirectoryExists(string append = "") + { + return EnsureDirectoryExists(new NPath(append)); + } + + public NPath EnsureDirectoryExists(NPath append) + { + var combined = Combine(append); + if (combined.DirectoryExists()) + return combined; + combined.EnsureParentDirectoryExists(); + combined.CreateDirectory(); + return combined; + } + + public NPath EnsureParentDirectoryExists() + { + var parent = Parent; + parent.EnsureDirectoryExists(); + return parent; + } + + public NPath FileMustExist() + { + if (!FileExists()) + throw new FileNotFoundException("File was expected to exist : " + ToString()); + + return this; + } + + public NPath DirectoryMustExist() + { + if (!DirectoryExists()) + throw new DirectoryNotFoundException("Expected directory to exist : " + ToString()); + + return this; + } + + public bool IsChildOf(string potentialBasePath) + { + return IsChildOf(new NPath(potentialBasePath)); + } + + public bool IsChildOf(NPath potentialBasePath) + { + if ((IsRelative && !potentialBasePath.IsRelative) || !IsRelative && potentialBasePath.IsRelative) + throw new ArgumentException("You can only call IsChildOf with two relative paths, or with two absolute paths"); + + // If the other path is the root directory, then anything is a child of it as long as it's not a Windows path + if (potentialBasePath.IsRoot) + { + if (_driveLetter != potentialBasePath._driveLetter) + return false; + return true; + } + + if (IsEmpty()) + return false; + + if (Equals(potentialBasePath)) + return true; + + return Parent.IsChildOf(potentialBasePath); + } + + public IEnumerable RecursiveParents + { + get + { + var candidate = this; + while (true) + { + if(candidate.IsEmpty()) + yield break; + + candidate = candidate.Parent; + yield return candidate; + } + } + } + + public NPath ParentContaining(string needle) + { + return ParentContaining(new NPath(needle)); + } + + public NPath ParentContaining(NPath needle) + { + ThrowIfRelative(); + + return RecursiveParents.FirstOrDefault(p => p.Exists(needle)); + } + + public NPath WriteAllText(string contents) + { + ThrowIfRelative(); + EnsureParentDirectoryExists(); + File.WriteAllText(ToString(), contents); + return this; + } + + public string ReadAllText() + { + ThrowIfRelative(); + return File.ReadAllText(ToString()); + } + + public NPath WriteAllLines(string[] contents) + { + ThrowIfRelative(); + EnsureParentDirectoryExists(); + File.WriteAllLines(ToString(), contents); + return this; + } + + public string[] ReadAllLines() + { + ThrowIfRelative(); + return File.ReadAllLines(ToString()); + } + + public IEnumerable CopyFiles(NPath destination, bool recurse, Func fileFilter = null) + { + destination.EnsureDirectoryExists(); + return Files(recurse).Where(fileFilter ?? AlwaysTrue).Select(file => file.Copy(destination.Combine(file.RelativeTo(this)))).ToArray(); + } + + public IEnumerable MoveFiles(NPath destination, bool recurse, Func fileFilter = null) + { + if (IsRoot) + throw new NotSupportedException("MoveFiles is not supported on this directory because it would be dangerous:" + ToString()); + + destination.EnsureDirectoryExists(); + return Files(recurse).Where(fileFilter ?? AlwaysTrue).Select(file => file.Move(destination.Combine(file.RelativeTo(this)))).ToArray(); + } + + static bool AlwaysTrue(NPath p) + { + return true; + } + + private static bool IsLinux() + { + return Directory.Exists("/proc"); + } + } + + public static class Extensions + { + public static IEnumerable Copy(this IEnumerable self, string dest) + { + return Copy(self, new NPath(dest)); + } + + public static IEnumerable Copy(this IEnumerable self, NPath dest) + { + if (dest.IsRelative) + throw new ArgumentException("When copying multiple files, the destination cannot be a relative path"); + dest.EnsureDirectoryExists(); + return self.Select(p => p.Copy(dest.Combine(p.FileName))).ToArray(); + } + + public static IEnumerable Move(this IEnumerable self, string dest) + { + return Move(self, new NPath(dest)); + } + + public static IEnumerable Move(this IEnumerable self, NPath dest) + { + if (dest.IsRelative) + throw new ArgumentException("When moving multiple files, the destination cannot be a relative path"); + dest.EnsureDirectoryExists(); + return self.Select(p => p.Move(dest.Combine(p.FileName))).ToArray(); + } + + public static IEnumerable Delete(this IEnumerable self) + { + foreach (var p in self) + p.Delete(); + return self; + } + + public static IEnumerable InQuotes(this IEnumerable self, SlashMode forward = SlashMode.Native) + { + return self.Select(p => p.InQuotes(forward)); + } + + public static NPath ToNPath(this string path) + { + return new NPath(path); + } + } + + public enum SlashMode + { + Native, + Forward, + Backward + } + + public enum DeleteMode + { + Normal, + Soft + } +} diff --git a/unity/CITools/BuildDriver/NullGC.cs b/unity/CITools/BuildDriver/NullGC.cs new file mode 100644 index 00000000000000..34983fcac624e1 --- /dev/null +++ b/unity/CITools/BuildDriver/NullGC.cs @@ -0,0 +1,44 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Diagnostics; +using System.Runtime.InteropServices; +using NiceIO; + +namespace BuildDriver; + +public class NullGC +{ + + + public static void Build(GlobalConfig gConfig) + { + Console.WriteLine("***********************"); + Console.WriteLine("Unity: Building Null GC"); + Console.WriteLine("***********************"); + + NPath workingDir = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? + Paths.UnityGC : Paths.UnityGC.CreateDirectory(gConfig.Configuration); + + string extraArchDefine = string.Empty; + if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) && gConfig.Architecture.Equals("arm64")) + extraArchDefine = "-DCMAKE_OSX_ARCHITECTURES=arm64 "; + else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + extraArchDefine = Utils.WinArchitecture(gConfig.Architecture); + + ProcessStartInfo sInfo = new(); + sInfo.FileName = "cmake"; + sInfo.WorkingDirectory = workingDir; + sInfo.Arguments = $". -A {extraArchDefine}"; + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + sInfo.Arguments = $"{extraArchDefine}-DCMAKE_BUILD_TYPE={gConfig.Configuration} .."; + + Utils.RunProcess(sInfo, gConfig); + + sInfo.Arguments = "--build ."; + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + sInfo.Arguments = $"--build . --config {gConfig.Configuration}"; + + Utils.RunProcess(sInfo, gConfig); + } +} diff --git a/unity/CITools/BuildDriver/Paths.cs b/unity/CITools/BuildDriver/Paths.cs new file mode 100644 index 00000000000000..3b3f8c7669c960 --- /dev/null +++ b/unity/CITools/BuildDriver/Paths.cs @@ -0,0 +1,21 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using NiceIO; + +namespace BuildDriver; + +public class Paths +{ + public static NPath RepoRoot => typeof(Paths).Assembly.Location.ToNPath().RecursiveParents + .First(dir => dir.Combine(".yamato").DirectoryExists()); + + public static NPath UnityRoot => RepoRoot.Combine("unity"); + public static NPath UnityGC => UnityRoot.Combine("unitygc"); + + public static NPath UnityEmbedApiTests => UnityRoot.Combine("embed_api_tests"); + + public static NPath UnityEmbedHost => UnityRoot.Combine("unity-embed-host"); + + public static NPath Artifacts => RepoRoot.Combine("artifacts"); +} diff --git a/unity/CITools/BuildDriver/Program.cs b/unity/CITools/BuildDriver/Program.cs new file mode 100644 index 00000000000000..9897b50a50b599 --- /dev/null +++ b/unity/CITools/BuildDriver/Program.cs @@ -0,0 +1,159 @@ +using System.Runtime.InteropServices; +using NiceIO; + +namespace BuildDriver; + +public class Program +{ + public static bool RunningOnYamato() => Environment.GetEnvironmentVariable("YAMATO_PROJECT_ID") != null; + public static async Task Main(string[] args) + { + string architecture = GetArchitectures()[0]; // Get default arch for current system + string configuration = "Release"; + bool silent = false; + bool skipBuild = false; + bool test = false; + bool zip = RunningOnYamato(); + Task? zipTask = null; + foreach (string arg in args) + { + if ((arg.StartsWith("--arch") || arg.StartsWith("--architecture=")) + && !TryParseArgument(GetArchitectures(true), arg, out architecture)) + return 1; + else if ((arg.StartsWith("--config=") || arg.StartsWith("--configuration=")) + && !TryParseArgument(new[] {"Release", "Debug"}, arg, out configuration)) + return 1; + else if (arg.Equals("--silent") || arg.Equals("--s")) + silent = true; + else if (arg.Equals("--zip") || arg.Equals("--z")) + zip = true; + else if (arg.Equals("--skip-build")) + skipBuild = true; + else if (arg.Equals("--test")) + { + skipBuild = true; // Assume we've already built + test = true; + } + } + + if (RunningOnYamato()) + { + zipTask = SevenZip.DownloadAndUnzip7Zip(); + } + + Console.WriteLine("*****************************"); + Console.WriteLine("Unity: Starting CoreCLR build"); + Console.WriteLine($"\tPlatform:\t\t{RuntimeInformation.OSDescription}"); + Console.WriteLine($"\tArchitecture:\t\t{architecture}"); + Console.WriteLine($"\tConfiguration:\t\t{configuration}"); + Console.WriteLine("*****************************"); + + GlobalConfig gConfig = new (){ Architecture = architecture, Configuration = configuration, Silent = silent}; + EmbeddingHost.Build(gConfig); + if (!skipBuild) + { + NullGC.Build(gConfig); + CoreCLR.Build(gConfig); + + // TODO: Switch to using Embedding Host build to perform the copy instead of this once that lands. + NPath artifacts = ConsolidateArtifacts(gConfig); + + NPath zipExe = new("7z"); + if (zipTask != null) + { + zipExe = await zipTask; + if (zipTask.Exception != null) + throw zipTask.Exception; + } + + if (zip) + SevenZip.Zip(zipExe, artifacts, gConfig); + } + + if (test) + { + EmbeddingHost.Test(gConfig); + CoreCLR.Test(gConfig); + Console.WriteLine("******************************"); + Console.WriteLine("Unity: Tested CoreCLR successfully"); + Console.WriteLine("******************************"); + } + + return 0; + } + + static NPath ConsolidateArtifacts(GlobalConfig gConfig) + { + string osAbbrev = "win"; + string unityGCLib = "unitygc.dll"; + if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + osAbbrev = "osx"; + unityGCLib = "libunitygc.dylib"; + } + else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + { + osAbbrev = "linux"; + unityGCLib = "libunitygc.so"; + } + + NPath destDir = Paths.RepoRoot.Combine("artifacts", "bin", + $"microsoft.netcore.app.runtime.{osAbbrev}-{gConfig.Architecture}", gConfig.Configuration, "runtimes", + $"{osAbbrev}-{gConfig.Architecture}"); + + Paths.UnityGC.Combine(gConfig.Configuration, unityGCLib).Copy(destDir.Combine("native")); + + NPath tfmDir = Paths.UnityEmbedHost.Combine("bin", gConfig.Configuration).Directories().Single(); + tfmDir.Files("unity-embed-host.*").Copy(destDir.Combine("lib", tfmDir.FileName)); + Paths.RepoRoot.Combine("LICENSE.md").Copy(destDir); + + return destDir; + } + + static bool TryParseArgument(string[] validArgs, string arg, out string value) + { + string[] args = arg.Split('='); + if (string.IsNullOrEmpty(args[1]) || !validArgs.Contains(args[1])) + { + value = null; + Console.WriteLine($"Invalid option: {arg} Example : `--{args[0]}={validArgs[0]}`"); + return false; + } + + value = args[1]; + + return true; + } + + private static string[] GetArchitectures(bool allArchitectures = false) + { + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + if (allArchitectures) + { + return new[] { "x64", "x86", "arm64" }; + } + + if (RuntimeInformation.OSArchitecture == Architecture.X86) + return new[] { "x86" }; + if (RuntimeInformation.OSArchitecture == Architecture.Arm64) + return new[] { "arm64" }; + return new[] { "x64" }; + } + + if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + return new[] { "x64" }; + + if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + if (allArchitectures) + return new[] { "x64", "arm64" }; + + if (RuntimeInformation.OSArchitecture == Architecture.Arm64) + return new[] { "arm64" }; + return new[] { "x64" }; + } + + throw new ArgumentException($"Unsupported build platform {RuntimeInformation.OSDescription}"); + } +} diff --git a/unity/CITools/BuildDriver/SevenZip.cs b/unity/CITools/BuildDriver/SevenZip.cs new file mode 100644 index 00000000000000..203850d570e58b --- /dev/null +++ b/unity/CITools/BuildDriver/SevenZip.cs @@ -0,0 +1,78 @@ +using System.Diagnostics; +using System.IO.Compression; +using System.Net; +using System.Runtime.InteropServices; +using NiceIO; + +namespace BuildDriver; + +public class SevenZip +{ + public static NPath Create7z(NPath sevenZipPath, NPath directory, string outputFile, string additional7zArguments = "") + { + Console.WriteLine($"Creating .7z {outputFile}"); + var args = $"a {outputFile} *"; + if (!string.IsNullOrWhiteSpace(additional7zArguments)) + args = $"{additional7zArguments} {args}"; + + ProcessStartInfo psi = new() + { + FileName = sevenZipPath, + Arguments = args, + WorkingDirectory = directory + }; + + Utils.RunProcess(psi); + + return new NPath(outputFile); + } + + public static void Zip(NPath zipExe, NPath artifacts, GlobalConfig gConfig) + { + NPath zipArtifact = new (Environment.GetEnvironmentVariable("ARTIFACT_FILENAME") ?? + $"dotnet-unity-{gConfig.Architecture}.7z"); + SevenZip.Create7z(zipExe, artifacts, Paths.Artifacts.Combine(zipArtifact)); + } + + public static void Get7ZipUrl(out string url, out string filename) + { + string baseUrl = "https://public-stevedore.unity3d.com/r/public"; + if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + { + url = $"{baseUrl}/7za-linux-x64/e6c75fb7ffda_e6a295cdcae3f74d315361883cf53f75141be2e739c020035f414a449d4876af.zip"; + } + else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + url = RuntimeInformation.OSArchitecture == Architecture.Arm64 + ? $"{baseUrl}/7za-mac-arm64/e6c75fb7ffda_891473e6242d16ca181cee7c728b73f80c931f58de45ab79f376acd63d524151.zip" + : $"{baseUrl}/7za-mac-x64/e6c75fb7ffda_5bd76652986a0e3756d1cfd7e84ce056a9e1dbfc5f70f0514a001f724c0fbad2.zip"; + } + else + url = $"{baseUrl}/7za-win-x64/38c5b39be2e8_a333cfccb708c88459b3812eb2597ca486ec9b416172543ca3ef8e5cd5f80984.zip"; + + filename = $"{url.Split('/').Single(s => s.StartsWith("7za"))}.zip"; + } + + public static async Task DownloadAndUnzip7Zip() + { + WebClient wc = new(); + string url, filename; + Get7ZipUrl(out url, out filename); + NPath zipDest = Paths.Artifacts.Combine(filename); + zipDest.Parent.EnsureDirectoryExists(); + if (!zipDest.FileExists()) + { + Console.WriteLine($"Starting download of 7zip: {filename}"); + wc.DownloadFile(url, zipDest); + } + + NPath destDir = zipDest.Parent.Combine(zipDest.FileNameWithoutExtension); + if (!destDir.DirectoryExists()) + { + Console.WriteLine($"Extracting 7zip to: {destDir}"); + ZipFile.ExtractToDirectory(zipDest, destDir); + } + + return RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? destDir.Combine("7za.exe") : destDir.Combine("7za"); + } +} diff --git a/unity/CITools/BuildDriver/Utils.cs b/unity/CITools/BuildDriver/Utils.cs new file mode 100644 index 00000000000000..08fdfe9242bd91 --- /dev/null +++ b/unity/CITools/BuildDriver/Utils.cs @@ -0,0 +1,43 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Diagnostics; + +namespace BuildDriver; + +public class Utils +{ + public static string WinArchitecture(string arch) => arch.Equals("x86") ? "Win32" : "x64"; + public static void RunProcess(ProcessStartInfo psi) => RunProcess(psi, + new GlobalConfig() { Configuration = "Release", Architecture = "x64", Silent = false }); + public static void RunProcess(ProcessStartInfo psi, GlobalConfig gConfig) + { + if (!gConfig.Silent) + Console.WriteLine($"Running: {psi.FileName} {psi.Arguments}"); + using (Process proc = new()) + { + proc.StartInfo = psi; + proc.StartInfo.UseShellExecute = false; + if (gConfig.Silent) + { + proc.StartInfo.RedirectStandardOutput = true; + proc.StartInfo.RedirectStandardError = true; + } + + proc.Start(); + + proc.WaitForExit(); + if (proc.ExitCode != 0) + { + if (gConfig.Silent) + { + Console.WriteLine(proc.StandardOutput.ReadToEnd()); + Console.WriteLine(proc.StandardError.ReadToEnd()); + } + + throw new Exception($"Running {psi.FileName} {psi.Arguments} failed!"); + } + } + } + +} diff --git a/unity/CITools/CITools.sln b/unity/CITools/CITools.sln new file mode 100644 index 00000000000000..ea4af064e9a593 --- /dev/null +++ b/unity/CITools/CITools.sln @@ -0,0 +1,16 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BuildDriver", "BuildDriver\BuildDriver.csproj", "{403C25BB-EA37-416C-BCDC-93C70117C61B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {403C25BB-EA37-416C-BCDC-93C70117C61B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {403C25BB-EA37-416C-BCDC-93C70117C61B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {403C25BB-EA37-416C-BCDC-93C70117C61B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {403C25BB-EA37-416C-BCDC-93C70117C61B}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/unity/CITools/Directory.Build.props b/unity/CITools/Directory.Build.props new file mode 100644 index 00000000000000..b9b7c8ad883070 --- /dev/null +++ b/unity/CITools/Directory.Build.props @@ -0,0 +1,3 @@ + + + diff --git a/unity/CITools/Directory.Build.targets b/unity/CITools/Directory.Build.targets new file mode 100644 index 00000000000000..5ccfee6ce2fd62 --- /dev/null +++ b/unity/CITools/Directory.Build.targets @@ -0,0 +1,6 @@ + + + false + false + + diff --git a/unity/CITools/before.managed.sln.targets b/unity/CITools/before.managed.sln.targets new file mode 100644 index 00000000000000..5ccfee6ce2fd62 --- /dev/null +++ b/unity/CITools/before.managed.sln.targets @@ -0,0 +1,6 @@ + + + false + false + +