public override bool IsSupportedFor(CSharpProgramConfiguration config) { //UNITY_DOTS_ENTRYPOINT is actually a fake define constraint we use to signal the buildsystem, // so don't impose it as a constraint return(DefineConstraintsHelper.IsDefineConstraintsCompatible(Defines.For(config).Append("UNITY_DOTS_ENTRYPOINT").ToArray(), AsmDefDescription.DefineConstraints) && base.IsSupportedFor(config)); }
public override BeeBuildCommand BeeBuildCommandFor(CSharpProgramConfiguration config) { if (config is DotsRuntimeCSharpProgramConfiguration drcspc) { return(new BeeBuildCommand(drcspc.Identifier)); } return(base.BeeBuildCommandFor(config)); }
public override DotNetAssembly SetupSpecificConfiguration(CSharpProgramConfiguration config) { EnsureNativeProgramLinksToReferences(); var result = base.SetupSpecificConfiguration(config); return(SetupNativeProgram(config, result)); }
public override bool IsSupportedFor(CSharpProgramConfiguration config) { //UNITY_DOTS_ENTRYPOINT is actually a fake define constraint we use to signal the buildsystem, //so don't impose it as a constraint return(base.IsSupportedFor(config) && AsmDefDescription.DefineConstraints.All(dc => dc == "UNITY_DOTS_ENTRYPOINT" || Defines.For(config).Contains(dc))); }
protected virtual TargetFramework GetTargetFramework(CSharpProgramConfiguration config, DotsRuntimeCSharpProgram program) { if (config is DotsRuntimeCSharpProgramConfiguration dotsConfig) { return(dotsConfig.TargetFramework); } return(TargetFramework.Tiny); }
private static TargetFramework GetTargetFramework(CSharpProgramConfiguration config) { if (config is DotsRuntimeCSharpProgramConfiguration dotsConfig) { return(dotsConfig.TargetFramework); } return(TargetFramework.Tiny); }
public static DotNetAssembly SetupInvocation( DotNetAssembly inputAssembly, CSharpProgramConfiguration config, string[] defines) { return(inputAssembly.ApplyDotNetAssembliesPostProcessor($"artifacts/{inputAssembly.Path.FileNameWithoutExtension}/{config.Identifier}/post_ilprocessing/", (inputAssemblies, targetDirectory) => AddActions(config, inputAssemblies, targetDirectory, defines) )); }
protected override bool ShouldTargetTinyCorlib(CSharpProgramConfiguration config, DotsRuntimeCSharpProgram program) { if (DoesTargetFullDotNet || IsTestAssembly || IsILPostProcessorAssembly) { return(false); } return(base.ShouldTargetTinyCorlib(config, program)); }
protected override TargetFramework GetTargetFramework(CSharpProgramConfiguration config, DotsRuntimeCSharpProgram program) { if (IsILPostProcessorAssembly) { return(TargetFramework.NetStandard20); } return(base.GetTargetFramework(config, program)); }
static BindGemResult MakeBindGemResultFor(NPath fileName, CSharpProgramConfiguration config) { NPath prefix = $"artifacts/bindgen/{fileName.FileNameWithoutExtension}-{config.Identifier}/bind-{fileName.FileNameWithoutExtension.Replace(".", "_")}"; return(new BindGemResult() { Header = prefix.ChangeExtension("h"), Cpp = prefix.ChangeExtension("cpp"), }); }
protected virtual DotNetAssembly SetupNativeProgram(CSharpProgramConfiguration config, DotNetAssembly result) { var dotsConfig = (DotsRuntimeCSharpProgramConfiguration)config; var npc = dotsConfig.NativeProgramConfiguration; if (NativeProgram != null && NativeProgram.Sources.ForAny().Any()) { BuiltNativeProgram setupSpecificConfiguration = NativeProgram.SetupSpecificConfiguration(npc, npc.ToolChain.DynamicLibraryFormat ?? npc.ToolChain.StaticLibraryFormat); result = result.WithDeployables(setupSpecificConfiguration); } return(result); }
private static void AddActions(CSharpProgramConfiguration config, DotNetAssembly[] inputAssemblies, NPath targetDirectory, string[] defines) { var processors = BuildProgram.ILPostProcessorAssemblies.Select(asm => asm.Path.MakeAbsolute()); var outputDirArg = "--outputDir " + targetDirectory.MakeAbsolute().QuoteForProcessStart(); var processorPathsArg = processors.Count() > 0 ? "--processors " + processors.Select(p => p.QuoteForProcessStart()).Aggregate((s1, s2) => s1 + "," + s2) : ""; foreach (var inputAsm in inputAssemblies.OrderByDependencies()) { var assemblyArg = inputAsm.Path.MakeAbsolute().QuoteForProcessStart(); var referenceAsmPaths = inputAsm.RuntimeDependencies.Where(a => !a.Path.IsChildOf("post_ilprocessing")) .Select(a => a.Path.MakeAbsolute().QuoteForProcessStart()) .Concat( new[] { Il2Cpp.Distribution.Path.Combine("build/profiles/Tiny/Facades/netstandard.dll").QuoteForProcessStart(), Il2Cpp.TinyCorlib.Path.MakeAbsolute().QuoteForProcessStart() }); var referencesArg = "--assemblyReferences " + referenceAsmPaths.Distinct().Aggregate((s1, s2) => s1 + "," + s2); var dotsConfig = (DotsRuntimeCSharpProgramConfiguration)config; var allscriptDefines = dotsConfig.Defines.Concat(defines); var definesArg = !allscriptDefines.Empty() ? "--scriptingDefines " + allscriptDefines.Distinct().Aggregate((d1, d2) => d1 + "," + d2) : ""; var targetFiles = TargetPathsFor(targetDirectory, inputAsm).ToArray(); var inputFiles = InputPathsFor(inputAsm).Concat(processors).Concat(new[] { _ILPostProcessorRunnableProgram.Value.Path }).ToArray(); var args = new List <string> { assemblyArg, outputDirArg, processorPathsArg, referencesArg, definesArg }.ToArray(); Backend.Current.AddAction($"ILPostProcessorRunner", targetFiles, inputFiles, _ILPostProcessorRunnableProgram.Value.InvocationString, args, allowedOutputSubstrings: new [] { "ILPostProcessorRunner", "[WARN]", "[ERROR]" } ); } }
public override DotNetAssembly SetupSpecificConfiguration(CSharpProgramConfiguration config) { var nonPatchedUnsafeUtility = base.SetupSpecificConfiguration(config); var builtPatcher = new CSharpProgram() { Path = "artifacts/UnsafeUtilityPatcher/UnsafeUtilityPatcher.exe", Sources = { $"{BuildProgram.LowLevelRoot}/UnsafeUtilityPatcher" }, Defines = { "NDESK_OPTIONS" }, Framework = { Bee.DotNet.Framework.Framework471 }, References = { MonoCecil.Paths, }, LanguageVersion = "7.3" }.SetupDefault(); var outDir = nonPatchedUnsafeUtility.Path.Parent.Combine("patched"); NPath nPath = outDir.Combine(nonPatchedUnsafeUtility.Path.FileName); var builtPatcherProgram = new DotNetRunnableProgram(builtPatcher); var args = new[] { $"--output={nPath}", $"--assembly={nonPatchedUnsafeUtility.Path}", }; var result = new DotNetAssembly(nPath, nonPatchedUnsafeUtility.Framework, nonPatchedUnsafeUtility.DebugFormat, nPath.ChangeExtension("pdb"), nonPatchedUnsafeUtility.RuntimeDependencies, nonPatchedUnsafeUtility.ReferenceAssemblyPath); Backend.Current.AddAction("Patch", result.Paths, nonPatchedUnsafeUtility.Paths.Concat(builtPatcher.Paths).ToArray(), builtPatcherProgram.InvocationString, args); return(result); }
public virtual bool IsSupportedFor(CSharpProgramConfiguration config) { if (config is DotsRuntimeCSharpProgramConfiguration dotsConfig) { if (IncludePlatforms?.Any(p => p.GetType().IsInstanceOfType(dotsConfig.Platform)) ?? false) { return(true); } if (IncludePlatforms?.Any() ?? false) { return(false); } if (!ExcludePlatforms?.Any() ?? true) { return(true); } return(!ExcludePlatforms?.Any(p => p.GetType().IsInstanceOfType(dotsConfig.Platform)) ?? true); } return(false); }
protected virtual bool ShouldTargetTinyCorlib(CSharpProgramConfiguration config, DotsRuntimeCSharpProgram program) { return(true); }
protected override DotNetAssembly SetupNativeProgram(CSharpProgramConfiguration config, DotNetAssembly result) { BindGem.Instance().SetupInvocation(result, (DotsRuntimeCSharpProgramConfiguration)config); return(base.SetupNativeProgram(config, result)); }
private static bool ShouldTargetTinyCorlib(CSharpProgramConfiguration config, DotsRuntimeCSharpProgram program) { return((program is AsmDefBasedDotsRuntimeCSharpProgram asmdefProgram) ? !asmdefProgram.IsTestAssembly : true); }
static BindGemResult BindGemOutputFor(CSharpProgram inputProgram, CSharpProgramConfiguration config) => SupportsBindgem(inputProgram.FileName) ? MakeBindGemResultFor(inputProgram.FileName, config) : null;
static void Main(string[] path) { var bee = new NPath(typeof(CSharpProgram).Assembly.Location); StevedoreGlobalSettings.Instance = new StevedoreGlobalSettings { // Manifest entries always override artifact IDs hard-coded in Bee // Setting EnforceManifest to true will also ensure no artifacts // are used without being listed in a manifest. EnforceManifest = true, Manifest = { bee.Parent.Combine("manifest.stevedore").ToString(), }, }; //The stevedore global manifest will override DownloadableCsc.Csc72 artifacts and use Csc73 CSharpConfig = new CSharpProgramConfiguration(CSharpCodeGen.Release, DownloadableCsc.Csc72, HostPlatform.IsWindows ? (DebugFormat)DebugFormat.Pdb : DebugFormat.PortablePdb); var asmdefsFile = new NPath("asmdefs.json").MakeAbsolute(); var asmDefInfo = JObject.Parse(asmdefsFile.ReadAllText()); var asmDefs = asmDefInfo["asmdefs"].Value <JArray>(); var asmDefFullPaths = asmDefs.Select(a => new NPath(a["FullPath"].Value <string>())); var buildProgram = new CSharpProgram() { Path = path[0], Sources = { bee.Parent.Combine("BuildProgramSources"), asmDefFullPaths.SelectMany(a => HarvestBeeFilesFrom(a.Parent)) }, Framework = { Framework.Framework471 }, LanguageVersion = "7.2", References = { bee }, ProjectFile = { Path = NPath.CurrentDirectory.Combine("buildprogram.gen.csproj") } }; ((TundraBackend)Backend.Current).AddExtensionToBeScannedByHashInsteadOfTimeStamp("json", "config"); buildProgram.ProjectFile.AddCustomLinkRoot(bee.Parent.Combine("BuildProgramSources"), "."); buildProgram.SetupSpecificConfiguration(CSharpConfig); var buildProgrambuildProgram = new CSharpProgram() { FileName = "buildprogrambuildprogram.exe", Sources = { bee.Parent.Combine("BuildProgramBuildProgramSources") }, LanguageVersion = "7.2", Framework = { Framework.Framework471 }, References = { bee } }; buildProgrambuildProgram.SetupSpecificConfiguration(CSharpConfig); new VisualStudioSolution() { Path = "build.gen.sln", Projects = { buildProgram, buildProgrambuildProgram } }.Setup(); }
private static bool IsManagedDebuggingWithIL2CPPEnabled(CSharpProgramConfiguration c) { return((c as DotsRuntimeCSharpProgramConfiguration).EnableManagedDebugging && (c as DotsRuntimeCSharpProgramConfiguration).ScriptingBackend == ScriptingBackend.TinyIl2cpp); }
static void Main(string[] path) { var bee = new NPath(typeof(CSharpProgram).Assembly.Location); StevedoreGlobalSettings.Instance = new StevedoreGlobalSettings { // Manifest entries always override artifact IDs hard-coded in Bee // Setting EnforceManifest to true will also ensure no artifacts // are used without being listed in a manifest. EnforceManifest = true, Manifest = { bee.Parent.Combine("manifest.stevedore").ToString(), }, }; //The stevedore global manifest will override DownloadableCsc.Csc72 artifacts and use Csc73 CSharpConfig = new CSharpProgramConfiguration(CSharpCodeGen.Release, DownloadableCsc.Csc72, DebugFormat.PortablePdb); var asmdefsFile = new NPath("asmdefs.json").MakeAbsolute(); var asmDefInfo = JObject.Parse(asmdefsFile.ReadAllText()); var asmDefs = asmDefInfo["asmdefs"].Value <JArray>(); var asmRefs = asmDefInfo["asmrefs"].Value <JArray>(); var asmDefToAsmRefs = new Dictionary <string, List <string> >(); foreach (var asmref in asmRefs) { var target = asmref["AsmRefTarget"].Value <string>(); if (target.StartsWith("GUID:")) { target = asmDefs.First(ad => ad["Guid"].Value <string>() == target.Substring(5))["AsmdefName"] .Value <string>(); } List <string> toaddto; if (asmDefToAsmRefs.TryGetValue(target, out var list)) { toaddto = list; } else { toaddto = new List <string>(); asmDefToAsmRefs[target] = toaddto; } toaddto.Add(asmref["FullPath"].Value <string>()); } var buildProgram = new CSharpProgram() { Path = path[0], Sources = { bee.Parent.Combine("BuildProgramSources"), asmDefs.SelectMany(asmdef => { var apath = new NPath(asmdef["FullPath"].Value <string>()); var beeFiles = HarvestBeeFilesFrom(apath.Parent); var asmdefName = asmdef["AsmdefName"].Value <string>(); if (asmDefToAsmRefs.TryGetValue(asmdefName, out var asmrefs)) { foreach (var asmref in asmrefs) { beeFiles = beeFiles.Concat(HarvestBeeFilesFrom(asmref.ToNPath().Parent)); } } return(beeFiles); }), HarvestBeeFilesFrom(bee.Parent.Parent.Combine("LowLevelSupport~", "Unity.ZeroJobs")) },
private static void AddActions(CSharpProgramConfiguration config, DotNetAssembly[] inputAssemblies, NPath targetDirectory, string[] defines) { var processors = BuildProgram.ILPostProcessorAssemblies.Select(asm => asm.Path.MakeAbsolute().ResolveWithFileSystem()); var outputDirArg = "-o " + targetDirectory.MakeAbsolute().QuoteForProcessStart(); var processorPathsArg = processors.Count() > 0 ? "-p " + processors.Select(p => p.QuoteForProcessStart()).Aggregate((s1, s2) => s1 + "," + s2) : ""; foreach (var inputAsm in inputAssemblies.OrderByDependencies()) { var inputAssemblyPath = inputAsm.Path.ResolveWithFileSystem().MakeAbsolute(); var assemblyArg = "-a " + inputAssemblyPath.QuoteForProcessStart(); var referenceAsmPaths = inputAsm.RecursiveRuntimeDependenciesIncludingSelf.Where(a => !a.Path.IsChildOf("post_ilprocessing")) .Select(a => a.Path.MakeAbsolute().ResolveWithFileSystem()); var dotsConfig = (DotsRuntimeCSharpProgramConfiguration)config; switch (dotsConfig.TargetFramework) { case TargetFramework.Tiny: { referenceAsmPaths = referenceAsmPaths.Concat( new[] { Il2Cpp.Distribution.Path.Combine("build/profiles/Tiny/Facades/netstandard.dll").ResolveWithFileSystem(), Il2Cpp.TinyCorlib.Path.ResolveWithFileSystem() }); break; } case TargetFramework.NetStandard20: { NPath bclDir = Il2Cpp.Il2CppDependencies.Path.Combine("MonoBleedingEdge/builds/monodistribution/lib/mono/unityaot").ResolveWithFileSystem(); referenceAsmPaths = referenceAsmPaths.Concat(new[] { bclDir.Combine("mscorlib.dll"), bclDir.Combine("Facades/netstandard.dll") }); break; } default: throw new NotImplementedException($"Unknown target framework: {dotsConfig.TargetFramework}"); } var referencesArg = referenceAsmPaths.Any() ? "-r " + referenceAsmPaths.Select(r => r.MakeAbsolute().QuoteForProcessStart()).Distinct().Aggregate((s1, s2) => s1 + "," + s2) : string.Empty; var assemblyFolders = referenceAsmPaths.Select(p => p.Parent.QuoteForProcessStart()).Concat(new[] { inputAssemblyPath.Parent.QuoteForProcessStart() }).Distinct(); var assemblyFoldersArg = assemblyFolders.Any() ? "-f " + assemblyFolders.Aggregate((d1, d2) => d1 + "," + d2) : ""; var allscriptDefines = dotsConfig.Defines.Concat(defines); var definesArg = !allscriptDefines.Empty() ? "-d " + allscriptDefines.Distinct().Aggregate((d1, d2) => d1 + "," + d2) : ""; var targetFiles = TargetPathsFor(targetDirectory, inputAsm).ResolveWithFileSystem().ToArray(); var inputFiles = InputPathsFor(inputAsm).Concat(processors).Concat(new[] { _ILPostProcessorRunnableProgram.Path }).Concat(referenceAsmPaths).ResolveWithFileSystem().ToArray(); var args = new List <string> { assemblyArg, outputDirArg, processorPathsArg, assemblyFoldersArg, referencesArg, definesArg }.ToArray(); Backend.Current.AddAction( actionName: $"ILPostProcessorRunner", targetFiles: targetFiles, inputs: inputFiles, executableStringFor: _ILPostProcessorRunnableProgram.InvocationString, commandLineArguments: args, allowedOutputSubstrings: new[] { "ILPostProcessorRunner", "[WARN]", "[ERROR]" }, supportResponseFile: true ); } }