|
@@ -242,7 +242,7 @@ let open_file ctx file =
|
|
|
let version_major = ctx.version / 1000 in
|
|
|
let version_minor = (ctx.version mod 1000) / 100 in
|
|
|
let version_revision = (ctx.version mod 100) in
|
|
|
- line ctx (sprintf "%s Generated by HLC %d.%d.%d (HL v%d)" (if file = "Makefile" then "#" else "//") version_major version_minor version_revision ctx.hlcode.version);
|
|
|
+ if file <> "hlc.json" then line ctx (sprintf "// Generated by HLC %d.%d.%d (HL v%d)" version_major version_minor version_revision ctx.hlcode.version);
|
|
|
ctx.curfile <- file
|
|
|
|
|
|
let string_data_limit = 64
|
|
@@ -963,12 +963,12 @@ let generate_function ctx f =
|
|
|
line "}";
|
|
|
line ""
|
|
|
|
|
|
-let write_c version file (code:code) =
|
|
|
+let write_c com file (code:code) =
|
|
|
|
|
|
let all_types, htypes = gather_types code in
|
|
|
|
|
|
let ctx = {
|
|
|
- version = version;
|
|
|
+ version = com.Common.version;
|
|
|
out = Buffer.create 1024;
|
|
|
tabs = "";
|
|
|
hlcode = code;
|
|
@@ -1402,9 +1402,15 @@ let write_c version file (code:code) =
|
|
|
line "}";
|
|
|
line "";
|
|
|
|
|
|
- open_file ctx "Makefile";
|
|
|
+ open_file ctx "hlc.json";
|
|
|
|
|
|
- line ("FILES = " ^ (String.concat " " (ctx.cfiles)));
|
|
|
+ line "{";
|
|
|
+ block ctx;
|
|
|
+ sline "\"version\" : %d," ctx.version;
|
|
|
+ sline "\"defines\" : {%s\n\t}," (String.concat "," (PMap.foldi (fun k v acc -> sprintf "\n\t\t\"%s\" : \"%s\"" k v :: acc) com.Common.defines []));
|
|
|
+ sline "\"files\" : [%s\n\t]" (String.concat "," (List.map (sprintf "\n\t\t\"%s\"") ctx.cfiles));
|
|
|
+ unblock ctx;
|
|
|
+ line "}";
|
|
|
|
|
|
close_file ctx
|
|
|
|