Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to dune ? #71

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 3 additions & 17 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
*.annot
*.cmo
*.cma
*.cmi
*.a
*.o
*.cmx
*.cmxs
*.cmxa
*.exe
*.cmt
*.cmti
dumpast
genlifter
ppx_metaquot
rewriter
ast_lifter.ml
_build
*.install
.merlin
3 changes: 0 additions & 3 deletions .merlin

This file was deleted.

12 changes: 0 additions & 12 deletions META

This file was deleted.

89 changes: 5 additions & 84 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,101 +2,22 @@
# under the terms of the MIT license (see LICENSE file).
# Copyright 2013 Alain Frisch and LexiFi

include $(shell ocamlc -where)/Makefile.config

PACKAGE = ppx_tools
VERSION = 5.0
# Don't forget to change META file as well

OCAMLC = ocamlc -bin-annot
OCAMLOPT = ocamlopt
COMPFLAGS = -w +A-4-17-44-45 -I +compiler-libs -safe-string

.PHONY: all
all: genlifter$(EXE) dumpast$(EXE) ppx_metaquot$(EXE) rewriter$(EXE) ast_mapper_class.cmo ppx_tools.cma

ifneq ($(ARCH),none)
all: ppx_tools.cmxa
ifeq ($(NATDYNLINK),true)
all: ppx_tools.cmxs
endif
endif

genlifter$(EXE): ppx_tools.cma genlifter.cmo
$(OCAMLC) $(COMPFLAGS) -o genlifter$(EXE) ocamlcommon.cma ppx_tools.cma genlifter.cmo

dumpast$(EXE): dumpast.cmo
$(OCAMLC) $(COMPFLAGS) -o dumpast$(EXE) ocamlcommon.cma ocamlbytecomp.cma ast_lifter.cmo dumpast.cmo

ppx_metaquot$(EXE): ppx_metaquot.cmo
$(OCAMLC) $(COMPFLAGS) -o ppx_metaquot$(EXE) ocamlcommon.cma ppx_tools.cma ast_lifter.cmo ppx_metaquot.cmo

rewriter$(EXE): rewriter.cmo
$(OCAMLC) $(COMPFLAGS) -o rewriter$(EXE) ocamlcommon.cma rewriter.cmo

ast_lifter.ml: genlifter$(EXE)
./genlifter$(EXE) -I +compiler-libs Parsetree.expression > ast_lifter.ml || rm -rf ast_lifter.ml


OBJS = ast_convenience.cmo ast_mapper_class.cmo

ppx_tools.cma: $(OBJS)
$(OCAMLC) -a -o ppx_tools.cma $(OBJS)
ppx_tools.cmxa: $(OBJS:.cmo=.cmx)
$(OCAMLOPT) -a -o ppx_tools.cmxa $(OBJS:.cmo=.cmx)
ppx_tools.cmxs: $(OBJS:.cmo=.cmx)
$(OCAMLOPT) -shared -o ppx_tools.cmxs -linkall ppx_tools.cmxa

all:
dune build @install

.PHONY: depend
depend:
touch ast_lifter.ml
ocamldep *.ml *.mli > .depend
-include .depend


.PHONY: clean
clean:
rm -f *.cm* *~ *.o *.obj *.a *.lib *.tar.gz *.cmxs *.cmt *.cmti
rm -f genlifter$(EXE) dumpast$(EXE) ppx_metaquot$(EXE)
rm -f ast_lifter.ml

# Default rules

.SUFFIXES: .ml .mli .cmo .cmi .cmx

.ml.cmo:
$(OCAMLC) $(COMPFLAGS) -c $<

.mli.cmi:
$(OCAMLC) $(COMPFLAGS) -c $<

.ml.cmx:
$(OCAMLOPT) $(COMPFLAGS) -c $<


# Install/uninstall
targets = $(1).mli $(1).cmi $(1).cmt $(1).cmti $(wildcard $(1).cmx)
INSTALL = META \
genlifter$(EXE) dumpast$(EXE) ppx_metaquot$(EXE) rewriter$(EXE) \
ppx_tools.cma $(wildcard ppx_tools.cmxa ppx_tools$(EXT_LIB)) \
$(wildcard ppx_tools.cmxs) \
$(call targets,ast_convenience) \
$(call targets,ast_mapper_class)

.PHONY: install
install:
ocamlfind install $(PACKAGE) $(INSTALL)

.PHONY: uninstall
uninstall:
ocamlfind remove $(PACKAGE)
dune clean

# Packaging

DISTRIB = \
README.md LICENSE META \
Makefile .depend \
README.md LICENSE \
Makefile dune ppx_tools.opam \
dumpast.ml \
genlifter.ml \
ppx_metaquot.ml \
Expand Down
42 changes: 42 additions & 0 deletions dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
(library
(name ppx_tools)
(public_name ppx_tools)
(wrapped false)
(libraries compiler-libs.common)
(modules ast_convenience ast_mapper_class))

(executable
(name genlifter)
(public_name genlifter)
(libraries compiler-libs.common ppx_tools)
(modules genlifter))

(rule
(with-stdout-to
ast_lifter.ml
(run ./genlifter.exe -I %{ocaml_where} -I %{ocaml_where}/compiler-libs Parsetree.expression)))

(library
(name ast_lifter)
(wrapped false)
(flags :standard -w -17)
(libraries compiler-libs.common)
(modules ast_lifter))

(executable
(name dumpast)
(public_name dumpast)
(libraries compiler-libs.common compiler-libs.bytecomp ast_lifter)
(modules dumpast))

(executable
(name ppx_metaquot)
(public_name ppx_metaquot)
(libraries compiler-libs.common ast_lifter ppx_tools)
(modules ppx_metaquot))

(executable
(name rewriter)
(public_name rewriter)
(libraries compiler-libs.common)
(modules rewriter))
2 changes: 2 additions & 0 deletions dune-project
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
(lang dune 1.8)
(name ppx_tools)
9 changes: 5 additions & 4 deletions opam → ppx_tools.opam
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ homepage: "https://github.com/ocaml-ppx/ppx_tools"
bug-reports: "https://github.com/ocaml-ppx/ppx_tools/issues"
dev-repo: "git://github.com/ocaml-ppx/ppx_tools.git"
tags: [ "syntax" ]
build: [[make "all"]]
install: [[make "install"]]
remove: [["ocamlfind" "remove" "ppx_tools"]]
build: [
["dune" "subst"] {pinned}
["dune" "build" "-p" name "-j" jobs]
]
depends: [
"ocamlfind" {>= "1.5.0"}
"dune" {build}
]
available: ocaml-version >= "4.06.0"