building almost done.

This commit is contained in:
Norayr Chilingarian 2022-01-18 19:59:19 +04:00
parent 277e8aa9a5
commit 39503ad331
4 changed files with 96 additions and 5 deletions

View file

@ -1,5 +1,5 @@
MODULE vpkInstaller;
IMPORT Out, StringList, vpkResolver, vpkdepTree, vpkDot, vpkSettings, vpkJsonDepRetriever, vpkSyncer;
IMPORT Out, StringList, vpkResolver, vpkdepTree, vpkDot, vpkEnv, vpkJsonDepRetriever, vpkSyncer, Platform;
PROCEDURE resolve*(VAR unit: ARRAY OF CHAR): vpkdepTree.TdepTree;
VAR
@ -7,7 +7,9 @@ VAR
lst: StringList.TStringList;
dep: vpkdepTree.Tdep;
i : LONGINT;
graphName : ARRAY 32 OF CHAR;
BEGIN
vpkEnv.getGraphName(graphName);
Out.Ln; Out.String("resolving dependencies..."); Out.Ln;
tree := vpkResolver.resolve(unit, vpkJsonDepRetriever.getDeps);
Out.String(" done! (:"); Out.Ln; Out.Ln;
@ -15,7 +17,7 @@ BEGIN
Out.String("dependency graph:"); Out.Ln;
Out.String("-----------------"); Out.Ln;
StringList.DumpOut(lst);
lst.Dump(lst, vpkSettings.graphName);
lst.Dump(lst, graphName);
Out.String("-----------------"); Out.Ln;
Out.String("(use 'dot -Tpng deps.dot > deps.png' to get the graph image)"); Out.Ln; Out.Ln;
Out.String("dependencies will be installed in the following order:"); Out.Ln;
@ -50,16 +52,44 @@ PROCEDURE build*(VAR package, prefix, tree: ARRAY OF CHAR);
VAR
depTree: vpkdepTree.TdepTree;
dep: vpkdepTree.Tdep;
i: LONGINT;
i, j: LONGINT;
URI: ARRAY 128 OF CHAR;
typ: ARRAY 16 OF CHAR;
keys, values: StringList.TStringList;
k, v: StringList.pstring;
b: BOOLEAN;
builddir: ARRAY 512 OF CHAR;
cmd, srcPath: StringList.pstring;
chdirRes: INTEGER;
BEGIN
vpkEnv.mkBldDirPath(prefix, builddir);
b := FALSE;
depTree := resolve(package);
i := 0;
REPEAT
dep := vpkdepTree.Get(depTree, i);
vpkJsonDepRetriever.getURIandType(dep, URI, typ);
vpkSyncer.fetch(dep.name^, URI, typ, prefix);
b := vpkJsonDepRetriever.getBuildInfo(dep, keys, values);
IF b THEN
j := 0;
REPEAT
k := keys.GetString(keys, j);
v := values.GetString(values, j);
Out.Int(j, 0); Out.String(": "); Out.String(k^); Out.Ln;
Out.Int(j, 0); Out.String(": "); Out.String(v^); Out.Ln;
chdirRes := Platform.Chdir(builddir);
IF chdirRes # 0 THEN
Out.String("failed to change directory to "); Out.String(builddir); Out.Ln; Out.String("this should never happen."); Out.Ln; HALT(66);
END;
srcPath := vpkEnv.getSrcRelPath(dep.name^, v^);
Out.String(srcPath^); Out.Ln;
INC(j)
UNTIL j = keys.Count - 1;
ELSE
Out.String("no build info found for the package: "); Out.String(dep.name^); Out.Ln;
HALT(67);
END;
INC(i);
UNTIL i = depTree.Count;
END build;