Skip to content

Commit

Permalink
Fixed: Bundles compilation and pyml update
Browse files Browse the repository at this point in the history
- %.cmx: %.cmo dependency (with .ml files that do not have .mli,
  compiling the .ml into .cmo or into .cmx both write to the same .cmi
  file, so that cannot be done concurrently)
- untarred pyml distribution to ease updates
- Python exception catched in pycocci interface
  • Loading branch information
thierry-martinez committed Jun 26, 2016
1 parent cfb9c00 commit 62f2df8
Show file tree
Hide file tree
Showing 27 changed files with 5,185 additions and 31 deletions.
6 changes: 1 addition & 5 deletions bundles/Makefile.bundles
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ clean:
rm -f $(patsubst %,$(SRC_DIR)/%.cmx,$(MODULES))
rm -f $(patsubst %,$(SRC_DIR)/%.cmo,$(MODULES))

distclean: clean
rm -rf $(PACKAGE_DIR)
rm -f .prepare

depend: .depend

.depend: .prepare $(patsubst %,$(SRC_DIR)/%.ml,$(PRODUCTS))
Expand Down Expand Up @@ -100,7 +96,7 @@ $(SRC_DIR)/dll$(LIBRARY)_stubs.so: $(SRC_DIR)/lib$(LIBRARY)_stubs.a
%.cmo: %.ml
$(OCAMLC_CMD) -c $< -o $@

%.cmx: %.ml
%.cmx: %.ml %.cmo
$(OCAMLOPT_CMD) -c $< -o $@

%.o: %.c
Expand Down
30 changes: 23 additions & 7 deletions bundles/menhirLib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,30 @@ include ../Makefile.bundles
depend: .depend
@$(MAKE) all-build

distclean: clean
rm -rf $(PACKAGE_DIR)
rm -f .prepare

.prepare: $(MARKER)
echo "let libdir = \"$(shell pwd\)\"" > $(SRC_DIR)/installation.ml
echo "let ocamlfind = false" >> $(SRC_DIR)/installation.ml
touch $@

$(SRC_DIR)/lexdep.mll \
$(SRC_DIR)/lexmli.mll \
$(SRC_DIR)/lexer.mll \
$(SRC_DIR)/sentenceLexer.mll \
$(SRC_DIR)/sentenceParser.mly \
$(SRC_DIR)/yacc-parser.mly: $(MARKER)

%.cmo: %.ml
if echo $(MENHIRLIB_MODULES) | grep -w $(notdir $(basename $<)); then \
$(OCAMLC_CMD) -for-pack MenhirLib -c $< -o $@; \
else \
$(OCAMLC_CMD) -c $< -o $@; \
fi

%.cmx: %.ml
%.cmx: %.ml %.cmo
if echo $(MENHIRLIB_MODULES) | grep -w $(notdir $(basename $<)); then \
$(OCAMLOPT_CMD) -for-pack MenhirLib -c $< -o $@; \
else \
Expand All @@ -58,13 +69,18 @@ $(SRC_DIR)/menhir: $(patsubst %,$(SRC_DIR)/%.cmx,$(MODULES))
standard.mly: $(SRC_DIR)/standard.mly
cp $< $@

$(SRC_DIR)/menhirLib.cmx: \
$(patsubst %,$(SRC_DIR)/%.cmx,$(MENHIRLIB_MODULES))
$(OCAMLOPT_CMD) -pack $^ -o $@

$(SRC_DIR)/menhirLib.cmi $(SRC_DIR)/menhirLib.cmo: \
$(SRC_DIR)/menhirLib.cmi \
$(SRC_DIR)/menhirLib.cmo: \
$(patsubst %,$(SRC_DIR)/%.cmo,$(MENHIRLIB_MODULES))
$(OCAMLC_CMD) -pack $^ -o $@
$(OCAMLC_CMD) -pack $^ -o $(SRC_DIR)/menhirLib.cmo

$(SRC_DIR)/menhirLib.cmx \
$(SRC_DIR)/menhirLib.o: \
$(patsubst %,$(SRC_DIR)/%.cmx,$(MENHIRLIB_MODULES)) \
$(SRC_DIR)/menhirLib.cmo
$(OCAMLOPT_CMD) -pack \
$(patsubst %,$(SRC_DIR)/%.cmx,$(MENHIRLIB_MODULES)) \
-o $(SRC_DIR)/menhirLib.cmx

