From 069f8a23f8026f35cdc6aad26902c45d8aae1506 Mon Sep 17 00:00:00 2001 From: ashwini Date: Fri, 2 Aug 2019 13:25:17 -0400 Subject: [PATCH] Download dependencies based on platform --- external/buildscripts/Build.bee.cs | 190 ++++++++++---------- external/buildscripts/buildDependencies.txt | 56 ------ 2 files changed, 93 insertions(+), 153 deletions(-) delete mode 100644 external/buildscripts/buildDependencies.txt diff --git a/external/buildscripts/Build.bee.cs b/external/buildscripts/Build.bee.cs index a21c607ea015..1df7df62c352 100644 --- a/external/buildscripts/Build.bee.cs +++ b/external/buildscripts/Build.bee.cs @@ -1,132 +1,128 @@ using System; -using System.IO; +using System.Collections.Generic; using Bee.Core; using Bee.Stevedore; -using NiceIO; -using Unity.BuildTools; -using System.Collections.Generic; -using System.Text; using Bee.Stevedore.Program; +using Unity.BuildSystem.NativeProgramSupport; namespace BuildProgram { public class BuildProgram { + private static readonly Dictionary> Artifacts = new Dictionary>(); + internal static void Main() { - if (IsRunningOnBuildMachine()) - Console.WriteLine("\n>>> Running on build machine"); - - var monoRoot = GetMonoRootDir(); - Console.WriteLine(">>> Mono root directory: " + monoRoot); - - var buildScriptsRoot = monoRoot.Combine("external").Combine("buildscripts"); - Console.WriteLine(">>> Build scripts directory: " + buildScriptsRoot); - - var buildDependenciesConfigFile = buildScriptsRoot.Combine("buildDependencies.txt"); - Console.WriteLine(">>> Mono build dependecies stevedore version config file: " + buildDependenciesConfigFile); + RegisterCommonArtifacts(); - var stevedoreArtifactsDir = buildScriptsRoot.Combine("artifacts").Combine("Stevedore"); - Console.WriteLine(">>> Stevedore artifacts directory: " + stevedoreArtifactsDir + "\n"); - - if (buildDependenciesConfigFile.Exists()) + if (Platform.HostPlatform is WindowsPlatform) + { + RegisterWindowsArtifacts(); + } + else { - var artifactList = ParseBuildDependenciesConfigFile(buildDependenciesConfigFile.ToString()); + RegisterCommonNonWindowsArtifacts(); - foreach (var item in artifactList) + if (Platform.HostPlatform is MacOSXPlatform) + { + RegisterOSXArtifacts(); + } + else if (Platform.HostPlatform is LinuxPlatform) { - var artifactName = item.Item1; - var artifactId = item.Item2; - var repoName = new RepoName(item.Item3); - DownloadArtifact(artifactId, artifactName, repoName); + RegisterLinuxArtifacts(); } } - else + + foreach (var artifact in Artifacts) { - throw new Exception($"{buildDependenciesConfigFile} does not exist"); + var name = artifact.Key; + var id = artifact.Value.Item1; + var repo = new RepoName(artifact.Value.Item2); + + Console.WriteLine($">>> Registering artifact {name}"); + var stevedoreArtifact = new StevedoreArtifact(repo, new ArtifactId(id)); + Backend.Current.Register(stevedoreArtifact); } } - private static void DownloadArtifact(string artifactId, string artifactName, RepoName repoName) + private static void RegisterCommonArtifacts() { - Console.WriteLine($">>> Registering artifact {artifactName}"); - var artifact = new StevedoreArtifact(repoName, new ArtifactId(artifactId)); - Backend.Current.Register(artifact); + Artifacts.Add("7z", + new Tuple( + "7z/9df1e3b3b120_12ed325f6a47f0e5cebc247dbe9282a5da280d392cce4e6c9ed227d57ff1e2ff.7z", + "testing")); + + Artifacts.Add("MonoBleedingEdge", + new Tuple( + "MonoBleedingEdge/9df1e3b3b120_ab6d2f131e6bd4fe2aacafb0f683e8fa4e1ccba35552b6fe89bf359b6ee16215.7z", + "testing")); + + Artifacts.Add("reference-assemblies", + new Tuple( + "reference-assemblies/9df1e3b3b120_bbb4750c6bf0a1784bec7d7c04b8ef5881f31f6212136e014694f3864a388886.7z", + "testing")); } - private static NPath GetMonoRootDir() + private static void RegisterWindowsArtifacts() { - var exePath = new NPath(System.Reflection.Assembly.GetEntryAssembly().Location); - var monoRoot = exePath; - - //Assume "external" directory exists under monoRoot. - while (monoRoot.ToString().Contains("external")) - monoRoot = monoRoot.Parent; - - return monoRoot; + Artifacts.Add("android-ndk-r16b-windows", + new Tuple( + "android-ndk-r16b-windows/9df1e3b3b120_403e0d58eabae03f0d9e8d1d2cea2dbf1d14c380c3d1c7eeb6e8c60ffc15e1b8.7z", + "testing")); } - private static bool IsRunningOnBuildMachine() + private static void RegisterOSXArtifacts() { - var buildMachine = Environment.GetEnvironmentVariable("UNITY_THISISABUILDMACHINE"); - return buildMachine != null && buildMachine == "1"; + Artifacts.Add("android-ndk-r16b-darwin", + new Tuple( + "android-ndk-r16b-darwin/9df1e3b3b120_c7cda5a221dd72799b7e618597b3f8766df7183d386becb2785631c2d3ac0d75.7z", + "testing")); + + Artifacts.Add("MacBuildEnvironment", + new Tuple( + "MacBuildEnvironment/9df1e3b3b120_2fc8e616a2e5dfb7907fc42d9576b427e692223c266dc3bc305de4bf03714e30.7z", + "testing")); } - //Sample config file format: - /* - # Dependencoes to pull down from Stevedore. Please follow the following format: - # name : - # id : - # repo : - - name: 7z - id: 7z/9df1e3b3b120_12ed325f6a47f0e5cebc247dbe9282a5da280d392cce4e6c9ed227d57ff1e2ff.7z - repo: testing - - name: libgdiplus - id : libgdiplus/9df1e3b3b120_4cf7c08770db93922f54f38d2461b9122cddc898db58585864446e70c5ad3057.7z - repo: public - */ - private static List> ParseBuildDependenciesConfigFile(string buildDependenciesConfigFile) + private static void RegisterLinuxArtifacts() { - var artifactNameIdFilesDictionary = new List>(); + Artifacts.Add("android-ndk-r16b-linux", + new Tuple( + "android-ndk-r16b-linux/9df1e3b3b120_fbabd18208d82cbc810266e8b566bb0ea4e1e438de38d450a92deaa3e23757b6.7z", + "testing")); + + Artifacts.Add("linux-sdk-20170609", + new Tuple( + "linux-sdk-20170609/9df1e3b3b120_9a3a0847d5b3767579e908b5a9ce050936617b1b9275a79a8b71bb3229998957.7z", + "testing")); + } - var fileStream = new FileStream(buildDependenciesConfigFile, FileMode.Open, FileAccess.Read); - using (var streamReader = new StreamReader(fileStream, Encoding.UTF8)) - { - string line; - while ((line = streamReader.ReadLine()) != null) - { - //Check if line contains a comment - if (!string.IsNullOrEmpty(line) && !line.Contains("#")) - { - if (line.Contains("name :") || line.Contains("name:")) - { - var name = ""; - var id = ""; - var repoName = ""; - - //read name - name = line.Split(':')[1].Trim(); - - //read id - if ((line = streamReader.ReadLine()) != null) - id = line.Split(':')[1].Trim(); - else - throw new Exception($">>> Invalid {buildDependenciesConfigFile}, id name does not exist"); - - //read repo name - if ((line = streamReader.ReadLine()) != null) - repoName = line.Split(':')[1].Trim(); - else - throw new Exception($">>> Invalid {buildDependenciesConfigFile}, repo name does not exist"); - - artifactNameIdFilesDictionary.Add(new Tuple(name, id, repoName)); - } - } - } - } - return artifactNameIdFilesDictionary; + private static void RegisterCommonNonWindowsArtifacts() + { + Artifacts.Add("libtool-src", + new Tuple( + "libtool-src/2.4.6_49a0ed204b3b24572e044400cd05513f611bcca6ced0d0816a57ac3b17376257.7z", + "public")); + + Artifacts.Add("texinfo-src", + new Tuple( + "texinfo-src/4.8_975b9657ebef8a4fe3897047ca450b757a0a956b05399dc813f63e84829bac6a.7z", + "public")); + + Artifacts.Add("automake-src", + new Tuple( + "automake-src/1.16.1_d281b950e26265f55f0a63188a8c6388e638b354b7ed80d186690119cbc4f953.7z", + "public")); + + Artifacts.Add("autoconf-src", + new Tuple( + "autoconf-src/2.69_0e4ba7a0363c68ad08a7d138b228596aecdaea68e1d8b8eefc645e6ac8fc85c7.7z", + "public")); + + Artifacts.Add("libgdiplus", + new Tuple( + "libgdiplus/9df1e3b3b120_4cf7c08770db93922f54f38d2461b9122cddc898db58585864446e70c5ad3057.7z", + "testing")); } } } diff --git a/external/buildscripts/buildDependencies.txt b/external/buildscripts/buildDependencies.txt deleted file mode 100644 index a3548137ac58..000000000000 --- a/external/buildscripts/buildDependencies.txt +++ /dev/null @@ -1,56 +0,0 @@ -# Dependencoes to pull down from Stevedore. Please follow the following format: -# name : -# id : -# repo : - -name : 7z -id: 7z/9df1e3b3b120_12ed325f6a47f0e5cebc247dbe9282a5da280d392cce4e6c9ed227d57ff1e2ff.7z -repo: testing - -name : libgdiplus -id : libgdiplus/9df1e3b3b120_4cf7c08770db93922f54f38d2461b9122cddc898db58585864446e70c5ad3057.7z -repo: testing - -name : MacBuildEnvironment -id : MacBuildEnvironment/9df1e3b3b120_2fc8e616a2e5dfb7907fc42d9576b427e692223c266dc3bc305de4bf03714e30.7z -repo: testing - -name : MonoBleedingEdge -id : MonoBleedingEdge/9df1e3b3b120_ab6d2f131e6bd4fe2aacafb0f683e8fa4e1ccba35552b6fe89bf359b6ee16215.7z -repo: testing - -name : reference-assemblies -id : reference-assemblies/9df1e3b3b120_bbb4750c6bf0a1784bec7d7c04b8ef5881f31f6212136e014694f3864a388886.7z -repo: testing - -name : linux-sdk-20170609 -id : linux-sdk-20170609/9df1e3b3b120_9a3a0847d5b3767579e908b5a9ce050936617b1b9275a79a8b71bb3229998957.7z -repo: testing - -name : libtool-src -id : libtool-src/2.4.6_49a0ed204b3b24572e044400cd05513f611bcca6ced0d0816a57ac3b17376257.7z -repo: public - -name : texinfo-src -id : texinfo-src/4.8_975b9657ebef8a4fe3897047ca450b757a0a956b05399dc813f63e84829bac6a.7z -repo: public - -name : automake-src -id : automake-src/1.16.1_d281b950e26265f55f0a63188a8c6388e638b354b7ed80d186690119cbc4f953.7z -repo: public - -name : autoconf-src -id : autoconf-src/2.69_0e4ba7a0363c68ad08a7d138b228596aecdaea68e1d8b8eefc645e6ac8fc85c7.7z -repo: public - -name : android-ndk-r16b-darwin -id : android-ndk-r16b-darwin/9df1e3b3b120_c7cda5a221dd72799b7e618597b3f8766df7183d386becb2785631c2d3ac0d75.7z -repo: testing - -name : android-ndk-r16b-linux -id : android-ndk-r16b-linux/9df1e3b3b120_fbabd18208d82cbc810266e8b566bb0ea4e1e438de38d450a92deaa3e23757b6.7z -repo: testing - -name : android-ndk-r16b-windows -id : android-ndk-r16b-windows/9df1e3b3b120_403e0d58eabae03f0d9e8d1d2cea2dbf1d14c380c3d1c7eeb6e8c60ffc15e1b8.7z -repo: testing \ No newline at end of file