Skip to content

Commit 52bb6db

Browse files
authored
Merge pull request #4166 from BuckleScript/wip_in_meory_loading
In memory loading that works
2 parents b646be4 + 6d4ceb6 commit 52bb6db

39 files changed

+52786
-49045
lines changed

jscomp/bsb/bsb_ninja_gen.ml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -142,14 +142,7 @@ let output_ninja_and_namespace_map
142142
(* resolved earlier *)
143143
Bsb_ninja_targets.output_kv Bsb_ninja_global_vars.gentypeconfig
144144
("-bs-gentype " ^ x.path) oc
145-
);
146-
Ext_option.iter built_in_dependency (fun x ->
147-
Bsb_ninja_targets.output_kv Bsb_ninja_global_vars.g_stdlib_incl
148-
(Ext_filename.maybe_quote x.package_install_path) oc
149-
)
150-
;
151-
152-
145+
);
153146
Bsb_ninja_targets.output_kvs
154147
[|
155148
Bsb_ninja_global_vars.g_pkg_flg, g_pkg_flg ;

jscomp/bsb/bsb_ninja_global_vars.ml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,3 @@ let gentypeconfig = "gentypeconfig"
5454

5555
let g_dev_incls = "g_dev_incls"
5656

57-
(* path to stdlib *)
58-
let g_stdlib_incl = "g_std_incl"

jscomp/bsb/bsb_ninja_rule.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ let make_custom_rules
129129
~is_dev
130130
~postbuild : string =
131131
Buffer.clear buf;
132-
Buffer.add_string buf "$bsc -nostdlib $g_pkg_flg -color always";
132+
Buffer.add_string buf "$bsc $g_pkg_flg -color always";
133133
if bs_suffix then
134134
Buffer.add_string buf " -bs-suffix";
135135
if read_cmi then
@@ -139,8 +139,8 @@ let make_custom_rules
139139
Buffer.add_string buf " $g_lib_incls" ;
140140
if is_dev then
141141
Buffer.add_string buf " $g_dpkg_incls";
142-
if has_builtin then
143-
Buffer.add_string buf " -I $g_std_incl";
142+
if not has_builtin then
143+
Buffer.add_string buf " -nostdlib";
144144
Buffer.add_string buf " $warnings $bsc_flags";
145145
if has_gentype then
146146
Buffer.add_string buf " $gentypeconfig";

jscomp/build_tests/bucklescript-tea/bsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"name": "bucklescript-tea",
33
"version": "0.6.11",
44
"bsc-flags": [
5+
"-bs-diagnose",
56
"-bs-cross-module-opt"
67
],
78
"package-specs": {
@@ -14,6 +15,6 @@
1415
"dir": "test",
1516
"type": "dev"
1617
}
17-
],
18+
],
1819
"suffix": ".bs.js"
1920
}
Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1+
var p = require("child_process");
12

2-
var p = require('child_process')
3+
var o = p.spawnSync(`bsb`);
34

4-
p.execSync(`bsb`)
5+
console.log(o.stderr + "");
6+
console.log("-----");
7+
console.log(o.stdout + "");
8+
if (o.error) {
9+
throw o.error;
10+
}

jscomp/common/bs_version.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* You should have received a copy of the GNU Lesser General Public License
2323
* along with this program; if not, write to the Free Software
2424
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
25-
let version = "7.1.1-dev.1"
25+
let version = "7.2.0-dev.1"
2626
let header =
2727
"// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE"
2828
let package_name = "bs-platform"

jscomp/common/js_config.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,5 @@ let is_reason = ref false
110110
let js_stdout = ref true
111111

112112
let all_module_aliases = ref false
113+
114+
let no_stdlib = ref false

jscomp/common/js_config.mli

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,5 @@ val is_reason : bool ref
107107
val js_stdout : bool ref
108108

109109
val all_module_aliases : bool ref
110+
111+
val no_stdlib: bool ref

jscomp/core/bs_cmi_load.ml

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,42 @@
1+
(* Copyright (C) Authors of BuckleScript
2+
*
3+
* This program is free software: you can redistribute it and/or modify
4+
* it under the terms of the GNU Lesser General Public License as published by
5+
* the Free Software Foundation, either version 3 of the License, or
6+
* (at your option) any later version.
7+
*
8+
* In addition to the permissions granted to you by the LGPL, you may combine
9+
* or link a "work that uses the Library" with a publicly distributed version
10+
* of this file to produce a combined library or application, then distribute
11+
* that combined work under the terms of your choosing, with no requirement
12+
* to comply with the obligations normally placed on you by section 4 of the
13+
* LGPL version 3 (or the corresponding section of a later version of the LGPL
14+
* should you choose to use a later version).
15+
*
16+
* This program is distributed in the hope that it will be useful,
17+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19+
* GNU Lesser General Public License for more details.
20+
*
21+
* You should have received a copy of the GNU Lesser General Public License
22+
* along with this program; if not, write to the Free Software
23+
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
124

225

3-
(* TODO: provide native load*)
4-
let browse_load ~unit_name : Env.Persistent_signature.t option=
5-
match Ext_string_array.find_sorted_assoc Builtin_cmi_datasets.module_sets_cmi unit_name with
6-
| Some cmi ->
7-
(* Format.fprintf Format.err_formatter "reading %s@." unit_name; *)
8-
Some {filename = Sys.executable_name ;
9-
cmi =
10-
Lazy.force cmi}
11-
| None -> assert false
26+
27+
let load_cmi ~unit_name : Env.Persistent_signature.t option =
28+
match Config_util.find_opt (unit_name ^".cmi") with
29+
| Some filename -> Some {filename; cmi = Cmi_format.read_cmi filename}
30+
| None ->
31+
if !Js_config.no_stdlib then None
32+
else
33+
match Ext_string_array.find_sorted_assoc Builtin_cmi_datasets.module_sets_cmi unit_name with
34+
| Some cmi ->
35+
if Js_config.get_diagnose () then
36+
Format.fprintf Format.err_formatter ">Cmi: %s@." unit_name;
37+
let lazy cmi = cmi in
38+
if Js_config.get_diagnose () then
39+
Format.fprintf Format.err_formatter "<Cmi: %s@." unit_name;
40+
Some {filename = Sys.executable_name ;
41+
cmi }
42+
| None -> None

jscomp/core/bs_conditional_initial.ml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@
2626
(* default to false -check later*)
2727
(* Clflags.keep_locs := false; *)
2828
let setup_env () =
29-
#if BS_BROWSER then
30-
Env.Persistent_signature.load := Bs_cmi_load.browse_load;
31-
#end
29+
Env.Persistent_signature.load := Bs_cmi_load.load_cmi;
30+
Clflags.no_std_include := true;
3231
Warnings.parse_options false Bsc_warnings.defaults_w;
3332
Warnings.parse_options true Bsc_warnings.defaults_warn_error;
3433
Clflags.dump_location := false;

0 commit comments

Comments
 (0)