You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+59-18Lines changed: 59 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -50,8 +50,8 @@ npm run build
50
50
And whenever you modify a file in bucklescript, run this inside `jscomp/`:
51
51
52
52
```
53
-
make ../lib/bsc.exe && ./install-bsc.sh
54
-
make ../lib/bsb.exe && ./install-bsb.sh
53
+
make ../lib/bsc.exe && ./install-bsc.sh # build the compiler and make it available globally
54
+
make ../lib/bsb.exe && ./install-bsb.sh # build the build system and make it available globally
55
55
```
56
56
57
57
This will substitute the global `bsc.exe` & `bsb.exe` you just installed with the newly built one. Then run `npm build again` in the dummy project and see the changes! The iteration cycle for testing these should be around 2 seconds =).
@@ -61,16 +61,15 @@ This will substitute the global `bsc.exe` & `bsb.exe` you just installed with th
61
61
Did any of the above step not work?
62
62
63
63
- If you get compilation errors even from a supposedly clean compilation, you might have skipped the opam reinstall step above: `opam switch reinstall 4.02.3+buckle-master`
64
-
65
64
- Make sure you did "eval `opam config env`" In your CLI/bashrc/zshrc
66
-
67
65
-**If the vendored ocaml changed between when you last iterated on the repo and now**, you probably skipped the `opam switch reinstall 4.02.3+buckle-master` part. You'll have to do `git clean -xdf` and then restart with the build instructions. Careful, as `git clean` removes your uncommitted changes.
68
-
69
66
-**If these fail too**, make sure you do have the correct `ocamlopt` in your environment: `which ocamlopt` should show an `opam` path, not `reason-cli` path. If you see the latter, this means it overrode the global `ocamlopt` BuckleScript needed. In this case, either temporarily uninstall reason-cli or make sure your opam PATH overrides the reason-cli PATH (and not the other way around) in your bashrc/zshrc.
70
67
71
-
## Special Iteration Workflow
68
+
Whenever there are dependencies changes: do `make depend` in the specific directory, when available. This allows the makefile to track new dependencies.
69
+
70
+
## Change the Vendored OCaml Compiler
72
71
73
-
This section is reserved for when you're making a change to the vendored ocaml compiler itself, in vendor/ocaml, and then testing on super-errors changes at the same time. If you're doing this for whatever reason, then the previous quick iteration workflow wouldn't work. Here's what you have to do after each change:
72
+
This section is reserved for when you're making a change to the vendored ocaml compiler itself, in `vendor/ocaml`, and then testing on super-errors changes at the same time. If you're doing this for whatever reason, then the previous quick iteration workflow wouldn't work. Here's what you have to do after each change:
74
73
75
74
```
76
75
# at project root
@@ -121,27 +120,16 @@ The API reference is generated from doc comments in the source code.
121
120
Some tips and guidelines:
122
121
123
122
- The first sentence or line should be a very short summary. This is used in indexes and by tools like merlin.
124
-
125
123
- Ideally, every function should have **at least one**`@example`.
126
-
127
124
- Cross-reference another definition with `{! identifier}`. But use them sparingly, they’re a bit verbose (currently, at least).
128
-
129
125
- Wrap non-cross-referenced identifiers and other code in `[ ... ]`.
130
-
131
126
- Escape `{`, `}`, `[`, `]` and `@` using `\`.
132
-
133
127
- It’s possible to use `{%html ...}` to generate custom html, but use this very, very sparingly.
134
-
135
128
- A number of "documentation tags" are provided that would be nice to use, but unfortunately they’re often not supported for \`external\`s. Which is of course most of the API.
136
-
137
129
-`@param` usually doesn’t work. Use `{b <param>} ...` instead
138
-
139
130
-`@returns` usually doesn’t work. Use `{b returns} ...` instead.
140
-
141
131
- Always use `@deprecated` when applicable.
142
-
143
132
- Always use `@raise` when applicable.
144
-
145
133
- Always provide a `@see` tag pointing to MDN for more information when available.
146
134
147
135
See [Ocamldoc documentation](http://caml.inria.fr/pub/docs/manual-ocaml/ocamldoc.html#sec333) for more details.
@@ -151,6 +139,59 @@ To generate the html, run `make docs` in `jscomp/`.
151
139
Html generation uses a custom generator located in `odoc_gen/` and
152
140
custom styles located in `docs/api_static`.
153
141
142
+
## Make a Release
143
+
144
+
In release mode, assuming you have NodeJS and OCaml compiler with the right version installed:
145
+
146
+
```sh
147
+
node scripts/install.js
148
+
```
149
+
150
+
The build process will generate configure file with correct `LIBDIR` path,
151
+
build all binaries and libraries and
152
+
install the binaries into `bin` and lib files into `lib`.
153
+
154
+
First it will try to generate `bin/config_whole_compiler.ml` based on existing
155
+
OCaml installation, if it fails, it will try to invoke `buildocaml.sh` to
156
+
install an OCaml compiler from scratch, and retry again.
157
+
158
+
### Publish Process
159
+
160
+
- Run `make force-snapshotml`
161
+
- Bump the compiler version
162
+
163
+
## Code structure
164
+
165
+
The highlevel architecture is illustrated as below:
166
+
167
+
```
168
+
Lambda IR (OCaml compiler libs) ---+
169
+
| ^ |
170
+
| | Lambda Passes (lam_* files)
171
+
| | Optimization/inlining/dead code elimination
172
+
| \ |
173
+
| \ --------------------------+
174
+
|
175
+
| Self tail call elimination
176
+
| Constant folding + propagation
177
+
V
178
+
JS IR (J.ml) ---------------------+
179
+
| ^ |
180
+
| | JS Passes (js_* files)
181
+
| | Optimization/inlining/dead code elimination
182
+
| \ |
183
+
| \ -------------------------+
184
+
|
185
+
| Smart printer includes scope analysis
186
+
|
187
+
V
188
+
Javascript Code
189
+
```
190
+
191
+
Note that there is one design goal to keep in mind, never introduce
192
+
any meaningless symbol unless real necessary, we do optimizations,
193
+
however, it should also compile readable output code.
194
+
154
195
## Contribution Licensing
155
196
156
197
Since BuckleScript is distributed under the terms of the [LGPL Version 3](LICENSE), contributions that you make
Copy file name to clipboardExpand all lines: jscomp/README.md
+7-134Lines changed: 7 additions & 134 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,137 +1,10 @@
1
-
# Build Instructions
1
+
Hello! This is the main directory for BuckleScript. `jscomp` is just a name that mirrors OCaml's own `bytecomp` and `asmcomp` (bytecode compilation and native compilation logic respectively). For building it, please see [CONTRIBUTING.md](../CONTRIBUTING.md).
2
2
3
-
## Release mode
3
+
Extra info:
4
4
5
-
In release mode, assume you have NodeJS and
6
-
OCaml compiler with the right version installed:
5
+
## Rebuilding the browser-based playground
7
6
8
-
```sh
9
-
node scripts/install.js
10
-
```
11
-
12
-
The build process will generate configure file with correct `LIBDIR` path,
13
-
build all binaries and libraries and
14
-
install the binaries into `bin` and lib files into `lib`.
15
-
16
-
First it will try to generate `bin/config_whole_compiler.ml` based on existing
17
-
OCaml installation, if it fails, it will try to invoke `buildocaml.sh` to
18
-
install an OCaml compiler from scratch, and retry again
19
-
20
-
21
-
## Dev mode
22
-
23
-
### Setup
24
-
25
-
#### Use the correct opam switch for working on BuckleScript
26
-
```sh
27
-
opam update
28
-
opam switch 4.02.3+buckle-master
29
-
opam switch reinstall 4.02.3+buckle-master # do this if you get errors even from a clean compilation
30
-
opam install camlp4 cppo
31
-
eval`opam config env`
32
-
```
33
-
34
-
#### build BuckleScript's forked OCaml
35
-
```sh
36
-
cd vendor/ocaml
37
-
./configure -prefix `pwd`
38
-
make world.opt
39
-
make install
40
-
```
41
-
42
-
#### build all of Bucklescript
43
-
```sh
44
-
cd ../../
45
-
make world
46
-
```
47
-
48
-
### build the compiler (bsc.exe)
49
-
50
-
If you don't change the type definition of JS IR, i.e, [j.ml](./j.ml),
51
-
then the only dependency is the build tool:
52
-
`make`
53
-
54
-
```sh
55
-
rm -rf core/js_map.ml core/js_fold.ml && make core/js_map.ml core/js_fold.ml ../lib/bsc.exe
56
-
```
57
-
58
-
If you do want to change the JS IR, you also need
59
-
[camlp4](https://github.com/ocaml/camlp4), note that the version does
60
-
not need match the exact the same version of compiler.
61
-
62
-
### build the build system (bsb.exe)
63
-
64
-
```sh
65
-
make ../lib/bsb.exe && make ../lib/bsb_helper.ml && make ../lib/bsb_helper.exe
66
-
```
67
-
68
-
Generate packed ML files for PR: `make force-snapshotml`
69
-
70
-
### build the runtime
71
-
72
-
```sh
73
-
cd ./runtime; make all
74
-
```
75
-
76
-
### build the stdlib
77
-
78
-
```sh
79
-
cd ./stdlib; make all
80
-
```
81
-
82
-
Several useful targets
83
-
84
-
-`make depend` generates the `.depend` files used by make to build things in the correct order
85
-
-`make check` builds and runs the tests
86
-
-`make libs` builds the JS runtime
87
-
88
-
### Publish process
89
-
- Run `make force-snapshotml`
90
-
- Bump the compiler version
91
-
- Build the JS playground
92
-
* Generate js_compiler.ml
93
-
* Generate cmj data sets
94
-
* Generate preload.js
95
-
* Make sure AMDJS are up to date
96
-
97
-
98
-
99
-
100
-
## Code structure
101
-
102
-
The highlevel architecture is illustrated as below:
103
-
104
-
```
105
-
Lambda IR (OCaml compiler libs) ---+
106
-
| ^ |
107
-
| | Lambda Passes (lam_* files)
108
-
| | Optimization/inlining/dead code elimination
109
-
| \ |
110
-
| \ --------------------------+
111
-
|
112
-
| Self tail call elimination
113
-
| Constant folding + propagation
114
-
V
115
-
JS IR (J.ml) ---------------------+
116
-
| ^ |
117
-
| | JS Passes (js_* files)
118
-
| | Optimization/inlining/dead code elimination
119
-
| \ |
120
-
| \ -------------------------+
121
-
|
122
-
| Smart printer includes scope analysis
123
-
|
124
-
V
125
-
Javascript Code
126
-
```
127
-
128
-
Note that there is one design goal to keep in mind, never introduce
129
-
any meaningless symbol unless real necessary, we do optimizations,
130
-
however, it should also compile readable output code.
131
-
132
-
# Rebuilding the browser-based playground
133
-
134
-
## Get `js_of_ocaml` from the normal switch
7
+
### Get `js_of_ocaml` from the normal switch
135
8
136
9
```
137
10
opam switch 4.02.3
@@ -140,7 +13,7 @@ opam install js_of_ocaml
140
13
which js_of_ocaml # symlink this into your $PATH, maybe /usr/local/bin or something
141
14
```
142
15
143
-
## Do everything else from the bucklescript switch
16
+
###Do everything else from the bucklescript switch
0 commit comments