mirror of
https://github.com/vishapoberon/vipak.git
synced 2026-07-10 03:13:32 +00:00
local builder also works with new vipatsar.
This commit is contained in:
parent
b99aed83c7
commit
2c979cbdb0
1 changed files with 27 additions and 45 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
MODULE vpkLocalBuilder;
|
MODULE vpkLocalBuilder;
|
||||||
IMPORT Files, Out, Strings, Platform, In,
|
IMPORT Files, Out, Strings, Platform,
|
||||||
Json, StringList, List, strUtils,
|
Json, StringList, List, strUtils,
|
||||||
vpkStorage, vpkSettings, vpkdepTree, vpkInstaller, vpkEnv, vpkJsonDepRetriever,
|
vpkStorage, vpkSettings, vpkdepTree, vpkEnv, vpkJsonDepRetriever,
|
||||||
vpkResolver, vpkSyncer, vpkDot, vpkTools, UnixFS;
|
vpkResolver, vpkSyncer, vpkDot, vpkTools, UnixFS;
|
||||||
|
|
||||||
CONST
|
CONST
|
||||||
|
|
@ -351,20 +351,17 @@ VAR
|
||||||
keys, values: StringList.TStringList;
|
keys, values: StringList.TStringList;
|
||||||
k, v: StringList.pstring;
|
k, v: StringList.pstring;
|
||||||
b: BOOLEAN;
|
b: BOOLEAN;
|
||||||
cmd, srcPath: StringList.pstring;
|
cmd, srcPath, fullCmd: StringList.pstring;
|
||||||
res: INTEGER;
|
res: INTEGER;
|
||||||
repoPath: ARRAY 256 OF CHAR;
|
repoPath: ARRAY 256 OF CHAR;
|
||||||
node: List.Node;
|
node: List.Node;
|
||||||
parentDir: ARRAY 8 OF CHAR;
|
lastSlash, idx: INTEGER;
|
||||||
lastSlash, idx: INTEGER; (* ADD: for filename removal *)
|
|
||||||
BEGIN
|
BEGIN
|
||||||
(* Resolve all dependencies for local project *)
|
(* Resolve all dependencies for local project *)
|
||||||
depTree := resolveLocal(projectFile);
|
depTree := resolveLocal(projectFile);
|
||||||
|
|
||||||
IF depTree.Count > 0 THEN
|
IF depTree.Count > 0 THEN
|
||||||
(* IMPROVED: Use simple build path *)
|
|
||||||
COPY("build", buildDir);
|
COPY("build", buildDir);
|
||||||
COPY("..", parentDir);
|
|
||||||
|
|
||||||
i := 0;
|
i := 0;
|
||||||
REPEAT
|
REPEAT
|
||||||
|
|
@ -429,20 +426,16 @@ BEGIN
|
||||||
Out.String("Executing dependency build: "); Out.String(cmd^); Out.Ln;
|
Out.String("Executing dependency build: "); Out.String(cmd^); Out.Ln;
|
||||||
Out.String("Building dependency in: "); Out.String(buildDir); Out.Ln;
|
Out.String("Building dependency in: "); Out.String(buildDir); Out.Ln;
|
||||||
|
|
||||||
(* IMPROVED: Continue on errors instead of HALT *)
|
NEW(fullCmd, Strings.Length(buildDir) + Strings.Length(cmd^) + 8);
|
||||||
res := Platform.Chdir(buildDir);
|
COPY("cd ", fullCmd^);
|
||||||
|
Strings.Append(buildDir, fullCmd^);
|
||||||
|
Strings.Append(" && ", fullCmd^);
|
||||||
|
Strings.Append(cmd^, fullCmd^);
|
||||||
|
res := Platform.System(fullCmd^);
|
||||||
IF res # 0 THEN
|
IF res # 0 THEN
|
||||||
Out.String("Warning: Failed to change directory to "); Out.String(buildDir); Out.Ln;
|
Out.String("Warning: Dependency build failed with code: "); Out.Int(res, 0); Out.Ln;
|
||||||
ELSE
|
ELSE
|
||||||
res := Platform.System(cmd^);
|
Out.String("Dependency build successful"); Out.Ln;
|
||||||
IF res # 0 THEN
|
|
||||||
Out.String("Warning: Dependency build failed with code: "); Out.Int(res, 0); Out.Ln;
|
|
||||||
ELSE
|
|
||||||
Out.String("Dependency build successful"); Out.Ln;
|
|
||||||
END;
|
|
||||||
|
|
||||||
(* Return to parent directory *)
|
|
||||||
res := Platform.Chdir(parentDir);
|
|
||||||
END;
|
END;
|
||||||
|
|
||||||
INC(j);
|
INC(j);
|
||||||
|
|
@ -465,52 +458,41 @@ VAR
|
||||||
keys, values: StringList.TStringList;
|
keys, values: StringList.TStringList;
|
||||||
k, v: StringList.pstring;
|
k, v: StringList.pstring;
|
||||||
b: BOOLEAN;
|
b: BOOLEAN;
|
||||||
cmd: ARRAY 256 OF CHAR;
|
fullCmd: strUtils.pstring;
|
||||||
|
srcFile: ARRAY 256 OF CHAR;
|
||||||
res, i: INTEGER;
|
res, i: INTEGER;
|
||||||
buildDirVar: ARRAY 64 OF CHAR;
|
|
||||||
BEGIN
|
BEGIN
|
||||||
(* Create a dummy dependency object for build info extraction *)
|
|
||||||
dep := vpkdepTree.CreateDep(info.name);
|
dep := vpkdepTree.CreateDep(info.name);
|
||||||
|
|
||||||
(* Get build information using the procedure from vpkJsonDepRetriever *)
|
|
||||||
b := vpkJsonDepRetriever.getBuildInfoFromFile(dep, keys, values, projectFile);
|
b := vpkJsonDepRetriever.getBuildInfoFromFile(dep, keys, values, projectFile);
|
||||||
|
|
||||||
IF b & (keys # NIL) & (values # NIL) THEN
|
IF b & (keys # NIL) & (values # NIL) THEN
|
||||||
Out.String("Building project: "); Out.String(info.name); Out.Ln;
|
Out.String("Building project: "); Out.String(info.name); Out.Ln;
|
||||||
|
|
||||||
(* Change to build directory *)
|
|
||||||
COPY(DefaultBuildDir, buildDirVar);
|
|
||||||
res := Platform.Chdir(buildDirVar);
|
|
||||||
IF res # 0 THEN
|
|
||||||
Out.String("Failed to change to build directory"); Out.Ln;
|
|
||||||
RETURN FALSE;
|
|
||||||
END;
|
|
||||||
|
|
||||||
(* Execute build commands *)
|
|
||||||
i := 0;
|
i := 0;
|
||||||
REPEAT
|
REPEAT
|
||||||
k := keys.GetString(keys, i);
|
k := keys.GetString(keys, i);
|
||||||
v := values.GetString(values, i);
|
v := values.GetString(values, i);
|
||||||
|
|
||||||
(* Create command: copy from parent directory if needed *)
|
(* Source file is relative to project root; build runs in build/ *)
|
||||||
COPY(k^, cmd);
|
COPY("../", srcFile);
|
||||||
Strings.Append(" ../", cmd);
|
Strings.Append(v^, srcFile);
|
||||||
Strings.Append(v^, cmd);
|
|
||||||
|
|
||||||
Out.String("Executing: "); Out.String(cmd); Out.Ln;
|
NEW(fullCmd, Strings.Length(DefaultBuildDir) + Strings.Length(k^) + Strings.Length(srcFile) + 10);
|
||||||
res := Platform.System(cmd);
|
COPY("cd ", fullCmd^);
|
||||||
|
Strings.Append(DefaultBuildDir, fullCmd^);
|
||||||
|
Strings.Append(" && ", fullCmd^);
|
||||||
|
Strings.Append(k^, fullCmd^);
|
||||||
|
Strings.Append(" ", fullCmd^);
|
||||||
|
Strings.Append(srcFile, fullCmd^);
|
||||||
|
|
||||||
|
Out.String("Executing: "); Out.String(fullCmd^); Out.Ln;
|
||||||
|
res := Platform.System(fullCmd^);
|
||||||
IF res # 0 THEN
|
IF res # 0 THEN
|
||||||
Out.String("Build command failed with code: "); Out.Int(res, 0); Out.Ln;
|
Out.String("Build command failed with code: "); Out.Int(res, 0); Out.Ln;
|
||||||
COPY("..", buildDirVar);
|
|
||||||
res := Platform.Chdir(buildDirVar);
|
|
||||||
RETURN FALSE;
|
RETURN FALSE;
|
||||||
END;
|
END;
|
||||||
INC(i);
|
INC(i);
|
||||||
UNTIL i = keys.Count;
|
UNTIL i = keys.Count;
|
||||||
|
|
||||||
(* Restore original directory *)
|
|
||||||
COPY("..", buildDirVar);
|
|
||||||
res := Platform.Chdir(buildDirVar);
|
|
||||||
Out.String("Build completed successfully!"); Out.Ln;
|
Out.String("Build completed successfully!"); Out.Ln;
|
||||||
RETURN TRUE;
|
RETURN TRUE;
|
||||||
ELSE
|
ELSE
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue