Exemple #1
0
        // cache the location of SDK tools
        public override void RegisterToolChain()
        {
            if (HTML5SDKInfo.IsSDKInstalled() && HTML5SDKInfo.IsPythonInstalled())
            {
                EMCCPath   = "\"" + HTML5SDKInfo.EmscriptenCompiler() + "\"";
                PythonPath = HTML5SDKInfo.PythonPath();

                // set some environment variable we'll need
                //Environment.SetEnvironmentVariable("EMCC_DEBUG", "cache");
                Environment.SetEnvironmentVariable("EMCC_CORES", "8");
                Environment.SetEnvironmentVariable("EMCC_FORCE_STDLIBS", "1");
                Environment.SetEnvironmentVariable("EMCC_OPTIMIZE_NORMALLY", "1");
                // finally register the toolchain that is now ready to go
                Log.TraceVerbose("        Registered for {0}", CPPTargetPlatform.HTML5.ToString());
                UEToolChain.RegisterPlatformToolChain(CPPTargetPlatform.HTML5, this);
            }
        }
        public override FileItem LinkFiles(LinkEnvironment LinkEnvironment, bool bBuildImportLibraryOnly, ActionGraph ActionGraph)
        {
            FileItem OutputFile;

            // Make the final javascript file
            Action LinkAction = ActionGraph.Add(ActionType.Link);

            LinkAction.CommandDescription = "Link";
//			LinkAction.bPrintDebugInfo = true;

            // ResponseFile lines.
            List <string> ReponseLines = new List <string>();

            LinkAction.bCanExecuteRemotely = false;
            LinkAction.WorkingDirectory    = UnrealBuildTool.EngineSourceDirectory.FullName;
            LinkAction.CommandPath         = HTML5SDKInfo.Python();
            LinkAction.CommandArguments    = HTML5SDKInfo.EmscriptenCompiler();
//			bool bIsBuildingLibrary = LinkEnvironment.bIsBuildingLibrary || bBuildImportLibraryOnly;
//			ReponseLines.Add(
//					bIsBuildingLibrary ?
//					GetLibArguments(LinkEnvironment) :
//					GetLinkArguments(LinkEnvironment)
//				);
            ReponseLines.Add(GetLinkArguments(LinkEnvironment));

            // Add the input files to a response file, and pass the response file on the command-line.
            foreach (FileItem InputFile in LinkEnvironment.InputFiles)
            {
                //System.Console.WriteLine("File  {0} ", InputFile.AbsolutePath);
                ReponseLines.Add(string.Format(" \"{0}\"", InputFile.AbsolutePath));
                LinkAction.PrerequisiteItems.Add(InputFile);
            }

            if (!LinkEnvironment.bIsBuildingLibrary)
            {
                // Make sure ThirdParty libs are at the end.
                List <string> ThirdParty = (from Lib in LinkEnvironment.AdditionalLibraries
                                            where Lib.Contains("ThirdParty")
                                            select Lib).ToList();

                LinkEnvironment.AdditionalLibraries.RemoveAll(Element => Element.Contains("ThirdParty"));
                LinkEnvironment.AdditionalLibraries.AddRange(ThirdParty);

                foreach (string InputFile in LinkEnvironment.AdditionalLibraries)
                {
                    FileItem Item = FileItem.GetItemByPath(InputFile);

                    if (Item.AbsolutePath.Contains(".lib"))
                    {
                        continue;
                    }

                    if (Item.ToString().EndsWith(".js"))
                    {
                        ReponseLines.Add(string.Format(" --js-library \"{0}\"", Item.AbsolutePath));
                    }


                    // WARNING: With --pre-js and --post-js, the order in which these directives are passed to
                    // the compiler is very critical, because that dictates the order in which they are appended.
                    //
                    // Set environment variable [ EMCC_DEBUG=1 ] to see the linker order used in packaging.
                    //     See GetSharedArguments_Global() above to set this environment variable

                    else if (Item.ToString().EndsWith(".jspre"))
                    {
                        ReponseLines.Add(string.Format(" --pre-js \"{0}\"", Item.AbsolutePath));
                    }

                    else if (Item.ToString().EndsWith(".jspost"))
                    {
                        ReponseLines.Add(string.Format(" --post-js \"{0}\"", Item.AbsolutePath));
                    }


                    else
                    {
                        ReponseLines.Add(string.Format(" \"{0}\"", Item.AbsolutePath));
                    }

                    LinkAction.PrerequisiteItems.Add(Item);
                }
            }
            // make the file we will create


            OutputFile = FileItem.GetItemByFileReference(LinkEnvironment.OutputFilePath);
            LinkAction.ProducedItems.Add(OutputFile);
            ReponseLines.Add(string.Format(" -o \"{0}\"", OutputFile.AbsolutePath));

            FileItem OutputBC = FileItem.GetItemByPath(LinkEnvironment.OutputFilePath.FullName.Replace(".js", ".bc").Replace(".html", ".bc"));

            LinkAction.ProducedItems.Add(OutputBC);
            ReponseLines.Add(string.Format(" --save-bc \"{0}\"", OutputBC.AbsolutePath));

            LinkAction.StatusDescription = Path.GetFileName(OutputFile.AbsolutePath);

            FileReference ResponseFileName = GetResponseFileName(LinkEnvironment, OutputFile);

            FileItem ResponseFileItem = FileItem.CreateIntermediateTextFile(ResponseFileName, ReponseLines);

            LinkAction.CommandArguments += string.Format(" @\"{0}\"", ResponseFileName);
            LinkAction.PrerequisiteItems.Add(ResponseFileItem);

            return(OutputFile);
        }
        public override CPPOutput CompileCPPFiles(CppCompileEnvironment CompileEnvironment, List <FileItem> InputFiles, DirectoryReference OutputDir, string ModuleName, ActionGraph ActionGraph)
        {
            string Arguments = GetCLArguments_Global(CompileEnvironment);

            CPPOutput Result = new CPPOutput();

            // Add include paths to the argument list.
            foreach (DirectoryReference IncludePath in CompileEnvironment.IncludePaths.UserIncludePaths)
            {
                AddIncludePath(ref Arguments, IncludePath);
            }
            foreach (DirectoryReference IncludePath in CompileEnvironment.IncludePaths.SystemIncludePaths)
            {
                AddIncludePath(ref Arguments, IncludePath);
            }


            // Add preprocessor definitions to the argument list.
            foreach (string Definition in CompileEnvironment.Definitions)
            {
                Arguments += string.Format(" -D{0}", Definition);
            }

            if (bEnableTracing)
            {
                Arguments += string.Format(" -D__EMSCRIPTEN_TRACING__");
            }

            // Force include all the requested headers
            foreach (FileItem ForceIncludeFile in CompileEnvironment.ForceIncludeFiles)
            {
                Arguments += String.Format(" -include \"{0}\"", ForceIncludeFile.Location);
            }

            foreach (FileItem SourceFile in InputFiles)
            {
                Action CompileAction = ActionGraph.Add(ActionType.Compile);
                CompileAction.CommandDescription = "Compile";
                CompileAction.PrerequisiteItems.AddRange(CompileEnvironment.ForceIncludeFiles);
//				CompileAction.bPrintDebugInfo = true;

                bool bIsPlainCFile = Path.GetExtension(SourceFile.AbsolutePath).ToUpperInvariant() == ".C";

                // Add the C++ source file and its included files to the prerequisite item list.
                AddPrerequisiteSourceFile(CompileEnvironment, SourceFile, CompileAction.PrerequisiteItems);

                // Add the source file path to the command-line.
                string FileArguments       = string.Format(" \"{0}\"", SourceFile.AbsolutePath);
                string ObjectFileExtension = UEBuildPlatform.GetBuildPlatform(UnrealTargetPlatform.HTML5).GetBinaryExtension(UEBuildBinaryType.Object);
                // Add the object file to the produced item list.
                FileItem ObjectFile = FileItem.GetItemByFileReference(
                    FileReference.Combine(
                        OutputDir,
                        Path.GetFileName(SourceFile.AbsolutePath) + ObjectFileExtension
                        )
                    );
                CompileAction.ProducedItems.Add(ObjectFile);
                FileArguments += string.Format(" -o \"{0}\"", ObjectFile.AbsolutePath);

                // Add C or C++ specific compiler arguments.
                if (bIsPlainCFile)
                {
                    FileArguments += GetCLArguments_C(CompileEnvironment.Architecture);
                }
                else
                {
                    FileArguments += GetCLArguments_CPP(CompileEnvironment);
                }

                CompileAction.WorkingDirectory = UnrealBuildTool.EngineSourceDirectory.FullName;
                CompileAction.CommandPath      = HTML5SDKInfo.Python();

                CompileAction.CommandArguments = HTML5SDKInfo.EmscriptenCompiler() + " " + Arguments + FileArguments + CompileEnvironment.AdditionalArguments;

                //System.Console.WriteLine(CompileAction.CommandArguments);
                CompileAction.StatusDescription = Path.GetFileName(SourceFile.AbsolutePath);

                // Don't farm out creation of precomputed headers as it is the critical path task.
                CompileAction.bCanExecuteRemotely = CompileEnvironment.PrecompiledHeaderAction != PrecompiledHeaderAction.Create;

                // this is the final output of the compile step (a .abc file)
                Result.ObjectFiles.Add(ObjectFile);

                // VC++ always outputs the source file name being compiled, so we don't need to emit this ourselves
                CompileAction.bShouldOutputStatusDescription = true;

                // Don't farm out creation of precompiled headers as it is the critical path task.
                CompileAction.bCanExecuteRemotely =
                    CompileEnvironment.PrecompiledHeaderAction != PrecompiledHeaderAction.Create ||
                    CompileEnvironment.bAllowRemotelyCompiledPCHs;
            }

            return(Result);
        }