$(SRC_DIR)/gSet.cmi $(SRC_DIR)/gSet.cmx: $(SRC_DIR)/gSet.ml
$(OCAMLOPT_CMD) -c $<
Expand Down
4 changes: 4 additions & 0 deletions bundles/parmap/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,9 @@ include ../Makefile.bundles
cd $(SRC_DIR) && ./configure
touch $@

distclean: clean
rm -rf $(PACKAGE_DIR)
rm -f .prepare

$(SRC_DIR)/setcore.cmi $(SRC_DIR)/setcore.cmo: $(SRC_DIR)/setcore.ml
$(OCAMLC_CMD) -c $<
4 changes: 4 additions & 0 deletions bundles/pcre/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ EXTRALNKFLAGS=$(PCRE_LIBS:%=-ldopt %)

include ../Makefile.bundles

distclean: clean
rm -rf $(PACKAGE_DIR)
rm -f .prepare

.prepare: $(MARKER)
if [ "$$OCAMLVERSION" "<" 4.02.0 ]; then \
cp $(SRC_DIR)/pcre_compat312.ml $(SRC_DIR)/pcre_compat.ml; \
Expand Down
2 changes: 1 addition & 1 deletion bundles/pyml/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
pyml-20160621
pyml-current
.prepare
10 changes: 6 additions & 4 deletions bundles/pyml/Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# This Makefile serves as a wrapper to bundle the
# pyml module without modifications.

PYML_VERSION=20160621
PYML_VERSION=current

PACKAGE_DIR=pyml-20160621
TARBALL=pyml-20160621.tar.gz
PACKAGE_DIR=pyml-$(PYML_VERSION)
TARBALL=
MODULES=pyml_compat pytypes pywrappers py pycaml_compat
OBJS=pytypes pywrappers py pycaml_compat
INTERFACES=pywrappers py pycaml_compat
Expand All @@ -23,6 +23,9 @@ PYML_COMPAT=$(shell \

include ../Makefile.bundles

distclean: clean
rm -f .prepare

$(SRC_DIR)/pywrappers.ml \
$(SRC_DIR)/pyml_wrappers.inc: \
$(MARKER) $(SRC_DIR)/generate
Expand All @@ -39,7 +42,6 @@ $(SRC_DIR)/pyml_compat.mli \
$(SRC_DIR)/$(PYML_COMPAT) \
$(SRC_DIR)/generate.ml \
$(SRC_DIR)/pytypes.mli: $(MARKER)
touch $@

$(SRC_DIR)/pywrappers.mli: $(SRC_DIR)/pywrappers.ml $(SRC_DIR)/pytypes.cmi
$(OCAMLC_CMD) -i $< >$@
Expand Down
Binary file removed bundles/pyml/pyml-20160621.tar.gz
Binary file not shown.
Empty file.
30 changes: 30 additions & 0 deletions bundles/pyml/pyml-current/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Copyright 1992-2016 The FreeBSD Project. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

The views and conclusions contained in the software and documentation
are those of the authors and should not be interpreted as representing
official policies, either expressed or implied, of the FreeBSD
Project.
5 changes: 5 additions & 0 deletions bundles/pyml/pyml-current/META
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
description = "py.ml: OCaml bindings for Python"
requires = "unix"
version = "20160620"
archive(byte) = "pyml.cma"
archive(native) = "pyml.cmxa"
180 changes: 180 additions & 0 deletions bundles/pyml/pyml-current/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
OCAMLFIND=ocamlfind

HAVE_OCAMLFIND=$(shell \
if $(OCAMLFIND) query -help >/dev/null 2>&1; then \
echo yes; \
else \
echo no; \
fi \
)

OCAMLC=$(shell \
if [ "$(HAVE_OCAMLFIND)" = yes ]; then \
echo $(OCAMLFIND) ocamlc; \
elif ocamlc.opt -version >/dev/null 2>&1; then \
echo ocamlc.opt; \
else \
echo ocamlc; \
fi \
)
OCAMLOPT=$(shell \
if [ "$(HAVE_OCAMLFIND)" = yes ]; then \
echo $(OCAMLFIND) ocamlopt; \
elif ocamlopt.opt -version >/dev/null 2>&1; then \
echo ocamlopt.opt; \
else \
echo ocamlopt; \
fi \
)
OCAMLMKLIB=$(shell \
if [ "$(HAVE_OCAMLFIND)" = yes ]; then \
echo $(OCAMLFIND) ocamlmklib; \
else \
echo ocamlmklib; \
fi \
)
OCAMLDEP=$(shell \
if [ "$(HAVE_OCAMLFIND)" = yes ]; then \
echo $(OCAMLFIND) ocamldep; \
else \
echo ocamldep; \
fi \
)
OCAMLDOC=$(shell \
if [ "$(HAVE_OCAMLFIND)" = yes ]; then \
echo $(OCAMLFIND) ocamldoc; \
else \
echo ocamldoc; \
fi \
)

MODULES=pyml_compat pytypes pywrappers py pycaml_compat
GENERATED=pyml_dlsyms.inc pyml_wrappers.inc pyml.h

VERSION=$(shell date "+%Y%m%d")

OCAMLLIBFLAGS=-cclib "-L. -lpyml_stubs"

OCAMLLIBFLAGSNATIVE=$(OCAMLLIBFLAGS)
OCAMLLIBFLAGSBYTECODE=-custom $(OCAMLLIBFLAGS)

OCAMLVERSION=$(shell $(OCAMLC) -version)

PYML_COMPAT=$(shell \
if [ "$(OCAMLVERSION)" "<" 4.00.0 ]; then \
echo pyml_compat312.ml; \
elif [ "$(OCAMLVERSION)" "<" 4.03.0 ]; then \
echo pyml_compat400.ml; \
else \
echo pyml_compat403.ml; \
fi \
)

all: py.cmi pycaml_compat.cmi pyml.cma pyml.cmxa pyml.cmxs doc

.PHONY: all tests tests.bytecode clean install

tests: pyml_tests
./pyml_tests

tests.bytecode: pyml_tests.bytecode
./pyml_tests.bytecode

doc: py.mli pycaml_compat.mli pywrappers.ml
mkdir -p $@
$(OCAMLDOC) -html -d $@ $^
touch $@

install:
$(OCAMLFIND) install pyml \
py.mli \
py.cmi pytypes.cmi pywrappers.cmi pycaml_compat.cmi \
py.cmx pytypes.cmx pywrappers.cmx pycaml_compat.cmx \
pyml.cma pyml.cmxa pyml.cmxs pyml.a \
libpyml_stubs.a dllpyml_stubs.so \
META

ifneq ($(MAKECMDGOALS),clean)
-include .depend
endif

.depend: $(MODULES:=.ml) $(MODULES:=.mli) pyml_tests.ml
$(OCAMLDEP) $^ >$@

clean:
rm -f py.cmi py.cmx py.cmo py.a py.o
rm -f pyml.cma pyml.cmxa
rm -f pytypes.cmi pytypes.cmo pytypes.cmx pytypes.o
rm -f pywrappers.mli pywrappers.ml pywrappers.cmi pywrappers.cmo
rm -f pywrappers.cmx pywrappers.o
rm -f pyml_stubs.o
rm -f generate.cmi generate.cmx
rm -f pyml_compat.ml pyml_compat.cmi pyml_compat.cmo pyml_compat.cmx
rm -f pyml_compat.o
rm -f pycaml_compat.cmi pycaml_compat.cmx pycaml_compat.cmo
rm -f pycaml_compat.a pycaml_compat.o
rm -f pyml_tests.cmi pyml_tests.cmx pyml_tests.cmo pyml_tests.a
rm -f pyml_tests.o
rm -f $(GENERATED)
rm -f .depend
rm -rf doc

tarball:
mkdir pyml-$(VERSION)/
cp Makefile pyml_compat312.ml pyml_compat400.ml pyml_compat403.ml \
pyml_compat.mli \
generate.ml py.ml py.mli pyml_stubs.c pytypes.ml pytypes.mli \
pyml_tests.ml test.py \
pycaml_compat.ml pycaml_compat.mli README LICENSE META \
pyml-$(VERSION)/
rm -f pyml-$(VERSION).tar.gz
tar -czf pyml-$(VERSION).tar.gz pyml-$(VERSION)/
rm -rf pyml-$(VERSION)/

generate: pyml_compat.cmx generate.cmx
$(OCAMLOPT) $^ -o $@

generate.cmx: generate.ml pyml_compat.cmi pyml_compat.cmx

pywrappers.ml pyml_wrappers.inc: generate
./generate

pyml_wrappers.inc: pywrappers.ml

pywrappers.mli: pywrappers.ml pytypes.cmi
$(OCAMLC) -i $< >$@

pyml_tests: py.cmi pyml.cmxa pyml_tests.cmx
$(OCAMLOPT) $(OCAMLLDFLAGS) unix.cmxa pyml.cmxa pyml_tests.cmx -o $@

pyml_tests.bytecode: py.cmi pyml.cma pyml_tests.cmo
$(OCAMLC) unix.cma pyml.cma pyml_tests.cmo -o $@

pyml_compat.ml: $(PYML_COMPAT)
cp $< $@

pyml_compat.cmx: pyml_compat.cmi

%.cmi: %.mli
$(OCAMLC) $(OCAMLCFLAGS) -c $< -o $@

%.cmo: %.ml
$(OCAMLC) $(OCAMLCFLAGS) -c $< -o $@

%.cmx: %.ml
$(OCAMLOPT) $(OCAMLCFLAGS) -c $< -o $@

pyml_stubs.o: pyml_stubs.c pyml_wrappers.inc
$(OCAMLC) -c $< -o $@

pyml.cma: $(MODULES:=.cmo) libpyml_stubs.a
$(OCAMLC) $(OCAMLLIBFLAGSBYTECODE) -a $(MODULES:=.cmo) -o $@

pyml.cmxa: $(MODULES:=.cmx) libpyml_stubs.a
$(OCAMLOPT) $(OCAMLLIBFLAGSNATIVE) -a $(MODULES:=.cmx) -o $@

pyml.cmxs: $(MODULES:=.cmx) libpyml_stubs.a
$(OCAMLOPT) $(OCAMLLIBFLAGSNATIVE) -shared $(MODULES:=.cmx) -o $@

libpyml_stubs.a: pyml_stubs.o
$(OCAMLMKLIB) -o pyml_stubs $<
43 changes: 43 additions & 0 deletions bundles/pyml/pyml-current/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
``py.ml``: OCaml bindings for Python
====================================

``py.ml`` provides OCaml bindings for ``Python 2`` and ``Python
3``. This library subsumes the ``pycaml`` library, which is no longer
actively maintained.

*Homepage:* http://pyml.gforge.inria.fr

*Documentation:* http://pyml.gforge.inria.fr/doc

*Git:* ``git clone http://pyml.gforge.inria.fr/git``

*Git Repository Browser:* http://pyml.gforge.inria.fr/browser

*Tracker for bug reports and feature requests:*
http://pyml.gforge.inria.fr/tracker

*OPAM:* ::

opam remote add pyml http://pyml.gforge.inria.fr
opam install pyml

The Python library is linked at runtime and the same executable can be
run in a Python 2 or a Python 3 environment. ``py.ml`` does not
require any Python library at compile time, nor any other
dependency. Bindings provide high level functions to convert strings
back and forth between OCaml and Python that handle Unicode strings
transparently (``Py.String.of_string`` and ``Py.String.to_string``).

Bindings are split in three modules:

- ``Pywrappers`` provides low-level bindings, which follow closely the
conventions of the C bindings for Python. Submodules
``Pywrappers.Python2`` and ``Pywrappers.Python3`` contain version-specific
bindings.

- ``Py`` provides the initialization functions and some high-level
bindings, with error handling and naming conventions closer to OCaml
usages.

- ``Pycaml_compat`` provides a signature close to the old `Pycaml`
module, so as to ease migration.
Loading

0 comments on commit 62f2df8

Please sign in to comment.