Esempio n. 1
0
        public Il2CppOutputProgram(string name) : base(name)
        {
            AddLibIl2CppAsLibraryFor(this);

            Libraries.Add(BoehmGCProgram);
            Sources.Add(Distribution.Path.Combine("external").Combine("xxHash/xxhash.c"));

            this.DynamicLinkerSettingsForMsvc()
            .Add(l => l.WithSubSystemType(SubSystemType.Console).WithEntryPoint("wWinMainCRTStartup"));

            Libraries.Add(c => c.ToolChain.Platform is WindowsPlatform, new SystemLibrary("kernel32.lib"));
            Defines.Add(c => c.Platform is WebGLPlatform, "IL2CPP_DISABLE_GC=1");

            this.DynamicLinkerSettingsForMsvc().Add(l => l
                                                    .WithSubSystemType(SubSystemType.Console)
                                                    .WithEntryPoint("wWinMainCRTStartup")
                                                    );
            Defines.Add(c => c.ToolChain.DynamicLibraryFormat == null, "FORCE_PINVOKE_INTERNAL=1");

            this.DynamicLinkerSettingsForEmscripten().Add(c =>
                                                          c.WithShellFile(BuildProgram.BeeRoot.Combine("shell.html")));


            Libraries.Add(c => c.Platform is WebGLPlatform, new PreJsLibrary(BuildProgram.BeeRoot.Combine("tiny_runtime.js")));
            Defines.Add(ManagedDebuggingIsEnabled, "IL2CPP_MONO_DEBUGGER=1");
            Defines.Add(ManagedDebuggingIsEnabled, "IL2CPP_DEBUGGER_PORT=56000");
            CompilerSettings().Add(ManagedDebuggingIsEnabled, c => c.WithExceptions(true));
            CompilerSettings().Add(ManagedDebuggingIsEnabled, c => c.WithRTTI(true));
            MsvcNativeProgramExtensions.CompilerSettingsForMsvc(this).Add(c => c.WithWarningPolicies(new [] { new WarningAndPolicy("4102", WarningPolicy.Silent) }));
            CompilerSettings().Add(s => s.WithCppLanguageVersion(CppLanguageVersion.Cpp11));
        }
Esempio n. 2
0
        public bool TryParse(string[] args)
        {
            if (!Parser.TryParseArgs(args, out var parsedArgs))
            {
                return(false);
            }

            foreach (var parsedArg in parsedArgs)
            {
                if (
                    TryProcess(parsedArg, "r", "reference", References, isFile: true) ||
                    TryProcess(parsedArg, "s", "sourceFile", SourceFiles, isFile: true) ||
                    TryProcess(parsedArg, "d", "define", val => Defines.Add(val)) ||
                    TryProcess(parsedArg, "o", "outputFile", val => OutputFile = val) ||
                    TryProcess(parsedArg, "ns", "nameSpace", val => Namespace = val) ||
                    TryProcess(parsedArg, "h", "help", _ => Help = true) ||
                    TryProcess(parsedArg, "?", "???", _ => Help = true)
                    )
                {
                    continue;
                }

                if (!Help)
                {
                    Console.Error.WriteLine($"Error: Unsupported argument '{parsedArg.OriginalArg}'");
                }

                ShowHelp();
                return(false);
            }

            return(true);
        }
Esempio n. 3
0
 public void Define(string define)
 {
     if (!Defines.Contains(define))
     {
         Defines.Add(define);
     }
     Log("Defined '{0}'", define);
 }
 private void AddDefine(object param)
 {
     Defines.Add(new DefinitionViewModel(Model, new Definition {
         Value = DefineText
     }));
     DefineText = string.Empty;
     Save();
 }
Esempio n. 5
0
 public freetypeBuild()
 {
     ModuleRoot = "\\freetype2\\";
     AddLibSearch(ref LibrarySearchPaths, "", LibBuildConfig.General, false);
     AddLibSearch(ref LibrarySearchPaths, "", LibBuildConfig.General, true);
     LibDirs.Add("../source/ThirdParty/freetype2/");
     StaticLibraries.Add(new LibDependency("freetype.lib", "all"));
     Defines.Add("SUPPORT_FREETYPE");
 }
Esempio n. 6
0
 public OpenVRBuild()
 {
     ModuleRoot = "\\OpenVR\\";
     AddLibSearch(ref LibrarySearchPaths, "", LibBuildConfig.General, false);
     AddLibSearch(ref LibrarySearchPaths, "", LibBuildConfig.General, true);
     DLLs.Add("openvr_api.dll");
     UnsupportedPlatforms.Add("X*");
     Defines.Add("SUPPORT_OPENVR");
     StaticLibraries.Add(new LibDependency("openvr_api.lib", "win64"));
     LibDirs.Add("../source/ThirdParty/OpenVR/");
 }
Esempio n. 7
0
 public assimpBuild()
 {
     ModuleRoot = "\\assimp\\";
     AddLibSearch(ref LibrarySearchPaths, "", LibBuildConfig.General, false);
     AddLibSearch(ref LibrarySearchPaths, "", LibBuildConfig.General, true);
     StaticLibraries.Add(new LibDependency("assimp.lib", "win64"));
     DLLs.Add("assimp-vc140-mt.dll");
     UnsupportedPlatforms.Add("X*");
     Defines.Add("BUILD_ASSIMP");
     LibDirs.Add("../source/ThirdParty/assimp/");
 }
        public override bool VisitStmtPreDefineBool([NotNull] GamaPreprocessorParser.StmtPreDefineBoolContext context)
        {
            var name = context.Symbol().GetText();

            if (Defines.ContainsKey(name))
            {
                return(false);
            }
            Defines.Add(name, "");
            return(true);
        }
Esempio n. 9
0
 void AddDefine(string arg)
 {
     foreach (var item in Defines)
     {
         if (arg.ToLower() == item.ToLower())
         {
             return;
         }
     }
     Defines.Add(arg);
 }
        public override bool VisitStmtPreDefineAbsolute([NotNull] GamaPreprocessorParser.StmtPreDefineAbsoluteContext context)
        {
            var name = context.Symbol().GetText();

            if (Defines.ContainsKey(name))
            {
                return(false);
            }
            Defines.Add(name, context.NonNewlineString().GetText());
            return(true);
        }
