예제 #1
0
        private static ParsedModule CreateModuleFor(RuntimeModelContext context, ISourceFile sourceFile)
        {
            const string ModuleName = "ModuleWith1File";
            var          specPath   = sourceFile.GetAbsolutePath(context.PathTable);

            var moduleRootDirectory = specPath.GetParent(context.PathTable);
            var moduleDefinition    = ModuleDefinition.CreateModuleDefinitionWithImplicitReferences(
                new ModuleDescriptor(
                    id: ModuleId.Create(context.StringTable, ModuleName),
                    name: ModuleName,
                    displayName: ModuleName,
                    version: "1.0.0",
                    resolverKind: KnownResolverKind.SourceResolverKind,
                    resolverName: "DScriptExpression"),
                moduleRootDirectory: moduleRootDirectory,
                moduleConfigFile: moduleRootDirectory.Combine(context.PathTable, "package.config.dsc"),
                specs: new [] { specPath },
                allowedModuleDependencies: null,
                cyclicalFriendModules: null
                );

            return(new ParsedModule(moduleDefinition, new Dictionary <AbsolutePath, ISourceFile>()
            {
                [specPath] = sourceFile
            }));
        }
예제 #2
0
        /// <summary>
        /// Helper method with defaults for convenient creation from unit tests
        /// </summary>
        public static PipConstructionHelper CreateForTesting(
            PipExecutionContext context,
            AbsolutePath?objectRoot     = null,
            AbsolutePath?redirectedRoot = null,
            AbsolutePath?tempRoot       = null,
            IMutablePipGraph pipGraph   = null,
            string moduleName           = null,
            string specRelativePath     = null,
            string symbol           = null,
            AbsolutePath?specPath   = null,
            QualifierId?qualifierId = null)
        {
            moduleName = moduleName ?? "TestModule";

            return(Create(
                       context,
                       objectRoot ?? AbsolutePath.Create(context.PathTable, "d:\\test\\obj"),
                       redirectedRoot ?? AbsolutePath.Create(context.PathTable, "d:\\test\\redirected"),
                       tempRoot ?? objectRoot ?? AbsolutePath.Create(context.PathTable, "d:\\test\\tmp"),
                       pipGraph,
                       ModuleId.Create(context.StringTable, moduleName),
                       moduleName,
                       RelativePath.Create(context.StringTable, specRelativePath ?? "spec"),
                       FullSymbol.Create(context.SymbolTable, symbol ?? "testValue"),
                       new LocationData(specPath ?? AbsolutePath.Create(context.PathTable, "d:\\src\\spec.dsc"), 0, 0),
                       qualifierId ?? QualifierId.Unqualified));
        }
        internal void UpdateDataForDownloadData(DownloadData downloadData, int resolverSettingsIndex, FrontEndContext context = null)
        {
            context = context ?? m_context;
            Contract.Assert(context != null);

            var name = downloadData.Settings.ModuleName;

            var moduleId   = ModuleId.Create(context.StringTable, name);
            var descriptor = new ModuleDescriptor(moduleId, name, name, string.Empty, Kind, Name);

            var definition = ModuleDefinition.CreateModuleDefinitionWithImplicitReferences(
                descriptor,
                downloadData.ModuleRoot,
                downloadData.ModuleConfigFile,
                new[] { downloadData.ModuleSpecFile },
                allowedModuleDependencies: null,
                cyclicalFriendModules: null,
                mounts: new Mount[] {
                new Mount {
                    Name = PathAtom.Create(m_context.StringTable, $"Download#{resolverSettingsIndex}"),
                    Path = downloadData.ModuleRoot,
                    TrackSourceFileChanges = true,
                    IsWritable             = true,
                    IsReadable             = true,
                    IsScrubbable           = true
                }
            });     // A Download package does not have any module dependency restrictions nor allowlist cycles

            m_descriptors.Add(descriptor);
            m_descriptorsByName.Add(name, descriptor);
            m_descriptorsBySpecPath.Add(downloadData.ModuleSpecFile, descriptor);
            m_definitions.Add(descriptor, definition);
        }
