Module("strategy/pack/modules",[Imports([Import("util/config/options"),Import("strategy/pack/graph"),Import("lang/dynamic-rules"),Import("util/config/common"),Import("util/config/verbose")]),Strategies([SDefNoArgs("pack-options",Choice(Call(SVar("ArgOption"),[Choice(StrCong("\"-I\""),StrCong("\"--Include\"")),Seq(Where(BA(CallNoArgs(SVar("extend-config")),NoAnnoList(Tuple([NoAnnoList(Str("\"-I\"")),NoAnnoList(List([NoAnnoList(Str("\"-I\"")),RootApp(Id)]))])))),Build(NoAnnoList(Tuple([])))),Build(NoAnnoList(Str("\"-I d | --Include d   Include modules from directory d\"")))]),Choice(Call(SVar("Option"),[Choice(StrCong("\"--nodep\""),StrCong("\"-nodep\"")),Seq(Where(BA(CallNoArgs(SVar("set-config")),NoAnnoList(Tuple([NoAnnoList(Str("\"-nodep\"")),NoAnnoList(Str("\"\""))])))),Build(NoAnnoList(Tuple([])))),Build(NoAnnoList(Str("\"--nodep              Don't create dependency file\"")))]),Call(SVar("ArgOption"),[Choice(StrCong("\"--dep\""),Choice(StrCong("\"-d\""),StrCong("\"-dep\""))),Seq(Where(BA(CallNoArgs(SVar("set-config")),NoAnnoList(Tuple([NoAnnoList(Str("\"-dep\"")),RootApp(Id)])))),Build(NoAnnoList(Tuple([])))),Build(NoAnnoList(Str("\"--dep f | -d f       Write dependency to file f\"")))])))),SDef("pack-modules",[VarDec("pack",FunType([FunType([ConstType(SortVar("term"))],ConstType(SortVar("term"))),ConstType(SortVar("term"))],ConstType(SortVar("term"))))],LChoice(Call(SVar("pack-modules"),[CallNoArgs(SVar("pack")),Fail]),BA(CallNoArgs(SVar("fatal-error")),NoAnnoList(List([NoAnnoList(Str("\"Packing modules failed\""))]))))),SDef("pack-modules",[VarDec("pack",FunType([FunType([ConstType(SortVar("term"))],ConstType(SortVar("term"))),ConstType(SortVar("term"))],ConstType(SortVar("term")))),DefaultVarDec("dep-base")],Call(SVar("option-wrap"),[LChoice(CallNoArgs(SVar("pack-options")),CallNoArgs(SVar("io-options"))),Seq(AM(LChoice(BA(Seq(CallNoArgs(SVar("get-config")),Call(SVar("filter"),[Not(StrCong("\"-I\""))])),NoAnnoList(Str("\"-I\""))),Build(NoAnnoList(List([])))),Var("path")),Seq(AM(LChoice(BA(CallNoArgs(SVar("get-config")),NoAnnoList(Str("\"-i\""))),Build(NoAnnoList(Op("stdin",[])))),Var("infile")),Seq(AM(LChoice(BA(CallNoArgs(SVar("get-config")),NoAnnoList(Str("\"-o\""))),Build(NoAnnoList(Op("stdout",[])))),Var("outfile")),Seq(AM(BA(Call(SVar("pack"),[Build(Var("path"))]),Var("infile")),NoAnnoList(Tuple([Var("files"),Var("spec")]))),Seq(LChoice(Seq(BA(CallNoArgs(SVar("get-config")),NoAnnoList(Str("\"-b\""))),BA(CallNoArgs(SVar("WriteToBinaryFile")),NoAnnoList(Tuple([Var("outfile"),Var("spec")])))),BA(CallNoArgs(SVar("WriteToTextFile")),NoAnnoList(Tuple([Var("outfile"),Var("spec")])))),Call(SVar("try"),[Seq(AM(LChoice(BA(CallNoArgs(SVar("get-config")),NoAnnoList(Str("\"-dep\""))),Seq(Not(BA(CallNoArgs(SVar("get-config")),NoAnnoList(Str("\"-nodep\"")))),CallNoArgs(SVar("dep-base")))),Var("depfile")),BA(Call(SVar("create-dep-file"),[Build(Var("depfile"))]),NoAnnoList(Tuple([Var("outfile"),Var("files")]))))]))))))])),RDef("create-dep-file",[DefaultVarDec("dep-base")],Rule(NoAnnoList(Tuple([Var("outfile"),Var("files")])),NoAnnoList(Tuple([Var("outfile"),Var("files")])),Seq(AM(BA(CallNoArgs(SVar("dep-base")),Var("outfile")),Var("out")),Seq(AM(BA(CallNoArgs(SVar("fopen")),NoAnnoList(Tuple([App(CallNoArgs(SVar("add-extension")),NoAnnoList(Tuple([Var("out"),NoAnnoList(Str("\"dep\""))]))),NoAnnoList(Str("\"w\""))]))),Var("dep")),Seq(BA(CallNoArgs(SVar("fprintnl")),NoAnnoList(Tuple([Var("dep"),NoAnnoList(ListTail([Var("out")],App(Call(SVar("separate-by"),[Build(NoAnnoList(Str("\" \\\\\\n\\t\"")))]),NoAnnoList(ListTail([NoAnnoList(Str("\" :\""))],Var("files"))))))]))),BA(CallNoArgs(SVar("fclose")),Var("dep")))))))])])