Esempio n. 11
0
        /// <summary>
        /// Extracts meta comments from all C# files of this compilation, including project files and files added through meta option 'c'.
        /// Returns false if there are errors, except with flag ForCodeInfo. Then use <see cref="Errors"/>.
        /// </summary>
        /// <param name="f">Main C# file. If projFolder not null, must be the main file of the project.</param>
        /// <param name="projFolder">Project folder of the main file, or null if it is not in a project.</param>
        /// <param name="flags"></param>
        public bool Parse(FileNode f, FileNode projFolder, EMPFlags flags)
        {
            Debug.Assert(Errors == null);             //cannot be called multiple times
            Errors = new ErrBuilder();
            _flags = flags;

            _ParseFile(f, true);

            if (projFolder != null)
            {
                foreach (var ff in projFolder.EnumProjectClassFiles(f))
                {
                    _ParseFile(ff, false);
                }
            }

            if (_filesC != null)
            {
                foreach (var ff in _filesC)
                {
                    if (CodeFiles.Exists(o => o.f == ff))
                    {
                        continue;
                    }
                    _ParseFile(ff, false);
                }
            }

            if (!Optimize)
            {
                if (!Defines.Contains("DEBUG"))
                {
                    Defines.Add("DEBUG");
                }
                if (!Defines.Contains("TRACE"))
                {
                    Defines.Add("TRACE");
                }
            }
            //if(Role == ERole.exeProgram && !Defines.Contains("EXE")) Defines.Add("EXE"); //rejected

            _FinalCheckOptions();

            if (Errors.ErrorCount > 0)
            {
                if (flags.Has(EMPFlags.PrintErrors))
                {
                    Errors.PrintAll();
                }
                return(false);
            }
            return(true);
        }
Esempio n. 12
0
        public void AddDefine(string define)
        {
            if (!s_defineValidationRegex.Value.IsMatch(define))
            {
                throw new Error("error: invalid define '{0}', a define must be a single word", define);
            }

            if (Defines.Add(define))
            {
                DebugWriteLine("Added define: {0}", define);
            }
        }
Esempio n. 13
0
        /// <summary>
        /// Configure this instance with Windows and MSVC.
        /// </summary>
        /// <returns>This instance</returns>
        public CppParserOptions ConfigureForWindowsMsvc(CppTargetCpu targetCpu = CppTargetCpu.X86, CppVisualStudioVersion vsVersion = CppVisualStudioVersion.VS2019)
        {
            // 1920
            var highVersion = ((int)vsVersion) / 100;   // => 19
            var lowVersion  = ((int)vsVersion) % 100;   // => 20

            var versionAsString = $"{highVersion}.{lowVersion}";

            TargetCpu    = targetCpu;
            TargetCpuSub = string.Empty;
            TargetVendor = "pc";
            TargetSystem = "windows";
            TargetAbi    = $"msvc{versionAsString}";

            // See https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros?view=vs-2019

            Defines.Add($"_MSC_VER={(int)vsVersion}");
            Defines.Add("_WIN32=1");

            switch (targetCpu)
            {
            case CppTargetCpu.X86:
                Defines.Add("_M_IX86=600");
                break;

            case CppTargetCpu.X86_64:
                Defines.Add("_M_AMD64=100");
                Defines.Add("_M_X64=100");
                Defines.Add("_WIN64=1");
                break;

            case CppTargetCpu.ARM:
                Defines.Add("_M_ARM=7");
                break;

            case CppTargetCpu.ARM64:
                Defines.Add("_M_ARM64=1");
                Defines.Add("_WIN64=1");
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(targetCpu), targetCpu, null);
            }

            AdditionalArguments.Add("-fms-extensions");
            AdditionalArguments.Add("-fms-compatibility");
            AdditionalArguments.Add($"-fms-compatibility-version={versionAsString}");
            return(this);
        }
Esempio n. 14
0
        public void Merge(ShaderCompilerContext cctx)
        {
            if (cctx == null)
            {
                throw new ArgumentNullException("cctx");
            }

            foreach (string symbol in cctx.Defines)
            {
                if (Defines.Contains(symbol) == false)
                {
                    Defines.Add(symbol);
                }
            }
            Defines.Sort();
        }
Esempio n. 15
0
        public Il2CppOutputProgram(string name) : base(name)
        {
            AddLibIl2CppAsLibraryFor(this);

            var distRoot = Distribution.Path.ResolveWithFileSystem();

            Libraries.Add(BoehmGCProgram);
            Sources.Add(distRoot.Combine("external").Combine("xxHash/xxhash.c"));

            this.DynamicLinkerSettingsForMsvc()
            .Add(l => l.WithSubSystemType(SubSystemType.Console).WithEntryPoint("wWinMainCRTStartup"));

            Libraries.Add(c => c.ToolChain.Platform is WindowsPlatform, new SystemLibrary("kernel32.lib"));

            this.DynamicLinkerSettingsForMsvc().Add(l => l
                                                    .WithSubSystemType(SubSystemType.Console)
                                                    .WithEntryPoint("wWinMainCRTStartup")
                                                    );
            Defines.Add(c => c.ToolChain.DynamicLibraryFormat == null, "FORCE_PINVOKE_INTERNAL=1");

            this.DynamicLinkerSettingsForAndroid().Add(c =>
                                                       ((DotsRuntimeNativeProgramConfiguration)c).CSharpConfig.DotsConfiguration == DotsConfiguration.Release, l => l.WithStripAll(true));

            Libraries.Add(c => c.Platform is WebGLPlatform, new PreJsLibrary(BuildProgram.BeeRoot.Parent.Combine("LowLevelSupport~", "WebSupport", "tiny_runtime.js")));
            Defines.Add(ManagedDebuggingIsEnabled, "IL2CPP_MONO_DEBUGGER=1");
            Defines.Add(ManagedDebuggingIsEnabled, "IL2CPP_DEBUGGER_PORT=56000");

            // Remove this comment to enable the managed debugger log file. It will be written to the working directory. For Web builds, the output will go to the browser's console.
            //Defines.Add(ManagedDebuggingIsEnabled, "IL2CPP_MONO_DEBUGGER_LOGFILE=il2cpp-debugger.log");

            Defines.Add(c => ((DotsRuntimeNativeProgramConfiguration)c).CSharpConfig.DotsConfiguration != DotsConfiguration.Release, "IL2CPP_TINY_DEBUG_METADATA");
            CompilerSettings().Add(ManagedDebuggingIsEnabled, c => c.WithExceptions(true));
            CompilerSettings().Add(ManagedDebuggingIsEnabled, c => c.WithRTTI(true));
            IncludeDirectories.Add(ManagedDebuggingIsEnabled, distRoot.Combine("libil2cpp/pch"));

            CompilerSettings().Add(s => s.WithCppLanguageVersion(CppLanguageVersion.Cpp11));

            this.CompilerSettingsForMsvc().Add(c => c.WithWarningPolicies(new [] { new WarningAndPolicy("4102", WarningPolicy.Silent) }));
            this.CompilerSettingsForGcc().Add(s => s.WithWarningPolicies(GetGccLikeWarningPolicies()));
            this.CompilerSettingsForClang().Add(s => s.WithWarningPolicies(GetGccLikeWarningPolicies()));
            this.CompilerSettingsForEmscripten().Add(s => s.WithWarningPolicies(GetGccLikeWarningPolicies()));
            this.CompilerSettingsForIos().Add(s => s.WithWarningPolicies(GetGccLikeWarningPolicies()));
            NativeJobsPrebuiltLibrary.AddToNativeProgram(this); // Only required for managed debugging
            this.CompilerSettingsForEmscripten().Add(ManagedDebuggingIsEnabled,
                                                     c => c.WithMultithreading_Compiler(EmscriptenMultithreadingMode.Enabled));
            this.CompilerSettingsForGccLike().Add(s => s.WithCustomFlags(new[] { "-fno-strict-overflow" }));
        }
Esempio n. 16
0
        public void SetupConditionalSourcesAndLibrariesForConfig(DotsRuntimeCSharpProgramConfiguration config, DotNetAssembly setupGame)
        {
            NPath[] il2cppGeneratedFiles = SetupInvocation(setupGame, config).ResolveWithFileSystem();

            //todo: stop comparing identifier.
            Sources.Add(npc => ((DotsRuntimeNativeProgramConfiguration)npc).CSharpConfig == config, il2cppGeneratedFiles);
            var staticLibs = setupGame.RecursiveRuntimeDependenciesIncludingSelf.SelectMany(r => r.Deployables.OfType <StaticLibrary>());

            Libraries.Add(npc => ((DotsRuntimeNativeProgramConfiguration)npc).CSharpConfig == config, staticLibs);

            // force pinvoke internal for static libraries
            staticLibs.ForEach(l => Defines.Add(npc => ((DotsRuntimeNativeProgramConfiguration)npc).CSharpConfig == config, PinvokeInternalDefineFor(l)));

            if (config.EnableManagedDebugging)
            {
                SupportFiles.Add(c => c == config.NativeProgramConfiguration, new DeployableFile(Il2CppTargetDirForAssembly(setupGame).Combine(metadataFilePath), new NPath(metadataFilePath)));
            }
        }
Esempio n. 17
0
 public void FindDefines()
 {
     foreach (var nodeHelper in _script.Nodes)
     {
         if (nodeHelper.Type == NodeTypes.Define)
         {
             if (!string.IsNullOrWhiteSpace(nodeHelper.Value))
             {
                 Defines.Add(nodeHelper.Value.Trim());
             }
         }
         if (nodeHelper.Type == NodeTypes.Undefine)
         {
             if (!string.IsNullOrWhiteSpace(nodeHelper.Value))
             {
                 Undefines.Add(nodeHelper.Value.Trim());
             }
         }
     }
 }
Esempio n. 18
0
        public Il2CppOutputProgram(string name) : base(name)
        {
            Libraries.Add(LibIL2Cpp);
            Libraries.Add(BoehmGCProgram);
            Sources.Add(Distribution.Path.Combine("external").Combine("xxHash/xxhash.c"));

            this.DynamicLinkerSettingsForMsvc()
            .Add(l => l.WithSubSystemType(SubSystemType.Console).WithEntryPoint("wWinMainCRTStartup"));

            Libraries.Add(c => c.ToolChain.Platform is WindowsPlatform, new SystemLibrary("kernel32.lib"));
            Defines.Add(c => c.Platform is WebGLPlatform, "IL2CPP_DISABLE_GC=1");

            this.DynamicLinkerSettingsForMsvc().Add(l => l
                                                    .WithSubSystemType(SubSystemType.Console)
                                                    .WithEntryPoint("wWinMainCRTStartup")
                                                    );
            Defines.Add(c => c.ToolChain.DynamicLibraryFormat == null, "FORCE_PINVOKE_INTERNAL=1");

            this.DynamicLinkerSettingsForEmscripten().Add(c =>
                                                          c.WithShellFile(BuildProgram.BeeRoot.Combine("shell.html")));


            Libraries.Add(c => c.Platform is WebGLPlatform, new PreJsLibrary(BuildProgram.BeeRoot.Combine("tiny_runtime.js")));
        }
