Skip to content

Commit

Permalink
Port to jbuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris00 committed Oct 28, 2017
1 parent 2379337 commit d1c8c32
Show file tree
Hide file tree
Showing 37 changed files with 1,248 additions and 411 deletions.
32 changes: 3 additions & 29 deletions .gitignore
@@ -1,16 +1,7 @@
# OCaml -*-conf-unix-*-
*.annot
*.cm[ioax]
*.cmxa
*.exe
*.com
*.byte
*.native
doc
.depend.ocaml
._d/
src/triangle
src/triangle.zip
.merlin
*.install
triangle/triangle
src/levels.tex
src/testmesh*.tex
_build
Expand All @@ -21,26 +12,9 @@ RE:.*\.ba[0-9]
*.log
*.pdf
auto/
# Test executables
tests/square
# Generated files (unmodified)
AUTHORS.txt
INSTALL.txt
README.txt
setup.data
*.clib
*.mllib
src/META
configure
API.docdir
API.odocl
src/easymeshC.ml
src/easymeshF.ml
src/mesh_displayC.ml
src/mesh_displayF.ml
src/mesh_triangleC.ml
src/mesh_triangleF.ml
src/meshC.ml
src/meshF.ml
# Tarball
*.tar.gz
62 changes: 0 additions & 62 deletions INSTALL.txt

This file was deleted.

58 changes: 9 additions & 49 deletions Makefile
@@ -1,22 +1,16 @@
WEB = mesh.forge.ocamlcore.org:/home/groups/mesh/htdocs/
TRIANGLE_URL = http://www.netlib.org/voronoi/triangle.zip

PKG_VERSION = $(shell oasis query version)
DIR = $(shell oasis query name)-$(PKG_VERSION)
TARBALL = $(DIR).tar.gz
all byte native:
jbuilder build @install #--dev

clean:
jbuilder clean

doc:
jbuilder build --dev @doc

DISTFILES = AUTHORS.txt INSTALL.txt README.txt \
Makefile myocamlbuild.ml _oasis _tags \
$(wildcard $(addprefix src/, *.ml *.mli *.clib *.mllib *.c triangle/)) \
$(wildcard tests/*.ml)

.PHONY: configure all byte native doc upload-doc install uninstall reinstall
all byte native: setup.data
ocaml setup.ml -build

BYTES_DIR = $(shell ocamlfind query bytes)
BYTES_CMA = $(wildcard $(BYTES_DIR)/bytes.cma)
BYTES_INC = $(if $(BYTES_CMA), -I $(BYTES_DIR) $(BYTES_CMA))

GENERATE_ML_FILES = ocaml $(BYTES_INC) src/make_FC_code.ml \
--pkg-version $(PKG_VERSION)
Expand Down Expand Up @@ -47,41 +41,7 @@ configure: setup.ml opam/opam
exit 2; \
fi

setup.ml: _oasis
$(GENERATE_ML_FILES)
oasis setup -setup-update dynamic

doc install uninstall reinstall: all
ocaml setup.ml -$@

opam/opam: _oasis
oasis2opam --local -y

upload-doc: doc
scp -C -p -r _build/API.docdir $(WEB)

.PHONY: dist tar
dist tar: setup.ml
mkdir -p $(DIR)
for f in $(DISTFILES); do \
cp --parents $$f $(DIR); \
done
# Generate a setup.ml independent of oasis:
cd $(DIR); $(GENERATE_ML_FILES) && oasis setup
# Download the C lib triangle, so OPAM complilation is smooth:
mkdir -p $(DIR)/src/triangle;
cd $(DIR)/src/triangle && wget $(TRIANGLE_URL) \
&& unzip triangle.zip && rm triangle.zip
tar -zcvf $(TARBALL) $(DIR)
$(RM) -r $(DIR)

.PHONY: clean distclean
clean:
ocaml setup.ml -clean
$(GENERATE_ML_FILES) --clean
$(RM) $(TARBALL)

distclean:
ocaml setup.ml -distclean
$(RM) $(wildcard src/*.clib src/*.mllib)
$(RM) $(wildcard *.ba[0-9] *.bak *~ *.odocl)
.PHONY: all byte native doc clean distclean
140 changes: 0 additions & 140 deletions _oasis

This file was deleted.

5 changes: 0 additions & 5 deletions _tags

This file was deleted.

26 changes: 26 additions & 0 deletions config/discover.ml
@@ -0,0 +1,26 @@
open Base
open Stdio

let configure t =
let module C = Configurator in
let system_libtriangle =
(* Test the presence of the header file. *)
C.c_test t ~link_flags:["-ltriangle"]
"#include <triangle.h>
int main() {
return 0;
}" in
let ccopt, cclib =
if system_libtriangle then
(* System with libtriangle *)
["-DTRILIBRARY"; "-DEXTERNAL_TEST"; "-DLIBTRIANGLE"],
["-ltriangle"]
else
["-DTRILIBRARY"; "-DEXTERNAL_TEST"], [] in
let write_sexp file sexp =
Out_channel.write_all file ~data:(Sexp.to_string sexp) in
write_sexp "c_flags.sexp" (sexp_of_list sexp_of_string ccopt);
write_sexp "c_library_flags.sexp" (sexp_of_list sexp_of_string cclib)

let () =
Configurator.main "discover" configure
11 changes: 11 additions & 0 deletions config/jbuild
@@ -0,0 +1,11 @@
(jbuild_version 1)

(executable
((name make_FC_code)
(modules (make_FC_code))
(libraries (str))))

(executable
((name discover)
(modules (Discover))
(libraries (base stdio configurator))))

0 comments on commit d1c8c32

Please sign in to comment.