Skip to content

Commit

Permalink
Fix for handling bytes.ml in OCaml versions less than 4.02
Browse files Browse the repository at this point in the history
  • Loading branch information
David Broman committed Feb 8, 2015
1 parent 29e39d1 commit 86f8cdd
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#



DIRS = src,test

.PHONY: all test clean

all: libs apidoc
all: bytesfix libs apidoc
ocamlbuild -Is $(DIRS) ucamlib.cma
ocamlbuild -Is $(DIRS) ucamlib.cmxa
@rm -f bytes.ml
@cp _build/src/ucamlib.cma libs/.
@cp _build/src/ucamlib.cmxa libs/.
@echo "--------------------------------------"
Expand All @@ -55,10 +58,23 @@ clean:
ocamlbuild -clean
@rm -rf libs
@rm -rf doc/api
@rm -f bytes.ml
@echo ""
@echo "Finished cleaning project."


# Solves a problem because of the introduction of Bytes.ml in the standard
# library in OCaml version 4.02. In the fix, we create a bytes.ml file locally
# if the current OCaml version does not inclue bytes.ml
BYTES = "let length s = String.length s\n"\
"let create l = String.create l\n"\
"let get s n = String.get s n\n"\
"let set s n c = String.set s n c\n"

bytesfix:
@echo "let main = Bytes.create 1" > t.ml
@ocaml t.ml >/dev/null 2>&1 || echo $(BYTES) > bytes.ml
@rm -f t.ml



Expand Down

0 comments on commit 86f8cdd

Please sign in to comment.