diff --git a/.appveyor.yml b/.appveyor.yml deleted file mode 100644 index 23e7349fb..000000000 --- a/.appveyor.yml +++ /dev/null @@ -1,32 +0,0 @@ -# Sharpmake AppVeyor CI configuration - -image: -- Visual Studio 2017 -- macOS -- Ubuntu - -skip_commits: - files: - - docs/* - -platform: -- Any CPU - -configuration: -- Debug -- Release - -before_build: -- cmd: bootstrap.bat -- sh: ./bootstrap.sh - -build_script: - - cmd: CompileSharpmake.bat Sharpmake.sln "%CONFIGURATION%" "%PLATFORM%" - - sh: ./CompileSharpmake.sh Sharpmake.sln "${CONFIGURATION}" "${PLATFORM}" - -test: - assemblies: - - 'Sharpmake.UnitTests\bin\*\Sharpmake.UnitTests.dll' - -after_test: -- cmd: python regression_test.py diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml new file mode 100644 index 000000000..161098c3a --- /dev/null +++ b/.github/workflows/actions.yml @@ -0,0 +1,54 @@ +# Sharpmake GitHub Actions CI configuration + +name: build +on: [push, pull_request] +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + configuration: [debug, release] + + env: + DOTNET_CLI_TELEMETRY_OPTOUT: 1 + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 + DOTNET_NOLOGO: true + + steps: + - name: Checkout the repo + uses: actions/checkout@v2 + + - name: Bootstrap.bat ${{ matrix.configuration }} + if: runner.os == 'Windows' + shell: cmd + run: bootstrap.bat Sharpmake.Main.sharpmake.cs ${{ matrix.configuration }} + + - name: Bootstrap.sh ${{ matrix.configuration }} + if: runner.os != 'Windows' + shell: bash + run: ./bootstrap.sh Sharpmake.Main.sharpmake.cs ${{ matrix.configuration }} + + - name: CompileSharpmake.bat ${{ matrix.configuration }} + if: runner.os == 'Windows' + shell: cmd + run: CompileSharpmake.bat Sharpmake.sln "${{ matrix.configuration }}" "Any CPU" + + - name: CompileSharpmake.sh ${{ matrix.configuration }} + if: runner.os != 'Windows' + shell: bash + run: ./CompileSharpmake.sh Sharpmake.sln "${{ matrix.configuration }}" + + - name: UnitTest + if: runner.os == 'Windows' + run: | + nuget install NUnit.ConsoleRunner -Version 3.12.0 -OutputDirectory tmp/pkg + tmp/pkg/NUnit.ConsoleRunner.3.12.0/tools/nunit3-console.exe tmp/unittests/${{ matrix.configuration }}/Sharpmake.UnitTests.dll + + - name: RegressionTest + if: runner.os == 'Windows' + run: python regression_test.py + + - name: FunctionalTest + if: runner.os == 'Windows' + run: python functional_test.py diff --git a/.gitignore b/.gitignore index 8a2f996cb..4c38c1754 100644 --- a/.gitignore +++ b/.gitignore @@ -61,7 +61,7 @@ _ReSharper*/ project.json project.lock.json Sharpmake.VC.db - +.vscode .idea # Desktop Services Store on MacOS diff --git a/CompileSharpmake.bat b/CompileSharpmake.bat index 0667a0293..23f416d13 100644 --- a/CompileSharpmake.bat +++ b/CompileSharpmake.bat @@ -6,6 +6,10 @@ :: if none are passed, defaults to building Sharpmake.sln in Debug|AnyCPU setlocal enabledelayedexpansion + +:: Clear previous run status +COLOR + : set batch file directory as current pushd "%~dp0" @@ -16,7 +20,7 @@ if not exist %VSWHERE% ( ) set VSMSBUILDCMD= -for /f "usebackq delims=" %%i in (`%VSWHERE% -latest -property installationPath`) do ( +for /f "usebackq delims=" %%i in (`%VSWHERE% -latest -products * -property installationPath`) do ( if exist "%%i\Common7\Tools\VsMSBuildCmd.bat" ( set VSMSBUILDCMD="%%i\Common7\Tools\VsMSBuildCmd.bat" ) @@ -26,31 +30,50 @@ if not defined VSMSBUILDCMD ( echo ERROR: Cannot determine the location of Common Tools folder. goto error ) + echo MSBuild batch path: !VSMSBUILDCMD! call !VSMSBUILDCMD! -if %errorlevel% NEQ 0 goto end +if %errorlevel% NEQ 0 goto error if "%~1" == "" ( call :BuildSharpmake "Sharpmake.sln" "Debug" "Any CPU" ) else ( call :BuildSharpmake %1 %2 %3 ) -goto end +if %errorlevel% NEQ 0 goto error + +goto success + +@REM ----------------------------------------------------------------------- :: Build Sharpmake using specified arguments :BuildSharpmake echo Compiling %~1 in "%~2|%~3"... -set MSBUILD_CMD=msbuild -t:build -restore "%~1" /nologo /verbosity:quiet /p:Configuration="%~2" /p:Platform="%~3" +set MSBUILD_CMD=msbuild -t:build -restore "%~1" /nologo /verbosity:m /p:Configuration="%~2" /p:Platform="%~3" echo %MSBUILD_CMD% %MSBUILD_CMD% -if %errorlevel% NEQ 0 ( +set ERROR_CODE=%errorlevel% +if %ERROR_CODE% NEQ 0 ( echo ERROR: Failed to compile %~1 in "%~2|%~3". - exit /b 1 + goto end ) -exit /b 0 +goto success -:: End of batch file +@REM ----------------------------------------------------------------------- +:success +COLOR 2F +set ERROR_CODE=0 +goto end + +@REM ----------------------------------------------------------------------- +:error +COLOR 4F +set ERROR_CODE=1 +goto end + +@REM ----------------------------------------------------------------------- :end +:: restore caller current directory popd - +exit /b %ERROR_CODE% diff --git a/README.md b/README.md index d7a694a2d..e29bbec13 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Sharpmake -[![Build status](https://ci.appveyor.com/api/projects/status/5y9eug3x9j078x6i?svg=true)](https://ci.appveyor.com/project/belkiss/sharpmake-36817) +![build](https://github.com/ubisoft/Sharpmake/workflows/build/badge.svg) ## Introduction Sharpmake is a generator for Visual Studio projects and solutions. It is @@ -79,7 +79,7 @@ functionality used toolset for functional tests: -tools\FastBuild\FBuild.exe (win x64) and FBuild (osx x64) - v1.01. http://www.fastbuild.org +tools\FastBuild - v1.01. http://www.fastbuild.org diff --git a/Sharpmake.Application/CommandLineArguments.cs b/Sharpmake.Application/CommandLineArguments.cs index 2c0ba82b5..6d9473b3f 100644 --- a/Sharpmake.Application/CommandLineArguments.cs +++ b/Sharpmake.Application/CommandLineArguments.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2021 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -57,11 +57,11 @@ public enum InputType public bool SkipInvalidPath = false; public bool DebugLog = false; public bool Debug = false; + public bool DebugScripts = false; public bool Diagnostics = false; public bool WriteFiles = true; public bool DumpDependency = false; private bool _testOptionValid = true; - public bool ProfileOutput = false; internal TestOptions TestOption; internal bool RegressionDiff = true; public DirectoryInfo OutputDirectory; @@ -69,6 +69,7 @@ public enum InputType public DirectoryInfo RemapRoot; public string MutexSuffix = string.Empty; public bool GenerateDebugSolution = false; + public bool GenerateDebugSolutionOnly = false; public string DebugSolutionStartArguments = string.Empty; [CommandLine.Option("sources", @"sharpmake sources files: ex: /sources( ""project1.sharpmake"", ""..\..\project2.sharpmake"" )")] @@ -157,12 +158,6 @@ public void CommandLineDebugLog(bool value) DebugLog = value; } - [CommandLine.Option("profileoutput", @"Write profiling information ( slow ): ex: /profileoutput()")] - public void CommandLineProfileOutput(bool value) - { - ProfileOutput = value; - } - [CommandLine.Option("diagnostics", @"Output more errors and warnings (slow): ex: /diagnostics")] public void CommandLineDiagnostics() { @@ -175,6 +170,12 @@ public void CommandLineDebug() Debug = true; } + [CommandLine.Option("debugscripts", @"Compile scripts in debug to ease their debuggging: ex: /debugscripts")] + public void CommandLineDebugScripts() + { + DebugScripts = true; + } + [CommandLine.Option("sharpmakemutexsuffix", @"Allow custom mutex name suffix. Useful to debug concurrently multiple sharpmake running from different branches. Ex: /sharpmakemutexsuffix(""Name"")")] public void CommandLineSharpmakeMutexSuffix(string name) { @@ -338,6 +339,13 @@ public void CommandLineDebugSolutionStartArguments(string arguments) DebugSolutionStartArguments = arguments; } + [CommandLine.Option("generateDebugSolutionOnly", @"Generate debug solution only (don't generate solution/project from user code).: /generateDebugSolutionOnly")] + public void CommandLineGenerateDebugSolutionOnly() + { + CommandLineGenerateDebugSolution(); + GenerateDebugSolutionOnly = true; + } + [CommandLine.Option("forcecleanup", @"Path to an autocleanup db. If this is set, all the files listed in the DB will be removed, and sharpmake will exit. ex: /forcecleanup( ""tmp/sharpmakeautocleanupdb.bin"" ")] diff --git a/Sharpmake.Application/Program.cs b/Sharpmake.Application/Program.cs index ae2a0d5b2..1c009730f 100644 --- a/Sharpmake.Application/Program.cs +++ b/Sharpmake.Application/Program.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2021 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ using System.IO; using System.Linq; using System.Reflection; +using System.Runtime.InteropServices; using System.Threading; using System.Threading.Tasks; using Sharpmake.Generators; @@ -192,16 +193,20 @@ private static int Main() if (DebugEnable && informationalVersion != null) versionString += " " + informationalVersion; } + LogWriteLine($"sharpmake {versionString}"); - LogWriteLine(" arguments : {0}", CommandLine.GetProgramCommandLine()); - LogWriteLine(" directory : {0}", Directory.GetCurrentDirectory()); + LogWriteLine(" arguments: {0}", CommandLine.GetProgramCommandLine()); + LogWriteLine(" directory: {0}", Directory.GetCurrentDirectory()); + LogWriteLine(" platform: {0} - {1}", Util.GetExecutingPlatform().ToString(), RuntimeInformation.OSDescription); + LogWriteLine(" compiled with framework: {0}", Util.FrameworkDisplayName()); + LogWriteLine(" running on framework: {0}", RuntimeInformation.FrameworkDescription); LogWriteLine(string.Empty); // display help if wanted and quit if ((CommandLine.GetProgramCommandLine().Length == 0) || CommandLine.ContainParameter("help")) { LogWriteLine(CommandLine.GetCommandLineHelp(typeof(Argument), false)); - return (int)ExitCode.Success; + return CommandLine.ContainParameter("help") ? (int)ExitCode.Success : (int)ExitCode.Error; } AppDomain.CurrentDomain.AssemblyLoad += AppDomain_AssemblyLoad; @@ -430,7 +435,7 @@ private static void LogSharpmakeExtensionLoaded(Assembly extensionAssembly) private static void CreateBuilderAndGenerate(BuildContext.BaseBuildContext buildContext, Argument parameters, bool generateDebugSolution) { - using (Builder builder = CreateBuilder(buildContext, parameters, true, generateDebugSolution)) + using (Builder builder = CreateBuilder(buildContext, parameters, allowCleanBlobs: true, generateDebugSolution: generateDebugSolution)) { if (parameters.CleanBlobsOnly) { @@ -478,7 +483,10 @@ private static void GenerateAll(BuildContext.BaseBuildContext buildContext, Argu ExtensionMethods.ClearVisualStudioDirCaches(); } - CreateBuilderAndGenerate(buildContext, parameters, generateDebugSolution: false); + if (!parameters.GenerateDebugSolutionOnly) + { + CreateBuilderAndGenerate(buildContext, parameters, generateDebugSolution: false); + } } private static ExitCode AnalyzeConfigureOrder(Argument parameters, bool stopOnFirstError) @@ -588,6 +596,7 @@ public static Builder CreateBuilder(BuildContext.BaseBuildContext context, Argum parameters.BlobOnly, parameters.SkipInvalidPath, parameters.Diagnostics, + parameters.DebugScripts, Program.GetGeneratorsManager, parameters.Defines ); @@ -598,9 +607,6 @@ public static Builder CreateBuilder(BuildContext.BaseBuildContext context, Argum builder.EventOutputMessage += LogWrite; builder.EventOutputDebug += DebugWrite; - if (parameters.ProfileOutput) - builder.EventOutputProfile += LogWrite; - if (!string.IsNullOrEmpty(parameters.ProfileFile)) builder.EnableProfiling(); diff --git a/Sharpmake.Application/Properties/AssemblyInfo.cs b/Sharpmake.Application/Properties/AssemblyInfo.cs index 2e6aaec5b..919758783 100644 --- a/Sharpmake.Application/Properties/AssemblyInfo.cs +++ b/Sharpmake.Application/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017, 2019-2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -43,4 +43,4 @@ // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("0.14.6.0")] +[assembly: AssemblyVersion("0.15.0.0")] diff --git a/Sharpmake.Application/Sharpmake.Application.csproj b/Sharpmake.Application/Sharpmake.Application.csproj index 47895a7e6..c500ca556 100644 --- a/Sharpmake.Application/Sharpmake.Application.csproj +++ b/Sharpmake.Application/Sharpmake.Application.csproj @@ -1,27 +1,31 @@ - - + Debug AnyCPU AnyCPU - {37CF3EE3-AFD3-3CC8-8F8E-B423292D491F} Exe Properties Sharpmake.Application Sharpmake.Application - v4.6.1 + net472 512 True + false + false app.manifest + + false + false + AnyCPU true full false - ..\bin\debug + ..\tmp\bin\debug ..\tmp\obj\debug\sharpmake.application ..\tmp\obj\debug\sharpmake.application DEBUG;TRACE @@ -29,14 +33,14 @@ true 618 false - 6 + 7 AnyCPU false pdbonly true - ..\bin\release + ..\tmp\bin\release ..\tmp\obj\release\sharpmake.application ..\tmp\obj\release\sharpmake.application TRACE @@ -44,8 +48,9 @@ true 618 false - 6 + 7 + False @@ -77,5 +82,5 @@ Sharpmake - + \ No newline at end of file diff --git a/Sharpmake.Application/Sharpmake.Application.nuspec b/Sharpmake.Application/Sharpmake.Application.nuspec index 951cdd14c..b58321ff2 100644 --- a/Sharpmake.Application/Sharpmake.Application.nuspec +++ b/Sharpmake.Application/Sharpmake.Application.nuspec @@ -4,9 +4,9 @@ Sharpmake - - - - + + + + diff --git a/Sharpmake.Application/Sharpmake.Application.sharpmake.cs b/Sharpmake.Application/Sharpmake.Application.sharpmake.cs index 14e4d471b..cca66908a 100644 --- a/Sharpmake.Application/Sharpmake.Application.sharpmake.cs +++ b/Sharpmake.Application/Sharpmake.Application.sharpmake.cs @@ -19,6 +19,7 @@ public SharpmakeApplicationProject() public override void ConfigureAll(Configuration conf, Target target) { base.ConfigureAll(conf, target); + conf.ProjectPath = @"[project.SourceRootPath]"; conf.Output = Configuration.OutputType.DotNetConsoleApp; diff --git a/Sharpmake.Application/app.config b/Sharpmake.Application/app.config index 2ca356719..c3f917f81 100644 --- a/Sharpmake.Application/app.config +++ b/Sharpmake.Application/app.config @@ -1,7 +1,8 @@  - - - - - \ No newline at end of file + + + + + + diff --git a/Sharpmake.FunctionalTests/FastBuildFunctionalTest/FastBuildFunctionalTest.sharpmake.cs b/Sharpmake.FunctionalTests/FastBuildFunctionalTest/FastBuildFunctionalTest.sharpmake.cs index 2aaee657c..280fbc211 100644 --- a/Sharpmake.FunctionalTests/FastBuildFunctionalTest/FastBuildFunctionalTest.sharpmake.cs +++ b/Sharpmake.FunctionalTests/FastBuildFunctionalTest/FastBuildFunctionalTest.sharpmake.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2019-2021 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -96,7 +96,7 @@ public static ITarget[] GetDefaultTargets() var targets = new List { new Target( Platform.win64, - DevEnv.vs2017, + DevEnv.vs2019, Optimization.Debug | Optimization.Release, Blob.NoBlob, BuildSystem.MSBuild @@ -539,7 +539,7 @@ public static void SharpmakeMain(Sharpmake.Arguments arguments) FileInfo fileInfo = Util.GetCurrentSharpmakeFileInfo(); string sharpmakeRootDirectory = Util.SimplifyPath(Path.Combine(fileInfo.DirectoryName, "..", "..")); - FastBuildSettings.FastBuildMakeCommand = Path.Combine(sharpmakeRootDirectory, @"tools\FastBuild\FBuild.exe"); + FastBuildSettings.FastBuildMakeCommand = Path.Combine(sharpmakeRootDirectory, @"tools\FastBuild\Windows-x64\FBuild.exe"); FastBuildSettings.FastBuildWait = true; FastBuildSettings.WriteAllConfigsSection = true; diff --git a/Sharpmake.FunctionalTests/FastBuildFunctionalTest/reference/projects/fastbuildfunctionaltest.sln b/Sharpmake.FunctionalTests/FastBuildFunctionalTest/reference/projects/fastbuildfunctionaltest.sln index a5adc765f..ec20630ae 100644 --- a/Sharpmake.FunctionalTests/FastBuildFunctionalTest/reference/projects/fastbuildfunctionaltest.sln +++ b/Sharpmake.FunctionalTests/FastBuildFunctionalTest/reference/projects/fastbuildfunctionaltest.sln @@ -6,8 +6,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "FastBuild", "FastBuild", "{ fastbuildfunctionaltest.bff = fastbuildfunctionaltest.bff EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MixCppAndCExe", "mixcppandcexe_vs2017_win64.vcxproj", "{5A047CB1-D2C4-4765-6F6F-EDD60899737F}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ExplicitlyOrderedPostBuildTest", "explicitlyorderedpostbuildtest_vs2017_win64.vcxproj", "{77AE9D0E-D7D9-039E-9DB9-180932FD4AE9}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FastBuildFunctionalTest_All", "fastbuildfunctionaltest_all.vcxproj", "{6AE06EC2-B2C7-52F6-C657-FE1FFFA43666}" @@ -26,6 +24,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FastBuildFunctionalTest_All {573CBFD5-C93E-15F6-9BFE-132BA37EAE47} = {573CBFD5-C93E-15F6-9BFE-132BA37EAE47} EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MixCppAndCExe", "mixcppandcexe_vs2017_win64.vcxproj", "{5A047CB1-D2C4-4765-6F6F-EDD60899737F}" +EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PostBuildCopyDirTest", "postbuildcopydirtest_vs2017_win64.vcxproj", "{B0087514-0636-5209-BC43-4E8096928555}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PostBuildCopySingleFileTest", "postbuildcopysinglefiletest_vs2017_win64.vcxproj", "{B1F3B803-C020-3A59-6346-D0E116BAAA74}" @@ -56,14 +56,6 @@ Global Release|MSBuild = Release|MSBuild EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {5A047CB1-D2C4-4765-6F6F-EDD60899737F}.Debug|FastBuild.ActiveCfg = Debug_FastBuild_vs2017|x64 - {5A047CB1-D2C4-4765-6F6F-EDD60899737F}.Debug|FastBuild_NoBlob.ActiveCfg = Debug_FastBuild_NoBlob_vs2017|x64 - {5A047CB1-D2C4-4765-6F6F-EDD60899737F}.Debug|MSBuild.ActiveCfg = Debug_MSBuild_vs2017|x64 - {5A047CB1-D2C4-4765-6F6F-EDD60899737F}.Debug|MSBuild.Build.0 = Debug_MSBuild_vs2017|x64 - {5A047CB1-D2C4-4765-6F6F-EDD60899737F}.Release|FastBuild.ActiveCfg = Release_FastBuild_vs2017|x64 - {5A047CB1-D2C4-4765-6F6F-EDD60899737F}.Release|FastBuild_NoBlob.ActiveCfg = Release_FastBuild_NoBlob_vs2017|x64 - {5A047CB1-D2C4-4765-6F6F-EDD60899737F}.Release|MSBuild.ActiveCfg = Release_MSBuild_vs2017|x64 - {5A047CB1-D2C4-4765-6F6F-EDD60899737F}.Release|MSBuild.Build.0 = Release_MSBuild_vs2017|x64 {77AE9D0E-D7D9-039E-9DB9-180932FD4AE9}.Debug|FastBuild.ActiveCfg = Debug_FastBuild_vs2017|x64 {77AE9D0E-D7D9-039E-9DB9-180932FD4AE9}.Debug|FastBuild_NoBlob.ActiveCfg = Debug_FastBuild_NoBlob_vs2017|x64 {77AE9D0E-D7D9-039E-9DB9-180932FD4AE9}.Debug|MSBuild.ActiveCfg = Debug_MSBuild_vs2017|x64 @@ -82,6 +74,14 @@ Global {6AE06EC2-B2C7-52F6-C657-FE1FFFA43666}.Release|FastBuild_NoBlob.ActiveCfg = Release_FastBuild_NoBlob_vs2017|x64 {6AE06EC2-B2C7-52F6-C657-FE1FFFA43666}.Release|FastBuild_NoBlob.Build.0 = Release_FastBuild_NoBlob_vs2017|x64 {6AE06EC2-B2C7-52F6-C657-FE1FFFA43666}.Release|MSBuild.ActiveCfg = Release_FastBuild_NoBlob_vs2017|x64 + {5A047CB1-D2C4-4765-6F6F-EDD60899737F}.Debug|FastBuild.ActiveCfg = Debug_FastBuild_vs2017|x64 + {5A047CB1-D2C4-4765-6F6F-EDD60899737F}.Debug|FastBuild_NoBlob.ActiveCfg = Debug_FastBuild_NoBlob_vs2017|x64 + {5A047CB1-D2C4-4765-6F6F-EDD60899737F}.Debug|MSBuild.ActiveCfg = Debug_MSBuild_vs2017|x64 + {5A047CB1-D2C4-4765-6F6F-EDD60899737F}.Debug|MSBuild.Build.0 = Debug_MSBuild_vs2017|x64 + {5A047CB1-D2C4-4765-6F6F-EDD60899737F}.Release|FastBuild.ActiveCfg = Release_FastBuild_vs2017|x64 + {5A047CB1-D2C4-4765-6F6F-EDD60899737F}.Release|FastBuild_NoBlob.ActiveCfg = Release_FastBuild_NoBlob_vs2017|x64 + {5A047CB1-D2C4-4765-6F6F-EDD60899737F}.Release|MSBuild.ActiveCfg = Release_MSBuild_vs2017|x64 + {5A047CB1-D2C4-4765-6F6F-EDD60899737F}.Release|MSBuild.Build.0 = Release_MSBuild_vs2017|x64 {B0087514-0636-5209-BC43-4E8096928555}.Debug|FastBuild.ActiveCfg = Debug_FastBuild_vs2017|x64 {B0087514-0636-5209-BC43-4E8096928555}.Debug|FastBuild_NoBlob.ActiveCfg = Debug_FastBuild_NoBlob_vs2017|x64 {B0087514-0636-5209-BC43-4E8096928555}.Debug|MSBuild.ActiveCfg = Debug_MSBuild_vs2017|x64 diff --git a/Sharpmake.FunctionalTests/NoAllFastBuildProjectFunctionalTest/NoAllFastBuildProjectFunctionalTest.sharpmake.cs b/Sharpmake.FunctionalTests/NoAllFastBuildProjectFunctionalTest/NoAllFastBuildProjectFunctionalTest.sharpmake.cs index c876aa006..dbf338dd2 100644 --- a/Sharpmake.FunctionalTests/NoAllFastBuildProjectFunctionalTest/NoAllFastBuildProjectFunctionalTest.sharpmake.cs +++ b/Sharpmake.FunctionalTests/NoAllFastBuildProjectFunctionalTest/NoAllFastBuildProjectFunctionalTest.sharpmake.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2020-2021 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -24,7 +24,7 @@ public static Target Get() { return new Target( Platform.win64, - DevEnv.vs2017, + DevEnv.vs2019, Optimization.Debug | Optimization.Release ); } @@ -190,7 +190,7 @@ public static void SharpmakeMain(Arguments arguments) FileInfo fileInfo = Util.GetCurrentSharpmakeFileInfo(); string sharpmakeRootDirectory = Util.SimplifyPath(Path.Combine(fileInfo.DirectoryName, "..", "..")); - FastBuildSettings.FastBuildMakeCommand = Path.Combine(sharpmakeRootDirectory, @"tools\FastBuild\FBuild.exe"); + FastBuildSettings.FastBuildMakeCommand = Path.Combine(sharpmakeRootDirectory, @"tools\FastBuild\Windows-x64\FBuild.exe"); FastBuildSettings.FastBuildWait = true; FastBuildSettings.WriteAllConfigsSection = true; diff --git a/Sharpmake.FunctionalTests/Sharpmake.FunctionalTests.sharpmake.cs b/Sharpmake.FunctionalTests/Sharpmake.FunctionalTests.sharpmake.cs index 7806aec4c..2c9321294 100644 --- a/Sharpmake.FunctionalTests/Sharpmake.FunctionalTests.sharpmake.cs +++ b/Sharpmake.FunctionalTests/Sharpmake.FunctionalTests.sharpmake.cs @@ -18,6 +18,8 @@ public FunctionalTestProject() @"\\reference\\" ); + DependenciesCopyLocal = DependenciesCopyLocalTypes.None; + AddTargets(Common.GetDefaultTargets()); } @@ -26,7 +28,7 @@ public override void ConfigureAll(Configuration conf, Target target) base.ConfigureAll(conf, target); conf.SolutionFolder = "FunctionalTests"; - conf.TargetPath = @"[project.RootPath]\bin\[target.Optimization]\functionaltests"; + conf.TargetPath = @"[project.RootPath]\tmp\functionaltests\[target.Optimization]\[project.Name]"; conf.AddPrivateDependency(target); conf.AddPrivateDependency(target); @@ -36,10 +38,9 @@ public override void ConfigureAll(Configuration conf, Target target) conf.CsprojUserFile = new Project.Configuration.CsprojUserFileSettings { StartAction = Project.Configuration.CsprojUserFileSettings.StartActionSetting.Program, - StartProgram = @"[conf.TargetPath]\Sharpmake.Application.exe", + StartProgram = @"[project.RootPath]\tmp\bin\[conf.Target.Optimization]\Sharpmake.Application.exe", StartArguments = "/sources(\"[project.Name].sharpmake.cs\")", - WorkingDirectory = "[project.SourceRootPath]", - OverwriteExistingFile = false + WorkingDirectory = "[project.SourceRootPath]" }; } } diff --git a/Sharpmake.Generators/Apple/XCWorkspace.Template.cs b/Sharpmake.Generators/Apple/XCWorkspace.Template.cs index 904ad5cd8..d079dc7a6 100644 --- a/Sharpmake.Generators/Apple/XCWorkspace.Template.cs +++ b/Sharpmake.Generators/Apple/XCWorkspace.Template.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017, 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -28,15 +28,23 @@ private static class Template public static string ProjectReference = "\t\n\t\n"; public static string ProjectReferenceAbsolute = -@" - +@"[indent] +[indent] "; public static string ProjectReferenceRelative = -@" - +@"[indent] +[indent] +"; + public static string GroupBegin = +@"[indent] +"; + public static string GroupEnd = +@"[indent] "; } } diff --git a/Sharpmake.Generators/Apple/XCWorkspace.cs b/Sharpmake.Generators/Apple/XCWorkspace.cs index ebfa37361..f90b16047 100644 --- a/Sharpmake.Generators/Apple/XCWorkspace.cs +++ b/Sharpmake.Generators/Apple/XCWorkspace.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2018, 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -24,6 +24,8 @@ public partial class XCWorkspace : ISolutionGenerator private const string SolutionExtension = ".xcworkspace"; private const string SolutionContentsFileName = "contents.xcworkspacedata"; + private Dictionary _solutionFolderCache = new Dictionary(); + public void Generate(Builder builder, Solution solution, List configurations, string solutionFile, List generatedFiles, List skipFiles) { _builder = builder; @@ -79,12 +81,16 @@ private string Generate(Solution solution, List configur fileGenerator.Write(Template.Header); - foreach (Solution.ResolvedProject resolvedProject in solutionProjects) + _solutionFolderCache.Clear(); + List solutionsFiles = solutionProjects.Select(project => { var solutionFileItem = new SolutionFile() { Name = project.ProjectFile, Parent = ParseSolutionFolder(project.SolutionFolder) }; solutionFileItem.RegisterToParent(); return solutionFileItem; }).ToList(); + List solutionsItems = solutionsFiles.GroupBy(solutionsItem => solutionsItem.GetRoot()).Select(group => group.Key).ToList(); + solutionsItems.Sort((a, b) => string.Compare(a.Name, b.Name)); + + foreach (var solutionItem in solutionsItems) { - using (fileGenerator.Declare("projectPath", resolvedProject.ProjectFile)) - { - fileGenerator.Write(Template.ProjectReferenceAbsolute); - } + //Sort of folders content + (solutionItem as SolutionFolder)?.Sort(); + WriteSolutionItem(fileGenerator, solutionItem); } fileGenerator.Write(Template.Footer); @@ -103,5 +109,125 @@ private void Write(string value, TextWriter writer, Resolver resolver) writer.Write(str); writer.Flush(); } + + private static void WriteSolutionItem(FileGenerator fileGenerator, SolutionItem solutionItem, int nbIndent = 0) + { + bool isFolder = !solutionItem.IsFile; + string indent = new string('\t', nbIndent); + if (isFolder) + { + SolutionFolder solutionFolder = solutionItem as SolutionFolder; + + using (fileGenerator.Declare("folderName", solutionFolder.Name)) + using (fileGenerator.Declare("indent", indent)) + { + fileGenerator.Write(Template.GroupBegin); + } + + foreach (var child in solutionFolder.Childs) + { + WriteSolutionItem(fileGenerator, child, nbIndent + 1); + } + + using (fileGenerator.Declare("indent", indent)) + { + fileGenerator.Write(Template.GroupEnd); + } + } + else + { + using (fileGenerator.Declare("projectPath", solutionItem.Name)) + using (fileGenerator.Declare("indent", indent)) + { + fileGenerator.Write(Template.ProjectReferenceAbsolute); + } + } + } + + [System.Diagnostics.DebuggerDisplay("{Path}")] + private class SolutionItem + { + public string Name; + public string Path + { + get + { + if (Parent == null) + return Name; + + return System.IO.Path.Combine(Parent.Path, Name); + } + } + + public SolutionItem Parent; + + public virtual bool IsFile => true; + + public SolutionItem GetRoot() + { + return Parent == null ? this : Parent.GetRoot(); + } + } + + private class SolutionFile : SolutionItem + { + public override bool IsFile => true; + public void RegisterToParent() + { + var parent = Parent as SolutionFolder; + if (parent != null) + parent.Childs.Add(this); + } + } + + private class SolutionFolder : SolutionItem + { + public List Childs = new List(); + public void Sort() + { + Childs.Sort((a, b) => string.Compare(a.Name, b.Name)); + foreach (var child in Childs) + { + (child as SolutionFolder)?.Sort(); + } + } + public override bool IsFile => false; + } + + private SolutionFolder ParseSolutionFolder(string solutionFolders) + { + if (string.IsNullOrEmpty(solutionFolders)) + return null; + + SolutionFolder result = null; + + string path = MakeStandartPath(solutionFolders); + if (!_solutionFolderCache.TryGetValue(path, out result)) + { + List solutionFolderStack = path.Split(Util._pathSeparators, System.StringSplitOptions.RemoveEmptyEntries).ToList(); + string folderName = solutionFolderStack.Last(); + solutionFolderStack.RemoveAt(solutionFolderStack.Count - 1); + SolutionFolder parent = ParseSolutionFolder(string.Join(Path.DirectorySeparatorChar.ToString(), solutionFolderStack)); + + result = new SolutionFolder() + { + Name = folderName, + Parent = parent + }; + + if (parent != null) + { + parent.Childs.Add(result); + } + + _solutionFolderCache.Add(path, result); + } + return result; + } + + private string MakeStandartPath(string path) + { + return string.Join(Path.DirectorySeparatorChar.ToString(), path.Split(Util._pathSeparators, System.StringSplitOptions.RemoveEmptyEntries)); + } } } diff --git a/Sharpmake.Generators/Apple/XCode.Util.cs b/Sharpmake.Generators/Apple/XCode.Util.cs index 6b0bb0c47..ded1c4122 100644 --- a/Sharpmake.Generators/Apple/XCode.Util.cs +++ b/Sharpmake.Generators/Apple/XCode.Util.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.Generators/Apple/XCodeProj.Template.cs b/Sharpmake.Generators/Apple/XCodeProj.Template.cs index 96e9c3c01..8caca1a15 100644 --- a/Sharpmake.Generators/Apple/XCodeProj.Template.cs +++ b/Sharpmake.Generators/Apple/XCodeProj.Template.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017, 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -260,6 +260,7 @@ private static class Template ""CODE_SIGN_IDENTITY[sdk=iphoneos*]"" = ""[item.Options.CodeSigningIdentity]""; DEBUG_INFORMATION_FORMAT = [item.Options.DebugInformationFormat]; DEAD_CODE_STRIPPING = [item.Options.DeadStripping]; + DEVELOPMENT_TEAM = [item.Options.DevelopmentTeam]; CONFIGURATION_BUILD_DIR = ""[item.Options.BuildDirectory]""; ENABLE_BITCODE = [item.Options.EnableBitcode]; EXCLUDED_SOURCE_FILE_NAMES = [item.Options.ExcludedSourceFileNames]; diff --git a/Sharpmake.Generators/Apple/XCodeProj.cs b/Sharpmake.Generators/Apple/XCodeProj.cs index c4a539b1b..49e94d460 100644 --- a/Sharpmake.Generators/Apple/XCodeProj.cs +++ b/Sharpmake.Generators/Apple/XCodeProj.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -275,7 +275,9 @@ private void PrepareSections(XCodeGenerationContext context, List(configuration); - XCodeUtil.ResolveProjectPaths(project, assetCatalog); - foreach (string asset in assetCatalog) - { - projectFiles.Add(asset); - } } _projectReferencesGroups = new Dictionary(); @@ -338,8 +333,8 @@ private void PrepareSections(XCodeGenerationContext context, List { return !project.ResourceFiles.Contains(file); }), project, conf, workspacePath); - PrepareResourceFiles(xCodeTargetName, project.ResourceFiles, project, conf); + PrepareSourceFiles(xCodeTargetName, sourceFiles.SortedValues, project, conf, workspacePath); + PrepareResourceFiles(xCodeTargetName, resourceFiles.SortedValues, project, conf); PrepareExternalResourceFiles(xCodeTargetName, project, conf); RegisterScriptBuildPhase(xCodeTargetName, _shellScriptPreBuildPhases, conf.EventPreBuild.GetEnumerator()); diff --git a/Sharpmake.Generators/CompilerSettings.cs b/Sharpmake.Generators/CompilerSettings.cs index 0075d7078..d9c674661 100644 --- a/Sharpmake.Generators/CompilerSettings.cs +++ b/Sharpmake.Generators/CompilerSettings.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2018, 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.Generators/FastBuild/Bff.Template.cs b/Sharpmake.Generators/FastBuild/Bff.Template.cs index 90e7edb26..bb4ebbaea 100644 --- a/Sharpmake.Generators/FastBuild/Bff.Template.cs +++ b/Sharpmake.Generators/FastBuild/Bff.Template.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2021 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -66,6 +66,7 @@ public static class ConfigurationFile [CachePath] [WorkerConnectionLimit] .AllowDBMigration_Experimental = [fastBuildAllowDBMigration] +[AdditionalGlobalSettings] } "; @@ -107,7 +108,9 @@ public static class ConfigurationFile .Executable = '[fastBuildCompilerExecutable]' .ExtraFiles = [fastBuildExtraFiles] .CompilerFamily = '[fastBuildCompilerFamily]' + .UseRelativePaths_Experimental = [fastBuildCompilerUseRelativePaths] [fastBuildVS2012EnumBugWorkaround] +[fastBuildCompilerAdditionalSettings] } "; @@ -205,6 +208,7 @@ public static class ConfigurationFile .PCHOptions = '""%1"" /Fp""%2"" /Fo""%3"" /c' + ' /Yc""[cmdLineOptions.PrecompiledHeaderThrough]""' + ' [fastBuildPCHForceInclude]' + + ' [options.AdditionalCompilerOptionsOnPCHCreate]' + ' $CompilerExtraOptions$' + ' $CompilerOptimizations$' @@ -215,6 +219,7 @@ public static class ConfigurationFile .PCHInputFile = '[fastBuildPrecompiledSourceFile]' .PCHOutputFile = '[cmdLineOptions.PrecompiledHeaderFile]' .PCHOptions = '-o ""%2"" -c -x c++-header ""%1""' + + ' [options.AdditionalCompilerOptionsOnPCHCreate]' + ' $CompilerExtraOptions$' + ' $CompilerOptimizations$' @@ -223,8 +228,11 @@ public static class ConfigurationFile .PCHOptionsDeoptimized = .PCHOptions "; - public static string UsePrecompClang = @"-include-pch $PCHOutputFile$"; + public static string UsePrecompClang = @"-include-pch $PCHOutputFile$' + + ' [options.AdditionalCompilerOptionsOnPCHUse]' + + '"; public static string UsePrecomp = @"/Yu""[cmdLineOptions.PrecompiledHeaderThrough]"" /Fp""$PCHOutputFile$""' + + ' [options.AdditionalCompilerOptionsOnPCHUse]' + ' [fastBuildPCHForceInclude]"; public static string ResourceCompilerOptions = @" @@ -370,7 +378,9 @@ public static class ConfigurationFile + ' [cmdLineOptions.RemoveUnreferencedCodeData]' + ' [cmdLineOptions.RuntimeTypeInfo]' + ' [cmdLineOptions.OpenMP]' + + ' [cmdLineOptions.LanguageStandard_C]' + ' [cmdLineOptions.LanguageStandard]' + + ' [cmdLineOptions.ConformanceMode]' // Output Files options // --------------------------- + ' [cmdLineOptions.CompilerProgramDatabaseFile]' @@ -519,6 +529,7 @@ public static class ConfigurationFile .ExecUseStdOutAsOutput = [fastBuildPrebuildUseStdOutAsOutput] .ExecAlwaysShowOutput = [fastBuildPrebuildAlwaysShowOutput] .PreBuildDependencies = [fastBuildExecPreBuildDependencies] + .ExecAlways = [fastBuildExecAlways] } "; @@ -562,6 +573,7 @@ public static class ConfigurationFile .UnityOutputPattern = '[unityFile.UnityOutputPattern]' .UnityNumFiles = [unityFile.UnityNumFiles] .UnityPCH = '[unityFile.UnityPCH]' + .UseRelativePaths_Experimental = [unityFile.UseRelativePaths] } "; diff --git a/Sharpmake.Generators/FastBuild/Bff.Util.cs b/Sharpmake.Generators/FastBuild/Bff.Util.cs index 7bd35e3fc..dfaddb241 100644 --- a/Sharpmake.Generators/FastBuild/Bff.Util.cs +++ b/Sharpmake.Generators/FastBuild/Bff.Util.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2021 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -25,21 +25,22 @@ public partial class Bff { public class Unity { - public string UnityName = string.Empty; // Name of unity - public string UnityOutputPath = string.Empty; // Path to output generated Unity files - public string UnityInputPath = FileGeneratorUtilities.RemoveLineTag; // (optional) Path (or paths) to find files - public string UnityInputExcludePath = FileGeneratorUtilities.RemoveLineTag; // (optional) Path (or paths) in which to ignore files - public string UnityInputExcludePattern = FileGeneratorUtilities.RemoveLineTag; // (optional) Wildcard pattern(s) of files/folders to exclude - public string UnityInputPattern = FileGeneratorUtilities.RemoveLineTag; // (optional) Pattern(s) of files to find (default *cpp) - public string UnityInputPathRecurse = FileGeneratorUtilities.RemoveLineTag; // (optional) Recurse when searching for files (default true) - public string UnityInputFiles = FileGeneratorUtilities.RemoveLineTag; // (optional) Explicit list of files to include - public string UnityInputExcludedFiles = FileGeneratorUtilities.RemoveLineTag; // (optional) Explicit list of excluded files (partial, root-relative of full path) - public string UnityInputObjectLists = FileGeneratorUtilities.RemoveLineTag; // (optional) ObjectList(s) to use as input - public string UnityInputIsolateWritableFiles = FileGeneratorUtilities.RemoveLineTag; // (optional) Build writable files individually (default false) + public string UnityName = string.Empty; // Name of unity + public string UnityOutputPath = string.Empty; // Path to output generated Unity files + public string UnityInputPath = FileGeneratorUtilities.RemoveLineTag; // (optional) Path (or paths) to find files + public string UnityInputExcludePath = FileGeneratorUtilities.RemoveLineTag; // (optional) Path (or paths) in which to ignore files + public string UnityInputExcludePattern = FileGeneratorUtilities.RemoveLineTag; // (optional) Wildcard pattern(s) of files/folders to exclude + public string UnityInputPattern = FileGeneratorUtilities.RemoveLineTag; // (optional) Pattern(s) of files to find (default *cpp) + public string UnityInputPathRecurse = FileGeneratorUtilities.RemoveLineTag; // (optional) Recurse when searching for files (default true) + public string UnityInputFiles = FileGeneratorUtilities.RemoveLineTag; // (optional) Explicit list of files to include + public string UnityInputExcludedFiles = FileGeneratorUtilities.RemoveLineTag; // (optional) Explicit list of excluded files (partial, root-relative of full path) + public string UnityInputObjectLists = FileGeneratorUtilities.RemoveLineTag; // (optional) ObjectList(s) to use as input + public string UnityInputIsolateWritableFiles = FileGeneratorUtilities.RemoveLineTag; // (optional) Build writable files individually (default false) public string UnityInputIsolateWritableFilesLimit = FileGeneratorUtilities.RemoveLineTag; // (optional) Disable isolation when many files are writable (default 0) - public string UnityOutputPattern = FileGeneratorUtilities.RemoveLineTag; // (optional) Pattern of output Unity file names (default Unity*cpp) - public string UnityNumFiles = FileGeneratorUtilities.RemoveLineTag; // (optional) Number of Unity files to generate (default 1) - public string UnityPCH = FileGeneratorUtilities.RemoveLineTag; // (optional) Precompiled Header file to add to generated Unity files + public string UnityOutputPattern = FileGeneratorUtilities.RemoveLineTag; // (optional) Pattern of output Unity file names (default Unity*cpp) + public string UnityNumFiles = FileGeneratorUtilities.RemoveLineTag; // (optional) Number of Unity files to generate (default 1) + public string UnityPCH = FileGeneratorUtilities.RemoveLineTag; // (optional) Precompiled Header file to add to generated Unity files + public string UseRelativePaths = FileGeneratorUtilities.RemoveLineTag; // (optional) Use relative paths for generated Unity files public const string DefaultUnityInputPatternExtension = ".cpp"; @@ -63,6 +64,7 @@ public override int GetHashCode() hash = hash * 23 + UnityOutputPattern.GetHashCode(); hash = hash * 23 + UnityNumFiles.GetHashCode(); hash = hash * 23 + UnityPCH.GetHashCode(); + hash = hash * 23 + UseRelativePaths.GetHashCode(); return hash; } @@ -79,21 +81,22 @@ public override bool Equals(object obj) private bool Equals(Unity unity) { - return string.Equals(UnityName, unity.UnityName) - && string.Equals(UnityOutputPath, unity.UnityOutputPath) - && string.Equals(UnityInputPath, unity.UnityInputPath) - && string.Equals(UnityInputExcludePath, unity.UnityInputExcludePath) - && string.Equals(UnityInputExcludePattern, unity.UnityInputExcludePattern) - && string.Equals(UnityInputPattern, unity.UnityInputPattern) - && string.Equals(UnityInputPathRecurse, unity.UnityInputPathRecurse) - && string.Equals(UnityInputFiles, unity.UnityInputFiles) - && string.Equals(UnityInputExcludedFiles, unity.UnityInputExcludedFiles) - && string.Equals(UnityInputObjectLists, unity.UnityInputObjectLists) - && string.Equals(UnityInputIsolateWritableFiles, unity.UnityInputIsolateWritableFiles) + return string.Equals(UnityName, unity.UnityName) + && string.Equals(UnityOutputPath, unity.UnityOutputPath) + && string.Equals(UnityInputPath, unity.UnityInputPath) + && string.Equals(UnityInputExcludePath, unity.UnityInputExcludePath) + && string.Equals(UnityInputExcludePattern, unity.UnityInputExcludePattern) + && string.Equals(UnityInputPattern, unity.UnityInputPattern) + && string.Equals(UnityInputPathRecurse, unity.UnityInputPathRecurse) + && string.Equals(UnityInputFiles, unity.UnityInputFiles) + && string.Equals(UnityInputExcludedFiles, unity.UnityInputExcludedFiles) + && string.Equals(UnityInputObjectLists, unity.UnityInputObjectLists) + && string.Equals(UnityInputIsolateWritableFiles, unity.UnityInputIsolateWritableFiles) && string.Equals(UnityInputIsolateWritableFilesLimit, unity.UnityInputIsolateWritableFilesLimit) - && string.Equals(UnityOutputPattern, unity.UnityOutputPattern) - && string.Equals(UnityNumFiles, unity.UnityNumFiles) - && string.Equals(UnityPCH, unity.UnityPCH); + && string.Equals(UnityOutputPattern, unity.UnityOutputPattern) + && string.Equals(UnityNumFiles, unity.UnityNumFiles) + && string.Equals(UnityPCH, unity.UnityPCH) + && string.Equals(UseRelativePaths, unity.UseRelativePaths); } } @@ -123,6 +126,7 @@ internal class ExecNode : BffDependentNode public string WorkingPath; public bool UseStdOutAsOutput; public bool AlwaysShowOutput; + public bool ExecAlways; public ExecNode(string buildStepKey, Project.Configuration.BuildStepExecutable buildStep) { @@ -137,6 +141,7 @@ public ExecNode(string buildStepKey, Project.Configuration.BuildStepExecutable b WorkingPath = buildStep.ExecutableWorkingDirectory; UseStdOutAsOutput = buildStep.FastBuildUseStdOutAsOutput; AlwaysShowOutput = buildStep.FastBuildAlwaysShowOutput; + ExecAlways = buildStep.FastBuildExecAlways; } public override string Resolve(string rootPath, string bffFilePath, Resolver resolver) @@ -152,6 +157,7 @@ public override string Resolve(string rootPath, string bffFilePath, Resolver res using (resolver.NewScopedParameter("fastBuildPrebuildUseStdOutAsOutput", UseStdOutAsOutput ? "true" : FileGeneratorUtilities.RemoveLineTag)) using (resolver.NewScopedParameter("fastBuildPrebuildAlwaysShowOutput", AlwaysShowOutput ? "true" : FileGeneratorUtilities.RemoveLineTag)) using (resolver.NewScopedParameter("fastBuildExecPreBuildDependencies", Dependencies.Count > 0 ? UtilityMethods.FBuildFormatList(Dependencies.ToList(), 26) : FileGeneratorUtilities.RemoveLineTag)) + using (resolver.NewScopedParameter("fastBuildExecAlways", ExecAlways ? "true" : FileGeneratorUtilities.RemoveLineTag)) { return resolver.Resolve(Bff.Template.ConfigurationFile.GenericExecutableSection); } diff --git a/Sharpmake.Generators/FastBuild/Bff.cs b/Sharpmake.Generators/FastBuild/Bff.cs index 5ddb39c02..f143f0246 100644 --- a/Sharpmake.Generators/FastBuild/Bff.cs +++ b/Sharpmake.Generators/FastBuild/Bff.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2021 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -625,6 +625,9 @@ List skipFiles // Do not take Cpp Language conformance into account while compiling in C scopedOptions.Add(new Options.ScopedOption(confCmdLineOptions, "CppLanguageStd", FileGeneratorUtilities.RemoveLineTag)); scopedOptions.Add(new Options.ScopedOption(confOptions, "ClangCppLanguageStandard", FileGeneratorUtilities.RemoveLineTag)); + // MSVC + scopedOptions.Add(new Options.ScopedOption(confCmdLineOptions, "LanguageStandard", FileGeneratorUtilities.RemoveLineTag)); + if (clangPlatformBff != null) clangFileLanguage = "-x c "; // Compiler option to indicate that its a C file fastBuildSourceFileType = "/TC"; @@ -634,6 +637,8 @@ List skipFiles // Do not take C Language conformance into account while compiling in Cpp scopedOptions.Add(new Options.ScopedOption(confCmdLineOptions, "CLanguageStd", FileGeneratorUtilities.RemoveLineTag)); scopedOptions.Add(new Options.ScopedOption(confOptions, "ClangCLanguageStandard", FileGeneratorUtilities.RemoveLineTag)); + // MSVC + scopedOptions.Add(new Options.ScopedOption(confCmdLineOptions, "LanguageStandard_C", FileGeneratorUtilities.RemoveLineTag)); fastBuildSourceFileType = "/TP"; fastBuildUsingPlatformConfig = platformBff.CppConfigName(conf); @@ -1842,7 +1847,8 @@ private void ConfigureUnities(IGenerationContext context, Dictionary " " + setting)); + } + string fastBuildPATH = FileGeneratorUtilities.RemoveLineTag; if (FastBuildSettings.SetPathToResourceCompilerInEnvironment) { @@ -609,6 +615,7 @@ private static void WriteMasterSettingsSection(FileGenerator masterBffGenerator, using (masterBffGenerator.Declare("fastBuildSystemRoot", FastBuildSettings.SystemRoot)) using (masterBffGenerator.Declare("fastBuildPATH", fastBuildPATH)) using (masterBffGenerator.Declare("fastBuildAllowDBMigration", FastBuildSettings.FastBuildAllowDBMigration ? "true" : FileGeneratorUtilities.RemoveLineTag)) + using (masterBffGenerator.Declare("AdditionalGlobalSettings", additionalGlobalSettings)) using (masterBffGenerator.Declare("fastBuildEnvironments", fastBuildEnvironments)) using (masterBffGenerator.Declare("envRemoveGuards", envRemoveGuards)) { @@ -626,6 +633,12 @@ private static void WriteMasterCompilerSection(FileGenerator masterBffGenerator, var compilerPlatform = compilerSettings.PlatformFlags; string fastBuildCompilerFamily = UtilityMethods.GetFBuildCompilerFamily(compilerSettings.FastBuildCompilerFamily); + string fastBuildCompilerUseRelativePaths = FileGeneratorUtilities.RemoveLineTag; + if (FastBuildSettings.CompilersUsingRelativePaths.Contains(compiler.Key)) + { + fastBuildCompilerUseRelativePaths = "true"; + } + string fastBuildVS2012EnumBugWorkaround = FileGeneratorUtilities.RemoveLineTag; if (FastBuildSettings.EnableVS2012EnumBugWorkaround && compilerSettings.DevEnv == DevEnv.vs2012 && @@ -634,12 +647,21 @@ private static void WriteMasterCompilerSection(FileGenerator masterBffGenerator, fastBuildVS2012EnumBugWorkaround = ".VS2012EnumBugFix = true"; } + string fastBuildCompilerAdditionalSettings = FileGeneratorUtilities.RemoveLineTag; + if (FastBuildSettings.AdditionalCompilerSettings.TryGetValue(compiler.Key, out IList extraOptions) && + extraOptions.Any()) + { + fastBuildCompilerAdditionalSettings = string.Join(Environment.NewLine, extraOptions.Select(option => " " + option)); + } + using (masterBffGenerator.Declare("fastbuildCompilerName", compiler.Key)) using (masterBffGenerator.Declare("fastBuildCompilerRootPath", compilerSettings.RootPath)) using (masterBffGenerator.Declare("fastBuildCompilerExecutable", string.IsNullOrEmpty(compilerSettings.Executable) ? FileGeneratorUtilities.RemoveLineTag : compilerSettings.Executable)) using (masterBffGenerator.Declare("fastBuildExtraFiles", compilerSettings.ExtraFiles.Count > 0 ? UtilityMethods.FBuildCollectionFormat(compilerSettings.ExtraFiles, 28) : FileGeneratorUtilities.RemoveLineTag)) using (masterBffGenerator.Declare("fastBuildCompilerFamily", string.IsNullOrEmpty(fastBuildCompilerFamily) ? FileGeneratorUtilities.RemoveLineTag : fastBuildCompilerFamily)) + using (masterBffGenerator.Declare("fastBuildCompilerUseRelativePaths", fastBuildCompilerUseRelativePaths)) using (masterBffGenerator.Declare("fastBuildVS2012EnumBugWorkaround", fastBuildVS2012EnumBugWorkaround)) + using (masterBffGenerator.Declare("fastBuildCompilerAdditionalSettings", fastBuildCompilerAdditionalSettings)) { masterBffGenerator.Write(Bff.Template.ConfigurationFile.CompilerSetting); foreach (var compilerConfiguration in compilerSettings.Configurations.OrderBy(x => x.Key)) diff --git a/Sharpmake.Generators/FileGenerator.cs b/Sharpmake.Generators/FileGenerator.cs index d57c13c8e..9687aee8c 100644 --- a/Sharpmake.Generators/FileGenerator.cs +++ b/Sharpmake.Generators/FileGenerator.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017, 2019-2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.Generators/GeneratorManager.cs b/Sharpmake.Generators/GeneratorManager.cs index 965de138a..76e5f6a50 100644 --- a/Sharpmake.Generators/GeneratorManager.cs +++ b/Sharpmake.Generators/GeneratorManager.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.Generators/Generic/JsonCompilationDatabase.cs b/Sharpmake.Generators/Generic/JsonCompilationDatabase.cs index 9c6e90156..cc8ccf989 100644 --- a/Sharpmake.Generators/Generic/JsonCompilationDatabase.cs +++ b/Sharpmake.Generators/Generic/JsonCompilationDatabase.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2019-2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.Generators/Generic/MakeApplication.Template.cs b/Sharpmake.Generators/Generic/MakeApplication.Template.cs index 93e57ca57..1a224671f 100644 --- a/Sharpmake.Generators/Generic/MakeApplication.Template.cs +++ b/Sharpmake.Generators/Generic/MakeApplication.Template.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017, 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.Generators/Generic/MakeApplication.cs b/Sharpmake.Generators/Generic/MakeApplication.cs index da13a4acc..1da9f6acb 100644 --- a/Sharpmake.Generators/Generic/MakeApplication.cs +++ b/Sharpmake.Generators/Generic/MakeApplication.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2018, 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.Generators/Generic/MakeProject.Template.cs b/Sharpmake.Generators/Generic/MakeProject.Template.cs index 71b367ad0..6402074e7 100644 --- a/Sharpmake.Generators/Generic/MakeProject.Template.cs +++ b/Sharpmake.Generators/Generic/MakeProject.Template.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017, 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.Generators/Generic/MakeProject.cs b/Sharpmake.Generators/Generic/MakeProject.cs index 349f50547..6f494e99d 100644 --- a/Sharpmake.Generators/Generic/MakeProject.cs +++ b/Sharpmake.Generators/Generic/MakeProject.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.Generators/Generic/Makefile.Template.cs b/Sharpmake.Generators/Generic/Makefile.Template.cs index 42e1c01d3..0e249d888 100644 --- a/Sharpmake.Generators/Generic/Makefile.Template.cs +++ b/Sharpmake.Generators/Generic/Makefile.Template.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017, 2019-2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -45,11 +45,11 @@ export config public static string ProjectRuleEnd = "\n\t@echo \" ==== Building [projectName] ($(config)) ====\"" + - "\n\t@${MAKE} --no-print-directory -C [projectFileDirectory] -f [projectFileName]\n\n"; + "\n\t@${MAKE} --no-print-directory -C \"[projectFileDirectory]\" -f \"[projectFileName]\"\n\n"; public static string CleanRuleBegin = "clean:\n"; - public static string CleanRuleProject = "\t@${MAKE} --no-print-directory -C [projectFileDirectory] -f [projectFileName] clean\n"; + public static string CleanRuleProject = "\t@${MAKE} --no-print-directory -C \"[projectFileDirectory]\" -f \"[projectFileName]\" clean\n"; public static string CleanRuleEnd = "\n"; @@ -103,6 +103,10 @@ ifndef verbose RESFLAGS += $(DEFINES) $(INCLUDES) LDDEPS += [options.LDDEPS] LINKCMD = [options.LinkCommand] + PCH = [precompHeader] + PCHOUT = [precompHeaderOut] + GCH = [precompIntermediate] + PCHCMD = [precompCommand] define PREBUILDCMDS endef define PRELINKCMDS @@ -116,6 +120,8 @@ define POSTFILECMDS "; public static string LinkCommandLib = "$(AR) -rcs $(TARGET) $(OBJECTS)"; + public static string LinkCommandDll = "$(CXX) -shared -o $(TARGET) $(OBJECTS) $(LDFLAGS) $(RESOURCES) $(LDLIBS)"; + public static string LinkCommandExe = "$(CXX) -o $(TARGET) $(OBJECTS) $(LDFLAGS) $(RESOURCES) $(LDLIBS)"; public static string ObjectsVariableBegin = "ifeq ($(config),[name])\n"; @@ -180,32 +186,35 @@ @echo Cleaning [projectName] $(PRELINKCMDS) ifneq (,$(PCH)) -$(GCH): $(PCH) +$(GCH): $(PCH) | $(OBJDIR) @echo $(notdir $<) -$(SILENT) cp $< $(OBJDIR) - $(SILENT) $(CXX) $(CXXFLAGS) -o ""$@"" -c ""$<"" + $(SILENT) $(CXX) $(CXXFLAGS) -xc++-header -o ""$@"" -c ""$<"" $(SILENT) $(POSTFILECMDS) endif "; public static readonly string ObjectRuleCxx = -@"$(OBJDIR)/[objectFile]: [sourceFile] | $(OBJDIR) +@"$(OBJDIR)/[objectFile]: [sourceFile] $(GCH) | $(OBJDIR) @echo $(notdir $<) - $(SILENT) $(CXX) $(CXXFLAGS) -o ""$@"" -c ""$<"" + $(SILENT) $(CXX) $(CXXFLAGS) $(PCHCMD) -o ""$@"" -c ""$<"" $(SILENT) $(POSTFILECMDS) "; public static readonly string ObjectRuleC = -@"$(OBJDIR)/[objectFile]: [sourceFile] | $(OBJDIR) +@"$(OBJDIR)/[objectFile]: [sourceFile] $(GCH) | $(OBJDIR) @echo $(notdir $<) - $(SILENT) $(CXX) $(CFLAGS) -x c -o ""$@"" -c ""$<"" + $(SILENT) $(CXX) $(CFLAGS) $(PCHCMD) -x c -o ""$@"" -c ""$<"" $(SILENT) $(POSTFILECMDS) "; - public static string Footer = "-include $(OBJECTS:%.o=%.d)\n"; + public static string Footer = +@"-include $(OBJECTS:%.o=%.d) +-include $(GCH:%.gch=%.d) +"; } } } diff --git a/Sharpmake.Generators/Generic/Makefile.cs b/Sharpmake.Generators/Generic/Makefile.cs index b94b1716f..190a045fb 100644 --- a/Sharpmake.Generators/Generic/Makefile.cs +++ b/Sharpmake.Generators/Generic/Makefile.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2021 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -149,7 +149,7 @@ private string GenerateSolution( { FileInfo projectFileInfo = new FileInfo(resolvedProject.ProjectFile); using (fileGenerator.Declare("projectName", resolvedProject.ProjectName)) - using (fileGenerator.Declare("projectFileDirectory", PathMakeUnix(Util.PathGetRelative(solutionFileInfo.DirectoryName, projectFileInfo.DirectoryName)))) + using (fileGenerator.Declare("projectFileDirectory", PathMakeUnix(Util.PathGetRelative(solutionFileInfo.DirectoryName, projectFileInfo.DirectoryName), false))) using (fileGenerator.Declare("projectFileName", projectFileInfo.Name)) { fileGenerator.Write(Template.Solution.ProjectRuleBegin); @@ -169,7 +169,7 @@ private string GenerateSolution( foreach (Solution.ResolvedProject resolvedProject in solutionProjects) { FileInfo projectFileInfo = new FileInfo(resolvedProject.ProjectFile); - using (fileGenerator.Declare("projectFileDirectory", PathMakeUnix(Util.PathGetRelative(solutionFileInfo.DirectoryName, projectFileInfo.DirectoryName)))) + using (fileGenerator.Declare("projectFileDirectory", PathMakeUnix(Util.PathGetRelative(solutionFileInfo.DirectoryName, projectFileInfo.DirectoryName), false))) using (fileGenerator.Declare("projectFileName", projectFileInfo.Name)) { fileGenerator.Write(Template.Solution.CleanRuleProject); @@ -280,8 +280,30 @@ private string GenerateProject( // Configurations variables. foreach (Project.Configuration conf in configurations) { + string precompHeader = ""; + string precompHeaderOut = ""; + string precompIntermediate = ""; + string precompCommand = ""; + + if (!string.IsNullOrEmpty(conf.PrecompHeader)) + { + // Support pch files in sub folders + var pchFile = PathMakeUnix(conf.PrecompHeader); + // Don't make additional subfolder in temp directory + var pchObj = Path.GetFileName(conf.PrecompHeader); + var fileName = Path.Combine(PathMakeUnix(project.SourceRootPath), pchFile); + precompHeader = PathMakeUnix(Util.PathGetRelative(projectFileInfo.DirectoryName, fileName, true)); + precompHeaderOut = $"$(OBJDIR)/{pchObj}"; + precompIntermediate = $"$(OBJDIR)/{pchObj}.gch"; + precompCommand = "-include $(PCHOUT)"; + } + using (fileGenerator.Declare("name", conf.Name.ToLower())) using (fileGenerator.Declare("options", options[conf])) + using (fileGenerator.Declare("precompHeader", precompHeader)) + using (fileGenerator.Declare("precompHeaderOut", precompHeaderOut)) + using (fileGenerator.Declare("precompIntermediate", precompIntermediate)) + using (fileGenerator.Declare("precompCommand", precompCommand)) { fileGenerator.Write(Template.Project.ProjectConfigurationVariables); } @@ -413,8 +435,12 @@ private Options.ExplicitOptions GenerateOptions(Project.Configuration conf, File else // Release defines.Add("NDEBUG"); - defines.AddRange(conf.Defines); - defines.InsertPrefix("-D"); + foreach (string define in conf.Defines) + { + if (!string.IsNullOrWhiteSpace(define)) + defines.Add(define.Replace(@"""", @"\""")); + } + defines.InsertPrefixSuffix(@"-D """, @""""); options["Defines"] = defines.JoinStrings(" "); // Includes @@ -424,6 +450,7 @@ private Options.ExplicitOptions GenerateOptions(Project.Configuration conf, File includePaths.AddRange(Util.PathGetRelative(projectFileInfo.DirectoryName, Util.PathGetCapitalized(conf.DependenciesIncludePaths))); PathMakeUnix(includePaths); includePaths.InsertPrefix("-I"); + includePaths.Sort(); options["Includes"] = includePaths.JoinStrings(" "); if (conf.ForcedIncludes.Count > 0) @@ -431,6 +458,7 @@ private Options.ExplicitOptions GenerateOptions(Project.Configuration conf, File OrderableStrings relativeForceIncludes = new OrderableStrings(Util.PathGetRelative(projectFileInfo.DirectoryName, conf.ForcedIncludes)); PathMakeUnix(relativeForceIncludes); relativeForceIncludes.InsertPrefix("-include "); + relativeForceIncludes.Sort(); options["Includes"] += " " + relativeForceIncludes.JoinStrings(" "); } @@ -441,18 +469,18 @@ private Options.ExplicitOptions GenerateOptions(Project.Configuration conf, File // ExtraWarnings SelectOption(conf, Options.Option(Options.Makefile.Compiler.ExtraWarnings.Enable, () => { cflags.Append("-Wextra "); }), - Options.Option(Options.Makefile.Compiler.ExtraWarnings.Disable, () => { cflags.Append(""); }) + Options.Option(Options.Makefile.Compiler.ExtraWarnings.Disable, () => { }) ); // GenerateDebugInformation SelectOption(conf, Options.Option(Options.Makefile.Compiler.GenerateDebugInformation.Enable, () => { cflags.Append("-g "); }), - Options.Option(Options.Makefile.Compiler.GenerateDebugInformation.Disable, () => { cflags.Append(""); }) + Options.Option(Options.Makefile.Compiler.GenerateDebugInformation.Disable, () => { }) ); // OptimizationLevel SelectOption(conf, - Options.Option(Options.Makefile.Compiler.OptimizationLevel.Disable, () => { cflags.Append(""); }), + Options.Option(Options.Makefile.Compiler.OptimizationLevel.Disable, () => { }), Options.Option(Options.Makefile.Compiler.OptimizationLevel.Standard, () => { cflags.Append("-O1 "); }), Options.Option(Options.Makefile.Compiler.OptimizationLevel.Full, () => { cflags.Append("-O2 "); }), Options.Option(Options.Makefile.Compiler.OptimizationLevel.FullWithInlining, () => { cflags.Append("-O3 "); }), @@ -461,7 +489,7 @@ private Options.ExplicitOptions GenerateOptions(Project.Configuration conf, File // Warnings SelectOption(conf, - Options.Option(Options.Makefile.Compiler.Warnings.NormalWarnings, () => { cflags.Append(""); }), + Options.Option(Options.Makefile.Compiler.Warnings.NormalWarnings, () => { }), Options.Option(Options.Makefile.Compiler.Warnings.MoreWarnings, () => { cflags.Append("-Wall "); }), Options.Option(Options.Makefile.Compiler.Warnings.Disable, () => { cflags.Append("-w "); }) ); @@ -469,7 +497,7 @@ private Options.ExplicitOptions GenerateOptions(Project.Configuration conf, File // WarningsAsErrors SelectOption(conf, Options.Option(Options.Makefile.Compiler.TreatWarningsAsErrors.Enable, () => { cflags.Append("-Werror "); }), - Options.Option(Options.Makefile.Compiler.TreatWarningsAsErrors.Disable, () => { cflags.Append(""); }) + Options.Option(Options.Makefile.Compiler.TreatWarningsAsErrors.Disable, () => { }) ); // AdditionalCompilerOptions @@ -484,13 +512,17 @@ private Options.ExplicitOptions GenerateOptions(Project.Configuration conf, File // CppLanguageStandard SelectOption(conf, - Options.Option(Options.Makefile.Compiler.CppLanguageStandard.Cpp17, () => { cxxflags.Append("-std=c++17 "); }), - Options.Option(Options.Makefile.Compiler.CppLanguageStandard.Cpp14, () => { cxxflags.Append("-std=c++14 "); }), - Options.Option(Options.Makefile.Compiler.CppLanguageStandard.Cpp11, () => { cxxflags.Append("-std=c++11 "); }), + Options.Option(Options.Makefile.Compiler.CppLanguageStandard.Default, () => { cxxflags.Append(""); }), Options.Option(Options.Makefile.Compiler.CppLanguageStandard.Cpp98, () => { cxxflags.Append("-std=c++98 "); }), - Options.Option(Options.Makefile.Compiler.CppLanguageStandard.GnuCpp11, () => { cxxflags.Append("-std=gnu++11 "); }), + Options.Option(Options.Makefile.Compiler.CppLanguageStandard.Cpp11, () => { cxxflags.Append("-std=c++11 "); }), + Options.Option(Options.Makefile.Compiler.CppLanguageStandard.Cpp14, () => { cxxflags.Append("-std=c++14 "); }), + Options.Option(Options.Makefile.Compiler.CppLanguageStandard.Cpp17, () => { cxxflags.Append("-std=c++17 "); }), + Options.Option(Options.Makefile.Compiler.CppLanguageStandard.Cpp2a, () => { cxxflags.Append("-std=c++2a "); }), Options.Option(Options.Makefile.Compiler.CppLanguageStandard.GnuCpp98, () => { cxxflags.Append("-std=gnu++98 "); }), - Options.Option(Options.Makefile.Compiler.CppLanguageStandard.Default, () => { cxxflags.Append(""); }) + Options.Option(Options.Makefile.Compiler.CppLanguageStandard.GnuCpp11, () => { cxxflags.Append("-std=gnu++11 "); }), + Options.Option(Options.Makefile.Compiler.CppLanguageStandard.GnuCpp14, () => { cxxflags.Append("-std=gnu++14 "); }), + Options.Option(Options.Makefile.Compiler.CppLanguageStandard.GnuCpp17, () => { cxxflags.Append("-std=gnu++17 "); }), + Options.Option(Options.Makefile.Compiler.CppLanguageStandard.GnuCpp2a, () => { cxxflags.Append("-std=gnu++2a "); }) ); // Exceptions @@ -513,17 +545,19 @@ private Options.ExplicitOptions GenerateOptions(Project.Configuration conf, File #region Linker // OutputFile - options["OutputFile"] = FormatOutputFileName(conf); + options["OutputFile"] = FormatOutputFileName(conf).Replace(" ", @"\ "); // DependenciesLibraryFiles OrderableStrings dependenciesLibraryFiles = new OrderableStrings(conf.DependenciesLibraryFiles); PathMakeUnix(dependenciesLibraryFiles); dependenciesLibraryFiles.InsertPrefix("-l"); + dependenciesLibraryFiles.Sort(); options["DependenciesLibraryFiles"] = dependenciesLibraryFiles.JoinStrings(" "); // LibraryFiles OrderableStrings libraryFiles = new OrderableStrings(conf.LibraryFiles); libraryFiles.InsertPrefix("-l"); + libraryFiles.Sort(); options["LibraryFiles"] = libraryFiles.JoinStrings(" "); // LibraryPaths @@ -533,6 +567,7 @@ private Options.ExplicitOptions GenerateOptions(Project.Configuration conf, File libraryPaths.AddRange(Util.PathGetRelative(projectFileInfo.DirectoryName, conf.DependenciesBuiltTargetsLibraryPaths)); PathMakeUnix(libraryPaths); libraryPaths.InsertPrefix("-L"); + libraryPaths.Sort(); options["LibraryPaths"] = libraryPaths.JoinStrings(" "); // Dependencies @@ -543,10 +578,10 @@ private Options.ExplicitOptions GenerateOptions(Project.Configuration conf, File { case Project.Configuration.OutputType.None: continue; case Project.Configuration.OutputType.Lib: - case Project.Configuration.OutputType.Dll: case Project.Configuration.OutputType.DotNetClassLibrary: deps.Add(Path.Combine(depConf.TargetLibraryPath, FormatOutputFileName(depConf)), depConf.TargetFileOrderNumber); break; + case Project.Configuration.OutputType.Dll: default: deps.Add(Path.Combine(depConf.TargetPath, FormatOutputFileName(depConf)), depConf.TargetFileOrderNumber); break; @@ -554,6 +589,7 @@ private Options.ExplicitOptions GenerateOptions(Project.Configuration conf, File } var depsRelative = Util.PathGetRelative(projectFileInfo.DirectoryName, deps); PathMakeUnix(depsRelative); + depsRelative.Sort(); options["LDDEPS"] = depsRelative.JoinStrings(" "); // LinkCommand @@ -561,6 +597,10 @@ private Options.ExplicitOptions GenerateOptions(Project.Configuration conf, File { options["LinkCommand"] = Template.Project.LinkCommandLib; } + else if (conf.Output == Project.Configuration.OutputType.Dll) + { + options["LinkCommand"] = Template.Project.LinkCommandDll; + } else { options["LinkCommand"] = Template.Project.LinkCommandExe; @@ -652,9 +692,13 @@ private static string FormatOutputFileName(Project.Configuration conf) #region Utils - private static string PathMakeUnix(string path) + private static string PathMakeUnix(string path, bool escapeSpaces = true) { - return path.Replace(Util.WindowsSeparator, Util.UnixSeparator).TrimEnd(Util.UnixSeparator); + string clean = path.Replace(Util.WindowsSeparator, Util.UnixSeparator).TrimEnd(Util.UnixSeparator); + if (escapeSpaces) + return clean.Replace(" ", @"\ "); + + return clean; } private static void PathMakeUnix(IList paths) diff --git a/Sharpmake.Generators/IGenerationContext.cs b/Sharpmake.Generators/IGenerationContext.cs index 74572a476..95b0cd61a 100644 --- a/Sharpmake.Generators/IGenerationContext.cs +++ b/Sharpmake.Generators/IGenerationContext.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017, 2019-2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.Generators/Properties/AssemblyInfo.cs b/Sharpmake.Generators/Properties/AssemblyInfo.cs index dcf5644fa..7ec5f3346 100644 --- a/Sharpmake.Generators/Properties/AssemblyInfo.cs +++ b/Sharpmake.Generators/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017, 2019-2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -44,6 +44,6 @@ // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("0.14.6.0")] +[assembly: AssemblyVersion("0.15.0.0")] [assembly: InternalsVisibleTo("Sharpmake")] diff --git a/Sharpmake.Generators/Sharpmake.Generators.csproj b/Sharpmake.Generators/Sharpmake.Generators.csproj index 150ca9da4..6da8078e1 100644 --- a/Sharpmake.Generators/Sharpmake.Generators.csproj +++ b/Sharpmake.Generators/Sharpmake.Generators.csproj @@ -1,51 +1,56 @@ - - + Debug AnyCPU AnyCPU - {844F66DE-B015-340E-720A-8E158B517E93} Library Properties Sharpmake.Generators Sharpmake.Generators - v4.6.1 + net472 512 + false + false + + + false + false AnyCPU true full false - ..\bin\debug + ..\tmp\bin\debug ..\tmp\obj\debug\sharpmake.generators ..\tmp\obj\debug\sharpmake.generators - ..\bin\debug\sharpmake.generators.xml + ..\tmp\bin\debug\sharpmake.generators.xml DEBUG;TRACE 4 true 618 false 1570,1591 - 6 + 7 AnyCPU false pdbonly true - ..\bin\release + ..\tmp\bin\release ..\tmp\obj\release\sharpmake.generators ..\tmp\obj\release\sharpmake.generators - ..\bin\release\sharpmake.generators.xml + ..\tmp\bin\release\sharpmake.generators.xml TRACE 4 true 618 false 1570,1591 - 6 + 7 + False @@ -114,5 +119,5 @@ Sharpmake - + \ No newline at end of file diff --git a/Sharpmake.Generators/Sharpmake.Generators.sharpmake.cs b/Sharpmake.Generators/Sharpmake.Generators.sharpmake.cs index 84eedcac7..0c834be75 100644 --- a/Sharpmake.Generators/Sharpmake.Generators.sharpmake.cs +++ b/Sharpmake.Generators/Sharpmake.Generators.sharpmake.cs @@ -17,6 +17,8 @@ public SharpmakeGeneratorsProject() public override void ConfigureAll(Configuration conf, Target target) { base.ConfigureAll(conf, target); + conf.ProjectPath = @"[project.SourceRootPath]"; + conf.ReferencesByName.Add( "System.Xml", "System.Xml.Linq" diff --git a/Sharpmake.Generators/VisualStudio/Androidproj.Template.cs b/Sharpmake.Generators/VisualStudio/Androidproj.Template.cs index 08f7ba4c5..8480cde56 100644 --- a/Sharpmake.Generators/VisualStudio/Androidproj.Template.cs +++ b/Sharpmake.Generators/VisualStudio/Androidproj.Template.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2018-2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.Generators/VisualStudio/Androidproj.cs b/Sharpmake.Generators/VisualStudio/Androidproj.cs index e04e89b98..ce181636e 100644 --- a/Sharpmake.Generators/VisualStudio/Androidproj.cs +++ b/Sharpmake.Generators/VisualStudio/Androidproj.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2018-2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.Generators/VisualStudio/Csproj.Template.cs b/Sharpmake.Generators/VisualStudio/Csproj.Template.cs index 253564d79..a75d464b2 100644 --- a/Sharpmake.Generators/VisualStudio/Csproj.Template.cs +++ b/Sharpmake.Generators/VisualStudio/Csproj.Template.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2021 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -29,7 +29,7 @@ public static class Project "; public static string ProjectBeginNetCore = -@" +@" "; public static string ProjectEnd = @@ -154,6 +154,10 @@ public static class Project "; public static string ImportProjectItem = @" +"; + + public static string ImportProjectSdkItem = +@" "; public static string VsixConfiguration = @@ -504,6 +508,14 @@ public static class ItemGroups public static string CompileBegin = @" +"; + + public static string SimpleCompileWithExclude = +@" +"; + + public static string CompileBeginWithExclude = +@" "; public static string CompileEnd = diff --git a/Sharpmake.Generators/VisualStudio/Csproj.cs b/Sharpmake.Generators/VisualStudio/Csproj.cs index 1c7d8865c..32547f05e 100644 --- a/Sharpmake.Generators/VisualStudio/Csproj.cs +++ b/Sharpmake.Generators/VisualStudio/Csproj.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2021 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -141,7 +141,7 @@ public string Resolve(Resolver resolver) var writer = new StringWriter(); var resolvedAlwaysTrueCondition = AlwaysTrueElement?.ResolveCondition(resolver); - foreach (var conditionalItemGroup in conditionalItemGroups.OrderBy(k => k.Key, StringComparer.InvariantCultureIgnoreCase)) + foreach (var conditionalItemGroup in conditionalItemGroups.OrderBy(k => k.Key, StringComparer.OrdinalIgnoreCase)) { // No element for this ItemGroup, skip if (!conditionalItemGroup.Value.Any()) @@ -157,7 +157,7 @@ public string Resolve(Resolver resolver) writer.Write(resolver.Resolve(Template.ItemGroups.ItemGroupConditionalBegin)); } - foreach (var elem in conditionalItemGroup.Value.OrderBy(v => v, StringComparer.InvariantCultureIgnoreCase)) + foreach (var elem in conditionalItemGroup.Value.OrderBy(v => v, StringComparer.OrdinalIgnoreCase)) writer.Write(elem); writer.Write(Template.ItemGroups.ItemGroupEnd); @@ -168,11 +168,26 @@ public string Resolve(Resolver resolver) internal class TargetFrameworksCondition : UniqueList, IResolvableCondition where T : IResolvable { - public List TargetFrameworks; + public List> TargetFrameworks; public string ResolveCondition(Resolver resolver) { - using (resolver.NewScopedParameter("targetFramework", string.Join(";", TargetFrameworks.Select(conf => conf.ToFolderName())))) + var targetFrameworks = TargetFrameworks.Select(tuple => + { + var dotNetFramework = tuple.Item1; + var dotNetOS = tuple.Item2; + var dotNetOSVersion = tuple.Item3; + + if (dotNetOS == DotNetOS.Default) + { + if (!string.IsNullOrEmpty(dotNetOSVersion)) + throw new Error(); + return dotNetFramework.ToFolderName(); + } + + return dotNetFramework.ToFolderName() + "-" + dotNetOS.ToString() + dotNetOSVersion; + }); + using (resolver.NewScopedParameter("targetFramework", string.Join(";", targetFrameworks))) { return resolver.Resolve(Template.ItemGroups.ItemGroupTargetFrameworkCondition); } @@ -559,10 +574,12 @@ internal class Compile : ItemGroupItem, IResolvable public bool? DesignTimeSharedInput = null; public string DependentUpon; public string SubType = null; + public string Exclude; public string Resolve(Resolver resolver) { using (resolver.NewScopedParameter("include", Include)) + using (resolver.NewScopedParameter("exclude", Exclude ?? string.Empty)) using (resolver.NewScopedParameter("autoGen", AutoGen)) using (resolver.NewScopedParameter("designTime", DesignTime)) using (resolver.NewScopedParameter("designTimeSharedInput", DesignTimeSharedInput)) @@ -586,9 +603,9 @@ public string Resolve(Resolver resolver) AddLinkIfNeeded(writer); if (builder.Length == 0) - return resolver.Resolve(Template.ItemGroups.SimpleCompile); + return resolver.Resolve(string.IsNullOrEmpty(Exclude) ? Template.ItemGroups.SimpleCompile : Template.ItemGroups.SimpleCompileWithExclude); - builder.Insert(0, Template.ItemGroups.CompileBegin); + builder.Insert(0, string.IsNullOrEmpty(Exclude) ? Template.ItemGroups.CompileBegin : Template.ItemGroups.CompileBeginWithExclude); writer.Write(Template.ItemGroups.CompileEnd); return resolver.Resolve(writer.ToString()); } @@ -898,23 +915,25 @@ private static void AddTargetFrameworksCondition(ItemGroupConditional it.Contains(elem))) { - foreach (var itemGroup in itemGroupConditional.Where(it => it.Contains(elem) && !it.TargetFrameworks.Contains(dotNetFramework))) + foreach (var itemGroup in itemGroupConditional.Where(it => it.Contains(elem))) { - itemGroup.TargetFrameworks.Add(dotNetFramework); + var tuple = Tuple.Create(dotNetFramework, DotNetOS.Default, string.Empty); + if (!itemGroup.TargetFrameworks.Contains(tuple)) + itemGroup.TargetFrameworks.Add(tuple); } } else { var newItemGroup = new TargetFrameworksCondition { - TargetFrameworks = new List { dotNetFramework }, + TargetFrameworks = new List> { Tuple.Create(dotNetFramework, DotNetOS.Default, string.Empty) }, }; newItemGroup.Add(elem); itemGroupConditional.Add(newItemGroup); } } - public void SetTargetFrameworks(List projectFrameworks) + public void SetTargetFrameworks(List> projectFrameworks) { References.AlwaysTrueElement = new TargetFrameworksCondition { @@ -1034,8 +1053,16 @@ List skipFiles // Need to sort by name and platform List configurations = unsortedConfigurations.OrderBy(conf => conf.Name + conf.Platform).ToList(); - List projectFrameworks = configurations.Select( - conf => conf.Target.GetFragment()).Distinct().ToList(); + var projectFrameworks = configurations.Select( + conf => + { + var dotNetFramework = conf.Target.GetFragment(); + DotNetOS dotNetOS; + if (!conf.Target.TryGetFragment(out dotNetOS)) + dotNetOS = DotNetOS.Default; + return Tuple.Create(dotNetFramework, dotNetOS, conf.DotNetOSVersionSuffix); + } + ).Distinct().ToList(); itemGroups.SetTargetFrameworks(projectFrameworks); // valid that 2 conf name in the same project don't have the same name @@ -1115,25 +1142,21 @@ List skipFiles bool isNetCoreProjectSchema = project.ProjectSchema == CSharpProjectSchema.NetCore || (project.ProjectSchema == CSharpProjectSchema.Default && - (projectFrameworks.Any(x => x.IsDotNetCore() || x.IsDotNetStandard()) || projectFrameworks.Count > 1) + (projectFrameworks.Any(x => x.Item1.IsDotNetCore() || x.Item1.IsDotNetStandard()) || projectFrameworks.Count > 1) ); + if (isNetCoreProjectSchema) { - targetFrameworkString = String.Join(";", projectFrameworks.Select(conf => conf.ToFolderName())); + Write(Template.Project.ProjectBeginNetCore, writer, resolver); - string netCoreSdk = "Microsoft.NET.Sdk"; - if (project.NetCoreSdkType != NetCoreSdkTypes.Default) - netCoreSdk += "." + project.NetCoreSdkType.ToString(); - - using (resolver.NewScopedParameter("sdkVersion", netCoreSdk)) - { - Write(Template.Project.ProjectBeginNetCore, writer, resolver); - } + targetFrameworkString = String.Join(";", projectFrameworks.Select(tuple => tuple.Item1.ToFolderName())); } else { - targetFrameworkString = Util.GetDotNetTargetString(projectFrameworks.Single()); - using (resolver.NewScopedParameter("toolsVersion", Util.GetToolVersionString(devenv, projectFrameworks.Single()))) + var framework = projectFrameworks.Single().Item1; + targetFrameworkString = Util.GetDotNetTargetString(framework); + + using (resolver.NewScopedParameter("toolsVersion", Util.GetToolVersionString(devenv, framework))) { // xml begin header switch (devenv) @@ -1392,6 +1415,18 @@ List skipFiles Write(Template.Project.ProjectConfigurationsRunPostBuildEvent, writer, resolver); } + string netCoreSdk = null; + if (isNetCoreProjectSchema) + { + netCoreSdk = "Microsoft.NET.Sdk"; + if (project.NetCoreSdkType != NetCoreSdkTypes.Default) + netCoreSdk += "." + project.NetCoreSdkType.ToString(); + + using (resolver.NewScopedParameter("importProject", "Sdk.props")) + using (resolver.NewScopedParameter("sdkVersion", netCoreSdk)) + Write(Template.Project.ImportProjectSdkItem, writer, resolver); + } + GenerateFiles(project, configurations, itemGroups, generatedFiles, skipFiles); #region section @@ -1426,7 +1461,8 @@ List skipFiles } #endregion - writer.Write(itemGroups.Resolve(resolver)); + using (resolver.NewScopedParameter("project", project)) + writer.Write(itemGroups.Resolve(resolver)); var importProjects = new List(project.ImportProjects); @@ -1496,6 +1532,14 @@ List skipFiles } WriteEvents(options, writer, resolver); + + if (isNetCoreProjectSchema) + { + using (resolver.NewScopedParameter("importProject", "Sdk.targets")) + using (resolver.NewScopedParameter("sdkVersion", netCoreSdk)) + Write(Template.Project.ImportProjectSdkItem, writer, resolver); + } + Write(Template.Project.ProjectEnd, writer, resolver); // Write the project file @@ -1627,6 +1671,11 @@ List skipFiles } #endregion + foreach (var glob in project.Globs) + { + itemGroups.Compiles.Add(new ItemGroups.Compile { Include = glob.Include, Exclude = glob.Exclude }); + } + foreach (var embeddedResource in project.AdditionalEmbeddedResourceAlwaysCopy) { string file = Util.PathGetRelative(_projectPathCapitalized, Project.GetCapitalizedFile(embeddedResource)); @@ -1716,14 +1765,14 @@ List skipFiles { Include = linkedCsFile, DependentUpon = Path.GetFileName(xaml), - LinkFolder = GetProjectLinkedFolder(linkedCsFile, _projectPathCapitalized, project.SourceRootPath) + LinkFolder = GetProjectLinkedFolder(linkedCsFile, _projectPathCapitalized, project) }); itemGroups.Pages.Add(new ItemGroups.Page { Include = xaml, - IsApplicationDefinition = project.ApplicationDefinitionFilenames.Any(f => f.Equals(Path.GetFileName(xaml), StringComparison.InvariantCultureIgnoreCase)), - LinkFolder = GetProjectLinkedFolder(xaml, _projectPathCapitalized, project.SourceRootPath) + IsApplicationDefinition = project.ApplicationDefinitionFilenames.Any(f => f.Equals(Path.GetFileName(xaml), StringComparison.OrdinalIgnoreCase)), + LinkFolder = GetProjectLinkedFolder(xaml, _projectPathCapitalized, project) }); remainingSourcesFiles.Remove(xaml); remainingSourcesFiles.Remove(linkedCsFile); @@ -1737,7 +1786,7 @@ List skipFiles { Include = designerFile, DependentUpon = Path.GetFileName(csFile), - LinkFolder = GetProjectLinkedFolder(designerFile, _projectPathCapitalized, project.SourceRootPath) + LinkFolder = GetProjectLinkedFolder(designerFile, _projectPathCapitalized, project) }); remainingSourcesFiles.Remove(designerFile); string resXFile = fileAssociation.GetFilenameWithExtension(".resx"); @@ -1747,7 +1796,7 @@ List skipFiles { Include = resXFile, DependUpon = Path.GetFileName(csFile), - LinkFolder = GetProjectLinkedFolder(resXFile, _projectPathCapitalized, project.SourceRootPath) + LinkFolder = GetProjectLinkedFolder(resXFile, _projectPathCapitalized, project) }); remainingEmbeddedResourcesFiles.Remove(resXFile); remainingResourcesFiles.Remove(resXFile); @@ -1764,21 +1813,21 @@ List skipFiles Include = mainAddinCode, SubType = "Code", LinkFolder = - GetProjectLinkedFolder(mainAddinCode, _projectPathCapitalized, project.SourceRootPath) + GetProjectLinkedFolder(mainAddinCode, _projectPathCapitalized, project) }); itemGroups.Compiles.Add(new ItemGroups.Compile { Include = designerCode, DependentUpon = designerXml, LinkFolder = - GetProjectLinkedFolder(mainAddinCode, _projectPathCapitalized, project.SourceRootPath) + GetProjectLinkedFolder(mainAddinCode, _projectPathCapitalized, project) }); itemGroups.Nones.Add(new ItemGroups.None { Include = designerXml, DependentUpon = mainAddinCode, LinkFolder = - GetProjectLinkedFolder(mainAddinCode, _projectPathCapitalized, project.SourceRootPath) + GetProjectLinkedFolder(mainAddinCode, _projectPathCapitalized, project) }); remainingSourcesFiles.Remove(mainAddinCode); remainingSourcesFiles.Remove(designerCode); @@ -1792,14 +1841,14 @@ List skipFiles itemGroups.Compiles.Add(new ItemGroups.Compile { Include = csFile, - LinkFolder = GetProjectLinkedFolder(csFile, _projectPathCapitalized, project.SourceRootPath) + LinkFolder = GetProjectLinkedFolder(csFile, _projectPathCapitalized, project) }); itemGroups.EmbeddedResources.Add(new ItemGroups.EmbeddedResource { Include = xmlFile, SubType = "Designer", Generator = RemoveLineTag, - LinkFolder = GetProjectLinkedFolder(csFile, _projectPathCapitalized, project.SourceRootPath) + LinkFolder = GetProjectLinkedFolder(csFile, _projectPathCapitalized, project) }); remainingEmbeddedResourcesFiles.Remove(xmlFile); remainingNoneFiles.Remove(xmlFile); @@ -1813,7 +1862,7 @@ List skipFiles { Include = resXFile, DependUpon = Path.GetFileName(csFile), - LinkFolder = GetProjectLinkedFolder(resXFile, _projectPathCapitalized, project.SourceRootPath) + LinkFolder = GetProjectLinkedFolder(resXFile, _projectPathCapitalized, project) }); remainingEmbeddedResourcesFiles.Remove(resXFile); remainingResourcesFiles.Remove(resXFile); @@ -1823,12 +1872,12 @@ List skipFiles { string designerFile = fileAssociation.GetFilenameWithExtension(".designer.cs"); string resXFile = fileAssociation.GetFilenameWithExtension(".resx"); - bool publicAccessModifiers = publicResources.Any(f => f.Equals(resXFile, StringComparison.InvariantCultureIgnoreCase)); + bool publicAccessModifiers = publicResources.Any(f => f.Equals(resXFile, StringComparison.OrdinalIgnoreCase)); itemGroups.Compiles.Add(new ItemGroups.Compile { Include = designerFile, DependentUpon = Path.GetFileName(resXFile), - LinkFolder = GetProjectLinkedFolder(designerFile, _projectPathCapitalized, project.SourceRootPath), + LinkFolder = GetProjectLinkedFolder(designerFile, _projectPathCapitalized, project), AutoGen = true, DesignTime = publicAccessModifiers ? (bool?)true : null }); @@ -1836,9 +1885,9 @@ List skipFiles { Include = resXFile, Generator = publicAccessModifiers ? "PublicResXFileCodeGenerator" : "ResXFileCodeGenerator", - MergeWithCto = resXFile.EndsWith("VSPackage.resx", StringComparison.InvariantCultureIgnoreCase) ? "true" : null, + MergeWithCto = resXFile.EndsWith("VSPackage.resx", StringComparison.OrdinalIgnoreCase) ? "true" : null, LastGenOutput = Path.GetFileName(designerFile), - LinkFolder = GetProjectLinkedFolder(resXFile, _projectPathCapitalized, project.SourceRootPath), + LinkFolder = GetProjectLinkedFolder(resXFile, _projectPathCapitalized, project), SubType = "Designer" }); remainingSourcesFiles.Remove(designerFile); @@ -1985,7 +2034,7 @@ List skipFiles { Include = linkedCsFile, DependentUpon = Path.GetFileName(asax), - LinkFolder = GetProjectLinkedFolder(linkedCsFile, _projectPathCapitalized, project.SourceRootPath) + LinkFolder = GetProjectLinkedFolder(linkedCsFile, _projectPathCapitalized, project) }); itemGroups.Contents.Add(new ItemGroups.Content @@ -2128,8 +2177,8 @@ List skipFiles itemGroups.Pages.Add(new ItemGroups.Page { Include = xaml, - IsApplicationDefinition = project.ApplicationDefinitionFilenames.Any(f => f.Equals(xaml, StringComparison.InvariantCultureIgnoreCase)), - LinkFolder = GetProjectLinkedFolder(xaml, _projectPathCapitalized, project.SourceRootPath) + IsApplicationDefinition = project.ApplicationDefinitionFilenames.Any(f => f.Equals(xaml, StringComparison.OrdinalIgnoreCase)), + LinkFolder = GetProjectLinkedFolder(xaml, _projectPathCapitalized, project) }); remainingSourcesFiles.Remove(xaml); } @@ -2150,7 +2199,7 @@ List skipFiles { Include = remainingSourcesFile, SubType = csProjSubTypesInfos?.SubTypeInfos.Find(s => string.Equals(s.FileName, remainingSourcesFile))?.SubType, - LinkFolder = GetProjectLinkedFolder(remainingSourcesFile, _projectPathCapitalized, project.SourceRootPath) + LinkFolder = GetProjectLinkedFolder(remainingSourcesFile, _projectPathCapitalized, project) }); } @@ -2163,7 +2212,7 @@ List skipFiles itemGroups.Resources.Add(new ItemGroups.Resource { Include = file, - LinkFolder = GetProjectLinkedFolder(file, _projectPathCapitalized, project.SourceRootPath) + LinkFolder = GetProjectLinkedFolder(file, _projectPathCapitalized, project) }); } } @@ -2173,7 +2222,7 @@ List skipFiles itemGroups.EmbeddedResources.Add(new ItemGroups.EmbeddedResource { Include = file, - MergeWithCto = file.Equals("VSPackage.resx", StringComparison.InvariantCultureIgnoreCase) ? "true" : null, + MergeWithCto = file.Equals("VSPackage.resx", StringComparison.OrdinalIgnoreCase) ? "true" : null, LinkFolder = project.GetLinkFolder(file) }); } @@ -2455,14 +2504,14 @@ private static void AddNoneGeneratedItem(ItemGroups itemGroups, string file, str Include = file, Generator = generator, LastGenOutput = Path.GetFileName(generatedFile), - LinkFolder = GetProjectLinkedFolder(file, projectPath, project.SourceRootPath) + LinkFolder = GetProjectLinkedFolder(file, projectPath, project) }); var compile = new ItemGroups.Compile { Include = generatedFile, AutoGen = true, DependentUpon = Path.GetFileName(file), - LinkFolder = GetProjectLinkedFolder(generatedFile, projectPath, project.SourceRootPath) + LinkFolder = GetProjectLinkedFolder(generatedFile, projectPath, project) }; if (designTimeSharedInput) compile.DesignTimeSharedInput = true; @@ -2493,7 +2542,7 @@ private static void AddContentGeneratedItem( Include = templateFile, Generator = generator, LastGenOutput = Path.GetFileName(generatedFile), - LinkFolder = GetProjectLinkedFolder(templateFile, projectPath, project.SourceRootPath) + LinkFolder = GetProjectLinkedFolder(templateFile, projectPath, project) }); if (!addGeneratedFile) @@ -2511,7 +2560,7 @@ private static void AddContentGeneratedItem( Include = generatedFile, AutoGen = true, DependentUpon = Path.GetFileName(templateFile), - LinkFolder = GetProjectLinkedFolder(generatedFile, projectPath, project.SourceRootPath) + LinkFolder = GetProjectLinkedFolder(generatedFile, projectPath, project) }; if (designTimeSharedInput) compile.DesignTimeSharedInput = true; @@ -2527,7 +2576,7 @@ private static void AddContentGeneratedItem( Include = generatedFile, AutoGen = true, DependentUpon = Path.GetFileName(templateFile), - LinkFolder = GetProjectLinkedFolder(generatedFile, projectPath, project.SourceRootPath), + LinkFolder = GetProjectLinkedFolder(generatedFile, projectPath, project), }); break; } @@ -2639,7 +2688,7 @@ private static FileAssociationType GetFileAssociationType(IEnumerable fi return FileAssociationType.Unknown; } - private static string GetProjectLinkedFolder(string sourceFile, string projectPath, string sourceRootPath) + private static string GetProjectLinkedFolder(string sourceFile, string projectPath, Project project) { // Exit out early if the file is not a relative path. if (!sourceFile.StartsWith("..", StringComparison.Ordinal)) @@ -2648,8 +2697,11 @@ private static string GetProjectLinkedFolder(string sourceFile, string projectPa string absoluteFile = Util.PathGetAbsolute(projectPath, sourceFile); var directoryName = Path.GetDirectoryName(absoluteFile); - if (directoryName.StartsWith(sourceRootPath, StringComparison.OrdinalIgnoreCase)) - return directoryName.Substring(sourceRootPath.Length).Trim(Util._pathSeparators); + if (directoryName.StartsWith(project.SourceRootPath, StringComparison.OrdinalIgnoreCase)) + return directoryName.Substring(project.SourceRootPath.Length).Trim(Util._pathSeparators); + + if (directoryName.StartsWith(project.RootPath)) + return directoryName.Substring(project.RootPath.Length).Trim(Util._pathSeparators); return Path.GetFileName(directoryName); } @@ -3141,10 +3193,12 @@ private Options.ExplicitOptions GenerateOptions(CSharpProject project, Project.C Options.Option(Options.CSharp.WarningLevel.Level4, () => { options["WarningLevel"] = "4"; }) ); + // https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/configure-language-version#c-language-version-reference SelectOption ( Options.Option(Options.CSharp.LanguageVersion.LatestMajorVersion, () => { options["LanguageVersion"] = RemoveLineTag; }), Options.Option(Options.CSharp.LanguageVersion.LatestMinorVersion, () => { options["LanguageVersion"] = "latest"; }), + Options.Option(Options.CSharp.LanguageVersion.Preview, () => { options["LanguageVersion"] = "preview"; }), Options.Option(Options.CSharp.LanguageVersion.ISO1, () => { options["LanguageVersion"] = "ISO-1"; }), Options.Option(Options.CSharp.LanguageVersion.ISO2, () => { options["LanguageVersion"] = "ISO-2"; }), Options.Option(Options.CSharp.LanguageVersion.CSharp3, () => { options["LanguageVersion"] = "3"; }), @@ -3152,7 +3206,11 @@ private Options.ExplicitOptions GenerateOptions(CSharpProject project, Project.C Options.Option(Options.CSharp.LanguageVersion.CSharp5, () => { options["LanguageVersion"] = "5"; }), Options.Option(Options.CSharp.LanguageVersion.CSharp6, () => { options["LanguageVersion"] = "6"; }), Options.Option(Options.CSharp.LanguageVersion.CSharp7, () => { options["LanguageVersion"] = "7"; }), - Options.Option(Options.CSharp.LanguageVersion.CSharp7_1, () => { options["LanguageVersion"] = "7.1"; }) + Options.Option(Options.CSharp.LanguageVersion.CSharp7_1, () => { options["LanguageVersion"] = "7.1"; }), + Options.Option(Options.CSharp.LanguageVersion.CSharp7_2, () => { options["LanguageVersion"] = "7.2"; }), + Options.Option(Options.CSharp.LanguageVersion.CSharp7_3, () => { options["LanguageVersion"] = "7.3"; }), + Options.Option(Options.CSharp.LanguageVersion.CSharp8, () => { options["LanguageVersion"] = "8.0"; }), + Options.Option(Options.CSharp.LanguageVersion.CSharp9, () => { options["LanguageVersion"] = "9.0"; }) ); SelectOption( diff --git a/Sharpmake.Generators/VisualStudio/IPlatformVcxproj.cs b/Sharpmake.Generators/VisualStudio/IPlatformVcxproj.cs index 11ba20137..8105ee3df 100644 --- a/Sharpmake.Generators/VisualStudio/IPlatformVcxproj.cs +++ b/Sharpmake.Generators/VisualStudio/IPlatformVcxproj.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.Generators/VisualStudio/IVcxprojGenerationContext.cs b/Sharpmake.Generators/VisualStudio/IVcxprojGenerationContext.cs index 883853d60..83ad49467 100644 --- a/Sharpmake.Generators/VisualStudio/IVcxprojGenerationContext.cs +++ b/Sharpmake.Generators/VisualStudio/IVcxprojGenerationContext.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017, 2019-2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.Generators/VisualStudio/PackagesConfig.Template.cs b/Sharpmake.Generators/VisualStudio/PackagesConfig.Template.cs index 292546f8e..6e6935cb1 100644 --- a/Sharpmake.Generators/VisualStudio/PackagesConfig.Template.cs +++ b/Sharpmake.Generators/VisualStudio/PackagesConfig.Template.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2018 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.Generators/VisualStudio/PackagesConfig.cs b/Sharpmake.Generators/VisualStudio/PackagesConfig.cs index f07e94a8f..681d2a9e1 100644 --- a/Sharpmake.Generators/VisualStudio/PackagesConfig.cs +++ b/Sharpmake.Generators/VisualStudio/PackagesConfig.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2018 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.Generators/VisualStudio/ProjectJson.Template.cs b/Sharpmake.Generators/VisualStudio/ProjectJson.Template.cs index d774b7244..e926a0071 100644 --- a/Sharpmake.Generators/VisualStudio/ProjectJson.Template.cs +++ b/Sharpmake.Generators/VisualStudio/ProjectJson.Template.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2018-2019 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.Generators/VisualStudio/ProjectJson.cs b/Sharpmake.Generators/VisualStudio/ProjectJson.cs index d400f5793..a4a09c67d 100644 --- a/Sharpmake.Generators/VisualStudio/ProjectJson.cs +++ b/Sharpmake.Generators/VisualStudio/ProjectJson.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2018-2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.Generators/VisualStudio/ProjectOptionsGenerator.cs b/Sharpmake.Generators/VisualStudio/ProjectOptionsGenerator.cs index 0d6280e41..b43eb45d8 100644 --- a/Sharpmake.Generators/VisualStudio/ProjectOptionsGenerator.cs +++ b/Sharpmake.Generators/VisualStudio/ProjectOptionsGenerator.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2021 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -13,7 +13,6 @@ // limitations under the License. using System; using System.Collections.Generic; -using System.Diagnostics.Eventing.Reader; using System.IO; using System.Linq; using System.Text; @@ -369,6 +368,17 @@ private void GenerateCompilerOptions(IGenerationContext context, ProjectOptionsG Options.Option(Options.Vc.Compiler.CppLanguageStandard.GNU17, () => { context.Options["LanguageStandard"] = "stdcpp17"; context.CommandLineOptions["LanguageStandard"] = "/std:c++17"; }), Options.Option(Options.Vc.Compiler.CppLanguageStandard.Latest, () => { context.Options["LanguageStandard"] = "stdcpplatest"; context.CommandLineOptions["LanguageStandard"] = "/std:c++latest"; }) ); + + //Options.Vc.Compiler.CLanguageStandard. + // Legacy LanguageStandard_C="" + // C11 LanguageStandard_C="stdc11" /std:c11 + // C17 LanguageStandard_C="stdc17" /std:c17 + context.SelectOption + ( + Options.Option(Options.Vc.Compiler.CLanguageStandard.Legacy, () => { context.Options["LanguageStandard_C"] = FileGeneratorUtilities.RemoveLineTag; context.CommandLineOptions["LanguageStandard_C"] = FileGeneratorUtilities.RemoveLineTag; }), + Options.Option(Options.Vc.Compiler.CLanguageStandard.C11, () => { context.Options["LanguageStandard_C"] = "stdc11"; context.CommandLineOptions["LanguageStandard_C"] = "/std:c11"; }), + Options.Option(Options.Vc.Compiler.CLanguageStandard.C17, () => { context.Options["LanguageStandard_C"] = "stdc17"; context.CommandLineOptions["LanguageStandard_C"] = "/std:c17"; }) + ); } // Compiler section @@ -824,8 +834,8 @@ private void GenerateCompilerOptions(IGenerationContext context, ProjectOptionsG // Enable CreateHotPatchableCode="true" /hotpatch context.SelectOption ( - Options.Option(Options.Vc.Compiler.CreateHotPatchableCode.Default, () => { context.Options["CreateHotPatchableCode"] = FileGeneratorUtilities.RemoveLineTag; ; context.CommandLineOptions["CreateHotPatchableCode"] = FileGeneratorUtilities.RemoveLineTag; ; }), - Options.Option(Options.Vc.Compiler.CreateHotPatchableCode.Disable, () => { context.Options["CreateHotPatchableCode"] = "false"; context.CommandLineOptions["CreateHotPatchableCode"] = FileGeneratorUtilities.RemoveLineTag; ; }), + Options.Option(Options.Vc.Compiler.CreateHotPatchableCode.Default, () => { context.Options["CreateHotPatchableCode"] = FileGeneratorUtilities.RemoveLineTag; context.CommandLineOptions["CreateHotPatchableCode"] = FileGeneratorUtilities.RemoveLineTag; }), + Options.Option(Options.Vc.Compiler.CreateHotPatchableCode.Disable, () => { context.Options["CreateHotPatchableCode"] = "false"; context.CommandLineOptions["CreateHotPatchableCode"] = FileGeneratorUtilities.RemoveLineTag; }), Options.Option(Options.Vc.Compiler.CreateHotPatchableCode.Enable, () => { context.Options["CreateHotPatchableCode"] = "true"; context.CommandLineOptions["CreateHotPatchableCode"] = "/hotpatch"; }) ); @@ -1043,15 +1053,25 @@ private void GenerateCompilerOptions(IGenerationContext context, ProjectOptionsG } // Options.Vc.Compiler.AdditionalOptions - if (context.Configuration.AdditionalCompilerOptions.Any()) - { - context.Configuration.AdditionalCompilerOptions.Sort(); - string additionalCompilerOptions = context.Configuration.AdditionalCompilerOptions.JoinStrings(" "); - context.Options["AdditionalCompilerOptions"] = additionalCompilerOptions; - } - else - { - context.Options["AdditionalCompilerOptions"] = FileGeneratorUtilities.RemoveLineTag; + foreach (Tuple optionsTuple in new[] + { + Tuple.Create(context.Configuration.AdditionalCompilerOptions, "AdditionalCompilerOptions"), + Tuple.Create(context.Configuration.AdditionalCompilerOptionsOnPCHCreate, "AdditionalCompilerOptionsOnPCHCreate"), + Tuple.Create(context.Configuration.AdditionalCompilerOptionsOnPCHUse, "AdditionalCompilerOptionsOnPCHUse") + }) + { + OrderableStrings optionsStrings = optionsTuple.Item1; + string optionsKey = optionsTuple.Item2; + if (optionsStrings.Any()) + { + optionsStrings.Sort(); + string additionalCompilerOptions = optionsStrings.JoinStrings(" "); + context.Options[optionsKey] = additionalCompilerOptions; + } + else + { + context.Options[optionsKey] = FileGeneratorUtilities.RemoveLineTag; + } } optionsContext.HasClrSupport = clrSupport; @@ -1060,11 +1080,12 @@ private void GenerateCompilerOptions(IGenerationContext context, ProjectOptionsG public static List> ConvertPostBuildCopiesToRelative(Project.Configuration conf, string relativeTo) { var relativePostBuildCopies = new List>(); - if (!conf.ResolvedTargetCopyFiles.Any() && conf.CopyDependenciesBuildStep == null && !conf.EventPostBuildCopies.Any()) + if (!conf.ResolvedTargetCopyFiles.Any() && conf.CopyDependenciesBuildStep == null && !conf.EventPostBuildCopies.Any() && !conf.ResolvedTargetCopyFilesToSubDirectory.Any()) return relativePostBuildCopies; relativePostBuildCopies.AddRange(conf.ResolvedTargetCopyFiles.Select(x => new KeyValuePair(x, conf.TargetPath))); relativePostBuildCopies.AddRange(conf.EventPostBuildCopies); + relativePostBuildCopies.AddRange(conf.ResolvedTargetCopyFilesToSubDirectory.Select(x => new KeyValuePair(x.Key, Path.Combine(conf.TargetPath, x.Value)))); for (int i = 0; i < relativePostBuildCopies.Count;) { diff --git a/Sharpmake.Generators/VisualStudio/Pyproj.Template.cs b/Sharpmake.Generators/VisualStudio/Pyproj.Template.cs index f517d354a..130646ead 100644 --- a/Sharpmake.Generators/VisualStudio/Pyproj.Template.cs +++ b/Sharpmake.Generators/VisualStudio/Pyproj.Template.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017, 2019-2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.Generators/VisualStudio/Pyproj.cs b/Sharpmake.Generators/VisualStudio/Pyproj.cs index 44b8f8cba..ca92978e1 100644 --- a/Sharpmake.Generators/VisualStudio/Pyproj.cs +++ b/Sharpmake.Generators/VisualStudio/Pyproj.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2021 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -126,11 +126,12 @@ private string Generate(PythonProject project, List unsor // xml begin header Write(Template.Project.ProjectBegin, writer, resolver); - string defaultInterpreterRegisterKeyName = $@"HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\{ + string defaultInterpreterRegisterKeyName = $@"Software\Microsoft\VisualStudio\{ devEnvRange.MinDevEnv.GetVisualVersionString() }\PythonTools\Options\Interpreters"; - var defaultInterpreter = (string)Registry.GetValue(defaultInterpreterRegisterKeyName, "DefaultInterpreter", "{}") ?? "{00000000-0000-0000-0000-000000000000}"; - var defaultInterpreterVersion = (string)Registry.GetValue(defaultInterpreterRegisterKeyName, "DefaultInterpreterVersion", "2.7") ?? "2.7"; + + var defaultInterpreter = GetRegistryCurrentUserSubKeyValue(defaultInterpreterRegisterKeyName, "DefaultInterpreter", "{00000000-0000-0000-0000-000000000000}"); + var defaultInterpreterVersion = GetRegistryCurrentUserSubKeyValue(defaultInterpreterRegisterKeyName, "DefaultInterpreterVersion", "2.7"); string currentInterpreterId = defaultInterpreter; string currentInterpreterVersion = defaultInterpreterVersion; @@ -142,14 +143,14 @@ private string Generate(PythonProject project, List unsor if (pyEnvironment.IsActivated) { string interpreterRegisterKeyName = - $@"HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\{ + $@"Software\Microsoft\VisualStudio\{ devEnvRange.MinDevEnv.GetVisualVersionString() }\PythonTools\Interpreters\{{{pyEnvironment.Guid}}}"; - string interpreterDescription = (string)Registry.GetValue(interpreterRegisterKeyName, "Description", ""); + string interpreterDescription = GetRegistryCurrentUserSubKeyValue(interpreterRegisterKeyName, "Description", ""); if (interpreterDescription != string.Empty) { currentInterpreterId = $"{{{pyEnvironment.Guid}}}"; - currentInterpreterVersion = (string)Registry.GetValue(interpreterRegisterKeyName, "Version", currentInterpreterVersion); + currentInterpreterVersion = GetRegistryCurrentUserSubKeyValue(interpreterRegisterKeyName, "Version", currentInterpreterVersion); } } } @@ -160,14 +161,14 @@ private string Generate(PythonProject project, List unsor if (virtualEnvironment.IsDefault) { string baseInterpreterRegisterKeyName = - $@"HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\{ + $@"Software\Microsoft\VisualStudio\{ devEnvRange.MinDevEnv.GetVisualVersionString() }\PythonTools\Interpreters\{{{virtualEnvironment.BaseInterpreterGuid}}}"; - string baseInterpreterDescription = (string)Registry.GetValue(baseInterpreterRegisterKeyName, "Description", ""); + string baseInterpreterDescription = GetRegistryCurrentUserSubKeyValue(baseInterpreterRegisterKeyName, "Description", ""); if (baseInterpreterDescription != string.Empty) { currentInterpreterId = $"{{{virtualEnvironment.Guid}}}"; - currentInterpreterVersion = (string)Registry.GetValue(baseInterpreterRegisterKeyName, "Version", currentInterpreterVersion); + currentInterpreterVersion = GetRegistryCurrentUserSubKeyValue(baseInterpreterRegisterKeyName, "Version", currentInterpreterVersion); } } } @@ -193,10 +194,11 @@ private string Generate(PythonProject project, List unsor foreach (PythonVirtualEnvironment virtualEnvironment in _project.VirtualEnvironments) { baseGuid = needsPypatching ? baseGuid : virtualEnvironment.BaseInterpreterGuid.ToString(); + string pyVersion = string.IsNullOrEmpty(virtualEnvironment.Version) ? currentInterpreterVersion : virtualEnvironment.Version; Write(Template.Project.ProjectItemGroupBegin, writer, resolver); using (resolver.NewScopedParameter("name", virtualEnvironment.Name)) - using (resolver.NewScopedParameter("version", currentInterpreterVersion)) + using (resolver.NewScopedParameter("version", pyVersion)) using (resolver.NewScopedParameter("basePath", virtualEnvironment.Path)) using (resolver.NewScopedParameter("baseGuid", baseGuid)) using (resolver.NewScopedParameter("guid", virtualEnvironment.Guid)) @@ -214,13 +216,13 @@ private string Generate(PythonProject project, List unsor { // Verify if the interpreter exists in the register. string interpreterRegisterKeyName = - $@"HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\{ + $@"Software\Microsoft\VisualStudio\{ devEnvRange.MinDevEnv.GetVisualVersionString() }\PythonTools\Interpreters\{{{pyEnvironment.Guid}}}"; - string interpreterDescription = (string)Registry.GetValue(interpreterRegisterKeyName, "Description", ""); + string interpreterDescription = GetRegistryCurrentUserSubKeyValue(interpreterRegisterKeyName, "Description", ""); if (interpreterDescription != string.Empty) { - string interpreterVersion = (string)Registry.GetValue(interpreterRegisterKeyName, "Version", currentInterpreterVersion); + string interpreterVersion = GetRegistryCurrentUserSubKeyValue(interpreterRegisterKeyName, "Version", currentInterpreterVersion); using (resolver.NewScopedParameter("guid", $"{{{pyEnvironment.Guid}}}")) using (resolver.NewScopedParameter("version", interpreterVersion)) { @@ -382,6 +384,22 @@ private string GetProperRelativePathToSourcePath(string path) return Util.PathGetRelative(_project.SourceRootPath, _project.IsSourceFilesCaseSensitive ? Util.GetCapitalizedPath(path) : path); } + private static string GetRegistryCurrentUserSubKeyValue(string registrySubKey, string value, string fallbackValue) + { + string key = string.Empty; + + if (Util.GetExecutingPlatform().HasAnyFlag(Platform.win32 | Platform.win64)) + { + using (RegistryKey subKey = Registry.CurrentUser.OpenSubKey(registrySubKey)) + key = (string)subKey?.GetValue(value); + } + + if (string.IsNullOrEmpty(key)) + key = fallbackValue; + + return key; + } + private class ProjectDirectory { public string Name; diff --git a/Sharpmake.Generators/VisualStudio/Sln.Template.cs b/Sharpmake.Generators/VisualStudio/Sln.Template.cs index 2ec5e7e03..ea38f8d70 100644 --- a/Sharpmake.Generators/VisualStudio/Sln.Template.cs +++ b/Sharpmake.Generators/VisualStudio/Sln.Template.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.Generators/VisualStudio/Sln.cs b/Sharpmake.Generators/VisualStudio/Sln.cs index 94fcb3142..9f60c9897 100644 --- a/Sharpmake.Generators/VisualStudio/Sln.cs +++ b/Sharpmake.Generators/VisualStudio/Sln.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2021 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -535,15 +535,15 @@ out bool updated fileGenerator.Write(Template.Solution.GlobalSectionSolutionConfigurationEnd); - if (containsMultiDotNetFramework) - multiDotNetFrameworkConfigurationNames.Clear(); - // write all project target and match then to a solution target fileGenerator.Write(Template.Solution.GlobalSectionProjectConfigurationBegin); var solutionConfigurationFastBuildBuilt = new Dictionary>(); foreach (Solution.ResolvedProject solutionProject in solutionProjects) { + if (containsMultiDotNetFramework) + multiDotNetFrameworkConfigurationNames.Clear(); + foreach (Solution.Configuration solutionConfiguration in solutionConfigurations) { ITarget solutionTarget = solutionConfiguration.Target; @@ -756,7 +756,9 @@ private Solution.Configuration.IncludedProjectInfo ResolveStartupProject(Solutio e.Configuration.Output == Project.Configuration.OutputType.DotNetConsoleApp || e.Configuration.Output == Project.Configuration.OutputType.DotNetWindowsApp || e.Configuration.Output == Project.Configuration.OutputType.Exe) - .GroupBy(e => e.Configuration.ProjectFullFileName).ToList(); + .GroupBy(e => e.Configuration.ProjectFileName) + .OrderBy(filename => filename.Key, StringComparer.InvariantCultureIgnoreCase) + .ToList(); // If there is more than one, set the one with the same name as the solution if (executableProjects.Count > 1) diff --git a/Sharpmake.Generators/VisualStudio/UserFile.cs b/Sharpmake.Generators/VisualStudio/UserFile.cs index 1c1f7a11f..a9d6347c5 100644 --- a/Sharpmake.Generators/VisualStudio/UserFile.cs +++ b/Sharpmake.Generators/VisualStudio/UserFile.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2018, 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.Generators/VisualStudio/Vcxproj.Template.cs b/Sharpmake.Generators/VisualStudio/Vcxproj.Template.cs index 6301be311..314315129 100644 --- a/Sharpmake.Generators/VisualStudio/Vcxproj.Template.cs +++ b/Sharpmake.Generators/VisualStudio/Vcxproj.Template.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.Generators/VisualStudio/Vcxproj.cs b/Sharpmake.Generators/VisualStudio/Vcxproj.cs index 09e7596ae..b2907c2fd 100644 --- a/Sharpmake.Generators/VisualStudio/Vcxproj.cs +++ b/Sharpmake.Generators/VisualStudio/Vcxproj.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.Generators/VisualStudio/VsProjCommon.Template.cs b/Sharpmake.Generators/VisualStudio/VsProjCommon.Template.cs index 537141a9d..8c75e5006 100644 --- a/Sharpmake.Generators/VisualStudio/VsProjCommon.Template.cs +++ b/Sharpmake.Generators/VisualStudio/VsProjCommon.Template.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.Generators/VisualStudio/VsProjCommon.cs b/Sharpmake.Generators/VisualStudio/VsProjCommon.cs index 3afcf3edb..93e06eec7 100644 --- a/Sharpmake.Generators/VisualStudio/VsProjCommon.cs +++ b/Sharpmake.Generators/VisualStudio/VsProjCommon.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.Generators/VisualStudio/VsUtil.cs b/Sharpmake.Generators/VisualStudio/VsUtil.cs index 6ec2ba595..703a93efc 100644 --- a/Sharpmake.Generators/VisualStudio/VsUtil.cs +++ b/Sharpmake.Generators/VisualStudio/VsUtil.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.Generators/XmlFileGenerator.cs b/Sharpmake.Generators/XmlFileGenerator.cs index adc31353b..733129f1a 100644 --- a/Sharpmake.Generators/XmlFileGenerator.cs +++ b/Sharpmake.Generators/XmlFileGenerator.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2019 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.Main.sharpmake.cs b/Sharpmake.Main.sharpmake.cs index 7a6ccb5db..cce00731b 100644 --- a/Sharpmake.Main.sharpmake.cs +++ b/Sharpmake.Main.sharpmake.cs @@ -19,6 +19,10 @@ namespace SharpmakeGen public static class Globals { public static string AbsoluteRootPath = string.Empty; + + // this holds the path where sharpmake binaries are expected to output + // note that it will contain an subdirectory per optimization + public const string OutputRootPath = @"[project.RootPath]\tmp\bin"; } public static class Common @@ -29,9 +33,9 @@ public static ITarget[] GetDefaultTargets() result.Add( new Target( Platform.anycpu, - DevEnv.vs2017, + DevEnv.vs2019, Optimization.Debug | Optimization.Release, - framework: DotNetFramework.v4_6_1 + framework: Assembler.SharpmakeDotNetFramework ) ); return result.ToArray(); @@ -52,6 +56,16 @@ protected SharpmakeBaseProject( RootPath = Globals.AbsoluteRootPath; + // Use the new csproj style + ProjectSchema = CSharpProjectSchema.NetCore; + + // prevents output dir to have a framework subfolder + CustomProperties.Add("AppendTargetFrameworkToOutputPath", "false"); + + // we need to disable determinism while because we are using wildcards in assembly versions + // error CS8357: The specified version string contains wildcards, which are not compatible with determinism + CustomProperties.Add("Deterministic", "false"); + if (excludeSharpmakeFiles) SourceFilesExcludeRegex.Add(@".*\.sharpmake.cs"); } @@ -60,16 +74,16 @@ protected SharpmakeBaseProject( public virtual void ConfigureAll(Configuration conf, Target target) { conf.ProjectFileName = "[project.Name]"; - conf.ProjectPath = @"[project.SourceRootPath]"; + conf.ProjectPath = @"[project.RootPath]\tmp\projects\[project.Name]"; conf.Output = Configuration.OutputType.DotNetClassLibrary; - conf.TargetPath = @"[project.RootPath]\bin\[target.Optimization]"; + conf.TargetPath = Path.Combine(Globals.OutputRootPath, "[target.Optimization]"); conf.IntermediatePath = @"[project.RootPath]\tmp\obj\[target.Optimization]\[project.Name]"; conf.BaseIntermediateOutputPath = conf.IntermediatePath; conf.ReferencesByName.Add("System"); - conf.Options.Add(Options.CSharp.LanguageVersion.CSharp6); + conf.Options.Add(Assembler.SharpmakeScriptsCSharpVersion); conf.Options.Add(Options.CSharp.TreatWarningsAsErrors.Enabled); conf.Options.Add( new Options.CSharp.WarningsNotAsErrors( diff --git a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Android/AndroidBuildTargets.cs b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Android/AndroidBuildTargets.cs index 4003a2da3..c17151a4d 100644 --- a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Android/AndroidBuildTargets.cs +++ b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Android/AndroidBuildTargets.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Android/AndroidPlatform.Vcxproj.Template.cs b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Android/AndroidPlatform.Vcxproj.Template.cs index 164590324..dc9ee02ee 100644 --- a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Android/AndroidPlatform.Vcxproj.Template.cs +++ b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Android/AndroidPlatform.Vcxproj.Template.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2018, 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Android/AndroidPlatform.cs b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Android/AndroidPlatform.cs index e5617a203..f712b76d8 100644 --- a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Android/AndroidPlatform.cs +++ b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Android/AndroidPlatform.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2018-2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Android/GlobalSettings.cs b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Android/GlobalSettings.cs index 6c4d14eed..fa4828b96 100644 --- a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Android/GlobalSettings.cs +++ b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Android/GlobalSettings.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Android/Util.cs b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Android/Util.cs index 8fc19d458..baea9d852 100644 --- a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Android/Util.cs +++ b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Android/Util.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Apple/BaseApplePlatform.Bff.Template.cs b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Apple/BaseApplePlatform.Bff.Template.cs index 7b22e8765..9f5be0327 100644 --- a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Apple/BaseApplePlatform.Bff.Template.cs +++ b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Apple/BaseApplePlatform.Bff.Template.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Apple/BaseApplePlatform.cs b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Apple/BaseApplePlatform.cs index 051423f8c..dd45aefa7 100644 --- a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Apple/BaseApplePlatform.cs +++ b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Apple/BaseApplePlatform.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -423,7 +423,6 @@ public virtual void SelectCompilerOptions(IGenerationContext context) options["ExcludedSourceFileNames"] = XCodeUtil.XCodeFormatList(conf.ResolvedSourceFilesBuildExclude, 4); options["SpecificLibraryPaths"] = FileGeneratorUtilities.RemoveLineTag; - options["TargetedDeviceFamily"] = "1,2"; options["BuildDirectory"] = (conf.Output == Project.Configuration.OutputType.Lib) ? conf.TargetLibraryPath : conf.TargetPath; SelectPrecompiledHeaderOptions(context); @@ -501,17 +500,12 @@ public virtual void SelectCompilerOptions(IGenerationContext context) Options.Option(Options.XCode.Compiler.CppLanguageStandard.GNU17, () => options["CppStandard"] = "gnu++17") ); - Options.XCode.Compiler.DevelopmentTeam developmentTeam = Options.GetObject(conf); - if (developmentTeam != null) - options["DevelopmentTeam"] = developmentTeam.Value; - else - options["DevelopmentTeam"] = FileGeneratorUtilities.RemoveLineTag; + options["DevelopmentTeam"] = Options.StringOption.Get(conf); - Options.XCode.Compiler.ProvisioningStyle provisioningStyle = Options.GetObject(conf); - if (provisioningStyle != null) - options["ProvisioningStyle"] = provisioningStyle.Value; - else - options["ProvisioningStyle"] = "Automatic"; + context.SelectOption( + Options.Option(Options.XCode.Compiler.ProvisioningStyle.Automatic, () => { options["ProvisioningStyle"] = "Automatic"; }), + Options.Option(Options.XCode.Compiler.ProvisioningStyle.Manual, () => { options["ProvisioningStyle"] = "Manual"; }) + ); context.SelectOption( Options.Option(Options.XCode.Compiler.DebugInformationFormat.Dwarf, () => options["DebugInformationFormat"] = "dwarf"), @@ -667,11 +661,7 @@ public virtual void SelectCompilerOptions(IGenerationContext context) throw new NotSupportedException($"XCode generator doesn't handle {conf.Output}"); } - Options.XCode.Compiler.ProvisioningProfile provisioningProfile = Options.GetObject(conf); - if (provisioningProfile != null) - options["ProvisioningProfile"] = provisioningProfile.ProfileName; - else - options["ProvisioningProfile"] = FileGeneratorUtilities.RemoveLineTag; + options["ProvisioningProfile"] = Options.StringOption.Get(conf); Options.XCode.Compiler.SDKRoot sdkRoot = Options.GetObject(conf); if (sdkRoot != null) @@ -682,12 +672,11 @@ public virtual void SelectCompilerOptions(IGenerationContext context) Options.Option(Options.XCode.Compiler.SkipInstall.Enable, () => options["SkipInstall"] = "YES") ); - Options.XCode.Compiler.TargetedDeviceFamily targetedDeviceFamily = Options.GetObject(conf); - if (targetedDeviceFamily != null) - options["TargetedDeviceFamily"] = targetedDeviceFamily.Value; - else - options["TargetedDeviceFamily"] = FileGeneratorUtilities.RemoveLineTag; - + context.SelectOption( + Options.Option(Options.XCode.Compiler.TargetedDeviceFamily.IosAndIpad, () => options["TargetedDeviceFamily"] = "1,2"), + Options.Option(Options.XCode.Compiler.TargetedDeviceFamily.Ios, () => options["TargetedDeviceFamily"] = "1"), + Options.Option(Options.XCode.Compiler.TargetedDeviceFamily.Ipad, () => options["TargetedDeviceFamily"] = "2") + ); Options.XCode.Compiler.ValidArchs validArchs = Options.GetObject(conf); if (validArchs != null) diff --git a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Apple/MacOsPlatform.cs b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Apple/MacOsPlatform.cs index 92a77257d..acf4a6c7b 100644 --- a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Apple/MacOsPlatform.cs +++ b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Apple/MacOsPlatform.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2018, 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Apple/iOsPlatform.Bff.Template.cs b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Apple/iOsPlatform.Bff.Template.cs index bc08701af..44274c8c6 100644 --- a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Apple/iOsPlatform.Bff.Template.cs +++ b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Apple/iOsPlatform.Bff.Template.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Apple/iOsPlatform.cs b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Apple/iOsPlatform.cs index ca0625516..e2cad64df 100644 --- a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Apple/iOsPlatform.cs +++ b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Apple/iOsPlatform.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/BaseMicrosoftPlatform.Vcxproj.Template.cs b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/BaseMicrosoftPlatform.Vcxproj.Template.cs index 573f8aad1..b2bcd79e3 100644 --- a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/BaseMicrosoftPlatform.Vcxproj.Template.cs +++ b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/BaseMicrosoftPlatform.Vcxproj.Template.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/BaseMicrosoftPlatform.cs b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/BaseMicrosoftPlatform.cs index 731519711..736ec5fa9 100644 --- a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/BaseMicrosoftPlatform.cs +++ b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/BaseMicrosoftPlatform.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/BasePlatform.Vcxproj.Template.cs b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/BasePlatform.Vcxproj.Template.cs index b1a9c5b03..3094672e2 100644 --- a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/BasePlatform.Vcxproj.Template.cs +++ b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/BasePlatform.Vcxproj.Template.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2021 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -62,6 +62,7 @@ public abstract partial class BasePlatform [options.ForceConformanceInForLoopScope] [options.RuntimeTypeInfo] [options.OpenMP] + [options.LanguageStandard_C] [options.LanguageStandard] false NoListing diff --git a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/BasePlatform.cs b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/BasePlatform.cs index e38896720..6a6bec12f 100644 --- a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/BasePlatform.cs +++ b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/BasePlatform.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/DefaultPlatform.cs b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/DefaultPlatform.cs index c8f8d7fb7..667845d74 100644 --- a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/DefaultPlatform.cs +++ b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/DefaultPlatform.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Linux/GlobalSettings.cs b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Linux/GlobalSettings.cs index 4284eb1e8..ee713fb32 100644 --- a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Linux/GlobalSettings.cs +++ b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Linux/GlobalSettings.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Linux/LinuxOptions.cs b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Linux/LinuxOptions.cs index bda228bdd..fd0191a30 100644 --- a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Linux/LinuxOptions.cs +++ b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Linux/LinuxOptions.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Linux/LinuxPlatform.Bff.Template.cs b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Linux/LinuxPlatform.Bff.Template.cs index 87182b277..98c477f36 100644 --- a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Linux/LinuxPlatform.Bff.Template.cs +++ b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Linux/LinuxPlatform.Bff.Template.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Linux/LinuxPlatform.Vcxproj.Template.cs b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Linux/LinuxPlatform.Vcxproj.Template.cs index e3240e12f..bea0237fd 100644 --- a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Linux/LinuxPlatform.Vcxproj.Template.cs +++ b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Linux/LinuxPlatform.Vcxproj.Template.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Linux/LinuxPlatform.cs b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Linux/LinuxPlatform.cs index 3efff3b1b..8998d3587 100644 --- a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Linux/LinuxPlatform.cs +++ b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Linux/LinuxPlatform.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2018, 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -72,7 +72,22 @@ public IEnumerable GetPlatformLibraryPaths(Project.Configuration conf) public void SetupDynamicLibraryPaths(Project.Configuration configuration, DependencySetting dependencySetting, Project.Configuration dependency) { - DefaultPlatform.SetupLibraryPaths(configuration, dependencySetting, dependency); + // There's no implib on linux platforms, the so does both + if (dependency.Project.SharpmakeProjectType != Project.ProjectTypeAttribute.Export && + !(configuration.IsFastBuild && !dependency.IsFastBuild)) + { + if (dependencySetting.HasFlag(DependencySetting.LibraryPaths)) + configuration.AddDependencyBuiltTargetLibraryPath(dependency.TargetPath, dependency.TargetLibraryPathOrderNumber); + if (dependencySetting.HasFlag(DependencySetting.LibraryFiles)) + configuration.AddDependencyBuiltTargetLibraryFile(dependency.TargetFileFullName, dependency.TargetFileOrderNumber); + } + else + { + if (dependencySetting.HasFlag(DependencySetting.LibraryPaths)) + configuration.DependenciesOtherLibraryPaths.Add(dependency.TargetPath, dependency.TargetLibraryPathOrderNumber); + if (dependencySetting.HasFlag(DependencySetting.LibraryFiles)) + configuration.DependenciesOtherLibraryFiles.Add(dependency.TargetFileFullName, dependency.TargetFileOrderNumber); + } } public void SetupStaticLibraryPaths(Project.Configuration configuration, DependencySetting dependencySetting, Project.Configuration dependency) diff --git a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Properties/AssemblyInfo.cs b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Properties/AssemblyInfo.cs index 943ecf178..953d57cba 100644 --- a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Properties/AssemblyInfo.cs +++ b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017, 2019-2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -44,6 +44,6 @@ // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("0.14.6.0")] +[assembly: AssemblyVersion("0.15.0.0")] [assembly: SharpmakeExtension] diff --git a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Sharpmake.CommonPlatforms.csproj b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Sharpmake.CommonPlatforms.csproj index 2871102a6..f9a47d6f4 100644 --- a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Sharpmake.CommonPlatforms.csproj +++ b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Sharpmake.CommonPlatforms.csproj @@ -1,51 +1,56 @@ - - + Debug AnyCPU AnyCPU - {3B476462-28E6-4640-4257-7942657699ED} Library Properties Sharpmake Sharpmake.CommonPlatforms - v4.6.1 + net472 512 + false + false + + + false + false AnyCPU true full false - ..\..\bin\debug + ..\..\tmp\bin\debug ..\..\tmp\obj\debug\sharpmake.commonplatforms ..\..\tmp\obj\debug\sharpmake.commonplatforms - ..\..\bin\debug\sharpmake.commonplatforms.xml + ..\..\tmp\bin\debug\sharpmake.commonplatforms.xml DEBUG;TRACE 4 true 618 false 1570,1591 - 6 + 7 AnyCPU false pdbonly true - ..\..\bin\release + ..\..\tmp\bin\release ..\..\tmp\obj\release\sharpmake.commonplatforms ..\..\tmp\obj\release\sharpmake.commonplatforms - ..\..\bin\release\sharpmake.commonplatforms.xml + ..\..\tmp\bin\release\sharpmake.commonplatforms.xml TRACE 4 true 618 false 1570,1591 - 6 + 7 + False @@ -90,5 +95,5 @@ Sharpmake - + \ No newline at end of file diff --git a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Sharpmake.CommonPlatforms.sharpmake.cs b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Sharpmake.CommonPlatforms.sharpmake.cs index 1e2ed6a90..7f9b37283 100644 --- a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Sharpmake.CommonPlatforms.sharpmake.cs +++ b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Sharpmake.CommonPlatforms.sharpmake.cs @@ -9,5 +9,11 @@ public CommonPlatformsProject() { Name = "Sharpmake.CommonPlatforms"; } + + public override void ConfigureAll(Configuration conf, Target target) + { + base.ConfigureAll(conf, target); + conf.ProjectPath = @"[project.SourceRootPath]"; + } } } diff --git a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Windows/BaseWindowsPlatform.cs b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Windows/BaseWindowsPlatform.cs index 0ac5eb9be..0100d8053 100644 --- a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Windows/BaseWindowsPlatform.cs +++ b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Windows/BaseWindowsPlatform.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Windows/ClangForWindowsSettings.cs b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Windows/ClangForWindowsSettings.cs index 12167f3e0..7393e1d9e 100644 --- a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Windows/ClangForWindowsSettings.cs +++ b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Windows/ClangForWindowsSettings.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2019-2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Windows/Win32Platform.cs b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Windows/Win32Platform.cs index 9c837ff68..11423258f 100644 --- a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Windows/Win32Platform.cs +++ b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Windows/Win32Platform.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017, 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Windows/Win64Platform.cs b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Windows/Win64Platform.cs index 1ba361c5d..49df27317 100644 --- a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Windows/Win64Platform.cs +++ b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Windows/Win64Platform.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -294,11 +294,14 @@ bool useCCompiler { Version toolsVersion = compilerDevEnv.Value.GetVisualStudioVCToolsVersion(); - if (toolsVersion >= new Version("14.22.27905")) + if (toolsVersion >= new Version("14.22.27905")) // 16.3.2 extraFiles.Add(@"$ExecutableRootPath$\tbbmalloc.dll"); - if (toolsVersion >= new Version("14.25.28610")) + if (toolsVersion >= new Version("14.25.28610")) // 16.5 extraFiles.Add(@"$ExecutableRootPath$\vcruntime140_1.dll"); + + if (toolsVersion >= new Version("14.28.29333")) // 16.8 + extraFiles.Add(@"$ExecutableRootPath$\msvcp140_atomic_wait.dll"); } try diff --git a/Sharpmake.Platforms/Sharpmake.NvShield/NvShieldPlatform.Vcxproj.Template.cs b/Sharpmake.Platforms/Sharpmake.NvShield/NvShieldPlatform.Vcxproj.Template.cs index 682b15e28..234dae049 100644 --- a/Sharpmake.Platforms/Sharpmake.NvShield/NvShieldPlatform.Vcxproj.Template.cs +++ b/Sharpmake.Platforms/Sharpmake.NvShield/NvShieldPlatform.Vcxproj.Template.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017, 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.Platforms/Sharpmake.NvShield/NvShieldPlatform.cs b/Sharpmake.Platforms/Sharpmake.NvShield/NvShieldPlatform.cs index 783621c60..601103b13 100644 --- a/Sharpmake.Platforms/Sharpmake.NvShield/NvShieldPlatform.cs +++ b/Sharpmake.Platforms/Sharpmake.NvShield/NvShieldPlatform.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2018 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.Platforms/Sharpmake.NvShield/Properties/AssemblyInfo.cs b/Sharpmake.Platforms/Sharpmake.NvShield/Properties/AssemblyInfo.cs index 71cb9d944..7ed380187 100644 --- a/Sharpmake.Platforms/Sharpmake.NvShield/Properties/AssemblyInfo.cs +++ b/Sharpmake.Platforms/Sharpmake.NvShield/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017, 2019-2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -44,6 +44,6 @@ // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("0.14.6.0")] +[assembly: AssemblyVersion("0.15.0.0")] [assembly: SharpmakeExtension] diff --git a/Sharpmake.Platforms/Sharpmake.X360/Properties/AssemblyInfo.cs b/Sharpmake.Platforms/Sharpmake.X360/Properties/AssemblyInfo.cs index fa1fed4de..9a5328287 100644 --- a/Sharpmake.Platforms/Sharpmake.X360/Properties/AssemblyInfo.cs +++ b/Sharpmake.Platforms/Sharpmake.X360/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017, 2019-2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -44,6 +44,6 @@ // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("0.14.6.0")] +[assembly: AssemblyVersion("0.15.0.0")] [assembly: SharpmakeExtension] diff --git a/Sharpmake.Platforms/Sharpmake.X360/X360Platform.Vcxproj.Template.cs b/Sharpmake.Platforms/Sharpmake.X360/X360Platform.Vcxproj.Template.cs index ae70a4104..32c3cad13 100644 --- a/Sharpmake.Platforms/Sharpmake.X360/X360Platform.Vcxproj.Template.cs +++ b/Sharpmake.Platforms/Sharpmake.X360/X360Platform.Vcxproj.Template.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017, 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.Platforms/Sharpmake.X360/X360Platform.cs b/Sharpmake.Platforms/Sharpmake.X360/X360Platform.cs index a20090058..ed77cc5ab 100644 --- a/Sharpmake.Platforms/Sharpmake.X360/X360Platform.cs +++ b/Sharpmake.Platforms/Sharpmake.X360/X360Platform.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2018 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.UnitTests/CSharpDependencyPropagationTest.cs b/Sharpmake.UnitTests/CSharpDependencyPropagationTest.cs index f59e018f1..d89127532 100644 --- a/Sharpmake.UnitTests/CSharpDependencyPropagationTest.cs +++ b/Sharpmake.UnitTests/CSharpDependencyPropagationTest.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.UnitTests/CommandLineTest.cs b/Sharpmake.UnitTests/CommandLineTest.cs index e06fe1d81..d0159425e 100644 --- a/Sharpmake.UnitTests/CommandLineTest.cs +++ b/Sharpmake.UnitTests/CommandLineTest.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017, 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.UnitTests/ConfigureAttributesTest.cs b/Sharpmake.UnitTests/ConfigureAttributesTest.cs index 6e2d96f91..f196ed88a 100644 --- a/Sharpmake.UnitTests/ConfigureAttributesTest.cs +++ b/Sharpmake.UnitTests/ConfigureAttributesTest.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.UnitTests/DependencyPropagationTest.cs b/Sharpmake.UnitTests/DependencyPropagationTest.cs index 668fb8f08..3cb9c7a0e 100644 --- a/Sharpmake.UnitTests/DependencyPropagationTest.cs +++ b/Sharpmake.UnitTests/DependencyPropagationTest.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.UnitTests/DotNetReferenceCollectionTest.cs b/Sharpmake.UnitTests/DotNetReferenceCollectionTest.cs index ea7aed044..54281497d 100644 --- a/Sharpmake.UnitTests/DotNetReferenceCollectionTest.cs +++ b/Sharpmake.UnitTests/DotNetReferenceCollectionTest.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2018-2019 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.UnitTests/JsonSerializerTest.cs b/Sharpmake.UnitTests/JsonSerializerTest.cs index 500ed373a..587edcce5 100644 --- a/Sharpmake.UnitTests/JsonSerializerTest.cs +++ b/Sharpmake.UnitTests/JsonSerializerTest.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2019-2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.UnitTests/KitsRootPathsTests.cs b/Sharpmake.UnitTests/KitsRootPathsTests.cs index 0f5f514f2..73597fd71 100644 --- a/Sharpmake.UnitTests/KitsRootPathsTests.cs +++ b/Sharpmake.UnitTests/KitsRootPathsTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2018-2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.UnitTests/OrderableStringsTests.cs b/Sharpmake.UnitTests/OrderableStringsTests.cs index 6996750c8..9b4aefab9 100644 --- a/Sharpmake.UnitTests/OrderableStringsTests.cs +++ b/Sharpmake.UnitTests/OrderableStringsTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.UnitTests/PackageReferencesTest.cs b/Sharpmake.UnitTests/PackageReferencesTest.cs index c9c9a01b1..faed1a613 100644 --- a/Sharpmake.UnitTests/PackageReferencesTest.cs +++ b/Sharpmake.UnitTests/PackageReferencesTest.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2018-2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.UnitTests/ResolverTest.cs b/Sharpmake.UnitTests/ResolverTest.cs index 0798ab521..6d6742fb4 100644 --- a/Sharpmake.UnitTests/ResolverTest.cs +++ b/Sharpmake.UnitTests/ResolverTest.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017, 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.UnitTests/Sharpmake.UnitTests.sharpmake.cs b/Sharpmake.UnitTests/Sharpmake.UnitTests.sharpmake.cs index bdb0f93ce..3640383a3 100644 --- a/Sharpmake.UnitTests/Sharpmake.UnitTests.sharpmake.cs +++ b/Sharpmake.UnitTests/Sharpmake.UnitTests.sharpmake.cs @@ -24,14 +24,17 @@ public override void ConfigureAll(Configuration conf, Target target) { base.ConfigureAll(conf, target); - conf.TargetPath = @"[conf.ProjectPath]\bin\[target.Optimization]"; + conf.TargetPath = @"[project.RootPath]\tmp\unittests\[target.Optimization]"; conf.AddPrivateDependency(target); conf.AddPrivateDependency(target); conf.AddPrivateDependency(target); - conf.ReferencesByNuGetPackage.Add("NUnit", "3.4.1"); - conf.ReferencesByNuGetPackage.Add("NUnit.Console", "3.4.1"); + conf.ReferencesByNuGetPackage.Add("Microsoft.NET.Test.Sdk", "16.8.3"); + + conf.ReferencesByNuGetPackage.Add("NUnit.Console", "3.12.0"); + conf.ReferencesByNuGetPackage.Add("NUnit", "3.12.0"); + conf.ReferencesByNuGetPackage.Add("NUnit3TestAdapter", "3.17.0"); } } } diff --git a/Sharpmake.UnitTests/SharpmakeFileParserTest.cs b/Sharpmake.UnitTests/SharpmakeFileParserTest.cs index 7602a97bf..1ee8d858c 100644 --- a/Sharpmake.UnitTests/SharpmakeFileParserTest.cs +++ b/Sharpmake.UnitTests/SharpmakeFileParserTest.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2018-2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.UnitTests/StringsTests.cs b/Sharpmake.UnitTests/StringsTests.cs index 92aebb98f..e79102523 100644 --- a/Sharpmake.UnitTests/StringsTests.cs +++ b/Sharpmake.UnitTests/StringsTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2019-2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.UnitTests/TargetTests.cs b/Sharpmake.UnitTests/TargetTests.cs index 21f8a6ed5..929a6f3e0 100644 --- a/Sharpmake.UnitTests/TargetTests.cs +++ b/Sharpmake.UnitTests/TargetTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.UnitTests/TestProjectBuilder.cs b/Sharpmake.UnitTests/TestProjectBuilder.cs index 6c594867f..833d4a08f 100644 --- a/Sharpmake.UnitTests/TestProjectBuilder.cs +++ b/Sharpmake.UnitTests/TestProjectBuilder.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2020-2021 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -73,6 +73,7 @@ protected void Init() false, false, false, + true, GetGeneratorsManager, null ); diff --git a/Sharpmake.UnitTests/UniqueListTests.cs b/Sharpmake.UnitTests/UniqueListTests.cs index 7ef2dcfc8..90483967d 100644 --- a/Sharpmake.UnitTests/UniqueListTests.cs +++ b/Sharpmake.UnitTests/UniqueListTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake.UnitTests/UtilTest.cs b/Sharpmake.UnitTests/UtilTest.cs index 8f914c236..9ecd81d57 100644 --- a/Sharpmake.UnitTests/UtilTest.cs +++ b/Sharpmake.UnitTests/UtilTest.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2018, 2020-2021 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -253,8 +253,8 @@ public class MockPath [Test] public void PathGetCapitalizedFile() { - var mockPath1 = Path.GetTempFileName(); - var mockPath2 = Path.GetTempFileName(); + var mockPath1 = Util.GetCapitalizedPath(Path.GetTempFileName()); + var mockPath2 = Util.GetCapitalizedPath(Path.GetTempFileName()); OrderableStrings paths = new OrderableStrings { mockPath1, @@ -278,8 +278,10 @@ public void PathGetCapitalizedFile() [Test] public void PathGetCapitalizedDirectory() { - var tempDirectory1 = Directory.CreateDirectory(Path.GetTempPath() + @"\test1"); - var tempDirectory2 = Directory.CreateDirectory(Path.GetTempPath() + @"\test2"); + string temp = Util.GetCapitalizedPath(Path.GetTempPath()); + + var tempDirectory1 = Directory.CreateDirectory(temp + @"\test1"); + var tempDirectory2 = Directory.CreateDirectory(temp + @"\test2"); OrderableStrings paths = new OrderableStrings { @@ -493,7 +495,7 @@ public class FakeTree [SetUp] public void Init() { - Util.FakePathPrefix = Path.GetDirectoryName(new Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).LocalPath); + Util.FakePathPrefix = Path.GetDirectoryName(new Uri(System.Reflection.Assembly.GetExecutingAssembly().Location).LocalPath); string[] files = { diff --git a/Sharpmake/Analyzer/Analyzer.cs b/Sharpmake/Analyzer/Analyzer.cs index 0fa2e8c7e..6e5961826 100644 --- a/Sharpmake/Analyzer/Analyzer.cs +++ b/Sharpmake/Analyzer/Analyzer.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2018 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake/Assembler.cs b/Sharpmake/Assembler.cs index 512e65035..219cc7af5 100644 --- a/Sharpmake/Assembler.cs +++ b/Sharpmake/Assembler.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2021 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,18 +12,26 @@ // See the License for the specific language governing permissions and // limitations under the License. using System; -using System.CodeDom.Compiler; +using System.Collections.Concurrent; using System.Collections.Generic; using System.IO; using System.Linq; using System.Reflection; +using System.Text; using System.Threading; -using Microsoft.Build.Utilities; +using System.Threading.Tasks; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.Emit; +using Microsoft.CodeAnalysis.Text; namespace Sharpmake { public class Assembler { + public const Options.CSharp.LanguageVersion SharpmakeScriptsCSharpVersion = Options.CSharp.LanguageVersion.CSharp7; + public const DotNetFramework SharpmakeDotNetFramework = DotNetFramework.v4_7_2; + /// /// Extra user directory to load assembly from using statement detection /// @@ -110,13 +118,11 @@ public static TDelegate BuildDelegate(string sourceFilePath, string f ParameterInfo[] delegateParameterInfos = delegateMethodInfo.GetParameters(); ParameterInfo delegateReturnInfos = delegateMethodInfo.ReturnParameter; - Assembly assembly; - Assembler assembler = new Assembler(); assembler.UseDefaultReferences = false; assembler.Assemblies.AddRange(assemblies); - assembly = assembler.BuildAssembly(fileInfo.FullName); + Assembly assembly = assembler.BuildAssembly(fileInfo.FullName); List matchMethods = new List(); @@ -235,7 +241,7 @@ public static TDelegate BuildDelegate(string functionBody, string fun } // build in memory - Assembly assembly = assembler.Build(null, null, sourceTmpFile).Assembly; + Assembly assembly = assembler.Build(builderContext: null, libraryFile: null, sources: sourceTmpFile).Assembly; InternalError.Valid(assembly != null); // Try to delete tmp file to prevent pollution, but useful while debugging @@ -383,14 +389,16 @@ public void AddDefine(string define) private IAssemblyInfo Build(IBuilderContext builderContext, string libraryFile, params string[] sources) { var assemblyInfo = LoadAssemblyInfo(builderContext, sources); + HashSet references = GetReferences(); - HashSet references = new HashSet(); - - Dictionary providerOptions = new Dictionary(); - providerOptions.Add("CompilerVersion", "v4.0"); - CodeDomProvider provider = new Microsoft.CSharp.CSharpCodeProvider(providerOptions); + assemblyInfo.Assembly = Compile(builderContext, assemblyInfo.SourceFiles.ToArray(), libraryFile, references); + assemblyInfo.Id = assemblyInfo.Assembly.Location; + return assemblyInfo; + } - CompilerParameters cp = new CompilerParameters(); + private HashSet GetReferences() + { + HashSet references = new HashSet(); if (UseDefaultReferences) { @@ -407,83 +415,102 @@ private IAssemblyInfo Build(IBuilderContext builderContext, string libraryFile, references.Add(assembly.Location); } - cp.ReferencedAssemblies.AddRange(references.ToArray()); + return references; + } - // Generate an library - cp.GenerateExecutable = false; + private SourceText ReadSourceCode(string path) + { + using (var stream = File.OpenRead(path)) + return SourceText.From(stream, Encoding.Default); + } - // Set the level at which the compiler - // should start displaying warnings. - cp.WarningLevel = 4; + private Assembly Compile(IBuilderContext builderContext, string[] files, string libraryFile, HashSet references) + { + // Parse all files + var syntaxTrees = new ConcurrentBag(); + var parseOptions = new CSharpParseOptions(ConvertSharpmakeOptionToLanguageVersion(SharpmakeScriptsCSharpVersion), DocumentationMode.None, preprocessorSymbols: _defines); + Parallel.ForEach(files, f => + { + var sourceText = ReadSourceCode(f); + syntaxTrees.Add(CSharpSyntaxTree.ParseText(sourceText, parseOptions, path: f)); + }); - // Set whether to treat all warnings as errors. - cp.TreatWarningsAsErrors = false; + return Compile(builderContext, syntaxTrees, libraryFile, references); + } - // Set compiler argument to optimize output. - // TODO : figure out why it does not work when uncommenting the following line - // cp.CompilerOptions = "/optimize"; + private Assembly Compile(IBuilderContext builderContext, IEnumerable syntaxTrees, string libraryFile, HashSet references) + { + // Add references + var portableExecutableReferences = new List(); - // If any defines are specified, pass them to the CSC. - if (_defines.Any()) + foreach (var reference in references.Where(r => !string.IsNullOrEmpty(r))) { - cp.CompilerOptions = "-DEFINE:" + string.Join(",", _defines); + portableExecutableReferences.Add(MetadataReference.CreateFromFile(reference)); } - // Specify the assembly file name to generate - if (libraryFile == null) - { - cp.GenerateInMemory = true; - cp.IncludeDebugInformation = false; - } - else + // Compile + var compilationOptions = new CSharpCompilationOptions( + OutputKind.DynamicallyLinkedLibrary, + optimizationLevel: (builderContext != null && builderContext.DebugScripts) ? OptimizationLevel.Debug : OptimizationLevel.Release, + warningLevel: 4 + ); + var assemblyName = libraryFile != null ? Path.GetFileNameWithoutExtension(libraryFile) : $"Sharpmake_{new Random().Next():X8}" + GetHashCode(); + var compilation = CSharpCompilation.Create(assemblyName, syntaxTrees, portableExecutableReferences, compilationOptions); + string pdbFilePath = libraryFile != null ? Path.ChangeExtension(libraryFile, ".pdb") : null; + + using (var dllStream = new MemoryStream()) + using (var pdbStream = new MemoryStream()) { - cp.GenerateInMemory = false; - cp.IncludeDebugInformation = true; - cp.OutputAssembly = libraryFile; - } + EmitResult result = compilation.Emit( + dllStream, + pdbStream, + options: new EmitOptions( + debugInformationFormat: DebugInformationFormat.PortablePdb, + pdbFilePath: pdbFilePath + ) + ); + + if (result.Success) + { + if (libraryFile != null) + { + dllStream.Seek(0, SeekOrigin.Begin); + using (var fileStream = new FileStream(libraryFile, FileMode.Create)) + dllStream.CopyTo(fileStream); - // Notes: - // Avoid getting spoiled by environment variables. - // C# will give compilation errors if a LIB variable contains non-existing directories. - Environment.SetEnvironmentVariable("LIB", null); + pdbStream.Seek(0, SeekOrigin.Begin); + using (var pdbFileStream = new FileStream(pdbFilePath, FileMode.Create)) + pdbStream.CopyTo(pdbFileStream); - // Configure Temp file collection to avoid deleting its temp file. We will delete them ourselves after the compilation - // For some reasons, this seems to add just enough delays to avoid the following first chance exception(probably caused by some handles in csc.exe) - // System.IO.IOException: 'The process cannot access the file 'C:\Users\xxx\AppData\Local\Temp\sa205152\sa205152.out' because it is being used by another process.' - // That exception wasn't causing real problems but was really annoying when debugging! - // Executed several times sharpmake and this first chance exception no longer occurs when KeepFiles is true. - cp.TempFiles.KeepFiles = true; + return Assembly.LoadFrom(libraryFile); + } - // Invoke compilation of the source file. - CompilerResults cr = provider.CompileAssemblyFromFile(cp, assemblyInfo.SourceFiles.ToArray()); + return Assembly.Load(dllStream.GetBuffer(), pdbStream.GetBuffer()); + } - // Manually delete the files in the temp files collection. - cp.TempFiles.Delete(); + bool throwErrorException = builderContext == null || builderContext.CompileErrorBehavior == BuilderCompileErrorBehavior.ThrowException; + LogCompilationResult(result, throwErrorException); + } - if (cr.Errors.HasErrors || cr.Errors.HasWarnings) - { - string errorMessage = ""; - foreach (CompilerError ce in cr.Errors) - { - if (ce.IsWarning) - EventOutputWarning?.Invoke("{0}" + Environment.NewLine, ce.ToString()); - else - EventOutputError?.Invoke("{0}" + Environment.NewLine, ce.ToString()); + return null; + } - errorMessage += ce + Environment.NewLine; - } + private void LogCompilationResult(EmitResult result, bool throwErrorException) + { + string errorMessage = ""; - if (cr.Errors.HasErrors) - { - if (builderContext == null || builderContext.CompileErrorBehavior == BuilderCompileErrorBehavior.ThrowException) - throw new Error(errorMessage); - return assemblyInfo; - } + foreach (var diagnostic in result.Diagnostics) + { + if (diagnostic.Severity == DiagnosticSeverity.Error) + EventOutputError?.Invoke("{0}" + Environment.NewLine, diagnostic.ToString()); + else // catch everything else as warning + EventOutputWarning?.Invoke("{0}" + Environment.NewLine, diagnostic.ToString()); + + errorMessage += diagnostic + Environment.NewLine; } - assemblyInfo.Assembly = cr.CompiledAssembly; - assemblyInfo.Id = assemblyInfo.Assembly.Location; - return assemblyInfo; + if (throwErrorException) + throw new Error(errorMessage); } private List ComputeParsers() @@ -648,11 +675,45 @@ private void AnalyseSourceFile(string sourceFile, IEnumerable EnumeratePathToDotNetFramework() { - for (int i = (int)TargetDotNetFrameworkVersion.VersionLatest; i >= 0; --i) + yield return Path.GetDirectoryName(typeof(object).Assembly.Location); + } + + private static LanguageVersion ConvertSharpmakeOptionToLanguageVersion(Options.CSharp.LanguageVersion languageVersion) + { + switch (languageVersion) { - string frameworkDirectory = ToolLocationHelper.GetPathToDotNetFramework((TargetDotNetFrameworkVersion)i); - if (frameworkDirectory != null) - yield return frameworkDirectory; + case Options.CSharp.LanguageVersion.LatestMajorVersion: + return LanguageVersion.LatestMajor; + case Options.CSharp.LanguageVersion.LatestMinorVersion: + return LanguageVersion.Latest; + case Options.CSharp.LanguageVersion.Preview: + return LanguageVersion.Preview; + case Options.CSharp.LanguageVersion.ISO1: + return LanguageVersion.CSharp1; + case Options.CSharp.LanguageVersion.ISO2: + return LanguageVersion.CSharp2; + case Options.CSharp.LanguageVersion.CSharp3: + return LanguageVersion.CSharp3; + case Options.CSharp.LanguageVersion.CSharp4: + return LanguageVersion.CSharp4; + case Options.CSharp.LanguageVersion.CSharp5: + return LanguageVersion.CSharp5; + case Options.CSharp.LanguageVersion.CSharp6: + return LanguageVersion.CSharp6; + case Options.CSharp.LanguageVersion.CSharp7: + return LanguageVersion.CSharp7; + case Options.CSharp.LanguageVersion.CSharp7_1: + return LanguageVersion.CSharp7_1; + case Options.CSharp.LanguageVersion.CSharp7_2: + return LanguageVersion.CSharp7_2; + case Options.CSharp.LanguageVersion.CSharp7_3: + return LanguageVersion.CSharp7_3; + case Options.CSharp.LanguageVersion.CSharp8: + return LanguageVersion.CSharp8; + case Options.CSharp.LanguageVersion.CSharp9: + return LanguageVersion.CSharp9; + default: + throw new NotImplementedException($"Don't know how to convert sharpmake option {languageVersion} to language version"); } } diff --git a/Sharpmake/AttributeParsers.cs b/Sharpmake/AttributeParsers.cs index 5feaa7231..1655da386 100644 --- a/Sharpmake/AttributeParsers.cs +++ b/Sharpmake/AttributeParsers.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2018-2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake/Attributes.cs b/Sharpmake/Attributes.cs index 5c0c472e1..0cf1e5875 100644 --- a/Sharpmake/Attributes.cs +++ b/Sharpmake/Attributes.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -13,7 +13,6 @@ // limitations under the License. using System; using System.Linq; -using JetBrains.Annotations; namespace Sharpmake { @@ -39,7 +38,6 @@ public class Compile : Attribute public class Export : Attribute { } - [MeansImplicitUse] [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)] public class Configure : Attribute { diff --git a/Sharpmake/BuildContext/BaseBuildContext.cs b/Sharpmake/BuildContext/BaseBuildContext.cs index 48cbb4d83..38e52e989 100644 --- a/Sharpmake/BuildContext/BaseBuildContext.cs +++ b/Sharpmake/BuildContext/BaseBuildContext.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017, 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake/BuildContext/ConfigureDependencyAnalyzer.cs b/Sharpmake/BuildContext/ConfigureDependencyAnalyzer.cs index c29babe07..5ce256665 100644 --- a/Sharpmake/BuildContext/ConfigureDependencyAnalyzer.cs +++ b/Sharpmake/BuildContext/ConfigureDependencyAnalyzer.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017, 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake/BuildContext/RegressionTest.cs b/Sharpmake/BuildContext/RegressionTest.cs index 1e22ee098..9c79e5361 100644 --- a/Sharpmake/BuildContext/RegressionTest.cs +++ b/Sharpmake/BuildContext/RegressionTest.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017, 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake/Builder.cs b/Sharpmake/Builder.cs index 5a108a1b7..c532b0f9c 100644 --- a/Sharpmake/Builder.cs +++ b/Sharpmake/Builder.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2021 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -90,7 +90,6 @@ public class Builder : IDisposable public event OutputDelegate EventOutputWarning; public event OutputDelegate EventOutputMessage; public event OutputDelegate EventOutputDebug; - public event OutputDelegate EventOutputProfile; // Configure events public delegate void PreProjectConfigure(Project project); @@ -130,6 +129,7 @@ public class Builder : IDisposable private bool _cleanBlobsOnly = false; public bool BlobOnly = false; public bool Diagnostics = false; + private bool _debugScripts = false; private ThreadPool _tasks; // Keep all instances of manually built (and loaded) assemblies, as they may be needed by other assemblies on load (command line). private readonly ConcurrentDictionary _builtAssemblies = new ConcurrentDictionary(); // Assembly Full Path -> Assembly @@ -262,6 +262,7 @@ public Builder( bool blobOnly, bool skipInvalidPath, bool diagnostics, + bool debugScripts, Func getGeneratorsManagerCallBack, HashSet defines) { @@ -272,6 +273,7 @@ public Builder( _cleanBlobsOnly = cleanBlobsOnly; BlobOnly = blobOnly; Diagnostics = diagnostics; + _debugScripts = debugScripts; SkipInvalidPath = skipInvalidPath; _getGeneratorsManagerCallBack = getGeneratorsManagerCallBack; _getGeneratorsManagerCallBack().InitializeBuilder(this); @@ -293,6 +295,10 @@ public Builder( } } + [Obsolete("Use the builder with the new debugScripts argument", error: false)] + public Builder(BuildContext.BaseBuildContext context, bool multithreaded, bool dumpDependencyGraph, bool cleanBlobsOnly, bool blobOnly, bool skipInvalidPath, bool diagnostics, Func getGeneratorsManagerCallBack, HashSet defines) + : this(context, multithreaded, dumpDependencyGraph, cleanBlobsOnly, blobOnly, skipInvalidPath, diagnostics, false, getGeneratorsManagerCallBack, defines) { } + public void Dispose() { if (_multithreaded) @@ -528,6 +534,9 @@ private IAssemblyInfo BuildAndLoadAssembly(IList sharpmakeFiles, IBuilde { Assembler assembler = new Assembler(Defines); + // Add currently loaded assemblies + assembler.Assemblies.AddRange(AppDomain.CurrentDomain.GetAssemblies()); + // Add sharpmake assembly assembler.Assemblies.Add(_sharpmakeAssembly.Value); @@ -616,7 +625,7 @@ private Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs a public Project LoadProjectType(Type type) { - using (CreateProfilingScope(type.Name)) + using (CreateProfilingScope(type.ToNiceTypeName())) { Project.ProjectTypeAttribute projectTypeAttribute; if (type.IsDefined(typeof(Generate), false)) @@ -672,7 +681,7 @@ public Project LoadProjectType(Type type) public Solution LoadSolutionType(Type type) { - using (new Util.StopwatchProfiler(ms => { ProfileWriteLine(" |{0,5} ms| load solution {1}", ms, type.Name); })) + using (CreateProfilingScope(type.ToNiceTypeName())) { if (!type.IsDefined(typeof(Generate), false) && !type.IsDefined(typeof(Compile), false) && @@ -873,7 +882,13 @@ public void Link() { // start with huge projects to balance end of tasks List projects = new List(_projects.Values); - projects.Sort((Project p0, Project p1) => { return p1.Configurations.Count.CompareTo(p0.Configurations.Count); }); + projects.Sort((Project p0, Project p1) => + { + int p0Int = p0.Configurations.Count * p0.ResolvedSourceFiles.Count; + int p1Int = p1.Configurations.Count * p1.ResolvedSourceFiles.Count; + int cmp = p1Int.CompareTo(p0Int); + return cmp; + }); LinkProjects(projects); @@ -1186,10 +1201,13 @@ private class BuilderContext : IBuilderContext public BuilderCompileErrorBehavior CompileErrorBehavior { get; } + public bool DebugScripts { get; } + public BuilderContext(Builder builder, BuilderCompileErrorBehavior compileErrorBehavior) { _builder = builder; CompileErrorBehavior = compileErrorBehavior; + DebugScripts = builder._debugScripts; } public ILoadInfo BuildAndLoadSharpmakeFiles(IEnumerable parsers, IEnumerable flowParsers, params string[] files) @@ -1248,11 +1266,6 @@ public void DebugWriteLine(string message, params object[] args) EventOutputDebug?.Invoke(message + Environment.NewLine, args); } - public void ProfileWriteLine(string message, params object[] args) - { - EventOutputProfile?.Invoke(message + Environment.NewLine, args); - } - #endregion #region Private diff --git a/Sharpmake/BuilderExtension.cs b/Sharpmake/BuilderExtension.cs index 2095f16a4..aa95eed04 100644 --- a/Sharpmake/BuilderExtension.cs +++ b/Sharpmake/BuilderExtension.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2018, 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake/CommandLine.cs b/Sharpmake/CommandLine.cs index 1b952e462..3d4570fe0 100644 --- a/Sharpmake/CommandLine.cs +++ b/Sharpmake/CommandLine.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2018, 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -13,10 +13,10 @@ // limitations under the License. using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Reflection; using System.Text; -using System.IO; namespace Sharpmake { diff --git a/Sharpmake/Configurable.cs b/Sharpmake/Configurable.cs index c6ec2ef51..32578b343 100644 --- a/Sharpmake/Configurable.cs +++ b/Sharpmake/Configurable.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. using System; -using System.Collections.Concurrent; using System.Collections.Generic; using System.IO; using System.Linq; diff --git a/Sharpmake/ConfigureCollection.cs b/Sharpmake/ConfigureCollection.cs index 9e7ddc6d3..895d620f8 100644 --- a/Sharpmake/ConfigureCollection.cs +++ b/Sharpmake/ConfigureCollection.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017, 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake/DebugProjectGenerator.cs b/Sharpmake/DebugProjectGenerator.cs index e3e7bc1e6..f6271ae1f 100644 --- a/Sharpmake/DebugProjectGenerator.cs +++ b/Sharpmake/DebugProjectGenerator.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2021 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -204,7 +204,7 @@ private static Type CreateProject(string typeSignature) { // define class type var assemblyName = new AssemblyName(typeSignature); - AssemblyBuilder assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.Run); + AssemblyBuilder assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.Run); ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule("DebugSharpmakeModule"); TypeBuilder typeBuilder = moduleBuilder.DefineType(typeSignature, TypeAttributes.Public | TypeAttributes.Class | @@ -225,12 +225,12 @@ internal static Target GetTargets() { return new Target( Platform.anycpu, - DevEnv.vs2017, - Optimization.Debug, + DevEnv.vs2019, + Optimization.Debug | Optimization.Release, OutputType.Dll, Blob.NoBlob, BuildSystem.MSBuild, - DotNetFramework.v4_6_1 + Assembler.SharpmakeDotNetFramework ); } @@ -252,7 +252,11 @@ public static void SetupProjectOptions(this Project.Configuration conf, string s conf.CsprojUserFile = new Project.Configuration.CsprojUserFileSettings(); conf.CsprojUserFile.StartAction = Project.Configuration.CsprojUserFileSettings.StartActionSetting.Program; - string quote = Util.IsRunningInMono() ? @"\""" : @""""; // When running in Mono, we must escape " + + if (conf.Target.GetOptimization() == Optimization.Debug) + startArguments += " /debugScripts"; + + string quote = "\'"; // Use single quote that is cross platform safe conf.CsprojUserFile.StartArguments = $@"/sources(@{quote}{string.Join(";", MainSources)}{quote}) {startArguments}"; conf.CsprojUserFile.StartProgram = sharpmakeApplicationExePath; } @@ -269,7 +273,7 @@ public DebugSolution() AddTargets(DebugProjectGenerator.GetTargets()); } - [Configure()] + [Configure] public virtual void Configure(Configuration conf, Target target) { conf.SolutionPath = DebugProjectGenerator.RootPath; @@ -307,17 +311,29 @@ public DebugProject() Name = _projectInfo.DisplayName; + // Use the new csproj style + ProjectSchema = CSharpProjectSchema.NetCore; + + // prevents output dir to have a framework subfolder + CustomProperties.Add("AppendTargetFrameworkToOutputPath", "false"); + + // we need to disable determinism while because we are using wildcards in assembly versions + // error CS8357: The specified version string contains wildcards, which are not compatible with determinism + CustomProperties.Add("Deterministic", "false"); + AddTargets(DebugProjectGenerator.GetTargets()); } - [Configure()] + [Configure] public void ConfigureAll(Configuration conf, Target target) { conf.ProjectPath = RootPath; conf.ProjectFileName = "[project.Name].[target.DevEnv]"; conf.Output = Configuration.OutputType.DotNetClassLibrary; - conf.Options.Add(Options.CSharp.LanguageVersion.CSharp5); + conf.DefaultOption = target.Optimization == Optimization.Debug ? Options.DefaultTarget.Debug : Options.DefaultTarget.Release; + + conf.Options.Add(Assembler.SharpmakeScriptsCSharpVersion); conf.Defines.Add(_projectInfo.Defines.ToArray()); @@ -330,8 +346,8 @@ public void ConfigureAll(Configuration conf, Target target) DebugProjectGenerator.DebugProjectExtension.AddSharpmakePackage(conf); // set up custom configuration only to setup project - if (string.CompareOrdinal(conf.ProjectPath.ToLower(), RootPath.ToLower()) == 0 - && _projectInfo.IsSetupProject) + if (_projectInfo.IsSetupProject && + FileSystemStringComparer.Default.Equals(conf.ProjectPath, RootPath)) { conf.SetupProjectOptions(_projectInfo.StartArguments); } diff --git a/Sharpmake/DependencyTracker.cs b/Sharpmake/DependencyTracker.cs index 62b3e52b9..e28a34217 100644 --- a/Sharpmake/DependencyTracker.cs +++ b/Sharpmake/DependencyTracker.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2018, 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake/DotNetReferenceCollection.cs b/Sharpmake/DotNetReferenceCollection.cs index 331106530..2b75166fe 100644 --- a/Sharpmake/DotNetReferenceCollection.cs +++ b/Sharpmake/DotNetReferenceCollection.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2018 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake/EnumExtensions.cs b/Sharpmake/EnumExtensions.cs index a268b7a58..1269e34e2 100644 --- a/Sharpmake/EnumExtensions.cs +++ b/Sharpmake/EnumExtensions.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2019 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake/Exception.cs b/Sharpmake/Exception.cs index fb0f632a5..084085fd5 100644 --- a/Sharpmake/Exception.cs +++ b/Sharpmake/Exception.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017, 2019 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake/ExtensionLoader.cs b/Sharpmake/ExtensionLoader.cs index 763fb07d2..c2f1baf06 100644 --- a/Sharpmake/ExtensionLoader.cs +++ b/Sharpmake/ExtensionLoader.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2018, 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -15,7 +15,6 @@ using System.Collections.Generic; using System.IO; using System.Reflection; -using System.Security.Policy; namespace Sharpmake { @@ -205,8 +204,8 @@ private void CreateRemoteExtensionCheckerIfNeeded() { if (_validator == null) { - _remoteDomain = AppDomain.CreateDomain("ExtensionHelperDomain", new Evidence(AppDomain.CurrentDomain.Evidence)); - _validator = _remoteDomain.CreateInstanceAndUnwrap(typeof(ExtensionChecker).Assembly.FullName, typeof(ExtensionChecker).FullName) as ExtensionChecker; + _remoteDomain = AppDomain.CreateDomain("ExtensionHelperDomain"); + _validator = _remoteDomain.Load(typeof(ExtensionChecker).Assembly.FullName).CreateInstance(typeof(ExtensionChecker).FullName) as ExtensionChecker; } } } diff --git a/Sharpmake/ExtensionMethods.cs b/Sharpmake/ExtensionMethods.cs index 0a1c30bc1..268de2f5b 100644 --- a/Sharpmake/ExtensionMethods.cs +++ b/Sharpmake/ExtensionMethods.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -100,6 +100,11 @@ public static string ToVersionString(this DotNetFramework framework) return "netstandard2.0"; case DotNetFramework.netstandard2_1: return "netstandard2.1"; + case DotNetFramework.net5_0: + return "net5.0"; + case DotNetFramework.all_netframework: + case DotNetFramework.all_netcore: + case DotNetFramework.all_netstandard: default: throw new ArgumentOutOfRangeException(nameof(framework)); } @@ -148,6 +153,8 @@ public static string ToFolderName(this DotNetFramework framework) return "netcoreapp3.0"; case DotNetFramework.netcore3_1: return "netcoreapp3.1"; + case DotNetFramework.net5_0: + return "net5.0"; case DotNetFramework.netstandard1_0: return "netstandard1.0"; case DotNetFramework.netstandard1_1: @@ -167,7 +174,7 @@ public static string ToFolderName(this DotNetFramework framework) case DotNetFramework.netstandard2_1: return "netstandard2.1"; default: - throw new ArgumentOutOfRangeException(nameof(framework)); + throw new ArgumentOutOfRangeException(nameof(framework), framework, nameof(DotNetFramework) + " cannot be converted to a folder name."); } } diff --git a/Sharpmake/FakeFileTree.cs b/Sharpmake/FakeFileTree.cs index 536c24181..9965be2e7 100644 --- a/Sharpmake/FakeFileTree.cs +++ b/Sharpmake/FakeFileTree.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2019 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake/FastBuildSettings.cs b/Sharpmake/FastBuildSettings.cs index 5650b6c70..f4d8f8e27 100644 --- a/Sharpmake/FastBuildSettings.cs +++ b/Sharpmake/FastBuildSettings.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2021 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. using System; +using System.Collections.Generic; namespace Sharpmake { @@ -56,6 +57,11 @@ public static class FastBuildSettings /// public static string CachePath = null; + /// + /// Additional settings to add to the global settings node. + /// + public static readonly IList AdditionalGlobalSettings = new List(); + /// /// Path to the fastbuild plugin dll if any. This typically will be the path to the Ubisoft asset store plugin DLL but could be any other compatible implementation. /// CachePath must also be set to an appropriate url. @@ -184,5 +190,15 @@ public enum CacheTypes /// Also it seems that this doesn't occurs with VS2013. /// public static bool EnableVS2012EnumBugWorkaround = false; // activate workaround for VS2012 enum bug(corrupted preprocessor output). + + /// + /// FastBuild names of compilers to set the 'UseRelativePaths_Experimental' option for. + /// + public static readonly ISet CompilersUsingRelativePaths = new HashSet(StringComparer.OrdinalIgnoreCase); + + /// + /// Additional settings to add to the Compiler node, keyed by compiler name. + /// + public static readonly IDictionary> AdditionalCompilerSettings = new Dictionary>(StringComparer.OrdinalIgnoreCase); } } diff --git a/Sharpmake/FileSystemStringComparer.cs b/Sharpmake/FileSystemStringComparer.cs index 1ae7ebd8e..db3875f5c 100644 --- a/Sharpmake/FileSystemStringComparer.cs +++ b/Sharpmake/FileSystemStringComparer.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2018-2021 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -29,12 +29,13 @@ namespace Sharpmake /// public class FileSystemStringComparer : IComparer, IEqualityComparer { + public static FileSystemStringComparer Default { get; } = new FileSystemStringComparer(); + private static readonly bool s_hostOsIsCaseSensitive; static FileSystemStringComparer() { - var operatingSystemFamily = Environment.OSVersion.Platform; - s_hostOsIsCaseSensitive = (operatingSystemFamily == PlatformID.MacOSX || operatingSystemFamily == PlatformID.Unix); + s_hostOsIsCaseSensitive = Util.IsRunningOnUnix(); } private readonly object _comparer; // Using System::Object as the type because this can be both IComparer or IEqualityComparer. @@ -71,10 +72,9 @@ public int GetHashCode(string obj) return ((IEqualityComparer)_comparer).GetHashCode(obj); } - private static FileSystemStringComparer s_instance = new FileSystemStringComparer(); public static int StaticCompare(string x, string y) { - return s_instance.Compare(x, y); + return Default.Compare(x, y); } } } diff --git a/Sharpmake/GeneratedAssemblyConfig.cs b/Sharpmake/GeneratedAssemblyConfig.cs index 6a5d3aee7..4825a7cc4 100644 --- a/Sharpmake/GeneratedAssemblyConfig.cs +++ b/Sharpmake/GeneratedAssemblyConfig.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake/GeneratorManager.cs b/Sharpmake/GeneratorManager.cs index 8102b3038..b27697f4e 100644 --- a/Sharpmake/GeneratorManager.cs +++ b/Sharpmake/GeneratorManager.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2018 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake/IAssemblerContext.cs b/Sharpmake/IAssemblerContext.cs index 8652af827..f840953dc 100644 --- a/Sharpmake/IAssemblerContext.cs +++ b/Sharpmake/IAssemblerContext.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2018-2021 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -36,6 +36,7 @@ public interface IBuilderContext ILoadInfo LoadExtension(string file); void AddDefine(string define); BuilderCompileErrorBehavior CompileErrorBehavior { get; } + bool DebugScripts { get; } } public interface IAssemblerContext diff --git a/Sharpmake/IFastBuildCompilerSettings.cs b/Sharpmake/IFastBuildCompilerSettings.cs index c39a27753..41076597b 100644 --- a/Sharpmake/IFastBuildCompilerSettings.cs +++ b/Sharpmake/IFastBuildCompilerSettings.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2018, 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake/IPlatformDescriptor.cs b/Sharpmake/IPlatformDescriptor.cs index fb7922640..6b4d18281 100644 --- a/Sharpmake/IPlatformDescriptor.cs +++ b/Sharpmake/IPlatformDescriptor.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017, 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake/IResolverHelper.cs b/Sharpmake/IResolverHelper.cs index e12a1ca1d..cae539601 100644 --- a/Sharpmake/IResolverHelper.cs +++ b/Sharpmake/IResolverHelper.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2018 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake/IWindowsFastBuildCompilerSettings.cs b/Sharpmake/IWindowsFastBuildCompilerSettings.cs index 43a612c60..05933633e 100644 --- a/Sharpmake/IWindowsFastBuildCompilerSettings.cs +++ b/Sharpmake/IWindowsFastBuildCompilerSettings.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2018, 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake/KitsRootPaths.cs b/Sharpmake/KitsRootPaths.cs index fab009d8c..32f529647 100644 --- a/Sharpmake/KitsRootPaths.cs +++ b/Sharpmake/KitsRootPaths.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2018-2021 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -43,9 +43,9 @@ public KitsRootPaths() string kitsRegistryKeyString = string.Format(@"SOFTWARE{0}\Microsoft\Windows Kits\Installed Roots", Environment.Is64BitProcess ? @"\Wow6432Node" : string.Empty); - s_defaultKitsRoots[KitsRootEnum.KitsRoot] = Util.GetRegistryLocalMachineSubKeyValue(kitsRegistryKeyString, KitsRootEnum.KitsRoot.ToString(), @"C:\Program Files (x86)\Windows Kits\8.0\"); - s_defaultKitsRoots[KitsRootEnum.KitsRoot81] = Util.GetRegistryLocalMachineSubKeyValue(kitsRegistryKeyString, KitsRootEnum.KitsRoot81.ToString(), @"C:\Program Files (x86)\Windows Kits\8.1\"); - s_defaultKitsRoots[KitsRootEnum.KitsRoot10] = Util.GetRegistryLocalMachineSubKeyValue(kitsRegistryKeyString, KitsRootEnum.KitsRoot10.ToString(), @"C:\Program Files (x86)\Windows Kits\10\"); + s_defaultKitsRoots[KitsRootEnum.KitsRoot] = Util.GetRegistryLocalMachineSubKeyValue(kitsRegistryKeyString, KitsRootEnum.KitsRoot.ToString(), @"C:\Program Files (x86)\Windows Kits\8.0\", enableLog: false); + s_defaultKitsRoots[KitsRootEnum.KitsRoot81] = Util.GetRegistryLocalMachineSubKeyValue(kitsRegistryKeyString, KitsRootEnum.KitsRoot81.ToString(), @"C:\Program Files (x86)\Windows Kits\8.1\", enableLog: false); + s_defaultKitsRoots[KitsRootEnum.KitsRoot10] = Util.GetRegistryLocalMachineSubKeyValue(kitsRegistryKeyString, KitsRootEnum.KitsRoot10.ToString(), @"C:\Program Files (x86)\Windows Kits\10\", enableLog: false); s_defaultKitsRootForDevEnv[DevEnv.vs2010] = Tuple.Create(KitsRootEnum.KitsRoot, null); s_defaultKitsRootForDevEnv[DevEnv.vs2012] = Tuple.Create(KitsRootEnum.KitsRoot, null); diff --git a/Sharpmake/MSBuildGlobalSettings.cs b/Sharpmake/MSBuildGlobalSettings.cs index 1831e6c4f..629081f8e 100644 --- a/Sharpmake/MSBuildGlobalSettings.cs +++ b/Sharpmake/MSBuildGlobalSettings.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2018-2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake/Options.Android.cs b/Sharpmake/Options.Android.cs index c1022257f..b63712d02 100644 --- a/Sharpmake/Options.Android.cs +++ b/Sharpmake/Options.Android.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2018, 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake/Options.CSharp.cs b/Sharpmake/Options.CSharp.cs index d9556866a..90619c5ef 100644 --- a/Sharpmake/Options.CSharp.cs +++ b/Sharpmake/Options.CSharp.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2021 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -392,19 +392,25 @@ public enum UseCodeBase Disabled } + // https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/configure-language-version#c-language-version-reference public enum LanguageVersion { [Default] - LatestMajorVersion, - LatestMinorVersion, - ISO1, - ISO2, + LatestMajorVersion, // The compiler accepts syntax from the latest released major version of the compiler. + LatestMinorVersion, // The compiler accepts syntax from the latest released version of the compiler (including minor version). + Preview, // The compiler accepts all valid language syntax from the latest preview version. + ISO1, // The compiler accepts only syntax that is included in ISO/IEC 23270:2003 C# (1.0/1.2). + ISO2, // The compiler accepts only syntax that is included in ISO/IEC 23270:2006 C# (2.0). CSharp3, CSharp4, CSharp5, CSharp6, CSharp7, CSharp7_1, + CSharp7_2, + CSharp7_3, + CSharp8, + CSharp9, } // Disable warning MSB3270 when disabled diff --git a/Sharpmake/Options.Clang.cs b/Sharpmake/Options.Clang.cs index 742db8dea..2832a53ad 100644 --- a/Sharpmake/Options.Clang.cs +++ b/Sharpmake/Options.Clang.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake/Options.Makefile.cs b/Sharpmake/Options.Makefile.cs index 7439d1a73..88dc4dafc 100644 --- a/Sharpmake/Options.Makefile.cs +++ b/Sharpmake/Options.Makefile.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017, 2019-2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -37,8 +37,12 @@ public enum CppLanguageStandard Cpp11, Cpp14, Cpp17, + Cpp2a, GnuCpp98, - GnuCpp11 + GnuCpp11, + GnuCpp14, + GnuCpp17, + GnuCpp2a, } public enum Exceptions diff --git a/Sharpmake/Options.Vc.cs b/Sharpmake/Options.Vc.cs index a2b8025b9..7f97b9100 100644 --- a/Sharpmake/Options.Vc.cs +++ b/Sharpmake/Options.Vc.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2021 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -573,6 +573,16 @@ public enum CppLanguageStandard Latest } + public enum CLanguageStandard + { + [Default] + Legacy, + [DevEnvVersion(minimum = DevEnv.vs2019)] + C11, + [DevEnvVersion(minimum = DevEnv.vs2019)] + C17 + } + public enum SupportJustMyCode { [Default] diff --git a/Sharpmake/Options.XCode.cs b/Sharpmake/Options.XCode.cs index de8ce1e06..533870feb 100644 --- a/Sharpmake/Options.XCode.cs +++ b/Sharpmake/Options.XCode.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017, 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -11,6 +11,8 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. + +using System; using System.Linq; namespace Sharpmake @@ -77,21 +79,17 @@ public enum CLanguageStandard GNU11 } - public class CodeSignEntitlements + public class CodeSignEntitlements : StringOption { - public string Value; - public CodeSignEntitlements(string value) + public CodeSignEntitlements(string value) : base(value) { - Value = value; } } - public class CodeSigningIdentity + public class CodeSigningIdentity : StringOption { - public string Value; - public CodeSigningIdentity(string value) + public CodeSigningIdentity(string value) : base(value) { - Value = value; } } @@ -144,9 +142,11 @@ public class DevelopmentTeam : StringOption public DevelopmentTeam(string value) : base(value) { } } - public class ProvisioningStyle : StringOption + public enum ProvisioningStyle { - public ProvisioningStyle(string value) : base(value) { } + [Default] + Automatic, + Manual } public enum DeploymentPostProcessing @@ -186,6 +186,7 @@ public ExternalResourceFolders(params string[] paths) { } } + [Obsolete("AssetCatalog is not used anymore.", error: true)] public class AssetCatalog : Strings { public AssetCatalog(params string[] paths) @@ -327,12 +328,10 @@ public enum PrivateSymbols Enable } - public class ProvisioningProfile + public class ProvisioningProfile : StringOption { - public string ProfileName; - public ProvisioningProfile(string profileName) + public ProvisioningProfile(string profileName) : base(profileName) { - ProfileName = profileName; } } @@ -387,13 +386,14 @@ public enum StripDebugSymbolsDuringCopy Disable } - public class TargetedDeviceFamily + [Flags] + public enum TargetedDeviceFamily { - public string Value; - public TargetedDeviceFamily(string value) - { - Value = value; - } + [Default] + Ios = 1 << 0, + Ipad = 1 << 1, + + IosAndIpad = Ios | Ipad } public class AssetCatalogCompilerAppIconName : StringOption diff --git a/Sharpmake/Options.cs b/Sharpmake/Options.cs index 12e5bce3a..b09c316fe 100644 --- a/Sharpmake/Options.cs +++ b/Sharpmake/Options.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2021 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -438,10 +438,9 @@ public static string GetString(Configuration conf) where T : StringOption for (int i = options.Count - 1; i >= 0; --i) { - string option = options[i] as string; - if (option is T) + if (options[i] is T stringOption) { - return option; + return stringOption.Value; } } return string.Empty; diff --git a/Sharpmake/PackageReferences.Template.cs b/Sharpmake/PackageReferences.Template.cs index e613fe3bd..b21c27ff8 100644 --- a/Sharpmake/PackageReferences.Template.cs +++ b/Sharpmake/PackageReferences.Template.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2018-2019 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake/PackageReferences.cs b/Sharpmake/PackageReferences.cs index 7d95f1253..31a618272 100644 --- a/Sharpmake/PackageReferences.cs +++ b/Sharpmake/PackageReferences.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2019 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake/PlatformAttributes.cs b/Sharpmake/PlatformAttributes.cs index 02f3c1953..456fb22c2 100644 --- a/Sharpmake/PlatformAttributes.cs +++ b/Sharpmake/PlatformAttributes.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2018 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake/PlatformExceptions.cs b/Sharpmake/PlatformExceptions.cs index 451a73213..6dd007fb1 100644 --- a/Sharpmake/PlatformExceptions.cs +++ b/Sharpmake/PlatformExceptions.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017, 2019-2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake/PlatformRegistry.cs b/Sharpmake/PlatformRegistry.cs index 95c1b3db1..b5abc986e 100644 --- a/Sharpmake/PlatformRegistry.cs +++ b/Sharpmake/PlatformRegistry.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2019 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake/PreprocessorConditionParser.cs b/Sharpmake/PreprocessorConditionParser.cs index b4f387ee1..8fae920e1 100644 --- a/Sharpmake/PreprocessorConditionParser.cs +++ b/Sharpmake/PreprocessorConditionParser.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2019-2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -16,10 +16,8 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using System.Text; using System.Text.RegularExpressions; using System.Threading; -using System.Threading.Tasks; namespace Sharpmake { diff --git a/Sharpmake/Project.Configuration.cs b/Sharpmake/Project.Configuration.cs index 59fbdb865..9f457b267 100644 --- a/Sharpmake/Project.Configuration.cs +++ b/Sharpmake/Project.Configuration.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2021 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -827,6 +827,22 @@ public OutputType Output /// public OrderableStrings AdditionalCompilerOptions = new OrderableStrings(); + /// + /// Compiler-specific options to pass when invoking the compiler to create PCHs. + /// + /// + /// Currently only respected by the BFF generator. + /// + public OrderableStrings AdditionalCompilerOptionsOnPCHCreate = new OrderableStrings(); + + /// + /// Compiler-specific options to pass when invoking the compiler telling it to use PCHs. + /// + /// + /// Currently only respected by the BFF generator. + /// + public OrderableStrings AdditionalCompilerOptionsOnPCHUse = new OrderableStrings(); + /// /// Gets a list of file extensions that are added to a Visual Studio project with the /// None build action. @@ -1282,6 +1298,11 @@ public string FastBuildUnityPath /// public string BffFullFileName => Path.Combine(ProjectPath, BffFileName); + /// + /// Whether to use relative paths in FASTBuild-generated Unity files. + /// + public bool FastBuildUnityUseRelativePaths = false; + /// /// Gets or sets whether to generate a FASTBuild (.bff) file when using FASTBuild. /// @@ -1335,7 +1356,8 @@ public BuildStepExecutable( string executableWorkingDirectory = "", bool isNameSpecific = false, bool useStdOutAsOutput = false, - bool alwaysShowOutput = false) + bool alwaysShowOutput = false, + bool executeAlways = false) { ExecutableFile = executableFile; @@ -1346,6 +1368,7 @@ public BuildStepExecutable( IsNameSpecific = isNameSpecific; FastBuildUseStdOutAsOutput = useStdOutAsOutput; FastBuildAlwaysShowOutput = alwaysShowOutput; + FastBuildExecAlways = executeAlways; } /// @@ -1385,6 +1408,11 @@ public BuildStepExecutable( public bool FastBuildAlwaysShowOutput = false; + /// + /// Gets or sets whether the step should be executed every time. + /// + public bool FastBuildExecAlways = false; + internal override void Resolve(Resolver resolver) { base.Resolve(resolver); @@ -1637,6 +1665,11 @@ internal void Resolve(Resolver resolver) /// public Strings TargetCopyFiles = new Strings(); + /// + /// Gets or sets the list of files to copy to a sub-directory of the output directory. + /// + public HashSet> TargetCopyFilesToSubDirectory = new HashSet>(); + /// /// Gets or sets the list of files that the target depends on. /// @@ -2082,6 +2115,14 @@ internal void AddMasterBff(string masterBff) /// public IEnumerable ResolvedTargetCopyFiles => _resolvedTargetCopyFiles; + private HashSet> _resolvedTargetCopyFilesToSubDirectory = new HashSet>(); + + /// + /// Gets the list of resolved files to copy to a sub directory of the target directory. + /// + public IEnumerable> ResolvedTargetCopyFilesToSubDirectory => _resolvedTargetCopyFilesToSubDirectory; + + private Strings _resolvedTargetDependsFiles = new Strings(); /// @@ -2178,6 +2219,12 @@ public void GeneratorSetGeneratedInformation(string executableExtension, string /// public bool PreferRelativePaths = true; + /// + /// Optional OS version at the end of the TargetFramework, for example, net5.0-ios13.0. + /// + /// C# only, will throw if the target doesn't have a non-default DotNetOS fragment + public string DotNetOSVersionSuffix = string.Empty; + internal override void Construct(object owner, ITarget target) { base.Construct(owner, target); @@ -2213,6 +2260,8 @@ internal void Resolve(Resolver resolver) Util.ResolvePath(Project.SharpmakeCsPath, ref BaseIntermediateOutputPath); Util.ResolvePath(Project.SharpmakeCsPath, ref LibraryPaths); Util.ResolvePathAndFixCase(Project.SharpmakeCsPath, ref TargetCopyFiles); + Util.ResolvePathAndFixCase(Project.SharpmakeCsPath, Util.KeyValuePairResolveType.ResolveAll, ref EventPostBuildCopies); + Util.ResolvePathAndFixCase(Project.SharpmakeCsPath, Util.KeyValuePairResolveType.ResolveKey, ref TargetCopyFilesToSubDirectory); Util.ResolvePath(Project.SharpmakeCsPath, ref TargetDependsFiles); Util.ResolvePath(Project.SharpmakeCsPath, ref TargetPath); Util.ResolvePath(Project.SharpmakeCsPath, ref TargetLibraryPath); @@ -2270,6 +2319,11 @@ internal void Resolve(Resolver resolver) _resolvedTargetDependsFiles.AddRange(TargetDependsFiles); _resolvedTargetCopyFiles.AddRange(TargetCopyFiles); + foreach (var keyValuePair in TargetCopyFilesToSubDirectory) + { + _resolvedTargetCopyFilesToSubDirectory.Add(keyValuePair); + } + foreach (var tuple in new[] { Tuple.Create(EventPreBuildExe, _resolvedEventPreBuildExe), Tuple.Create(EventPostBuildExe, _resolvedEventPostBuildExe), @@ -2812,6 +2866,11 @@ internal void Link(Builder builder) _resolvedTargetDependsFiles.AddRange(dependency.TargetDependsFiles); _resolvedExecDependsFiles.AddRange(dependency.EventPreBuildExe); _resolvedExecDependsFiles.AddRange(dependency.EventPostBuildExe); + + foreach (var keyValuePair in dependency.TargetCopyFilesToSubDirectory) + { + _resolvedTargetCopyFilesToSubDirectory.Add(keyValuePair); + } } else if (Output == OutputType.None && isExport == false) { diff --git a/Sharpmake/Project.cs b/Sharpmake/Project.cs index aeb70bd49..7c33856f7 100644 --- a/Sharpmake/Project.cs +++ b/Sharpmake/Project.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2021 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -962,7 +962,8 @@ internal virtual void ResolveSourceFiles(Builder builder) NoneFilesCopyIfNewer.IntersectWith(SourceFilesFilters); } - AdditionalFiltering(SourceFiles, ref SourceFilesExclude); + using (builder.CreateProfilingScope("Project.ResolveSourceFiles:AdditionalFiltering")) + AdditionalFiltering(SourceFiles, ref SourceFilesExclude); // Add source files ResolvedSourceFiles.AddRange(SourceFiles); @@ -1653,7 +1654,7 @@ public virtual void PreConfigure() { } - public void AfterConfigure() + public virtual void AfterConfigure() { foreach (Project.Configuration conf in Configurations) { @@ -1708,15 +1709,28 @@ public virtual void PostResolve() var includePathsExcludeFromWarningRegex = RegexCache.GetCachedRegexes(IncludePathsExcludeFromWarningRegex).ToArray(); var libraryPathsExcludeFromWarningRegex = RegexCache.GetCachedRegexes(LibraryPathsExcludeFromWarningRegex).ToArray(); - // check if the files marked as excluded from build still exist + // check if the files marked with specific options still exist foreach (var array in new Dictionary { - {conf.ResolvedSourceFilesBuildExclude, nameof(conf.ResolvedSourceFilesBuildExclude)}, - {conf.ResolvedSourceFilesBlobExclude, nameof(conf.ResolvedSourceFilesBlobExclude)}, {conf.ResolvedSourceFilesWithCompileAsCLROption, nameof(conf.ResolvedSourceFilesWithCompileAsCLROption)}, {conf.ResolvedSourceFilesWithCompileAsCOption, nameof(conf.ResolvedSourceFilesWithCompileAsCOption)}, {conf.ResolvedSourceFilesWithCompileAsCPPOption, nameof(conf.ResolvedSourceFilesWithCompileAsCPPOption)}, {conf.ResolvedSourceFilesWithCompileAsNonCLROption, nameof(conf.ResolvedSourceFilesWithCompileAsNonCLROption)}, {conf.ResolvedSourceFilesWithCompileAsWinRTOption, nameof(conf.ResolvedSourceFilesWithCompileAsWinRTOption)}, + }) + { + foreach (string file in array.Key) + { + if (!File.Exists(file)) + { + ReportError($@"{conf.Project.SharpmakeCsFileName}: Error: File contained in {array.Value} doesn't exist: {file}."); + } + } + } + + // check if the files marked as excluded from build still exist + foreach (var array in new Dictionary { + {conf.ResolvedSourceFilesBuildExclude, nameof(conf.ResolvedSourceFilesBuildExclude)}, + {conf.ResolvedSourceFilesBlobExclude, nameof(conf.ResolvedSourceFilesBlobExclude)}, {conf.ResolvedSourceFilesWithExcludeAsWinRTOption, nameof(conf.ResolvedSourceFilesWithExcludeAsWinRTOption)}, {conf.PrecompSourceExclude, nameof(conf.PrecompSourceExclude)} }) @@ -1725,7 +1739,7 @@ public virtual void PostResolve() { if (!File.Exists(file)) { - ReportError($@"{conf.Project.SharpmakeCsFileName}: Error: File contained in {array.Value} doesn't exist: {file}."); + ReportError($@"{conf.Project.SharpmakeCsFileName}: Warning: File contained in {array.Value} doesn't exist: {file}.", onlyWarn: true); } } } @@ -1751,6 +1765,10 @@ public virtual void PostResolve() var platformLibraryPaths = configTasks.GetPlatformLibraryPaths(conf); allLibraryPaths.AddRange(platformLibraryPaths); + // remove all the rooted files + var allRootedFiles = allLibraryFiles.Where(file => Path.IsPathRooted(file)).ToArray(); + allLibraryFiles.RemoveRange(allRootedFiles); + string platformLibExtension = "." + configTasks.GetDefaultOutputExtension(Configuration.OutputType.Lib); foreach (string folder in allLibraryPaths) { @@ -1764,7 +1782,7 @@ public virtual void PostResolve() var toRemove = new List(); foreach (string file in allLibraryFiles) { - string path = Path.IsPathRooted(file) ? file : Path.Combine(folder, file); + string path = Path.Combine(folder, file); if (File.Exists(path) || File.Exists(path + platformLibExtension) || File.Exists(Path.Combine(folder, "lib" + file + platformLibExtension))) toRemove.Add(file); } @@ -1773,6 +1791,9 @@ public virtual void PostResolve() } } + // Add all rooted files that are missing + allLibraryFiles.Add(allRootedFiles.Where(file => !File.Exists(file)).ToArray()); + // everything that remains is a missing library file foreach (string file in allLibraryFiles) { @@ -1818,7 +1839,7 @@ internal void Resolve(Builder builder, bool skipInvalidPath) XResourcesImg.Resolve(SourceRootPath, resolver); - using (builder.CreateProfilingScope("ResolveConfs")) + using (builder.CreateProfilingScope("ResolveConfs (" + Configurations.Count + ")")) { // Resolve Configuration foreach (Project.Configuration conf in Configurations) @@ -2065,6 +2086,13 @@ public class PublishFile public FileType FileType = FileType.File; } + [Resolver.Resolvable] + public class GlobSetting + { + public string Include; + public string Exclude; + } + public enum CSharpProjectType { Test, @@ -2291,6 +2319,7 @@ public class CSharpProject : Project public List BootstrapperPackages = new List(); public List FileAssociationItems = new List(); public List PublishFiles = new List(); + public List Globs = new List(); /// /// If set to true. Will explicit the RestoreProjectStyle in the project file @@ -2575,15 +2604,25 @@ public class PythonVirtualEnvironment public Guid Guid; public bool IsDefault; public Guid BaseInterpreterGuid; + public string Version; public PythonVirtualEnvironment(string name, string path, bool isDefault) - : this(name, path, isDefault, default(Guid)) + : this(name, path, String.Empty, isDefault, default(Guid)) + { } + + public PythonVirtualEnvironment(string name, string path, string version, bool isDefault) + : this(name, path, version, isDefault, default(Guid)) { } public PythonVirtualEnvironment(string name, string path, bool isDefault, Guid baseInterpreterGuid) + : this(name, path, String.Empty, isDefault, baseInterpreterGuid) + { } + + public PythonVirtualEnvironment(string name, string path, string version, bool isDefault, Guid baseInterpreterGuid) { Name = name; Path = path; + Version = version; Guid = Util.BuildGuid(path); IsDefault = isDefault; BaseInterpreterGuid = baseInterpreterGuid; diff --git a/Sharpmake/Properties/AssemblyInfo.cs b/Sharpmake/Properties/AssemblyInfo.cs index 3269331b8..89c1b159d 100644 --- a/Sharpmake/Properties/AssemblyInfo.cs +++ b/Sharpmake/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -44,9 +44,9 @@ // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("0.14.6.0")] +[assembly: AssemblyVersion("0.15.0.0")] #pragma warning disable CS7035 -[assembly: AssemblyFileVersion("0.14.6.0 (LocalBuild)")] +[assembly: AssemblyFileVersion("0.15.0.0 (LocalBuild)")] #pragma warning restore [assembly: InternalsVisibleTo("Sharpmake.Application")] diff --git a/Sharpmake/ReferenceAlias.cs b/Sharpmake/ReferenceAlias.cs index 2fa50c7dc..b8abf1438 100644 --- a/Sharpmake/ReferenceAlias.cs +++ b/Sharpmake/ReferenceAlias.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2018-2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake/RegexCache.cs b/Sharpmake/RegexCache.cs index 7a5ccd2ae..c48a8c91e 100644 --- a/Sharpmake/RegexCache.cs +++ b/Sharpmake/RegexCache.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017, 2019-2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake/ResharperAnnotations.cs b/Sharpmake/ResharperAnnotations.cs deleted file mode 100644 index 771e858de..000000000 --- a/Sharpmake/ResharperAnnotations.cs +++ /dev/null @@ -1,1065 +0,0 @@ -/* MIT License - -Copyright (c) 2016 JetBrains http://www.jetbrains.com - -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; - -#pragma warning disable 1591 -// ReSharper disable UnusedMember.Global -// ReSharper disable MemberCanBePrivate.Global -// ReSharper disable UnusedAutoPropertyAccessor.Global -// ReSharper disable IntroduceOptionalParameters.Global -// ReSharper disable MemberCanBeProtected.Global -// ReSharper disable InconsistentNaming - -namespace JetBrains.Annotations -{ - /// - /// Indicates that the value of the marked element could be null sometimes, - /// so the check for null is necessary before its usage. - /// - /// - /// [CanBeNull] object Test() => null; - /// - /// void UseTest() { - /// var p = Test(); - /// var s = p.ToString(); // Warning: Possible 'System.NullReferenceException' - /// } - /// - [AttributeUsage( - AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property | - AttributeTargets.Delegate | AttributeTargets.Field | AttributeTargets.Event | - AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.GenericParameter)] - internal sealed class CanBeNullAttribute : Attribute { } - - /// - /// Indicates that the value of the marked element could never be null. - /// - /// - /// [NotNull] object Foo() { - /// return null; // Warning: Possible 'null' assignment - /// } - /// - [AttributeUsage( - AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property | - AttributeTargets.Delegate | AttributeTargets.Field | AttributeTargets.Event | - AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.GenericParameter)] - internal sealed class NotNullAttribute : Attribute { } - - /// - /// Can be appplied to symbols of types derived from IEnumerable as well as to symbols of Task - /// and Lazy classes to indicate that the value of a collection item, of the Task.Result property - /// or of the Lazy.Value property can never be null. - /// - [AttributeUsage( - AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property | - AttributeTargets.Delegate | AttributeTargets.Field)] - internal sealed class ItemNotNullAttribute : Attribute { } - - /// - /// Can be appplied to symbols of types derived from IEnumerable as well as to symbols of Task - /// and Lazy classes to indicate that the value of a collection item, of the Task.Result property - /// or of the Lazy.Value property can be null. - /// - [AttributeUsage( - AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property | - AttributeTargets.Delegate | AttributeTargets.Field)] - internal sealed class ItemCanBeNullAttribute : Attribute { } - - /// - /// Indicates that the marked method builds string by format pattern and (optional) arguments. - /// Parameter, which contains format string, should be given in constructor. The format string - /// should be in -like form. - /// - /// - /// [StringFormatMethod("message")] - /// void ShowError(string message, params object[] args) { /* do something */ } - /// - /// void Foo() { - /// ShowError("Failed: {0}"); // Warning: Non-existing argument in format string - /// } - /// - [AttributeUsage( - AttributeTargets.Constructor | AttributeTargets.Method | - AttributeTargets.Property | AttributeTargets.Delegate)] - internal sealed class StringFormatMethodAttribute : Attribute - { - /// - /// Specifies which parameter of an annotated method should be treated as format-string - /// - public StringFormatMethodAttribute([NotNull] string formatParameterName) - { - FormatParameterName = formatParameterName; - } - - [NotNull] public string FormatParameterName { get; private set; } - } - - /// - /// For a parameter that is expected to be one of the limited set of values. - /// Specify fields of which type should be used as values for this parameter. - /// - [AttributeUsage( - AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.Field, - AllowMultiple = true)] - internal sealed class ValueProviderAttribute : Attribute - { - public ValueProviderAttribute([NotNull] string name) - { - Name = name; - } - - [NotNull] public string Name { get; private set; } - } - - /// - /// Indicates that the function argument should be string literal and match one - /// of the parameters of the caller function. For example, ReSharper annotates - /// the parameter of . - /// - /// - /// void Foo(string param) { - /// if (param == null) - /// throw new ArgumentNullException("par"); // Warning: Cannot resolve symbol - /// } - /// - [AttributeUsage(AttributeTargets.Parameter)] - internal sealed class InvokerParameterNameAttribute : Attribute { } - - /// - /// Indicates that the method is contained in a type that implements - /// System.ComponentModel.INotifyPropertyChanged interface and this method - /// is used to notify that some property value changed. - /// - /// - /// The method should be non-static and conform to one of the supported signatures: - /// - /// NotifyChanged(string) - /// NotifyChanged(params string[]) - /// NotifyChanged{T}(Expression{Func{T}}) - /// NotifyChanged{T,U}(Expression{Func{T,U}}) - /// SetProperty{T}(ref T, T, string) - /// - /// - /// - /// public class Foo : INotifyPropertyChanged { - /// public event PropertyChangedEventHandler PropertyChanged; - /// - /// [NotifyPropertyChangedInvocator] - /// protected virtual void NotifyChanged(string propertyName) { ... } - /// - /// string _name; - /// - /// public string Name { - /// get { return _name; } - /// set { _name = value; NotifyChanged("LastName"); /* Warning */ } - /// } - /// } - /// - /// Examples of generated notifications: - /// - /// NotifyChanged("Property") - /// NotifyChanged(() => Property) - /// NotifyChanged((VM x) => x.Property) - /// SetProperty(ref myField, value, "Property") - /// - /// - [AttributeUsage(AttributeTargets.Method)] - internal sealed class NotifyPropertyChangedInvocatorAttribute : Attribute - { - public NotifyPropertyChangedInvocatorAttribute() { } - public NotifyPropertyChangedInvocatorAttribute([NotNull] string parameterName) - { - ParameterName = parameterName; - } - - [CanBeNull] public string ParameterName { get; private set; } - } - - /// - /// Describes dependency between method input and output. - /// - /// - ///

Function Definition Table syntax:

- /// - /// FDT ::= FDTRow [;FDTRow]* - /// FDTRow ::= Input => Output | Output <= Input - /// Input ::= ParameterName: Value [, Input]* - /// Output ::= [ParameterName: Value]* {halt|stop|void|nothing|Value} - /// Value ::= true | false | null | notnull | canbenull - /// - /// If method has single input parameter, it's name could be omitted.
- /// Using halt (or void/nothing, which is the same) for method output - /// means that the methos doesn't return normally (throws or terminates the process).
- /// Value canbenull is only applicable for output parameters.
- /// You can use multiple [ContractAnnotation] for each FDT row, or use single attribute - /// with rows separated by semicolon. There is no notion of order rows, all rows are checked - /// for applicability and applied per each program state tracked by R# analysis.
- ///
- /// - /// - /// [ContractAnnotation("=> halt")] - /// public void TerminationMethod() - /// - /// - /// [ContractAnnotation("halt <= condition: false")] - /// public void Assert(bool condition, string text) // regular assertion method - /// - /// - /// [ContractAnnotation("s:null => true")] - /// public bool IsNullOrEmpty(string s) // string.IsNullOrEmpty() - /// - /// - /// // A method that returns null if the parameter is null, - /// // and not null if the parameter is not null - /// [ContractAnnotation("null => null; notnull => notnull")] - /// public object Transform(object data) - /// - /// - /// [ContractAnnotation("=> true, result: notnull; => false, result: null")] - /// public bool TryParse(string s, out Person result) - /// - /// - [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] - internal sealed class ContractAnnotationAttribute : Attribute - { - public ContractAnnotationAttribute([NotNull] string contract) - : this(contract, false) { } - - public ContractAnnotationAttribute([NotNull] string contract, bool forceFullStates) - { - Contract = contract; - ForceFullStates = forceFullStates; - } - - [NotNull] public string Contract { get; private set; } - - public bool ForceFullStates { get; private set; } - } - - /// - /// Indicates that marked element should be localized or not. - /// - /// - /// [LocalizationRequiredAttribute(true)] - /// class Foo { - /// string str = "my string"; // Warning: Localizable string - /// } - /// - [AttributeUsage(AttributeTargets.All)] - internal sealed class LocalizationRequiredAttribute : Attribute - { - public LocalizationRequiredAttribute() : this(true) { } - - public LocalizationRequiredAttribute(bool required) - { - Required = required; - } - - public bool Required { get; private set; } - } - - /// - /// Indicates that the value of the marked type (or its derivatives) - /// cannot be compared using '==' or '!=' operators and Equals() - /// should be used instead. However, using '==' or '!=' for comparison - /// with null is always permitted. - /// - /// - /// [CannotApplyEqualityOperator] - /// class NoEquality { } - /// - /// class UsesNoEquality { - /// void Test() { - /// var ca1 = new NoEquality(); - /// var ca2 = new NoEquality(); - /// if (ca1 != null) { // OK - /// bool condition = ca1 == ca2; // Warning - /// } - /// } - /// } - /// - [AttributeUsage(AttributeTargets.Interface | AttributeTargets.Class | AttributeTargets.Struct)] - internal sealed class CannotApplyEqualityOperatorAttribute : Attribute { } - - /// - /// When applied to a target attribute, specifies a requirement for any type marked - /// with the target attribute to implement or inherit specific type or types. - /// - /// - /// [BaseTypeRequired(typeof(IComponent)] // Specify requirement - /// class ComponentAttribute : Attribute { } - /// - /// [Component] // ComponentAttribute requires implementing IComponent interface - /// class MyComponent : IComponent { } - /// - [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] - [BaseTypeRequired(typeof(Attribute))] - internal sealed class BaseTypeRequiredAttribute : Attribute - { - public BaseTypeRequiredAttribute([NotNull] Type baseType) - { - BaseType = baseType; - } - - [NotNull] public Type BaseType { get; private set; } - } - - /// - /// Indicates that the marked symbol is used implicitly (e.g. via reflection, in external library), - /// so this symbol will not be marked as unused (as well as by other usage inspections). - /// - [AttributeUsage(AttributeTargets.All)] - internal sealed class UsedImplicitlyAttribute : Attribute - { - public UsedImplicitlyAttribute() - : this(ImplicitUseKindFlags.Default, ImplicitUseTargetFlags.Default) { } - - public UsedImplicitlyAttribute(ImplicitUseKindFlags useKindFlags) - : this(useKindFlags, ImplicitUseTargetFlags.Default) { } - - public UsedImplicitlyAttribute(ImplicitUseTargetFlags targetFlags) - : this(ImplicitUseKindFlags.Default, targetFlags) { } - - public UsedImplicitlyAttribute(ImplicitUseKindFlags useKindFlags, ImplicitUseTargetFlags targetFlags) - { - UseKindFlags = useKindFlags; - TargetFlags = targetFlags; - } - - public ImplicitUseKindFlags UseKindFlags { get; private set; } - - public ImplicitUseTargetFlags TargetFlags { get; private set; } - } - - /// - /// Should be used on attributes and causes ReSharper to not mark symbols marked with such attributes - /// as unused (as well as by other usage inspections) - /// - [AttributeUsage(AttributeTargets.Class | AttributeTargets.GenericParameter)] - internal sealed class MeansImplicitUseAttribute : Attribute - { - public MeansImplicitUseAttribute() - : this(ImplicitUseKindFlags.Default, ImplicitUseTargetFlags.Default) { } - - public MeansImplicitUseAttribute(ImplicitUseKindFlags useKindFlags) - : this(useKindFlags, ImplicitUseTargetFlags.Default) { } - - public MeansImplicitUseAttribute(ImplicitUseTargetFlags targetFlags) - : this(ImplicitUseKindFlags.Default, targetFlags) { } - - public MeansImplicitUseAttribute(ImplicitUseKindFlags useKindFlags, ImplicitUseTargetFlags targetFlags) - { - UseKindFlags = useKindFlags; - TargetFlags = targetFlags; - } - - [UsedImplicitly] public ImplicitUseKindFlags UseKindFlags { get; private set; } - - [UsedImplicitly] public ImplicitUseTargetFlags TargetFlags { get; private set; } - } - - [Flags] - internal enum ImplicitUseKindFlags - { - Default = Access | Assign | InstantiatedWithFixedConstructorSignature, - /// Only entity marked with attribute considered used. - Access = 1, - /// Indicates implicit assignment to a member. - Assign = 2, - /// - /// Indicates implicit instantiation of a type with fixed constructor signature. - /// That means any unused constructor parameters won't be reported as such. - /// - InstantiatedWithFixedConstructorSignature = 4, - /// Indicates implicit instantiation of a type. - InstantiatedNoFixedConstructorSignature = 8, - } - - /// - /// Specify what is considered used implicitly when marked - /// with or . - /// - [Flags] - internal enum ImplicitUseTargetFlags - { - Default = Itself, - Itself = 1, - /// Members of entity marked with attribute are considered used. - Members = 2, - /// Entity marked with attribute and all its members considered used. - WithMembers = Itself | Members - } - - /// - /// This attribute is intended to mark publicly available API - /// which should not be removed and so is treated as used. - /// - [MeansImplicitUse(ImplicitUseTargetFlags.WithMembers)] - internal sealed class PublicAPIAttribute : Attribute - { - public PublicAPIAttribute() { } - - public PublicAPIAttribute([NotNull] string comment) - { - Comment = comment; - } - - [CanBeNull] public string Comment { get; private set; } - } - - /// - /// Tells code analysis engine if the parameter is completely handled when the invoked method is on stack. - /// If the parameter is a delegate, indicates that delegate is executed while the method is executed. - /// If the parameter is an enumerable, indicates that it is enumerated while the method is executed. - /// - [AttributeUsage(AttributeTargets.Parameter)] - internal sealed class InstantHandleAttribute : Attribute { } - - /// - /// Indicates that a method does not make any observable state changes. - /// The same as System.Diagnostics.Contracts.PureAttribute. - /// - /// - /// [Pure] int Multiply(int x, int y) => x * y; - /// - /// void M() { - /// Multiply(123, 42); // Waring: Return value of pure method is not used - /// } - /// - [AttributeUsage(AttributeTargets.Method)] - internal sealed class PureAttribute : Attribute { } - - /// - /// Indicates that the return value of method invocation must be used. - /// - [AttributeUsage(AttributeTargets.Method)] - internal sealed class MustUseReturnValueAttribute : Attribute - { - public MustUseReturnValueAttribute() { } - - public MustUseReturnValueAttribute([NotNull] string justification) - { - Justification = justification; - } - - [CanBeNull] public string Justification { get; private set; } - } - - /// - /// Indicates the type member or parameter of some type, that should be used instead of all other ways - /// to get the value that type. This annotation is useful when you have some "context" value evaluated - /// and stored somewhere, meaning that all other ways to get this value must be consolidated with existing one. - /// - /// - /// class Foo { - /// [ProvidesContext] IBarService _barService = ...; - /// - /// void ProcessNode(INode node) { - /// DoSomething(node, node.GetGlobalServices().Bar); - /// // ^ Warning: use value of '_barService' field - /// } - /// } - /// - [AttributeUsage( - AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Parameter | AttributeTargets.Method | - AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Struct | AttributeTargets.GenericParameter)] - internal sealed class ProvidesContextAttribute : Attribute { } - - /// - /// Indicates that a parameter is a path to a file or a folder within a web project. - /// Path can be relative or absolute, starting from web root (~). - /// - [AttributeUsage(AttributeTargets.Parameter)] - internal sealed class PathReferenceAttribute : Attribute - { - public PathReferenceAttribute() { } - - public PathReferenceAttribute([NotNull, PathReference] string basePath) - { - BasePath = basePath; - } - - [CanBeNull] public string BasePath { get; private set; } - } - - /// - /// An extension method marked with this attribute is processed by ReSharper code completion - /// as a 'Source Template'. When extension method is completed over some expression, it's source code - /// is automatically expanded like a template at call site. - /// - /// - /// Template method body can contain valid source code and/or special comments starting with '$'. - /// Text inside these comments is added as source code when the template is applied. Template parameters - /// can be used either as additional method parameters or as identifiers wrapped in two '$' signs. - /// Use the attribute to specify macros for parameters. - /// - /// - /// In this example, the 'forEach' method is a source template available over all values - /// of enumerable types, producing ordinary C# 'foreach' statement and placing caret inside block: - /// - /// [SourceTemplate] - /// public static void forEach<T>(this IEnumerable<T> xs) { - /// foreach (var x in xs) { - /// //$ $END$ - /// } - /// } - /// - /// - [AttributeUsage(AttributeTargets.Method)] - internal sealed class SourceTemplateAttribute : Attribute { } - - /// - /// Allows specifying a macro for a parameter of a source template. - /// - /// - /// You can apply the attribute on the whole method or on any of its additional parameters. The macro expression - /// is defined in the property. When applied on a method, the target - /// template parameter is defined in the property. To apply the macro silently - /// for the parameter, set the property value = -1. - /// - /// - /// Applying the attribute on a source template method: - /// - /// [SourceTemplate, Macro(Target = "item", Expression = "suggestVariableName()")] - /// public static void forEach<T>(this IEnumerable<T> collection) { - /// foreach (var item in collection) { - /// //$ $END$ - /// } - /// } - /// - /// Applying the attribute on a template method parameter: - /// - /// [SourceTemplate] - /// public static void something(this Entity x, [Macro(Expression = "guid()", Editable = -1)] string newguid) { - /// /*$ var $x$Id = "$newguid$" + x.ToString(); - /// x.DoSomething($x$Id); */ - /// } - /// - /// - [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method, AllowMultiple = true)] - internal sealed class MacroAttribute : Attribute - { - /// - /// Allows specifying a macro that will be executed for a source template - /// parameter when the template is expanded. - /// - [CanBeNull] public string Expression { get; set; } - - /// - /// Allows specifying which occurrence of the target parameter becomes editable when the template is deployed. - /// - /// - /// If the target parameter is used several times in the template, only one occurrence becomes editable; - /// other occurrences are changed synchronously. To specify the zero-based index of the editable occurrence, - /// use values >= 0. To make the parameter non-editable when the template is expanded, use -1. - /// > - public int Editable { get; set; } - - /// - /// Identifies the target parameter of a source template if the - /// is applied on a template method. - /// - [CanBeNull] public string Target { get; set; } - } - - [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)] - internal sealed class AspMvcAreaMasterLocationFormatAttribute : Attribute - { - public AspMvcAreaMasterLocationFormatAttribute([NotNull] string format) - { - Format = format; - } - - [NotNull] public string Format { get; private set; } - } - - [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)] - internal sealed class AspMvcAreaPartialViewLocationFormatAttribute : Attribute - { - public AspMvcAreaPartialViewLocationFormatAttribute([NotNull] string format) - { - Format = format; - } - - [NotNull] public string Format { get; private set; } - } - - [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)] - internal sealed class AspMvcAreaViewLocationFormatAttribute : Attribute - { - public AspMvcAreaViewLocationFormatAttribute([NotNull] string format) - { - Format = format; - } - - [NotNull] public string Format { get; private set; } - } - - [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)] - internal sealed class AspMvcMasterLocationFormatAttribute : Attribute - { - public AspMvcMasterLocationFormatAttribute([NotNull] string format) - { - Format = format; - } - - [NotNull] public string Format { get; private set; } - } - - [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)] - internal sealed class AspMvcPartialViewLocationFormatAttribute : Attribute - { - public AspMvcPartialViewLocationFormatAttribute([NotNull] string format) - { - Format = format; - } - - [NotNull] public string Format { get; private set; } - } - - [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)] - internal sealed class AspMvcViewLocationFormatAttribute : Attribute - { - public AspMvcViewLocationFormatAttribute([NotNull] string format) - { - Format = format; - } - - [NotNull] public string Format { get; private set; } - } - - /// - /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter - /// is an MVC action. If applied to a method, the MVC action name is calculated - /// implicitly from the context. Use this attribute for custom wrappers similar to - /// System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String). - /// - [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] - internal sealed class AspMvcActionAttribute : Attribute - { - public AspMvcActionAttribute() { } - - public AspMvcActionAttribute([NotNull] string anonymousProperty) - { - AnonymousProperty = anonymousProperty; - } - - [CanBeNull] public string AnonymousProperty { get; private set; } - } - - /// - /// ASP.NET MVC attribute. Indicates that a parameter is an MVC area. - /// Use this attribute for custom wrappers similar to - /// System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String). - /// - [AttributeUsage(AttributeTargets.Parameter)] - internal sealed class AspMvcAreaAttribute : Attribute - { - public AspMvcAreaAttribute() { } - - public AspMvcAreaAttribute([NotNull] string anonymousProperty) - { - AnonymousProperty = anonymousProperty; - } - - [CanBeNull] public string AnonymousProperty { get; private set; } - } - - /// - /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter is - /// an MVC controller. If applied to a method, the MVC controller name is calculated - /// implicitly from the context. Use this attribute for custom wrappers similar to - /// System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String, String). - /// - [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] - internal sealed class AspMvcControllerAttribute : Attribute - { - public AspMvcControllerAttribute() { } - - public AspMvcControllerAttribute([NotNull] string anonymousProperty) - { - AnonymousProperty = anonymousProperty; - } - - [CanBeNull] public string AnonymousProperty { get; private set; } - } - - /// - /// ASP.NET MVC attribute. Indicates that a parameter is an MVC Master. Use this attribute - /// for custom wrappers similar to System.Web.Mvc.Controller.View(String, String). - /// - [AttributeUsage(AttributeTargets.Parameter)] - internal sealed class AspMvcMasterAttribute : Attribute { } - - /// - /// ASP.NET MVC attribute. Indicates that a parameter is an MVC model type. Use this attribute - /// for custom wrappers similar to System.Web.Mvc.Controller.View(String, Object). - /// - [AttributeUsage(AttributeTargets.Parameter)] - internal sealed class AspMvcModelTypeAttribute : Attribute { } - - /// - /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter is an MVC - /// partial view. If applied to a method, the MVC partial view name is calculated implicitly - /// from the context. Use this attribute for custom wrappers similar to - /// System.Web.Mvc.Html.RenderPartialExtensions.RenderPartial(HtmlHelper, String). - /// - [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] - internal sealed class AspMvcPartialViewAttribute : Attribute { } - - /// - /// ASP.NET MVC attribute. Allows disabling inspections for MVC views within a class or a method. - /// - [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)] - internal sealed class AspMvcSuppressViewErrorAttribute : Attribute { } - - /// - /// ASP.NET MVC attribute. Indicates that a parameter is an MVC display template. - /// Use this attribute for custom wrappers similar to - /// System.Web.Mvc.Html.DisplayExtensions.DisplayForModel(HtmlHelper, String). - /// - [AttributeUsage(AttributeTargets.Parameter)] - internal sealed class AspMvcDisplayTemplateAttribute : Attribute { } - - /// - /// ASP.NET MVC attribute. Indicates that a parameter is an MVC editor template. - /// Use this attribute for custom wrappers similar to - /// System.Web.Mvc.Html.EditorExtensions.EditorForModel(HtmlHelper, String). - /// - [AttributeUsage(AttributeTargets.Parameter)] - internal sealed class AspMvcEditorTemplateAttribute : Attribute { } - - /// - /// ASP.NET MVC attribute. Indicates that a parameter is an MVC template. - /// Use this attribute for custom wrappers similar to - /// System.ComponentModel.DataAnnotations.UIHintAttribute(System.String). - /// - [AttributeUsage(AttributeTargets.Parameter)] - internal sealed class AspMvcTemplateAttribute : Attribute { } - - /// - /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter - /// is an MVC view component. If applied to a method, the MVC view name is calculated implicitly - /// from the context. Use this attribute for custom wrappers similar to - /// System.Web.Mvc.Controller.View(Object). - /// - [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] - internal sealed class AspMvcViewAttribute : Attribute { } - - /// - /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter - /// is an MVC view component name. - /// - [AttributeUsage(AttributeTargets.Parameter)] - internal sealed class AspMvcViewComponentAttribute : Attribute { } - - /// - /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter - /// is an MVC view component view. If applied to a method, the MVC view component view name is default. - /// - [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] - internal sealed class AspMvcViewComponentViewAttribute : Attribute { } - - /// - /// ASP.NET MVC attribute. When applied to a parameter of an attribute, - /// indicates that this parameter is an MVC action name. - /// - /// - /// [ActionName("Foo")] - /// public ActionResult Login(string returnUrl) { - /// ViewBag.ReturnUrl = Url.Action("Foo"); // OK - /// return RedirectToAction("Bar"); // Error: Cannot resolve action - /// } - /// - [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property)] - internal sealed class AspMvcActionSelectorAttribute : Attribute { } - - [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.Field)] - internal sealed class HtmlElementAttributesAttribute : Attribute - { - public HtmlElementAttributesAttribute() { } - - public HtmlElementAttributesAttribute([NotNull] string name) - { - Name = name; - } - - [CanBeNull] public string Name { get; private set; } - } - - [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)] - internal sealed class HtmlAttributeValueAttribute : Attribute - { - public HtmlAttributeValueAttribute([NotNull] string name) - { - Name = name; - } - - [NotNull] public string Name { get; private set; } - } - - /// - /// Razor attribute. Indicates that a parameter or a method is a Razor section. - /// Use this attribute for custom wrappers similar to - /// System.Web.WebPages.WebPageBase.RenderSection(String). - /// - [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] - internal sealed class RazorSectionAttribute : Attribute { } - - /// - /// Indicates how method, constructor invocation or property access - /// over collection type affects content of the collection. - /// - [AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Property)] - internal sealed class CollectionAccessAttribute : Attribute - { - public CollectionAccessAttribute(CollectionAccessType collectionAccessType) - { - CollectionAccessType = collectionAccessType; - } - - public CollectionAccessType CollectionAccessType { get; private set; } - } - - [Flags] - internal enum CollectionAccessType - { - /// Method does not use or modify content of the collection. - None = 0, - /// Method only reads content of the collection but does not modify it. - Read = 1, - /// Method can change content of the collection but does not add new elements. - ModifyExistingContent = 2, - /// Method can add new elements to the collection. - UpdatedContent = ModifyExistingContent | 4 - } - - /// - /// Indicates that the marked method is assertion method, i.e. it halts control flow if - /// one of the conditions is satisfied. To set the condition, mark one of the parameters with - /// attribute. - /// - [AttributeUsage(AttributeTargets.Method)] - internal sealed class AssertionMethodAttribute : Attribute { } - - /// - /// Indicates the condition parameter of the assertion method. The method itself should be - /// marked by attribute. The mandatory argument of - /// the attribute is the assertion type. - /// - [AttributeUsage(AttributeTargets.Parameter)] - internal sealed class AssertionConditionAttribute : Attribute - { - public AssertionConditionAttribute(AssertionConditionType conditionType) - { - ConditionType = conditionType; - } - - public AssertionConditionType ConditionType { get; private set; } - } - - /// - /// Specifies assertion type. If the assertion method argument satisfies the condition, - /// then the execution continues. Otherwise, execution is assumed to be halted. - /// - internal enum AssertionConditionType - { - /// Marked parameter should be evaluated to true. - IS_TRUE = 0, - /// Marked parameter should be evaluated to false. - IS_FALSE = 1, - /// Marked parameter should be evaluated to null value. - IS_NULL = 2, - /// Marked parameter should be evaluated to not null value. - IS_NOT_NULL = 3, - } - - /// - /// Indicates that the marked method unconditionally terminates control flow execution. - /// For example, it could unconditionally throw exception. - /// - [Obsolete("Use [ContractAnnotation('=> halt')] instead")] - [AttributeUsage(AttributeTargets.Method)] - internal sealed class TerminatesProgramAttribute : Attribute { } - - /// - /// Indicates that method is pure LINQ method, with postponed enumeration (like Enumerable.Select, - /// .Where). This annotation allows inference of [InstantHandle] annotation for parameters - /// of delegate type by analyzing LINQ method chains. - /// - [AttributeUsage(AttributeTargets.Method)] - internal sealed class LinqTunnelAttribute : Attribute { } - - /// - /// Indicates that IEnumerable, passed as parameter, is not enumerated. - /// - [AttributeUsage(AttributeTargets.Parameter)] - internal sealed class NoEnumerationAttribute : Attribute { } - - /// - /// Indicates that parameter is regular expression pattern. - /// - [AttributeUsage(AttributeTargets.Parameter)] - internal sealed class RegexPatternAttribute : Attribute { } - - /// - /// Prevents the Member Reordering feature from tossing members of the marked class. - /// - /// - /// The attribute must be mentioned in your member reordering patterns - /// - [AttributeUsage( - AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Struct | AttributeTargets.Enum)] - internal sealed class NoReorderAttribute : Attribute { } - - /// - /// XAML attribute. Indicates the type that has ItemsSource property and should be treated - /// as ItemsControl-derived type, to enable inner items DataContext type resolve. - /// - [AttributeUsage(AttributeTargets.Class)] - internal sealed class XamlItemsControlAttribute : Attribute { } - - /// - /// XAML attribute. Indicates the property of some BindingBase-derived type, that - /// is used to bind some item of ItemsControl-derived type. This annotation will - /// enable the DataContext type resolve for XAML bindings for such properties. - /// - /// - /// Property should have the tree ancestor of the ItemsControl type or - /// marked with the attribute. - /// - [AttributeUsage(AttributeTargets.Property)] - internal sealed class XamlItemBindingOfItemsControlAttribute : Attribute { } - - [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] - internal sealed class AspChildControlTypeAttribute : Attribute - { - public AspChildControlTypeAttribute([NotNull] string tagName, [NotNull] Type controlType) - { - TagName = tagName; - ControlType = controlType; - } - - [NotNull] public string TagName { get; private set; } - - [NotNull] public Type ControlType { get; private set; } - } - - [AttributeUsage(AttributeTargets.Property | AttributeTargets.Method)] - internal sealed class AspDataFieldAttribute : Attribute { } - - [AttributeUsage(AttributeTargets.Property | AttributeTargets.Method)] - internal sealed class AspDataFieldsAttribute : Attribute { } - - [AttributeUsage(AttributeTargets.Property)] - internal sealed class AspMethodPropertyAttribute : Attribute { } - - [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] - internal sealed class AspRequiredAttributeAttribute : Attribute - { - public AspRequiredAttributeAttribute([NotNull] string attribute) - { - Attribute = attribute; - } - - [NotNull] public string Attribute { get; private set; } - } - - [AttributeUsage(AttributeTargets.Property)] - internal sealed class AspTypePropertyAttribute : Attribute - { - public bool CreateConstructorReferences { get; private set; } - - public AspTypePropertyAttribute(bool createConstructorReferences) - { - CreateConstructorReferences = createConstructorReferences; - } - } - - [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] - internal sealed class RazorImportNamespaceAttribute : Attribute - { - public RazorImportNamespaceAttribute([NotNull] string name) - { - Name = name; - } - - [NotNull] public string Name { get; private set; } - } - - [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] - internal sealed class RazorInjectionAttribute : Attribute - { - public RazorInjectionAttribute([NotNull] string type, [NotNull] string fieldName) - { - Type = type; - FieldName = fieldName; - } - - [NotNull] public string Type { get; private set; } - - [NotNull] public string FieldName { get; private set; } - } - - [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] - internal sealed class RazorDirectiveAttribute : Attribute - { - public RazorDirectiveAttribute([NotNull] string directive) - { - Directive = directive; - } - - [NotNull] public string Directive { get; private set; } - } - - [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] - internal sealed class RazorPageBaseTypeAttribute : Attribute - { - public RazorPageBaseTypeAttribute([NotNull] string baseType) - { - BaseType = baseType; - } - public RazorPageBaseTypeAttribute([NotNull] string baseType, string pageName) - { - BaseType = baseType; - PageName = pageName; - } - - [NotNull] public string BaseType { get; private set; } - [CanBeNull] public string PageName { get; private set; } - } - - [AttributeUsage(AttributeTargets.Method)] - internal sealed class RazorHelperCommonAttribute : Attribute { } - - [AttributeUsage(AttributeTargets.Property)] - internal sealed class RazorLayoutAttribute : Attribute { } - - [AttributeUsage(AttributeTargets.Method)] - internal sealed class RazorWriteLiteralMethodAttribute : Attribute { } - - [AttributeUsage(AttributeTargets.Method)] - internal sealed class RazorWriteMethodAttribute : Attribute { } - - [AttributeUsage(AttributeTargets.Parameter)] - internal sealed class RazorWriteMethodParameterAttribute : Attribute { } -} diff --git a/Sharpmake/Resolver.cs b/Sharpmake/Resolver.cs index e128558b8..02a331f50 100644 --- a/Sharpmake/Resolver.cs +++ b/Sharpmake/Resolver.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2021 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -768,6 +768,17 @@ private void ResolveMember(string objectPath, object obj, MemberInfo memberInfo, SetResolved(memberPath); } } + else if (fieldValue is HashSet>) + { + if (CanWriteFieldValue(fieldInfo)) + { + SetResolving(memberPath); + + ResolveKeyPairHashSet((HashSet>)fieldValue, fallbackValue); + + SetResolved(memberPath); + } + } else if (fieldInfo.FieldType.IsClass) { object memberObject = fieldValue; @@ -817,6 +828,14 @@ private void ResolveMember(string objectPath, object obj, MemberInfo memberInfo, SetResolved(memberPath); } + else if (propertyValue is HashSet>) + { + SetResolving(memberPath); + + ResolveKeyPairHashSet((HashSet>)propertyValue, fallbackValue); + + SetResolved(memberPath); + } else if (propertyInfo.PropertyType.IsClass) { ResolveObject(memberPath, propertyValue, fallbackValue); @@ -826,14 +845,34 @@ private void ResolveMember(string objectPath, object obj, MemberInfo memberInfo, } } + private void ResolveKeyPairHashSet(HashSet> values, object fallbackValue) + { + // Empty check to prevent a useless memory allocation in .ToList() + if (values.Count == 0) + return; + + foreach (var keyValuePair in values.ToList()) + { + bool keyChanged; + bool valueChanged; + + string key = Resolve(keyValuePair.Key, fallbackValue, out keyChanged); + string value = Resolve(keyValuePair.Value, fallbackValue, out valueChanged); + + if (keyChanged || valueChanged) + { + values.Remove(keyValuePair); + values.Add(new KeyValuePair(key, value)); + } + } + } + private void ResolveObject(string objectPath, object obj, object fallbackValue) { // prevent object resolve recursion if (_resolvedObject.Add(obj) == false) return; - var typeWrapper = GetTypeWrapper(obj.GetType()); - if (objectPath != null) { if (GetResolveStatus(objectPath) == ResolveStatus.Resolved) @@ -842,6 +881,7 @@ private void ResolveObject(string objectPath, object obj, object fallbackValue) SetResolving(objectPath); } + var typeWrapper = GetTypeWrapper(obj.GetType()); if (typeWrapper == null) return; diff --git a/Sharpmake/Sharpmake.csproj b/Sharpmake/Sharpmake.csproj index 11372ada1..b34b1cb9c 100644 --- a/Sharpmake/Sharpmake.csproj +++ b/Sharpmake/Sharpmake.csproj @@ -1,18 +1,20 @@ - - + Debug AnyCPU AnyCPU - {15F793C7-9E88-64A9-591C-7244FCC6B771} Library Properties Sharpmake Sharpmake - v4.6.1 + net472 512 + false + false + false + false https://api.nuget.org/v3/index.json @@ -20,10 +22,10 @@ true full false - ..\bin\debug + ..\tmp\bin\debug ..\tmp\obj\debug\sharpmake ..\tmp\obj\debug\sharpmake - ..\bin\debug\sharpmake.xml + ..\tmp\bin\debug\sharpmake.xml DEBUG;TRACE 4 true @@ -31,17 +33,17 @@ 618 false 1570,1591 - 6 + 7 AnyCPU false pdbonly true - ..\bin\release + ..\tmp\bin\release ..\tmp\obj\release\sharpmake ..\tmp\obj\release\sharpmake - ..\bin\release\sharpmake.xml + ..\tmp\bin\release\sharpmake.xml TRACE 4 true @@ -49,12 +51,10 @@ 618 false 1570,1591 - 6 + 7 + - - True - False @@ -118,7 +118,6 @@ - @@ -135,7 +134,8 @@ - + + - + \ No newline at end of file diff --git a/Sharpmake/Sharpmake.sharpmake.cs b/Sharpmake/Sharpmake.sharpmake.cs index 7fd23166f..f494fa984 100644 --- a/Sharpmake/Sharpmake.sharpmake.cs +++ b/Sharpmake/Sharpmake.sharpmake.cs @@ -20,10 +20,12 @@ public SharpmakeProject() public override void ConfigureAll(Configuration conf, Target target) { base.ConfigureAll(conf, target); - conf.ReferencesByNameExternal.Add("Microsoft.Build.Utilities.v4.0"); + conf.ProjectPath = @"[project.SourceRootPath]"; conf.Options.Add(Options.CSharp.AllowUnsafeBlocks.Enabled); - conf.ReferencesByNuGetPackage.Add("Microsoft.VisualStudio.Setup.Configuration.Interop", "1.16.30"); + + conf.ReferencesByNuGetPackage.Add("Microsoft.CodeAnalysis.CSharp", "3.8.0"); + conf.ReferencesByNuGetPackage.Add("Microsoft.VisualStudio.Setup.Configuration.Interop", "2.3.2262-g94fae01e"); } } } diff --git a/Sharpmake/SharpmakeExtension.cs b/Sharpmake/SharpmakeExtension.cs index a6ad14ee8..db793916f 100644 --- a/Sharpmake/SharpmakeExtension.cs +++ b/Sharpmake/SharpmakeExtension.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2018 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake/Solution.Configuration.cs b/Sharpmake/Solution.Configuration.cs index d02fea55f..7534e7676 100644 --- a/Sharpmake/Solution.Configuration.cs +++ b/Sharpmake/Solution.Configuration.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake/Solution.cs b/Sharpmake/Solution.cs index 548c03a92..33da248ef 100644 --- a/Sharpmake/Solution.cs +++ b/Sharpmake/Solution.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake/SourceAttributeParser.cs b/Sharpmake/SourceAttributeParser.cs index db6362221..aa589ebeb 100644 --- a/Sharpmake/SourceAttributeParser.cs +++ b/Sharpmake/SourceAttributeParser.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2018-2019 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake/Strings.cs b/Sharpmake/Strings.cs index 7e00b2c5e..5720edb6a 100644 --- a/Sharpmake/Strings.cs +++ b/Sharpmake/Strings.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017, 2019 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake/Target.cs b/Sharpmake/Target.cs index 2d294e5c1..27a118808 100644 --- a/Sharpmake/Target.cs +++ b/Sharpmake/Target.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2021 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -85,23 +85,23 @@ public enum DevEnv [Fragment, Flags] public enum Platform { - win32 = 1 << 0, - win64 = 1 << 1, - anycpu = 1 << 2, - x360 = 1 << 3, - durango = 1 << 4, - ps3 = 1 << 5, - ps3spu = 1 << 6, - orbis = 1 << 7, - wii = 1 << 8, - wiiu = 1 << 9, - nx = 1 << 10, - nvshield = 1 << 11, - ctr = 1 << 12, - ios = 1 << 13, - android = 1 << 14, - linux = 1 << 15, - mac = 1 << 16, + win32 = 1 << 0, + win64 = 1 << 1, + anycpu = 1 << 2, + x360 = 1 << 3, + durango = 1 << 4, + ps3 = 1 << 5, + ps3spu = 1 << 6, + orbis = 1 << 7, + wii = 1 << 8, + wiiu = 1 << 9, + nx = 1 << 10, + nvshield = 1 << 11, + ctr = 1 << 12, + ios = 1 << 13, + android = 1 << 14, + linux = 1 << 15, + mac = 1 << 16, _reserved9 = 1 << 22, _reserved8 = 1 << 23, @@ -144,45 +144,59 @@ public enum DotNetFramework [Obsolete("Please use at least .net framework 3.5.", error: false)] v3 = v3_5, - v3_5 = 1 << 0, + v3_5 = 1 << 0, v3_5clientprofile = 1 << 1, - v4_0 = 1 << 2, - v4_5 = 1 << 3, - v4_5_1 = 1 << 4, - v4_5_2 = 1 << 5, + v4_0 = 1 << 2, + v4_5 = 1 << 3, + v4_5_1 = 1 << 4, + v4_5_2 = 1 << 5, v4_5clientprofile = 1 << 6, - v4_6 = 1 << 7, - v4_6_1 = 1 << 8, - v4_6_2 = 1 << 9, - v4_7 = 1 << 10, - v4_7_1 = 1 << 11, - v4_7_2 = 1 << 12, - v4_8 = 1 << 13, - netcore1_0 = 1 << 14, - netcore1_1 = 1 << 15, - netcore2_0 = 1 << 16, - netcore2_1 = 1 << 17, - netcore2_2 = 1 << 18, - netcore3_0 = 1 << 19, - netcore3_1 = 1 << 20, - netstandard1_0 = 1 << 21, - netstandard1_1 = 1 << 22, - netstandard1_2 = 1 << 23, - netstandard1_3 = 1 << 24, - netstandard1_4 = 1 << 25, - netstandard1_5 = 1 << 26, - netstandard1_6 = 1 << 27, - netstandard2_0 = 1 << 28, - netstandard2_1 = 1 << 29, + v4_6 = 1 << 7, + v4_6_1 = 1 << 8, + v4_6_2 = 1 << 9, + v4_7 = 1 << 10, + v4_7_1 = 1 << 11, + v4_7_2 = 1 << 12, + v4_8 = 1 << 13, + netcore1_0 = 1 << 14, + netcore1_1 = 1 << 15, + netcore2_0 = 1 << 16, + netcore2_1 = 1 << 17, + netcore2_2 = 1 << 18, + netcore3_0 = 1 << 19, + netcore3_1 = 1 << 20, + net5_0 = 1 << 21, + netstandard1_0 = 1 << 22, + netstandard1_1 = 1 << 23, + netstandard1_2 = 1 << 24, + netstandard1_3 = 1 << 25, + netstandard1_4 = 1 << 26, + netstandard1_5 = 1 << 27, + netstandard1_6 = 1 << 28, + netstandard2_0 = 1 << 29, + netstandard2_1 = 1 << 30, [CompositeFragment] all_netframework = v3_5 | v3_5clientprofile | v4_0 | v4_5 | v4_5_1 | v4_5_2 | v4_5clientprofile | v4_6 | v4_6_1 | v4_6_2 | v4_7 | v4_7_1 | v4_7_2 | v4_8, [CompositeFragment] - all_netcore = netcore1_0 | netcore1_1 | netcore2_0 | netcore2_1 | netcore3_0 | netcore3_1, + all_netcore = netcore1_0 | netcore1_1 | netcore2_0 | netcore2_1 | netcore3_0 | netcore3_1 | net5_0, [CompositeFragment] all_netstandard = netstandard1_0 | netstandard1_1 | netstandard1_2 | netstandard1_3 | netstandard1_4 | netstandard1_5 | netstandard1_6 | netstandard2_0 | netstandard2_1 } + // https://docs.microsoft.com/en-us/dotnet/standard/frameworks#net-5-os-specific-tfms + [Fragment, Flags] + public enum DotNetOS + { + Default = 1 << 0, + android = 1 << 1, + ios = 1 << 2, + macos = 1 << 3, + tvos = 1 << 4, + watchos = 1 << 5, + windows = 1 << 6 + } + // Optional [Fragment, Flags] public enum Blob diff --git a/Sharpmake/TrackedConfiguration.cs b/Sharpmake/TrackedConfiguration.cs index 01e5bf880..048329e8a 100644 --- a/Sharpmake/TrackedConfiguration.cs +++ b/Sharpmake/TrackedConfiguration.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017, 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake/TrackedProject.cs b/Sharpmake/TrackedProject.cs index 71c62a0a4..ac69929f3 100644 --- a/Sharpmake/TrackedProject.cs +++ b/Sharpmake/TrackedProject.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017, 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake/UniqueList.cs b/Sharpmake/UniqueList.cs index eefd5eb82..5cf768d03 100644 --- a/Sharpmake/UniqueList.cs +++ b/Sharpmake/UniqueList.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017, 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sharpmake/Util.cs b/Sharpmake/Util.cs index 78fb38ba8..539d45493 100644 --- a/Sharpmake/Util.cs +++ b/Sharpmake/Util.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2021 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -79,7 +79,7 @@ public static void PathMakeStandard(IList paths) public static string PathMakeStandard(string path) { - return PathMakeStandard(path, !Util.IsRunningInMono()); + return PathMakeStandard(path, !Util.IsRunningOnUnix()); } /// @@ -415,7 +415,7 @@ public static unsafe string SimplifyPath(string path) } else { - if (Util.IsRunningInMono() && + if (Util.IsRunningOnUnix() && index == 0 && currentChar == Path.DirectorySeparatorChar && Path.IsPathRooted(path)) pathHelper.Append(currentChar); @@ -585,6 +585,38 @@ internal static void ResolvePathAndFixCase(string root, ref IEnumerable paths = paths.Select(path => ResolvePathAndFixCase(root, path)); } + [Flags] + internal enum KeyValuePairResolveType + { + ResolveKey = 1 << 0, + ResolveValue = 1 << 1, + ResolveAll = ResolveKey | ResolveValue + } + + internal static void ResolvePathAndFixCase(string root, KeyValuePairResolveType resolveType, ref HashSet> paths) + { + if (paths.Count == 0) + return; + + foreach (var keyValuePair in paths.ToList()) + { + string key = keyValuePair.Key; + string value = keyValuePair.Value; + + if (resolveType.HasFlag(KeyValuePairResolveType.ResolveKey)) + key = ResolvePathAndFixCase(root, key); + + if (resolveType.HasFlag(KeyValuePairResolveType.ResolveValue)) + value = ResolvePathAndFixCase(root, value); + + if (keyValuePair.Key != key || keyValuePair.Value != value) + { + paths.Remove(keyValuePair); + paths.Add(new KeyValuePair(key, value)); + } + } + } + public static void ResolvePath(string root, ref Strings paths) { List sortedPaths = paths.Values; @@ -795,9 +827,6 @@ public static string GetCapitalizedPath(string path) return capitalizedPath; } - [System.Runtime.InteropServices.DllImport("msvcrt.dll", CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)] - private static extern int memcmp(byte[] b1, byte[] b2, long count); - private static bool AreStreamsEqual(Stream stream1, Stream stream2) { const int BufferSize = 4096; @@ -818,7 +847,7 @@ private static bool AreStreamsEqual(Stream stream1, Stream stream2) if (count1 == 0) return true; - if (memcmp(buffer1, buffer2, count1) != 0) + if (!buffer1.SequenceEqual(buffer2)) return false; } } @@ -1390,7 +1419,7 @@ private static int SequenceCompare(IEnumerable source1, IEnumerable source2) return 1; } // Both are still going, compare current elements - int comparison = Comparer.Default.Compare(iterator1.Current.ToString(), iterator2.Current.ToString()); + int comparison = string.CompareOrdinal(iterator1.Current.ToString(), iterator2.Current.ToString()); // If elements are non-equal, we're done if (comparison != 0) { @@ -1752,6 +1781,9 @@ public static bool IsVisualStudio2010Installed() private static bool IsVisualStudioInstalled(DevEnv devEnv) { + if (!GetExecutingPlatform().HasAnyFlag(Platform.win32 | Platform.win64)) + return false; + string registryKeyString = string.Format( @"SOFTWARE{0}\Microsoft\VisualStudio\SxS\VS7", Environment.Is64BitProcess ? @"\Wow6432Node" : string.Empty @@ -1962,7 +1994,7 @@ public static string GetVisualStudioInstallPathFromQuery( string[] requiredWorkloads = null ) { - if (IsRunningInMono()) + if (IsRunningOnUnix()) return null; var vsInstallations = GetVisualStudioInstallationsFromQuery(visualVersion, allowPrereleaseVersions, requiredComponents, requiredWorkloads); @@ -2355,21 +2387,25 @@ public static string GetRegistryLocalMachineSubKeyValue(string registrySubKey, s return registryValue; string key = string.Empty; - try + + if (GetExecutingPlatform().HasAnyFlag(Platform.win32 | Platform.win64)) { - using (RegistryKey localMachineKey = Registry.LocalMachine.OpenSubKey(registrySubKey)) + try { - if (localMachineKey != null) + using (RegistryKey localMachineKey = Registry.LocalMachine.OpenSubKey(registrySubKey)) { - key = (string)localMachineKey.GetValue(value); - if (enableLog && string.IsNullOrEmpty(key)) - LogWrite("Value '{0}' under registry subKey '{1}' is not set, fallback to default: '{2}'", value ?? "(Default)", registrySubKey, fallbackValue); + if (localMachineKey != null) + { + key = (string)localMachineKey.GetValue(value); + if (enableLog && string.IsNullOrEmpty(key)) + LogWrite("Value '{0}' under registry subKey '{1}' is not set, fallback to default: '{2}'", value ?? "(Default)", registrySubKey, fallbackValue); + } + else if (enableLog) + LogWrite("Registry subKey '{0}' is not found, fallback to default for value '{1}': '{2}'", registrySubKey, value ?? "(Default)", fallbackValue); } - else if (enableLog) - LogWrite("Registry subKey '{0}' is not found, fallback to default for value '{1}': '{2}'", registrySubKey, value ?? "(Default)", fallbackValue); } + catch { } } - catch { } if (string.IsNullOrEmpty(key)) key = fallbackValue; @@ -2455,40 +2491,45 @@ private int Parse(string version) private static readonly bool s_monoRuntimeExists = (Type.GetType("Mono.Runtime") != null); public static bool IsRunningInMono() => s_monoRuntimeExists; + private static readonly bool s_isUnix = RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX); + public static bool IsRunningOnUnix() => s_isUnix; + public static Platform GetExecutingPlatform() => s_executingPlatform; private static readonly Platform s_executingPlatform = DetectExecutingPlatform(); private static Platform DetectExecutingPlatform() { - switch (Environment.OSVersion.Platform) + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - case PlatformID.Win32Windows: - case PlatformID.Win32NT: - return (Environment.Is64BitOperatingSystem) ? Platform.win64 : Platform.win32; - case PlatformID.MacOSX: - return Platform.mac; - case PlatformID.Unix: // could be mac or linux - { - bool isMacOs = false; - try - { - var p = new System.Diagnostics.Process(); - p.StartInfo.UseShellExecute = false; - p.StartInfo.RedirectStandardOutput = true; - p.StartInfo.FileName = "uname"; - p.Start(); - string output = p.StandardOutput.ReadToEnd().Trim(); - p.WaitForExit(); - - isMacOs = string.CompareOrdinal(output, "Darwin") == 0; - } - catch { } + switch (RuntimeInformation.OSArchitecture) + { + case Architecture.X86: + return Platform.win32; + case Architecture.X64: + return Platform.win64; + default: + throw new NotSupportedException($"{RuntimeInformation.OSArchitecture} Architecture is not supported on Windows"); + } + } - return isMacOs ? Platform.mac : Platform.linux; - } + if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + return Platform.mac; } + + if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + { + return Platform.linux; + } + LogWrite("Warning: Couldn't determine running platform"); return Platform.win64; // arbitrary } + + private static readonly string s_framework = Assembly.GetEntryAssembly()?.GetCustomAttribute()?.FrameworkName; + private static readonly string s_frameworkDisplayName = Assembly.GetEntryAssembly()?.GetCustomAttribute()?.FrameworkDisplayName; + private static readonly bool s_isDotNetCore = s_framework != null && !s_framework.StartsWith(".NETFramework"); + public static string FrameworkDisplayName() => !string.IsNullOrEmpty(s_frameworkDisplayName) ? s_frameworkDisplayName : !string.IsNullOrEmpty(s_framework) ? s_framework : "Unknown"; + public static bool IsRunningDotNetCore() => s_isDotNetCore; } } diff --git a/UpdateSamplesOutput.bat b/UpdateSamplesOutput.bat index f7e9ae769..388e7dee3 100644 --- a/UpdateSamplesOutput.bat +++ b/UpdateSamplesOutput.bat @@ -7,6 +7,12 @@ COLOR call CompileSharpmake.bat Sharpmake.sln Debug "Any CPU" if %errorlevel% NEQ 0 goto error +set SHARPMAKE_EXECUTABLE=%~dp0tmp\bin\debug\Sharpmake.Application.exe +if not exist %SHARPMAKE_EXECUTABLE% set SHARPMAKE_EXECUTABLE=%~dp0tmp\bin\release\Sharpmake.Application.exe +if not exist %SHARPMAKE_EXECUTABLE% echo Cannot find sharpmake executable in %~dp0tmp\bin\[debug|release] & pause & goto error + +echo Using executable %SHARPMAKE_EXECUTABLE% + :: main set ERRORLEVEL_BACKUP=0 @@ -36,9 +42,9 @@ if not "%ERRORLEVEL_BACKUP%" == "0" goto error call :UpdateRef samples NetCore\DotNetCoreFrameworkHelloWorld HelloWorld.sharpmake.cs reference NetCore\DotNetCoreFrameworkHelloWorld if not "%ERRORLEVEL_BACKUP%" == "0" goto error -call :UpdateRef samples NetCore\DotNetFrameworkHelloWorld HelloWorld.sharpmake.cs reference NetCore\DotNetFrameworkHelloWorld +call :UpdateRef samples NetCore\DotNetFrameworkHelloWorld HelloWorld.sharpmake.cs reference NetCore\DotNetFrameworkHelloWorld if not "%ERRORLEVEL_BACKUP%" == "0" goto error -call :UpdateRef samples NetCore\DotNetMultiFrameworksHelloWorld HelloWorld.sharpmake.cs reference NetCore\DotNetMultiFrameworksHelloWorld +call :UpdateRef samples NetCore\DotNetMultiFrameworksHelloWorld HelloWorld.sharpmake.cs reference NetCore\DotNetMultiFrameworksHelloWorld if not "%ERRORLEVEL_BACKUP%" == "0" goto error :: functional tests @@ -62,15 +68,9 @@ pushd %CD% :: set testScopedCurrentDirectory as current cd /d %~dp0%~1 -set SHARPMAKE_EXECUTABLE=%~dp0bin\Debug\Sharpmake.Application.exe -if not exist %SHARPMAKE_EXECUTABLE% set SHARPMAKE_EXECUTABLE=%~dp0bin\Release\Sharpmake.Application.exe -if not exist %SHARPMAKE_EXECUTABLE% echo Cannot find sharpmake executable in %~dp0bin & pause & goto error - -echo Using executable %SHARPMAKE_EXECUTABLE% - echo Updating references of %2... rd /s /q "%~2\%~4" -call %SHARPMAKE_EXECUTABLE% "/sources(@"%~2\%~3") /outputdir(@"%~2\%~4") /remaproot(@"%~5") /verbose" +call %SHARPMAKE_EXECUTABLE% /sources(@'%~2\%~3') /outputdir(@'%~2\%~4') /remaproot(@'%~5') /verbose set ERRORLEVEL_BACKUP=%errorlevel% :: restore caller current directory popd diff --git a/bootstrap.bat b/bootstrap.bat index 02fbe61e2..2a642f399 100644 --- a/bootstrap.bat +++ b/bootstrap.bat @@ -1,4 +1,10 @@ @echo off +:: Batch arguments: +:: %~1 Main sharpmake file +:: %~2 Target(Normally should be Debug or Release) +:: if none are passed, defaults to Sharpmake.Main.sharpmake.cs and Debug + +setlocal enabledelayedexpansion :: Clear previous run status COLOR @@ -6,13 +12,18 @@ COLOR :: set batch file directory as current pushd "%~dp0" -set SHARPMAKE_EXECUTABLE=bin\debug\Sharpmake.Application.exe +set SHARPMAKE_OPTIM=Debug +if not "%~2" == "" ( + set SHARPMAKE_OPTIM=%~2 +) + +set SHARPMAKE_EXECUTABLE=tmp\bin\%SHARPMAKE_OPTIM%\Sharpmake.Application.exe -call CompileSharpmake.bat Sharpmake.Application/Sharpmake.Application.csproj Debug AnyCPU +call CompileSharpmake.bat Sharpmake.Application/Sharpmake.Application.csproj %SHARPMAKE_OPTIM% AnyCPU if %errorlevel% NEQ 0 goto error -set SHARPMAKE_MAIN="Sharpmake.Main.sharpmake.cs" +set SHARPMAKE_MAIN='Sharpmake.Main.sharpmake.cs' if not "%~1" == "" ( - set SHARPMAKE_MAIN="%~1" + set SHARPMAKE_MAIN='%~1' ) set SM_CMD=%SHARPMAKE_EXECUTABLE% /sources(%SHARPMAKE_MAIN%) /verbose diff --git a/bootstrap.sh b/bootstrap.sh index 7d46392a5..31b024708 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -1,4 +1,8 @@ #!/usr/bin/env bash +# Script arguments: +# %1: Main sharpmake file +# $2: Target(Normally should be Debug or Release) +# if arguments are omitted, defaults to Sharpmake.Main.sharpmake.cs and Debug function success { echo Bootstrap succeeded \! @@ -25,9 +29,11 @@ fi # workaround for https://github.com/mono/mono/issues/6752 TERM=xterm -SHARPMAKE_EXECUTABLE=$CURRENT_DIR/bin/debug/Sharpmake.Application.exe +SHARPMAKE_OPTIM=${2:-"debug"} -$CURRENT_DIR/CompileSharpmake.sh $CURRENT_DIR/Sharpmake.Application/Sharpmake.Application.csproj Debug AnyCPU +SHARPMAKE_EXECUTABLE=$CURRENT_DIR/tmp/bin/$SHARPMAKE_OPTIM/Sharpmake.Application.exe + +$CURRENT_DIR/CompileSharpmake.sh $CURRENT_DIR/Sharpmake.Application/Sharpmake.Application.csproj $SHARPMAKE_OPTIM AnyCPU if [ $? -ne 0 ]; then echo "The build has failed." if [ -f $SHARPMAKE_EXECUTABLE ]; then @@ -45,7 +51,7 @@ fi SHARPMAKE_MAIN=${1:-"$CURRENT_DIR/Sharpmake.Main.sharpmake.cs"} echo "Generating Sharpmake solution..." -SM_CMD="mono --debug \"${SHARPMAKE_EXECUTABLE}\" \"/sources(\\\"${SHARPMAKE_MAIN}\\\")\" /verbose" +SM_CMD="mono --debug \"${SHARPMAKE_EXECUTABLE}\" \"/sources('${SHARPMAKE_MAIN}') /verbose\"" echo $SM_CMD eval $SM_CMD || error diff --git a/deploy_binaries.py b/deploy_binaries.py index 63849660e..563689d60 100644 --- a/deploy_binaries.py +++ b/deploy_binaries.py @@ -64,7 +64,7 @@ sys.exit(-1) # Check if there are actual DLLs to copy, otherwise it must be compiled in VS. -if not os.path.isfile(os.path.join(root_dir, "bin/{}/Sharpmake.dll".format(config))): +if not os.path.isfile(os.path.join(root_dir, "tmp/bin/{}/sharpmake/Sharpmake.dll".format(config))): print("Please build Sharpmake in its {} configuration.".format(config)) sys.exit(1) @@ -74,7 +74,7 @@ ################################################################################ def copy_file(src): - if os.path.isfile(src) and os.path.normpath(os.path.dirname(src)) != os.path.normpath(target_dir): + if os.path.isfile(src) and os.path.normcase(os.path.normpath(os.path.dirname(src))) != os.path.normcase(os.path.normpath(target_dir)): print("Copying {} to {}".format(os.path.join(root_dir, src), target_dir)) shutil.copy2(src, target_dir) @@ -86,12 +86,12 @@ def __init__(self, name): def copy(self): # Copy the DLL. - dll_path = os.path.join(root_dir, "bin", config, self.name + ".dll") + dll_path = os.path.join(root_dir, "tmp", "bin", config, self.name, self.name + ".dll") copy_file(dll_path) copy_file(dll_path + ".config") # Copy the executable. - exe_path = os.path.join(root_dir, "bin", config, self.name + ".exe") + exe_path = os.path.join(root_dir, "tmp", "bin", config, self.name, self.name + ".exe") copy_file(exe_path) copy_file(exe_path + ".config") @@ -99,11 +99,11 @@ def copy(self): if deploy_pdb: copy_file(dll_path + ".mdb") copy_file(exe_path + ".mdb") - copy_file(os.path.join(root_dir, "bin", config, self.name + ".pdb")) + copy_file(os.path.join(root_dir, "tmp", "bin", config, self.name, self.name + ".pdb")) # Copy the XML API doc if it exists. if deploy_xmldoc: - copy_file(os.path.join(root_dir, "bin", config, self.name + ".xml")) + copy_file(os.path.join(root_dir, "tmp", "bin", config, self.name, self.name + ".xml")) def __str__(self): return self.name @@ -147,7 +147,7 @@ def __str__(self): site.copy() # Also copy the interop allowing the detection of visual studio -vs_interop = os.path.join(root_dir, "bin", config, "Microsoft.VisualStudio.Setup.Configuration.Interop.dll") +vs_interop = os.path.join(root_dir, "tmp", "bin", config, "sharpmake", "Microsoft.VisualStudio.Setup.Configuration.Interop.dll") if os.path.isfile(vs_interop): copy_file(vs_interop) diff --git a/functional_test.py b/functional_test.py index eda1ab170..0d8062873 100644 --- a/functional_test.py +++ b/functional_test.py @@ -5,6 +5,7 @@ # This script supports Python 3. import os.path +import platform import sys if os.name != "nt": @@ -15,7 +16,7 @@ class FunctionalTest(object): def __init__(self, directory, script_name, project_root = ""): self.directory = directory self.script_name = script_name - self.use_mono = os.name == "posix" + self.runs_on_unix = os.name == "posix" if project_root == "": self.project_root = directory else: @@ -28,12 +29,12 @@ def run_test(self): os.chdir(pwd) # Detects the path of the Sharpmake executable - sharpmake_path = find_target_path(os.path.join(entry_path, "bin"), "Sharpmake.Application.exe") + sharpmake_path = find_sharpmake_path() write_line("Using sharpmake " + sharpmake_path) # Builds the command line argument list. - sources = "/sources(@\"{}\")".format(os.path.join(self.directory, self.script_name)) + sources = "/sources(@\'{}\')".format(os.path.join(self.directory, self.script_name)) verbose = "/verbose" args = [ @@ -41,11 +42,9 @@ def run_test(self): verbose ] - if self.use_mono: - args_string = "\" \"".join([arg.replace('"','\\"') for arg in args]) - cmd_line = "mono --debug {} \"{}\"".format(sharpmake_path, args_string) - else: - cmd_line = "{} \"{}\"".format(sharpmake_path, " ".join(args)) + cmd_line = "{} \"{}\"".format(sharpmake_path, " ".join(args)) + if self.runs_on_unix: + cmd_line = "mono --debug " + cmd_line generation_exit_code = os.system(cmd_line) @@ -95,7 +94,7 @@ def verifyCustomBuildEventsInTargetDir(self, targetDir): def verifyCustomBuildEvents(self, projectDir): output_dir = os.path.join(projectDir, self.directory, "projects", "output") - target_dirs = ["debug_fastbuild_noblob_vs2017", "debug_fastbuild_vs2017", "release_fastbuild_noblob_vs2017", "release_fastbuild_vs2017"] + target_dirs = ["debug_fastbuild_noblob_vs2019", "debug_fastbuild_vs2019", "release_fastbuild_noblob_vs2019", "release_fastbuild_vs2019"] for target_dir in target_dirs: target_dir = os.path.join(output_dir, target_dir) @@ -130,7 +129,9 @@ def build(self, projectDir): def build_with_fastbuild(root_dir, test_dir): entry_path = os.getcwd() - fastBuildPath = os.path.join(entry_path, "tools", "FastBuild", "FBuild.exe"); + platformSystem = platform.system() + fastBuildInfo = ("Linux-x64", "fbuild") if platformSystem == "Linux" else ("OSX-x64", "FBuild") if platformSystem == "Darwin" else ("Windows-x64", "FBuild.exe") + fastBuildPath = os.path.join(entry_path, "tools", "FastBuild", fastBuildInfo[0], fastBuildInfo[1]); if not os.path.isfile(fastBuildPath): return -1 @@ -142,10 +143,10 @@ def build_with_fastbuild(root_dir, test_dir): write_line("Working dir: " + working_dir) return os.system(cmd_line) -def find_target_path(directory, target): +def find_sharpmake_path(): optim_tokens = ["debug", "release"] for optim_token in optim_tokens: - path = os.path.abspath(os.path.join(directory, optim_token, target)) + path = os.path.abspath(os.path.join("..", "tmp", "bin", optim_token, "Sharpmake.Application.exe")) if os.path.isfile(path): return path @@ -163,6 +164,10 @@ def red_bg(): def green_bg(): if os.name == "nt": os.system("color 2F") + +def black_bg(): + if os.name == "nt": + os.system("color 0F") def pause(timeout=None): if timeout is None: @@ -216,5 +221,6 @@ def launch_functional_tests(): finally: os.chdir(entry_path) +black_bg() exit_code = launch_functional_tests() sys.exit(exit_code) diff --git a/regression_test.py b/regression_test.py index da313ebe9..f1703004f 100644 --- a/regression_test.py +++ b/regression_test.py @@ -16,7 +16,7 @@ def __init__(self, directory, script_name, project_root = ""): self.directory = directory self.assembly = directory + ".dll" # same name as the directory for now self.script_name = script_name - self.use_mono = os.name == "posix" + self.runs_on_unix = os.name == "posix" if project_root == "": self.project_root = directory else: @@ -29,17 +29,17 @@ def run_test(self, as_source): os.chdir(pwd) # Detects the path of the Sharpmake executable - sharpmake_path = find_target_path(self.directory, "Sharpmake.Application.exe") + sharpmake_path = find_sharpmake_path() write_line("Using sharpmake " + sharpmake_path) # Builds the command line argument list. - sources = "/sources(@\"{}\")".format(os.path.join(self.directory, self.script_name)) - assemblies = "/assemblies(@\"{}\")".format(find_target_path(self.directory, self.assembly)) - referencedir = "/referencedir(@\"{}\")".format(os.path.join(self.directory, "reference")) - outputdir = "/outputdir(@\"{}\")".format(os.path.join(self.directory, "projects")) - remaproot = "/remaproot(@\"{}\")".format(self.project_root) - test = "/test(@\"Regression\")" + sources = "/sources(@\'{}\')".format(os.path.join(self.directory, self.script_name)) + assemblies = "/assemblies(@\'{}\')".format(find_assembly_path(self.directory, self.assembly)) + referencedir = "/referencedir(@\'{}\')".format(os.path.join(self.directory, "reference")) + outputdir = "/outputdir(@\'{}\')".format(os.path.join(self.directory, "projects")) + remaproot = "/remaproot(@\'{}\')".format(self.project_root) + test = "/test(@\'Regression\')" verbose = "/verbose" args = [ @@ -51,11 +51,9 @@ def run_test(self, as_source): verbose ] - if self.use_mono: - args_string = "\" \"".join([arg.replace('"','\\"') for arg in args]) - cmd_line = "mono --debug {} \"{}\"".format(sharpmake_path, args_string) - else: - cmd_line = "{} \"{}\"".format(sharpmake_path, " ".join(args)) + cmd_line = "{} \"{}\"".format(sharpmake_path, " ".join(args)) + if self.runs_on_unix: + cmd_line = "mono --debug " + cmd_line return os.system(cmd_line) @@ -78,10 +76,16 @@ def run_test(self, as_source): Test("SimpleExeLibDependency", "SimpleExeLibDependency.sharpmake.cs") ] -def find_target_path(directory, target): +def find_sharpmake_path(): + return find_target_path("bin", '', "Sharpmake.Application.exe") + +def find_assembly_path(directory, target): + return find_target_path("samples", directory, target) + +def find_target_path(root_directory, subdirectory, target): optim_tokens = ["debug", "release"] for optim_token in optim_tokens: - path = os.path.abspath(os.path.join("..", "bin", optim_token, "samples", target)) + path = os.path.abspath(os.path.join("..", "tmp", root_directory, optim_token, subdirectory, target)) if os.path.isfile(path): return path @@ -99,11 +103,11 @@ def red_bg(): def green_bg(): if os.name == "nt": os.system("color 2F") - + def black_bg(): if os.name == "nt": os.system("color 0F") - + def pause(timeout=None): if timeout is None: diff --git a/samples/CPPCLI/CLRTest.sharpmake.cs b/samples/CPPCLI/CLRTest.sharpmake.cs index d1367c3fc..d90ec3c18 100644 --- a/samples/CPPCLI/CLRTest.sharpmake.cs +++ b/samples/CPPCLI/CLRTest.sharpmake.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017, 2019 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/CPPCLI/Properties/AssemblyInfo.cs b/samples/CPPCLI/Properties/AssemblyInfo.cs index 1e4de0b60..ef55d1c36 100644 --- a/samples/CPPCLI/Properties/AssemblyInfo.cs +++ b/samples/CPPCLI/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017, 2019 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/CPPCLI/codebase/OtherCSharpProj/Properties/AssemblyInfo.cs b/samples/CPPCLI/codebase/OtherCSharpProj/Properties/AssemblyInfo.cs index 589f5483e..2274af5d8 100644 --- a/samples/CPPCLI/codebase/OtherCSharpProj/Properties/AssemblyInfo.cs +++ b/samples/CPPCLI/codebase/OtherCSharpProj/Properties/AssemblyInfo.cs @@ -10,7 +10,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Ubisoft")] [assembly: AssemblyProduct("OtherCSharpProj")] -[assembly: AssemblyCopyright("Copyright © Ubisoft 2019")] +[assembly: AssemblyCopyright("Copyright © Ubisoft 2017, 2019")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/samples/CPPCLI/codebase/TestCSharpConsole/Properties/AssemblyInfo.cs b/samples/CPPCLI/codebase/TestCSharpConsole/Properties/AssemblyInfo.cs index 25177a5c2..75f0686f1 100644 --- a/samples/CPPCLI/codebase/TestCSharpConsole/Properties/AssemblyInfo.cs +++ b/samples/CPPCLI/codebase/TestCSharpConsole/Properties/AssemblyInfo.cs @@ -10,7 +10,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Ubisoft")] [assembly: AssemblyProduct("TestCSharpConsole")] -[assembly: AssemblyCopyright("Copyright © Ubisoft 2019")] +[assembly: AssemblyCopyright("Copyright © Ubisoft 2017, 2019")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/samples/CPPCLI/projects.sharpmake.cs b/samples/CPPCLI/projects.sharpmake.cs index 7f49f04b8..5cc76982a 100644 --- a/samples/CPPCLI/projects.sharpmake.cs +++ b/samples/CPPCLI/projects.sharpmake.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017, 2019 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/CSharpHelloWorld/HelloWorld.sharpmake.cs b/samples/CSharpHelloWorld/HelloWorld.sharpmake.cs index 848e9cf02..e68d8dcc8 100644 --- a/samples/CSharpHelloWorld/HelloWorld.sharpmake.cs +++ b/samples/CSharpHelloWorld/HelloWorld.sharpmake.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017, 2019 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/CSharpHelloWorld/codebase/HelloWorld/Properties/AssemblyInfo.cs b/samples/CSharpHelloWorld/codebase/HelloWorld/Properties/AssemblyInfo.cs index f0f99af14..e0b5191a1 100644 --- a/samples/CSharpHelloWorld/codebase/HelloWorld/Properties/AssemblyInfo.cs +++ b/samples/CSharpHelloWorld/codebase/HelloWorld/Properties/AssemblyInfo.cs @@ -10,7 +10,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Ubisoft")] [assembly: AssemblyProduct("ExampleCodeProject")] -[assembly: AssemblyCopyright("Copyright © Ubisoft 2019")] +[assembly: AssemblyCopyright("Copyright © Ubisoft 2017, 2019")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/samples/CSharpHelloWorld/common.sharpmake.cs b/samples/CSharpHelloWorld/common.sharpmake.cs index e7a4b149e..48f5721db 100644 --- a/samples/CSharpHelloWorld/common.sharpmake.cs +++ b/samples/CSharpHelloWorld/common.sharpmake.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017, 2019-2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/CSharpImports/CSharpImports.sharpmake.cs b/samples/CSharpImports/CSharpImports.sharpmake.cs index 2dff2374e..550aedeb2 100644 --- a/samples/CSharpImports/CSharpImports.sharpmake.cs +++ b/samples/CSharpImports/CSharpImports.sharpmake.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2019 Ubisoft Entertainment +// Copyright (c) 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/CSharpImports/codebase/CSharpImports/Properties/AssemblyInfo.cs b/samples/CSharpImports/codebase/CSharpImports/Properties/AssemblyInfo.cs index f0f99af14..500276595 100644 --- a/samples/CSharpImports/codebase/CSharpImports/Properties/AssemblyInfo.cs +++ b/samples/CSharpImports/codebase/CSharpImports/Properties/AssemblyInfo.cs @@ -10,7 +10,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Ubisoft")] [assembly: AssemblyProduct("ExampleCodeProject")] -[assembly: AssemblyCopyright("Copyright © Ubisoft 2019")] +[assembly: AssemblyCopyright("Copyright © Ubisoft 2020")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/samples/CSharpImports/common.sharpmake.cs b/samples/CSharpImports/common.sharpmake.cs index e7a4b149e..ed1a6692a 100644 --- a/samples/CSharpImports/common.sharpmake.cs +++ b/samples/CSharpImports/common.sharpmake.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/CSharpVsix/CSharpVsix.sharpmake.cs b/samples/CSharpVsix/CSharpVsix.sharpmake.cs index 52f257e8b..a5d1fca2f 100644 --- a/samples/CSharpVsix/CSharpVsix.sharpmake.cs +++ b/samples/CSharpVsix/CSharpVsix.sharpmake.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2019 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/CSharpVsix/codebase/CSharpVsix/Properties/AssemblyInfo.cs b/samples/CSharpVsix/codebase/CSharpVsix/Properties/AssemblyInfo.cs index 634cd2013..cebdbc655 100644 --- a/samples/CSharpVsix/codebase/CSharpVsix/Properties/AssemblyInfo.cs +++ b/samples/CSharpVsix/codebase/CSharpVsix/Properties/AssemblyInfo.cs @@ -10,7 +10,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Ubisoft")] [assembly: AssemblyProduct("CSharpVsix")] -[assembly: AssemblyCopyright("Copyright © Ubisoft 2019")] +[assembly: AssemblyCopyright("Copyright © Ubisoft 2017, 2019")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/samples/CSharpVsix/common.sharpmake.cs b/samples/CSharpVsix/common.sharpmake.cs index 08d997b14..358f0ccbe 100644 --- a/samples/CSharpVsix/common.sharpmake.cs +++ b/samples/CSharpVsix/common.sharpmake.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017, 2019 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/CSharpWCF/CSharpWCF.sharpmake.cs b/samples/CSharpWCF/CSharpWCF.sharpmake.cs index 3c54c5cec..cfecab3ae 100644 --- a/samples/CSharpWCF/CSharpWCF.sharpmake.cs +++ b/samples/CSharpWCF/CSharpWCF.sharpmake.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2018-2019 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/CSharpWCF/codebase/CSharpWCF/Properties/AssemblyInfo.cs b/samples/CSharpWCF/codebase/CSharpWCF/Properties/AssemblyInfo.cs index 48f1cd705..afb46a1ad 100644 --- a/samples/CSharpWCF/codebase/CSharpWCF/Properties/AssemblyInfo.cs +++ b/samples/CSharpWCF/codebase/CSharpWCF/Properties/AssemblyInfo.cs @@ -10,7 +10,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Ubisoft")] [assembly: AssemblyProduct("CSharpWCF")] -[assembly: AssemblyCopyright("Copyright © Ubisoft 2019")] +[assembly: AssemblyCopyright("Copyright © Ubisoft 2018-2019")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/samples/CSharpWCF/codebase/CSharpWCFApp/Properties/AssemblyInfo.cs b/samples/CSharpWCF/codebase/CSharpWCFApp/Properties/AssemblyInfo.cs index f4500a8e5..df3c595fa 100644 --- a/samples/CSharpWCF/codebase/CSharpWCFApp/Properties/AssemblyInfo.cs +++ b/samples/CSharpWCF/codebase/CSharpWCFApp/Properties/AssemblyInfo.cs @@ -10,7 +10,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Ubisoft")] [assembly: AssemblyProduct("CSharpWCFApp")] -[assembly: AssemblyCopyright("Copyright © Ubisoft 2019")] +[assembly: AssemblyCopyright("Copyright © Ubisoft 2018-2019")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/samples/CSharpWCF/common.sharpmake.cs b/samples/CSharpWCF/common.sharpmake.cs index 08d997b14..df0d7f756 100644 --- a/samples/CSharpWCF/common.sharpmake.cs +++ b/samples/CSharpWCF/common.sharpmake.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2018-2019 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/CompileCommandDatabase/CompileCommandDatabase.sharpmake.cs b/samples/CompileCommandDatabase/CompileCommandDatabase.sharpmake.cs index 77eb19705..69f430436 100644 --- a/samples/CompileCommandDatabase/CompileCommandDatabase.sharpmake.cs +++ b/samples/CompileCommandDatabase/CompileCommandDatabase.sharpmake.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2019 Ubisoft Entertainment +// Copyright (c) 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/ConfigureOrder/ConfigureOrdering.sharpmake.cs b/samples/ConfigureOrder/ConfigureOrdering.sharpmake.cs index d8dc8a0c5..13446da17 100644 --- a/samples/ConfigureOrder/ConfigureOrdering.sharpmake.cs +++ b/samples/ConfigureOrder/ConfigureOrdering.sharpmake.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017, 2019 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/ConfigureOrder/Properties/AssemblyInfo.cs b/samples/ConfigureOrder/Properties/AssemblyInfo.cs index 2eeb7ada2..ecd8ea569 100644 --- a/samples/ConfigureOrder/Properties/AssemblyInfo.cs +++ b/samples/ConfigureOrder/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017, 2019 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/ConfigureOrder/Util.sharpmake.cs b/samples/ConfigureOrder/Util.sharpmake.cs index a93e5017b..ec951ed34 100644 --- a/samples/ConfigureOrder/Util.sharpmake.cs +++ b/samples/ConfigureOrder/Util.sharpmake.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017, 2019 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/ConfigureOrder/main.sharpmake.cs b/samples/ConfigureOrder/main.sharpmake.cs index 909daa704..31802822d 100644 --- a/samples/ConfigureOrder/main.sharpmake.cs +++ b/samples/ConfigureOrder/main.sharpmake.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017, 2019-2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/ConfigureOrder/reference/projects/configureorderingsolution.sln b/samples/ConfigureOrder/reference/projects/configureorderingsolution.sln index 7477b8a89..78561cc37 100644 --- a/samples/ConfigureOrder/reference/projects/configureorderingsolution.sln +++ b/samples/ConfigureOrder/reference/projects/configureorderingsolution.sln @@ -1,9 +1,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FooBarProject", "foobarproject.vcxproj", "{4D10CB07-4E09-3F8E-412E-E6DA311CC3C5}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ChildProject", "childproject.vcxproj", "{BBE4416F-6E16-43B4-BFB1-D83310280DEE}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FooBarProject", "foobarproject.vcxproj", "{4D10CB07-4E09-3F8E-412E-E6DA311CC3C5}" +EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ParentProject", "parentproject.vcxproj", "{A793E67F-D67F-638E-6588-C6073FAFCF8E}" EndProject Global @@ -11,10 +11,10 @@ Global Release|Win32 = Release|Win32 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {4D10CB07-4E09-3F8E-412E-E6DA311CC3C5}.Release|Win32.ActiveCfg = Release|Win32 - {4D10CB07-4E09-3F8E-412E-E6DA311CC3C5}.Release|Win32.Build.0 = Release|Win32 {BBE4416F-6E16-43B4-BFB1-D83310280DEE}.Release|Win32.ActiveCfg = Release|Win32 {BBE4416F-6E16-43B4-BFB1-D83310280DEE}.Release|Win32.Build.0 = Release|Win32 + {4D10CB07-4E09-3F8E-412E-E6DA311CC3C5}.Release|Win32.ActiveCfg = Release|Win32 + {4D10CB07-4E09-3F8E-412E-E6DA311CC3C5}.Release|Win32.Build.0 = Release|Win32 {A793E67F-D67F-638E-6588-C6073FAFCF8E}.Release|Win32.ActiveCfg = Release|Win32 {A793E67F-D67F-638E-6588-C6073FAFCF8E}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection diff --git a/samples/FastBuildSimpleExecutable/FastBuildSimpleExecutable.sharpmake.cs b/samples/FastBuildSimpleExecutable/FastBuildSimpleExecutable.sharpmake.cs index 791bb0e13..12bc35078 100644 --- a/samples/FastBuildSimpleExecutable/FastBuildSimpleExecutable.sharpmake.cs +++ b/samples/FastBuildSimpleExecutable/FastBuildSimpleExecutable.sharpmake.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2019, 2021 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -79,7 +79,7 @@ public void ConfigureAll(Configuration conf, Target target) [Sharpmake.Main] public static void SharpmakeMain(Sharpmake.Arguments arguments) { - FastBuildSettings.FastBuildMakeCommand = @"tools\FastBuild\FBuild.exe"; + FastBuildSettings.FastBuildMakeCommand = @"tools\FastBuild\Windows-x64\FBuild.exe"; arguments.Generate(); } diff --git a/samples/FastBuildSimpleExecutable/Properties/AssemblyInfo.cs b/samples/FastBuildSimpleExecutable/Properties/AssemblyInfo.cs index 0b3fe9e0c..d47c23981 100644 --- a/samples/FastBuildSimpleExecutable/Properties/AssemblyInfo.cs +++ b/samples/FastBuildSimpleExecutable/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2019 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/HelloLinux/HelloLinux.CommonProject.sharpmake.cs b/samples/HelloLinux/HelloLinux.CommonProject.sharpmake.cs new file mode 100644 index 000000000..4d3ad1cac --- /dev/null +++ b/samples/HelloLinux/HelloLinux.CommonProject.sharpmake.cs @@ -0,0 +1,136 @@ +// Copyright (c) 2020-2021 Ubisoft Entertainment +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System.IO; +using System.Linq; +using Sharpmake; + +namespace HelloLinux +{ + public static class ConfigurePriorities + { + public const int All = -75; + public const int Platform = -50; + public const int Optimization = -25; + /* SHARPMAKE DEFAULT IS 0 */ + public const int Blobbing = 10; + public const int BuildSystem = 30; + } + + public abstract class CommonProject : Sharpmake.Project + { + protected CommonProject() + : base(typeof(CommonTarget)) + { + RootPath = Globals.RootDirectory; + IsFileNameToLower = false; + IsTargetFileNameToLower = false; + + SourceRootPath = @"[project.RootPath]\[project.Name]"; + } + + [ConfigurePriority(ConfigurePriorities.All)] + [Configure] + public virtual void ConfigureAll(Configuration conf, CommonTarget target) + { + conf.ProjectFileName = "[project.Name]_[target.Platform]"; + if (target.DevEnv != DevEnv.xcode4ios) + conf.ProjectFileName += "_[target.DevEnv]"; + conf.ProjectPath = Path.Combine(Globals.TmpDirectory, @"projects\[project.Name]"); + conf.IsFastBuild = target.BuildSystem == BuildSystem.FastBuild; + + conf.IntermediatePath = Path.Combine(Globals.TmpDirectory, @"obj\[target.DirectoryName]\[project.Name]"); + conf.TargetPath = Path.Combine(Globals.OutputDirectory, "[target.DirectoryName]"); + + // Note: uncomment the following line if we port this sample to windows + //conf.TargetLibraryPath = conf.IntermediatePath; // .lib files must be with the .obj files when running in fastbuild distributed mode or we'll have missing symbols due to merging of the .pdb + conf.TargetLibraryPath = Path.Combine(Globals.TmpDirectory, @"lib\[target.DirectoryName]\[project.Name]"); + + // TODO: uncomment and fix this. Didn't find a way to have product with + // different names per configurations to work properly... + //conf.TargetFileName += "_" + target.Optimization.ToString().ToLowerInvariant().First(); // suffix with lowered first letter of optim + //if (conf.IsFastBuild) + //conf.TargetFileName += "x"; + + conf.Output = Configuration.OutputType.Lib; // defaults to creating static libs + } + + //////////////////////////////////////////////////////////////////////// + #region Platfoms + [ConfigurePriority(ConfigurePriorities.Platform)] + [Configure(Platform.linux)] + public virtual void ConfigureLinux(Configuration conf, CommonTarget target) + { + } + #endregion + //////////////////////////////////////////////////////////////////////// + + //////////////////////////////////////////////////////////////////////// + #region Optimizations + [ConfigurePriority(ConfigurePriorities.Optimization)] + [Configure(Optimization.Debug)] + public virtual void ConfigureDebug(Configuration conf, CommonTarget target) + { + conf.DefaultOption = Options.DefaultTarget.Debug; + } + + [ConfigurePriority(ConfigurePriorities.Optimization)] + [Configure(Optimization.Release)] + public virtual void ConfigureRelease(Configuration conf, CommonTarget target) + { + conf.DefaultOption = Options.DefaultTarget.Release; + } + #endregion + //////////////////////////////////////////////////////////////////////// + + //////////////////////////////////////////////////////////////////////// + #region Blobs and unitys + [Configure(Blob.FastBuildUnitys)] + [ConfigurePriority(ConfigurePriorities.Blobbing)] + public virtual void FastBuildUnitys(Configuration conf, CommonTarget target) + { + conf.FastBuildBlobbed = true; + conf.FastBuildUnityPath = Path.Combine(Globals.TmpDirectory, @"unity\[project.Name]"); + conf.IncludeBlobbedSourceFiles = false; + conf.IsBlobbed = false; + } + + [Configure(Blob.NoBlob)] + [ConfigurePriority(ConfigurePriorities.Blobbing)] + public virtual void BlobNoBlob(Configuration conf, CommonTarget target) + { + conf.FastBuildBlobbed = false; + conf.IsBlobbed = false; + + if (conf.IsFastBuild) + conf.ProjectName += "_NoBlob"; + } + #endregion + //////////////////////////////////////////////////////////////////////// + + //////////////////////////////////////////////////////////////////////// + #region Compilers and toolchains + [ConfigurePriority(ConfigurePriorities.BuildSystem)] + [Configure(BuildSystem.FastBuild)] + public virtual void ConfigureFastBuild(Configuration conf, CommonTarget target) + { + conf.SolutionFolder = "FastBuild/" + conf.SolutionFolder; + conf.ProjectName += "_FastBuild"; + + conf.Defines.Add("USES_FASTBUILD"); + } + #endregion + //////////////////////////////////////////////////////////////////////// + } +} diff --git a/samples/HelloLinux/HelloLinux.CommonSolution.sharpmake.cs b/samples/HelloLinux/HelloLinux.CommonSolution.sharpmake.cs new file mode 100644 index 000000000..30319918c --- /dev/null +++ b/samples/HelloLinux/HelloLinux.CommonSolution.sharpmake.cs @@ -0,0 +1,38 @@ +// Copyright (c) 2020 Ubisoft Entertainment +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using Sharpmake; + +namespace HelloLinux +{ + public class CommonSolution : Sharpmake.Solution + { + public CommonSolution() + : base(typeof(CommonTarget)) + { + IsFileNameToLower = false; + } + + [ConfigurePriority(ConfigurePriorities.All)] + [Configure] + public virtual void ConfigureAll(Configuration conf, CommonTarget target) + { + conf.SolutionFileName = "[solution.Name]_[target.Platform]"; + if (target.DevEnv != DevEnv.xcode4ios) + conf.SolutionFileName += "_[target.DevEnv]"; + conf.PlatformName = "[target.SolutionPlatformName]"; + conf.SolutionPath = System.IO.Path.Combine(Globals.TmpDirectory, "solutions"); + } + } +} diff --git a/samples/HelloLinux/HelloLinux.CommonTarget.sharpmake.cs b/samples/HelloLinux/HelloLinux.CommonTarget.sharpmake.cs new file mode 100644 index 000000000..9d37391c4 --- /dev/null +++ b/samples/HelloLinux/HelloLinux.CommonTarget.sharpmake.cs @@ -0,0 +1,152 @@ +// Copyright (c) 2020 Ubisoft Entertainment +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using Sharpmake; + +namespace HelloLinux +{ + [Fragment, Flags] + public enum Optimization + { + Debug = 1 << 0, + Release = 1 << 1 + } + + [Fragment, Flags] + public enum BuildSystem + { + Default = 1 << 0, + FastBuild = 1 << 1, + } + + [DebuggerDisplay("\"{Platform}_{DevEnv}\" {Name}")] + public class CommonTarget : Sharpmake.ITarget + { + public Platform Platform; + public DevEnv DevEnv; + public Optimization Optimization; + public Blob Blob; + public BuildSystem BuildSystem; + + public CommonTarget() { } + + public CommonTarget( + Platform platform, + DevEnv devEnv, + Optimization optimization, + Blob blob, + BuildSystem buildSystem + ) + { + Platform = platform; + DevEnv = devEnv; + Optimization = optimization; + Blob = blob; + BuildSystem = buildSystem; + } + + public override string Name + { + get + { + var nameParts = new List(); + + nameParts.Add(Optimization.ToString().ToLowerInvariant()); + + return string.Join(" ", nameParts); + } + } + + public string SolutionPlatformName + { + get + { + var nameParts = new List(); + + nameParts.Add(BuildSystem.ToString()); + + if (BuildSystem == BuildSystem.FastBuild && Blob == Blob.NoBlob) + nameParts.Add(Blob.ToString()); + + return string.Join("_", nameParts); + } + } + + /// + /// returns a string usable as a directory name, to use for instance for the intermediate path + /// + public string DirectoryName + { + get + { + var dirNameParts = new List(); + + dirNameParts.Add(Platform.ToString()); + dirNameParts.Add(Optimization.ToString()); + + if (BuildSystem == BuildSystem.FastBuild) + dirNameParts.Add(BuildSystem.ToString()); + + return string.Join("_", dirNameParts); + } + } + + public override Sharpmake.Optimization GetOptimization() + { + switch (Optimization) + { + case Optimization.Debug: + return Sharpmake.Optimization.Debug; + case Optimization.Release: + return Sharpmake.Optimization.Release; + default: + throw new NotSupportedException("Optimization value " + Optimization.ToString()); + } + } + + public override Platform GetPlatform() + { + return Platform; + } + + public static CommonTarget[] GetDefaultTargets() + { + var result = new List(); + result.AddRange(GetLinuxTargets()); + return result.ToArray(); + } + + public static CommonTarget[] GetLinuxTargets() + { + var defaultTarget = new CommonTarget( + Platform.linux, + DevEnv.make, + Optimization.Debug | Optimization.Release, + Blob.NoBlob, + BuildSystem.Default + ); + + // make a fastbuild version of the target + var fastBuildTarget = (CommonTarget)defaultTarget.Clone( + Blob.FastBuildUnitys, + BuildSystem.FastBuild + ); + + return new[] { defaultTarget }; + } + } +} diff --git a/samples/HelloLinux/HelloLinux.Main.sharpmake.cs b/samples/HelloLinux/HelloLinux.Main.sharpmake.cs new file mode 100644 index 000000000..adf37f3d0 --- /dev/null +++ b/samples/HelloLinux/HelloLinux.Main.sharpmake.cs @@ -0,0 +1,94 @@ +// Copyright (c) 2020-2021 Ubisoft Entertainment +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Threading.Tasks; +using Sharpmake; +using Sharpmake.Generators.FastBuild; + +[module: Sharpmake.DebugProjectName("Sharpmake.HelloLinux")] + +[module: Sharpmake.Include("HelloLinux.*.sharpmake.cs")] +[module: Sharpmake.Include("codebase/*.sharpmake.cs")] +[module: Sharpmake.Include("codebase/*/*.sharpmake.cs")] + +namespace HelloLinux +{ + public static class Globals + { + // branch root path relative to current sharpmake file location + public const string RelativeRootPath = @".\codebase"; + public static string RootDirectory; + public static string TmpDirectory { get { return Path.Combine(RootDirectory, "temp"); } } + public static string OutputDirectory { get { return Path.Combine(TmpDirectory, "bin"); } } + } + + public static class Main + { + private static void ConfigureRootDirectory() + { + FileInfo fileInfo = Util.GetCurrentSharpmakeFileInfo(); + string rootDirectory = Path.Combine(fileInfo.DirectoryName, Globals.RelativeRootPath); + Globals.RootDirectory = Util.SimplifyPath(rootDirectory); + } + + private static void ConfigureAutoCleanup() + { + Util.FilesAutoCleanupActive = true; + Util.FilesAutoCleanupDBPath = Path.Combine(Globals.TmpDirectory, "sharpmake"); + + if (!Directory.Exists(Util.FilesAutoCleanupDBPath)) + Directory.CreateDirectory(Util.FilesAutoCleanupDBPath); + } + + [Sharpmake.Main] + public static void SharpmakeMain(Sharpmake.Arguments arguments) + { + ConfigureRootDirectory(); + ConfigureAutoCleanup(); + + FastBuildSettings.FastBuildWait = true; + FastBuildSettings.FastBuildSummary = false; + FastBuildSettings.FastBuildNoSummaryOnError = true; + FastBuildSettings.FastBuildDistribution = false; + FastBuildSettings.FastBuildMonitor = true; + FastBuildSettings.FastBuildAllowDBMigration = true; + + // for the purpose of this sample, we'll reuse the FastBuild executables that live in the sharpmake source repo + string sharpmakeFastBuildDir = Util.PathGetAbsolute(Globals.RootDirectory, @"..\..\..\tools\FastBuild"); + switch (Util.GetExecutingPlatform()) + { + case Platform.linux: + FastBuildSettings.FastBuildMakeCommand = Path.Combine(sharpmakeFastBuildDir, "Linux-x64", "fbuild"); + break; + case Platform.mac: + FastBuildSettings.FastBuildMakeCommand = Path.Combine(sharpmakeFastBuildDir, "OSX-x64", "FBuild"); + break; + case Platform.win64: + default: + FastBuildSettings.FastBuildMakeCommand = Path.Combine(sharpmakeFastBuildDir, "Windows-x64", "FBuild.exe"); + break; + } + + Bff.UnityResolver = new Bff.FragmentUnityResolver(); + + foreach (Type solutionType in Assembly.GetExecutingAssembly().GetTypes().Where(t => !t.IsAbstract && t.IsSubclassOf(typeof(CommonSolution)))) + arguments.Generate(solutionType); + } + } +} diff --git a/samples/HelloLinux/Properties/AssemblyInfo.cs b/samples/HelloLinux/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..db1978b0d --- /dev/null +++ b/samples/HelloLinux/Properties/AssemblyInfo.cs @@ -0,0 +1,47 @@ +// Copyright (c) 2020 Ubisoft Entertainment +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("HelloLinux.Properties")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Ubisoft")] +[assembly: AssemblyProduct("HelloLinux.Properties")] +[assembly: AssemblyCopyright("Copyright \u00A9 Ubisoft 2020")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("CC6018D5-0760-463E-92FB-849E7E904449")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/samples/HelloLinux/codebase/HelloXCode.sharpmake.cs b/samples/HelloLinux/codebase/HelloXCode.sharpmake.cs new file mode 100644 index 000000000..4555106c8 --- /dev/null +++ b/samples/HelloLinux/codebase/HelloXCode.sharpmake.cs @@ -0,0 +1,38 @@ +// Copyright (c) 2020 Ubisoft Entertainment +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using Sharpmake; + +namespace HelloLinux +{ + [Sharpmake.Generate] + public class HelloLinuxSolution : CommonSolution + { + public HelloLinuxSolution() + { + AddTargets(CommonTarget.GetDefaultTargets()); + Name = "HelloLinux"; + } + + public override void ConfigureAll(Configuration conf, CommonTarget target) + { + base.ConfigureAll(conf, target); + + conf.AddProject(target); + conf.AddProject(target); + conf.AddProject(target); + conf.AddProject(target); + } + } +} diff --git a/samples/HelloLinux/codebase/dll1/dll1.sharpmake.cs b/samples/HelloLinux/codebase/dll1/dll1.sharpmake.cs new file mode 100644 index 000000000..98bd4a16b --- /dev/null +++ b/samples/HelloLinux/codebase/dll1/dll1.sharpmake.cs @@ -0,0 +1,48 @@ +// Copyright (c) 2020 Ubisoft Entertainment +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using Sharpmake; + +namespace HelloLinux +{ + [Sharpmake.Generate] + public class Dll1Project : CommonProject + { + public Dll1Project() + { + AddTargets(CommonTarget.GetDefaultTargets()); + Name = "dll1"; + } + + public override void ConfigureAll(Configuration conf, CommonTarget target) + { + base.ConfigureAll(conf, target); + + conf.SolutionFolder = "SharedLibs"; + + conf.PrecompHeader = "precomp.h"; + conf.PrecompSource = "precomp.cpp"; + + conf.Output = Configuration.OutputType.Dll; + conf.AdditionalCompilerOptions.Add("-fPIC"); + + conf.Defines.Add("UTIL_DLL_EXPORT"); + conf.ExportDefines.Add("UTIL_DLL_IMPORT"); + + conf.IncludePaths.Add(SourceRootPath); + + conf.AddPrivateDependency(target); + } + } +} diff --git a/samples/HelloLinux/codebase/dll1/precomp.cpp b/samples/HelloLinux/codebase/dll1/precomp.cpp new file mode 100644 index 000000000..15c6d7b04 --- /dev/null +++ b/samples/HelloLinux/codebase/dll1/precomp.cpp @@ -0,0 +1,2 @@ +#include "precomp.h" + diff --git a/samples/HelloLinux/codebase/dll1/precomp.h b/samples/HelloLinux/codebase/dll1/precomp.h new file mode 100644 index 000000000..c32e3aaf4 --- /dev/null +++ b/samples/HelloLinux/codebase/dll1/precomp.h @@ -0,0 +1,3 @@ +#pragma once + +#include diff --git a/samples/HelloLinux/codebase/dll1/util_dll.cpp b/samples/HelloLinux/codebase/dll1/util_dll.cpp new file mode 100644 index 000000000..73e079cb4 --- /dev/null +++ b/samples/HelloLinux/codebase/dll1/util_dll.cpp @@ -0,0 +1,33 @@ +#include "precomp.h" +#include "util_dll.h" + +#include "src/util_static_lib1.h" +#include + +int UtilDll1::ComputeSum(const std::vector& someInts) +{ + int acc = 0; + for (int item : someInts) + acc += item; + +#if _DEBUG + std::cout << "- Dll1 is built in Debug" +# if USES_FASTBUILD + " with FastBuild" +# endif + "!" << std::endl; +#endif + +#if NDEBUG + std::cout << "- Dll1 is built in Release" +# if USES_FASTBUILD + " with FastBuild" +# endif + "!" << std::endl; +#endif + + acc += static_lib1_utils::GetRandomPosition(); + + return acc; +} + diff --git a/samples/HelloLinux/codebase/dll1/util_dll.h b/samples/HelloLinux/codebase/dll1/util_dll.h new file mode 100644 index 000000000..3cdb40a16 --- /dev/null +++ b/samples/HelloLinux/codebase/dll1/util_dll.h @@ -0,0 +1,18 @@ +#pragma once +#include + +#if defined(UTIL_DLL_EXPORT) && HAVE_VISIBILITY +# define UTIL_DLL __attribute__((__visibility("default"))) +#elif defined(UTIL_DLL_EXPORT) && defined(_MSC_VER) +# define UTIL_DLL __declspec(dllexport) +#elif defined(UTIL_DLL_IMPORT) && defined(_MSC_VER) +#define UTIL_DLL __declspec(dllimport) +#else +#define UTIL_DLL +#endif + +struct UtilDll1 +{ + UTIL_DLL int ComputeSum(const std::vector& someInts); +}; + diff --git a/samples/HelloLinux/codebase/exe/exe.sharpmake.cs b/samples/HelloLinux/codebase/exe/exe.sharpmake.cs new file mode 100644 index 000000000..3205c5890 --- /dev/null +++ b/samples/HelloLinux/codebase/exe/exe.sharpmake.cs @@ -0,0 +1,47 @@ +// Copyright (c) 2020 Ubisoft Entertainment +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using Sharpmake; + +namespace HelloLinux +{ + [Sharpmake.Generate] + public class ExeProject : CommonProject + { + public ExeProject() + { + AddTargets(CommonTarget.GetDefaultTargets()); + Name = "exe"; + } + + public override void ConfigureAll(Configuration conf, CommonTarget target) + { + base.ConfigureAll(conf, target); + + conf.Output = Configuration.OutputType.Exe; + + conf.PrecompHeader = "stdafx.h"; + conf.PrecompSource = "stdafx.cpp"; + + // this tells the shared lib loader to look in the exe dir + // note: because we write in makefiles we double the $ to escape it + conf.AdditionalLinkerOptions.Add("-Wl,-rpath='$$ORIGIN'"); + + conf.AddPrivateDependency(target); + conf.AddPrivateDependency(target); + + conf.Defines.Add("CREATION_DATE=\"October 2020\""); + } + } +} diff --git a/samples/HelloLinux/codebase/exe/main.cpp b/samples/HelloLinux/codebase/exe/main.cpp new file mode 100644 index 000000000..86912aed5 --- /dev/null +++ b/samples/HelloLinux/codebase/exe/main.cpp @@ -0,0 +1,37 @@ +#include "stdafx.h" +#include "util_dll.h" +#include "util_static_lib2.h" +#include "sub folder/useless_static_lib2.h" + +int main(int, char**) +{ + std::cout << "Hello Linux World, from " CREATION_DATE "!" << std::endl; + +#if _DEBUG + std::cout << "- Exe is built in Debug" +# if USES_FASTBUILD + " with FastBuild" +# endif + "!" << std::endl; +#endif + +#if NDEBUG + std::cout << "- Exe is built in Release" +# if USES_FASTBUILD + " with FastBuild" +# endif + "!" << std::endl; +#endif + + std::vector someArray(5, 6); + + // from dll1 + UtilDll1 utilityDll; + utilityDll.ComputeSum(someArray); + + // from static_lib2 + Util2 utilityStatic; + utilityStatic.DoSomethingUseful(); + StaticLib2::UselessMethod(); + return 0; +} diff --git a/samples/HelloLinux/codebase/exe/stdafx.cpp b/samples/HelloLinux/codebase/exe/stdafx.cpp new file mode 100644 index 000000000..fd4f341c7 --- /dev/null +++ b/samples/HelloLinux/codebase/exe/stdafx.cpp @@ -0,0 +1 @@ +#include "stdafx.h" diff --git a/samples/HelloLinux/codebase/exe/stdafx.h b/samples/HelloLinux/codebase/exe/stdafx.h new file mode 100644 index 000000000..23395186c --- /dev/null +++ b/samples/HelloLinux/codebase/exe/stdafx.h @@ -0,0 +1,3 @@ +#pragma once + +#include diff --git a/samples/HelloLinux/codebase/static lib2/static_lib2.sharpmake.cs b/samples/HelloLinux/codebase/static lib2/static_lib2.sharpmake.cs new file mode 100644 index 000000000..78336ae8c --- /dev/null +++ b/samples/HelloLinux/codebase/static lib2/static_lib2.sharpmake.cs @@ -0,0 +1,37 @@ +// Copyright (c) 2020 Ubisoft Entertainment +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using Sharpmake; + +namespace HelloLinux +{ + [Sharpmake.Generate] + public class StaticLib2Project : CommonProject + { + public StaticLib2Project() + { + AddTargets(CommonTarget.GetDefaultTargets()); + Name = "static lib2"; + } + + public override void ConfigureAll(Configuration conf, CommonTarget target) + { + base.ConfigureAll(conf, target); + + conf.SolutionFolder = "StaticLibs"; + + conf.IncludePaths.Add(SourceRootPath); + } + } +} diff --git a/samples/HelloLinux/codebase/static lib2/sub folder/useless_static_lib2.cpp b/samples/HelloLinux/codebase/static lib2/sub folder/useless_static_lib2.cpp new file mode 100644 index 000000000..49469d32a --- /dev/null +++ b/samples/HelloLinux/codebase/static lib2/sub folder/useless_static_lib2.cpp @@ -0,0 +1,11 @@ +#include "useless_static_lib2.h" +#include + +namespace StaticLib2 +{ + void UselessMethod() + { + std::cout << "- Useless in fact!" << std::endl; + } +} + diff --git a/samples/HelloLinux/codebase/static lib2/sub folder/useless_static_lib2.h b/samples/HelloLinux/codebase/static lib2/sub folder/useless_static_lib2.h new file mode 100644 index 000000000..ee6d3ef92 --- /dev/null +++ b/samples/HelloLinux/codebase/static lib2/sub folder/useless_static_lib2.h @@ -0,0 +1,7 @@ +#pragma once + +namespace StaticLib2 +{ + void UselessMethod(); +} + diff --git a/samples/HelloLinux/codebase/static lib2/util_static_lib2.cpp b/samples/HelloLinux/codebase/static lib2/util_static_lib2.cpp new file mode 100644 index 000000000..b6404f891 --- /dev/null +++ b/samples/HelloLinux/codebase/static lib2/util_static_lib2.cpp @@ -0,0 +1,34 @@ +#include "util_static_lib2.h" +#include + +Util2::Util2() = default; + +Util2::~Util2() +{ +} + +void Util2::DoSomethingUseful() const +{ +#if _DEBUG + std::cout << "- StaticLib2 is built in Debug" +# if USES_FASTBUILD + " with FastBuild" +# endif + "!" << std::endl; +#endif + +#if NDEBUG + std::cout << "- StaticLib2 is built in Release" +# if USES_FASTBUILD + " with FastBuild" +# endif + "!" << std::endl; +#endif + + return DoSomethingInternal("Yeah right..."); +} + +void Util2::DoSomethingInternal(const char* anArgument) const +{ + std::cout << "Useful, right?\n- " << anArgument << std::endl; +} diff --git a/samples/HelloLinux/codebase/static lib2/util_static_lib2.h b/samples/HelloLinux/codebase/static lib2/util_static_lib2.h new file mode 100644 index 000000000..196128c58 --- /dev/null +++ b/samples/HelloLinux/codebase/static lib2/util_static_lib2.h @@ -0,0 +1,15 @@ +#pragma once + +class Util2 +{ +public: + Util2(); + ~Util2(); + +public: + void DoSomethingUseful() const; + +private: + void DoSomethingInternal(const char* anArgument) const; +}; + diff --git a/samples/HelloLinux/codebase/static_lib1/src/ensure_debug.cpp b/samples/HelloLinux/codebase/static_lib1/src/ensure_debug.cpp new file mode 100644 index 000000000..2f8e4ac06 --- /dev/null +++ b/samples/HelloLinux/codebase/static_lib1/src/ensure_debug.cpp @@ -0,0 +1,11 @@ +#include "src/pch.h" + +#if !_DEBUG + #error Expected Debug define (_DEBUG) was not found +#endif + +#if NDEBUG + #error Unexpected Release define (NDEBUG) was found +#endif + +#warning Debug is built! diff --git a/samples/HelloLinux/codebase/static_lib1/src/ensure_release.cpp b/samples/HelloLinux/codebase/static_lib1/src/ensure_release.cpp new file mode 100644 index 000000000..18d52b619 --- /dev/null +++ b/samples/HelloLinux/codebase/static_lib1/src/ensure_release.cpp @@ -0,0 +1,11 @@ +#include "src/pch.h" + +#if _DEBUG + #error Unexpected Debug define (_DEBUG) was found +#endif + +#if !NDEBUG + #error Expected Release define (NDEBUG) was not found +#endif + +#warning Release is built! diff --git a/samples/HelloLinux/codebase/static_lib1/src/pch.cpp b/samples/HelloLinux/codebase/static_lib1/src/pch.cpp new file mode 100644 index 000000000..ce9b73991 --- /dev/null +++ b/samples/HelloLinux/codebase/static_lib1/src/pch.cpp @@ -0,0 +1,2 @@ +#include "pch.h" + diff --git a/samples/HelloLinux/codebase/static_lib1/src/pch.h b/samples/HelloLinux/codebase/static_lib1/src/pch.h new file mode 100644 index 000000000..23395186c --- /dev/null +++ b/samples/HelloLinux/codebase/static_lib1/src/pch.h @@ -0,0 +1,3 @@ +#pragma once + +#include diff --git a/samples/HelloLinux/codebase/static_lib1/src/util_static_lib1.cpp b/samples/HelloLinux/codebase/static_lib1/src/util_static_lib1.cpp new file mode 100644 index 000000000..e07f280ae --- /dev/null +++ b/samples/HelloLinux/codebase/static_lib1/src/util_static_lib1.cpp @@ -0,0 +1,28 @@ +#include "src/pch.h" +#include "util_static_lib1.h" +#include + +namespace static_lib1_utils +{ + std::streampos GetRandomPosition() + { +#if _DEBUG + std::cout << "- StaticLib1 is built in Debug" +# if USES_FASTBUILD + " with FastBuild" +# endif + "!" << std::endl; +#endif + +#if NDEBUG + std::cout << "- StaticLib1 is built in Release" +# if USES_FASTBUILD + " with FastBuild" +# endif + "!" << std::endl; +#endif + + return 1; + } +} + diff --git a/samples/HelloLinux/codebase/static_lib1/src/util_static_lib1.h b/samples/HelloLinux/codebase/static_lib1/src/util_static_lib1.h new file mode 100644 index 000000000..0cec87480 --- /dev/null +++ b/samples/HelloLinux/codebase/static_lib1/src/util_static_lib1.h @@ -0,0 +1,7 @@ +#pragma once +#include + +namespace static_lib1_utils +{ + std::streampos GetRandomPosition(); +} diff --git a/samples/HelloLinux/codebase/static_lib1/static_lib1.sharpmake.cs b/samples/HelloLinux/codebase/static_lib1/static_lib1.sharpmake.cs new file mode 100644 index 000000000..8f765f576 --- /dev/null +++ b/samples/HelloLinux/codebase/static_lib1/static_lib1.sharpmake.cs @@ -0,0 +1,57 @@ +// Copyright (c) 2020 Ubisoft Entertainment +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using Sharpmake; + +namespace HelloLinux +{ + [Sharpmake.Generate] + public class StaticLib1Project : CommonProject + { + public StaticLib1Project() + { + AddTargets(CommonTarget.GetDefaultTargets()); + Name = "static_lib1"; + } + + public override void ConfigureAll(Configuration conf, CommonTarget target) + { + base.ConfigureAll(conf, target); + + conf.SolutionFolder = "StaticLibs"; + + // intentionally in a subfolder + conf.PrecompHeader = @"src\pch.h"; + conf.PrecompSource = @"src\pch.cpp"; + + // becase this lib will be used in a shared lib, we need it to be position independent + conf.AdditionalCompilerOptions.Add("-fPIC"); + + conf.IncludePaths.Add(SourceRootPath); + + switch (target.Optimization) + { + case Optimization.Debug: + conf.SourceFilesBuildExclude.Add(@"src\ensure_release.cpp"); + break; + case Optimization.Release: + // use a different method to exclude ensure_debug.cpp + conf.SourceFilesBuildExcludeRegex.Add(Util.RegexPathCombine("src", @"ensure_d.*\.cpp$")); + break; + default: + throw new Error("Unexpected optimization " + target.Optimization); + } + } + } +} diff --git a/samples/HelloWorld/HelloWorld.sharpmake.cs b/samples/HelloWorld/HelloWorld.sharpmake.cs index c6e2fdbba..34b6a5176 100644 --- a/samples/HelloWorld/HelloWorld.sharpmake.cs +++ b/samples/HelloWorld/HelloWorld.sharpmake.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017, 2019 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/HelloWorld/Properties/AssemblyInfo.cs b/samples/HelloWorld/Properties/AssemblyInfo.cs index 13e60138f..da5dcc910 100644 --- a/samples/HelloWorld/Properties/AssemblyInfo.cs +++ b/samples/HelloWorld/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017, 2019 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/HelloXCode/HelloXCode.CommonProject.sharpmake.cs b/samples/HelloXCode/HelloXCode.CommonProject.sharpmake.cs index 338162e78..fda6d93df 100644 --- a/samples/HelloXCode/HelloXCode.CommonProject.sharpmake.cs +++ b/samples/HelloXCode/HelloXCode.CommonProject.sharpmake.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2020-2021 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -61,7 +61,7 @@ public virtual void ConfigureAll(Configuration conf, CommonTarget target) // different names per configurations to work properly... //conf.TargetFileName += "_" + target.Optimization.ToString().ToLowerInvariant().First(); // suffix with lowered first letter of optim //if (conf.IsFastBuild) - //conf.TargetFileName += "x"; + //conf.TargetFileName += "x"; conf.Output = Configuration.OutputType.Lib; // defaults to creating static libs } diff --git a/samples/HelloXCode/HelloXCode.CommonSolution.sharpmake.cs b/samples/HelloXCode/HelloXCode.CommonSolution.sharpmake.cs index 0fd2b81a0..8784e1e09 100644 --- a/samples/HelloXCode/HelloXCode.CommonSolution.sharpmake.cs +++ b/samples/HelloXCode/HelloXCode.CommonSolution.sharpmake.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/HelloXCode/HelloXCode.CommonTarget.sharpmake.cs b/samples/HelloXCode/HelloXCode.CommonTarget.sharpmake.cs index f2a2a311b..2c8b757bb 100644 --- a/samples/HelloXCode/HelloXCode.CommonTarget.sharpmake.cs +++ b/samples/HelloXCode/HelloXCode.CommonTarget.sharpmake.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/HelloXCode/HelloXCode.Main.sharpmake.cs b/samples/HelloXCode/HelloXCode.Main.sharpmake.cs index 7c350cdb5..9193f649f 100644 --- a/samples/HelloXCode/HelloXCode.Main.sharpmake.cs +++ b/samples/HelloXCode/HelloXCode.Main.sharpmake.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2020-2021 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -73,12 +73,15 @@ public static void SharpmakeMain(Sharpmake.Arguments arguments) string sharpmakeFastBuildDir = Util.PathGetAbsolute(Globals.RootDirectory, @"..\..\..\tools\FastBuild"); switch (Util.GetExecutingPlatform()) { + case Platform.linux: + FastBuildSettings.FastBuildMakeCommand = Path.Combine(sharpmakeFastBuildDir, "Linux-x64", "fbuild"); + break; case Platform.mac: - FastBuildSettings.FastBuildMakeCommand = Path.Combine(sharpmakeFastBuildDir, "FBuild"); + FastBuildSettings.FastBuildMakeCommand = Path.Combine(sharpmakeFastBuildDir, "OSX-x64", "FBuild"); break; case Platform.win64: default: - FastBuildSettings.FastBuildMakeCommand = Path.Combine(sharpmakeFastBuildDir, "FBuild.exe"); + FastBuildSettings.FastBuildMakeCommand = Path.Combine(sharpmakeFastBuildDir, "Windows-x64", "FBuild.exe"); break; } diff --git a/samples/HelloXCode/Properties/AssemblyInfo.cs b/samples/HelloXCode/Properties/AssemblyInfo.cs index 049c96c4d..926caf1c2 100644 --- a/samples/HelloXCode/Properties/AssemblyInfo.cs +++ b/samples/HelloXCode/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/HelloXCode/codebase/HelloXCode.sharpmake.cs b/samples/HelloXCode/codebase/HelloXCode.sharpmake.cs index b50f9df71..0d04440ec 100644 --- a/samples/HelloXCode/codebase/HelloXCode.sharpmake.cs +++ b/samples/HelloXCode/codebase/HelloXCode.sharpmake.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/HelloXCode/codebase/dll1/dll1.sharpmake.cs b/samples/HelloXCode/codebase/dll1/dll1.sharpmake.cs index f14502266..0c6018084 100644 --- a/samples/HelloXCode/codebase/dll1/dll1.sharpmake.cs +++ b/samples/HelloXCode/codebase/dll1/dll1.sharpmake.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/HelloXCode/codebase/exe/exe.sharpmake.cs b/samples/HelloXCode/codebase/exe/exe.sharpmake.cs index de8b866dd..1431c3707 100644 --- a/samples/HelloXCode/codebase/exe/exe.sharpmake.cs +++ b/samples/HelloXCode/codebase/exe/exe.sharpmake.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/HelloXCode/codebase/static lib2/static_lib2.sharpmake.cs b/samples/HelloXCode/codebase/static lib2/static_lib2.sharpmake.cs index 6b14ec969..6bdde23e4 100644 --- a/samples/HelloXCode/codebase/static lib2/static_lib2.sharpmake.cs +++ b/samples/HelloXCode/codebase/static lib2/static_lib2.sharpmake.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/HelloXCode/codebase/static_lib1/static_lib1.sharpmake.cs b/samples/HelloXCode/codebase/static_lib1/static_lib1.sharpmake.cs index 882aaa94f..3135d0e26 100644 --- a/samples/HelloXCode/codebase/static_lib1/static_lib1.sharpmake.cs +++ b/samples/HelloXCode/codebase/static_lib1/static_lib1.sharpmake.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/NetCore/DotNetCoreFrameworkHelloWorld/HelloWorld.sharpmake.cs b/samples/NetCore/DotNetCoreFrameworkHelloWorld/HelloWorld.sharpmake.cs index 082485367..02f982e3b 100644 --- a/samples/NetCore/DotNetCoreFrameworkHelloWorld/HelloWorld.sharpmake.cs +++ b/samples/NetCore/DotNetCoreFrameworkHelloWorld/HelloWorld.sharpmake.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/NetCore/DotNetCoreFrameworkHelloWorld/codebase/HelloWorldMultiframework/Properties/AssemblyInfo.cs b/samples/NetCore/DotNetCoreFrameworkHelloWorld/codebase/HelloWorldMultiframework/Properties/AssemblyInfo.cs index 825ace357..a91083181 100644 --- a/samples/NetCore/DotNetCoreFrameworkHelloWorld/codebase/HelloWorldMultiframework/Properties/AssemblyInfo.cs +++ b/samples/NetCore/DotNetCoreFrameworkHelloWorld/codebase/HelloWorldMultiframework/Properties/AssemblyInfo.cs @@ -7,7 +7,7 @@ [assembly: AssemblyDescription("Dummy description")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Ubisoft")] -[assembly: AssemblyProduct("Sharpamke")] +[assembly: AssemblyProduct("Sharpmake")] [assembly: AssemblyCopyright("Copyright © Ubisoft 2020")] [assembly: AssemblyVersion("1.0.0.0")] diff --git a/samples/NetCore/DotNetCoreFrameworkHelloWorld/reference/projects/helloworld/HelloWorld.vs2017.netcore1_0.csproj b/samples/NetCore/DotNetCoreFrameworkHelloWorld/reference/projects/helloworld/HelloWorld.vs2017.netcore1_0.csproj index 0b84c1b04..361342313 100644 --- a/samples/NetCore/DotNetCoreFrameworkHelloWorld/reference/projects/helloworld/HelloWorld.vs2017.netcore1_0.csproj +++ b/samples/NetCore/DotNetCoreFrameworkHelloWorld/reference/projects/helloworld/HelloWorld.vs2017.netcore1_0.csproj @@ -1,4 +1,4 @@ - + Debug AnyCPU @@ -35,9 +35,11 @@ true false + Program.cs + \ No newline at end of file diff --git a/samples/NetCore/DotNetCoreFrameworkHelloWorld/reference/projects/helloworld/HelloWorld.vs2019.netcore2_0.csproj b/samples/NetCore/DotNetCoreFrameworkHelloWorld/reference/projects/helloworld/HelloWorld.vs2019.netcore2_0.csproj index febaf2655..e05677434 100644 --- a/samples/NetCore/DotNetCoreFrameworkHelloWorld/reference/projects/helloworld/HelloWorld.vs2019.netcore2_0.csproj +++ b/samples/NetCore/DotNetCoreFrameworkHelloWorld/reference/projects/helloworld/HelloWorld.vs2019.netcore2_0.csproj @@ -1,4 +1,4 @@ - + Debug AnyCPU @@ -35,9 +35,11 @@ true false + Program.cs + \ No newline at end of file diff --git a/samples/NetCore/DotNetCoreFrameworkHelloWorld/reference/projects/helloworldmultiframework/HelloWorldMultiFramework.vs2019.csproj b/samples/NetCore/DotNetCoreFrameworkHelloWorld/reference/projects/helloworldmultiframework/HelloWorldMultiFramework.vs2019.csproj index 6ff8942a9..b76644319 100644 --- a/samples/NetCore/DotNetCoreFrameworkHelloWorld/reference/projects/helloworldmultiframework/HelloWorldMultiFramework.vs2019.csproj +++ b/samples/NetCore/DotNetCoreFrameworkHelloWorld/reference/projects/helloworldmultiframework/HelloWorldMultiFramework.vs2019.csproj @@ -1,4 +1,4 @@ - + Debug AnyCPU @@ -60,6 +60,7 @@ true false + Program.cs @@ -68,4 +69,5 @@ Properties\AssemblyInfo.cs + \ No newline at end of file diff --git a/samples/NetCore/DotNetFrameworkHelloWorld/HelloWorld.sharpmake.cs b/samples/NetCore/DotNetFrameworkHelloWorld/HelloWorld.sharpmake.cs index 7eb15270c..c7a77aa8e 100644 --- a/samples/NetCore/DotNetFrameworkHelloWorld/HelloWorld.sharpmake.cs +++ b/samples/NetCore/DotNetFrameworkHelloWorld/HelloWorld.sharpmake.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/NetCore/DotNetFrameworkHelloWorld/reference/projects/helloworldmultiframework/HelloWorldMultiFramework.vs2019.csproj b/samples/NetCore/DotNetFrameworkHelloWorld/reference/projects/helloworldmultiframework/HelloWorldMultiFramework.vs2019.csproj index ba29c7ff8..4783192c6 100644 --- a/samples/NetCore/DotNetFrameworkHelloWorld/reference/projects/helloworldmultiframework/HelloWorldMultiFramework.vs2019.csproj +++ b/samples/NetCore/DotNetFrameworkHelloWorld/reference/projects/helloworldmultiframework/HelloWorldMultiFramework.vs2019.csproj @@ -1,4 +1,4 @@ - + Debug AnyCPU @@ -60,9 +60,11 @@ true false + Program.cs + \ No newline at end of file diff --git a/samples/NetCore/DotNetMultiFrameworksHelloWorld/HelloWorld.sharpmake.cs b/samples/NetCore/DotNetMultiFrameworksHelloWorld/HelloWorld.sharpmake.cs index a10a98944..32fe29618 100644 --- a/samples/NetCore/DotNetMultiFrameworksHelloWorld/HelloWorld.sharpmake.cs +++ b/samples/NetCore/DotNetMultiFrameworksHelloWorld/HelloWorld.sharpmake.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/NetCore/DotNetMultiFrameworksHelloWorld/codebase/HelloWorldMultiframeworks/Properties/AssemblyInfo.cs b/samples/NetCore/DotNetMultiFrameworksHelloWorld/codebase/HelloWorldMultiframeworks/Properties/AssemblyInfo.cs index 825ace357..a91083181 100644 --- a/samples/NetCore/DotNetMultiFrameworksHelloWorld/codebase/HelloWorldMultiframeworks/Properties/AssemblyInfo.cs +++ b/samples/NetCore/DotNetMultiFrameworksHelloWorld/codebase/HelloWorldMultiframeworks/Properties/AssemblyInfo.cs @@ -7,7 +7,7 @@ [assembly: AssemblyDescription("Dummy description")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Ubisoft")] -[assembly: AssemblyProduct("Sharpamke")] +[assembly: AssemblyProduct("Sharpmake")] [assembly: AssemblyCopyright("Copyright © Ubisoft 2020")] [assembly: AssemblyVersion("1.0.0.0")] diff --git a/samples/NetCore/DotNetMultiFrameworksHelloWorld/reference/projects/HelloWorldMultiFrameworksSolution.vs2019.sln b/samples/NetCore/DotNetMultiFrameworksHelloWorld/reference/projects/HelloWorldMultiFrameworksSolution.vs2019.sln index 232809be5..1492c6d09 100644 --- a/samples/NetCore/DotNetMultiFrameworksHelloWorld/reference/projects/HelloWorldMultiFrameworksSolution.vs2019.sln +++ b/samples/NetCore/DotNetMultiFrameworksHelloWorld/reference/projects/HelloWorldMultiFrameworksSolution.vs2019.sln @@ -16,6 +16,10 @@ Global {39A4FB20-F152-B28B-4386-81262F615392}.Debug|Any CPU.Build.0 = Debug|Any CPU {39A4FB20-F152-B28B-4386-81262F615392}.Release|Any CPU.ActiveCfg = Release|Any CPU {39A4FB20-F152-B28B-4386-81262F615392}.Release|Any CPU.Build.0 = Release|Any CPU + {2118A95F-4FDA-D7C9-6CC8-A7A85A81062E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2118A95F-4FDA-D7C9-6CC8-A7A85A81062E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2118A95F-4FDA-D7C9-6CC8-A7A85A81062E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2118A95F-4FDA-D7C9-6CC8-A7A85A81062E}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/samples/NetCore/DotNetMultiFrameworksHelloWorld/reference/projects/helloworldlib/HelloWorldLib.vs2019.csproj b/samples/NetCore/DotNetMultiFrameworksHelloWorld/reference/projects/helloworldlib/HelloWorldLib.vs2019.csproj index b7e9f1d79..8ae33be63 100644 --- a/samples/NetCore/DotNetMultiFrameworksHelloWorld/reference/projects/helloworldlib/HelloWorldLib.vs2019.csproj +++ b/samples/NetCore/DotNetMultiFrameworksHelloWorld/reference/projects/helloworldlib/HelloWorldLib.vs2019.csproj @@ -1,4 +1,4 @@ - + Debug AnyCPU @@ -60,6 +60,7 @@ true false + False @@ -73,4 +74,5 @@ + \ No newline at end of file diff --git a/samples/NetCore/DotNetMultiFrameworksHelloWorld/reference/projects/helloworldmultiframeworks/HelloWorldMultiFrameworks.vs2019.csproj b/samples/NetCore/DotNetMultiFrameworksHelloWorld/reference/projects/helloworldmultiframeworks/HelloWorldMultiFrameworks.vs2019.csproj index c6d09b1c9..314b2e817 100644 --- a/samples/NetCore/DotNetMultiFrameworksHelloWorld/reference/projects/helloworldmultiframeworks/HelloWorldMultiFrameworks.vs2019.csproj +++ b/samples/NetCore/DotNetMultiFrameworksHelloWorld/reference/projects/helloworldmultiframeworks/HelloWorldMultiFrameworks.vs2019.csproj @@ -1,4 +1,4 @@ - + Debug AnyCPU @@ -60,6 +60,7 @@ true false + Program.cs @@ -74,4 +75,5 @@ HelloWorldLib + \ No newline at end of file diff --git a/samples/PackageReferences/PackageReferences.sharpmake.cs b/samples/PackageReferences/PackageReferences.sharpmake.cs index 15eef1a3f..10b9cf407 100644 --- a/samples/PackageReferences/PackageReferences.sharpmake.cs +++ b/samples/PackageReferences/PackageReferences.sharpmake.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017-2019 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/PackageReferences/codebase/PackageReferences/Properties/AssemblyInfo.cs b/samples/PackageReferences/codebase/PackageReferences/Properties/AssemblyInfo.cs index f0f99af14..e0b5191a1 100644 --- a/samples/PackageReferences/codebase/PackageReferences/Properties/AssemblyInfo.cs +++ b/samples/PackageReferences/codebase/PackageReferences/Properties/AssemblyInfo.cs @@ -10,7 +10,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Ubisoft")] [assembly: AssemblyProduct("ExampleCodeProject")] -[assembly: AssemblyCopyright("Copyright © Ubisoft 2019")] +[assembly: AssemblyCopyright("Copyright © Ubisoft 2017, 2019")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/samples/QTFileCustomBuild/QTFileCustomBuild.sharpmake.cs b/samples/QTFileCustomBuild/QTFileCustomBuild.sharpmake.cs index 50ebc3a85..406c7bde5 100644 --- a/samples/QTFileCustomBuild/QTFileCustomBuild.sharpmake.cs +++ b/samples/QTFileCustomBuild/QTFileCustomBuild.sharpmake.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2018-2019 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/Sharpmake.Samples.sharpmake.cs b/samples/Sharpmake.Samples.sharpmake.cs index 8000ebf20..5bfb3d99b 100644 --- a/samples/Sharpmake.Samples.sharpmake.cs +++ b/samples/Sharpmake.Samples.sharpmake.cs @@ -19,6 +19,8 @@ protected SampleProject() @"\\projects\\", @"\\reference\\" ); + + DependenciesCopyLocal = DependenciesCopyLocalTypes.None; } public override void ConfigureAll(Configuration conf, Target target) @@ -26,7 +28,7 @@ public override void ConfigureAll(Configuration conf, Target target) base.ConfigureAll(conf, target); conf.SolutionFolder = "Samples"; - conf.TargetPath = @"[project.RootPath]\bin\[target.Optimization]\Samples"; + conf.TargetPath = @"[project.RootPath]\tmp\samples\[target.Optimization]\[project.Name]"; conf.AddPrivateDependency(target); conf.AddPrivateDependency(target); @@ -35,10 +37,9 @@ public override void ConfigureAll(Configuration conf, Target target) conf.CsprojUserFile = new Project.Configuration.CsprojUserFileSettings { StartAction = Project.Configuration.CsprojUserFileSettings.StartActionSetting.Program, - StartProgram = @"[conf.TargetPath]\Sharpmake.Application.exe", - StartArguments = "/sources(\"[project.SharpmakeMainFile]\")", - WorkingDirectory = "[project.SourceRootPath]", - OverwriteExistingFile = false + StartProgram = @"[project.RootPath]\tmp\bin\[conf.Target.Optimization]\Sharpmake.Application.exe", + StartArguments = "/sources('[project.SharpmakeMainFile]')", + WorkingDirectory = "[project.SourceRootPath]" }; } } @@ -158,6 +159,26 @@ public FastBuildSimpleExecutable() } } + [Generate] + public class HelloLinuxProject : SampleProject + { + public HelloLinuxProject() + { + Name = "HelloLinux"; + SharpmakeMainFile = "HelloLinux.Main.sharpmake.cs"; + + // This one is special, we have .sharpmake.cs files in the codebase + SourceFilesExcludeRegex.Remove(@"\\codebase\\"); + } + + public override void ConfigureAll(Configuration conf, Target target) + { + base.ConfigureAll(conf, target); + + conf.AddPrivateDependency(target); + } + } + [Generate] public class HelloWorldProject : SampleProject { diff --git a/samples/SimpleExeLibDependency/LibStuff.sharpmake.cs b/samples/SimpleExeLibDependency/LibStuff.sharpmake.cs index 9096086dd..c6e83c003 100644 --- a/samples/SimpleExeLibDependency/LibStuff.sharpmake.cs +++ b/samples/SimpleExeLibDependency/LibStuff.sharpmake.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017, 2019-2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/SimpleExeLibDependency/SimpleExeLibDependency.sharpmake.cs b/samples/SimpleExeLibDependency/SimpleExeLibDependency.sharpmake.cs index 5c24c078c..919c8d9a0 100644 --- a/samples/SimpleExeLibDependency/SimpleExeLibDependency.sharpmake.cs +++ b/samples/SimpleExeLibDependency/SimpleExeLibDependency.sharpmake.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ubisoft Entertainment +// Copyright (c) 2017, 2019-2020 Ubisoft Entertainment // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/vcpkg/.gitignore b/samples/vcpkg/.gitignore new file mode 100644 index 000000000..ff1fdb368 --- /dev/null +++ b/samples/vcpkg/.gitignore @@ -0,0 +1,3 @@ +extern/vcpkg/ +tmp/ +blob/ \ No newline at end of file diff --git a/samples/vcpkg/bootstrap-sample.bat b/samples/vcpkg/bootstrap-sample.bat new file mode 100644 index 000000000..350186a7d --- /dev/null +++ b/samples/vcpkg/bootstrap-sample.bat @@ -0,0 +1,31 @@ +@echo off + +SETLOCAL + +call :DECOMPRESS_VCPKG_EXPORTED_PACKAGES +IF ERRORLEVEL 1 exit /b %ERRORLEVEL% + +call :GENERATE_PROJECTS +IF ERRORLEVEL 1 exit /b %ERRORLEVEL% + +:: Final Cleanup +exit /B %ERRORLEVEL% + +:: ---------- FUNCTIONS --------------- + +:: Decompress the exported vcpkg package for consumption by Sharpmake and generated projects +:DECOMPRESS_VCPKG_EXPORTED_PACKAGES +rmdir /Q /S extern\vcpkg >NUL 2>NUL +echo Extracting extern\vcpkg.zip to extern\vcpkg +powershell Expand-Archive extern\vcpkg.zip -DestinationPath extern +exit /B %ERRORLEVEL% + +:: Generate projects using Sharpmake +:GENERATE_PROJECTS +%~dp0..\..\bin\Release\Sharpmake.Application.exe /sources(@".\sharpmake\main.sharpmake.cs") /generatedebugsolution +exit /B %ERRORLEVEL% + + + + + diff --git a/samples/vcpkg/extern/vcpkg.zip b/samples/vcpkg/extern/vcpkg.zip new file mode 100644 index 000000000..7a50f16e0 Binary files /dev/null and b/samples/vcpkg/extern/vcpkg.zip differ diff --git a/samples/vcpkg/readme.md b/samples/vcpkg/readme.md new file mode 100644 index 000000000..314a3dfaf --- /dev/null +++ b/samples/vcpkg/readme.md @@ -0,0 +1,6 @@ +### VCPKG Sample + +This is a completely functional sample to demonstrate a way of integrating some vcpkg packages in sharpmake generated projects. + +## Warning: +This doesn't use the official Visual Studio support for vcpkg diff --git a/samples/vcpkg/sharpmake/baseclasses.sharpmake.cs b/samples/vcpkg/sharpmake/baseclasses.sharpmake.cs new file mode 100644 index 000000000..50aef1422 --- /dev/null +++ b/samples/vcpkg/sharpmake/baseclasses.sharpmake.cs @@ -0,0 +1,125 @@ +using Sharpmake; + +namespace VCPKGSample +{ + + /// + /// This class is used to define the targets fragments used everywhere in this sample + /// + public class SampleTargets + { + public static Target[] Targets + { + get + { + return new Target[]{ new Target( + Platform.win64, + DevEnv.vs2019, + Optimization.Debug | Optimization.Release, + buildSystem: BuildSystem.MSBuild | BuildSystem.FastBuild)}; + } + } + } + + /// + /// This is the base class for projects with the Sharpmake.Export attribute. + /// + /// + /// + /// ConfigurePriority() attribute on configure methods is to force the order of the calls. Lower numbers have highest priority + /// + public class ExportProject : Project + { + public ExportProject() + { + AddTargets(SampleTargets.Targets); + } + + [Configure(), ConfigurePriority(1)] + public virtual void ConfigureAll(Configuration conf, Target target) + { + } + + [Configure(Optimization.Debug), ConfigurePriority(2)] + public virtual void ConfigureDebug(Configuration conf, Target target) + { + } + + [Configure(Optimization.Release), ConfigurePriority(3)] + public virtual void ConfigureRelease(Configuration conf, Target target) + { + } + } + + /// + /// This is the base class for sharpmake project needing compilation. + /// + [Sharpmake.Generate] + public class CommonProject : Project + { + public string TmpPath = @"[project.SharpmakeCsPath]\..\tmp"; + public string OutputPath = @"[project.SharpmakeCsPath]\..\bin"; + public string ExternPath = @"[project.SharpmakeCsPath]\..\extern"; + + public CommonProject() + { + AddTargets(SampleTargets.Targets); + + SourceRootPath = @"[project.SharpmakeCsPath]\..\src\[project.Name]"; + } + + + [Configure(), ConfigurePriority(1)] + public virtual void ConfigureAll(Configuration conf, Target target) + { + conf.ProjectFileName = "[project.Name]_[target.DevEnv]"; + conf.ProjectPath = @"[project.TmpPath]\projects\[project.Name]"; + conf.TargetPath = @"[project.OutputPath]\[target.Optimization]-[target.BuildSystem]"; + conf.IntermediatePath = @"[project.TmpPath]\[project.Name]\[target.Optimization]-[target.BuildSystem]"; + if ((target.BuildSystem & BuildSystem.FastBuild) != 0) + conf.Name += "_FastBuild"; + + conf.Options.Add(Sharpmake.Options.Vc.Compiler.CppLanguageStandard.CPP17); + conf.Options.Add(Sharpmake.Options.Vc.Compiler.ConformanceMode.Enable); + conf.AdditionalCompilerOptions.Add("/Zo"); + conf.LinkerPdbSuffix = string.Empty; + + conf.TargetFileSuffix = (target.Optimization == Optimization.Debug) ? "_d" : ""; + conf.Options.Add(new Sharpmake.Options.Vc.Librarian.DisableSpecificWarnings( + "4221" // This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library + )); + + conf.Options.Add(new Sharpmake.Options.Vc.Compiler.DisableSpecificWarnings( + "4100", // unreferenced formal parameter + "4324" // structure was padded due to alignment specifier + )); + + conf.Options.Add(Sharpmake.Options.Vc.Linker.GenerateMapFile.Disable); + + conf.Defines.Add("WIN32_LEAN_AND_MEAN"); + } + + [Configure(Optimization.Debug), ConfigurePriority(2)] + public virtual void ConfigureDebug(Configuration conf, Target target) + { + conf.Options.Add(Sharpmake.Options.Vc.Compiler.Inline.Disable); + } + + [Configure(Optimization.Release), ConfigurePriority(3)] + public virtual void ConfigureRelease(Configuration conf, Target target) + { + conf.Options.Add(Sharpmake.Options.Vc.Compiler.Optimization.MaximizeSpeed); + conf.Options.Add(Sharpmake.Options.Vc.General.WholeProgramOptimization.LinkTime); + conf.Options.Add(Sharpmake.Options.Vc.Linker.LinkTimeCodeGeneration.UseLinkTimeCodeGeneration); + conf.Options.Add(Sharpmake.Options.Vc.Linker.EnableCOMDATFolding.RemoveRedundantCOMDATs); + conf.Options.Add(Sharpmake.Options.Vc.Linker.Reference.EliminateUnreferencedData); + } + + [Configure(BuildSystem.FastBuild)] + public void ConfigureFastBuild(Configuration conf, Target target) + { + conf.IsFastBuild = true; + conf.FastBuildUnityPath = @"[project.TmpPath]\projects\[project.Name]\Unity"; + } + } +} diff --git a/samples/vcpkg/sharpmake/externprojects.sharpmake.cs b/samples/vcpkg/sharpmake/externprojects.sharpmake.cs new file mode 100644 index 000000000..525e5c348 --- /dev/null +++ b/samples/vcpkg/sharpmake/externprojects.sharpmake.cs @@ -0,0 +1,99 @@ +using Sharpmake; + +namespace VCPKGSample.Extern +{ + // Add a dependency to this project to be able to use vcpkg packages in a project. + // + // This project then setup the necessary include and library paths to be able to reference any installed vcpkg package in + // our local vcpackage installation. + // + // Note: The required vcpkg packages are installed by bootstrap-sample.bat + // + [Sharpmake.Export] + public class VCPKG : ExportProject + { + public override void ConfigureRelease(Configuration conf, Target target) + { + base.ConfigureRelease(conf, target); + + // Add root include path for vcpkg packages. + conf.IncludePaths.Add(@"[project.SharpmakeCsPath]\..\extern\vcpkg\installed\x64-windows-static\include"); + + // Add root lib path for vcpkg packages. + conf.LibraryPaths.Add(@"[project.SharpmakeCsPath]\..\extern\vcpkg\installed\x64-windows-static\lib"); + + } + + public override void ConfigureDebug(Configuration conf, Target target) + { + base.ConfigureDebug(conf, target); + + // Add root include path for vcpkg packages. + conf.IncludePaths.Add(@"[project.SharpmakeCsPath]\..\extern\vcpkg\installed\x64-windows-static\include"); + + // Add root lib path for vcpkg packages. + conf.LibraryPaths.Add(@"[project.SharpmakeCsPath]\..\extern\vcpkg\installed\x64-windows-static\debug\lib"); + } + } + + // Curl is a vcpkg package. The package is installed by bootstrap-sample.bat + [Sharpmake.Export] + class Curl : VCPKG + { + public override void ConfigureAll(Configuration conf, Target target) + { + base.ConfigureAll(conf, target); + + conf.AddPublicDependency(target); + + // Dependencies on windows libraries when using Curl + conf.LibraryFiles.Add("Crypt32.lib", "Wldap32.lib", "wsock32", "ws2_32"); + } + + public override void ConfigureDebug(Configuration conf, Target target) + { + base.ConfigureDebug(conf, target); + + conf.LibraryFiles.Add(@"libcurl-d.lib"); + } + + public override void ConfigureRelease(Configuration conf, Target target) + { + base.ConfigureRelease(conf, target); + + conf.LibraryFiles.Add(@"libcurl.lib"); + } + } + + + // ZLib is a vcpkg package. The package is installed by bootstrap-sample.bat as a dependency to curl. + [Sharpmake.Export] + class ZLib : VCPKG + { + public override void ConfigureAll(Configuration conf, Target target) + { + base.ConfigureAll(conf, target); + } + + public override void ConfigureDebug(Configuration conf, Target target) + { + base.ConfigureDebug(conf, target); + + conf.LibraryFiles.Add("zlibd.lib"); + } + + public override void ConfigureRelease(Configuration conf, Target target) + { + base.ConfigureRelease(conf, target); + + conf.LibraryFiles.Add("zlib.lib"); + } + } + + // RapidJSON is a vcpkg package. The package is installed by bootstrap-sample.bat + // This project is header only. + [Sharpmake.Export] + class RapidJSON : VCPKG + { + } +} diff --git a/samples/vcpkg/sharpmake/main.sharpmake.cs b/samples/vcpkg/sharpmake/main.sharpmake.cs new file mode 100644 index 000000000..dc6bfbc8c --- /dev/null +++ b/samples/vcpkg/sharpmake/main.sharpmake.cs @@ -0,0 +1,32 @@ +using Sharpmake; +using System.IO; + +[module: Sharpmake.Include("baseclasses.sharpmake.cs")] +[module: Sharpmake.Include("externprojects.sharpmake.cs")] +[module: Sharpmake.Include("projects.sharpmake.cs")] + + +namespace VCPKGSample +{ + public static class Main + { + [Sharpmake.Main] + public static void SharpmakeMain(Sharpmake.Arguments arguments) + { + + FileInfo sharpmakeFileInfo = Util.GetCurrentSharpmakeFileInfo(); + string sharpmakeFileDirectory = Util.PathMakeStandard(sharpmakeFileInfo.DirectoryName); + string absoluteRootPath = Util.PathGetAbsolute(sharpmakeFileDirectory, @"..\tmp"); + + // This is necessary since there is no rc.exe in the same directory than link.exe + FastBuildSettings.SetPathToResourceCompilerInEnvironment = true; + FastBuildSettings.FastBuildMakeCommand = Util.PathGetAbsolute(sharpmakeFileDirectory, @"..\..\..\tools\FastBuild\Windows-x64\FBuild.exe"); + + Util.FilesAutoCleanupDBPath = absoluteRootPath; + Util.FilesAutoCleanupActive = true; + arguments.Generate(); + + + } + } +} diff --git a/samples/vcpkg/sharpmake/projects.sharpmake.cs b/samples/vcpkg/sharpmake/projects.sharpmake.cs new file mode 100644 index 000000000..ec60cd470 --- /dev/null +++ b/samples/vcpkg/sharpmake/projects.sharpmake.cs @@ -0,0 +1,48 @@ +using Sharpmake; + +namespace VCPKGSample +{ + [Sharpmake.Generate] + public class VCPKGSample : CommonProject + { + public VCPKGSample() + { + Name = "VCPKGSample"; + } + + public override void ConfigureAll(Configuration conf, Target target) + { + base.ConfigureAll(conf, target); + conf.Output = Configuration.OutputType.Exe; + conf.Options.Add(Options.Vc.Compiler.Exceptions.Enable); + + conf.AddPrivateDependency(target); + conf.AddPrivateDependency(target); + } + } + + [Sharpmake.Generate] + public class VCPKGSampleSolution : Sharpmake.Solution + { + public VCPKGSampleSolution() + { + Name = "VCPKGSample"; + + AddTargets(SampleTargets.Targets); + ExtraItems.Add("Markdown", new Strings() + { + @"[solution.SharpmakeCsPath]/../README.md", + }); + } + + [Configure()] + public void ConfigureAll(Configuration conf, Target target) + { + conf.SolutionFileName = "[solution.Name]_[target.DevEnv]"; + conf.SolutionPath = @"[solution.SharpmakeCsPath]\..\tmp\projects"; + if ((target.BuildSystem & BuildSystem.FastBuild) != 0) + conf.Name += "_FastBuild"; + conf.AddProject(target); + } + } +} diff --git a/samples/vcpkg/src/vcpkgsample/main.cpp b/samples/vcpkg/src/vcpkgsample/main.cpp new file mode 100644 index 000000000..22e0b8a4b --- /dev/null +++ b/samples/vcpkg/src/vcpkgsample/main.cpp @@ -0,0 +1,19 @@ +#include +#include +#include + + +int main(int argc, char** argv) +{ + CURL* curlHandle = curl_easy_init(); + // TODO... do some stuff + curl_easy_cleanup(curlHandle); + + + // Do some useless stuff with rapidjson + rapidjson::Document jsonDoc; + jsonDoc.SetArray(); + rapidjson::Value newSection(rapidjson::kObjectType); + newSection.AddMember("count", 0, jsonDoc.GetAllocator()); + jsonDoc.PushBack(newSection, jsonDoc.GetAllocator()); +} diff --git a/samples/vcpkg/update-vcpkg-packages.bat b/samples/vcpkg/update-vcpkg-packages.bat new file mode 100644 index 000000000..8f6e15c4d --- /dev/null +++ b/samples/vcpkg/update-vcpkg-packages.bat @@ -0,0 +1,59 @@ +@echo off +:: This batch file is used to update the vcpkg packages that we need for this sample. The packages +:: are then exported in a zip file ready for consumption on build machine or programmer pc. + +SETLOCAL +SET VCPKG_LIST=curl:x64-windows-static rapidjson:x64-windows-static +SET VCPKG_TMPFOLDER=%~dp0\tmp\vcpkg + +CALL :GET_VCPKG +IF ERRORLEVEL 1 exit /b %ERRORLEVEL% + +CALL :BUILD_VCPKG +IF ERRORLEVEL 1 exit /b %ERRORLEVEL% + +CALL :INSTALL_VCPKG_PACKAGES +IF ERRORLEVEL 1 exit /b %ERRORLEVEL% + +CALL :GENERATE_VCPKG_EXPORT +IF ERRORLEVEL 1 exit /b %ERRORLEVEL% + + +:: Cleanup +EXIT /B %ERRORLEVEL% + +:: ------------ FUNCTIONS ---------- + +:: clone vcpkg in a temporary folder +:GET_VCPKG +IF NOT EXIST %VCPKG_TMPFOLDER% GOTO CLONE_VCPKG +GOTO PULL_VCPKG + +:CLONE_VCPKG +echo clone vcpkg +git clone https://github.com/microsoft/vcpkg.git %VCPKG_TMPFOLDER% +exit /B %ERRORLEVEL% + +:PULL_VCPKG +echo pull latest vcpkg +pushd %VCPKG_TMPFOLDER% +git pull +popd +exit /B %ERRORLEVEL% + +:: Bootstrap vcpkg executable +:BUILD_VCPKG +IF EXIST %VCPKG_TMPFOLDER%\vcpkg.exe exit /B 0 +call %VCPKG_TMPFOLDER%\bootstrap-vcpkg.bat +exit /B %ERRORLEVEL% + +:: Install required vcpkg packages +:INSTALL_VCPKG_PACKAGES +%VCPKG_TMPFOLDER%\vcpkg.exe install %VCPKG_LIST% +exit /B %ERRORLEVEL% + +:: Generate export package. This is what we submit in git +:: This package then need to be decompressed to be used. Will be decompresssed in extern/vcpkg +:GENERATE_VCPKG_EXPORT +%VCPKG_TMPFOLDER%\vcpkg.exe export %VCPKG_LIST% --zip --output=vcpkg --output-dir=%~dp0\extern +exit /B %ERRORLEVEL% diff --git a/tools/FastBuild/Linux-x64/fbuild b/tools/FastBuild/Linux-x64/fbuild new file mode 100644 index 000000000..23957c9c9 Binary files /dev/null and b/tools/FastBuild/Linux-x64/fbuild differ diff --git a/tools/FastBuild/FBuild b/tools/FastBuild/OSX-x64/FBuild similarity index 100% rename from tools/FastBuild/FBuild rename to tools/FastBuild/OSX-x64/FBuild diff --git a/tools/FastBuild/FBuild.exe b/tools/FastBuild/Windows-x64/FBuild.exe similarity index 100% rename from tools/FastBuild/FBuild.exe rename to tools/FastBuild/Windows-x64/FBuild.exe