/// <inheritdoc /> protected override void WriteEnd() { var environmentVariablesString = string.Join(", ", AllowedEnvironmentVariables.Select(DScriptWriterUtils.EncloseInDoubleQuotes)); Writer.WriteLine( @"config({ projects: [], modules: [f`package.dsc`], resolvers: Environment.getPathValues(""ScriptSdk"", "";"").map(path => <SourceResolver>{ kind: ""SourceResolver"", root: d`${path}` }),"); Writer.WriteLine(" allowedEnvironmentVariables: [{0}],", environmentVariablesString); Writer.WriteLine(" mounts: ["); foreach (var mountPoint in m_mountPoints) { Writer.WriteLine(" {"); Writer.WriteLine(" name: PathAtom.create(\"{0}\"),", mountPoint.Key); Writer.WriteLine(" path: {0}, ", DScriptWriterUtils.ToPath(mountPoint.Value, PathType.Path)); Writer.WriteLine(" trackSourceFileChanges: true, "); Writer.WriteLine(" isReadable: true, "); Writer.WriteLine(" isWritable: true, "); Writer.WriteLine(" isSystem: false "); Writer.WriteLine(" },"); } Writer.WriteLine(" ]"); Writer.WriteLine(@"});"); }
/// <inheritdoc /> public override void AddMimicInvocation( string outputValue, IEnumerable <string> sealDirectoryInputs, IEnumerable <string> pathInputs, IEnumerable <MimicFileOutput> outputs, string observedAccessesPath, IEnumerable <SemaphoreInfo> semaphores, int runTimeInMs, bool isLongestProcess = false) { string mimicName = ToMimicRunnerVarName(outputValue); m_runners.Add(mimicName); m_writer.WriteLine("export const {0} = Mimic.evaluate({{", mimicName); m_writer.WriteLine(" processRunningTime: {0},", runTimeInMs); m_writer.WriteLine(" isLongestProcess: {0},", isLongestProcess.ToString().ToLower(CultureInfo.CurrentCulture)); if (observedAccessesPath != null) { m_writer.WriteLine(" observedAccesses: {0},", DScriptWriterUtils.ToPath(observedAccessesPath, PathType.Path)); m_writer.WriteLine(" observedAccessesRoot: {0},", "p`/RootMarker.dummy`.parent"); } m_writer.WriteLine(" sealDirectoryInputs: ["); foreach (var sealDirectory in sealDirectoryInputs) { m_writer.WriteLine(" {0},", IfStringThenToPath(sealDirectory, PathType.Directory)); } m_writer.WriteLine(" ],"); m_writer.WriteLine(" fileInputs: ["); foreach (var pathInput in pathInputs) { m_writer.WriteLine(" {0},", IfStringThenToPath(pathInput, PathType.File)); } m_writer.WriteLine(" ],"); m_writer.WriteLine(" fileOutputs: ["); foreach (var output in outputs) { m_writer.WriteLine(" {"); m_writer.WriteLine(" path: {0},", IfStringThenToPath(output.Path, PathType.Path)); m_writer.WriteLine(" repeatingContent: \"{0}\",", output.RepeatingContent); m_writer.WriteLine(" lengthInBytes: {0},", output.LengthInBytes); m_writer.WriteLine(" fileId: {0}", output.FileId); m_writer.WriteLine(" }, "); } m_writer.WriteLine(" ],"); m_writer.WriteLine(" semaphores: ["); foreach (var semaphore in semaphores) { m_writer.WriteLine(" {"); m_writer.WriteLine(" name: {0},", semaphore.Name); m_writer.WriteLine(" value: \"{0}\",", semaphore.Value); m_writer.WriteLine(" limit: {0},", semaphore.Limit); m_writer.WriteLine(" }, "); } m_writer.WriteLine(" ],"); // TODO: need to plumb this stuff through to DScript m_writer.WriteLine("});"); }
/// <summary> /// If given 'expr' is quoted (<see cref="IsStringExpression"/>), the expression is converted /// to path (<see cref="ToPath"/>); otherwise, the expression is returned. /// </summary> private static string IfStringThenToPath(string expression, PathType type) { return(DScriptWriterUtils.IsStringExpression(expression) ? DScriptWriterUtils.ToPath(expression, type) : expression); }