This commit is contained in:
Norayr Chilingarian 2025-07-17 23:25:08 +04:00
parent b6ae2ad096
commit 9ec814db42
2 changed files with 45 additions and 96 deletions

View file

@ -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;