Esempio n. 19
0
    protected void Construct(string name, bool isExe)
    {
        FileName = name + (isExe ? ".exe" : ".dll");

        Framework.Add(c => ShouldTargetTinyCorlib(c, this), Bee.DotNet.Framework.FrameworkNone);
        References.Add(c => ShouldTargetTinyCorlib(c, this), Il2Cpp.TinyCorlib);

        Framework.Add(c => !ShouldTargetTinyCorlib(c, this), Bee.DotNet.Framework.Framework471);
        References.Add(c => !ShouldTargetTinyCorlib(c, this), new SystemReference("System"));

        ProjectFile.Path = DeterminePathForProjectFile();

        ProjectFile.ReferenceModeCallback = arg =>
        {
            // Most projects are AsmDefCSharpProgram. For everything else we'll look up their
            // packagestatus by the fact that we know it's in the same package as Unity.Entities.CPlusPlus
            // XXX This is not true any more!
            //var asmdefDotsProgram = (arg as AsmDefCSharpProgram)?.AsmDefDescription ?? AsmDefConfigFile.AsmDefDescriptionFor("Unity.Entities.CPlusPlus");
            return(ProjectFile.ReferenceMode.ByCSProj);
        };

        LanguageVersion = "7.3";
        Defines.Add(
            "UNITY_DOTSPLAYER",
            "NET_DOTS",
            // TODO -- figure out what's gated with this, and if it should have a UNITY_DOTSPLAYER || ...
            "UNITY_2018_3_OR_NEWER",
            // And these might not make sense for DOTS Runtime anyway beacuse they are UnityEngine/UnityEditor APIs.
            // They break the build if we add them.
            //"UNITY_2019_1_OR_NEWER",
            //"UNITY_2019_2_OR_NEWER",
            //"UNITY_2019_3_OR_NEWER",
            // TODO -- removing this breaks Burst, it should be using DOTSPLAYER!
            "UNITY_ZEROPLAYER"
            );

        Defines.Add(c => (c as DotsRuntimeCSharpProgramConfiguration)?.Platform is WebGLPlatform, "UNITY_WEBGL");
        Defines.Add(c => (c as DotsRuntimeCSharpProgramConfiguration)?.Platform is WindowsPlatform, "UNITY_WINDOWS");
        Defines.Add(c => (c as DotsRuntimeCSharpProgramConfiguration)?.Platform is MacOSXPlatform, "UNITY_MACOSX");
        Defines.Add(c => (c as DotsRuntimeCSharpProgramConfiguration)?.Platform is LinuxPlatform, "UNITY_LINUX");
        Defines.Add(c => (c as DotsRuntimeCSharpProgramConfiguration)?.Platform is IosPlatform, "UNITY_IOS");
        Defines.Add(c => (c as DotsRuntimeCSharpProgramConfiguration)?.Platform is AndroidPlatform, "UNITY_ANDROID");
        Defines.Add(c => !((DotsRuntimeCSharpProgramConfiguration)c).MultiThreadedJobs, "UNITY_SINGLETHREADED_JOBS");

        CopyReferencesNextToTarget = false;

        WarningsAsErrors = false;
        //hack, fix this in unity.mathematics

        foreach (var sourcePath in AllSourcePaths)
        {
            if (sourcePath.FileName == "Unity.Mathematics")
            {
                Sources.Add(sourcePath.Files("*.cs", true)
                            .Where(f => f.FileName != "math_unity_conversion.cs" && f.FileName != "PropertyAttributes.cs"));
            }
            else
            {
                Sources.Add(new CustomProvideFiles(sourcePath));
            }
        }
        foreach (var sourcePath in AllSourcePaths)
        {
            var cppFolder     = sourcePath.Combine("cpp~");
            var prejsFolder   = sourcePath.Combine("prejs~");
            var jsFolder      = sourcePath.Combine("js~");
            var postjsFolder  = sourcePath.Combine("postjs~");
            var beeFolder     = sourcePath.Combine("bee~");
            var includeFolder = cppFolder.Combine("include");

            NPath[] cppFiles = Array.Empty <NPath>();
            if (cppFolder.DirectoryExists())
            {
                cppFiles = cppFolder.Files("*.c*", true);
                ProjectFile.AdditionalFiles.AddRange(cppFolder.Files(true));
                GetOrMakeNativeProgram().Sources.Add(cppFiles);
            }

            if (prejsFolder.DirectoryExists())
            {
                var jsFiles = prejsFolder.Files("*.js", true);
                ProjectFile.AdditionalFiles.AddRange(prejsFolder.Files(true));
                GetOrMakeNativeProgram()
                .Libraries.Add(c => c.Platform is WebGLPlatform,
                               jsFiles.Select(jsFile => new PreJsLibrary(jsFile)));
            }

            //todo: get rid of having both a regular js and a prejs folder
            if (jsFolder.DirectoryExists())
            {
                var jsFiles = jsFolder.Files("*.js", true);
                ProjectFile.AdditionalFiles.AddRange(jsFolder.Files(true));
                GetOrMakeNativeProgram()
                .Libraries.Add(c => c.Platform is WebGLPlatform,
                               jsFiles.Select(jsFile => new JavascriptLibrary(jsFile)));
            }

            if (postjsFolder.DirectoryExists())
            {
                var jsFiles = postjsFolder.Files("*.js", true);
                ProjectFile.AdditionalFiles.AddRange(postjsFolder.Files(true));
                GetOrMakeNativeProgram()
                .Libraries.Add(c => c.Platform is WebGLPlatform,
                               jsFiles.Select(jsFile => new PostJsLibrary(jsFile)));
            }

            if (beeFolder.DirectoryExists())
            {
                ProjectFile.AdditionalFiles.AddRange(beeFolder.Files("*.cs"));
            }

            if (includeFolder.DirectoryExists())
            {
                GetOrMakeNativeProgram().PublicIncludeDirectories.Add(includeFolder);
            }
        }

        SupportFiles.Add(AllSourcePaths.SelectMany(p =>
                                                   p.Files()
                                                   .Where(f => f.HasExtension("jpg", "png", "wav", "mp3", "jpeg", "mp4", "webm", "ogg", "ttf", "json"))));

        Defines.Add(c => c.CodeGen == CSharpCodeGen.Debug || (c as DotsRuntimeCSharpProgramConfiguration)?.DotsConfiguration < DotsConfiguration.Release, "DEBUG");

        Defines.Add(c => ((DotsRuntimeCSharpProgramConfiguration)c).EnableUnityCollectionsChecks, "ENABLE_UNITY_COLLECTIONS_CHECKS");

        Defines.Add(
            c => (c as DotsRuntimeCSharpProgramConfiguration)?.ScriptingBackend == ScriptingBackend.TinyIl2cpp,
            "UNITY_DOTSPLAYER_IL2CPP");
        Defines.Add(c => (c as DotsRuntimeCSharpProgramConfiguration)?.ScriptingBackend == ScriptingBackend.Dotnet, "UNITY_DOTSPLAYER_DOTNET");
        Defines.Add(c => (c as DotsRuntimeCSharpProgramConfiguration)?.Defines ?? new List <string>());

        ProjectFile.RedirectMSBuildBuildTargetToBee = true;
        ProjectFile.AddCustomLinkRoot(MainSourcePath, ".");
        ProjectFile.RootNameSpace = "";

        DotsRuntimeCSharpProgramCustomizer.RunAllCustomizersOn(this);
    }
Esempio n. 20
0
 public void AddDefines(string value)
 {
     Defines.Add(value);
 }
Esempio n. 21
0
 public void DisableExceptions()
 {
     Defines.Add("_HAS_EXCEPTIONS=0");
     Options.Add(Sharpmake.Options.Vc.Compiler.Exceptions.Disable);
 }