Exemple #4
0
        public override FileItem LinkFiles(LinkEnvironment LinkEnvironment, bool bBuildImportLibraryOnly)
        {
            if (LinkEnvironment.Config.Target.Architecture == "-win32")             // simulator
            {
                return(base.LinkFiles(LinkEnvironment, bBuildImportLibraryOnly));
            }

            FileItem OutputFile;

            // Make the final javascript file
            Action LinkAction = new Action(ActionType.Link);

            // ResponseFile lines.
            List <string> ReponseLines = new List <string>();

            LinkAction.bCanExecuteRemotely = false;
            LinkAction.WorkingDirectory    = UnrealBuildTool.EngineSourceDirectory.FullName;
            LinkAction.CommandPath         = HTML5SDKInfo.Python();
            LinkAction.CommandArguments    = HTML5SDKInfo.EmscriptenCompiler();
            ReponseLines.Add(GetLinkArguments(LinkEnvironment));

            // Add the input files to a response file, and pass the response file on the command-line.
            foreach (FileItem InputFile in LinkEnvironment.InputFiles)
            {
                //System.Console.WriteLine("File  {0} ", InputFile.AbsolutePath);
                ReponseLines.Add(string.Format(" \"{0}\"", InputFile.AbsolutePath));
                LinkAction.PrerequisiteItems.Add(InputFile);
            }

            if (!LinkEnvironment.Config.bIsBuildingLibrary)
            {
                // Make sure ThirdParty libs are at the end.
                List <string> ThirdParty = (from Lib in LinkEnvironment.Config.AdditionalLibraries
                                            where Lib.Contains("ThirdParty")
                                            select Lib).ToList();

                LinkEnvironment.Config.AdditionalLibraries.RemoveAll(Element => Element.Contains("ThirdParty"));
                LinkEnvironment.Config.AdditionalLibraries.AddRange(ThirdParty);

                foreach (string InputFile in LinkEnvironment.Config.AdditionalLibraries)
                {
                    FileItem Item = FileItem.GetItemByPath(InputFile);

                    if (Item.AbsolutePath.Contains(".lib"))
                    {
                        continue;
                    }

                    if (Item != null)
                    {
                        if (Item.ToString().Contains(".js"))
                        {
                            ReponseLines.Add(string.Format(" --js-library \"{0}\"", Item.AbsolutePath));
                        }
                        else
                        {
                            ReponseLines.Add(string.Format(" \"{0}\"", Item.AbsolutePath));
                        }
                        LinkAction.PrerequisiteItems.Add(Item);
                    }
                }
            }
            // make the file we will create


            OutputFile = FileItem.GetItemByFileReference(LinkEnvironment.Config.OutputFilePath);
            LinkAction.ProducedItems.Add(OutputFile);
            ReponseLines.Add(string.Format(" -o \"{0}\"", OutputFile.AbsolutePath));

            FileItem OutputBC = FileItem.GetItemByPath(LinkEnvironment.Config.OutputFilePath.FullName.Replace(".js", ".bc").Replace(".html", ".bc"));

            LinkAction.ProducedItems.Add(OutputBC);
            ReponseLines.Add(" --emit-symbol-map " + string.Format(" --save-bc \"{0}\"", OutputBC.AbsolutePath));

            LinkAction.StatusDescription = Path.GetFileName(OutputFile.AbsolutePath);

            FileReference ResponseFileName = GetResponseFileName(LinkEnvironment, OutputFile);


            LinkAction.CommandArguments += string.Format(" @\"{0}\"", ResponseFile.Create(ResponseFileName, ReponseLines));

            LinkAction.OutputEventHandler = new DataReceivedEventHandler(RemoteOutputReceivedEventHandler);

            return(OutputFile);
        }
