This commit is contained in:
swrup 2025-11-11 02:07:51 +01:00
parent aa2ff7b2f0
commit 2f3113f55d
11742 changed files with 1223940 additions and 0 deletions

View file

@ -0,0 +1,6 @@
(executables
(names technologic)
(libraries js_of_ocaml x)
(modes wasm)
(wasm_of_ocaml
(javascript_files runtime.js)))

View file

@ -0,0 +1,3 @@
global.globalPrintFunction = function(x){
console.log(x);
}

View file

@ -0,0 +1,13 @@
module Js = Js_of_ocaml.Js
let _ =
print_endline X.buy_it;
let obj = Js.Unsafe.obj [|"name", Js.Unsafe.inject (Js.string Z.use_it)|] in
Printf.printf "%s\n%!" (X.print obj);
X.external_print (Js.string "break it");
(fun x ->
let global = Js.Unsafe.get Js.Unsafe.global "global" in
let globalPrintFunction : Js.js_string Js.t -> unit =
Js.Unsafe.get global "globalPrintFunction" in
Js.Unsafe.fun_call globalPrintFunction [|Js.Unsafe.inject x|]
) (Js.string "fix it")

View file

@ -0,0 +1 @@
let use_it = "use it"

View file

@ -0,0 +1,7 @@
(library
(name x)
(libraries js_of_ocaml)
(public_name x)
(wasm_of_ocaml
(flags (--pretty)) (javascript_files runtime.js) (wasm_files runtime.wat))
)

View file

@ -0,0 +1,6 @@
//Provides: jsPrint
function jsPrint(x){
globalThis.console.log(x);
}

View file

@ -0,0 +1,7 @@
(module
(import "env" "unwrap" (func $unwrap (param (ref eq)) (result anyref)))
(import "js" "jsPrint" (func $print (param anyref)))
(func (export "jsPrint") (param $x (ref eq)) (result (ref eq))
(call $print (call $unwrap (local.get $x)))
(ref.i31 (i32.const 0)))
)

View file

@ -0,0 +1,5 @@
module Js = Js_of_ocaml.Js
let buy_it = "buy " ^ Y.it
let print x = Js.to_string (Js.Unsafe.get x "name")
external external_print : Js.js_string Js.t -> unit = "jsPrint"

View file

@ -0,0 +1,50 @@
Compilation using WasmOO
$ dune build --display short bin/technologic.bc.wasm.js @install 2>&1 | \
> sed s,^\ *$(ocamlc -config-var c_compiler),\ \ C_COMPILER,g
ocamldep bin/.technologic.eobjs/dune__exe__Technologic.impl.d
ocamldep lib/.x.objs/x.impl.d
ocamlc lib/.x.objs/byte/x__.{cmi,cmo,cmt}
ocamldep lib/.x.objs/x__Y.impl.d
wasm_of_ocaml bin/.technologic.eobjs/jsoo/technologic.bc.runtime.wasma
ocamldep bin/.technologic.eobjs/dune__exe__Z.impl.d
ocamlopt lib/.x.objs/native/x__.{cmx,o}
ocamlc lib/.x.objs/byte/x__Y.{cmi,cmo,cmt}
wasm_of_ocaml .js/default/stdlib/stdlib.wasma
wasm_of_ocaml .js/default/stdlib/std_exit.wasmo
ocamlc bin/.technologic.eobjs/byte/dune__exe.{cmi,cmo,cmt}
ocamldep bin/.technologic.eobjs/dune__exe__Technologic.intf.d
ocamlopt lib/.x.objs/native/x__Y.{cmx,o}
ocamlc lib/.x.objs/byte/x.{cmi,cmo,cmt}
wasm_of_ocaml .js/default/js_of_ocaml-compiler.runtime/jsoo_runtime.wasma
ocamlopt lib/.x.objs/native/x.{cmx,o}
ocamlc bin/.technologic.eobjs/byte/dune__exe__Z.{cmi,cmo,cmt}
ocamlc lib/x.cma
ocamlc bin/.technologic.eobjs/byte/dune__exe__Technologic.{cmi,cmti}
wasm_of_ocaml .js/default/js_of_ocaml/js_of_ocaml.wasma
ocamlopt lib/x.{a,cmxa}
ocamlc bin/.technologic.eobjs/byte/dune__exe__Technologic.{cmo,cmt}
wasm_of_ocaml lib/.x.objs/jsoo/default/x.wasma
ocamlopt lib/x.cmxs
wasm_of_ocaml bin/.technologic.eobjs/jsoo/dune__exe.wasmo
wasm_of_ocaml bin/.technologic.eobjs/jsoo/dune__exe__Z.wasmo
wasm_of_ocaml bin/.technologic.eobjs/jsoo/dune__exe__Technologic.wasmo
wasm_of_ocaml bin/technologic.bc.wasm.{js,assets}
$ node ./_build/default/bin/technologic.bc.wasm.js
buy it
use it
break it
fix it
$ dune build bin/technologic.bc.wasm.js @install --profile release
$ node ./_build/default/bin/technologic.bc.wasm.js
buy it
use it
break it
fix it
$ cat >dune-workspace <<EOF
> (lang dune 3.17)
> (context
> (default (disable_dynamically_linked_foreign_archives true)))
> EOF
$ dune build bin/technologic.bc.wasm.js @install --profile dev
$ dune build bin/technologic.bc.wasm.js @install --profile release