Skip to content

Commit 24a3546

Browse files
authored
Merge pull request #1094 from bloomberg/depends_format_test
introduce dev group in bsb
2 parents 349fd9e + f2799d0 commit 24a3546

34 files changed

+1059
-373
lines changed

.merlin

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
####{BSB GENERATED: NO EDIT
2+
S /Users/hzhang295/git/bucklescript/jscomp/bin/../lib/ocaml
3+
B /Users/hzhang295/git/bucklescript/jscomp/bin/../lib/ocaml
4+
FLG -ppx /Users/hzhang295/git/bucklescript/jscomp/bin/bsppx.exe
5+
6+
FLG -w -40-30 -w +a
7+
S jscomp/test/
8+
B lib/bs/jscomp/test/
9+
10+
S jscomp/test/glob
11+
B lib/bs/jscomp/test/glob
12+
13+
S jscomp/test/acyc
14+
B lib/bs/jscomp/test/acyc
15+
####BSB GENERATED: NO EDIT}

bin/bsb

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,25 @@
22
"use strict";
33

44
var child_process = require('child_process')
5+
var fs = require('fs')
6+
var bsconfig = 'bsconfig.json'
7+
var bsb_exe = __filename + ".exe"
8+
var delegate_args = process.argv.slice(2)
59

6-
child_process.execFileSync(__filename + ".exe", process.argv.slice(2), {stdio:[0,1,2]})
10+
if(fs.existsSync(bsconfig)){
11+
child_process.execFileSync(bsb_exe, delegate_args, {stdio:'inherit'})
12+
} else {
13+
var path = require('path')
14+
var last_dir = process.cwd()
15+
var search_dir = last_dir
16+
do{
17+
last_dir = search_dir
18+
search_dir = path.dirname(last_dir)
19+
}while(!fs.existsSync(path.join(search_dir,bsconfig)) && (search_dir.length !== search_dir.length))
20+
if(search_dir.length === last_dir.length){
21+
console.error('bsconfig.json not found in current directory and its parent')
22+
process.exit(2)
23+
}else{
24+
child_process.execFileSync(bsb_exe, delegate_args, {stdio:'inherit', cwd: search_dir} )
25+
}
26+
}

docs/Manual.html