Esempio n. 22
0
            public ManagedTestInfo(Platform platform, ManagedTestVariant type = ManagedTestVariant.None)
            {
                bool fsharp = type == ManagedTestVariant.FSharp;

                Platform = platform;

                ManagedTestCount = GetBaseTestCount(fsharp);
                Defines.Add("TEST_FRAMEWORK=1");

                // There would be a lot of fsharp projects to clone to do them all...
                if (fsharp && Platform != Platform.macOSModern)
                {
                    throw new NotImplementedException();
                }

                if (type == ManagedTestVariant.ManagedExceptions)
                {
                    Defines.Add("NATIVEEXCEPTION");
                    AdditionalGeneratorArgs = "--nativeexception";
                }

                switch (platform)
                {
                case Platform.macOSFull:
                    Dlldir  = "macos-full";
                    Dllname = "managed-macos-full.dll";
                    Defines.Add("XAMARIN_MAC=1");
                    Defines.Add("XAMARIN_MAC_FULL=1");
                    Abi = "x86_64";                     // FIXME: fat XM apps not supported yet
                    ManagedTestCount += GetMacTestCount();
                    return;

                case Platform.macOSSystem:
                    Dlldir  = "macos-system";
                    Dllname = "managed-macos-system.dll";
                    Defines.Add("XAMARIN_MAC=1");
                    Defines.Add("XAMARIN_MAC_SYSTEM=1");
                    Abi = "x86_64";                     // FIXME: fat XM apps not supported yet
                    ManagedTestCount += GetMacTestCount();
                    return;

                case Platform.macOSModern:
                    if (fsharp)
                    {
                        Dlldir  = "fsharp-macos";
                        Dllname = "fsharp-macos.dll";
                        Defines.Add("XAMARIN_FSHARP=1");
                    }
                    else
                    {
                        Dlldir  = "macos-modern";
                        Dllname = "managed-macos-modern.dll";
                        Defines.Add("XAMARIN_MAC_MODERN=1");
                    }
                    Defines.Add("XAMARIN_MAC=1");
                    Abi = "x86_64";                     // FIXME: fat XM apps not supported yet
                    ManagedTestCount += GetMacTestCount(fsharp);
                    return;

                case Platform.macOS:
                    Dlldir  = "generic";
                    Dllname = "managed.dll";
                    Abi     = "i386,x86_64";
                    return;

                case Platform.iOS:
                    Dlldir  = "ios";
                    Dllname = "managed-ios.dll";
                    Defines.Add("XAMARIN_IOS=1");
                    Abi = "armv7,arm64,i386,x86_64";
                    ManagedTestCount += GetIOSTestCount();
                    return;

                case Platform.tvOS:
                    Dlldir  = "tvos";
                    Dllname = "managed-tvos.dll";
                    Defines.Add("XAMARIN_TVOS=1");
                    Abi = "arm64,x86_64";
                    ManagedTestCount += GetTVTestCount();
                    return;

                default:
                    throw new NotImplementedException();
                }
            }
    protected void Construct(string name, bool isExe)
    {
        FileName = name + (isExe ? ".exe" : ".dll");

        Framework.Add(c => ShouldTargetTinyCorlib(c, this), Bee.DotNet.Framework.FrameworkNone);
        References.Add(c => ShouldTargetTinyCorlib(c, this), Il2Cpp.TinyCorlib);

        Framework.Add(c => !ShouldTargetTinyCorlib(c, this), Bee.DotNet.Framework.Framework471);
        References.Add(c => !ShouldTargetTinyCorlib(c, this), new SystemReference("System"));

        ProjectFile.Path = new NPath(FileName).ChangeExtension(".csproj");

        ProjectFile.ReferenceModeCallback = arg =>
        {
            if (arg == Il2Cpp.TinyCorlib)
            {
                return(ProjectFile.ReferenceMode.ByCSProj);
            }

            //most projects are AsmDefBasedDotsRuntimeCSharpProgram. The remained are things like ZeroJobs. For them we'll look up their packagestatus by the fact that we know
            //it's in the same package as Unity.Entities.CPlusPlus
            var asmdefDotsProgram = (arg as AsmDefBasedDotsRuntimeCSharpProgram)?.AsmDefDescription ?? BuildProgramConfigFile.AsmDefDescriptionFor("Unity.Entities.CPlusPlus");

            switch (asmdefDotsProgram.PackageSource)
            {
            case "NoPackage":
            case "Embedded":
            case "Local":
                return(ProjectFile.ReferenceMode.ByCSProj);

            default:
                return(ProjectFile.ReferenceMode.ByDotNetAssembly);
            }
        };

        LanguageVersion = "7.3";
        Defines.Add(
            "UNITY_2018_3_OR_NEWER",
            "UNITY_DOTSPLAYER",
            "UNITY_ZEROPLAYER", //<-- this was used for a while, let's keep it around to not break people's incoming PR's.
            "NET_TINY",
            "NET_DOTS",
            "UNITY_USE_TINYMATH",
            "UNITY_BINDGEM"
            );

        Defines.Add(c => (c as DotsRuntimeCSharpProgramConfiguration)?.Platform is WebGLPlatform, "UNITY_WEBGL");
        Defines.Add(c => (c as DotsRuntimeCSharpProgramConfiguration)?.Platform is WindowsPlatform, "UNITY_WINDOWS");
        Defines.Add(c => (c as DotsRuntimeCSharpProgramConfiguration)?.Platform is MacOSXPlatform, "UNITY_MACOSX");
        Defines.Add(c => (c as DotsRuntimeCSharpProgramConfiguration)?.Platform is LinuxPlatform, "UNITY_LINUX");
        Defines.Add(c => (c as DotsRuntimeCSharpProgramConfiguration)?.Platform is IosPlatform, "UNITY_IOS");
        Defines.Add(c => (c as DotsRuntimeCSharpProgramConfiguration)?.Platform is AndroidPlatform, "UNITY_ANDROID");

        CopyReferencesNextToTarget = false;

        WarningsAsErrors = false;
        //hack, fix this in unity.mathematics
        if (SourcePath.FileName == "Unity.Mathematics")
        {
            Sources.Add(SourcePath.Files("*.cs", true).Where(f => f.FileName != "math_unity_conversion.cs" && f.FileName != "PropertyAttributes.cs"));
        }
        else
        {
            var csFilesForDirectory = CSFilesForDirectory(SourcePath).ToList();
            if (csFilesForDirectory.Count == 0)
            {
                csFilesForDirectory.Add(BuildProgram.BeeRoot.Combine("CSharpSupport/PlaceHolderForEmptyProject.cs"));
            }
            Sources.Add(csFilesForDirectory);
        }

        var cppFolder     = SourcePath.Combine("cpp~");
        var prejsFolder   = SourcePath.Combine("prejs~");
        var jsFolder      = SourcePath.Combine("js~");
        var postjsFolder  = SourcePath.Combine("postjs~");
        var beeFolder     = SourcePath.Combine("bee~");
        var includeFolder = cppFolder.Combine("include");

        NPath[] cppFiles = Array.Empty <NPath>();
        if (cppFolder.DirectoryExists())
        {
            cppFiles = cppFolder.Files("*.c*", true);
            ProjectFile.AdditionalFiles.AddRange(cppFolder.Files(true));
            GetOrMakeNativeProgram().Sources.Add(cppFiles);
        }

        if (prejsFolder.DirectoryExists())
        {
            var jsFiles = prejsFolder.Files("*.js", true);
            ProjectFile.AdditionalFiles.AddRange(prejsFolder.Files(true));
            GetOrMakeNativeProgram().Libraries.Add(jsFiles.Select(jsFile => new PreJsLibrary(jsFile)));
        }

        //todo: get rid of having both a regular js and a prejs folder
        if (jsFolder.DirectoryExists())
        {
            var jsFiles = jsFolder.Files("*.js", true);
            ProjectFile.AdditionalFiles.AddRange(jsFolder.Files(true));
            GetOrMakeNativeProgram().Libraries.Add(jsFiles.Select(jsFile => new JavascriptLibrary(jsFile)));
        }

        if (postjsFolder.DirectoryExists())
        {
            var jsFiles = postjsFolder.Files("*.js", true);
            ProjectFile.AdditionalFiles.AddRange(postjsFolder.Files(true));
            GetOrMakeNativeProgram().Libraries.Add(jsFiles.Select(jsFile => new PostJsLibrary(jsFile)));
        }

        if (beeFolder.DirectoryExists())
        {
            ProjectFile.AdditionalFiles.AddRange(beeFolder.Files("*.cs"));
        }

        if (includeFolder.DirectoryExists())
        {
            GetOrMakeNativeProgram().PublicIncludeDirectories.Add(includeFolder);
        }

        SupportFiles.Add(SourcePath.Files().Where(f => f.HasExtension("jpg", "png", "wav", "mp3", "jpeg", "mp4", "webm", "ogg")));


        Defines.Add(c => c.CodeGen == CSharpCodeGen.Debug, "DEBUG");

        Defines.Add(c => ((DotsRuntimeCSharpProgramConfiguration)c).EnableUnityCollectionsChecks, "ENABLE_UNITY_COLLECTIONS_CHECKS");

        Defines.Add(
            c => (c as DotsRuntimeCSharpProgramConfiguration)?.ScriptingBackend == ScriptingBackend.TinyIl2cpp,
            "UNITY_DOTSPLAYER_IL2CPP");
        Defines.Add(c => (c as DotsRuntimeCSharpProgramConfiguration)?.ScriptingBackend == ScriptingBackend.Dotnet, "UNITY_DOTSPLAYER_DOTNET");

        ProjectFile.RedirectMSBuildBuildTargetToBee = true;
        ProjectFile.AddCustomLinkRoot(SourcePath, ".");
        ProjectFile.RootNameSpace = "";

        DotsRuntimeCSharpProgramCustomizer.RunAllCustomizersOn(this);
    }