예제 #4
0
        void LoadInternal()
        {
            var section = settingsService.GetOrCreateSection(SETTINGS_GUID);

            breakpointService.Clear();
            foreach (var bpx in section.SectionsWithName("Breakpoint"))
            {
                uint?  token          = bpx.Attribute <uint?>("Token");
                string asmFullName    = bpx.Attribute <string>("AssemblyFullName");
                string moduleName     = bpx.Attribute <string>("ModuleName");
                bool?  isDynamic      = bpx.Attribute <bool?>("IsDynamic");
                bool?  isInMemory     = bpx.Attribute <bool?>("IsInMemory");
                bool   moduleNameOnly = bpx.Attribute <bool?>("ModuleNameOnly") ?? false;
                uint?  ilOffset       = bpx.Attribute <uint?>("ILOffset");
                bool?  isEnabled      = bpx.Attribute <bool?>("IsEnabled");

                if (token == null)
                {
                    continue;
                }
                if (isDynamic == null || isInMemory == null)
                {
                    continue;
                }
                if (string.IsNullOrEmpty(asmFullName) && !moduleNameOnly)
                {
                    continue;
                }
                if (string.IsNullOrEmpty(moduleName))
                {
                    continue;
                }
                if (ilOffset == null)
                {
                    continue;
                }
                if (isEnabled == null)
                {
                    continue;
                }

                var moduleId = ModuleId.Create(asmFullName, moduleName, isDynamic.Value, isInMemory.Value, moduleNameOnly);
                var key      = new ModuleTokenId(moduleId, token.Value);

                if (!isInMemory.Value && !isDynamic.Value)
                {
                    var s = bpx.Attribute <string>("Method");
                    if (s == null || s != GetMethodAsString(key))
                    {
                        continue;
                    }
                }

                var bp = new ILCodeBreakpoint(key, ilOffset.Value, isEnabled.Value);
                breakpointService.Add(bp);
            }
        }
예제 #5
0
 /// <summary>
 /// Creates a module from a module name and optionally a version using an id that it is guaranteed to be unique.
 /// </summary>
 public static ModuleDescriptor CreateWithUniqueId(StringTable table, string moduleName, IWorkspaceModuleResolver resolver, string version = null)
 {
     return(new ModuleDescriptor(
                id: ModuleId.Create(table, moduleName, version),
                name: moduleName,
                displayName: moduleName,
                version: version,
                resolverKind: resolver.Kind,
                resolverName: resolver.Name));
 }
예제 #6
0
        /// <remarks>
        /// We have to construct a built-in prelude for configuration processing because
        /// before we parse and convert the config file we don't know know where the user-specified
        /// prelude module resides.
        /// </remarks>
        private async Task <Possible <ParsedModule> > CreatePreludeModuleAsync()
        {
            var moduleName = FrontEndHost.PreludeModuleName;

            string       preludeRootDir     = GetPreludeRoot();
            AbsolutePath preludeRootDirPath = AbsolutePath.Create(m_pathTable, preludeRootDir);

            if (!m_engine.DirectoryExists(preludeRootDirPath))
            {
                return(new Failure <string>($"Prelude root folder '{preludeRootDir}' does not exist"));
            }

            var specs = DiscoverPreludeSpecs(preludeRootDirPath, out AbsolutePath mainSpec, out AbsolutePath moduleConfigSpec);

            if (!mainSpec.IsValid)
            {
                return(new Failure <string>($"Prelude main spec file ('{PreludeMainFile}') not found inside the '{preludeRootDir}' folder"));
            }

            if (!moduleConfigSpec.IsValid)
            {
                return(new Failure <string>($"Prelude module configuration spec file ('{PreludeModuleConfigName}') not found inside the '{preludeRootDir}' folder"));
            }

            ModuleDefinition preludeModuleDefinition = ModuleDefinition.CreateModuleDefinitionWithExplicitReferencesWithEmptyQualifierSpace(
                descriptor: new ModuleDescriptor(
                    id: ModuleId.Create(m_pathTable.StringTable, moduleName),
                    name: moduleName,
                    displayName: moduleName,
                    version: "0",
                    resolverKind: KnownResolverKind.DScriptResolverKind,
                    resolverName:  "DScriptPrelude"),
                main: mainSpec,
                moduleConfigFile: moduleConfigSpec,
                specs: specs,
                pathTable: PathTable);

            var parsedPreludeFiles = await Task.WhenAll(specs.Select(m_parser));

            var failures = parsedPreludeFiles.Where(r => !r.Succeeded).ToList();

            if (failures.Count > 0)
            {
                var separator = Environment.NewLine + "  ";
                var message   = "Parsing built-in prelude failed:" + separator + string.Join(separator, failures.Select(f => f.Failure.Describe()));
                return(new Failure <string>(message));
            }

            Dictionary <AbsolutePath, ISourceFile> specFileMap = parsedPreludeFiles
                                                                 .ToDictionary(
                maybeSourceFile => AbsolutePath.Create(PathTable, maybeSourceFile.Result.FileName),
                maybeSourceFile => maybeSourceFile.Result);

            return(new ParsedModule(preludeModuleDefinition, specFileMap));
        }
