DIRECTORY BasicTime USING [GMT, Period], FileNames USING [GetShortName], FS USING [ComponentPositions, Error, ExpandName, FileInfo, StreamOpen], IO USING [EndOfStream, GetLineRope, GetTokenRope, IDProc, PutFR, RIS, STREAM], MakeDo USING [ActionClass, ActionClassRep, ActionDep, AddFinder, ConsistencyChecker, fileClass, FinderProc, From, GetNode, InnerEnumerateSources, InnerGetCreated, Node, notExistTime, PublicPartsOfAction, PublicPartsOfNode, RederiveProc, Time], Rope USING [Cat, Concat, Fetch, Length, Match, ROPE, Substr], SummonerLoadDeps USING [], SymTab USING [Create, EachPairAction, Pairs, Ref, Store], VersionMap USING [MapAndNameList, MapList, ShortNameToNames], VersionMapDefaults USING [GetMapList]; SummonerLoadDepsImpl: CEDAR PROGRAM IMPORTS BasicTime, FileNames, FS, IO, MakeDo, Rope, SymTab, VersionMap, VersionMapDefaults EXPORTS SummonerLoadDeps ~ BEGIN OPEN SummonerLoadDeps; ROPE: TYPE = Rope.ROPE; SummonerLoadData: TYPE ~ RECORD [ summonerInstallFile, summonerInstallRoot: ROPE ]; summonerLoadClass: MakeDo.ActionClass _ NEW[MakeDo.ActionClassRep _ [ CheckConsistency: CheckSummonerLoadConsistency, Rederive: RederiveSummonerLoad ]]; SummonerLoadFind: MakeDo.FinderProc = { summonerLoadData: REF SummonerLoadData; summonerInstallName: ROPE; cp: FS.ComponentPositions; IF ~ Rope.Match[pattern: "*.summonerLoad", object: resultName, case: FALSE] THEN GOTO Fail; --This is all we know how to build [resultName, cp,] _ FS.ExpandName[name: resultName ! FS.Error => GOTO Fail]; summonerInstallName _ WithoutVersion[FS.FileInfo[name: Rope.Substr[base: resultName, len: cp.base.start+cp.base.length].Concat[".summonerInstall"] ! FS.Error => GOTO Fail].fullFName]; foundData _ summonerLoadData _ NEW[SummonerLoadData _ [ summonerInstallFile: summonerInstallName, summonerInstallRoot: Rope.Substr[base: resultName, start: cp.base.start, len: cp.base.length] ]]; from _ DeriveFrom[summonerLoadData]; cmdFrom _ LIST[MakeDo.GetNode[someName: summonerInstallName, class: MakeDo.fileClass]]; makes _ LIST[sought _ MakeDo.GetNode[someName: resultName, class: MakeDo.fileClass]]; cmd _ DeriveCmd[summonerLoadData]; class _ summonerLoadClass; found _ TRUE; EXITS Fail => { found _ FALSE; sought _ NIL; }; }; WithoutVersion: PROC [with: ROPE] RETURNS [without: ROPE] ~ { cp: FS.ComponentPositions; [fullFName: without, cp: cp] _ FS.ExpandName[name: with]; without _ Rope.Substr[base: without, len: cp.ext.start+cp.ext.length]; }; DeriveCmd: PROC [summonerLoadData: REF SummonerLoadData] RETURNS [cmd: ROPE] ~ { RETURN [Rope.Cat["RederiveSummonerLoad ", summonerLoadData.summonerInstallRoot]]; }; DeriveFrom: PROC [summonerLoadData: REF SummonerLoadData] RETURNS [from: MakeDo.From] ~ { PutFilesInFromList: SymTab.EachPairAction = { from.mustHave _ CONS[MakeDo.GetNode[someName: key, class: MakeDo.fileClass], from.mustHave]; RETURN [FALSE] }; Install: PROC [module, file: ROPE] ~ { [] _ SymTab.Store[x: x, key: file, val: NIL]; }; s: IO.STREAM _ FS.StreamOpen[fileName: summonerLoadData.summonerInstallFile]; x: SymTab.Ref ~ SymTab.Create[case: FALSE]; from _ [mustHave: LIST[MakeDo.GetNode[someName: FS.ExpandName[name: summonerLoadData.summonerInstallFile].fullFName, class: MakeDo.fileClass]], optional: NIL]; RecurseThroughInstall[file: summonerLoadData.summonerInstallFile, install: Install, run: NIL, other: NIL, recurseVMap: FALSE ! CantFind => {Install[module: module, file: FileNames.GetShortName[path: full]]; RESUME}]; [] _ SymTab.Pairs[x: x, action: PutFilesInFromList]; }; ForceConsistencyReturn: ERROR [setConsistent: BOOL, setReason: ROPE] ~ CODE; CheckSummonerLoadConsistency: MakeDo.ConsistencyChecker = { ingredientFound: BOOL _ FALSE; PerIngredient: PROC [n: MakeDo.Node, which: MakeDo.ActionDep, optional: BOOL] ~ { nodeTime: BasicTime.GMT _ MakeDo.InnerGetCreated[n]; IF nodeTime = MakeDo.notExistTime THEN RETURN; ingredientFound _ TRUE; IF resultExists AND BasicTime.Period[from: nodeTime, to: resultTime] < 0 THEN ERROR ForceConsistencyReturn[setConsistent: FALSE, setReason: IO.PutFR[format: "result %g (of %g) predates ingredient %g (of %g)", v1: [rope[resultName]], v2: [time[resultTime]], v3: [rope[MakeDo.PublicPartsOfNode[n: n].name]], v4: [time[nodeTime]] ]]; RETURN}; summonerLoadData: REF SummonerLoadData ~ NARROW[MakeDo.PublicPartsOfAction[a].foundData]; resultTime: MakeDo.Time = result.InnerGetCreated[]; resultName: ROPE = MakeDo.PublicPartsOfNode[n: result].name; resultExists: BOOL ~ resultTime # MakeDo.notExistTime; MakeDo.InnerEnumerateSources[a: a, which: data, to: PerIngredient ! ForceConsistencyReturn => { consistent _ setConsistent; reason _ setReason; GOTO Exit; }]; IF NOT ingredientFound THEN RETURN [TRUE, "no inputs exist to indicate inconsistency"]; IF NOT resultExists THEN RETURN [FALSE, "some inputs but no output exist"]; RETURN [consistent: TRUE, reason: "result dated later than any existing ingredient"]; EXITS Exit => a _ a; }; RederiveSummonerLoad: MakeDo.RederiveProc = { summonerLoadData: REF SummonerLoadData ~ NARROW[MakeDo.PublicPartsOfAction[a].foundData]; from _ DeriveFrom[summonerLoadData]; cmd _ DeriveCmd[summonerLoadData]; }; CantFind: PUBLIC SIGNAL [module, full: ROPE] ~ CODE; --Called by RecurseThroughInstall when it has to resort to a version map RecurseThroughInstall: PUBLIC PROC [file: ROPE, install: PROC [module, file: ROPE], run: PROC [package: ROPE], other: PROC [line: ROPE], checkVMap, recurseVMap: BOOL _ TRUE] ~ { stream: IO.STREAM ~ FS.StreamOpen[fileName: file]; DO line: ROPE ~ IO.GetLineRope[stream ! IO.EndOfStream => EXIT]; SELECT TRUE FROM Rope.Match[pattern: "install *", object: line, case: FALSE] => { s: IO.STREAM ~ IO.RIS[rope: line]; word: ROPE _ IO.GetTokenRope[stream: s, breakProc: IO.IDProc].token; DO attemptRecurse: BOOL _ TRUE; TryLocalDirectory: PROC [name: ROPE] RETURNS [succeeded: BOOL] ~ { file _ FS.FileInfo[name: name ! FS.Error => {file _ NIL; CONTINUE}].fullFName; RETURN [file#NIL] }; TryVersionMap: PROC [name: ROPE] RETURNS [succeeded: BOOL] ~ { IF ~checkVMap THEN RETURN [FALSE] ELSE { map: VersionMap.MapList ~ VersionMapDefaults.GetMapList[which: $Source]; manl: VersionMap.MapAndNameList ~ VersionMap.ShortNameToNames[list: map, shortName: name]; FOR each: VersionMap.MapAndNameList _ manl, each.rest UNTIL each=NIL DO file _ FS.FileInfo[name: each.first.name ! FS.Error => LOOP].fullFName; SIGNAL CantFind[word, each.first.name]; attemptRecurse _ recurseVMap; RETURN [TRUE]; ENDLOOP; RETURN [FALSE]; }; }; file: ROPE _ NIL; word _ IO.GetTokenRope[stream: s, breakProc: IO.IDProc ! IO.EndOfStream => EXIT].token; SELECT TRUE FROM TryLocalDirectory[Rope.Cat[word, ".load"]] => {}; TryLocalDirectory[Rope.Cat["Load", word, ".cm"]] => {}; TryVersionMap[Rope.Cat[word, ".load"]] => {}; TryVersionMap[Rope.Cat["Load", word, ".cm"]] => {}; ENDCASE => { short: ROPE ~ Rope.Cat[word, ".load"]; SIGNAL CantFind[module: word, full: FS.ExpandName[short].fullFName]; }; IF ~ Rope.Fetch[base: word]='- AND install#NIL THEN install[module: word, file: file]; IF file#NIL AND attemptRecurse THEN RecurseThroughInstall[file: file, install: install, run: run, other: other, checkVMap: checkVMap, recurseVMap: recurseVMap]; ENDLOOP; }; Rope.Match[pattern: "run *", object: line, case: FALSE] => { s: IO.STREAM ~ IO.RIS[rope: line]; word: ROPE _ IO.GetTokenRope[stream: s, breakProc: IO.IDProc].token; DO word _ IO.GetTokenRope[stream: s, breakProc: IO.IDProc ! IO.EndOfStream => EXIT].token; IF ~ Rope.Fetch[base: word]='- AND run#NIL THEN run[word]; ENDLOOP; }; ENDCASE => { IF line.Length[] > 0 AND other#NIL THEN other[line]; }; ENDLOOP; }; MakeDo.AddFinder[finder: [name: "SummonerLoad", finderProc: SummonerLoadFind], end: front]; END.  SummonerLoadDepsImpl.mesa Copyright c 1986 by Xerox Corporation. All rights reserved. Eric Nickell, September 30, 1986 4:22:14 pm PDT Mike Spreitzer February 9, 1987 2:37:09 pm PST JKF January 11, 1989 10:20:44 am PST Last tweaked by Mike Spreitzer on October 26, 1989 11:41:15 am PDT [resultName: ROPE, finderData: REF ANY] RETURNS [found: BOOLEAN, sought: MakeDo.Node, makes: MakeDo.NodeList, cmdFrom: MakeDo.NodeList, from: MakeDo.From, cmd: ROPE, class: MakeDo.ActionClass, foundData: REF ANY] [key: SymTab.Key, val: SymTab.Val] RETURNS [quit: BOOL] from.mustHave _ CONS[MakeDo.GetNode[someName: file, class: MakeDo.fileClass], from.mustHave]; [a: MakeDo.Action, result: MakeDo.Node] RETURNS [consistent: BOOL, reason: ROPE] [a: MakeDo.Action] RETURNS [from: MakeDo.From, cmd: ROPE] Κ£•NewlineDelimiter ™™Icodešœ Οmœ1™K–*[which: VersionMapDefaults.WhichMapList]šžœ žœžœžœ˜!šžœ˜K˜HK–/[list: VersionMap.MapList, shortName: ROPE]˜Zšžœ3žœžœž˜GK–b[name: ROPE, wantedCreatedTime: GMT _ nullGMT, remoteCheck: BOOL _ TRUE, wDir: ROPE _ NIL]šœžœ"žœ žœ ˜GKšžœ!˜'Kšœ˜Kšžœžœ˜Kšžœ˜—Kšžœžœ˜Kšœ˜—K˜—Kšœžœžœ˜K–-[stream: STREAM, breakProc: IO.BreakProc]š œžœ$žœ žœžœ˜W–b[name: ROPE, wantedCreatedTime: GMT _ nullGMT, remoteCheck: BOOL _ TRUE, wDir: ROPE _ NIL]šžœžœž˜Kšœ1˜1Kšœ7˜7Kšœ-˜-Kšœ3˜3šžœ˜ Kšœžœ˜&K–"[name: ROPE, wDir: ROPE _ NIL]šžœžœ˜DKšœ˜——K– [base: ROPE, index: INT _ 0]šžœžœ žœžœ#˜VKšžœžœžœžœ}˜ Kšžœ˜—Kšœ˜—–6[pattern: ROPE, object: ROPE, case: BOOL _ TRUE]šœ€œžœ˜