Esempio n. 24
0
    public AsmDefCSharpProgram(AsmDefDescription asmDefDescription)
        : base(asmDefDescription.Directory,
               asmDefDescription.IncludedAsmRefs.Select(asmref => asmref.Path.Parent),
               deferConstruction: true)
    {
        AsmDefDescription = asmDefDescription;

        var asmDefReferences = AsmDefDescription.References.Select(asmDefDescription1 => BuildProgram.GetOrMakeDotsRuntimeCSharpProgramFor(asmDefDescription1)).ToList();
        var isExe            = asmDefDescription.DefineConstraints.Contains("UNITY_DOTS_ENTRYPOINT") || asmDefDescription.Name.EndsWith(".Tests");

        Construct(asmDefDescription.Name, isExe);

        ProjectFile.AdditionalFiles.Add(asmDefDescription.Path);

        IncludePlatforms = AsmDefDescription.IncludePlatforms;
        ExcludePlatforms = AsmDefDescription.ExcludePlatforms;
        Unsafe           = AsmDefDescription.AllowUnsafeCode;
        References.Add(config =>
        {
            if (config is DotsRuntimeCSharpProgramConfiguration dotsConfig)
            {
                if (dotsConfig.TargetFramework == TargetFramework.Tiny)
                {
                    return(asmDefReferences.Where(rp => rp.IsSupportedFor(dotsConfig) && !IncompatibleTinyBCLAsmDefs.Contains(rp.FileName)));
                }
                else
                {
                    return(asmDefReferences.Where(rp => rp.IsSupportedFor(dotsConfig)));
                }
            }

            //this codepath will be hit for the bindgem invocation
            return(asmDefReferences);
        });

        if (AsmDefDescription.IsTinyRoot || isExe)
        {
            AsmDefCSharpProgramCustomizer.RunAllAddPlatformImplementationReferences(this);
        }

        if (BuildProgram.UnityTinyBurst != null)
        {
            References.Add(BuildProgram.UnityTinyBurst);
        }
        if (BuildProgram.ZeroJobs != null)
        {
            References.Add(BuildProgram.ZeroJobs);
        }
        if (BuildProgram.UnityLowLevel != null)
        {
            References.Add(BuildProgram.UnityLowLevel);
        }
        if (BuildProgram.TinyIO != null)
        {
            References.Add(BuildProgram.TinyIO);
        }

        // Add in any precompiled references found in the asmdef directory or sub-directory
        foreach (var pcr in asmDefDescription.PrecompiledReferences)
        {
            var files = asmDefDescription.Path.Parent.Files(pcr, true);
            if (files.Any())
            {
                References.Add(files);
            }
        }

        if (IsTestAssembly)
        {
            var nunitLiteMain = BuildProgram.BeeRoot.Combine("CSharpSupport/NUnitLiteMain.cs");
            Sources.Add(nunitLiteMain);

            // Setup for IL2CPP
            var tinyTestFramework = BuildProgram.BeeRoot.Parent.Combine("TinyTestFramework");
            Sources.Add(c => ((DotsRuntimeCSharpProgramConfiguration)c).ScriptingBackend == ScriptingBackend.TinyIl2cpp || ((DotsRuntimeCSharpProgramConfiguration)c).TargetFramework == TargetFramework.Tiny, tinyTestFramework);
            Defines.Add(c => ((DotsRuntimeCSharpProgramConfiguration)c).ScriptingBackend == ScriptingBackend.TinyIl2cpp || ((DotsRuntimeCSharpProgramConfiguration)c).TargetFramework == TargetFramework.Tiny, "UNITY_PORTABLE_TEST_RUNNER");

            // Setup for dotnet
            References.Add(c => ((DotsRuntimeCSharpProgramConfiguration)c).ScriptingBackend == ScriptingBackend.Dotnet && ((DotsRuntimeCSharpProgramConfiguration)c).TargetFramework != TargetFramework.Tiny, BuildProgram.NUnitFramework);
            ProjectFile.AddCustomLinkRoot(nunitLiteMain.Parent, "TestRunner");
            References.Add(c => ((DotsRuntimeCSharpProgramConfiguration)c).ScriptingBackend == ScriptingBackend.Dotnet && ((DotsRuntimeCSharpProgramConfiguration)c).TargetFramework != TargetFramework.Tiny, BuildProgram.NUnitLite);

            // General setup
            References.Add(BuildProgram.GetOrMakeDotsRuntimeCSharpProgramFor(AsmDefConfigFile.AsmDefDescriptionFor("Unity.Entities")));
            References.Add(BuildProgram.GetOrMakeDotsRuntimeCSharpProgramFor(AsmDefConfigFile.AsmDefDescriptionFor("Unity.Tiny.Core")));
            References.Add(BuildProgram.GetOrMakeDotsRuntimeCSharpProgramFor(AsmDefConfigFile.AsmDefDescriptionFor("Unity.Tiny.UnityInstance")));
            References.Add(BuildProgram.GetOrMakeDotsRuntimeCSharpProgramFor(AsmDefConfigFile.AsmDefDescriptionFor("Unity.Collections")));
        }
        else if (IsILPostProcessorAssembly)
        {
            References.Add(BuildProgram.UnityCompilationPipeline);
            References.Add(MonoCecil.Paths);
            References.Add(Il2Cpp.Distribution.Path.Combine("build/deploy/net471/Unity.Cecil.Awesome.dll"));
        }
    }
    protected void Construct(string name, bool isExe)
    {
        FileName = name + (isExe ? ".exe" : ".dll");

        Framework.Add(c => GetTargetFramework(c, this) == TargetFramework.Tiny, Bee.DotNet.Framework.FrameworkNone);
        References.Add(c => GetTargetFramework(c, this) == TargetFramework.Tiny, Il2Cpp.TinyCorlib);

        Framework.Add(
            c => GetTargetFramework(c, this) == TargetFramework.NetStandard20,
            BuildProgram.HackedFrameworkToUseForProjectFilesIfNecessary);

        ProjectFile.Path = DeterminePathForProjectFile();

        ProjectFile.ReferenceModeCallback = arg =>
        {
            // Most projects are AsmDefCSharpProgram. For everything else we'll look up their
            // packagestatus by the fact that we know it's in the same package as Unity.Entities.CPlusPlus
            // XXX This is not true any more!
            //var asmdefDotsProgram = (arg as AsmDefCSharpProgram)?.AsmDefDescription ?? AsmDefConfigFile.AsmDefDescriptionFor("Unity.Entities.CPlusPlus");
            return(ProjectFile.ReferenceMode.ByCSProj);
        };

        LanguageVersion = "7.3";
        Defines.Add(
            "UNITY_DOTSPLAYER", // this is deprecated and we should remove in the distant future
            "UNITY_DOTSRUNTIME",
            "UNITY_2018_3_OR_NEWER",
            "UNITY_2019_1_OR_NEWER",
            "UNITY_2019_2_OR_NEWER",
            "UNITY_2019_3_OR_NEWER",
            "UNITY_2020_1_OR_NEWER",
            "UNITY_ENTITIES_0_12_OR_NEWER"
            );

        Defines.Add(c => GetTargetFramework(c, this) == TargetFramework.Tiny, "NET_DOTS");
        Defines.Add(c => GetTargetFramework(c, this) == TargetFramework.NetStandard20, "NET_STANDARD_2_0");

        // Managed components are unsupported when using the Tiny BCL
        Defines.Add(c => GetTargetFramework(c, this) == TargetFramework.Tiny, "UNITY_DISABLE_MANAGED_COMPONENTS");

        Defines.Add(c => (c as DotsRuntimeCSharpProgramConfiguration)?.NativeProgramConfiguration?.ToolChain.Architecture.Bits == 32, "UNITY_DOTSPLAYER32");
        Defines.Add(c => (c as DotsRuntimeCSharpProgramConfiguration)?.NativeProgramConfiguration?.ToolChain.Architecture.Bits == 32, "UNITY_DOTSRUNTIME32");
        Defines.Add(c => (c as DotsRuntimeCSharpProgramConfiguration)?.NativeProgramConfiguration?.ToolChain.Architecture.Bits == 64, "UNITY_DOTSPLAYER64");
        Defines.Add(c => (c as DotsRuntimeCSharpProgramConfiguration)?.NativeProgramConfiguration?.ToolChain.Architecture.Bits == 64, "UNITY_DOTSRUNTIME64");

        Defines.Add(c => (c as DotsRuntimeCSharpProgramConfiguration)?.Platform is WebGLPlatform, "UNITY_WEBGL");
        Defines.Add(c => (c as DotsRuntimeCSharpProgramConfiguration)?.Platform is WindowsPlatform, "UNITY_WINDOWS");
        Defines.Add(c => (c as DotsRuntimeCSharpProgramConfiguration)?.Platform is MacOSXPlatform, "UNITY_MACOSX");
        Defines.Add(c => (c as DotsRuntimeCSharpProgramConfiguration)?.Platform is LinuxPlatform, "UNITY_LINUX");
        Defines.Add(c => (c as DotsRuntimeCSharpProgramConfiguration)?.Platform is IosPlatform, "UNITY_IOS");
        Defines.Add(c => (c as DotsRuntimeCSharpProgramConfiguration)?.Platform is AndroidPlatform, "UNITY_ANDROID");
        Defines.Add(c => !((DotsRuntimeCSharpProgramConfiguration)c).MultiThreadedJobs, "UNITY_SINGLETHREADED_JOBS");

        // Adds stack traces to mallocs until we get a better system for memory leaks
        //Defines.Add("UNITY_DOTSRUNTIME_TRACEMALLOCS");

        CopyReferencesNextToTarget = false;

        WarningsAsErrors = ShouldEnableWarningsAsErrors(name);

        foreach (var sourcePath in AllSourcePaths)
        {
            if (sourcePath.FileName == "Unity.Mathematics")
            {
                Sources.Add(sourcePath.Files("*.cs", true)
                            .Where(f => f.FileName != "math_unity_conversion.cs" && f.FileName != "PropertyAttributes.cs"));
            }
            else
            {
                Sources.Add(new CustomProvideFiles(sourcePath));
            }
        }
        bool hasCpp = false;

        foreach (var sourcePath in AllSourcePaths)
        {
            var cppFolder      = sourcePath.Combine("cpp~");
            var androidFolder  = sourcePath.Combine("android~");
            var prejsFolder    = sourcePath.Combine("prejs~");
            var jsFolder       = sourcePath.Combine("js~");
            var postjsFolder   = sourcePath.Combine("postjs~");
            var beeFolder      = sourcePath.Combine("bee~");
            var includeFolder  = cppFolder.Combine("include");
            var bindingsFolder = sourcePath.Combine("bindings~");

            if (cppFolder.DirectoryExists())
            {
                ProjectFile.AdditionalFiles.AddRange(cppFolder.Files(true));

                var cppFiles = cppFolder.Files("*.c*", true);
                GetOrMakeNativeProgram().Sources.Add(cppFiles);

                var mmFiles = cppFolder.Files("*.m*", true);
                GetOrMakeNativeProgram().Sources.Add(c => (c.Platform is MacOSXPlatform || c.Platform is IosPlatform), mmFiles);

                GetOrMakeNativeProgram().DynamicLinkerSettingsForAndroid().Add(c => ((DotsRuntimeNativeProgramConfiguration)c).CSharpConfig.DotsConfiguration == DotsConfiguration.Release, l => l.WithStripAll(true));

                hasCpp = true;
            }

            if (prejsFolder.DirectoryExists())
            {
                var jsFiles = prejsFolder.Files("*.js", true);
                ProjectFile.AdditionalFiles.AddRange(prejsFolder.Files(true));
                GetOrMakeNativeProgram()
                .Libraries.Add(c => c.Platform is WebGLPlatform,
                               jsFiles.Select(jsFile => new PreJsLibrary(jsFile)));
            }

            //todo: get rid of having both a regular js and a prejs folder
            if (jsFolder.DirectoryExists())
            {
                var jsFiles = jsFolder.Files("*.js", true);
                ProjectFile.AdditionalFiles.AddRange(jsFolder.Files(true));
                GetOrMakeNativeProgram()
                .Libraries.Add(c => c.Platform is WebGLPlatform,
                               jsFiles.Select(jsFile => new JavascriptLibrary(jsFile)));
            }

            if (postjsFolder.DirectoryExists())
            {
                var jsFiles = postjsFolder.Files("*.js", true);
                ProjectFile.AdditionalFiles.AddRange(postjsFolder.Files(true));
                GetOrMakeNativeProgram()
                .Libraries.Add(c => c.Platform is WebGLPlatform,
                               jsFiles.Select(jsFile => new PostJsLibrary(jsFile)));
            }

            // .jslib files in asmdef dir, like Unity
            var jslibFiles = sourcePath.Files("*.jslib", true);
            if (jslibFiles.Any())
            {
                ProjectFile.AdditionalFiles.AddRange(jslibFiles);
                GetOrMakeNativeProgram()
                .Libraries.Add(c => c.Platform is WebGLPlatform,
                               jslibFiles.Select(jsFile => new JavascriptLibrary(jsFile)));
            }

            if (beeFolder.DirectoryExists())
            {
                ProjectFile.AdditionalFiles.AddRange(beeFolder.Files("*.cs"));
            }

            if (includeFolder.DirectoryExists())
            {
                GetOrMakeNativeProgram().PublicIncludeDirectories.Add(includeFolder);
            }

            if (bindingsFolder.DirectoryExists())
            {
                NativeJobsPrebuiltLibrary.AddBindings(this, bindingsFolder);
            }

            if (androidFolder.DirectoryExists())
            {
                foreach (var extraFile in androidFolder.Files(true).Where(f => f.HasExtension("java", "kt", "aar", "jar")))
                {
                    SupportFiles.Add(c => (c as DotsRuntimeCSharpProgramConfiguration)?.Platform is AndroidPlatform, new DeployableFile(extraFile, extraFile.RelativeTo(androidFolder)));
                }
            }
        }

        if (hasCpp)
        {
            GetOrMakeNativeProgram().Libraries.Add(c => c.Platform is LinuxPlatform, new SystemLibrary("rt"));
            GetOrMakeNativeProgram().Libraries.Add(c => c.Platform is LinuxPlatform, new SystemLibrary("atomic"));
            GetOrMakeNativeProgram().Libraries.Add(c => c.Platform is WindowsPlatform, new SystemLibrary("ws2_32.lib"));
            NativeJobsPrebuiltLibrary.AddToNativeProgram(GetOrMakeNativeProgram());
        }

        SupportFiles.Add(AllSourcePaths.SelectMany(p =>
                                                   p.Files()
                                                   .Where(f => f.HasExtension("jpg", "png", "wav", "mp3", "jpeg", "mp4", "webm", "ogg", "ttf", "json"))));

        Defines.Add(c => ((DotsRuntimeCSharpProgramConfiguration)c).EnableUnityCollectionsChecks, "ENABLE_UNITY_COLLECTIONS_CHECKS");

        bool isConfigDebug(CSharpProgramConfiguration c) =>
        c.CodeGen == CSharpCodeGen.Debug || (c as DotsRuntimeCSharpProgramConfiguration)?.DotsConfiguration < DotsConfiguration.Release;

        Defines.Add(isConfigDebug, "DEBUG");

        bool isConfigDevelop(CSharpProgramConfiguration c) => (c as DotsRuntimeCSharpProgramConfiguration)?.DotsConfiguration == DotsConfiguration.Develop;

        Defines.Add(isConfigDevelop, "DEVELOP");

        Defines.Add(c => (c as DotsRuntimeCSharpProgramConfiguration)?.EnableProfiler == true, "ENABLE_PROFILER");

        // Many systems needs their own DOTS Runtime specific profiler define since they will get scanned by
        // the hybrid builds/editor, but they will use the DOTS Runtime-specific profiler API.
        Defines.Add(c => (c as DotsRuntimeCSharpProgramConfiguration)?.EnableProfiler == true, "ENABLE_DOTSRUNTIME_PROFILER");

        // Only enable player connection when we need it
        // - To support logging ("debug" builds)
        // - To support profiling
        // - To support il2cpp managed debugging (multicast)
        Defines.Add(c => isConfigDebug(c) || (c as DotsRuntimeCSharpProgramConfiguration)?.EnableProfiler == true || IsManagedDebuggingWithIL2CPPEnabled(c), "ENABLE_PLAYERCONNECTION");

        // Multicasting
        // - Is a supplement to player connection in non-webgl builds
        // - Is needed for identification in webgl builds, too, if il2cpp managed debugging is enabled
        Defines.Add(c => !((c as DotsRuntimeCSharpProgramConfiguration).Platform is WebGLPlatform) || IsManagedDebuggingWithIL2CPPEnabled(c), "ENABLE_MULTICAST");

        // Special define used mainly for debugging multithread jobs without bursting them
        Defines.Add(c => !(c as DotsRuntimeCSharpProgramConfiguration).UseBurst && (c as DotsRuntimeCSharpProgramConfiguration).MultiThreadedJobs, "UNITY_DOTSRUNTIME_MULTITHREAD_NOBURST");

        Defines.Add(c => (c as DotsRuntimeCSharpProgramConfiguration)?.ScriptingBackend == ScriptingBackend.TinyIl2cpp, "UNITY_DOTSPLAYER_IL2CPP"); // deprecated version
        Defines.Add(c => (c as DotsRuntimeCSharpProgramConfiguration)?.ScriptingBackend == ScriptingBackend.TinyIl2cpp, "UNITY_DOTSRUNTIME_IL2CPP");

        Defines.Add(c => IsManagedDebuggingWithIL2CPPEnabled(c), "UNITY_DOTSPLAYER_IL2CPP_MANAGED_DEBUGGER"); // deprecated version
        Defines.Add(c => IsManagedDebuggingWithIL2CPPEnabled(c), "UNITY_DOTSRUNTIME_IL2CPP_MANAGED_DEBUGGER");

        Defines.Add(c => IsManagedDebuggingWithIL2CPPEnabled(c) && (c as DotsRuntimeCSharpProgramConfiguration).WaitForManagedDebugger, "UNITY_DOTSPLAYER_IL2CPP_WAIT_FOR_MANAGED_DEBUGGER"); // deprecated version
        Defines.Add(c => IsManagedDebuggingWithIL2CPPEnabled(c) && (c as DotsRuntimeCSharpProgramConfiguration).WaitForManagedDebugger, "UNITY_DOTSRUNTIME_IL2CPP_WAIT_FOR_MANAGED_DEBUGGER");

        Defines.Add(c => (c as DotsRuntimeCSharpProgramConfiguration)?.ScriptingBackend == ScriptingBackend.Dotnet, "UNITY_DOTSPLAYER_DOTNET"); // deprecated version
        Defines.Add(c => (c as DotsRuntimeCSharpProgramConfiguration)?.ScriptingBackend == ScriptingBackend.Dotnet, "UNITY_DOTSRUNTIME_DOTNET");
        Defines.Add(c => (c as DotsRuntimeCSharpProgramConfiguration)?.Defines ?? new List <string>());

        ProjectFile.RedirectMSBuildBuildTargetToBee = true;
        ProjectFile.AddCustomLinkRoot(MainSourcePath, ".");
        ProjectFile.RootNameSpace = "";

        DotsRuntimeCSharpProgramCustomizer.RunAllCustomizersOn(this);
    }
 private void AddDefine(object param)
 {
     Defines.Add(DefineText);
     DefineText = string.Empty;
     UpdateCompileString();
 }
Esempio n. 27
0
 /// <summary>
 /// Adds a define item.
 /// </summary>
 /// <param name="define">to add</param>
 public void AddDefine(MatchRecognizeDefineItem define)
 {
     Defines.Add(define);
 }