Ejemplo n.º 1
0
        public void BreakawayProcessIsHonored()
        {
            var project            = CreateRushProject();
            var breakawayTest      = PathAtom.Create(StringTable, "test.exe");
            var breakawayProcesses = Start(new RushResolverSettings {
                ChildProcessesToBreakawayFromSandbox = new[] { breakawayTest }
            })
                                     .Add(project)
                                     .ScheduleAll()
                                     .RetrieveSuccessfulProcess(project)
                                     .ChildProcessesToBreakawayFromSandbox;

            XAssert.Contains(breakawayProcesses, breakawayTest);
        }
Ejemplo n.º 2
0
        public static void Configure(ConfigurationImpl config, IStartupConfiguration startupConfig, PathTable pathTable)
        {
            Contract.Requires(startupConfig.ConfigFile.IsValid);

            // Ide generation implies a schedule phase.
            config.Engine.Phase = EnginePhases.Schedule;

            var enlistmentRoot = startupConfig.ConfigFile.GetParent(pathTable);

            Contract.Assume(enlistmentRoot.IsValid);

            // Populate the missing values of the Ide configuration
            var ideConfiguration = config.Ide;

            // Deciding the solution name:
            // If the user passes a custom name for solution, use it.
            // Otherwise if the spec filtering is used, use the directory name of the spec.
            // Otherwise, use the directory name of the config file as the solution name.
            if (!ideConfiguration.SolutionName.IsValid)
            {
                // Translate enlistmentRoot because we need to get the name of the repository, which is not possible when using mapped path (e.g., b:\)
                var            unmappedEnlistmentRoot = enlistmentRoot;
                PathTranslator translator;
                if (PathTranslator.CreateIfEnabled(config.Logging.SubstTarget, config.Logging.SubstSource, pathTable, out translator))
                {
                    unmappedEnlistmentRoot = translator.Translate(pathTable, enlistmentRoot);
                }

                // It's possible for the path to be at the root of the drive and not be able to be translated back when
                // the PathTranslator isn't enabled. In that case, fall back on some default solution name.
                string solutionNameCandidate = unmappedEnlistmentRoot.GetName(pathTable).ToString(pathTable.StringTable);
                if (string.IsNullOrWhiteSpace(solutionNameCandidate))
                {
                    solutionNameCandidate = "ideGenerated";
                }

                // If a new solution generator is used, change the solution name so users can distinguish between the old and new one.
                if (ideConfiguration.IsNewEnabled)
                {
                    solutionNameCandidate += "New";
                }

                ideConfiguration.SolutionName = PathAtom.Create(pathTable.StringTable, solutionNameCandidate);
            }

            if (!ideConfiguration.SolutionRoot.IsValid)
            {
                ideConfiguration.SolutionRoot = config.Layout.OutputDirectory.Combine(pathTable, "VS");
            }
        }
