public static void Write() { string buildPath = DataDirectory.GetBuildPath(); Build build = new Build(buildPath); BuildTarget qfBuildTarget = BuildTargetFactory.Construct(BuildTargetFactory.QFName, build); BuildTarget tifBuildTarget = BuildTargetFactory.Construct(BuildTargetFactory.TIFName, build); TES4Collection collection = TES4CollectionFactory.Create(DataDirectory.GetESMDirectoryPath(), DataDirectory.TES4GameFileName);//Needs the "full" collection for SCRO lookups. using (ESMAnalyzer esmAnalyzer = ESMAnalyzer.Load(collection)) { foreach (TES4Record record in collection.Where(r => r.RecordType == TES4RecordType.INFO)) { var scroRecords = esmAnalyzer.GetTypesFromSCROEnumerable(record, null); string[] aliases = scroRecords.Select(r => r.Key).ToArray(); Write(qfBuildTarget, tifBuildTarget, record, null, aliases); } foreach (TES4Record record in collection.GetGrupRecords(TES4RecordType.QUST)) { Dictionary <StageIndexAndLogIndex, List <string> > aliasesDictionary = new Dictionary <StageIndexAndLogIndex, List <string> >(); foreach (var subrecord in record.GetSubrecordsWithStageIndexAndLogIndex("SCRO")) { int formID = subrecord.Item1.Value.FirstFourBytesToInt(); string name = formID == TES5PlayerReference.FormID ? TES5PlayerReference.PlayerRefName : esmAnalyzer.GetEDIDByFormID(formID); aliasesDictionary.AddNewListIfNotContainsKeyAndAddValueToList(subrecord.Item2, name); } foreach (var aliases in aliasesDictionary) { Write(qfBuildTarget, tifBuildTarget, record, aliases.Key, aliases.Value); } } } }
public void Execute(string scriptName, string targets = BuildTargetFactory.DefaultNames, string?buildPath = null) { if (!PreExecutionChecks(true, true, true, true)) { return; } if (buildPath == null) { buildPath = Build.DEFAULT_BUILD_PATH; } Build build = new Build(buildPath); BuildTarget[] buildTargets = BuildTargetFactory.ParseCollection(targets, build); if (!buildTargets.CanBuildAndWarnIfNot()) { return; } BuildTargetSimple[] buildTargetsSimple = BuildTargetFactory.GetCollection(buildTargets); using (BuildTargetAdvancedCollection buildTargetsAdvanced = BuildTargetFactory.GetCollection(build, buildTargetsSimple)) { TranspileScriptJob transpileJob = new TranspileScriptJob(buildTargetsAdvanced, scriptName); transpileJob.Run(); } PrepareWorkspace(build, buildTargets); Compile(build, buildTargetsSimple); Console.WriteLine("Build Complete"); string compileLog = File.ReadAllText(build.GetCompileStandardOutputPath()); Console.WriteLine(compileLog); }
public void Execute(string targets, int threadsNumber = DefaultThreads, string buildPath = null) { if (!PreExecutionChecks(true, true, true, true)) { return; } if (buildPath == null) { buildPath = Build.DEFAULT_BUILD_PATH; } Build build = new Build(buildPath); using (BuildLogServices buildLogServices = new BuildLogServices(build)) { BuildTargetCollection buildTargets = BuildTargetFactory.GetCollection(targets, build, buildLogServices); if (!buildTargets.CanBuildAndWarnIfNot()) { return; } BuildTracker buildTracker = new BuildTracker(buildTargets); Transpile(build, buildTracker, buildTargets, buildLogServices, threadsNumber); WriteTranspiled(buildTargets, buildTracker); ESMAnalyzer.Deallocate();//Hack - force ESM analyzer deallocation. PrepareWorkspace(buildTargets); Compile(build, buildTargets); } Console.WriteLine("Build Complete"); }
public void Execute(string targets, bool writeTranspiledFilesAndCompile, int threadsNumber = DefaultThreads, string?buildPath = null) { if (!PreExecutionChecks(true, true, true, true)) { return; } if (buildPath == null) { buildPath = Build.DEFAULT_BUILD_PATH; } Build build = new Build(buildPath); BuildTarget[] buildTargets = BuildTargetFactory.ParseCollection(targets, build); if (writeTranspiledFilesAndCompile && !buildTargets.CanBuildAndWarnIfNot()) { return; } BuildTargetSimple[] buildTargetsSimple = BuildTargetFactory.GetCollection(buildTargets); using (BuildTargetAdvancedCollection buildTargetsAdvanced = BuildTargetFactory.GetCollection(build, buildTargetsSimple)) { BuildTracker buildTracker = new BuildTracker(buildTargets); Transpile(build, buildTracker, buildTargetsAdvanced, threadsNumber); if (writeTranspiledFilesAndCompile) { WriteTranspiled(buildTargetsAdvanced, buildTracker); } } if (writeTranspiledFilesAndCompile) { PrepareWorkspace(build, buildTargets); Compile(build, buildTargetsSimple); Console.WriteLine("Build Complete"); } }
private BuildTarget GetBuildTarget(string targetName) { if (this.buildTargets.GetByNameOrNull(targetName) == null) { this.buildTargets.Add(BuildTargetFactory.Get(targetName, this.build, buildLogServices)); } BuildTarget result = this.buildTargets.GetByName(targetName); return(result); }
public static void Write() { TES4Collection collection = TES4CollectionFactory.CreateForQUSTReferenceAliasExporting(DataDirectory.GetESMDirectoryPath(), DataDirectory.TES4GameFileName); BuildTarget qfBuildTarget = BuildTargetFactory.Construct(BuildTargetFactory.QFName, new Build(DataDirectory.GetBuildPath())); string sourcePath = qfBuildTarget.GetSourcePath(); IEnumerable <TES4Record> qustRecords = collection.GetGrupRecords(TES4RecordType.QUST); foreach (TES4Record qust in qustRecords) { Write(sourcePath, qust); } }
public void Execute(string targets, string?buildPath = null) { if (!PreExecutionChecks(false, true, false, false)) { return; } if (buildPath == null) { buildPath = Build.DEFAULT_BUILD_PATH; } Build build = new Build(buildPath); BuildTarget[] buildTargets = BuildTargetFactory.ParseCollection(targets, build); buildTargets.DeleteBuildFiles(); Console.WriteLine("Deletion Complete"); }
public void Execute(string targets, string buildPath = null) { PreExecutionChecks(false, false, false, false); if (buildPath == null) { buildPath = Build.DEFAULT_BUILD_PATH; } Build build = new Build(buildPath); using (BuildLogServices buildLogServices = new BuildLogServices(build)) { BuildTargetCollection buildTargets = BuildTargetFactory.GetCollection(targets, build, buildLogServices, false); buildTargets.DeleteBuildFiles(); } Console.WriteLine("Deletion Complete"); }
public static void Write() { BuildTarget qfBuildTarget = BuildTargetFactory.Construct(BuildTargetFactory.QFName, new Build(DataDirectory.GetBuildPath())); string sourcePath = qfBuildTarget.GetSourcePath(); TES4Collection collection = TES4CollectionFactory.CreateForQUSTStageMapExportingFromESM(DataDirectory.GetESMDirectoryPath(), DataDirectory.TES4GameFileName); IEnumerable <TES4Record> qusts = collection.GetGrupRecords(TES4RecordType.QUST); foreach (TES4Record qust in qusts) { string fileNameNoExt = BuildTargetsWriter.GetFileNameNoExt(TES5ReferenceFactory.qf_Prefix, qust, true, null); string fileName = fileNameNoExt + ".map"; string mapFilePath = sourcePath + Path.DirectorySeparatorChar + fileName; string contentsString = StageMapFromESMBuilder.BuildString(qust); FileWriter.WriteAllTextOrThrowIfExists(mapFilePath, contentsString); } }
public static void Write() { BuildTarget qfBuildTarget = BuildTargetFactory.Construct(BuildTargetFactory.QFName, new Build(DataDirectory.GetBuildPath())); string transpiledPath = qfBuildTarget.GetTranspiledPath(); string sourcePath = qfBuildTarget.GetSourcePath(); foreach (string pscPath in Directory.EnumerateFiles(transpiledPath, "*.psc")) { Write(sourcePath, pscPath); } TES4Collection collection = TES4CollectionFactory.CreateForQUSTStageMapExportingFromPSCFiles(DataDirectory.GetESMDirectoryPath(), DataDirectory.TES4GameFileName); IEnumerable <TES4Record> qustRecords = collection.GetGrupRecords(TES4RecordType.QUST); foreach (TES4Record qust in qustRecords) { string path = sourcePath + BuildTargetsWriter.GetFileNameNoExt(TES5ReferenceFactory.qf_Prefix, qust, true, null) + ".map2"; FileWriter.WriteAllTextIfNotExists(path, ""); } }
public void Execute(string scriptName, string targets = BuildTarget.DEFAULT_TARGETS, string buildPath = null) { if (!PreExecutionChecks(true, true, true, true)) { return; } if (buildPath == null) { buildPath = Build.DEFAULT_BUILD_PATH; } Build build = new Build(buildPath); using (BuildLogServices buildLogServices = new BuildLogServices(build)) { BuildTargetCollection buildTargets = BuildTargetFactory.GetCollection(targets, build, buildLogServices); if (!buildTargets.CanBuildAndWarnIfNot()) { return; } TranspileScriptJob transpileJob = new TranspileScriptJob(buildTargets, scriptName); #if !DEBUG try { #endif transpileJob.Run(); #if !DEBUG } catch (ConversionException ex) { Console.WriteLine("Exception occured." + Environment.NewLine + ex.GetType().FullName + ": " + ex.Message); return; } #endif PrepareWorkspace(buildTargets); Compile(build, buildTargets); } Console.WriteLine("Build Complete"); string compileLog = File.ReadAllText(build.GetCompileStandardOutputPath()); Console.WriteLine(compileLog); }
public void Run() { Build build = null;//WTM: Change: BuildTargetFactory.get takes two arguments, but in PHP, it was invoked with one argument. This file will fail to run. using (BuildLogServices buildLogServices = new BuildLogServices(build)) { BuildTarget buildTarget = BuildTargetFactory.Get(this.buildTarget, build, buildLogServices); int latestBuild = Directory.EnumerateFileSystemEntries(buildTarget.GetArchivePath()) .Select(path => Path.GetFileName(path)) .Select(name => { int fileBuild; return(int.TryParse(name, out fileBuild) ? fileBuild : 0); }) .Max(); int archivedBuild = latestBuild + 1; Directory.CreateDirectory(buildTarget.GetArchivedBuildPath(archivedBuild)); //WTM: Change: buildTarget.getBuildPath() is not a valid method. string sourcePath = null;//buildTarget.getBuildPath() string destinationPath = buildTarget.GetArchivedBuildPath(archivedBuild); FileTransfer.CopyDirectoryFiles(sourcePath, destinationPath, false); } Process.Start("clean.sh", this.buildTarget); }
public override void Execute() { if (!PreExecutionChecks(false, true, false, false)) { return; } Build build = new Build(Build.DEFAULT_BUILD_PATH); BuildTarget buildTarget = BuildTargetFactory.Construct(BuildTargetFactory.QFName, build); bool preprocessed; Dictionary <int, List <int> > originalStageMap = StageMapFromMAPBuilder.BuildStageMapDictionary(buildTarget, "QF_FGC01Rats_01035713", out preprocessed); StageMap stageMap = new StageMap(originalStageMap.ToDictionary(m => m.Key, m => m.Value.ToList()), preprocessed);//Copy dictionary StringBuilder output = new StringBuilder(StageMapToMAPBuilder.GetContents(stageMap, originalStageMap)); output.Append("Mapping index print"); foreach (var kvp in stageMap.MappedTargetsIndex) { var originalTargetIndex = kvp.Key; var mappedTargetIndexes = kvp.Value; output.AppendLine(); output.Append(originalTargetIndex + " - " + string.Join(" ", mappedTargetIndexes)); } string outputString = output.ToString(); Console.WriteLine(outputString); const string fgc01RatsResultFromPHP = @"10 - 0 0 0 1 10 - 0 0 0 1 0 0 0 0 0 0 20 - 1 0 0 0 20 - 1 0 0 0 0 0 0 0 0 0 30 - 0 0 0 1 30 - 0 0 0 0 1 0 0 0 0 0 40 - 0 0 1 0 40 - 0 0 1 0 0 0 0 0 0 0 50 - 0 0 1 0 50 - 0 0 1 0 0 0 0 0 0 0 55 - 0 0 0 1 55 - 0 0 0 0 0 1 0 0 0 0 60 - 1 0 0 0 60 - 0 0 0 0 0 0 1 0 0 0 65 - 0 0 0 1 65 - 0 0 0 0 0 0 0 1 0 0 70 - 0 1 0 0 70 - 0 1 0 0 0 0 0 0 0 0 80 - 0 1 0 0 80 - 0 1 0 0 0 0 0 0 0 0 90 - 0 0 0 1 90 - 0 0 0 0 0 0 0 0 1 0 100 - 0 0 0 0 100 - 0 0 0 0 0 0 0 0 0 0 105 - 0 1 0 0 105 - 0 0 0 0 0 0 0 0 0 1 110 - 0 0 0 0 110 - 0 0 0 0 0 0 0 0 0 0 200 - 0 0 0 0 200 - 0 0 0 0 0 0 0 0 0 0 Mapping index print 3 - 4 5 7 8 0 - 6 1 - 9"; bool match = fgc01RatsResultFromPHP.Replace("\r\n", "\n") == outputString.Replace("\r\n", "\n"); Console.WriteLine("Output " + (match ? "matched" : "did not match") + " the output of the PHP version."); }
public override void Execute() { if (!PreExecutionChecks(false, false, false, false)) { return; } Build build = new Build(Build.DEFAULT_BUILD_PATH); Dictionary <int, List <int> > originalStageMap; using (BuildLogServices buildLogServices = new BuildLogServices(build)) { BuildTarget buildTarget = BuildTargetFactory.Get(BuildTarget.BUILD_TARGET_QF, build, buildLogServices); originalStageMap = QFFragmentFactory.BuildStageMapDictionary(buildTarget, "QF_FGC01Rats_01035713"); } StageMap stageMap = new StageMap(originalStageMap.ToDictionary(m => m.Key, m => m.Value.ToList()));//Copy dictionary StringBuilder output = new StringBuilder(); foreach (var stageId in stageMap.StageIDs) { output.AppendLine(stageId.ToString() + " - " + string.Join(" ", originalStageMap[stageId])); output.Append(stageId.ToString() + " -"); List <int> map = stageMap.GetStageTargetsMap(stageId); foreach (var val in map) { output.Append(" " + val); } output.AppendLine(); } output.Append("Mapping index print"); foreach (var kvp in stageMap.MappedTargetsIndex) { var originalTargetIndex = kvp.Key; var mappedTargetIndexes = kvp.Value; output.AppendLine(); output.Append(originalTargetIndex + " - " + string.Join(" ", mappedTargetIndexes)); } string outputString = output.ToString(); Console.WriteLine(outputString); const string fgc01RatsResultFromPHP = @"10 - 0 0 0 1 10 - 0 0 0 1 0 0 0 0 0 0 20 - 1 0 0 0 20 - 1 0 0 0 0 0 0 0 0 0 30 - 0 0 0 1 30 - 0 0 0 0 1 0 0 0 0 0 40 - 0 0 1 0 40 - 0 0 1 0 0 0 0 0 0 0 50 - 0 0 1 0 50 - 0 0 1 0 0 0 0 0 0 0 55 - 0 0 0 1 55 - 0 0 0 0 0 1 0 0 0 0 60 - 1 0 0 0 60 - 0 0 0 0 0 0 1 0 0 0 65 - 0 0 0 1 65 - 0 0 0 0 0 0 0 1 0 0 70 - 0 1 0 0 70 - 0 1 0 0 0 0 0 0 0 0 80 - 0 1 0 0 80 - 0 1 0 0 0 0 0 0 0 0 90 - 0 0 0 1 90 - 0 0 0 0 0 0 0 0 1 0 100 - 0 0 0 0 100 - 0 0 0 0 0 0 0 0 0 0 105 - 0 1 0 0 105 - 0 0 0 0 0 0 0 0 0 1 110 - 0 0 0 0 110 - 0 0 0 0 0 0 0 0 0 0 200 - 0 0 0 0 200 - 0 0 0 0 0 0 0 0 0 0 Mapping index print 3 - 4 5 7 8 0 - 6 1 - 9"; bool match = fgc01RatsResultFromPHP.Replace("\r\n", "\n") == outputString.Replace("\r\n", "\n"); Console.WriteLine("Output " + (match ? "matched" : "did not match") + " the output of the PHP version."); }
public void Execute(string targets) { if (!PreExecutionChecks(true, true, false, false)) { return; } Directory.CreateDirectory(DataDirectory.GetGraphDirectoryPath()); Build build = new Build(Build.DEFAULT_BUILD_PATH); //This argument might well not be important in this case BuildTarget[] buildTargets = BuildTargetFactory.ParseCollection(targets, build); BuildTargetSimple[] buildTargetsSimple = BuildTargetFactory.GetCollection(buildTargets); ProgressWriter? progressWriter = null; Dictionary <string, List <string> > dependencyGraph = new Dictionary <string, List <string> >(); Dictionary <string, List <string> > usageGraph = new Dictionary <string, List <string> >(); using (ESMAnalyzer esmAnalyzer = ESMAnalyzer.Load()) { progressWriter = new ProgressWriter("Building Interoperable Compilation Graph", buildTargets.GetTotalSourceFiles()); BuildSourceFilesCollection <BuildTargetSimple> sourceFiles = buildTargetsSimple.GetSourceFiles(); using (StreamWriter errorLog = new StreamWriter(TES5ScriptDependencyGraph.ErrorLogPath, false)) { using (StreamWriter debugLog = new StreamWriter(TES5ScriptDependencyGraph.DebugLogPath, false)) { foreach (var kvp in sourceFiles) { BuildTargetSimple buildTarget = kvp.Key; var sourceBuildFiles = kvp.Value; foreach (var sourceFile in sourceBuildFiles) { string scriptName = sourceFile.Substring(0, sourceFile.Length - 4);//remove extension string source = buildTarget.GetSourceFromPath(scriptName); ITES4CodeFilterable ast; try { ast = buildTarget.GetAST(source); } catch (EOFOnlyException) { continue; }//Ignore files that are only whitespace or comments. /*catch (UnexpectedTokenException ex) * {//UnexpectedTokenExceptions no longer occur, so this code should not be invoked. * errorLog.WriteLine(sourceFile + ": " + ex.Message + Environment.NewLine); * continue; * }*/ List <TES4ObjectProperty> propertiesAccesses = new List <TES4ObjectProperty>(); ast.Filter((data) => { TES4ObjectProperty?property = data as TES4ObjectProperty; if (property == null) { return(false); } propertiesAccesses.Add(property); return(true); }); Dictionary <string, ITES5Type> preparedProperties = new Dictionary <string, ITES5Type>(); foreach (var property in propertiesAccesses) { Match match = TES5ReferenceFactory.ReferenceAndPropertyNameRegex.Match(property.StringValue); string propertyName = match.Groups[1].Value; string propertyKeyName = propertyName.ToLower(); preparedProperties.AddIfNotContainsKey(propertyKeyName, () => esmAnalyzer.GetScriptTypeByEDID(propertyName)); } debugLog.WriteLine(scriptName + " - " + preparedProperties.Count + " prepared"); string lowerScriptType = scriptName.ToLower(); foreach (var kvp2 in preparedProperties) { var preparedPropertyKey = kvp2.Key; string propertyTypeName = preparedProperties[preparedPropertyKey].OriginalName; //Only keys are lowercased. string lowerPropertyType = propertyTypeName.ToLower(); dependencyGraph.AddNewListIfNotContainsKeyAndAddValueToList(lowerPropertyType, lowerScriptType); usageGraph.AddNewListIfNotContainsKeyAndAddValueToList(lowerScriptType, lowerPropertyType); debugLog.WriteLine("Registering a dependency from " + scriptName + " to " + propertyTypeName); } progressWriter.IncrementAndWrite(); } } } } } progressWriter.Write("Saving"); TES5ScriptDependencyGraph graph = new TES5ScriptDependencyGraph(dependencyGraph, usageGraph); buildTargets.WriteGraph(graph); progressWriter.WriteLast(); }
public void Execute(string targets) { if (!PreExecutionChecks(true, true, false, false)) { return; } Directory.CreateDirectory(DataDirectory.GetGraphDirectoryPath()); Build build = new Build(Build.DEFAULT_BUILD_PATH); //This argument might well not be important in this case using (BuildLogServices buildLogServices = new BuildLogServices(build)) { BuildTargetCollection buildTargets = BuildTargetFactory.GetCollection(targets, build, buildLogServices); //if (!buildTargets.CanBuildAndWarnIfNot()) { return; }//WTM: Change: This doesn't matter for building graphs. Dictionary <string, List <string> > dependencyGraph = new Dictionary <string, List <string> >(); Dictionary <string, List <string> > usageGraph = new Dictionary <string, List <string> >(); BuildSourceFilesCollection sourceFiles = buildTargets.GetSourceFiles(); ProgressWriter progressWriter = new ProgressWriter("Building Interoperable Compilation Graph", buildTargets.GetTotalSourceFiles()); TES5TypeInferencer inferencer = new TES5TypeInferencer(new ESMAnalyzer(), BuildTarget.StandaloneSourcePath); using (StreamWriter errorLog = new StreamWriter(TES5ScriptDependencyGraph.ErrorLogPath, false)) { using (StreamWriter debugLog = new StreamWriter(TES5ScriptDependencyGraph.DebugLogPath, false)) { foreach (var kvp in sourceFiles) { var buildTargetName = kvp.Key; var sourceBuildFiles = kvp.Value; BuildTarget buildTarget = buildTargets.GetByName(buildTargetName); foreach (var sourceFile in sourceBuildFiles) { string scriptName = sourceFile.Substring(0, sourceFile.Length - 4); ITES4CodeFilterable AST; try { AST = buildTarget.GetAST(buildTarget.GetSourceFromPath(scriptName)); } catch (EOFOnlyException) { continue; }//Ignore files that are only whitespace or comments. /*catch (UnexpectedTokenException ex) * {//Exceptions no longer occur, so this code should not be invoked. * errorLog.WriteLine(sourceFile + ": " + ex.Message + Environment.NewLine); * continue; * }*/ List <TES4ObjectProperty> propertiesAccesses = new List <TES4ObjectProperty>(); AST.Filter((data) => { TES4ObjectProperty property = data as TES4ObjectProperty; if (property == null) { return(false); } propertiesAccesses.Add(property); return(true); }); Dictionary <string, TES5Property> preparedProperties = new Dictionary <string, TES5Property>(); Dictionary <string, ITES5Type> preparedPropertiesTypes = new Dictionary <string, ITES5Type>(); foreach (var property in propertiesAccesses) { Match match = TES5ReferenceFactory.PropertyNameRegex.Match(property.StringValue); string propertyName = match.Groups[1].Value; string propertyKeyName = propertyName.ToLower(); bool containedKey; TES5Property preparedProperty = preparedProperties.GetOrAdd(propertyKeyName, () => new TES5Property(propertyName, TES5BasicType.T_FORM, propertyName), out containedKey); ITES5Type inferencingType = inferencer.ResolveInferenceTypeByReferenceEdid(preparedProperty); if (!containedKey) { preparedPropertiesTypes.Add(propertyKeyName, inferencingType); } else { if (!inferencingType.Equals(preparedPropertiesTypes[propertyKeyName])) { throw new ConversionException("Cannot settle up the properties types - conflict."); } } } debugLog.WriteLine(scriptName + " - " + preparedProperties.Count + " prepared"); string lowerScriptType = scriptName.ToLower(); foreach (var kvp2 in preparedProperties) { var preparedPropertyKey = kvp2.Key; var preparedProperty = kvp2.Value; string propertyTypeName = preparedPropertiesTypes[preparedPropertyKey].OriginalName; //Only keys are lowercased. string lowerPropertyType = propertyTypeName.ToLower(); dependencyGraph.AddNewListIfNotContainsKeyAndAddValueToList(lowerPropertyType, lowerScriptType); usageGraph.AddNewListIfNotContainsKeyAndAddValueToList(lowerScriptType, lowerPropertyType); debugLog.WriteLine("Registering a dependency from " + scriptName + " to " + propertyTypeName); } progressWriter.IncrementAndWrite(); } } } } progressWriter.Write("Saving"); TES5ScriptDependencyGraph graph = new TES5ScriptDependencyGraph(dependencyGraph, usageGraph); buildTargets.WriteGraph(graph); progressWriter.WriteLast(); } }