Lines changed: 118 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,12 @@ <h1><a href="https://github.com/bloomberg/bucklescript">BuckleScript</a> User Ma
632632
</li>
633633
<li><a href="#_build_system_support">Build system support</a>
634634
<ul class="sectlevel2">
635-
<li><a href="#_build_with_bsb">Build with bsb</a></li>
635+
<li><a href="#_bucklescript_build_system_code_bsb_code">BuckleScript build system: <code>bsb</code></a>
636+
<ul class="sectlevel3">
637+
<li><a href="#_build_with_other_bucklescript_dependencies">Build with other BuckleScript dependencies</a></li>
638+
<li><a href="#_mark_your_directory_as_dev_only">Mark your directory as dev only</a></li>
639+
</ul>
640+
</li>
636641
<li><a href="#_build_using_make">Build using Make</a></li>
637642
</ul>
638643
</li>
@@ -3769,27 +3774,22 @@ <h2 id="_build_system_support"><a class="anchor" href="#_build_system_support"><
37693774
</table>
37703775
</div>
37713776
<div class="sect2">
3772-
<h3 id="_build_with_bsb"><a class="anchor" href="#_build_with_bsb"></a>Build with bsb</h3>
3777+
<h3 id="_bucklescript_build_system_code_bsb_code"><a class="anchor" href="#_bucklescript_build_system_code_bsb_code"></a>BuckleScript build system: <code>bsb</code></h3>
37733778
<div class="paragraph">
3774-
<p>BuckleScript proivdes a native build tool using <a href="https://github.com/ninja-build/ninja/releases">ninja</a>,
3775-
it is designed for fast feedback loop (typically 100ms feedback loop).</p>
3779+
<p>BuckleScript proivdes a native build tool on top of Google&#8217;s <a href="https://github.com/ninja-build/ninja/releases">ninja-build</a>,
3780+
it is designed for fast feedback loop (typically 100ms feedback loop) and works cross platform.</p>
37763781
</div>
3777-
<div class="admonitionblock note">
3778-
<table>
3779-
<tr>
3780-
<td class="icon">
3781-
<div class="title">Note</div>
3782-
</td>
3783-
<td class="content">
3782+
<div class="exampleblock">
3783+
<div class="content">
37843784
<div class="paragraph">
3785-
<p>Currently user needs install ninja first (version &gt;= 1.7.1)</p>
3785+
<p>Currently for non-Windows users, they needs install ninja first (version &gt;= 1.7.1),
3786+
please don&#8217;t be confused with the npm ninja,
3787+
we are using Google&#8217;s <a href="https://github.com/ninja-build/ninja/releases">ninja-build</a>.</p>
3788+
</div>
37863789
</div>
3787-
</td>
3788-
</tr>
3789-
</table>
37903790
</div>
37913791
<div class="paragraph">
3792-
<p>It is a schema based build tool, the schema is
3792+
<p><code>bsb</code> can be running in any subdirectory, it is a schema based build tool, the schema is
37933793
<a href="http://bloomberg.github.io/bucklescript/docson/#build-schema.json">available</a></p>
37943794
</div>
37953795
<div class="paragraph">
@@ -3870,9 +3870,111 @@ <h3 id="_build_with_bsb"><a class="anchor" href="#_build_with_bsb"></a>Build wit
38703870
<pre class="pygments highlight"><code data-lang="sh">bsb -w</code></pre>
38713871
</div>
38723872
</div>
3873+
<div class="sect3">
3874+
<h4 id="_build_with_other_bucklescript_dependencies"><a class="anchor" href="#_build_with_other_bucklescript_dependencies"></a>Build with other BuckleScript dependencies</h4>
3875+
<div class="paragraph">
3876+
<p>List your dependency in <code>bs-dependencies</code> and install it via <code>npm install</code> as below:</p>
3877+
</div>
3878+
<div class="listingblock">
3879+
<div class="title">bsconfig.json</div>
3880+
<div class="content">
3881+
<pre class="pygments highlight"><code data-lang="js"><span class="tok-p">{</span>
3882+
<span class="tok-s2">&quot;name&quot;</span><span class="tok-o">:</span> <span class="tok-s2">&quot;bs-string&quot;</span><span class="tok-p">,</span>
3883+
<span class="tok-s2">&quot;version&quot;</span><span class="tok-o">:</span> <span class="tok-s2">&quot;0.1.3&quot;</span><span class="tok-p">,</span>
3884+
<span class="tok-s2">&quot;bs-dependencies&quot;</span><span class="tok-o">:</span> <span class="tok-p">[</span>
3885+
<span class="tok-s2">&quot;bs-mocha&quot;</span> <b class="conum">(1)</b>
3886+
<span class="tok-p">],</span>
3887+
<span class="tok-s2">&quot;sources&quot;</span><span class="tok-o">:</span> <span class="tok-p">[</span>
3888+
<span class="tok-p">..</span> <span class="tok-p">.</span>
3889+
<span class="tok-p">],</span>
3890+
<span class="tok-s2">&quot;generate-merlin&quot;</span> <span class="tok-o">:</span> <span class="tok-kc">true</span> <b class="conum">(2)</b>
3891+
<span class="tok-p">}</span></code></pre>
3892+
</div>
3893+
</div>
3894+
<div class="colist arabic">
3895+
<ol>
3896+
<li>
3897+
<p>Yet another BuckleScript dependency</p>
3898+
</li>
3899+
<li>
3900+
<p>bsb will generate merlin file for you</p>
3901+
</li>
3902+
</ol>
3903+
</div>
3904+
<div class="listingblock">
3905+
<div class="title">package.json</div>
3906+
<div class="content">
3907+
<pre class="pygments highlight"><code data-lang="js"><span class="tok-p">{</span>
3908+
<span class="tok-s2">&quot;dependencies&quot;</span><span class="tok-o">:</span> <span class="tok-p">{</span>
3909+
<span class="tok-s2">&quot;bs-mocha&quot;</span><span class="tok-o">:</span> <span class="tok-s2">&quot;0.1.5&quot;</span>
3910+
<span class="tok-p">},</span>
3911+
<span class="tok-p">...</span>
3912+
<span class="tok-p">}</span></code></pre>
3913+
</div>
3914+
</div>
3915+
<div class="paragraph">
3916+
<p>After your <code>npm install</code>,</p>
3917+
</div>
3918+
<div class="listingblock">
3919+
<div class="content">
3920+
<pre class="pygments highlight"><code data-lang="sh">bsb -clean-world <b class="conum">(1)</b>
3921+
bsb -make-world <b class="conum">(2)</b></code></pre>
3922+
</div>
3923+
</div>
3924+
<div class="colist arabic">
3925+
<ol>
3926+
<li>
3927+
<p>Clean the binary artifact of current build and your dependency</p>
3928+
</li>
3929+
<li>
3930+
<p>Build dependencies and lib itself</p>
3931+
</li>
3932+
</ol>
3933+
</div>
3934+
</div>
3935+
<div class="sect3">
3936+
<h4 id="_mark_your_directory_as_dev_only"><a class="anchor" href="#_mark_your_directory_as_dev_only"></a>Mark your directory as dev only</h4>
3937+
<div class="paragraph">
3938+
<p>Note sometimes, you have directories which are just tests that you don&#8217;t need your dependent
3939+
to build in that case you can mark it as dev only</p>
3940+
</div>
3941+
<div class="listingblock">
3942+
<div class="title">bsconfig.json</div>
3943+
<div class="content">
3944+
<pre class="pygments highlight"><code data-lang="js"><span class="tok-p">{</span>
3945+
<span class="tok-s2">&quot;sources&quot;</span> <span class="tok-o">:</span> <span class="tok-p">{</span>
3946+
<span class="tok-s2">&quot;dir&quot;</span> <span class="tok-o">:</span> <span class="tok-s2">&quot;test&quot;</span><span class="tok-p">,</span>
3947+
<span class="tok-s2">&quot;type&quot;</span> <span class="tok-o">:</span> <span class="tok-s2">&quot;dev&quot;</span> <b class="conum">(1)</b>
3948+
<span class="tok-p">}</span>
3949+
<span class="tok-p">}</span></code></pre>
3950+
</div>
3951+
</div>
3952+
<div class="colist arabic">
3953+
<ol>
3954+
<li>
3955+
<p>directory <code>test</code> is in dev mode, it will not be built when used as a dependency</p>
3956+
</li>
3957+
</ol>
3958+
</div>
3959+
</div>
38733960
</div>
38743961
<div class="sect2">
38753962
<h3 id="_build_using_make"><a class="anchor" href="#_build_using_make"></a>Build using Make</h3>
3963+
<div class="admonitionblock warning">
3964+
<table>
3965+
<tr>
3966+
<td class="icon">
3967+
<div class="title">Warning</div>
3968+
</td>
3969+
<td class="content">
3970+
<div class="paragraph">
3971+
<p><code>bsb</code> is officialy recommended build system, this section is listed here only for people who
3972+
are curious about how the build works</p>
3973+
</div>
3974+
</td>
3975+
</tr>
3976+
</table>
3977+
</div>
38763978
<div class="paragraph">
38773979
<p>BuckleScript distribution has <code>bsdep.exe</code> which has the same interface as <code>ocamldep</code></p>
38783980
</div>

