コード例 #1
0
        protected bool Setup()
        {
            SkippedExecution = false;
            if (!ValidateParameters())
            {
                return(false);
            }

            if (IsPNaCl())
            {
                if (!SDKUtilities.FindPython())
                {
                    Log.LogError("PNaCl linking requires python in your executable path.");
                    return(false);
                }
            }

            if (TrackFileAccess || MinimalRebuildFromTracking)
            {
                SetTrackerLogPaths();
            }

            CalcSourcesToBuild();
            return(true);
        }
コード例 #2
0
ファイル: NaClCompile.cs プロジェクト: zhqli/nativeclient-sdk
        private int Compile(string pathToTool)
        {
            if (Platform.Equals("pnacl", StringComparison.OrdinalIgnoreCase))
            {
                if (!SDKUtilities.FindPython())
                {
                    Log.LogError("PNaCl compilation requires python in your executable path.");
                    return(-1);
                }

                // The SDK root is five levels up from the compiler binary.
                string sdkroot = Path.GetDirectoryName(Path.GetDirectoryName(pathToTool));
                sdkroot = Path.GetDirectoryName(Path.GetDirectoryName(sdkroot));

                if (!SDKUtilities.SupportsPNaCl(sdkroot))
                {
                    int revision;
                    int version = SDKUtilities.GetSDKVersion(sdkroot, out revision);
                    Log.LogError("The configured version of the NaCl SDK ({0} r{1}) is too old " +
                                 "for building PNaCl projects.\n" +
                                 "Please install at least 24 r{2} using the naclsdk command " +
                                 "line tool.", version, revision, SDKUtilities.MinPNaCLSDKVersion,
                                 SDKUtilities.MinPNaCLSDKRevision);
                    return(-1);
                }
            }

            // If multiprocess compilation is enabled (not the VS default)
            // and the number of processors to use is not 1, then use the
            // compiler_wrapper python script to run multiple instances of
            // gcc
            if (MultiProcessorCompilation && ProcessorNumber != 1)
            {
                if (!SDKUtilities.FindPython())
                {
                    Log.LogWarning("Multi-processor Compilation with NaCl requires that python " +
                                   "be available in the visual studio executable path.\n" +
                                   "Please disable Multi-processor Compilation in the project " +
                                   "properties or add python to the your executable path.\n" +
                                   "Falling back to serial compilation.\n");
                }
                else
                {
                    return(CompileParallel(pathToTool));
                }
            }
            return(CompileSerial(pathToTool));
        }
コード例 #3
0
        protected bool PostLink()
        {
            if (IsPNaCl())
            {
                if (!Finalize())
                {
                    return(false);
                }

                if (TranslateX64 && !Translate("64", "x86-64"))
                {
                    return(false);
                }

                if (TranslateX86 && !Translate("32", "i686"))
                {
                    return(false);
                }

                if (TranslateARM && !Translate("arm"))
                {
                    return(false);
                }
            }

            if (CreateNMF)
            {
                if (!SDKUtilities.FindPython())
                {
                    Log.LogError("Automatic NMF creation requires python in your executable path.");
                    return(false);
                }

                string outputRoot = ToolchainName;
                if (IsPNaCl())
                {
                    outputRoot = "PNaCl";
                }

                if (!Directory.Exists(outputRoot))
                {
                    Directory.CreateDirectory(outputRoot);
                }

                string nmfPath = Path.Combine(outputRoot, Path.ChangeExtension(ProjectName, ".nmf"));

                string cmd = "\"" + CreateNMFPath + "\" -o \"" + nmfPath + "\"";

                // The SDK root is one level up from create_nmf.py
                // Starting with 25.170267 the -t options to create_nmf is deprecated.
                string sdkroot = Path.GetDirectoryName(Path.GetDirectoryName(CreateNMFPath));
                if (!SDKUtilities.CheckVersionAtLeast(sdkroot, 25, 170267))
                {
                    cmd += " -t " + ToolchainName;
                }

                cmd += " -s " + ToolchainName;

                if (IsPNaCl())
                {
                    if (!TranslateARM && !TranslateX64 && !TranslateX86)
                    {
                        // Don't run create_nmf unless we actaully produced a nexe file.
                        return(true);
                    }

                    foreach (var arch in new string [] { "arm", "32", "64" })
                    {
                        string nexe = PexeToNexe(OutputFile, arch);
                        if (File.Exists(nexe))
                        {
                            cmd += " \"" + nexe + "\"";
                        }
                    }
                }
                else
                {
                    cmd += " \"" + OutputFile + "\"";
                }

                if (!OutputCommandLine)
                {
                    Log.LogMessage("CreateNMF -> {0}", Path.GetFileName(nmfPath));
                }

                if (ExecuteTool("python", string.Empty, cmd) != 0)
                {
                    return(false);
                }
            }

            return(true);
        }