Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

21 changes: 15 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,31 +53,40 @@ Note that you have to clone this project with `--recursive` option, as the core
### Linux and Mac OSX


1. Apply the patch to OCaml compiler and build
1. Build the patched OCaml Compiler

Please ignore the warnings generated by git apply
Checkout the `master` branch in the [OCaml Repo](https://github.com/bloomberg/ocaml/tree/master)

For exmaple:

```sh
cd ocaml
git apply ../js.diff
git clone https://github.com/bloomberg/ocaml
cd ./ocaml
git checkout master
./configure -prefix `pwd`
make world.opt
make install
```

The patched compiler is installed locally into your `$(pwd)/bin`
directory, check if `ocamlc.opt` and `ocamlopt.opt` are there, add
them into your `$(PATH)`.

2. Build OCamlScript Compiler

Assume that you have `ocamlopt.opt` in the `PATH`
```sh
cd ../jscomp
cd ./jscomp
ocamlopt.opt -I +compiler-libs -I bin -c bin/compiler.mli bin/compiler.ml
ocamlopt.opt -g -linkall -o bin/osc -I +compiler-libs ocamlcommon.cmxa ocamlbytecomp.cmxa bin/compiler.cmx main.cmx
```

Now you have a binary called `osc` under `jscomp/bin` directory,
put it in your `PATH`.


Our compiler is released as a single file so that for release-builds
it does not need any build system(easier to be supported on Windows Platform).

3. Test

Create a file called `hello.ml`:
Expand Down
134,129 changes: 0 additions & 134,129 deletions js.diff

This file was deleted.

1,856 changes: 1,065 additions & 791 deletions jscomp/bin/compiler.ml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion jscomp/j_helper.ml
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ module Exp = struct
match v.expression_desc with
| Str (_, x) ->
assert (String.length x = 1) ;
int ~comment:("\"" ^ Ext_string.escaped x ^ "\"")
int ~comment:(Printf.sprintf "%S" x )
(Char.code x.[0])
| Char_of_int v -> v
| _ -> {comment; expression_desc = Char_to_int v }
Expand Down
80 changes: 40 additions & 40 deletions jscomp/js_cmj_datasets.ml

Large diffs are not rendered by default.

42 changes: 42 additions & 0 deletions jscomp/tools/ocaml_pack.ml
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,48 @@ include
}, []))
}])) : Parsetree.attribute))
};
{
Parsetree.pstr_loc = _loc;
pstr_desc =
(Pstr_attribute
(({ loc = _loc; txt = "ocaml.doc" },
(PStr
[{
Parsetree.pstr_loc = _loc;
pstr_desc =
(Pstr_eval
({
pexp_loc = _loc;
pexp_desc =
(Pexp_constant
(Const_string
({|
OCamlScript compiler
Copyright (C) 2015-2016 Bloomberg Finance L.P.

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, with linking exception;
either version 2.1 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.


Author: Hongbo Zhang

|},
None)));
pexp_attributes = []
}, []))
}])) : Parsetree.attribute))
};
str_item]
end
end
83 changes: 62 additions & 21 deletions jscomp/tools/ocaml_pack_main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -47,27 +47,68 @@ let _ =

let str_item = Ocaml_extract.process files in
Pprintast.structure Format.std_formatter
[{
Parsetree.pstr_loc = _loc;
pstr_desc =
(Pstr_attribute
(({ loc = _loc; txt = "warning" },
(PStr
[{
Parsetree.pstr_loc = _loc;
pstr_desc =
(Pstr_eval
({
pexp_loc = _loc;
pexp_desc =
(Pexp_constant (** my personal preferrence *)
(Const_string ("-a", None)));
pexp_attributes = []
}, []))
}])) : Parsetree.attribute))
};
str_item
]
[
{
Parsetree.pstr_loc = _loc;
pstr_desc =
(Pstr_attribute
(({ loc = _loc; txt = "warning" },
(PStr
[{
Parsetree.pstr_loc = _loc;
pstr_desc =
(Pstr_eval
({
pexp_loc = _loc;
pexp_desc =
(Pexp_constant (** my personal preferrence *)
(Const_string ("-a", None)));
pexp_attributes = []
}, []))
}])) : Parsetree.attribute))
} ;
{
Parsetree.pstr_loc = _loc;
pstr_desc =
(Pstr_attribute
(({ loc = _loc; txt = "ocaml.doc"},
(PStr
[{
Parsetree.pstr_loc = _loc;
pstr_desc =
(Pstr_eval
({
pexp_loc = _loc;
pexp_desc =
(Pexp_constant (** Copy right header *)
(Const_string ({|
OCamlScript compiler
Copyright (C) 2015-2016 Bloomberg Finance L.P.

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, with linking exception;
either version 2.1 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.


Author: Hongbo Zhang

|}, None)));
pexp_attributes = []
}, []))
}])) : Parsetree.attribute))
};
str_item
]

(* local variables: *)
(* compile-command: "ocamlbuild -no-hygiene -cflags -annot -use-ocamlfind -pkg compiler-libs.common ocaml_pack_main.byte " *)
Expand Down
1 change: 0 additions & 1 deletion ocaml
Submodule ocaml deleted from 6497b0