예제 #7
0
파일: ModulePip.cs 프로젝트: uilit/BuildXL
        /// <summary>
        /// Helper method to crate a dummy test version of the modulepip.
        /// </summary>
        public static ModulePip CreateForTesting(StringTable stringTable, AbsolutePath specPath, ModuleId?moduleId = null)
        {
            var moduleName = StringId.Create(stringTable, "TestModule");

            return(new ModulePip(
                       module: moduleId ?? ModuleId.Create(moduleName),
                       identity: moduleName,
                       version: StringId.Invalid,
                       location: new LocationData(specPath, 0, 0),
                       resolverKind: StringId.Create(stringTable, "TestResolver"),
                       resolverName: StringId.Create(stringTable, "TestResolver")
                       ));
        }
예제 #8
0
        /// <summary>
        /// Creates an instance of <see cref="TestPipGraphFragment"/>.
        /// </summary>
        public TestPipGraphFragment(LoggingContext loggingContext, string sourceRoot, string objectRoot, string redirectedRoot, string moduleName, bool useTopSort = false)
        {
            Contract.Requires(loggingContext != null);
            Contract.Requires(!string.IsNullOrEmpty(sourceRoot));
            Contract.Requires(!string.IsNullOrEmpty(objectRoot));
            Contract.Requires(!string.IsNullOrEmpty(moduleName));

            Context          = BuildXLContext.CreateInstanceForTesting();
            m_loggingContext = loggingContext;
            m_sourceRoot     = AbsolutePath.Create(Context.PathTable, sourceRoot);
            m_objectRoot     = AbsolutePath.Create(Context.PathTable, objectRoot);
            m_expander       = new MountPathExpander(Context.PathTable);

            var configuration = new ConfigurationImpl()
            {
                Schedule =
                {
                    UseFixedApiServerMoniker     = true,
                    ComputePipStaticFingerprints = true,
                }
            };

            m_useTopSort = useTopSort;
            PipGraph     = m_useTopSort
                ? new PipGraphFragmentBuilderTopSort(Context, configuration, m_expander)
                : new PipGraphFragmentBuilder(Context, configuration, m_expander);

            ModuleName = moduleName;
            var specFileName = moduleName + ".dsc";

            m_specPath = m_sourceRoot.Combine(Context.PathTable, specFileName);
            m_moduleId = ModuleId.Create(StringId.Create(Context.StringTable, moduleName));
            var modulePip = ModulePip.CreateForTesting(
                Context.StringTable,
                m_specPath,
                m_moduleId);

            PipGraph.AddModule(modulePip);
            PipGraph.AddSpecFile(new SpecFilePip(new FileArtifact(m_specPath), new LocationData(m_specPath, 0, 0), modulePip.Module));

            m_defaultConstructionHelper = PipConstructionHelper.CreateForTesting(
                Context,
                objectRoot: m_objectRoot,
                redirectedRoot: AbsolutePath.Create(Context.PathTable, redirectedRoot),
                pipGraph: PipGraph,
                moduleName: moduleName,
                specRelativePath: Path.Combine(m_sourceRoot.GetName(Context.PathTable).ToString(Context.StringTable), specFileName),
                specPath: m_specPath,
                symbol: moduleName + "_defaultValue");
        }
예제 #9
0
        private ModuleDefinition CreateConfigModuleDefinition(AbsolutePath mainConfig, HashSet <AbsolutePath> allSpecs, IWorkspaceModuleResolver configurationResolver)
        {
            var descriptorName = Names.ConfigModuleName;
            var mdsc           = new ModuleDescriptor(
                id: ModuleId.Create(PathTable.StringTable, descriptorName),
                name: descriptorName,
                displayName: descriptorName,
                version: "0.0",
                resolverKind: configurationResolver.Kind,
                resolverName: configurationResolver.Name);

            return(ModuleDefinition.CreateModuleDefinitionWithExplicitReferencesWithEmptyQualifierSpace(
                       descriptor: mdsc,
                       main: mainConfig,
                       moduleConfigFile: AbsolutePath.Invalid,
                       specs: allSpecs,
                       pathTable: PathTable));
        }
