Skip to content

Commit 0bfe51d

Browse files
committed
1. clean up the build system to use node_moduels/bs-platform/ instead of inferred path\n 2. allow append bsc-flags so that we can provide a built in (allow reset later)
1 parent e52859b commit 0bfe51d

25 files changed

+481
-294
lines changed

Diff for: docs/docson/build-schema.json

+134-101
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@
3636
"$ref": "#/definitions/single-ppx-spec"
3737
}
3838
},
39-
"bs-dependency" : {
40-
"type" : "string",
39+
"bs-dependency": {
40+
"type": "string",
4141
"title": "dependency"
42-
},
42+
},
4343
"bs-dependencies": {
4444
"type": "array",
4545
"items": {
@@ -49,128 +49,131 @@
4949
},
5050
"sourceItem": {
5151
"title": "sourceItem",
52-
"oneOf" : [
52+
"oneOf": [
5353
{
54-
"type" : "object",
55-
"properties": {
56-
"dir": {
57-
"type": "string"
58-
},
59-
"ppx-specs": {
60-
"$ref": "#/definitions/ppx-specs"
61-
},
62-
"type" : {
63-
"enum" : ["dev", "lib"]
64-
},
65-
"files": {
66-
"oneOf": [
67-
{
68-
"type": "array",
69-
"items": {
70-
"type": "string"
71-
},
72-
"description": "if files are empty, the build tool will populate it automatically, this is useful for initial adoption"
54+
"type": "object",
55+
"properties": {
56+
"dir": {
57+
"type": "string"
7358
},
74-
{
75-
"type": "object",
76-
"properties": {
77-
"slow-re": {
78-
"type": "string",
79-
"description": "Regex to glob the patterns, syntax is documented here: http://caml.inria.fr/pub/docs/manual-ocaml/libref/Str.html, if users want to have better performance for incremental build, we would suggest list it explicitly"
80-
},
81-
"excludes": {
59+
"ppx-specs": {
60+
"$ref": "#/definitions/ppx-specs"
61+
},
62+
"type": {
63+
"enum": [
64+
"dev",
65+
"lib"
66+
]
67+
},
68+
"files": {
69+
"oneOf": [
70+
{
8271
"type": "array",
8372
"items": {
8473
"type": "string"
8574
},
86-
"description": "A list of strings to be excluded "
75+
"description": "if files are empty, the build tool will populate it automatically, this is useful for initial adoption"
76+
},
77+
{
78+
"type": "object",
79+
"properties": {
80+
"slow-re": {
81+
"type": "string",
82+
"description": "Regex to glob the patterns, syntax is documented here: http://caml.inria.fr/pub/docs/manual-ocaml/libref/Str.html, if users want to have better performance for incremental build, we would suggest list it explicitly"
83+
},
84+
"excludes": {
85+
"type": "array",
86+
"items": {
87+
"type": "string"
88+
},
89+
"description": "A list of strings to be excluded "
90+
}
91+
},
92+
"required": [
93+
"slow-re"
94+
]
8795
}
88-
},
89-
"required": [
90-
"slow-re"
9196
]
92-
}
93-
]
94-
},
95-
"bs-dependencies": {
96-
"$ref": "#/definitions/bs-dependencies",
97-
"description": "More dependencies added to this group"
98-
},
99-
"public": {
100-
"oneOf": [
101-
{
102-
"enum": [
103-
"all"
97+
},
98+
"bs-dependencies": {
99+
"$ref": "#/definitions/bs-dependencies",
100+
"description": "More dependencies added to this group"
101+
},
102+
"public": {
103+
"oneOf": [
104+
{
105+
"enum": [
106+
"all"
107+
],
108+
"description": "All modules in this directory"
109+
},
110+
{
111+
"type": "array",
112+
"items": {
113+
"type": "string"
114+
},
115+
"description": "Selected modules, for example, [Module_a, Module_b] "
116+
}
104117
],
105-
"description": "All modules in this directory"
118+
"description": "default: export all modules by default, it is recommended for library developers to hide some interfaces"
106119
},
107-
{
120+
"resources": {
108121
"type": "array",
109122
"items": {
110123
"type": "string"
111-
},
112-
"description": "Selected modules, for example, [Module_a, Module_b] "
113-
}
114-
],
115-
"description": "default: export all modules by default, it is recommended for library developers to hide some interfaces"
116-
},
117-
"resources": {
118-
"type": "array",
119-
"items": {
120-
"type": "string"
121-
}
122-
},
123-
"subdirs": {
124-
"$ref" : "#/definitions/sources",
125-
"description": "nested specifications inside"
126-
},
127-
"group": {
128-
"oneOf": [
129-
{
130-
"type": "string",
131-
"description": "A _unique_ name for each directory to refer as an internal dependency later"
124+
}
125+
},
126+
"subdirs": {
127+
"$ref": "#/definitions/sources",
128+
"description": "nested specifications inside"
132129
},
133-
{
134-
"properties": {
135-
"name": {
136-
"type": "string"
130+
"group": {
131+
"oneOf": [
132+
{
133+
"type": "string",
134+
"description": "A _unique_ name for each directory to refer as an internal dependency later"
137135
},
138-
"hierachy": {
139-
"type": "boolean",
140-
"description": "When true, all subdirs are considered as a whole as dependency"
136+
{
137+
"properties": {
138+
"name": {
139+
"type": "string"
140+
},
141+
"hierachy": {
142+
"type": "boolean",
143+
"description": "When true, all subdirs are considered as a whole as dependency"
144+
}
145+
}
141146
}
147+
],
148+
"description": "Not implemented yet"
149+
},
150+
"internal-depends": {
151+
"type": "array",
152+
"items": {
153+
"type": "string",
154+
"description": "internal dependencies, if unspecified, all existing listed source files are considered potential dependencies"
142155
}
143156
}
144-
],
145-
"description": "Not implemented yet"
157+
},
158+
"required": [
159+
"dir"
160+
]
146161
},
147-
"internal-depends": {
148-
"type": "array",
149-
"items": {
150-
"type": "string",
151-
"description": "internal dependencies, if unspecified, all existing listed source files are considered potential dependencies"
152-
}
162+
{
163+
"title": "single non nested directory",
164+
"type": "string",
165+
"description": "directory name (no nested)"
153166
}
154-
},
155-
"required": [
156-
"dir"
157-
]
158-
},
159-
{
160-
"title": "single non nested directory",
161-
"type" : "string",
162-
"description": "directory name (no nested)"
163-
}
164167
]
165168
},
166-
"sources" : {
167-
"oneOf": [
169+
"sources": {
170+
"oneOf": [
168171
{
169172
"type": "array",
170173
"items": {
171174
"$ref": "#/definitions/sourceItem"
172175
},
173-
"description" : "A list of source items"
176+
"description": "A list of source items"
174177
},
175178
{
176179
"$ref": "#/definitions/sourceItem",
@@ -179,6 +182,33 @@
179182
],
180183
"description": "can be either a single sourceItem or an array of sourceItems, sourceItem can be either a single string(non nested directory) or an detailed object config"
181184
},
185+
"bsc-flags": {
186+
"oneOf": [
187+
{
188+
"type": "array",
189+
"items": {
190+
"type": "string"
191+
},
192+
"description": "It will append flags to the default"
193+
},
194+
{
195+
"properties": {
196+
"kind" :
197+
{
198+
"enum": [
199+
"reset",
200+
"prefix",
201+
"append"
202+
]
203+
},
204+
"flags" : {
205+
"$ref" : "#/definitions/stringArray"
206+
}
207+
},
208+
"description": "Not implemented yet"
209+
}
210+
]
211+
},
182212
"stringArray": {
183213
"type": "array",
184214
"items": {
@@ -241,13 +271,16 @@
241271
"description": "external include directories, which will be applied -I to all compilation units, it is *not needed* in most cases"
242272
},
243273
"sources": {
244-
"$ref" : "#/definitions/sources",
245-
"description": "specication of where source code is "
274+
"$ref": "#/definitions/sources",
275+
"description": "specication of where source code is "
246276
},
247-
248277
"generate-merlin": {
249278
"type": "boolean",
250279
"description": "default true (generate .merlin)"
280+
},
281+
"use-stdlib" : {
282+
"type" : "boolean",
283+
"description": "default true(Set use OCaml stdlib or not)"
251284
}
252285
},
253286
"additionalProperties": false,

Diff for: jscomp/bsb/bsb_build_schemas.ml

+1
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,4 @@ let export_none = "none"
3737

3838
let bsb_dir_group = "bsb_dir_group"
3939
let bsc_lib_includes = "bsc_lib_includes"
40+
let use_stdlib = "use-stdlib"

Diff for: jscomp/bsb/bsb_build_util.ml

+6-4
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,14 @@ let rec mkp dir =
111111
else ()
112112

113113

114-
let get_list_string s =
115-
Ext_array.to_list_map (fun (x : Ext_json.t) ->
114+
let get_list_string_acc s acc =
115+
Ext_array.to_list_map_acc (fun (x : Ext_json.t) ->
116116
match x with
117117
| `Str x -> Some x.str
118118
| _ -> None
119-
) s
119+
) s acc
120+
121+
let get_list_string s = get_list_string_acc s []
120122

121123
let bsc_group_1_includes = "bsc_group_1_includes"
122124
let bsc_group_2_includes = "bsc_group_2_includes"
@@ -165,4 +167,4 @@ let rec walk_all_deps top dir cb =
165167
cb top dir
166168
| _ -> ()
167169
| exception _ -> failwith ( "failed to parse" ^ bsconfig_json ^ " properly")
168-
170+

Diff for: jscomp/bsb/bsb_build_util.mli

+10-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,16 @@ val mkp : string -> unit
6161
*)
6262
val get_bsc_bsdep : string -> string * string
6363
val get_bsc_dir : string -> string
64-
val get_list_string : Ext_json.t array -> string list
64+
65+
66+
val get_list_string_acc :
67+
Ext_json.t array ->
68+
string list ->
69+
string list
70+
71+
val get_list_string :
72+
Ext_json.t array ->
73+
string list
6574

6675
val string_of_bsb_dev_include : int -> string
6776

0 commit comments

Comments
 (0)