Skip to content

[compiler] [build-fs] Fix target not set error #1694

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions compiler/bin-js_of_ocaml/build_fs.ml
Original file line number Diff line number Diff line change
@@ -61,6 +61,7 @@ function jsoo_create_file_extern(name,content){
}
|}
in
Config.set_target `JavaScript;
let fragments = Linker.Fragment.parse_string code in
Linker.load_fragments ~target_env:Isomorphic ~filename:"<dummy>" fragments;
Linker.check_deps ();
2 changes: 2 additions & 0 deletions compiler/bin-js_of_ocaml/js_of_ocaml.ml
Original file line number Diff line number Diff line change
@@ -109,7 +109,9 @@ let () =
comp;
exit 1
| Failure s ->
let backtrace = Printexc.get_backtrace () in
Format.eprintf "%s: Error: %s@." Sys.argv.(0) s;
prerr_string backtrace;
exit 1
| exc ->
let backtrace = Printexc.get_backtrace () in
17 changes: 17 additions & 0 deletions compiler/tests-full/dune
Original file line number Diff line number Diff line change
@@ -26,3 +26,20 @@
(= %{ocaml_version} "5.2.0"))
(action
(diff stdlib.cma.expected.js stdlib.cma.output.js)))

(rule
(targets fs.output.js)
(deps file1 file2)
(action
(run
%{bin:js_of_ocaml}
build-fs
-o
%{targets}
file1:/static/file1
file2:/static/dir/file2)))

(rule
(alias runtest)
(action
(diff fs.expected.js fs.output.js)))
1 change: 1 addition & 0 deletions compiler/tests-full/file1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is file 1
1 change: 1 addition & 0 deletions compiler/tests-full/file2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is file 2
31 changes: 31 additions & 0 deletions compiler/tests-full/fs.expected.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
(function(a){
typeof globalThis !== "object"
&&
(this
? b()
: (a.defineProperty
(a.prototype, "_T_", {configurable: true, get: b}),
_T_));
function b(){
var b = this || self;
b.globalThis = b;
delete a.prototype._T_;
}
}
(Object));
(function(c){
"use strict";
function a(a, b){
if(c.jsoo_create_file)
c.jsoo_create_file(a, b);
else{
if(! c.caml_fs_tmp) c.caml_fs_tmp = [];
c.caml_fs_tmp.push({name: a, content: b});
}
return 0;
}
a("/static/file1", "This is file 1");
a("/static/dir/file2", "This is file 2");
return;
}
(globalThis));