diff --git a/build/BuildEnv.shade b/build/BuildEnv.shade new file mode 100644 index 0000000000..625ccb7056 --- /dev/null +++ b/build/BuildEnv.shade @@ -0,0 +1,14 @@ + +use namespace="System" + +functions + @{ + string BuildNumber + { + get + { + return Environment.GetEnvironmentVariable("BUILD_NUMBER") ?? + "t" + DateTime.UtcNow.ToString("yyMMddHHmmss"); + } + } + } diff --git a/build/_k-generate-projects.shade b/build/_k-generate-projects.shade index 084cf2bf64..c4d37c8c17 100644 --- a/build/_k-generate-projects.shade +++ b/build/_k-generate-projects.shade @@ -185,6 +185,7 @@ functions var d = serializer.DeserializeObject(jsonText) as IDictionary; var configs = GetObject(d, "configurations") ?? new Dictionary(); var dependencies = GetObject(d, "dependencies") ?? new Dictionary(); + var compilationOptions = GetObject(d, "compilationOptions") ?? new Dictionary(); if(configs.Count == 0) { @@ -208,6 +209,10 @@ functions .Select(r => r.Key) .ToList(); + var sharedDefines = Get>(compilationOptions, "define") ?? new object[0]; + object unsafeValue = Get(compilationOptions, "allowUnsafe"); + bool sharedAllowUnsafeCode = unsafeValue == null ? false : (bool)unsafeValue; + // HACK: Assume the packages folder is 2 up from the projectDir string packagesDir = Path.GetFullPath(Path.Combine(projectDir, "..", "..", "packages")); @@ -218,16 +223,22 @@ functions var targetFramework = pair.Key; var props = (IDictionary)pair.Value; - var compilationOptions = GetObject(props, "compilationOptions") ?? new Dictionary(); + var specificCompilationOptions = GetObject(props, "compilationOptions") ?? compilationOptions ?? new Dictionary(); - var defines = Get>(compilationOptions, "define") ?? new object[0]; - object unsafeValue = Get(compilationOptions, "allowUnsafe"); - bool allowUnsafeCode = unsafeValue == null ? false : (bool)unsafeValue; + var specificDefines = Get>(specificCompilationOptions, "define") ?? new object[0]; + object specificUnsafeValue = Get(specificCompilationOptions, "allowUnsafe"); + bool allowUnsafeCode = unsafeValue == null ? sharedAllowUnsafeCode : (bool)specificUnsafeValue; string extraProperties = allowUnsafeCode ? "\ntrue" : ""; string id = (string)GetObject(projectMapping, projectName)[targetFramework]; + var defines = new HashSet(specificDefines.Select(sd => sd.ToString())); + foreach(var def in sharedDefines) + { + defines.Add(def.ToString()); + } + var specificDependencies = GetObject(props, "dependencies") ?? new Dictionary(); var gacReferences = new List(); @@ -255,7 +266,7 @@ functions var template = templates[targetFramework] .Replace("{ProjectGuid}", id) .Replace("{Name}", projectName) - .Replace("{Defines}", String.Join(";", defines.Select(def => def.ToString()))) + .Replace("{Defines}", String.Join(";", defines)) .Replace("{ExtraProperties}", extraProperties) .Replace("{Files}", filesString) .Replace("{ProjectReferences}", BuildProjectReferences(projectReferences, targetFramework, projectMapping)) diff --git a/build/_k-standard-goals.shade b/build/_k-standard-goals.shade index b4a59fccb9..311387bc2f 100644 --- a/build/_k-standard-goals.shade +++ b/build/_k-standard-goals.shade @@ -1,6 +1,7 @@ use namespace="System" use namespace="System.IO" use import="Files" +use import="BuildEnv" default BASE_DIR='${Directory.GetCurrentDirectory()}' default TARGET_DIR='${Path.Combine(BASE_DIR, "artifacts")}' @@ -8,7 +9,7 @@ default BUILD_DIR='${Path.Combine(TARGET_DIR, "build")}' default TEST_DIR='${Path.Combine(TARGET_DIR, "test")}' @{ - E("K_BUILD_VERSION", "t" + DateTime.UtcNow.ToString("yyMMddHHmmss")); + E("K_BUILD_VERSION", BuildNumber); } #target-default target='default' diff --git a/makefile.shade b/makefile.shade index a12f88c6a4..1bf5ee5500 100644 --- a/makefile.shade +++ b/makefile.shade @@ -1,10 +1,11 @@ var PROJECT='AspNet' -var VERSION='0.1.${Environment.GetEnvironmentVariable("BUILD_NUMBER") ?? "0"}' +var VERSION='0.2.0-dev' use namespace='System' use namespace='System.IO' use namespace='System.Collections.Generic' +use import="BuildEnv" var repos='${new Dictionary { {"HttpAbstractions", "git@github.com:aspnet/HttpAbstractions.git"}, @@ -19,6 +20,10 @@ var repos='${new Dictionary { default BASE_DIR='${Directory.GetCurrentDirectory()}' default TARGET_DIR='${Path.Combine(BASE_DIR, "artifacts", "build")}' +@{ + VERSION += "-" + BuildNumber; +} + #default .compile #pull