Skip to content

Commit

Permalink
Merge pull request #2734 from OCamlPro/externalise-opam-file-fmt
Browse files Browse the repository at this point in the history
Externalise opam-file-format
  • Loading branch information
AltGr authored Oct 31, 2016
2 parents 0758f87 + 80117cf commit 6a12623
Show file tree
Hide file tree
Showing 20 changed files with 89 additions and 689 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ src_ext/cmdliner/
src_ext/extlib/
src_ext/re/
src_ext/graph/
src_ext/opam-file-format/
src_ext/*.stamp
src_ext/*.tbz
src_ext/*.tar.gz
Expand Down
8 changes: 6 additions & 2 deletions .travis-ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@ case "$TARGET" in
;;
install)
# Note: this part is cached, and must be idempotent
opam init --root=$OPAMBSROOT --yes --no-setup --compiler=$OCAML_VERSION
if [ -d "$OPAMBSROOT" ]; then
opam update --root=$OPAMBSROOT
else
opam init --root=$OPAMBSROOT --yes --no-setup --compiler=$OCAML_VERSION
fi
eval $(opam config env --root=$OPAMBSROOT)
if [ "$OPAM_TEST" = "1" ]; then
opam install ocamlfind lwt.2.5.2 cohttp.0.20.2 ssl cmdliner dose3 jsonm --yes
opam install ocamlfind lwt.2.5.2 cohttp.0.20.2 ssl cmdliner dose3 jsonm opam-file-format --yes
# Allow use of ocamlfind packages in ~/local/lib
FINDCONF=$(ocamlfind printconf conf)
sed "s%^path=.*%path=\"$HOME/local/lib:$(opam config var lib)\"%" $FINDCONF >$FINDCONF.1
Expand Down
40 changes: 0 additions & 40 deletions META.in

This file was deleted.

22 changes: 17 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,15 @@ download-ext:
clean-ext:
$(MAKE) -C src_ext distclean

clean:
clean: fastclean
$(MAKE) -C src $@
$(MAKE) -C doc $@
rm -f META *.install *.env *.err *.info *.out
rm -f *.install *.env *.err *.info *.out

distclean: clean
rm -f Makefile.config
rm -f src/*.META
rm -f src/core/opamVersion.ml

OPAMINSTALLER_FLAGS = --prefix $(DESTDIR)$(prefix)
OPAMINSTALLER_FLAGS += --mandir $(DESTDIR)$(mandir)
Expand Down Expand Up @@ -80,9 +85,16 @@ opam-devel.install:
@echo ' "_obuild/opam-installer/opam-installer.asm" {"opam-installer"}' >>$@
@echo ']' >>$@

libinstall: opam-lib.install opam-admin.top
$(if $(wildcard src_ext/lib/*),$(error Installing the opam libraries is incompatible with embedding the dependencies. Run 'make clean-ext' and try again))
src/opam-installer $(OPAMINSTALLER_FLAGS) opam-lib.install
OPAMLIBS = core format solver repository state client

installlib-%: opam-installer opam-%.install src/opam-%$(LIBEXT)
$(if $(wildcard src_ext/lib/*),\
$(error Installing the opam libraries is incompatible with embedding \
the dependencies. Run 'make clean-ext' and try again))
src/opam-installer $(OPAMINSTALLER_FLAGS) opam-$*.install

libinstall: opam-admin.top $(OPAMLIBS:%=installlib-%)
@

install: opam.install
src/opam-installer $(OPAMINSTALLER_FLAGS) $<
Expand Down
3 changes: 2 additions & 1 deletion Makefile.config.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ version = @PACKAGE_VERSION@
FETCH = @fetch@
HAS_PACKAGES = @hasalldeps@
USE_BYTE := $(if $(subst no,,@OCAMLOPT@),,true)
LIBEXT := $(if $(USE_BYTE),.cma,.cmxa)

PACKS = @OCAML_PKG_unix@ @OCAML_PKG_bigarray@ @OCAML_PKG_extlib@ @OCAML_PKG_re@ @OCAML_PKG_re_str@ @OCAML_PKG_re_pcre@ @OCAML_PKG_re_glob@ @OCAML_PKG_cmdliner@ @OCAML_PKG_ocamlgraph@ @OCAML_PKG_cudf@ @OCAML_PKG_dose3_common@ @OCAML_PKG_dose3_algo@ @OCAML_PKG_jsonm@
PACKS = @OCAML_PKG_unix@ @OCAML_PKG_bigarray@ @OCAML_PKG_extlib@ @OCAML_PKG_re@ @OCAML_PKG_re_str@ @OCAML_PKG_re_pcre@ @OCAML_PKG_re_glob@ @OCAML_PKG_cmdliner@ @OCAML_PKG_ocamlgraph@ @OCAML_PKG_cudf@ @OCAML_PKG_dose3_common@ @OCAML_PKG_dose3_algo@ @OCAML_PKG_jsonm@ @OCAML_PKG_opam_file_format@

OCAMLFIND = @OCAMLFIND@
OCAML = @OCAML@
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ easier to already have a working opam installation in this case, so you can do
it as a second step.

* Make sure to have ocamlfind, ocamlgraph, cmdliner >= 0.9.8, jsonm, cudf,
dose3 and re >= 1.2.0 installed. Or run `opam install
dose3, re >= 1.2.0, opam-file-format installed. Or run `opam install
opam-lib --deps-only` if you already have a working instance. Re-run
`./configure` once done
* Run `make libinstall` at the end
Expand Down
28 changes: 26 additions & 2 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,7 @@ PACKAGE_URL=''
ac_subst_vars='LTLIBOBJS
LIBOBJS
hasalldeps
OCAML_PKG_opam_file_format
OCAML_PKG_jsonm
OCAML_PKG_dose3_algo
OCAML_PKG_dose3_common
Expand Down Expand Up @@ -4509,6 +4510,30 @@ $as_echo "not found" >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for OCaml findlib package opam-file-format" >&5
$as_echo_n "checking for OCaml findlib package opam-file-format... " >&6; }
unset found
unset pkg
found=no
for pkg in opam-file-format ; do
if $OCAMLFIND query $pkg >/dev/null 2>/dev/null; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5
$as_echo "found" >&6; }
OCAML_PKG_opam_file_format=$pkg
found=yes
break
fi
done
if test "$found" = "no" ; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5
$as_echo "not found" >&6; }
OCAML_PKG_opam_file_format=no
fi
echo
Expand Down Expand Up @@ -4540,7 +4565,7 @@ if test "x$prefix" = "xNONE"; then
prefix=$ac_default_prefix
fi
ac_config_files="$ac_config_files Makefile.config src/core/opamVersion.ml META src/core.META src/format.META src/repository.META src/solver.META src/state.META src/client.META src/admin.META"
ac_config_files="$ac_config_files Makefile.config src/core/opamVersion.ml src/core.META src/format.META src/repository.META src/solver.META src/state.META src/client.META src/admin.META"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
Expand Down Expand Up @@ -5250,7 +5275,6 @@ do
case $ac_config_target in
"Makefile.config") CONFIG_FILES="$CONFIG_FILES Makefile.config" ;;
"src/core/opamVersion.ml") CONFIG_FILES="$CONFIG_FILES src/core/opamVersion.ml" ;;
"META") CONFIG_FILES="$CONFIG_FILES META" ;;
"src/core.META") CONFIG_FILES="$CONFIG_FILES src/core.META" ;;
"src/format.META") CONFIG_FILES="$CONFIG_FILES src/format.META" ;;
"src/repository.META") CONFIG_FILES="$CONFIG_FILES src/repository.META" ;;
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ AC_CHECK_OCAML_PKG([cudf])
AC_CHECK_OCAML_PKG(dose3.common,dose.common)
AC_CHECK_OCAML_PKG(dose3.algo,dose.algo)
AC_CHECK_OCAML_PKG([jsonm])
AC_CHECK_OCAML_PKG([opam-file-format])

dnl echo
dnl echo "extlib........................ ${OCAML_PKG_extlib}"
Expand Down Expand Up @@ -107,7 +108,6 @@ fi
AC_CONFIG_FILES(
Makefile.config
src/core/opamVersion.ml
META
src/core.META
src/format.META
src/repository.META
Expand Down
13 changes: 0 additions & 13 deletions doc/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,6 @@ <h1>OPAM %{OPAMVERSION}% API and libraries documentation</h1>
<td><em>opam-format</em> library</td>
</tr>

<tr><td colspan="2" class="libnote">
Lexer, parser and printer for the base opam syntax
</td></tr>

<tr><th><a href="ocamldoc/OpamParserTypes.html">opamParserTypes.mli</a></th>
<td>Basic value and file structure types</td></tr>
<tr><th><a href="ocamldoc/OpamLexer.html">opamLexer.mll</a></th>
<td>OPAM config file lexer</td></tr>
<tr><th><a href="ocamldoc/OpamParser.html">opamParser.mly</a></th>
<td>OPAM config file generic type parser</td></tr>
<tr><th><a href="ocamldoc/OpamPrinter.html">opamPrinter.ml</a></th>
<td>Printer for the generic opam file format</td></tr>

<tr><td colspan="2" class="libnote">
Definition of OPAM datastructures and its file interface
</td></tr>
Expand Down
1 change: 1 addition & 0 deletions opam-format.opam
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ build: [
]
depends: [
"opam-core" {= "2.0~alpha4"}
"opam-file-format" {>= "2.0~alpha4"}
]
available: ocaml-version >= "4.01.0"
20 changes: 6 additions & 14 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ endif

export OCAMLFLAGS OCAMLLDFLAGS

USE_BYTE ?=
LIBEXT = $(if $(USE_BYTE),.cma,.cmxa)
BINTARGET = $(if $(USE_BYTE),byte-code,native-code)

# --
Expand All @@ -37,7 +35,7 @@ endif

ifneq ($(HAS_LIBEXT),)
EXT_INCDIRS = ../src_ext/lib
LIBS = unix bigarray extlib re cmdliner graph cudf dose_common dose_algo uutf jsonm
LIBS = unix bigarray extlib re cmdliner graph cudf dose_common dose_algo uutf jsonm opam-file-format
else
ifeq ($(HAS_PACKAGES),)
$(error Dependencies missing. Either run 'make lib-ext' or install them and re-run './configure')
Expand All @@ -63,10 +61,10 @@ INCDIRS = $(EXT_INCDIRS) $(SUBS)

export INCDIRS

opam-lib.byte: client/opamGitVersion.ml
opam-lib.byte:
$(MAKE) $(OPAMLIB:=.cma)

opam-lib.native: client/opamGitVersion.ml
opam-lib.native:
$(MAKE) $(OPAMLIB:=.cmxa)

opam-lib: opam-lib.byte $(if $(USE_BYTE),,opam-lib.native) opam-admin.top
Expand Down Expand Up @@ -133,10 +131,6 @@ opam-repository.cma: opam-core.cma opam-format.cma ALWAYS
opam-repository.cmxa: opam-core.cmxa opam-format.cmxa ALWAYS

SRC_format = \
opamParserTypes.mli \
opamParser.mly \
opamLexer.mll \
opamPrinter.ml \
opamFormatConfig.ml \
opamLineLexer.mll \
opamRepositoryName.ml \
Expand Down Expand Up @@ -296,7 +290,7 @@ export PROJ_opam-admin
define PROJ_opam-installer
SOURCES = tools/opam_installer.ml
RESULT = opam-installer
LIBS = $(LIBS) $(OPAMLIB)
LIBS = $(LIBS) opam-core opam-format opam-state
endef
export PROJ_opam-installer

Expand Down Expand Up @@ -333,7 +327,7 @@ define lib_inst_files
.cma .cmxa .a .cmi .cmo .cmx .cmxs .cmti))
endef

../opam-%.install:
../opam-%.install: opam-%$(LIBEXT)
@echo 'lib: [' >$@
@echo ' "src/$*.META" {"META"}' >>$@
@{ $(patsubst %,echo ' "src/'%'"';,$(call lib_inst_files,$*)) } >>$@
Expand All @@ -349,8 +343,7 @@ endef
@echo ' "src/opam-admin.top"' >>$@
@echo ']' >>$@

# Older, all-inclusive opam-lib with ocamlfind sub-packages (still used by 'make
# libinstall')
# Older, all-inclusive opam-lib with ocamlfind sub-packages
../opam-lib.install: $(OPAMLIB:=.cma)
@echo 'lib: [' >$@
@echo ' "META"' >>$@
Expand Down Expand Up @@ -387,7 +380,6 @@ clean-aux:
rm -f client/opamGitVersion.ml state/opamScript.ml core/opamCompat.ml core/opamCompat.mli ../opam-lib.install
rm -f */*Parser.ml */*Parser.mli */*Lexer.ml
rm -f $(foreach e,o cmo cmx cmxs cmi cmt cmti,$(wildcard */*.$e))
rm -f *.META

clean: clean-aux

Expand Down
21 changes: 6 additions & 15 deletions src/format/opamLexer.mli → src/core/opamSHA.mli
Original file line number Diff line number Diff line change
@@ -1,27 +1,18 @@
(**************************************************************************)
(* *)
(* Copyright 2012-2015 OCamlPro *)
(* Copyright 2012 INRIA *)
(* Copyright 2016 OCamlPro *)
(* *)
(* All rights reserved. This file is distributed under the terms of the *)
(* GNU Lesser General Public License version 2.1, with the special *)
(* exception on linking described in the file LICENSE. *)
(* *)
(**************************************************************************)

(** OPAM config file lexer *)
(** Pure OCaml implementation of SHA256/512 hashing functions. Functions take a
filename and return the hash as an hex string. *)

open OpamParserTypes
val sha256: string -> string

exception Error of string
val sha512: string -> string

val relop: string -> relop

val logop: string -> logop

val pfxop: string -> pfxop

val env_update_op: string -> env_update_op


val token: Lexing.lexbuf -> OpamParser.token
val hash: [< `SHA256 | `SHA512 ] -> string -> string
2 changes: 1 addition & 1 deletion src/format.META.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ version = "@PACKAGE_VERSION@"
description = "OCaml Package Manager file format handling library"
archive(byte) = "opam-format.cma"
archive(native) = "opam-format.cmxa"
requires = "re.pcre, opam-core"
requires = "re.pcre, opam-core, opam-file-format"
5 changes: 1 addition & 4 deletions src/format/format.ocp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ then {
begin library "opam-format"
sort = false
files = [
"opamParserTypes.mli"
"opamParser.mly"
"opamLexer.mll"
"opamPrinter.ml"
"opamFormatConfig.ml"
"opamSwitch.ml"
"opamPackage.ml"
Expand All @@ -25,6 +21,7 @@ begin library "opam-format"
]

requires = [
"opam-file-format"
"opam-core"
"re.pcre"
]
Expand Down
Loading

0 comments on commit 6a12623

Please sign in to comment.