Skip to content

Commit

Permalink
Build opam with the builtin 0install solver whenever possible
Browse files Browse the repository at this point in the history
  • Loading branch information
kit-ty-kate committed Apr 22, 2021
1 parent 3c026c2 commit 36f8cc2
Show file tree
Hide file tree
Showing 7 changed files with 158 additions and 5 deletions.
1 change: 1 addition & 0 deletions Makefile.config.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ PACKS = $(filter-out no,@OCAML_PKG_unix@ @OCAML_PKG_bigarray@ @OCAML_PKG_extlib@
CONF_OCAMLFLAGS = @CONF_OCAMLFLAGS@

MCCS_ENABLED = @MCCS_ENABLED@
OPAM_0INSTALL_SOLVER_ENABLED = @OPAM_0INSTALL_SOLVER_ENABLED@

OCAMLLIB = @OCAMLLIB@

Expand Down
107 changes: 105 additions & 2 deletions configure

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 24 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ AC_ARG_WITH([mccs],
AC_HELP_STRING([--without-mccs],
[Compile without a built-in Cudf solver (only works if 'mccs' is not otherwise installed)]),[],[MCCS_DEFAULT=yes]
)
AC_ARG_WITH([0install-solver],
AC_HELP_STRING([--without-0install-solver],
[Compile without the built-in 0install solver (only works if 'opam-0install-cudf' is not otherwise installed)]),
[],
[OPAM_0INSTALL_SOLVER_DEFAULT=yes]
)


AC_ARG_WITH([libacl],
AC_HELP_STRING([--with-libacl],
Expand Down Expand Up @@ -144,6 +151,7 @@ AS_IF([test "x${enable_developer_mode}" = "xyes"],[
])

AS_IF([test "x${with_mccs}" = "xno"], [AC_SUBST(MCCS_ENABLED,false)], [AC_SUBST(MCCS_ENABLED,true)])
AS_IF([test "x${with_0install_solver}" = "xno"], [AC_SUBST(OPAM_0INSTALL_SOLVER_ENABLED,false)], [AC_SUBST(OPAM_0INSTALL_SOLVER_ENABLED,true)])

AS_IF([test "x${with_libacl}" != "xno"],[
have_libacl=yes
Expand Down Expand Up @@ -321,9 +329,12 @@ AC_CHECK_OCAML_PKG(dose3.common,dose.common)
AC_CHECK_OCAML_PKG(dose3.algo,dose.algo)
AC_CHECK_OCAML_PKG([opam-file-format])
AC_CHECK_OCAML_PKG([mccs])
AC_CHECK_OCAML_PKG([opam-0install-cudf])

AS_IF([test "x${with_mccs}" = "xno" && test "x$OCAML_PKG_mccs" != "xno"],
[AC_MSG_ERROR([Option --without-mccs is not available without uninstalling the 'mccs' package])])
AS_IF([test "x${with_0install_solver}" = "xno" && test "x$OCAML_PKG_opam_0install_cudf" != "xno"],
[AC_MSG_ERROR([Option --without-0install-solver is not available without uninstalling the 'opam-0install-cudf' package])])

dnl -- that's what we would like to do, but no way to disable mccs in jbuilder
dnl -- if it's installed, at the moment
Expand All @@ -349,6 +360,16 @@ AS_IF([test "x$MCCS_ENABLED" = "xtrue"],[
])
])

AS_IF([test "x$MCCS_ENABLED" = "xtrue"],[
AX_COMPARE_VERSION([$OCAMLVERSION], [lt], [4.08],[
AS_IF([test "x$OPAM_0INSTALL_SOLVER_DEFAULT" = "xyes"],[
AC_SUBST(OPAM_0INSTALL_SOLVER_ENABLED,false)
],[
AC_MSG_ERROR([Your version of OCaml: $OCAMLVERSION does not support the requested 0install-solver. \
You can either re-run the configure script with --without-0install-solver or use make cold])
])
])
])

dnl echo
dnl echo "extlib........................ ${OCAML_PKG_extlib}"
Expand All @@ -368,7 +389,8 @@ AS_IF([test "x${enable_checks}" != "xno" && {
test "x$OCAML_PKG_dose3_common" = "xno" ||
test "x$OCAML_PKG_opam_file_format" = "xno" ||
test "x$CPPO" = "x" ||
test "x$OCAML_PKG_mccs$MCCS_ENABLED" = "xnotrue";}],[
test "x$OCAML_PKG_mccs$MCCS_ENABLED" = "xnotrue" ||
test "x$OCAML_PKG_opam_0install_cudf$OPAM_0INSTALL_SOLVER_ENABLED" = "xnotrue";}],[
echo "============================================================================"
echo "Some dependencies are missing. If you are just interested in the stand-alone"
echo "'opam' binary, run 'make lib-ext' to download and include them."
Expand Down Expand Up @@ -423,7 +445,7 @@ bindir="`eval echo ${bindir}`"
mandir="`eval echo ${mandir}`"
mandir="`eval echo ${mandir}`"

AS_IF([test "x$MCCS_ENABLED" = "xfalse"],[
AS_IF([test "x$MCCS_ENABLED" = "xfalse" -a "x$OPAM_0INSTALL_SOLVER_ENABLED" = "xfalse"],[
echo "Opam will be built WITHOUT a built-in solver"
],[
echo "Opam will be built WITH a built-in solver"
Expand Down
1 change: 1 addition & 0 deletions master_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ New option/command/subcommand are prefixed with ◈.
* Fix Cudf preprocessing [#4534 #4627 @AltGr - fix #4624]
* Allow to upgrade to a hidden-version package if a hidden-version package is already installed [#4525 @kit-ty-kate]
* Add support for a few select criteria useful to CI to the 0install solver: `+count[version-lag,solution]` to always choose the oldest version available, `+removed` to not try to keep installed packages [#4631 @kit-ty-kate]
* Build opam with the builtin 0install solver whenever possible [#4643 @kit-ty-kate]

## Client
* ✘ Environment variables initialised only at opam client launch, no more via libraries [#4606 @rjbou]
Expand Down
6 changes: 5 additions & 1 deletion src_ext/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,16 @@ MD5_PKG_$(1) = $(MD5_$(1))
endef

SRC_EXTS = cppo extlib re cmdliner ocamlgraph cudf dose3 opam-file-format result seq stdlib-shims
PKG_EXTS = $(SRC_EXTS) dune-local findlib ocamlbuild topkg mccs
PKG_EXTS = $(SRC_EXTS) dune-local findlib ocamlbuild topkg mccs opam-0install-cudf 0install-solver

ifeq ($(MCCS_ENABLED),true)
SRC_EXTS := $(SRC_EXTS) mccs
endif

ifeq ($(OPAM_0INSTALL_SOLVER_ENABLED),true)
SRC_EXTS := $(SRC_EXTS) opam-0install-cudf 0install-solver
endif

include Makefile.sources
ifneq ($(shell PATH="$(PATH)" command -v ocamlc 2>/dev/null),)
include Makefile.packages
Expand Down
12 changes: 12 additions & 0 deletions src_ext/Makefile.packages
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ dose3.pkgbuild: findlib.pkgbuild ocamlbuild.pkgbuild cppo.pkgbuild extlib.pkgbui
# mccs.pkgbuild depends on findlib because the files are explicitly installed using it
mccs.pkgbuild: dune-local.pkgbuild cudf.pkgbuild findlib.pkgbuild

opam-0install-cudf.pkgbuild: dune-local.pkgbuild cudf.pkgbuild 0install-solver.pkgbuild

0install-solver.pkgbuild: dune-local.pkgbuild

stdlib-shims.pkgbuild: dune-local.pkgbuild

dune-local.pkgbuild: findlib.pkgbuild
Expand Down Expand Up @@ -107,6 +111,14 @@ mccs-pkg-build:
ocamlfind install mccs $(addprefix _build/install/default/lib/,$(addprefix mccs/,META libmccs_stubs.$(EXT_LIB) mccs.*) stublibs/*.$(EXT_DLL))
cp -RL _build/install/default/lib/mccs/glpk $(SITELIB)/mccs/

opam-0install-cudf-pkg-build:
dune build @install -p opam-0install-cudf
dune install -p opam-0install-cudf opam-0install-cudf

0install-solver-pkg-build:
dune build @install -p 0install-solver
dune install -p 0install-solver 0install-solver

seq-pkg-build:
dune build @install -p seq
dune install -p seq seq
Expand Down
10 changes: 10 additions & 0 deletions src_ext/Makefile.sources
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ MD5_mccs = 7086eefb41e631a63e26b23577cef582

$(call PKG_SAME,mccs)

URL_opam-0install-cudf = https://github.com/ocaml-opam/opam-0install-solver/releases/download/v0.4.1/opam-0install-cudf-v0.4.1.tbz
MD5_opam-0install-cudf = 44e6d5a7fcdbc130db5dc86a6b9aeca6

$(call PKG_SAME,opam-0install-cudf)

URL_0install-solver = https://github.com/0install/0install/releases/download/v2.17/0install-v2.17.tbz
MD5_0install-solver = 50daf035b04b29399a3c6e6f965ac447

$(call PKG_SAME,0install-solver)

URL_opam-file-format = https://github.com/ocaml/opam-file-format/archive/2.1.2.tar.gz
MD5_opam-file-format = f16ed774167fc1881876b8185087e0ab

Expand Down

0 comments on commit 36f8cc2

Please sign in to comment.