|
1 | 1 | using System;
|
2 |
| -using System.IO; |
| 2 | +using System.Collections.Generic; |
3 | 3 | using Bee.Core;
|
4 | 4 | using Bee.Stevedore;
|
5 |
| -using NiceIO; |
6 |
| -using Unity.BuildTools; |
7 |
| -using System.Collections.Generic; |
8 |
| -using System.Text; |
9 | 5 | using Bee.Stevedore.Program;
|
| 6 | +using Unity.BuildSystem.NativeProgramSupport; |
10 | 7 |
|
11 | 8 | namespace BuildProgram
|
12 | 9 | {
|
13 | 10 | public class BuildProgram
|
14 | 11 | {
|
| 12 | + private static readonly Dictionary<string, Tuple<string, string>> Artifacts = new Dictionary<string, Tuple<string, string>>(); |
| 13 | + |
15 | 14 | internal static void Main()
|
16 | 15 | {
|
17 |
| - if (IsRunningOnBuildMachine()) |
18 |
| - Console.WriteLine("\n>>> Running on build machine"); |
19 |
| - |
20 |
| - var monoRoot = GetMonoRootDir(); |
21 |
| - Console.WriteLine(">>> Mono root directory: " + monoRoot); |
22 |
| - |
23 |
| - var buildScriptsRoot = monoRoot.Combine("external").Combine("buildscripts"); |
24 |
| - Console.WriteLine(">>> Build scripts directory: " + buildScriptsRoot); |
25 |
| - |
26 |
| - var buildDependenciesConfigFile = buildScriptsRoot.Combine("buildDependencies.txt"); |
27 |
| - Console.WriteLine(">>> Mono build dependecies stevedore version config file: " + buildDependenciesConfigFile); |
| 16 | + RegisterCommonArtifacts(); |
28 | 17 |
|
29 |
| - var stevedoreArtifactsDir = buildScriptsRoot.Combine("artifacts").Combine("Stevedore"); |
30 |
| - Console.WriteLine(">>> Stevedore artifacts directory: " + stevedoreArtifactsDir + "\n"); |
31 |
| - |
32 |
| - if (buildDependenciesConfigFile.Exists()) |
| 18 | + if (Platform.HostPlatform is WindowsPlatform) |
| 19 | + { |
| 20 | + RegisterWindowsArtifacts(); |
| 21 | + } |
| 22 | + else |
33 | 23 | {
|
34 |
| - var artifactList = ParseBuildDependenciesConfigFile(buildDependenciesConfigFile.ToString()); |
| 24 | + RegisterCommonNonWindowsArtifacts(); |
35 | 25 |
|
36 |
| - foreach (var item in artifactList) |
| 26 | + if (Platform.HostPlatform is MacOSXPlatform) |
| 27 | + { |
| 28 | + RegisterOSXArtifacts(); |
| 29 | + } |
| 30 | + else if (Platform.HostPlatform is LinuxPlatform) |
37 | 31 | {
|
38 |
| - var artifactName = item.Item1; |
39 |
| - var artifactId = item.Item2; |
40 |
| - var repoName = new RepoName(item.Item3); |
41 |
| - DownloadArtifact(artifactId, artifactName, repoName); |
| 32 | + RegisterLinuxArtifacts(); |
42 | 33 | }
|
43 | 34 | }
|
44 |
| - else |
| 35 | + |
| 36 | + foreach (var artifact in Artifacts) |
45 | 37 | {
|
46 |
| - throw new Exception($"{buildDependenciesConfigFile} does not exist"); |
| 38 | + var name = artifact.Key; |
| 39 | + var id = artifact.Value.Item1; |
| 40 | + var repo = new RepoName(artifact.Value.Item2); |
| 41 | + |
| 42 | + Console.WriteLine($">>> Registering artifact {name}"); |
| 43 | + var stevedoreArtifact = new StevedoreArtifact(repo, new ArtifactId(id)); |
| 44 | + Backend.Current.Register(stevedoreArtifact); |
47 | 45 | }
|
48 | 46 | }
|
49 | 47 |
|
50 |
| - private static void DownloadArtifact(string artifactId, string artifactName, RepoName repoName) |
| 48 | + private static void RegisterCommonArtifacts() |
51 | 49 | {
|
52 |
| - Console.WriteLine($">>> Registering artifact {artifactName}"); |
53 |
| - var artifact = new StevedoreArtifact(repoName, new ArtifactId(artifactId)); |
54 |
| - Backend.Current.Register(artifact); |
| 50 | + Artifacts.Add("7z", |
| 51 | + new Tuple<string, string>( |
| 52 | + "7z/9df1e3b3b120_12ed325f6a47f0e5cebc247dbe9282a5da280d392cce4e6c9ed227d57ff1e2ff.7z", |
| 53 | + "testing")); |
| 54 | + |
| 55 | + Artifacts.Add("MonoBleedingEdge", |
| 56 | + new Tuple<string, string>( |
| 57 | + "MonoBleedingEdge/9df1e3b3b120_ab6d2f131e6bd4fe2aacafb0f683e8fa4e1ccba35552b6fe89bf359b6ee16215.7z", |
| 58 | + "testing")); |
| 59 | + |
| 60 | + Artifacts.Add("reference-assemblies", |
| 61 | + new Tuple<string, string>( |
| 62 | + "reference-assemblies/9df1e3b3b120_bbb4750c6bf0a1784bec7d7c04b8ef5881f31f6212136e014694f3864a388886.7z", |
| 63 | + "testing")); |
55 | 64 | }
|
56 | 65 |
|
57 |
| - private static NPath GetMonoRootDir() |
| 66 | + private static void RegisterWindowsArtifacts() |
58 | 67 | {
|
59 |
| - var exePath = new NPath(System.Reflection.Assembly.GetEntryAssembly().Location); |
60 |
| - var monoRoot = exePath; |
61 |
| - |
62 |
| - //Assume "external" directory exists under monoRoot. |
63 |
| - while (monoRoot.ToString().Contains("external")) |
64 |
| - monoRoot = monoRoot.Parent; |
65 |
| - |
66 |
| - return monoRoot; |
| 68 | + Artifacts.Add("android-ndk-r16b-windows", |
| 69 | + new Tuple<string, string>( |
| 70 | + "android-ndk-r16b-windows/9df1e3b3b120_403e0d58eabae03f0d9e8d1d2cea2dbf1d14c380c3d1c7eeb6e8c60ffc15e1b8.7z", |
| 71 | + "testing")); |
67 | 72 | }
|
68 | 73 |
|
69 |
| - private static bool IsRunningOnBuildMachine() |
| 74 | + private static void RegisterOSXArtifacts() |
70 | 75 | {
|
71 |
| - var buildMachine = Environment.GetEnvironmentVariable("UNITY_THISISABUILDMACHINE"); |
72 |
| - return buildMachine != null && buildMachine == "1"; |
| 76 | + Artifacts.Add("android-ndk-r16b-darwin", |
| 77 | + new Tuple<string, string>( |
| 78 | + "android-ndk-r16b-darwin/9df1e3b3b120_c7cda5a221dd72799b7e618597b3f8766df7183d386becb2785631c2d3ac0d75.7z", |
| 79 | + "testing")); |
| 80 | + |
| 81 | + Artifacts.Add("MacBuildEnvironment", |
| 82 | + new Tuple<string, string>( |
| 83 | + "MacBuildEnvironment/9df1e3b3b120_2fc8e616a2e5dfb7907fc42d9576b427e692223c266dc3bc305de4bf03714e30.7z", |
| 84 | + "testing")); |
73 | 85 | }
|
74 | 86 |
|
75 |
| - //Sample config file format: |
76 |
| - /* |
77 |
| - # Dependencoes to pull down from Stevedore. Please follow the following format: |
78 |
| - # name : <stevedore artifact name> |
79 |
| - # id : <stevedore artifact id> |
80 |
| - # repo : <stevedore repo name (can be testing/public/unityinternal)> |
81 |
| -
|
82 |
| - name: 7z |
83 |
| - id: 7z/9df1e3b3b120_12ed325f6a47f0e5cebc247dbe9282a5da280d392cce4e6c9ed227d57ff1e2ff.7z |
84 |
| - repo: testing |
85 |
| -
|
86 |
| - name: libgdiplus |
87 |
| - id : libgdiplus/9df1e3b3b120_4cf7c08770db93922f54f38d2461b9122cddc898db58585864446e70c5ad3057.7z |
88 |
| - repo: public |
89 |
| - */ |
90 |
| - private static List<Tuple<string, string, string>> ParseBuildDependenciesConfigFile(string buildDependenciesConfigFile) |
| 87 | + private static void RegisterLinuxArtifacts() |
91 | 88 | {
|
92 |
| - var artifactNameIdFilesDictionary = new List<Tuple<string, string, string>>(); |
| 89 | + Artifacts.Add("android-ndk-r16b-linux", |
| 90 | + new Tuple<string, string>( |
| 91 | + "android-ndk-r16b-linux/9df1e3b3b120_fbabd18208d82cbc810266e8b566bb0ea4e1e438de38d450a92deaa3e23757b6.7z", |
| 92 | + "testing")); |
| 93 | + |
| 94 | + Artifacts.Add("linux-sdk-20170609", |
| 95 | + new Tuple<string, string>( |
| 96 | + "linux-sdk-20170609/9df1e3b3b120_9a3a0847d5b3767579e908b5a9ce050936617b1b9275a79a8b71bb3229998957.7z", |
| 97 | + "testing")); |
| 98 | + } |
93 | 99 |
|
94 |
| - var fileStream = new FileStream(buildDependenciesConfigFile, FileMode.Open, FileAccess.Read); |
95 |
| - using (var streamReader = new StreamReader(fileStream, Encoding.UTF8)) |
96 |
| - { |
97 |
| - string line; |
98 |
| - while ((line = streamReader.ReadLine()) != null) |
99 |
| - { |
100 |
| - //Check if line contains a comment |
101 |
| - if (!string.IsNullOrEmpty(line) && !line.Contains("#")) |
102 |
| - { |
103 |
| - if (line.Contains("name :") || line.Contains("name:")) |
104 |
| - { |
105 |
| - var name = ""; |
106 |
| - var id = ""; |
107 |
| - var repoName = ""; |
108 |
| - |
109 |
| - //read name |
110 |
| - name = line.Split(':')[1].Trim(); |
111 |
| - |
112 |
| - //read id |
113 |
| - if ((line = streamReader.ReadLine()) != null) |
114 |
| - id = line.Split(':')[1].Trim(); |
115 |
| - else |
116 |
| - throw new Exception($">>> Invalid {buildDependenciesConfigFile}, id name does not exist"); |
117 |
| - |
118 |
| - //read repo name |
119 |
| - if ((line = streamReader.ReadLine()) != null) |
120 |
| - repoName = line.Split(':')[1].Trim(); |
121 |
| - else |
122 |
| - throw new Exception($">>> Invalid {buildDependenciesConfigFile}, repo name does not exist"); |
123 |
| - |
124 |
| - artifactNameIdFilesDictionary.Add(new Tuple<string, string, string>(name, id, repoName)); |
125 |
| - } |
126 |
| - } |
127 |
| - } |
128 |
| - } |
129 |
| - return artifactNameIdFilesDictionary; |
| 100 | + private static void RegisterCommonNonWindowsArtifacts() |
| 101 | + { |
| 102 | + Artifacts.Add("libtool-src", |
| 103 | + new Tuple<string, string>( |
| 104 | + "libtool-src/2.4.6_49a0ed204b3b24572e044400cd05513f611bcca6ced0d0816a57ac3b17376257.7z", |
| 105 | + "public")); |
| 106 | + |
| 107 | + Artifacts.Add("texinfo-src", |
| 108 | + new Tuple<string, string>( |
| 109 | + "texinfo-src/4.8_975b9657ebef8a4fe3897047ca450b757a0a956b05399dc813f63e84829bac6a.7z", |
| 110 | + "public")); |
| 111 | + |
| 112 | + Artifacts.Add("automake-src", |
| 113 | + new Tuple<string, string>( |
| 114 | + "automake-src/1.16.1_d281b950e26265f55f0a63188a8c6388e638b354b7ed80d186690119cbc4f953.7z", |
| 115 | + "public")); |
| 116 | + |
| 117 | + Artifacts.Add("autoconf-src", |
| 118 | + new Tuple<string, string>( |
| 119 | + "autoconf-src/2.69_0e4ba7a0363c68ad08a7d138b228596aecdaea68e1d8b8eefc645e6ac8fc85c7.7z", |
| 120 | + "public")); |
| 121 | + |
| 122 | + Artifacts.Add("libgdiplus", |
| 123 | + new Tuple<string, string>( |
| 124 | + "libgdiplus/9df1e3b3b120_4cf7c08770db93922f54f38d2461b9122cddc898db58585864446e70c5ad3057.7z", |
| 125 | + "testing")); |
130 | 126 | }
|
131 | 127 | }
|
132 | 128 | }
|
0 commit comments