GenMap: Commander.CommandProc = {
[cmd: Handle] RETURNS [result: REF ← NIL, msg: ROPE ← NIL]
ris: STREAM = IO.RIS[cmd.commandLine];
token: ROPE ← "CurrentCedar";
dump: BOOL ← TRUE;
dumpDebug: BOOL ← TRUE;
namesOnly: BOOL ← FALSE;
remoteOpened: BOOL ← FALSE;
pos,bang,dot: INT ← 0;
inName,sourceName,objectName,outPrefix: ROPE ← NIL;
command: ROPE ← cmd.command;
forkers: NAT ← 0;
results: GenerateDFClosure.ClosureInfo;
myData: MyData;
sourceMap: Map ← NIL;
objectMap: Map ← NIL;
checkRemote: BOOL ← TRUE;
inLog,outLog: STREAM ← NIL;
genMaps: BOOL ← FALSE; -- gen regular version maps if TRUE
trustOld: BOOL ← FALSE; -- trust old version maps if TRUE
prefix: ROPE ← NIL; -- the first prefix seen
oldPath: ROPE ← DefaultRemoteNames.Get[].previous; -- the previous release
token ← IO.GetTokenRope[ris, IO.IDProc ! IO.EndOfStream => CONTINUE].token;
[pos,bang,dot] ← ScanName[inName ← token];
IF bang = Rope.Size[inName]
-- no version stuff
AND (bang-dot # 3 OR Rope.Run[inName, dot, ".df", 0, FALSE] # 3) -- no DF extension
THEN inName ← Rope.Concat[token, ".df"];
inName ←
FS.FileInfo[inName
!
FS.Error =>
IF error.group # bug
THEN {
IO.PutF[
cmd.out, "\nCan't open %g\n %g\n",
[rope[inName]], [rope[error.explanation]]];
GO TO quit;
};
].fullFName;
[inLog,outLog] ← ViewerIO.CreateViewerStreams[
"VersionMapBuilder.log", NIL, "VersionMapBuilder.log", FALSE];
[pos,bang,dot] ← ScanName[inName];
outPrefix ← Rope.Flatten[inName, pos, dot-pos];
IO.PutF[outLog, "\nVersion Map Builder started at %g", [time[BasicTime.Now[]]]];
IO.PutF[outLog, "\n\nInput from: %g\n", [rope[inName]]];
sourceName ← Rope.Concat[outPrefix, ".sourceMap"];
objectName ← Rope.Concat[outPrefix, ".symbolsMap"];
TRUSTED {IFSFile.Initialize[]};
{
ENABLE
UNWIND => {
FinalizeRemoteHandle[myData];
};
SELECT cmd.procData.clientData
FROM
$GenMap => {
forkers ← 2;
genMaps ← TRUE;
};
$MergeMap => {
forkers ← 2;
trustOld ← genMaps ← TRUE;
};
$GenCedarMap => {
forkers ← 2;
genMaps ← TRUE;
outPrefix ← "Cedar";
};
$MergeCedarMap => {
forkers ← 2;
trustOld ← genMaps ← TRUE;
outPrefix ← "Cedar";
};
ENDCASE;
myData ←
NEW[MyDataRep ← [
sourceQueue: PriorityQueue.Predict[2000, EntrySortPred],
objectQueue: PriorityQueue.Predict[1500, EntrySortPred],
errs: outLog,
checkRemote: checkRemote
]];
SELECT cmd.procData.clientData
FROM
$GenCedarMap, $MergeCedarMap =>
myData.warningMatch ← Rope.Concat[oldPath, "*.df*"];
ENDCASE;
IF genMaps
THEN {
sourceName ← Rope.Concat[outPrefix, "Source.VersionMap"];
objectName ← Rope.Concat[outPrefix, "Symbols.VersionMap"];
};
IF trustOld
THEN {
Setup the old maps (if any); also make an index for the object map.
IO.PutRope[outLog, "\nReading old maps."];
myData.oldSourceMap ←
LIST[
VersionMap.RestoreMapFromFile[sourceName
!
FS.Error => {
IO.PutRope[outLog, "\nWarning, can't read "];
IO.PutRope[outLog, sourceName];
CONTINUE}]
];
myData.oldObjectMap ←
LIST[
VersionMap.RestoreMapFromFile[objectName
!
FS.Error => {
IO.PutRope[outLog, "\nWarning, can't read "];
IO.PutRope[outLog, objectName];
GO TO exit}]
];
EXITS exit => {};
};
CheckAbort[myData];
myData.which ← both;
IO.PutRope[outLog, "\nGenerating DF closure."];
results ← GenerateDFClosure.GenerateClosureToProc[
inName, outLog, EachFile, myData, [toFork: forkers]];
};
FinalizeRemoteHandle[myData];
IO.PutF[outLog, "\n\n%g DF files, %g source files, %g object files.\n",
[integer[results.dfFiles]], [integer[myData.sourceFiles]], [integer[myData.objectFiles]]];
IO.PutRope[outLog, "\nPrefixes seen:"];
FOR each: RopeList ← myData.prefixList, each.rest
WHILE each #
NIL
DO
IF prefix = NIL THEN prefix ← each.first;
IO.PutF[outLog, "\n %g", [rope[each.first]]];
ENDLOOP;
IO.PutRope[outLog, "\n\nMaking short name index for source map."];
sourceMap ← VersionMapFromPQ[myData.sourceQueue, prefix, myData];
CheckAbort[myData];
IO.PutRope[outLog, "\n\nWriting "];
IO.PutRope[outLog, sourceName];
IO.PutRope[outLog, "\n"];
IF genMaps
THEN VersionMap.SaveMapToFile[sourceMap, sourceName]
ELSE WriteMapToFile[sourceMap, sourceName];
IO.PutRope[outLog, "\nMaking short name index for object map."];
objectMap ← VersionMapFromPQ[myData.objectQueue, prefix, myData];
CheckAbort[myData];
IO.PutRope[outLog, "\n\nWriting "];
IO.PutRope[outLog, objectName];
IO.PutRope[outLog, "\n"];
IF genMaps
THEN VersionMap.SaveMapToFile[objectMap, objectName]
ELSE WriteMapToFile[objectMap, objectName];
IO.PutF[outLog, "\n\nVersion maps built at %g\n\n", [time[BasicTime.Now[]]]];
IO.Close[inLog];
IO.Close[outLog];
EXITS quit => {};
};