Skip to content

Commit

Permalink
substitute $target when we actually need it
Browse files Browse the repository at this point in the history
  • Loading branch information
Simn committed Jan 25, 2024
1 parent 845be4b commit 09f7630
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/compiler/compiler.ml
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ let compile ctx actx callbacks =
| None ->
()
| Some file ->
com.hxb_writer_config <- HxbWriterConfig.process_argument (platform_name com.platform) file
com.hxb_writer_config <- HxbWriterConfig.process_argument file
end;
t();
enter_stage com CInitialized;
Expand Down
1 change: 1 addition & 0 deletions src/compiler/generate.ml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ let check_hxb_output ctx config =
in
let try_write () =
let path = config.HxbWriterConfig.archive_path in
let path = Str.global_replace (Str.regexp "\\$target") (platform_name ctx.com.platform) path in
let t = Timer.timer ["generate";"hxb"] in
Path.mkdir_from_path path;
let zip = new Zip_output.zip_output path 6 in
Expand Down
18 changes: 8 additions & 10 deletions src/compiler/hxb/hxbWriterConfig.ml
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,13 @@ module WriterConfigReader (API : DataReaderApi.DataReaderApi) = struct
error (Printf.sprintf "Unknown key for target config: %s" s)
) fl

let read_writer_config config target_name data =
let read_writer_config config data =
let read data =
let fl = API.read_object data in
List.iter (fun (s,data) ->
match s with
| "archivePath" ->
let path = API.read_string data in
let path = Str.global_replace (Str.regexp "\\$target") target_name path in
config.archive_path <- path;
config.archive_path <- API.read_string data;
| "targetConfig" ->
API.read_optional data (fun data -> read_target_config config.target_config (API.read_object data))
| "macroConfig" ->
Expand Down Expand Up @@ -90,15 +88,15 @@ module WriterConfigWriter (API : DataWriterApi.DataWriterApi) = struct
]
end

let process_json config target_name json =
WriterConfigReaderJson.read_writer_config config target_name json
let process_json config json =
WriterConfigReaderJson.read_writer_config config json

let parse config target_name input =
let parse config input =
let lexbuf = Sedlexing.Utf8.from_string input in
let json = read_json lexbuf in
process_json config target_name json
process_json config json

let process_argument target_name file =
let process_argument file =
let config = create () in
begin match Path.file_extension file with
| "json" ->
Expand All @@ -109,7 +107,7 @@ let process_argument target_name file =
in
let data = Std.input_all file in
close_in file;
parse config target_name data;
parse config data;
| _ ->
config.archive_path <- file;
end;
Expand Down
2 changes: 1 addition & 1 deletion src/typing/macroContext.ml
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ let make_macro_com_api com mcom p =
com.hxb_writer_config <- Some config;
config
in
HxbWriterConfigReaderEval.read_writer_config config (platform_name com.platform) v
HxbWriterConfigReaderEval.read_writer_config config v
end
);
}
Expand Down

0 comments on commit 09f7630

Please sign in to comment.