Skip to content
This repository was archived by the owner on Sep 7, 2022. It is now read-only.

Commit cbf231b

Browse files
authored
Merge pull request #163 from Unity-Technologies/zgh/build_scripts
Zgh/build scripts
2 parents 181ecbc + a4b2bbf commit cbf231b

File tree

9 files changed

+700
-39
lines changed

9 files changed

+700
-39
lines changed

engine/Build.bee.cs

Lines changed: 116 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
using Bee.Toolchain.GNU;
1717
using Bee.Toolchain.IOS;
1818
using System.Diagnostics;
19-
19+
using System.IO;
2020
enum UIWidgetsBuildTargetPlatform
2121
{
2222
windows,
@@ -143,7 +143,7 @@ class Build
143143
//bee.exe win
144144
static void DeployWindows()
145145
{
146-
var libUIWidgets = SetupLibUIWidgets(UIWidgetsBuildTargetPlatform.windows, out var dependencies);
146+
var libUIWidgets = SetupLibUIWidgets(UIWidgetsBuildTargetPlatform.windows, out var dependencies_debug, out var dependencies_release);
147147

148148
var builder = new VisualStudioNativeProjectFileBuilder(libUIWidgets);
149149
builder = libUIWidgets.SetupConfigurations.Aggregate(
@@ -156,62 +156,109 @@ static void DeployWindows()
156156
sln.Projects.Add(deployed);
157157
Backend.Current.AddAliasDependency("ProjectFiles", sln.Setup());
158158

159-
Backend.Current.AddAliasDependency("win", deployed.Path);
160-
foreach (var dep in dependencies)
159+
Backend.Current.AddAliasDependency("win_debug", deployed.Path);
160+
foreach (var dep in dependencies_debug)
161+
{
162+
Backend.Current.AddAliasDependency("win_debug", dep);
163+
}
164+
foreach (var dep in dependencies_release)
161165
{
162-
Backend.Current.AddAliasDependency("win", dep);
166+
Backend.Current.AddAliasDependency("win_release", dep);
163167
}
164168
}
165169

166170
//bee.exe mac
167171
static void DeployAndroid()
168172
{
169-
var libUIWidgets = SetupLibUIWidgets(UIWidgetsBuildTargetPlatform.android, out var dependencies);
173+
var libUIWidgets = SetupLibUIWidgets(UIWidgetsBuildTargetPlatform.android, out var dependencies_debug, out var dependencies_release);
170174
var androidProject = AndroidNativeProgramExtensions.DynamicLinkerSettingsForAndroid(libUIWidgets);
171-
foreach (var dep in dependencies)
175+
foreach (var dep in dependencies_debug)
172176
{
173-
Backend.Current.AddAliasDependency("android", dep);
177+
Backend.Current.AddAliasDependency("android_debug", dep);
178+
}
179+
foreach (var dep in dependencies_release)
180+
{
181+
Backend.Current.AddAliasDependency("android_release", dep);
174182
}
175183
}
176184

177185
static void DeployMac()
178186
{
179-
var libUIWidgets = SetupLibUIWidgets(UIWidgetsBuildTargetPlatform.mac, out var dependencies);
187+
var libUIWidgets = SetupLibUIWidgets(UIWidgetsBuildTargetPlatform.mac, out var dependencies_debug, out var dependencies_release);
180188

181189
var nativePrograms = new List<NativeProgram>();
182190
nativePrograms.Add(libUIWidgets);
183191
var xcodeProject = new XCodeProjectFile(nativePrograms, new NPath("libUIWidgetsMac.xcodeproj/project.pbxproj"));
184192

185-
Backend.Current.AddAliasDependency("mac", new NPath("libUIWidgetsMac.xcodeproj/project.pbxproj"));
186-
foreach (var dep in dependencies)
193+
Backend.Current.AddAliasDependency("mac_debug", new NPath("libUIWidgetsMac.xcodeproj/project.pbxproj"));
194+
foreach (var dep in dependencies_debug)
195+
{
196+
Backend.Current.AddAliasDependency("mac_debug", dep);
197+
}
198+
foreach (var dep in dependencies_release)
187199
{
188-
Backend.Current.AddAliasDependency("mac", dep);
200+
Backend.Current.AddAliasDependency("mac_release", dep);
189201
}
190202
}
191203

192204
//bee.exe ios
193205
static void DeployIOS()
194206
{
195-
var libUIWidgets = SetupLibUIWidgets(UIWidgetsBuildTargetPlatform.ios, out var dependencies);
207+
var libUIWidgets = SetupLibUIWidgets(UIWidgetsBuildTargetPlatform.ios, out var dependencies_debug, out var dependencies_release);
196208
var nativePrograms = new List<NativeProgram>();
197209
nativePrograms.Add(libUIWidgets);
198210
var xcodeProject = new XCodeProjectFile(nativePrograms, new NPath("libUIWidgetsIOS.xcodeproj/project.pbxproj"));
199211

200-
Backend.Current.AddAliasDependency("ios", new NPath("libUIWidgetsIOS.xcodeproj/project.pbxproj"));
201-
foreach(var dep in dependencies) {
202-
Backend.Current.AddAliasDependency("ios", dep);
212+
Backend.Current.AddAliasDependency("ios_debug", new NPath("libUIWidgetsIOS.xcodeproj/project.pbxproj"));
213+
foreach(var dep in dependencies_debug) {
214+
Backend.Current.AddAliasDependency("ios_debug", dep);
215+
}
216+
foreach(var dep in dependencies_release) {
217+
Backend.Current.AddAliasDependency("ios_release", dep);
203218
}
204219
}
205220

206221
static void Main()
207222
{
208-
flutterRoot = Environment.GetEnvironmentVariable("FLUTTER_ROOT");
223+
flutterRoot = Environment.GetEnvironmentVariable("FLUTTER_ROOT_PATH");
209224
if (string.IsNullOrEmpty(flutterRoot))
210225
{
211226
flutterRoot = Environment.GetEnvironmentVariable("USERPROFILE") + "/engine/src";
212227
}
213228
skiaRoot = flutterRoot + "/third_party/skia";
214229

230+
try
231+
{
232+
if(File.Exists("Scripts/bitcode.conf"))
233+
{
234+
using (StreamReader sr = new StreamReader("Scripts/bitcode.conf"))
235+
{
236+
string line;
237+
if ((line = sr.ReadLine()) != null)
238+
{
239+
if(line.Trim() == "true")
240+
{
241+
ios_bitcode_enabled = true;
242+
}
243+
else
244+
{
245+
ios_bitcode_enabled = false;
246+
}
247+
}
248+
}
249+
}
250+
else
251+
{
252+
ios_bitcode_enabled = false;
253+
}
254+
}
255+
catch (Exception e)
256+
{
257+
Console.WriteLine(e.Message);
258+
}
259+
260+
261+
215262
//available target platforms of Windows
216263
if (BuildUtils.IsHostWindows())
217264
{
@@ -234,7 +281,7 @@ static void Main()
234281
//refer to the readme file for the details
235282
private static bool ios_bitcode_enabled = false;
236283

237-
static NativeProgram SetupLibUIWidgets(UIWidgetsBuildTargetPlatform platform, out List<NPath> dependencies)
284+
static NativeProgram SetupLibUIWidgets(UIWidgetsBuildTargetPlatform platform, out List<NPath> dependencies_debug, out List<NPath> dependencies_release)
238285
{
239286
var np = new NativeProgram("libUIWidgets")
240287
{
@@ -751,9 +798,9 @@ static NativeProgram SetupLibUIWidgets(UIWidgetsBuildTargetPlatform platform, ou
751798
//SetupFml(np);
752799
//SetupSkia(np);
753800
//SetupTxt(np);
754-
var codegens = new[] { CodeGen.Debug };
755-
dependencies = new List<NPath>();
756-
801+
var codegens = new[] { CodeGen.Debug, CodeGen.Release };
802+
dependencies_debug = new List<NPath>();
803+
dependencies_release = new List<NPath>();
757804
if (platform == UIWidgetsBuildTargetPlatform.windows)
758805
{
759806
var toolchain = ToolChain.Store.Windows().VS2019().Sdk_17134().x64();
@@ -762,11 +809,20 @@ static NativeProgram SetupLibUIWidgets(UIWidgetsBuildTargetPlatform platform, ou
762809
{
763810
var config = new NativeProgramConfiguration(codegen, toolchain, lump: true);
764811

765-
var builtNP = np.SetupSpecificConfiguration(config, toolchain.DynamicLibraryFormat)
766-
.DeployTo("build");
767-
768-
dependencies.Add(builtNP.Path);
769-
builtNP.DeployTo("../com.unity.uiwidgets/Runtime/Plugins/x86_64");
812+
813+
if(codegen == CodeGen.Debug)
814+
{
815+
var builtNP = np.SetupSpecificConfiguration(config, toolchain.DynamicLibraryFormat)
816+
.DeployTo("build_debug");
817+
dependencies_debug.Add(builtNP.Path);
818+
}
819+
else if(codegen == CodeGen.Release)
820+
{
821+
var builtNP = np.SetupSpecificConfiguration(config, toolchain.DynamicLibraryFormat)
822+
.DeployTo("build_release");
823+
dependencies_release.Add(builtNP.Path);
824+
}
825+
770826
}
771827
}
772828
else if (platform == UIWidgetsBuildTargetPlatform.android)
@@ -780,11 +836,18 @@ static NativeProgram SetupLibUIWidgets(UIWidgetsBuildTargetPlatform platform, ou
780836
var config = new NativeProgramConfiguration(codegen, androidToolchain, lump: true);
781837
validConfigurations.Add(config);
782838

783-
var buildNP = np.SetupSpecificConfiguration(config, androidToolchain.DynamicLibraryFormat).DeployTo("build");
784-
785-
var deoployNp = buildNP.DeployTo("../com.unity.uiwidgets/Runtime/Plugins/Android");
786-
dependencies.Add(buildNP.Path);
787-
dependencies.Add(deoployNp.Path);
839+
840+
if(codegen == CodeGen.Debug)
841+
{
842+
var buildNP = np.SetupSpecificConfiguration(config, androidToolchain.DynamicLibraryFormat).DeployTo("build_debug");
843+
dependencies_debug.Add(buildNP.Path);
844+
}
845+
else if(codegen == CodeGen.Release)
846+
{
847+
var buildNP = np.SetupSpecificConfiguration(config, androidToolchain.DynamicLibraryFormat).DeployTo("build_release");
848+
dependencies_release.Add(buildNP.Path);
849+
}
850+
788851
}
789852
np.ValidConfigurations = validConfigurations;
790853
}
@@ -798,10 +861,17 @@ static NativeProgram SetupLibUIWidgets(UIWidgetsBuildTargetPlatform platform, ou
798861
validConfigurations.Add(config);
799862

800863
var buildProgram = np.SetupSpecificConfiguration(config, toolchain.DynamicLibraryFormat);
801-
var buildNp = buildProgram.DeployTo("build");
802-
var deployNp = buildProgram.DeployTo("../com.unity.uiwidgets/Runtime/Plugins/osx");
803-
dependencies.Add(buildNp.Path);
804-
dependencies.Add(deployNp.Path);
864+
865+
if(codegen == CodeGen.Debug)
866+
{
867+
var buildNp = buildProgram.DeployTo("build_debug");
868+
dependencies_debug.Add(buildNp.Path);
869+
}
870+
else if(codegen == CodeGen.Release)
871+
{
872+
var buildNp = buildProgram.DeployTo("build_release");
873+
dependencies_release.Add(buildNp.Path);
874+
}
805875
}
806876
np.ValidConfigurations = validConfigurations;
807877

@@ -815,10 +885,17 @@ static NativeProgram SetupLibUIWidgets(UIWidgetsBuildTargetPlatform platform, ou
815885
var config = new NativeProgramConfiguration(codegen, toolchain, lump: true);
816886
validConfigurations.Add(config);
817887
var buildProgram = np.SetupSpecificConfiguration(config, toolchain.StaticLibraryFormat);
818-
var builtNP = buildProgram.DeployTo("build");
819-
var deployNP = buildProgram.DeployTo("../com.unity.uiwidgets/Runtime/Plugins/iOS/");
820-
dependencies.Add(builtNP.Path);
821-
dependencies.Add(deployNP.Path);
888+
889+
if(codegen == CodeGen.Debug)
890+
{
891+
var builtNP = buildProgram.DeployTo("build_debug");
892+
dependencies_debug.Add(builtNP.Path);
893+
}
894+
else if(codegen == CodeGen.Release)
895+
{
896+
var builtNP = buildProgram.DeployTo("build_release");
897+
dependencies_release.Add(builtNP.Path);
898+
}
822899
}
823900

824901
np.ValidConfigurations = validConfigurations;

0 commit comments

Comments
 (0)