public override bool Execute() { Utils.Logger = Log; bool isDevice = Arch.Equals("arm64", StringComparison.InvariantCultureIgnoreCase); if (isDevice && string.IsNullOrEmpty(CrossCompiler)) { throw new ArgumentException("arm64 arch requires CrossCompiler"); } if (!File.Exists(Path.Combine(AppDir, MainLibraryFileName))) { throw new ArgumentException($"MainLibraryFileName='{MainLibraryFileName}' was not found in AppDir='{AppDir}'"); } if (ProjectName.Contains(" ")) { throw new ArgumentException($"ProjectName='{ProjectName}' should not contain spaces"); } if (UseLlvm && string.IsNullOrEmpty(LlvmPath)) { // otherwise we might accidentally use some random llc/opt from PATH (installed with clang) throw new ArgumentException($"LlvmPath shoun't be empty when UseLlvm is set"); } string[] excludes = new string[0]; if (ExcludeFromAppDir != null) { excludes = ExcludeFromAppDir .Where(i => !string.IsNullOrEmpty(i.ItemSpec)) .Select(i => i.ItemSpec) .ToArray(); } string[] libsToAot = Directory.GetFiles(AppDir, "*.dll") .Where(f => !excludes.Contains(Path.GetFileName(f))) .ToArray(); string binDir = Path.Combine(AppDir, $"bin-{ProjectName}-{Arch}"); if (!string.IsNullOrEmpty(OutputDirectory)) { binDir = OutputDirectory; } Directory.CreateDirectory(binDir); // run AOT compilation only for devices if (isDevice) { if (string.IsNullOrEmpty(CrossCompiler)) { throw new InvalidOperationException("cross-compiler is not set"); } AotCompiler.PrecompileLibraries(CrossCompiler, Arch, !DisableParallelAot, binDir, libsToAot, new Dictionary <string, string> { { "MONO_PATH", AppDir } }, Optimized, UseLlvm, LlvmPath); } // generate modules.m AotCompiler.GenerateLinkAllFile( Directory.GetFiles(binDir, "*.dll.o"), Path.Combine(binDir, "modules.m")); if (GenerateXcodeProject) { XcodeProjectPath = Xcode.GenerateXCode(ProjectName, MainLibraryFileName, AppDir, binDir, MonoRuntimeHeaders, !isDevice, UseConsoleUITemplate, NativeMainSource); if (BuildAppBundle) { if (isDevice && string.IsNullOrEmpty(DevTeamProvisioning)) { // DevTeamProvisioning shouldn't be empty for arm64 builds Utils.LogInfo("DevTeamProvisioning is not set, BuildAppBundle step is skipped."); } else { AppBundlePath = Xcode.BuildAppBundle( Path.Combine(binDir, ProjectName, ProjectName + ".xcodeproj"), Arch, Optimized, DevTeamProvisioning); } } } return(true); }
public override bool Execute() { Utils.Logger = Log; bool isDevice = Arch.Equals("arm64", StringComparison.InvariantCultureIgnoreCase) && TargetOS != TargetNames.MacCatalyst; if (!File.Exists(Path.Combine(AppDir, MainLibraryFileName))) { throw new ArgumentException($"MainLibraryFileName='{MainLibraryFileName}' was not found in AppDir='{AppDir}'"); } if (ProjectName.Contains(" ")) { throw new ArgumentException($"ProjectName='{ProjectName}' should not contain spaces"); } string[] excludes = Array.Empty <string>(); if (ExcludeFromAppDir != null) { excludes = ExcludeFromAppDir .Where(i => !string.IsNullOrEmpty(i.ItemSpec)) .Select(i => i.ItemSpec) .ToArray(); } string binDir = Path.Combine(AppDir, $"bin-{ProjectName}-{Arch}"); if (!string.IsNullOrEmpty(OutputDirectory)) { binDir = OutputDirectory; } Directory.CreateDirectory(binDir); var assemblerFiles = new List <string>(); foreach (ITaskItem file in Assemblies) { // use AOT files if available var obj = file.GetMetadata("AssemblerFile"); if (!string.IsNullOrEmpty(obj)) { assemblerFiles.Add(obj); } } if (((!ForceInterpreter && (isDevice || ForceAOT)) && !assemblerFiles.Any())) { throw new InvalidOperationException("Need list of AOT files for device builds."); } if (ForceInterpreter && ForceAOT) { throw new InvalidOperationException("Interpreter and AOT cannot be enabled at the same time"); } if (GenerateXcodeProject) { Xcode generator = new Xcode(TargetOS); generator.EnableRuntimeLogging = EnableRuntimeLogging; XcodeProjectPath = generator.GenerateXCode(ProjectName, MainLibraryFileName, assemblerFiles, AppDir, binDir, MonoRuntimeHeaders, !isDevice, UseConsoleUITemplate, ForceAOT, ForceInterpreter, InvariantGlobalization, Optimized, NativeMainSource); if (BuildAppBundle) { if (isDevice && string.IsNullOrEmpty(DevTeamProvisioning)) { // DevTeamProvisioning shouldn't be empty for arm64 builds Utils.LogInfo("DevTeamProvisioning is not set, BuildAppBundle step is skipped."); } else { AppBundlePath = generator.BuildAppBundle(XcodeProjectPath, Arch, Optimized, DevTeamProvisioning); } } } return(true); }
public override bool Execute() { Utils.Logger = Log; bool isDevice = Arch.Equals("arm64", StringComparison.InvariantCultureIgnoreCase); if (!File.Exists(Path.Combine(AppDir, MainLibraryFileName))) { throw new ArgumentException($"MainLibraryFileName='{MainLibraryFileName}' was not found in AppDir='{AppDir}'"); } if (ProjectName.Contains(" ")) { throw new ArgumentException($"ProjectName='{ProjectName}' should not contain spaces"); } string[] excludes = new string[0]; if (ExcludeFromAppDir != null) { excludes = ExcludeFromAppDir .Where(i => !string.IsNullOrEmpty(i.ItemSpec)) .Select(i => i.ItemSpec) .ToArray(); } string binDir = Path.Combine(AppDir, $"bin-{ProjectName}-{Arch}"); if (!string.IsNullOrEmpty(OutputDirectory)) { binDir = OutputDirectory; } Directory.CreateDirectory(binDir); var assemblerFiles = new List <string>(); foreach (ITaskItem file in Assemblies) { // use AOT files if available var obj = file.GetMetadata("AssemblerFile"); if (!String.IsNullOrEmpty(obj)) { assemblerFiles.Add(obj); } } if (isDevice && !assemblerFiles.Any()) { throw new InvalidOperationException("Need list of AOT files for device builds."); } // generate modules.m GenerateLinkAllFile( assemblerFiles, Path.Combine(binDir, "modules.m")); if (GenerateXcodeProject) { XcodeProjectPath = Xcode.GenerateXCode(ProjectName, MainLibraryFileName, assemblerFiles, AppDir, binDir, MonoRuntimeHeaders, !isDevice, UseConsoleUITemplate, NativeMainSource); if (BuildAppBundle) { if (isDevice && string.IsNullOrEmpty(DevTeamProvisioning)) { // DevTeamProvisioning shouldn't be empty for arm64 builds Utils.LogInfo("DevTeamProvisioning is not set, BuildAppBundle step is skipped."); } else { AppBundlePath = Xcode.BuildAppBundle( Path.Combine(binDir, ProjectName, ProjectName + ".xcodeproj"), Arch, Optimized, DevTeamProvisioning); } } } return(true); }