mirror of
https://github.com/vishapoberon/vipak.git
synced 2026-04-05 20:42:26 +00:00
works!
This commit is contained in:
parent
b6ae2ad096
commit
9ec814db42
2 changed files with 45 additions and 96 deletions
|
|
@ -413,47 +413,66 @@ VAR
|
|||
tree, buildValue, command, file: Json.Value;
|
||||
rootObj, buildStep: Json.Obj;
|
||||
buildArray: Json.Arr;
|
||||
cm, fl, bl, cmLower, flLower: Json.jString;
|
||||
cm, fl, bl: Json.jString;
|
||||
b: BOOLEAN;
|
||||
BEGIN
|
||||
k := NIL; v := NIL;
|
||||
b := FALSE;
|
||||
jsonstr := NIL;
|
||||
|
||||
Out.String("DEBUG: Reading file: "); Out.String(filename); Out.Ln;
|
||||
|
||||
(* Read from specified file instead of package tree *)
|
||||
vpkStorage.fileToString(filename, jsonstr);
|
||||
|
||||
IF jsonstr # NIL THEN
|
||||
Out.String("DEBUG: JSON string loaded, length: "); Out.Int(LEN(jsonstr^), 0); Out.Ln;
|
||||
NEW(errstr, ErrmessSize);
|
||||
b := Json.Parse(tree, jsonstr^, errstr^);
|
||||
IF b THEN
|
||||
Out.String("DEBUG: JSON parsed successfully"); Out.Ln;
|
||||
IF tree IS Json.Obj THEN
|
||||
Out.String("DEBUG: Root is object"); Out.Ln;
|
||||
rootObj := tree(Json.Obj);
|
||||
NEW(bl, Strings.Length(vpkSettings.bldType) + 1); (* +1 for 0X *)
|
||||
NEW(bl, Strings.Length(vpkSettings.bldType) + 1);
|
||||
COPY(vpkSettings.bldType, bl^);
|
||||
Out.String("DEBUG: Looking for build key: "); Out.String(bl^); Out.Ln;
|
||||
IF Json.ObjSelect(buildValue, rootObj, bl) THEN
|
||||
Out.String("DEBUG: Found Build section"); Out.Ln;
|
||||
IF buildValue IS Json.Arr THEN
|
||||
Out.String("DEBUG: Build section is array"); Out.Ln;
|
||||
buildArray := buildValue(Json.Arr);
|
||||
WHILE buildArray # NIL DO
|
||||
buildStep := buildArray.value(Json.Obj);
|
||||
NEW(cm, Strings.Length(vpkSettings.bldCommand) + 1); (* +1 for 0X *)
|
||||
NEW(fl, Strings.Length(vpkSettings.bldFile) + 1); (* +1 for 0X *)
|
||||
COPY(vpkSettings.bldCommand, cm^);
|
||||
COPY(vpkSettings.bldFile, fl^);
|
||||
Out.String("DEBUG: Processing build array element"); Out.Ln;
|
||||
IF buildArray.value IS Json.Obj THEN
|
||||
Out.String("DEBUG: Build array element is object"); Out.Ln;
|
||||
buildStep := buildArray.value(Json.Obj);
|
||||
NEW(cm, Strings.Length(vpkSettings.bldCommand) + 1);
|
||||
NEW(fl, Strings.Length(vpkSettings.bldFile) + 1);
|
||||
COPY(vpkSettings.bldCommand, cm^);
|
||||
COPY(vpkSettings.bldFile, fl^);
|
||||
Out.String("DEBUG: Looking for command key: "); Out.String(cm^); Out.Ln;
|
||||
Out.String("DEBUG: Looking for file key: "); Out.String(fl^); Out.Ln;
|
||||
|
||||
(* Handle build steps (same logic as original getBuildInfo) *)
|
||||
IF Json.ObjSelect(command, buildStep, cm) & Json.ObjSelect(file, buildStep, fl) THEN
|
||||
IF (command IS Json.Str) & (file IS Json.Str) THEN
|
||||
IF k = NIL THEN k := StringList.Create() END;
|
||||
IF v = NIL THEN v := StringList.Create() END;
|
||||
k.AppendString(k, command(Json.Str).str^);
|
||||
v.AppendString(v, file(Json.Str).str^);
|
||||
(* Simple approach - just try to get command and file directly *)
|
||||
IF Json.ObjSelect(command, buildStep, cm) & Json.ObjSelect(file, buildStep, fl) THEN
|
||||
Out.String("DEBUG: Found both command and file keys"); Out.Ln;
|
||||
IF (command IS Json.Str) & (file IS Json.Str) THEN
|
||||
Out.String("DEBUG: Both are strings"); Out.Ln;
|
||||
IF k = NIL THEN k := StringList.Create() END;
|
||||
IF v = NIL THEN v := StringList.Create() END;
|
||||
k.AppendString(k, command(Json.Str).str^);
|
||||
v.AppendString(v, file(Json.Str).str^);
|
||||
Out.String("Found build step: "); Out.String(command(Json.Str).str^);
|
||||
Out.String(" "); Out.String(file(Json.Str).str^); Out.Ln;
|
||||
ELSE
|
||||
Out.String("DEBUG: command and file must be strings"); Out.Ln;
|
||||
END;
|
||||
ELSE
|
||||
Out.String("command and file must be strings"); Out.Ln;
|
||||
HALT(5);
|
||||
Out.String("DEBUG: Failed to select 'command' or 'file' from build step"); Out.Ln;
|
||||
END;
|
||||
ELSE
|
||||
Out.String("Failed to select 'command' or 'file' from build step"); Out.Ln;
|
||||
Out.String("DEBUG: Build array element is not an object"); Out.Ln;
|
||||
END;
|
||||
buildArray := buildArray.next;
|
||||
END;
|
||||
|
|
@ -472,7 +491,7 @@ BEGIN
|
|||
ELSE
|
||||
Out.String("No JSON string provided."); Out.Ln;
|
||||
END;
|
||||
RETURN b;
|
||||
RETURN (k # NIL) & (v # NIL) & (k.Count > 0);
|
||||
END getBuildInfoFromFile;
|
||||
|
||||
PROCEDURE getDepsFromFile*(VAR d: vpkdepTree.Tdep; VAR depstrlist: StringList.TStringList): LONGINT;
|
||||
|
|
|
|||
|
|
@ -22,80 +22,6 @@ TYPE
|
|||
hasBuild: BOOLEAN;
|
||||
END;
|
||||
|
||||
PROCEDURE getBuildInfoFromLocalFile(VAR projectFile: ARRAY OF CHAR; VAR k, v: StringList.TStringList): BOOLEAN;
|
||||
VAR
|
||||
jsonstr, errstr: strUtils.pstring;
|
||||
tree, buildValue, command, file: Json.Value;
|
||||
rootObj, buildStep: Json.Obj;
|
||||
buildArray: Json.Arr;
|
||||
cm, fl, bl: Json.jString;
|
||||
b: BOOLEAN;
|
||||
BEGIN
|
||||
k := NIL; v := NIL;
|
||||
b := FALSE;
|
||||
jsonstr := NIL;
|
||||
|
||||
(* Read from specified file *)
|
||||
vpkStorage.fileToString(projectFile, jsonstr);
|
||||
|
||||
IF jsonstr # NIL THEN
|
||||
NEW(errstr, ErrmessSize);
|
||||
b := Json.Parse(tree, jsonstr^, errstr^);
|
||||
IF b THEN
|
||||
IF tree IS Json.Obj THEN
|
||||
rootObj := tree(Json.Obj);
|
||||
NEW(bl, Strings.Length(vpkSettings.bldType) + 1);
|
||||
COPY(vpkSettings.bldType, bl^);
|
||||
IF Json.ObjSelect(buildValue, rootObj, bl) THEN
|
||||
IF buildValue IS Json.Arr THEN
|
||||
buildArray := buildValue(Json.Arr);
|
||||
WHILE buildArray # NIL DO
|
||||
(* buildArray.value should contain the build step object *)
|
||||
IF buildArray.value IS Json.Obj THEN
|
||||
buildStep := buildArray.value(Json.Obj);
|
||||
NEW(cm, Strings.Length(vpkSettings.bldCommand) + 1);
|
||||
NEW(fl, Strings.Length(vpkSettings.bldFile) + 1);
|
||||
COPY(vpkSettings.bldCommand, cm^);
|
||||
COPY(vpkSettings.bldFile, fl^);
|
||||
|
||||
(* Look for "command" and "file" keys in the build step object *)
|
||||
IF Json.ObjSelect(command, buildStep, cm) & Json.ObjSelect(file, buildStep, fl) THEN
|
||||
IF (command IS Json.Str) & (file IS Json.Str) THEN
|
||||
IF k = NIL THEN k := StringList.Create() END;
|
||||
IF v = NIL THEN v := StringList.Create() END;
|
||||
k.AppendString(k, command(Json.Str).str^);
|
||||
v.AppendString(v, file(Json.Str).str^);
|
||||
Out.String("Found build step: "); Out.String(command(Json.Str).str^);
|
||||
Out.String(" "); Out.String(file(Json.Str).str^); Out.Ln;
|
||||
ELSE
|
||||
Out.String("command and file must be strings"); Out.Ln;
|
||||
END;
|
||||
ELSE
|
||||
Out.String("Build step missing 'command' or 'file' fields"); Out.Ln;
|
||||
END;
|
||||
ELSE
|
||||
Out.String("Build array element is not an object"); Out.Ln;
|
||||
END;
|
||||
buildArray := buildArray.next;
|
||||
END;
|
||||
ELSE
|
||||
Out.String("Build section is not an array."); Out.Ln;
|
||||
END;
|
||||
ELSE
|
||||
Out.String("Build section not found."); Out.Ln;
|
||||
END;
|
||||
ELSE
|
||||
Out.String("JSON root is not an object."); Out.Ln;
|
||||
END;
|
||||
ELSE
|
||||
Out.String("JSON parsing failed: "); Out.String(errstr^); Out.Ln;
|
||||
END;
|
||||
ELSE
|
||||
Out.String("No JSON string provided."); Out.Ln;
|
||||
END;
|
||||
RETURN (k # NIL) & (v # NIL) & (k.Count > 0);
|
||||
END getBuildInfoFromLocalFile;
|
||||
|
||||
PROCEDURE createTemplateModule(VAR projectName: ARRAY OF CHAR);
|
||||
VAR
|
||||
filename: ARRAY 80 OF CHAR;
|
||||
|
|
@ -206,9 +132,9 @@ BEGIN
|
|||
Strings.Append(eol, content);
|
||||
Strings.Append(' {', content);
|
||||
Strings.Append(eol, content);
|
||||
Strings.Append(' "command": "voc -m",', content);
|
||||
Strings.Append(' "Command": "voc -m",', content);
|
||||
Strings.Append(eol, content);
|
||||
Strings.Append(' "file": "src/', content);
|
||||
Strings.Append(' "File": "src/', content);
|
||||
Strings.Append(projectName, content);
|
||||
Strings.Append('.Mod"', content);
|
||||
Strings.Append(eol, content);
|
||||
|
|
@ -349,6 +275,7 @@ END buildDependencies;
|
|||
|
||||
PROCEDURE buildProject(VAR projectFile: ARRAY OF CHAR; info: ProjectInfo): BOOLEAN;
|
||||
VAR
|
||||
dep: vpkdepTree.Tdep;
|
||||
keys, values: StringList.TStringList;
|
||||
k, v: StringList.pstring;
|
||||
b: BOOLEAN;
|
||||
|
|
@ -356,8 +283,11 @@ VAR
|
|||
res, i: INTEGER;
|
||||
buildDirVar: ARRAY 64 OF CHAR;
|
||||
BEGIN
|
||||
(* Get build information using local file reader *)
|
||||
b := getBuildInfoFromLocalFile(projectFile, keys, values);
|
||||
(* Create a dummy dependency object for build info extraction *)
|
||||
dep := vpkdepTree.CreateDep(info.name);
|
||||
|
||||
(* Get build information using the procedure from vpkJsonDepRetriever *)
|
||||
b := vpkJsonDepRetriever.getBuildInfoFromFile(dep, keys, values, projectFile);
|
||||
|
||||
IF b & (keys # NIL) & (values # NIL) THEN
|
||||
Out.String("Building project: "); Out.String(info.name); Out.Ln;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue