From 21c6f07e61814a9aee645d8d7e4aa9190e73644b Mon Sep 17 00:00:00 2001 From: Zhenhua Yao Date: Wed, 28 Mar 2018 15:03:50 -0700 Subject: [PATCH] Add ossbuild for build support on GitHub Common-RSL commit 89adfe794d9682ecff196d0d108b9229e60aa48e --- .config/.inc/versions.xml | 5 ++ .config/build.props | 75 +++++++++++++++++++++++++ .gitignore | 5 ++ ossbuild/Microsoft.CSharp.targets | 40 +++++++++++++ ossbuild/Microsoft.Cpp.Default.props | 23 ++++++++ ossbuild/Microsoft.cpp.props | 4 ++ ossbuild/Microsoft.cpp.targets | 16 ++++++ ossbuild/NoTarget.targets | 72 ++++++++++++++++++++++++ ossbuild/Traversal.targets | 27 +++++++++ ossbuild/ossbuildenv.props | 65 +++++++++++++++++++++ ossbuild/ossbuildenv.ps1 | 84 ++++++++++++++++++++++++++++ src/build/native.props | 2 +- src/lib/RSLib.vcxproj | 4 +- src/packages.config | 7 +++ 14 files changed, 426 insertions(+), 3 deletions(-) create mode 100644 .config/.inc/versions.xml create mode 100644 .config/build.props create mode 100644 ossbuild/Microsoft.CSharp.targets create mode 100644 ossbuild/Microsoft.Cpp.Default.props create mode 100644 ossbuild/Microsoft.cpp.props create mode 100644 ossbuild/Microsoft.cpp.targets create mode 100644 ossbuild/NoTarget.targets create mode 100644 ossbuild/Traversal.targets create mode 100644 ossbuild/ossbuildenv.props create mode 100644 ossbuild/ossbuildenv.ps1 create mode 100644 src/packages.config diff --git a/.config/.inc/versions.xml b/.config/.inc/versions.xml new file mode 100644 index 0000000..3fd8ea9 --- /dev/null +++ b/.config/.inc/versions.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/.config/build.props b/.config/build.props new file mode 100644 index 0000000..d2af69c --- /dev/null +++ b/.config/build.props @@ -0,0 +1,75 @@ + + + + + + + Microsoft Corporation + Microsoft Azure%ae + Copyright %a9 Microsoft Corporation. All rights reserved. + + + + + false + + + + + false + + + + + $(PkgNuGet_CommandLine)\tools + + + + + false + 4.3.0.8 + + + + $(OutputRoot)\$(BuildType)-$(BuildArchitecture)\Headers + + + + $(OutputRoot)\$(BuildType)-$(BuildArchitecture)\Binaries + + + + $(PkgTaef_amd64)\Binaries\Release\x64\TestExecution\ + + + + + + $(PkgVisualCpp_Corext)\bin\x64\$(_BuildArch)\lib.exe + + + + + lib.exe + + + + + diff --git a/.gitignore b/.gitignore index 940794e..4aac928 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,11 @@ bld/ [Bb]in/ [Oo]bj/ [Ll]og/ +objd/ +obj/ +ossbuild/packageList.props +/out/ +.*.swp # Visual Studio 2015 cache/options directory .vs/ diff --git a/ossbuild/Microsoft.CSharp.targets b/ossbuild/Microsoft.CSharp.targets new file mode 100644 index 0000000..762e472 --- /dev/null +++ b/ossbuild/Microsoft.CSharp.targets @@ -0,0 +1,40 @@ + + + + + + $(AssemblyName)\ + + $(TargetName)\ + + $(MSBuildProjectName) + $(OUTPUTROOT)\$(BuildType)-$(BuildArchitecture) + $(BinariesBuildTypeArchDirectory)\$(OutDirSuffix) + $(OutDir) + + + + + <_Parameter1>$(AssemblyCompany) + <_Parameter1>$(AssemblyCopyright) + <_Parameter1>$(GitRepositoryName) $(GitBranchName) commit $(VersionCommitHash) on $(BuildDate) + <_Parameter1>$(BUILDNUMBER) + <_Parameter1>$(AssemblyInformationalVersion) + <_Parameter1>$(AssemblyProduct) + <_Parameter1>$(AssemblyName) + <_Parameter1>$(BUILDNUMBER) + + + + + + + + + + + + diff --git a/ossbuild/Microsoft.Cpp.Default.props b/ossbuild/Microsoft.Cpp.Default.props new file mode 100644 index 0000000..fa42c2a --- /dev/null +++ b/ossbuild/Microsoft.Cpp.Default.props @@ -0,0 +1,23 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + diff --git a/ossbuild/Microsoft.cpp.props b/ossbuild/Microsoft.cpp.props new file mode 100644 index 0000000..ce33a3d --- /dev/null +++ b/ossbuild/Microsoft.cpp.props @@ -0,0 +1,4 @@ + + + + diff --git a/ossbuild/Microsoft.cpp.targets b/ossbuild/Microsoft.cpp.targets new file mode 100644 index 0000000..debdc84 --- /dev/null +++ b/ossbuild/Microsoft.cpp.targets @@ -0,0 +1,16 @@ + + + + + + $(AssemblyName)\ + + $(TargetName)\ + + $(MSBuildProjectName) + $(OUTPUTROOT)\$(BuildType)-$(BuildArchitecture) + $(BinariesBuildTypeArchDirectory)\$(OutDirSuffix) + $(OutDir) + $(OutDir)$(TargetName)$(TargetExt) + + diff --git a/ossbuild/NoTarget.targets b/ossbuild/NoTarget.targets new file mode 100644 index 0000000..8eacaf6 --- /dev/null +++ b/ossbuild/NoTarget.targets @@ -0,0 +1,72 @@ + + + + + + + + + + + + shouldCopy = filePath => { + var dir = Path.GetDirectoryName(filePath); + var name = Path.GetFileName(filePath); + var ext = Path.GetExtension(filePath).ToUpperInvariant(); + if (!copySymbol && ext == ".PDB") + return false; + + if (!string.IsNullOrEmpty(dirExclude) && Regex.IsMatch(dir, dirExclude, RegexOptions.IgnoreCase)) + return false; + + return true; + }; + + Log.LogMessage(MessageImportance.High, "Robocopy: {0} -> {1} recursive: '{2}'", item, dest, isRecursive); + if (!Directory.Exists(dest)) { + Directory.CreateDirectory(dest); + } + + if (!string.IsNullOrEmpty(isRecursive) && + string.Equals(isRecursive, "true", StringComparison.OrdinalIgnoreCase) && + Directory.Exists(item)) { + var files = Directory.EnumerateFiles(item, "*.*", SearchOption.AllDirectories); + foreach (var f in files) { + if (!File.Exists(f)) // skip directories + continue; + + var fName = f.Substring(item.Length + 1); + var dName = Path.Combine(dest, fName); + var destDir = Path.GetDirectoryName(dName); + if (!Directory.Exists(destDir)) + Directory.CreateDirectory(destDir); + Log.LogMessage("Copy {0} -> {1}", f, dName); + File.Copy(f, dName, true); + } + } + else { + var destFile = Path.Combine(dest, Path.GetFileName(item)); + Log.LogMessage("Copy {0} -> {1}", item, destFile); + File.Copy(item, destFile, true); + } + } + ]]> + + + + + + + + + diff --git a/ossbuild/Traversal.targets b/ossbuild/Traversal.targets new file mode 100644 index 0000000..54a201c --- /dev/null +++ b/ossbuild/Traversal.targets @@ -0,0 +1,27 @@ + + + + $(MsBuildAllProjects);$(MsBuildThisFileFullPath) + true + true + false + + + + + + + + + + + + + + diff --git a/ossbuild/ossbuildenv.props b/ossbuild/ossbuildenv.props new file mode 100644 index 0000000..cfbab18 --- /dev/null +++ b/ossbuild/ossbuildenv.props @@ -0,0 +1,65 @@ + + + + $(MsBuildAllProjects);$(MsBuildThisFileFullPath) + + + + $(REPOROOT)\ossbuild + + $(OBJECT_ROOT) + $(_NTTREE) + + $(BaseDir)\out\obj + $(BaseDir)\out\bin + + Debug + x64 + + $(_defaultBuildArch) + amd64 + amd64 + + $(_BuildArch) + amd64 + $(DefaultBuildArchitecture) + + retail + debug + + d + obj$(BUILD_ALT_DIR) + $(ObjectDirectory)\ + $(BaseIntermediateOutputPath)$(BuildArchitecture)\ + $(IntermediateOutputPath) + $(MSBuildProjectDirectory.Substring($(BaseDir.Length))) + $(ObjectRoot)$(ProjectDirRelativeToBaseDir)\$(O) + $(OutputPath) + + true + + + + + + + + + + + + + + + + + $(MSBuildProgramFiles32)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.2 + $(DevEnvDir)\PublicAssemblies + + $(PkgNuproj)\tools + + + + + diff --git a/ossbuild/ossbuildenv.ps1 b/ossbuild/ossbuildenv.ps1 new file mode 100644 index 0000000..ddb997d --- /dev/null +++ b/ossbuild/ossbuildenv.ps1 @@ -0,0 +1,84 @@ +#Requires -version 3.0 +param( + [string] $PackagesDirectory = $null +) + +# Go to C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\Tools, run VsMSBuildCmd.bat, +# and start PowerShell. +Set-StrictMode -version latest + +function SetEnv +{ + # Get the root directory + $repoRoot = Join-Path -Resolve $PSScriptRoot ".." + $srcRoot = Join-Path -Resolve $repoRoot "src" + $outRoot = Join-Path $repoRoot "out" + $buildPropsRoot = Join-Path -Resolve $PSScriptRoot "ossbuildenv.props" + $confRoot = Join-Path -Resolve $repoRoot ".config" + $verPath = Join-Path -Resolve $confRoot ".inc" + $asmVerDefFile = Join-Path -Resolve $verPath "versions.xml" + + $verXml = [XML](Get-Content $asmVerDefFile) + $ver = $verXml.root.versions.version.value + + $env:REPOROOT = $repoRoot + $env:BaseDir = $repoRoot + $env:EnlistmentRoot = $repoRoot + $env:INETROOT = $repoRoot + $env:OBJECT_ROOT = $repoRoot + $env:ROOT = $repoRoot + $env:_NTTREE = $repoRoot + + $env:SRCROOT = $srcRoot + $env:OUTPUTROOT = $outRoot + + $env:EnvironmentConfig = $buildPropsRoot + $env:CONFROOT = $confRoot + $env:AssemblyVersionDefinitionFile = $asmVerDefFile + + $env:OSSBUILD = "1" + $env:BUILD_COREXT = "0" + $env:NOTQBUILD = "1" + $env:MsBuildArgs = "/consoleloggerparameters:Summary;ForceNoAlign;Verbosity=minimal" + $env:BUILDNUMBER = $ver +} + +function CreatePackagesProps($rootDir) +{ + $rootDir = [IO.Path]::GetFullPath($rootDir) + $propsFile = Join-Path $PSScriptRoot "packageList.props" + + # Restore all nuget packages + $conf = Join-Path -Resolve $PSScriptRoot "..\src\packages.config" + & nuget restore $conf -PackagesDirectory $rootDir + + # Then generate packageList.props for MSBuild + $content = @() + $content += "" + $content += " " + + $pkgXml = [XML](Get-Content $conf) + $pkgXml.packages.package | % { + $id = $_.id + $ver = $_.version + $dir = Join-Path $rootDir "$id.$ver" + $name = "Pkg" + ($id.Replace('.', '_')) + $content += " <$name>$dir" + } + + $content += " " + $content += "" + $content | Out-File -FilePath $propsFile -Encoding utf8 -Force +} + +####################################################################################################################### + +if ([string]::IsNullOrEmpty($PackagesDirectory)) { + $PackagesDirectory = Join-Path $PSScriptRoot "..\packages" + if (-not (Test-Path -PathType Container $PackagesDirectory)) { + mkdir $PackagesDirectory + } +} + +SetEnv +CreatePackagesProps $PackagesDirectory diff --git a/src/build/native.props b/src/build/native.props index 9e7eb24..a79bbdb 100644 --- a/src/build/native.props +++ b/src/build/native.props @@ -6,7 +6,6 @@ - 10.0.15063.0 false + + + +