docs/docson/build-schema.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@
5151
"ppx-specs": {
5252
"$ref": "#/definitions/ppx-specs"
5353
},
54+
"type" : {
55+
"enum" : ["dev", "lib"]
56+
},
5457
"files": {
5558
"oneOf": [
5659
{

jscomp/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ BSB_SRCS= bsb_config bsb_build_schemas bsb_build_util \
255255

256256
BSB_CMXS=$(addprefix bsb/, $(addsuffix .cmx, $(BSB_SRCS)))
257257
MAIN_SRCS= jsgen_main jscmj_main bsb/bsb_main bsb/bsb_helper_main
258-
MAINS_CMXS=$(addsuffix .cmx, $(MAIN_SRCS))
258+
MAIN_CMXS=$(addsuffix .cmx, $(MAIN_SRCS))
259259

260260
ounit.cmxa: $(OUNIT_CMXS)
261261
ocamlopt.opt -a $^ -o $@

jscomp/all.depend

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -642,9 +642,9 @@ ounit_tests/ounit_tests_main.cmx : ext/resize_array.cmx \
642642
bsb/bsb_build_schemas.cmx :
643643
bsb/bsb_build_ui.cmx : ext/string_vec.cmx ext/string_set.cmx \
644644
ext/string_map.cmx ext/ext_string.cmx ext/ext_json.cmx \
645-
ext/ext_filename.cmx ext/ext_file_pp.cmx bsb/bsb_dir.cmx \
646-
bsb/bsb_build_util.cmx bsb/bsb_build_schemas.cmx common/binary_cache.cmx \
647-
bsb/bsb_build_ui.cmi
645+
ext/ext_filename.cmx ext/ext_file_pp.cmx ext/ext_array.cmx \
646+
bsb/bsb_dir.cmx bsb/bsb_config.cmx bsb/bsb_build_util.cmx \
647+
bsb/bsb_build_schemas.cmx common/binary_cache.cmx bsb/bsb_build_ui.cmi
648648
bsb/bsb_build_util.cmx : ext/ext_string.cmx ext/ext_list.cmx \
649649
ext/ext_json.cmx ext/ext_filename.cmx ext/ext_array.cmx \
650650
bsb/bsb_config.cmx bsb/bsb_build_util.cmi
@@ -657,7 +657,8 @@ bsb/bsb_dep_infos.cmx : bsb/bsb_dep_infos.cmi
657657
bsb/bsb_dir.cmx : bsb/bsb_dir.cmi
658658
bsb/bsb_gen.cmx : ext/string_map.cmx ext/literals.cmx ext/ext_filename.cmx \
659659
bsb/bsb_ninja.cmx bsb/bsb_config.cmx bsb/bsb_build_util.cmx \
660-
bsb/bsb_build_ui.cmx common/binary_cache.cmx bsb/bsb_gen.cmi
660+
bsb/bsb_build_ui.cmx bsb/bsb_build_schemas.cmx common/binary_cache.cmx \
661+
bsb/bsb_gen.cmi
661662
bsb/bsb_helper_main.cmx : depends/depends_post_process.cmx \
662663
bsb/bsb_helper_main.cmi
663664
bsb/bsb_main.cmx : ext/string_vec.cmx ext/literals.cmx ext/ext_string.cmx \
@@ -667,7 +668,8 @@ bsb/bsb_main.cmx : ext/string_vec.cmx ext/literals.cmx ext/ext_string.cmx \
667668
bsb/bsb_build_ui.cmx bsb/bsb_build_schemas.cmx bsb/bsb_main.cmi
668669
bsb/bsb_ninja.cmx : ext/string_set.cmx ext/string_map.cmx ext/literals.cmx \
669670
ext/ext_filename.cmx bsb/bsb_config.cmx bsb/bsb_build_util.cmx \
670-
bsb/bsb_build_ui.cmx common/binary_cache.cmx bsb/bsb_ninja.cmi
671+
bsb/bsb_build_ui.cmx bsb/bsb_build_schemas.cmx common/binary_cache.cmx \
672+
bsb/bsb_ninja.cmi
671673
bsb/bsb_unix.cmx : bsb/bsb_unix.cmi
672674
bsb/bsb_build_ui.cmi : ext/string_set.cmi ext/string_map.cmi \
673675
ext/ext_json.cmi ext/ext_file_pp.cmi common/binary_cache.cmi

jscomp/bin/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ifndef EXE
66
endif
77
NATIVE=ocamlopt.opt$(EXE)
88

9-
OCAMLOPT_FLAGS= -g -inline 1000 -w -a ../stubs/ext_basic_hash_stubs.c
9+
OCAMLOPT_FLAGS= -inline 1000 -g -w -a ../stubs/ext_basic_hash_stubs.c
1010

1111
bsppx.exe: config_bsppx.mli config_bsppx.ml bsppx.mli bsppx.ml
1212
$(NATIVE) $(OCAMLOPT_FLAGS) $^ -o $@

jscomp/bin/all_ounit_tests.ml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1313,6 +1313,7 @@ val find_and_split :
13131313

13141314
val exists : ('a -> bool) -> 'a array -> bool
13151315

1316+
val is_empty : 'a array -> bool
13161317
end = struct
13171318
#1 "ext_array.ml"
13181319
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
@@ -1493,6 +1494,9 @@ let exists p a =
14931494
else loop (succ i) in
14941495
loop 0
14951496

1497+
1498+
let is_empty arr =
1499+
Array.length arr = 0
14961500
end
14971501
module Ext_bytes : sig
14981502
#1 "ext_bytes.mli"

0 commit comments

Comments
 (0)