<> <> <> DIRECTORY BasicTime, FS, IO, MakeDo, Rope; LupineDeps: CEDAR PROGRAM IMPORTS BasicTime, FS, IO, MakeDo, Rope = BEGIN ROPE: TYPE = Rope.ROPE; LupineCommand: TYPE = REF LupineCommandRep; LupineCommandRep: TYPE = RECORD [ resultPrefix: ROPE, sourceNode, switchesNode: MakeDo.Node, earliestResultNode, lateIngredientNode: MakeDo.Node _ NIL, earliestResultTime, lateIngredientTime: BasicTime.GMT _ BasicTime.nullGMT, cmd: ROPE _ NIL]; lupineClass: MakeDo.CommandClass _ NEW [MakeDo.CommandClassRep _ [ NotCurrent: LupineNotCurrent, Rederive: RederiveLupine, Explain: ExplainLupine ]]; LupineFind: PROC [resultName: ROPE, finderData: REF ANY] RETURNS [found: BOOLEAN, sought: MakeDo.Node, makes: MakeDo.NodeList, from, cmdFrom: MakeDo.From, cmd: ROPE, class: MakeDo.CommandClass, foundData: REF ANY] -- MakeDo.FinderProc -- = BEGIN EndsIn: PROC [ending: ROPE] RETURNS [ans: BOOL] = { elen: INT = ending.Length[]; IF elen > slen THEN RETURN [FALSE]; IF (ans _ resultShort.Substr[start: slen - elen, len: elen].Equal[s2: ending, case: FALSE]) THEN {plen _ slen - elen; sending _ ending}}; Tail: PROC [ending: ROPE] RETURNS [node: MakeDo.Node] = { node _ MakeDo.GetNode[resultPrefix.Cat[ending], MakeDo.fileClass]; IF ending.Equal[sending] THEN sought _ node}; resultCP: FS.ComponentPositions; resultFull, resultPrefix, resultShort, interfaceName, sourceName, sending: ROPE; sourceNode, switchesNode: MakeDo.Node; lc: LupineCommand; slen, plen: INT; sought _ NIL; found _ TRUE; [resultFull, resultCP, ] _ FS.ExpandName[resultName !FS.Error => {found _ FALSE; CONTINUE}]; IF NOT found THEN RETURN; resultShort _ resultFull.Substr[start: resultCP.base.start, len: (resultCP.ext.start + resultCP.ext.length) - resultCP.base.start]; slen _ resultShort.Length[]; found _ EndsIn["RpcControl.Mesa"] OR EndsIn["RpcClientImpl.Mesa"] OR EndsIn["RpcBinderImpl.Mesa"] OR EndsIn["RpcServerImpl.Mesa"]; IF NOT found THEN RETURN; interfaceName _ resultShort.Substr[start: 0, len: plen]; resultPrefix _ resultFull.Substr[start: 0, len: resultCP.base.start].Concat[interfaceName]; cmdFrom _ [ mustHave: NIL, optional: LIST[ sourceNode _ MakeDo.GetNode[sourceName _ resultPrefix.Cat[".BCD"], MakeDo.fileClass], switchesNode _ MakeDo.GetNode[resultPrefix.Cat[".LupineSwitches"], MakeDo.fileClass] ] ]; foundData _ lc _ NEW [LupineCommandRep _ [ resultPrefix: resultPrefix, sourceNode: sourceNode, switchesNode: switchesNode, cmd: cmd _ IO.PutFR["Lupine %g TranslateInterface[%g]", IO.rope[GetSwitches[resultPrefix]], IO.rope[interfaceName]] ]]; makes _ LIST[ Tail["RpcControl.Mesa"], Tail["RpcClientImpl.Mesa"], Tail["RpcBinderImpl.Mesa"], Tail["RpcServerImpl.Mesa"]]; IF sought = NIL THEN ERROR; from _ DeriveFrom[lc]; class _ lupineClass; END; GetSwitches: PROC [resultPrefix: ROPE] RETURNS [switches: ROPE] = { ss: IO.STREAM _ NIL; ss _ FS.StreamOpen[resultPrefix.Cat[".LupineSwitches"] !FS.Error => CONTINUE]; IF ss = NIL THEN RETURN [NIL]; [] _ ss.SkipWhitespace[]; IF ss.EndOf[] THEN RETURN [NIL]; switches _ ss.GetLineRope[]; ss.Close[]; }; DeriveFrom: PROC [lc: LupineCommand] RETURNS [from: MakeDo.From] = BEGIN from _ [mustHave: LIST[lc.sourceNode], optional: NIL]; END; RederiveLupine: PROC [c: MakeDo.Command] RETURNS [from: MakeDo.From, cmd: ROPE] --MakeDo.RederiveProc-- = { lc: LupineCommand _ NARROW[c.PublicPartsOfCommand[].foundData]; from _ DeriveFrom[lc]; cmd _ lc.cmd}; LupineNotCurrent: PROC [c: MakeDo.Command, Needed: PROC [MakeDo.Node] RETURNS [BOOL]] RETURNS [whyNotCurrent: ROPE--NIL means all outputs up-to-date--] --MakeDo.NotCurrentProc-- = BEGIN lc: LupineCommand = NARROW[c.PublicPartsOfCommand[].foundData]; PerSource: PROC [n: MakeDo.Node, which: MakeDo.CmdDep, optional: BOOL] = { fromTime: BasicTime.GMT _ MakeDo.GetCreated[n]; IF (fromTime # MakeDo.notExistTime) AND (lc.lateIngredientTime.Period[fromTime] > 0) THEN { lc.lateIngredientTime _ fromTime; lc.lateIngredientNode _ n; }; }; PerResult: PROC [made: MakeDo.Node] = { thisTime: BasicTime.GMT; IF NOT Needed[made] THEN RETURN; thisTime _ MakeDo.GetCreated[made]; IF thisTime # MakeDo.notExistTime AND thisTime.Period[lc.earliestResultTime] > 0 THEN {lc.earliestResultTime _ thisTime; lc.earliestResultNode _ made}; }; whyNotCurrent _ NIL; lc.earliestResultTime _ BasicTime.latestGMT; lc.lateIngredientTime _ BasicTime.earliestGMT; lc.earliestResultNode _ lc.lateIngredientNode _ NIL; MakeDo.EnumerateResults[c, PerResult]; IF lc.earliestResultNode = NIL THEN RETURN; MakeDo.InnerEnumerateSources[c, data, PerSource]; IF (lc.lateIngredientTime # BasicTime.earliestGMT) AND (lc.lateIngredientTime.Period[lc.earliestResultTime] < 0) THEN { whyNotCurrent _ IO.PutFR[ "result %g (of %g) predates ingredient %g (of %g)", [rope[lc.earliestResultNode.PublicPartsOfNode[].name]], [time[lc.earliestResultTime]], [rope[lc.lateIngredientNode.PublicPartsOfNode[].name]], [time[lc.lateIngredientTime]] ]; }; END; ExplainLupine: PROC [c: MakeDo.Command, to: IO.STREAM] --MakeDo.ExplainProc-- = BEGIN lc: LupineCommand = NARROW[c.PublicPartsOfCommand[].foundData]; NeedAll: PROC [MakeDo.Node] RETURNS [BOOL] = {RETURN [TRUE]}; whyNotCurrent: ROPE _ LupineNotCurrent[c, NeedAll]; IF lc.earliestResultNode = NIL THEN to.PutRope["\tno result files exist.\n"] ELSE IF lc.lateIngredientNode = NIL THEN to.PutRope["\tno ingredients exist.\n"] ELSE IF whyNotCurrent # NIL THEN to.PutF["\t%g.\n", IO.rope[whyNotCurrent]] ELSE to.PutRope["\tall result files are dated later than any ingredient file.\n"]; END; MakeDo.AddFinder[["Lupine", LupineFind], back]; END.