예제 #10
0
        /// <summary>
        /// Creates a module definition for configuration file.
        /// </summary>
        public static ModuleDefinition CreateConfigModuleDefinition(PathTable pathTable, AbsolutePath configPath, IEnumerable <AbsolutePath> allSpecs)
        {
            Contract.Requires(pathTable != null);
            Contract.Requires(configPath.IsValid);
            Contract.Requires(allSpecs != null);

            var descriptorName = Names.ConfigModuleName;
            var mdsc           = new ModuleDescriptor(
                id: ModuleId.Create(pathTable.StringTable, descriptorName),
                name: descriptorName,
                displayName: descriptorName,
                version: "0.0",
                resolverKind: KnownResolverKind.DScriptResolverKind,
                resolverName: "DScriptConfiguration");

            return(ModuleDefinition.CreateModuleDefinitionWithExplicitReferencesWithEmptyQualifierSpace(
                       descriptor: mdsc,
                       main: configPath,
                       moduleConfigFile: AbsolutePath.Invalid,
                       specs: allSpecs,
                       pathTable: pathTable));
        }
예제 #11
0
        internal void UpdateDataForDownloadData(DownloadData downloadData, FrontEndContext context = null)
        {
            context = context ?? m_context;
            Contract.Assert(context != null);

            var name = downloadData.Settings.ModuleName;

            var moduleId   = ModuleId.Create(context.StringTable, name);
            var descriptor = new ModuleDescriptor(moduleId, name, name, string.Empty, Kind, Name);

            var definition = ModuleDefinition.CreateModuleDefinitionWithImplicitReferences(
                descriptor,
                downloadData.ModuleRoot,
                downloadData.ModuleConfigFile,
                new[] { downloadData.ModuleSpecFile },
                allowedModuleDependencies: null,
                cyclicalFriendModules: null); // A Download package does not have any module dependency restrictions nor whitelists cycles

            m_descriptors.Add(descriptor);
            m_descriptorsByName.Add(name, descriptor);
            m_descriptorsBySpecPath.Add(downloadData.ModuleSpecFile, descriptor);
            m_definitions.Add(descriptor, definition);
        }
예제 #12
0
        /// <nodoc />
        public PrimitiveTypes(StringTable stringTable)
        {
            Contract.Requires(stringTable != null);

            StringTable    = stringTable;
            ScriptModuleId = ModuleId.Create(StringTable, "<DominoScript>");

            PathType                   = CreateNamedTypeReference("Path");
            PathAtomType               = CreateNamedTypeReference("PathAtom");
            RelativePathType           = CreateNamedTypeReference("RelativePath");
            FileType                   = CreateNamedTypeReference("File");
            DirectoryType              = CreateNamedTypeReference("Directory");
            DerivedFileType            = CreateNamedTypeReference("DerivedFile");
            StaticDirectoryType        = CreateNamedTypeReference("StaticDirectory");
            ExecuteArgumentsType       = CreateNamedTypeReference("ExecuteArguments");
            ExecuteResultType          = CreateNamedTypeReference("ExecuteResult");
            IpcSendArgumentsType       = CreateNamedTypeReference("IpcSendArguments");
            IpcSendResultType          = CreateNamedTypeReference("IpcSendResult");
            CreateServiceArgumentsType = CreateNamedTypeReference("CreateServiceArguments");
            CreateServiceResultType    = CreateNamedTypeReference("CreateServiceResult");
            ObjectType                 = CreateNamedTypeReference("Object");
            ArrayType                  = CreateNamedTypeReference("Array");
            ModuleType                 = CreateNamedTypeReference("Module");
            EnumType                   = CreateNamedTypeReference("Enum");
            ClosureType                = CreateNamedTypeReference("Closure");
            AmbientType                = CreateNamedTypeReference("Ambient");
            UnitType                   = PrimitiveType.UnitType;
            BooleanType                = PrimitiveType.BooleanType;
            StringType                 = PrimitiveType.StringType;
            NumberType                 = PrimitiveType.NumberType;
            StringBuilderType          = CreateNamedTypeReference("StringBuilder");
            MapType        = CreateNamedTypeReference("Map");
            SetType        = CreateNamedTypeReference("Set");
            DataType       = CreateNamedTypeReference("Data");
            IpcMonikerType = CreateNamedTypeReference("IpcMoniker");
        }
예제 #13
0
        /// <summary>
        /// Creates a package.
        /// </summary>
        public static Package Create(PackageId id, AbsolutePath path, IPackageDescriptor descriptor, IEnumerable <AbsolutePath> parsedProjects = null, ModuleId moduleId = default)
        {
            Contract.Requires(id.IsValid);
            Contract.Requires(path.IsValid);
            Contract.Requires(descriptor != null);

            return(new Package(id, path, descriptor, parsedProjects, moduleId.IsValid ? moduleId : ModuleId.Create(id.Name)));
        }