示例#1
0
 /// <summary>
 /// Setup the configuration environment for building
 /// </summary>
 /// <param name="Target"> The target being built</param>
 /// <param name="GlobalCompileEnvironment">The global compile environment</param>
 /// <param name="GlobalLinkEnvironment">The global link environment</param>
 public override void SetUpConfigurationEnvironment(ReadOnlyTargetRules Target, CppCompileEnvironment GlobalCompileEnvironment, LinkEnvironment GlobalLinkEnvironment)
 {
     base.SetUpConfigurationEnvironment(Target, GlobalCompileEnvironment, GlobalLinkEnvironment);
     GlobalLinkEnvironment.bCreateDebugInfo = Target.Configuration != UnrealTargetConfiguration.Shipping;
 }
示例#2
0
    /// <summary>
    /// Setup the target environment for building
    /// </summary>
    /// <param name="Target">Settings for the target being compiled</param>
    /// <param name="CompileEnvironment">The compile environment for this target</param>
    /// <param name="LinkEnvironment">The link environment for this target</param>
    public override void SetUpEnvironment(ReadOnlyTargetRules Target, CppCompileEnvironment CompileEnvironment, LinkEnvironment LinkEnvironment)
    {
        // read a setting from the read only target rules, specific to XXX
        CompileEnvironment.Definitions.Add(string.Format("SOMESETTING={0}", Target.XXXPlatform.bSomeSetting));

        CompileEnvironment.Definitions.Add("PLATFORM_DESKTOP=0");
        CompileEnvironment.Definitions.Add("PLATFORM_64BITS=1");
        CompileEnvironment.Definitions.Add("EXCEPTIONS_DISABLED=0");
        CompileEnvironment.Definitions.Add("UNICODE");
        CompileEnvironment.Definitions.Add("_UNICODE");
    }
        static string GetLinkArguments(LinkEnvironment LinkEnvironment)
        {
            string Result = "";

            // debugging symbols
            if (LinkEnvironment.Config.TargetConfiguration < CPPTargetConfiguration.Shipping)
            {
                Result += " -rdynamic";
            }
            else
            {
                Result += " -Wl,-s"; // Strip binaries in Shipping
            }

            if (LinkEnvironment.Config.bIsBuildingDLL)
            {
                Result += " -shared";
            }
            Result += " -v";

            // ignore unresolved symbols in shared libs (handy sometimes)
            //Result += " -Wl,--unresolved-symbols=ignore-in-shared-libs";

            Result += " -target x86_64-unknown-linux-gnu";        // Set target triple
            Result += String.Format(" --sysroot={0}", BaseLinuxPath);

            return Result;
        }
 static string GetArchiveArguments(LinkEnvironment LinkEnvironment)
 {
     return " rc";
 }
        public override FileItem LinkFiles(LinkEnvironment LinkEnvironment, bool bBuildImportLibraryOnly)
        {
            if (LinkEnvironment.Config.bIsBuildingLibrary || bBuildImportLibraryOnly)
            {
                return CreateArchiveAndIndex(LinkEnvironment);
            }

            // Create an action that invokes the linker.
            Action LinkAction = new Action(ActionType.Link);
            LinkAction.WorkingDirectory = Path.GetFullPath(".");
            LinkAction.CommandPath = ClangPath;

            // Get link arguments.
            LinkAction.CommandArguments = GetLinkArguments(LinkEnvironment);

            // Tell the action that we're building an import library here and it should conditionally be
            // ignored as a prerequisite for other actions
            LinkAction.bProducesImportLibrary = LinkEnvironment.Config.bIsBuildingDLL;

            // Add the output file as a production of the link action.
            FileItem OutputFile = FileItem.GetItemByPath(LinkEnvironment.Config.OutputFilePath);
            LinkAction.ProducedItems.Add(OutputFile);
            LinkAction.StatusDescription = string.Format("{0}", Path.GetFileName(OutputFile.AbsolutePath));

            // Add the output file to the command-line.
            LinkAction.CommandArguments += string.Format(" -o \"{0}\"", OutputFile.AbsolutePath);

            // Add the input files to a response file, and pass the response file on the command-line.
            List<string> InputFileNames = new List<string>();
            foreach (FileItem InputFile in LinkEnvironment.InputFiles)
            {
                InputFileNames.Add(string.Format("\"{0}\"", InputFile.AbsolutePath.Replace("\\", "/")));
                LinkAction.PrerequisiteItems.Add(InputFile);
            }

            string ResponseFileName = GetResponseFileName(LinkEnvironment, OutputFile);
            LinkAction.CommandArguments += string.Format(" -Wl,@\"{0}\"", ResponseFile.Create(ResponseFileName, InputFileNames));

            // Add the library paths to the argument list.
            foreach (string LibraryPath in LinkEnvironment.Config.LibraryPaths)
            {
                LinkAction.CommandArguments += string.Format(" -L\"{0}\"", LibraryPath);
            }

            // add libraries in a library group
            LinkAction.CommandArguments += string.Format(" -Wl,--start-group");
            foreach (string AdditionalLibrary in LinkEnvironment.Config.AdditionalLibraries)
            {
                if (String.IsNullOrEmpty(Path.GetDirectoryName(AdditionalLibrary)))
                {
                    LinkAction.CommandArguments += string.Format(" \"-l{0}\"", AdditionalLibrary);
                }
                else
                {
                    // full pathed libs are compiled by us, so we depend on linking them
                    LinkAction.CommandArguments += string.Format(" \"{0}\"", AdditionalLibrary);
                    LinkAction.PrerequisiteItems.Add(FileItem.GetItemByFullPath(AdditionalLibrary));
                }
            }
            LinkAction.CommandArguments += " -lrt"; // needed for clock_gettime()
            LinkAction.CommandArguments += string.Format(" -Wl,--end-group");

            // Add the additional arguments specified by the environment.
            LinkAction.CommandArguments += LinkEnvironment.Config.AdditionalArguments;
            LinkAction.CommandArguments.Replace("\\", "/");

            // Only execute linking on the local PC.
            LinkAction.bCanExecuteRemotely = false;

            return OutputFile;
        }
        /** Creates an action to archive all the .o files into single .a file */
        public FileItem CreateArchiveAndIndex(LinkEnvironment LinkEnvironment)
        {
            // Create an archive action
            Action ArchiveAction = new Action(ActionType.Link);
            ArchiveAction.WorkingDirectory = Path.GetFullPath(".");
            ArchiveAction.CommandPath = "cmd.exe";
            ArchiveAction.CommandArguments = "/c ";

            // this will produce a final library
            ArchiveAction.bProducesImportLibrary = true;

            // Add the output file as a production of the link action.
            FileItem OutputFile = FileItem.GetItemByPath(LinkEnvironment.Config.OutputFilePath);
            ArchiveAction.ProducedItems.Add(OutputFile);
            ArchiveAction.StatusDescription = string.Format("{0}", Path.GetFileName(OutputFile.AbsolutePath));
            ArchiveAction.CommandArguments += string.Format("{0} {1} \"{2}\"",  ArPath, GetArchiveArguments(LinkEnvironment), OutputFile.AbsolutePath);

            // Add the input files to a response file, and pass the response file on the command-line.
            List<string> InputFileNames = new List<string>();
            foreach (FileItem InputFile in LinkEnvironment.InputFiles)
            {
                string InputAbsolutePath = InputFile.AbsolutePath.Replace("\\", "/");
                InputFileNames.Add(string.Format("\"{0}\"", InputAbsolutePath));
                ArchiveAction.PrerequisiteItems.Add(InputFile);
                ArchiveAction.CommandArguments += string.Format(" \"{0}\"", InputAbsolutePath);
            }

            // add ranlib
            ArchiveAction.CommandArguments += string.Format(" && {0} \"{1}\"", RanlibPath, OutputFile.AbsolutePath);

            // Add the additional arguments specified by the environment.
            ArchiveAction.CommandArguments += LinkEnvironment.Config.AdditionalArguments;
            ArchiveAction.CommandArguments.Replace("\\", "/");

            // Only execute linking on the local PC.
            ArchiveAction.bCanExecuteRemotely = false;

            return OutputFile;
        }