Exemple #5
0
        public override CPPOutput CompileCPPFiles(UEBuildTarget Target, CPPEnvironment CompileEnvironment, List <FileItem> SourceFiles, string ModuleName)
        {
            if (CompileEnvironment.Config.Target.Architecture == "-win32")             // simulator
            {
                return(base.CompileCPPFiles(Target, CompileEnvironment, SourceFiles, ModuleName));
            }

            string Arguments = GetCLArguments_Global(CompileEnvironment);

            CPPOutput Result = new CPPOutput();

            // Add include paths to the argument list.
            foreach (string IncludePath in CompileEnvironment.Config.CPPIncludeInfo.IncludePaths)
            {
                Arguments += string.Format(" -I\"{0}\"", IncludePath);
            }
            foreach (string IncludePath in CompileEnvironment.Config.CPPIncludeInfo.SystemIncludePaths)
            {
                Arguments += string.Format(" -I\"{0}\"", IncludePath);
            }


            // Add preprocessor definitions to the argument list.
            foreach (string Definition in CompileEnvironment.Config.Definitions)
            {
                Arguments += string.Format(" -D{0}", Definition);
            }

            if (bEnableTracing)
            {
                Arguments += string.Format(" -D__EMSCRIPTEN_TRACING__");
            }

            var BuildPlatform = UEBuildPlatform.GetBuildPlatformForCPPTargetPlatform(CompileEnvironment.Config.Target.Platform);

            foreach (FileItem SourceFile in SourceFiles)
            {
                Action CompileAction = new Action(ActionType.Compile);
                bool   bIsPlainCFile = Path.GetExtension(SourceFile.AbsolutePath).ToUpperInvariant() == ".C";

                // Add the C++ source file and its included files to the prerequisite item list.
                AddPrerequisiteSourceFile(Target, BuildPlatform, CompileEnvironment, SourceFile, CompileAction.PrerequisiteItems);

                // Add the source file path to the command-line.
                string FileArguments       = string.Format(" \"{0}\"", SourceFile.AbsolutePath);
                var    ObjectFileExtension = UEBuildPlatform.GetBuildPlatform(UnrealTargetPlatform.HTML5).GetBinaryExtension(UEBuildBinaryType.Object);
                // Add the object file to the produced item list.
                FileItem ObjectFile = FileItem.GetItemByFileReference(
                    FileReference.Combine(
                        CompileEnvironment.Config.OutputDirectory,
                        Path.GetFileName(SourceFile.AbsolutePath) + ObjectFileExtension
                        )
                    );
                CompileAction.ProducedItems.Add(ObjectFile);
                FileArguments += string.Format(" -o \"{0}\"", ObjectFile.AbsolutePath);

                // Add C or C++ specific compiler arguments.
                if (bIsPlainCFile)
                {
                    FileArguments += GetCLArguments_C(CompileEnvironment.Config.Target.Architecture);
                }
                else
                {
                    FileArguments += GetCLArguments_CPP(CompileEnvironment);
                }

                CompileAction.WorkingDirectory = UnrealBuildTool.EngineSourceDirectory.FullName;
                CompileAction.CommandPath      = HTML5SDKInfo.Python();

                CompileAction.CommandArguments = HTML5SDKInfo.EmscriptenCompiler() + " " + Arguments + FileArguments + CompileEnvironment.Config.AdditionalArguments;

                //System.Console.WriteLine(CompileAction.CommandArguments);
                CompileAction.StatusDescription  = Path.GetFileName(SourceFile.AbsolutePath);
                CompileAction.OutputEventHandler = new DataReceivedEventHandler(CompileOutputReceivedDataEventHandler);

                // Don't farm out creation of precomputed headers as it is the critical path task.
                CompileAction.bCanExecuteRemotely = CompileEnvironment.Config.PrecompiledHeaderAction != PrecompiledHeaderAction.Create;

                // this is the final output of the compile step (a .abc file)
                Result.ObjectFiles.Add(ObjectFile);

                // VC++ always outputs the source file name being compiled, so we don't need to emit this ourselves
                CompileAction.bShouldOutputStatusDescription = true;

                // Don't farm out creation of precompiled headers as it is the critical path task.
                CompileAction.bCanExecuteRemotely =
                    CompileEnvironment.Config.PrecompiledHeaderAction != PrecompiledHeaderAction.Create ||
                    BuildConfiguration.bAllowRemotelyCompiledPCHs;
            }

            return(Result);
        }