Ejemplo n.º 3
0
        public Context(
            PipExecutionContext pipContext,
            PipGraph pipGraph,
            IReadonlyDirectedGraph scheduledGraph,
            AbsolutePath configFilePath,
            IIdeConfiguration ideConfig)
        {
            Contract.Requires(pipGraph != null);
            Contract.Requires(scheduledGraph != null);
            Contract.Requires(configFilePath.IsValid);
            Contract.Requires(ideConfig.SolutionRoot.IsValid);
            Contract.Requires(ideConfig.SolutionName.IsValid);
            Contract.Requires(ideConfig.IsEnabled);
            Contract.Requires(!ideConfig.IsNewEnabled);

            PipGraph       = pipGraph;
            ScheduledGraph = scheduledGraph;
            StringTable    = pipContext.StringTable;
            PathTable      = pipContext.PathTable;
            SymbolTable    = pipContext.SymbolTable;
            QualifierTable = pipContext.QualifierTable;

            DotSettingsPathStr = ideConfig.DotSettingsFile.IsValid ? ideConfig.DotSettingsFile.ToString(PathTable) : null;
            ConfigFilePathStr  = configFilePath.ToString(PathTable);

            EnlistmentRoot    = configFilePath.GetParent(PathTable);
            EnlistmentRootStr = EnlistmentRoot.ToString(PathTable);

            SolutionRoot    = ideConfig.SolutionRoot;
            SolutionRootStr = SolutionRoot.ToString(PathTable);

            SolutionFilePathStr = IdeGenerator.GetSolutionPath(ideConfig, PathTable).ToString(PathTable);

            CanWriteToSrc = ideConfig.CanWriteToSrc ?? false;
            ProjectsRoot  = CanWriteToSrc
                    ? EnlistmentRoot
                    : SolutionRoot.Combine(PathTable, PathAtom.Create(PathTable.StringTable, "Projects"));

            ResxExtensionName      = PathAtom.Create(StringTable, ".resx");
            CscExeName             = PathAtom.Create(StringTable, "csc.exe");
            ResgenExeName          = PathAtom.Create(StringTable, "ResGen.exe");
            ResourcesExtensionName = PathAtom.Create(StringTable, ".resources");
            CsExtensionName        = PathAtom.Create(StringTable, ".cs");
            DllExtensionName       = PathAtom.Create(StringTable, ".dll");
            ClExeName             = PathAtom.Create(StringTable, "cl.exe");
            LinkExeName           = PathAtom.Create(StringTable, "Link.exe");
            VsTestExeName         = PathAtom.Create(StringTable, "vstest.console.exe");
            AssemblyDeploymentTag = StringId.Create(StringTable, "assemblyDeployment");
            TestDeploymentTag     = StringId.Create(StringTable, "testDeployment");
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Returns a unique redirected directory (located under the process unique redirected directory root) that is stable across builds
        /// </summary>
        private AbsolutePath GetUniqueRedirectedDirectory(Process process, ref ReserveFoldersResolver reserveFoldersResolver, AbsolutePath originalDirectory)
        {
            var name        = originalDirectory.GetName(m_pathTable);
            var count       = reserveFoldersResolver.GetNextId(name);
            var stringTable = m_pathTable.StringTable;

            var pathAtom = count == 0
                ? name
                : PathAtom.Create(stringTable, $"{name.ToString(stringTable)}_{count}");

            var redirectedDirectory = process.UniqueRedirectedDirectoryRoot.Combine(m_pathTable, pathAtom);

            return(redirectedDirectory);
        }
Ejemplo n.º 5
0
        /// <nodoc />
        public NugetFrameworkMonikers(StringTable stringTable)
        {
            LibFolderName = PathAtom.Create(stringTable, "lib");
            RefFolderName = PathAtom.Create(stringTable, "ref");

            WellknownMonikers            = new HashSet <PathAtom>();
            CompatibilityMatrix          = new MultiValueDictionary <PathAtom, PathAtom>();
            TargetFrameworkNameToMoniker = new Dictionary <string, PathAtom>();

            NetStandard10 = Register(stringTable, "netstandard1.0", ".NETStandard1.0");
            NetStandard11 = Register(stringTable, "netstandard1.1", ".NETStandard1.1");
            NetStandard12 = Register(stringTable, "netstandard1.2", ".NETStandard1.2");
            NetStandard13 = Register(stringTable, "netstandard1.3", ".NETStandard1.3");
            NetStandard14 = Register(stringTable, "netstandard1.4", ".NETStandard1.4");
            NetStandard15 = Register(stringTable, "netstandard1.5", ".NETStandard1.5");
            NetStandard16 = Register(stringTable, "netstandard1.6", ".NETStandard1.6");
            NetStandard20 = Register(stringTable, "netstandard2.0", ".NETStandard2.0");

            NetCoreApp20 = Register(stringTable, "netcoreapp2.0", ".NETCoreApp2.0");
            NetCoreApp21 = Register(stringTable, "netcoreapp2.1", ".NETCoreApp2.1");
            NetCoreApp22 = Register(stringTable, "netcoreapp2.2", ".NETCoreApp2.2");

            Net10 = Register(stringTable, "net10", ".NETFramework1.0");
            Net11 = Register(stringTable, "net11", ".NETFramework1.1");
            Net20 = Register(stringTable, "net20", ".NETFramework2.0");
            Net35 = Register(stringTable, "net35", ".NETFramework3.5");
            Net40 = Register(stringTable, "net40", ".NETFramework4.0");

            Net45  = Register(stringTable, "net45", ".NETFramework4.5");
            Net451 = Register(stringTable, "net451", ".NETFramework4.5.1");
            Net452 = Register(stringTable, "net452", ".NETFramework4.5.2");

            Net46  = Register(stringTable, "net46", ".NETFramework4.6");
            Net461 = Register(stringTable, "net461", ".NETFramework4.6.1");
            Net462 = Register(stringTable, "net462", ".NETFramework4.6.2");
            Net472 = Register(stringTable, "net472", ".NETFramework4.7.2");

            RegisterCompatibility(Net451, Net45, Net40, Net35, Net20, NetStandard12, NetStandard11, NetStandard10, Net11, Net10);
            //RegisterCompatibility(Net452, Net451, Net45, Net40, Net35);
            //RegisterCompatibility(Net46, NetStandard13, NetStandard12, NetStandard11, NetStandard10, Net452, Net451, Net45, Net40, Net35);
            // The fallback logic is: to use .net 4x version for .net 4.6.1
            RegisterCompatibility(Net461, Net46, Net452, Net451, Net45, Net40, NetStandard20, NetStandard16, NetStandard15, NetStandard14, NetStandard13, NetStandard12, NetStandard11, NetStandard10, Net35, Net20, Net11, Net10);

            RegisterCompatibility(Net472, Net461, Net46, Net452, Net451, Net45, Net40, NetStandard20, NetStandard16, NetStandard15, NetStandard14, NetStandard13, NetStandard12, NetStandard11, NetStandard10, Net35, Net20, Net11, Net10);

            RegisterCompatibility(NetStandard20, NetStandard16, NetStandard15, NetStandard14, NetStandard13, NetStandard12, NetStandard11, NetStandard10);

            RegisterCompatibility(NetCoreApp22, NetCoreApp21, NetCoreApp20, NetStandard20, NetStandard16, NetStandard15, NetStandard14, NetStandard13, NetStandard12, NetStandard11, NetStandard10);
        }
Ejemplo n.º 6
0
        public async Task CmdWithTestShim_ShimNothingRunsChildProcessWithoutShimAsync(bool shimAllProcess, bool filterMatch)
        {
            var context         = BuildXLContext.CreateInstanceForTesting();
            var shimProgramPath = GetShimProgramPath(context);

            string executable   = CmdHelper.CmdX64;
            string processMatch = filterMatch ? null : "foo.exe"; // Filter should never match foo.exe.

            var fam = CreateCommonFileAccessManifest(context.PathTable);

            fam.SubstituteProcessExecutionInfo = new SubstituteProcessExecutionInfo(
                shimProgramPath,
                shimAllProcesses: shimAllProcess,
                processMatches: processMatch == null
                    ? new ShimProcessMatch[0]
                    : new[] { new ShimProcessMatch(PathAtom.Create(context.StringTable, processMatch), PathAtom.Invalid) });

            string predicate   = shimAllProcess ? string.Empty : "not ";
            string childOutput = $"Child cmd that should {predicate}be shimmed";
            string childArgs   = $"{executable} /D /C @echo {childOutput}";
            string args        = "/D /C echo Top-level cmd. Running child process && " + childArgs;

            var stdOutSb = new StringBuilder(128);
            var stdErrSb = new StringBuilder();

            SandboxedProcessInfo sandboxedProcessInfo = CreateCommonSandboxedProcessInfo(
                context,
                executable,
                args,
                fam,
                stdOutSb,
                stdErrSb);

            ISandboxedProcess sandboxedProcess =
                await SandboxedProcessFactory.StartAsync(sandboxedProcessInfo, forceSandboxing : true)
                .ConfigureAwait(false);

            SandboxedProcessResult result = await sandboxedProcess.GetResultAsync().ConfigureAwait(false);

            string stdOut = stdOutSb.ToString();
            string stdErr = stdErrSb.ToString();

            m_output.WriteLine($"stdout: {stdOut}");
            m_output.WriteLine($"stderr: {stdErr}");

            AssertSuccess(result, stdErr);
            AssertShimmedIf(stdOut, shimAllProcess);
            XAssert.Contains(stdOut, childOutput);
        }
Ejemplo n.º 7
0
        public void RemoveExtension()
        {
            var st = new StringTable(0);

            // remove a single char extension
            PathAtom pa1 = PathAtom.Create(st, @"a.c");
            PathAtom pa2 = pa1.RemoveExtension(st);

            XAssert.AreEqual(@"a", pa2.ToString(st));

            // remove a multi char extension
            pa1 = PathAtom.Create(st, @"a.cpp");
            pa2 = pa1.RemoveExtension(st);
            XAssert.AreEqual(@"a", pa2.ToString(st));

            // remove nothing
            pa1 = PathAtom.Create(st, @"a");
            pa2 = pa1.RemoveExtension(st);
            XAssert.AreEqual(pa1, pa2);

            // remove a single char extension
            pa1 = PathAtom.Create(st, @"ab.c");
            pa2 = pa1.RemoveExtension(st);
            XAssert.AreEqual(@"ab", pa2.ToString(st));

            // remove a multi char extension
            pa1 = PathAtom.Create(st, @"ab.cpp");
            pa2 = pa1.RemoveExtension(st);
            XAssert.AreEqual(@"ab", pa2.ToString(st));

            // remove nothing
            pa1 = PathAtom.Create(st, @"ab");
            pa2 = pa1.RemoveExtension(st);
            XAssert.AreEqual(pa1, pa2);

            pa1 = PathAtom.Create(st, @"ab.xyz.c");
            pa2 = pa1.RemoveExtension(st);
            XAssert.AreEqual(@"ab.xyz", pa2.ToString(st));

            // remove a multi char extension
            pa1 = PathAtom.Create(st, @"ab.xyz.cpp");
            pa2 = pa1.RemoveExtension(st);
            XAssert.AreEqual(@"ab.xyz", pa2.ToString(st));

            pa1 = PathAtom.Create(st, @".cpp");
            pa2 = pa1.RemoveExtension(st);
            XAssert.AreEqual(pa1, pa2);
        }
Ejemplo n.º 8
0
        /// <nodoc />
        public PackageOnDisk(PathTable pathTable, INugetPackage package, PackageDownloadResult packageDownloadResult)
        {
            Contract.Requires(pathTable != null);
            Contract.Requires(package != null);
            Contract.Requires(packageDownloadResult != null);

            Package = package;
            PackageDownloadResult = packageDownloadResult;

            var nuspecFileName = PathAtom.Create(pathTable.StringTable, package.Id + ".nuspec");

            GetSpecialFiles(pathTable, nuspecFileName, packageDownloadResult, out var nuSpecFile, out var moduleConfigFile);

            NuSpecFile       = nuSpecFile;
            ModuleConfigFile = moduleConfigFile;
        }
Ejemplo n.º 9
0
        public void TryCreate()
        {
            var st = new StringTable(0);

            PathAtom atom;

            XAssert.IsTrue(PathAtom.TryCreate(st, "AAA", out atom));
            XAssert.AreEqual("AAA", atom.ToString(st));
            XAssert.IsFalse(PathAtom.TryCreate(st, Path.DirectorySeparatorChar + "AAA", out atom));
            XAssert.IsFalse(PathAtom.TryCreate(st, Path.VolumeSeparatorChar + "AAA", out atom));
            XAssert.IsFalse(PathAtom.TryCreate(st, "AAA" + Path.DirectorySeparatorChar, out atom));
            XAssert.IsFalse(PathAtom.TryCreate(st, string.Empty, out atom));

            atom = PathAtom.Create(st, "BBB");
            XAssert.AreEqual("BBB", atom.ToString(st));
        }
Ejemplo n.º 10
0
        /// <nodoc />
        public PathAtom Remap(PathAtom pathAtom)
        {
            if (m_oldPathTable == null || !pathAtom.IsValid)
            {
                return(pathAtom);
            }

            var pathAtomString = pathAtom.ToString(m_oldPathTable.StringTable);

            if (m_pathAtomStringRemapper != null)
            {
                pathAtomString = m_pathAtomStringRemapper(pathAtomString);
            }

            return(PathAtom.Create(m_newPathTable.StringTable, pathAtomString));
        }
Ejemplo n.º 11
0
        /// <nodoc />
        public NugetFrameworkMonikers(StringTable stringTable)
        {
            LibFolderName = PathAtom.Create(stringTable, "lib");
            RefFolderName = PathAtom.Create(stringTable, "ref");

            WellknownMonikers            = new HashSet <PathAtom>();
            TargetFrameworkNameToMoniker = new Dictionary <string, PathAtom>();
            FullFrameworkVersionHistory  = new List <PathAtom>();
            NetCoreVersionHistory        = new List <PathAtom>();

            NetStandard10 = Register(stringTable, "netstandard1.0", ".NETStandard1.0", NetCoreVersionHistory);
            NetStandard11 = Register(stringTable, "netstandard1.1", ".NETStandard1.1", NetCoreVersionHistory);
            NetStandard12 = Register(stringTable, "netstandard1.2", ".NETStandard1.2", NetCoreVersionHistory);
            NetStandard13 = Register(stringTable, "netstandard1.3", ".NETStandard1.3", NetCoreVersionHistory);
            NetStandard14 = Register(stringTable, "netstandard1.4", ".NETStandard1.4", NetCoreVersionHistory);
            NetStandard15 = Register(stringTable, "netstandard1.5", ".NETStandard1.5", NetCoreVersionHistory);
            NetStandard16 = Register(stringTable, "netstandard1.6", ".NETStandard1.6", NetCoreVersionHistory);
            NetStandard20 = Register(stringTable, "netstandard2.0", ".NETStandard2.0", NetCoreVersionHistory);
            NetCoreApp20  = Register(stringTable, "netcoreapp2.0", ".NETCoreApp2.0", NetCoreVersionHistory);
            NetCoreApp21  = Register(stringTable, "netcoreapp2.1", ".NETCoreApp2.1", NetCoreVersionHistory);
            NetCoreApp22  = Register(stringTable, "netcoreapp2.2", ".NETCoreApp2.2", NetCoreVersionHistory);
            NetCoreApp30  = Register(stringTable, "netcoreapp3.0", ".NETCoreApp3.0", NetCoreVersionHistory);
            NetStandard21 = Register(stringTable, "netstandard2.1", ".NETStandard2.1", NetCoreVersionHistory);

            NetCoreAppVersionHistory = new List <PathAtom>()
            {
                NetCoreApp20, NetCoreApp21, NetCoreApp22, NetCoreApp30
            };

            Net10  = Register(stringTable, "net10", ".NETFramework1.0", FullFrameworkVersionHistory);
            Net11  = Register(stringTable, "net11", ".NETFramework1.1", FullFrameworkVersionHistory);
            Net20  = Register(stringTable, "net20", ".NETFramework2.0", FullFrameworkVersionHistory);
            Net35  = Register(stringTable, "net35", ".NETFramework3.5", FullFrameworkVersionHistory);
            Net40  = Register(stringTable, "net40", ".NETFramework4.0", FullFrameworkVersionHistory);
            Net45  = Register(stringTable, "net45", ".NETFramework4.5", FullFrameworkVersionHistory);
            Net451 = Register(stringTable, "net451", ".NETFramework4.5.1", FullFrameworkVersionHistory);
            Net452 = Register(stringTable, "net452", ".NETFramework4.5.2", FullFrameworkVersionHistory);
            Net46  = Register(stringTable, "net46", ".NETFramework4.6", FullFrameworkVersionHistory);
            Net461 = Register(stringTable, "net461", ".NETFramework4.6.1", FullFrameworkVersionHistory);
            Net462 = Register(stringTable, "net462", ".NETFramework4.6.2", FullFrameworkVersionHistory);
            Net472 = Register(stringTable, "net472", ".NETFramework4.7.2", FullFrameworkVersionHistory);

            NetStandardToFullFrameworkCompatibility = new List <PathAtom>()
            {
                Net461, Net462, Net472
            };
        }
Ejemplo n.º 12
0
        private void IntializeIpcNames()
        {
            m_ipcSendMoniker                        = Symbol("moniker");
            m_ipcSendMessageBody                    = Symbol("messageBody");
            m_ipcSendTargetServicePip               = Symbol("targetService");
            m_ipcSendOutputFile                     = Symbol("outputFile");
            m_ipcSendDependencies                   = Symbol("fileDependencies");
            m_ipcSendMaxConnectRetries              = Symbol("maxConnectRetries");
            m_ipcSendConnectRetryDelayMillis        = Symbol("connectRetryDelayMillis");
            m_ipcSendLazilyMaterializedDependencies = Symbol("lazilyMaterializedDependencies");
            m_ipcSendMustRunOnMaster                = Symbol("mustRunOnMaster");

            // IpcSendResult
            m_ipcSendResultOutputFile = Symbol("outputFile");
            m_ipcObjectFolderName     = PathAtom.Create(StringTable, "ipc");
            m_ipcOutputFileName       = PathAtom.Create(StringTable, "results.txt");
        }
        [InlineData("\"\"", "\"\"")] // Force case where child process is executed with double quotes around it
        public async Task CmdWithSingleTokenChildProcessNoArgsAsync(string preCommand, string postCommand)
        {
            var context         = BuildXLContext.CreateInstanceForTesting();
            var shimProgramPath = GetShimProgramPath(context);

            string executable       = CmdHelper.CmdX64;
            string childExecutable  = executable;
            string quotedExecutable = '"' + executable + '"';

            childExecutable = quotedExecutable;

            var fam = CreateCommonFileAccessManifest(context.PathTable);

            // Use 'doskey' (alias manager) built into Windows.
            string args = $"/D /C {preCommand}doskey.exe{postCommand}";

            fam.SubstituteProcessExecutionInfo = new SubstituteProcessExecutionInfo(
                shimProgramPath,
                shimAllProcesses: false,
                processMatches: new[] { new ShimProcessMatch(PathAtom.Create(context.StringTable, "cmd.exe"), PathAtom.Invalid) });

            var stdOutSb = new StringBuilder(128);
            var stdErrSb = new StringBuilder();

            SandboxedProcessInfo sandboxedProcessInfo = CreateCommonSandboxedProcessInfo(
                context,
                executable,
                args,
                fam,
                stdOutSb,
                stdErrSb);

            ISandboxedProcess sandboxedProcess =
                await SandboxedProcessFactory.StartAsync(sandboxedProcessInfo, forceSandboxing : true)
                .ConfigureAwait(false);

            SandboxedProcessResult result = await sandboxedProcess.GetResultAsync().ConfigureAwait(false);

            string stdOut = stdOutSb.ToString();
            string stdErr = stdErrSb.ToString();

            m_output.WriteLine($"stdout: {stdOut}");
            m_output.WriteLine($"stderr: {stdErr}");

            AssertSuccess(result, stdErr);
        }
Ejemplo n.º 14
0
        public void RoundTripSerializationOfPathsWithUnicodeChars()
        {
            var pathTable = new PathTable();

            var mpe = new global::BuildXL.Engine.MountPathExpander(pathTable);

            mpe.Add(
                pathTable,
                new global::BuildXL.Pips.SemanticPathInfo(
                    PathAtom.Create(pathTable.StringTable, "xcode"),
                    AbsolutePath.Create(pathTable, X("/c/Applications")),
                    false, true, true, false, false, false));

            var pathSet = ObservedPathSetTestUtilities.CreatePathSet(
                pathTable,
                X("/c/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/DeviceTypes/iPhone Xʀ.simdevicetype"),
                X("/c/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/DeviceTypes/iPhone Xʀ.simdevicetype/Contents"));

            SerializeRoundTripAndAssertEquivalent(pathTable, pathSet, mpe);
        }
Ejemplo n.º 15
0
        private async Task <Possible <NinjaGraphWithModuleDefinition> > TryComputeBuildGraphAsync()
        {
            Possible <NinjaGraphResult> maybeGraph = await ComputeBuildGraphAsync();

            var result         = maybeGraph.Result;
            var specFileConfig = SpecFile.ChangeExtension(m_context.PathTable, PathAtom.Create(m_context.StringTable, ".ninja.dsc")); // It needs to be a .dsc for the parsing to work

            var moduleDescriptor = ModuleDescriptor.CreateWithUniqueId(m_context.StringTable, m_resolverSettings.ModuleName, this);
            var moduleDefinition = ModuleDefinition.CreateModuleDefinitionWithImplicitReferences(
                moduleDescriptor,
                ProjectRoot,
                m_resolverSettings.File,
                new List <AbsolutePath>()
            {
                specFileConfig
            },
                allowedModuleDependencies: null, // no module policies
                cyclicalFriendModules: null);    // no whitelist of cycles

            return(new NinjaGraphWithModuleDefinition(result.Graph, moduleDefinition));
        }
Ejemplo n.º 16
0
        public void Combine()
        {
            var          pt = new PathTable();
            AbsolutePath a1 = AbsolutePath.Create(pt, @"/");
            PathAtom     p1 = PathAtom.Create(pt.StringTable, "home");
            AbsolutePath a2 = a1.Combine(pt, p1);

            XAssert.AreEqual(@"/home", a2.ToString(pt));

            a1 = AbsolutePath.Create(pt, @"/home");
            p1 = PathAtom.Create(pt.StringTable, "root");
            a2 = a1.Combine(pt, p1);
            XAssert.AreEqual(@"/home/root", a2.ToString(pt));

            a1 = AbsolutePath.Create(pt, @"/home");
            p1 = PathAtom.Create(pt.StringTable, "root");
            PathAtom p2 = PathAtom.Create(pt.StringTable, "documents");

            a2 = a1.Combine(pt, p1, p2);
            XAssert.AreEqual(@"/home/root/documents", a2.ToString(pt));

            a1 = AbsolutePath.Create(pt, @"/home");
            p1 = PathAtom.Create(pt.StringTable, "root");
            p2 = PathAtom.Create(pt.StringTable, "documents");
            PathAtom p3 = PathAtom.Create(pt.StringTable, "config");

            a2 = a1.Combine(pt, p1, p2, p3);
            XAssert.AreEqual(@"/home/root/documents/config", a2.ToString(pt));

            a1 = AbsolutePath.Create(pt, @"/");
            RelativePath rp = RelativePath.Create(pt.StringTable, @"home/root");

            a2 = a1.Combine(pt, rp);
            XAssert.AreEqual(@"/home/root", a2.ToString(pt));

            a1 = AbsolutePath.Create(pt, @"/home");
            rp = RelativePath.Create(pt.StringTable, @"root/documents");
            a2 = a1.Combine(pt, rp);
            XAssert.AreEqual(@"/home/root/documents", a2.ToString(pt));
        }
Ejemplo n.º 17
0
        public void Equality()
        {
            var      st = new StringTable(0);
            PathAtom a1 = PathAtom.Create(st, "AAA");
            PathAtom a2 = PathAtom.Create(st, "AAA");
            PathAtom a3 = PathAtom.Create(st, "BBB");

            XAssert.IsTrue(a1.Equals(a1));
            XAssert.IsTrue(a1.Equals(a2));
            XAssert.IsTrue(a2.Equals(a1));
            XAssert.IsFalse(a1.Equals(a3));
            XAssert.IsFalse(a2.Equals(a3));

            XAssert.IsTrue(a1.Equals((object)a1));
            XAssert.IsTrue(a1.Equals((object)a2));
            XAssert.IsTrue(a2.Equals((object)a1));
            XAssert.IsFalse(a1.Equals((object)a3));
            XAssert.IsFalse(a2.Equals((object)a3));
            XAssert.IsFalse(a2.Equals("XYZ"));

            XAssert.IsTrue(a1 == a2);
            XAssert.IsTrue(a2 == a1);
            XAssert.IsFalse(a1 == a3);
            XAssert.IsFalse(a2 == a3);

            XAssert.IsFalse(a1 != a2);
            XAssert.IsFalse(a2 != a1);
            XAssert.IsTrue(a1 != a3);
            XAssert.IsTrue(a2 != a3);

            int h1 = a1.GetHashCode();
            int h2 = a2.GetHashCode();

            XAssert.AreEqual(h1, h2);

            StringId id1 = a1.StringId;
            StringId id2 = a2.StringId;

            XAssert.AreEqual(id1, id2);
        }
Ejemplo n.º 18
0
        public void RelocateForm1()
        {
            // replace the file extension
            var pt = new PathTable();

            {
                AbsolutePath d1  = AbsolutePath.Create(pt, @"/a/b");
                AbsolutePath d2  = AbsolutePath.Create(pt, @"/a/x");
                AbsolutePath f1  = AbsolutePath.Create(pt, @"/a/b/c/d.cpp");
                PathAtom     ext = PathAtom.Create(pt.StringTable, ".obj");
                XAssert.IsTrue(f1.IsWithin(pt, d1));
                XAssert.IsFalse(f1.IsWithin(pt, d2));
                AbsolutePath f2 = f1.Relocate(pt, d1, d2, ext);
                XAssert.AreEqual(@"/a/x/c/d.obj", f2.ToString(pt));
            }

            // strip the extension instead of replacing it
            pt = new PathTable();
            {
                AbsolutePath d1 = AbsolutePath.Create(pt, @"/a/b");
                AbsolutePath d2 = AbsolutePath.Create(pt, @"/a/x");
                AbsolutePath f1 = AbsolutePath.Create(pt, @"/a/b/c/d.cpp");
                XAssert.IsTrue(f1.IsWithin(pt, d1));
                XAssert.IsFalse(f1.IsWithin(pt, d2));
                AbsolutePath f2 = f1.Relocate(pt, d1, d2, PathAtom.Invalid);
                XAssert.AreEqual(@"/a/x/c/d", f2.ToString(pt));
            }

            // leave the extension alone
            pt = new PathTable();
            {
                AbsolutePath d1 = AbsolutePath.Create(pt, @"/a/b");
                AbsolutePath d2 = AbsolutePath.Create(pt, @"/a/x");
                AbsolutePath f1 = AbsolutePath.Create(pt, @"/a/b/c/d.cpp");
                XAssert.IsTrue(f1.IsWithin(pt, d1));
                XAssert.IsFalse(f1.IsWithin(pt, d2));
                AbsolutePath f2 = f1.Relocate(pt, d1, d2);
                XAssert.AreEqual(@"/a/x/c/d.cpp", f2.ToString(pt));
            }
        }
Ejemplo n.º 19
0
        public void Combine()
        {
            var          pt = new PathTable();
            AbsolutePath a1 = AbsolutePath.Create(pt, @"C:\");
            PathAtom     p1 = PathAtom.Create(pt.StringTable, "A");
            AbsolutePath a2 = a1.Combine(pt, p1);

            XAssert.AreEqual(@"C:\A", a2.ToString(pt));

            a1 = AbsolutePath.Create(pt, @"C:\X");
            p1 = PathAtom.Create(pt.StringTable, "A");
            a2 = a1.Combine(pt, p1);
            XAssert.AreEqual(@"C:\X\A", a2.ToString(pt));

            a1 = AbsolutePath.Create(pt, @"C:\X");
            p1 = PathAtom.Create(pt.StringTable, "A");
            PathAtom p2 = PathAtom.Create(pt.StringTable, "B");

            a2 = a1.Combine(pt, p1, p2);
            XAssert.AreEqual(@"C:\X\A\B", a2.ToString(pt));

            a1 = AbsolutePath.Create(pt, @"C:\X");
            p1 = PathAtom.Create(pt.StringTable, "A");
            p2 = PathAtom.Create(pt.StringTable, "B");
            PathAtom p3 = PathAtom.Create(pt.StringTable, "C");

            a2 = a1.Combine(pt, p1, p2, p3);
            XAssert.AreEqual(@"C:\X\A\B\C", a2.ToString(pt));

            a1 = AbsolutePath.Create(pt, @"C:\");
            RelativePath rp = RelativePath.Create(pt.StringTable, @"A\B");

            a2 = a1.Combine(pt, rp);
            XAssert.AreEqual(@"C:\A\B", a2.ToString(pt));

            a1 = AbsolutePath.Create(pt, @"C:\X");
            rp = RelativePath.Create(pt.StringTable, @"A\B");
            a2 = a1.Combine(pt, rp);
            XAssert.AreEqual(@"C:\X\A\B", a2.ToString(pt));
        }
Ejemplo n.º 20
0
        public void RelocateSubtree()
        {
            var pt = new PathTable();

            AbsolutePath.Create(pt, A("c", "a"));
            AbsolutePath id2 = AbsolutePath.Create(pt, A("c", "a", "b"));

            AbsolutePath.Create(pt, A("c", "a", "b", "c"));
            AbsolutePath id4 = AbsolutePath.Create(pt, A("c", "a", "b", "c", "d.cpp"));
            AbsolutePath id5 = AbsolutePath.Create(pt, A("c", "a", "e"));
            AbsolutePath id6 = id4.Relocate(pt, id2, id5, PathAtom.Create(pt.StringTable, ".obj"));

            XAssert.AreEqual(A("c", "a", "e", "c", "d.obj"), id6.ToString(pt));

            AbsolutePath.Create(pt, A("c", "a"));
            id2 = AbsolutePath.Create(pt, A("c", "a", "b"));
            AbsolutePath.Create(pt, A("c", "a", "b", "c"));
            id4 = AbsolutePath.Create(pt, A("c", "a", "b", "c", "d"));
            id5 = AbsolutePath.Create(pt, A("c", "a", "e"));
            id6 = id4.Relocate(pt, id2, id5, PathAtom.Create(pt.StringTable, ".obj"));
            XAssert.AreEqual(A("c", "a", "e", "c", "d.obj"), id6.ToString(pt));
        }
Ejemplo n.º 21
0
        private static MountPathExpander CreateMountPathExpander(params TestMount[] mounts)
        {
            var pathTable         = new PathTable();
            var mountPathExpander = new MountPathExpander(pathTable);

            foreach (var mount in mounts)
            {
                mountPathExpander.Add(
                    pathTable,
                    new Mount
                {
                    Name                   = PathAtom.Create(pathTable.StringTable, mount.Name),
                    Path                   = AbsolutePath.Create(pathTable, mount.Path),
                    IsReadable             = mount.Features.HasFlag(MountFeatures.Readable),
                    IsWritable             = mount.Features.HasFlag(MountFeatures.Writable),
                    IsScrubbable           = mount.Features.HasFlag(MountFeatures.Scrubbable),
                    TrackSourceFileChanges = mount.Features.HasFlag(MountFeatures.Hashable)
                });
            }

            return(mountPathExpander);
        }
Ejemplo n.º 22
0
        public void SharedCompilationIsTurnedOnWhenAvailable()
        {
            var project = CreateProjectWithPredictions("A.proj");

            // We need to explicitly turn on shared compilation because for tests it is off by default
            var testProj = Start(new MsBuildResolverSettings {
                UseLegacyProjectIsolation = true, UseManagedSharedCompilation = true
            })
                           .Add(project)
                           .ScheduleAll()
                           .AssertSuccess().
                           RetrieveSuccessfulProcess(project);

            var arguments = RetrieveProcessArguments(testProj);

            // - not turn off shared compilation,
            // - let VBCSCompiler escape the sandbox
            // - attach the VBCSCompiler logger to compensate for missing accesses
            Assert.DoesNotContain("/p:UseSharedCompilation=false", arguments);
            Assert.Equal(PathAtom.Create(StringTable, "VBCSCompiler.exe"), testProj.ChildProcessesToBreakawayFromSandbox.Single());
            Assert.Contains(PipConstructor.VBCSCompilerLogger, arguments);
        }
Ejemplo n.º 23
0
        /// <nodoc />
        public Literals(StringTable stringTable)
        {
            Contract.Requires(stringTable != null);

            m_stringTable = stringTable;

            Obsolete        = SymbolAtom.Create(stringTable, ObsoleteString);
            ForeignFunction = SymbolAtom.Create(stringTable, ForeignFunctionString);

            PathNamespace         = SymbolAtom.Create(stringTable, "Path");
            RelativePathNamespace = SymbolAtom.Create(stringTable, "RelativePath");
            PathAtomNamespace     = SymbolAtom.Create(stringTable, "PathAtom");
            PathCombine           = SymbolAtom.Create(stringTable, "combine");
            PathCombinePaths      = SymbolAtom.Create(stringTable, "combinePaths");
            PathInterpolate       = SymbolAtom.Create(stringTable, Literals.InterpolateString);
            ArrayConcat           = SymbolAtom.Create(stringTable, "concat");
            FileNamespace         = SymbolAtom.Create(stringTable, "File");
            DirectoryNamespace    = SymbolAtom.Create(stringTable, "Directory");
            FileDirCreate         = SymbolAtom.Create(stringTable, "fromPath");
            InlineImportFrom      = SymbolAtom.Create(stringTable, Names.InlineImportFunction);
            DotDscExtension       = PathAtom.Create(stringTable, Names.DotDscExtension);
            ConfigDsc             = PathAtom.Create(stringTable, Names.ConfigDsc);
            ConfigBc   = PathAtom.Create(stringTable, Names.ConfigBc);
            PackageDsc = PathAtom.Create(stringTable, Names.PackageDsc);
            this.DotConfigDotDscExtension = PathAtom.Create(stringTable, Names.DotConfigDotDscExtension);
            PackageConfigDsc            = PathAtom.Create(stringTable, Names.PackageConfigDsc);
            ModuleConfigBm              = PathAtom.Create(stringTable, Names.ModuleConfigBm);
            ModuleConfigDsc             = PathAtom.Create(stringTable, Names.ModuleConfigDsc);
            ConfigurationKeyword        = SymbolAtom.Create(stringTable, Names.ConfigurationFunctionCall);
            LegacyPackageKeyword        = SymbolAtom.Create(stringTable, Names.LegacyModuleConfigurationFunctionCall);
            ModuleKeyword               = SymbolAtom.Create(stringTable, Names.ModuleConfigurationFunctionCall);
            QualifierDeclarationKeyword = SymbolAtom.Create(stringTable, Names.CurrentQualifier);
            WithQualifierKeyword        = SymbolAtom.Create(stringTable, Names.WithQualifierFunction);
            RuntimeRootNamespaceSymbol  = SymbolAtom.Create(stringTable, Names.RuntimeRootNamespaceAlias);
            TemplateReference           = SymbolAtom.Create(stringTable, Names.TemplateReference);
            UndefinedLiteral            = SymbolAtom.Create(stringTable, "undefined");
            CustomMergeFunction         = SymbolAtom.Create(stringTable, Names.CustomMergeFunctionName);
        }
Ejemplo n.º 24
0
        public void TryCreate()
        {
            var st = new StringTable(0);

            RelativePath p;

            XAssert.IsTrue(RelativePath.TryCreate(st, @"usr/src", out p));
            XAssert.AreEqual(@"usr/src", p.ToString(st));

            XAssert.IsFalse(RelativePath.TryCreate(st, @"C\:AAA", out p));
            XAssert.IsFalse(RelativePath.TryCreate(st, @"AAA:", out p));
            XAssert.IsFalse(RelativePath.TryCreate(st, @":AAA", out p));
            XAssert.IsFalse(RelativePath.TryCreate(st, @"..", out p));

            p = RelativePath.Create(st, ".");
            XAssert.AreEqual(string.Empty, p.ToString(st));

            p = RelativePath.Create(st, "usr");
            XAssert.AreEqual("usr", p.ToString(st));

            p = RelativePath.Create(st, @"usr/.");
            XAssert.AreEqual("usr", p.ToString(st));

            p = RelativePath.Create(st, @"usr\..");
            XAssert.AreEqual(string.Empty, p.ToString(st));

            p = RelativePath.Create(st, @"usr/src/..");
            XAssert.AreEqual("usr", p.ToString(st));

            PathAtom a1 = PathAtom.Create(st, "usr");
            PathAtom a2 = PathAtom.Create(st, "src");
            PathAtom a3 = PathAtom.Create(st, "include");

            p = RelativePath.Create(a1, a2, a3);
            XAssert.AreEqual(@"usr/src/include", p.ToString(st));
        }
Ejemplo n.º 25
0
        public void TryCreate()
        {
            var st = new StringTable(0);

            RelativePath p;

            XAssert.IsTrue(RelativePath.TryCreate(st, @"AAA\CCC", out p));
            XAssert.AreEqual(@"AAA\CCC", p.ToString(st));

            XAssert.IsFalse(RelativePath.TryCreate(st, @"C\:AAA", out p));
            XAssert.IsFalse(RelativePath.TryCreate(st, @"AAA:", out p));
            XAssert.IsFalse(RelativePath.TryCreate(st, @":AAA", out p));
            XAssert.IsFalse(RelativePath.TryCreate(st, @"..", out p));

            p = RelativePath.Create(st, ".");
            XAssert.AreEqual(string.Empty, p.ToString(st));

            p = RelativePath.Create(st, "BBB");
            XAssert.AreEqual("BBB", p.ToString(st));

            p = RelativePath.Create(st, @"BBB\.");
            XAssert.AreEqual("BBB", p.ToString(st));

            p = RelativePath.Create(st, @"BBB\..");
            XAssert.AreEqual(string.Empty, p.ToString(st));

            p = RelativePath.Create(st, @"BBB\CCC\..");
            XAssert.AreEqual("BBB", p.ToString(st));

            PathAtom a1 = PathAtom.Create(st, "AAA");
            PathAtom a2 = PathAtom.Create(st, "BBB");
            PathAtom a3 = PathAtom.Create(st, "CCC");

            p = RelativePath.Create(a1, a2, a3);
            XAssert.AreEqual(@"AAA\BBB\CCC", p.ToString(st));
        }
Ejemplo n.º 26
0
        private void AddRequiredSurvivingChildren(ProcessBuilder processBuilder)
        {
            // mspdbsrv:
            // This process will live beyond the cl.exe call.
            // Allow the pip job object to clean the process without complaint.
            //
            // vctip.exe: On any compile error this telemetry upload exe will be run as a detached process.
            // Just let it be killed.
            // TODO: Can we stop it running? https://stackoverflow.microsoft.com/questions/74425/how-to-disable-vctip-exe-in-vc14
            //
            // conhost.exe: This process needs a little bit more time to finish after the main process. We shouldn't be allowing
            // this one to survive, we just need the timeout to be slightly more than zero. This will also be beneficial to other
            // arbitrary processeses that need a little bit more time. But, apparently, setting a timeout has a perf impact that is
            // being investigated. TODO: revisit this once this is fixed.
            //
            // All child processes: Don't wait to kill the processes.
            // CODESYNC: CloudBuild repo TrackerExecutor.cs "info.NestedProcessTerminationTimeout = TimeSpan.Zero"
            processBuilder.AllowedSurvivingChildProcessNames = ReadOnlyArray <PathAtom> .FromWithoutCopy(
                PathAtom.Create(m_context.StringTable, "mspdbsrv.exe"),
                PathAtom.Create(m_context.StringTable, "vctip.exe"),
                PathAtom.Create(m_context.StringTable, "conhost.exe"));

            processBuilder.NestedProcessTerminationTimeout = TimeSpan.Zero;
        }
Ejemplo n.º 27
0
        public void ProcessIsProperlyConfigured()
        {
            var project = CreateProjectWithPredictions("A.proj");

            var testProj = Start()
                           .Add(project)
                           .ScheduleAll()
                           .AssertSuccess()
                           .RetrieveSuccessfulProcess(project);

            // Undeclared sources are allowed as long as they are true sources
            Assert.True(testProj.AllowUndeclaredSourceReads);
            // Double writes are allowed as long as the written content is the same
            Assert.True(testProj.DoubleWritePolicy == DoubleWritePolicy.AllowSameContentDoubleWrites);
            // Working directory is the project directory
            Assert.True(testProj.WorkingDirectory == project.FullPath.GetParent(PathTable));
            // Log file is configured
            testProj.GetOutputs().Any(fa => fa.Path.GetName(PathTable).ToString(PathTable.StringTable) == "msbuild.log");
            // Surviving processes are configured
            testProj.AllowedSurvivingChildProcessNames.ToReadOnlySet().SetEquals(ReadOnlyArray <PathAtom> .FromWithoutCopy(
                                                                                     PathAtom.Create(PathTable.StringTable, "mspdbsrv.exe"),
                                                                                     PathAtom.Create(PathTable.StringTable, "vctip.exe"),
                                                                                     PathAtom.Create(PathTable.StringTable, "conhost.exe")));
        }
        public void ComplexEnvironmentVariableIsHonored()
        {
            var data = new EnvironmentData(new CompoundEnvironmentData()
            {
                Separator = "|",
                Contents  = new[] {
                    new EnvironmentData(1),
                    new EnvironmentData("2"),
                    new EnvironmentData(AbsolutePath.Create(PathTable, "C:\\foo\\bar")),
                    new EnvironmentData(new CompoundEnvironmentData()
                    {
                        Separator = " ",
                        Contents  = new [] {
                            new EnvironmentData(PathAtom.Create(StringTable, "atom")),
                            new EnvironmentData(RelativePath.Create(StringTable, "relative\\path"))
                        }
                    }),
                    new EnvironmentData(DirectoryArtifact.CreateWithZeroPartialSealId(AbsolutePath.Create(PathTable, "C:\\foo\\baaz")))
                }
            });

            var project  = CreateProjectWithPredictions("A.proj");
            var testProj = Start(new MsBuildResolverSettings {
                Environment = new Dictionary <string, EnvironmentData> {
                    ["Test"] = data
                }
            })
                           .Add(project)
                           .ScheduleAll()
                           .AssertSuccess()
                           .RetrieveSuccessfulProcess(project);

            var testEnvironmentVariable = testProj.EnvironmentVariables.First(e => e.Name.ToString(PathTable.StringTable).Equals("Test"));

            Assert.Equal("1|2|C:\\foo\\bar|atom relative\\path|C:\\foo\\baaz", testEnvironmentVariable.Value.ToString(PathTable));
        }
 private static PathAtom CreatePathAtom(FrontEndContext context, string pathAtom)
 {
     return(PathAtom.Create(context.StringTable, pathAtom));
 }
Ejemplo n.º 30
0
        internal MsbuildFile(
            Context context,
            AbsolutePath specFilePath,
            string projectExtension)
        {
            ProjectsByQualifier = new Dictionary <string, Project>();
            ProjectReferences   = new List <MsbuildFile>();

            Context       = context;
            Name          = specFilePath.GetName(Context.PathTable).RemoveExtension(Context.StringTable).ToString(Context.StringTable);
            SpecFilePath  = specFilePath;
            SpecDirectory = SpecFilePath.GetParent(Context.PathTable);

            // Add '.g' suffix only if the projects files will be in the spec root
            if (Context.CanWriteToSrc)
            {
                projectExtension = ".g" + projectExtension;
            }

            // Relative to enlistment root
            RelativePath = Context.GetRelativePath(SpecFilePath).ChangeExtension(Context.StringTable, PathAtom.Create(Context.StringTable, projectExtension));

            Guid = GenerateGuid(RelativePath.ToString(Context.StringTable));
            Path = Context.ProjectsRoot.Combine(Context.PathTable, RelativePath);
        }