Esempio n. 1
0
        public LuminToolChain(FileReference InProjectFile, bool bInUseLdGold = true, IReadOnlyList <string> InAdditionalArches = null, IReadOnlyList <string> InAdditionalGPUArches = null, bool bAllowMissingNDK = true)
            : base(CppPlatform.Lumin, InProjectFile,
                   // @todo Lumin: ld gold?
                   true, null, null, true)

        {
            AdditionalGPUArches = new List <string>();
            if (InAdditionalGPUArches != null)
            {
                AdditionalGPUArches.AddRange(InAdditionalGPUArches);
            }


            // by default tools chains don't parse arguments, but we want to be able to check the -gpuarchitectures flag defined above. This is
            // only necessary when LuminToolChain is used during UAT
            CommandLine.ParseArguments(Environment.GetCommandLineArgs(), this);
            if (AdditionalGPUArches.Count == 0 && GPUArchitectureArg.Count > 0)
            {
                AdditionalGPUArches.AddRange(GPUArchitectureArg);
            }

            string MLSDKPath = Environment.GetEnvironmentVariable("MLSDK");

            // don't register if we don't have an MLSDK specified
            if (String.IsNullOrEmpty(MLSDKPath))
            {
                throw new BuildException("MLSDK is not specified; cannot use Lumin toolchain.");
            }

            MLSDKPath = MLSDKPath.Replace("\"", "");

            string MabuSpec = RunMabuAndReadOutput("-t device --print-spec");

            // parse clange version
            Regex SpecRegex = new Regex("\\s*(?:[a-z]+_lumin_clang-)(\\d)[.](\\d)\\s*");

            Match SpecMatch = SpecRegex.Match(MabuSpec);

            if (SpecMatch.Groups.Count != 3)
            {
                throw new BuildException("Could not parse clang version from mabu spec '{0}'", MabuSpec);
            }

            string ClangVersion = string.Format("{0}.{1}", SpecMatch.Groups[1].Value, SpecMatch.Groups[2].Value);

            SetClangVersion(int.Parse(SpecMatch.Groups[1].Value), int.Parse(SpecMatch.Groups[2].Value), 0);

            string MabuTools = RunMabuAndReadOutput("-t device --print-tools");

            Dictionary <string, string> ToolsDict = new Dictionary <string, string>();

            using (StringReader Reader = new StringReader(MabuTools))
            {
                string Line = null;
                while (null != (Line = Reader.ReadLine()))
                {
                    string[] Split = Line.Split('=');
                    if (Split.Length != 2)
                    {
                        throw new BuildException("Unexpected output from mabu in --print-tools: '{0}'", Line);
                    }

                    ToolsDict.Add(Split[0].Trim(), Split[1].Trim());
                }
            }

            // set up the path to our toolchains
            ClangPath   = ToolsDict["CXX"];
            ArPathArm64 = ToolsDict["AR"];
            StripPath   = ToolsDict["STRIP"];
            ObjCopyPath = ToolsDict["OBJCOPY"];

            // force the compiler to be executed through a command prompt instance
            bExecuteCompilerThroughShell = true;

            // toolchain params
            ToolchainParamsArm64 = " --sysroot=\"" + Path.Combine(MLSDKPath, "lumin") + "\"";

            ToolchainLinkParamsArm   = ToolchainParamsArm;
            ToolchainLinkParamsArm64 = ToolchainParamsArm64;
            ToolchainLinkParamsx86   = ToolchainParamsx86;
            ToolchainLinkParamsx64   = ToolchainParamsx64;
        }