Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
8 changes: 2 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ BIN_DIR := $(SRC_DIR)/bin
LIB_DIR := $(SRC_DIR)/lib
PLUGINS_DIR := $(SRC_DIR)/plugins
PARSERS_DIR := $(SRC_DIR)/parsers
LOCK_SWITCH := alt-ergo-lock

COMMON_DIR := $(BIN_DIR)/common
BTEXT_DIR := $(BIN_DIR)/text
Expand Down Expand Up @@ -201,12 +202,7 @@ archi: $(EXTRA_DIR)/ocamldot/ocamldot
dot -Tpdf archi.dot > archi.pdf

lock:
dune build ./alt-ergo-lib.opam
opam lock ./alt-ergo-lib.opam -w
# Remove OCaml compiler constraints
sed -i \
'/"ocaml"\|"ocaml-base-compiler"\|"ocaml-system"\|"ocaml-config"\|"base-domains"\|"base-nnp"/d' \
./alt-ergo-lib.opam.locked
LOCK_SWITCH="$(LOCK_SWITCH)" ./rsc/extra/generate_lock_file.sh

dev-switch:
opam switch create . --deps-only --ignore-constraints-on alt-ergo-lib
Expand Down
43 changes: 16 additions & 27 deletions alt-ergo-lib.opam.locked
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

opam-version: "2.0"
name: "alt-ergo-lib"
version: "dev"
Expand All @@ -17,64 +18,55 @@ doc: "https://ocamlpro.github.io/alt-ergo"
bug-reports: "https://github.com/OCamlPro/alt-ergo/issues"
depends: [
"base-bigarray" {= "base"}
"base-bytes" {= "base"}
"base-threads" {= "base"}
"base-unix" {= "base"}
"camlzip" {= "1.14"}
"cmdliner" {= "2.1.0"}
"cmdliner" {= "2.1.1"}
"conf-gmp" {= "5"}
"conf-pkg-config" {= "4"}
"conf-pkg-config" {= "5"}
"conf-zlib" {= "1"}
"cppo" {= "1.8.0"}
"crunch" {= "4.0.0"}
"crunch" {= "4.1.0"}
"csexp" {= "1.5.2"}
"dolmen" {= "dev"}
"dolmen_loop" {= "dev"}
"dolmen_type" {= "dev"}
"dune" {= "3.22.0"}
"dune-build-info" {= "3.22.0"}
"dune-configurator" {= "3.22.0"}
"dune-private-libs" {= "3.22.0"}
"dune-site" {= "3.22.0"}
"dyn" {= "3.22.0"}
"dune" {= "3.24.2"}
"dune-build-info" {= "3.24.2"}
"dune-private-libs" {= "3.24.2"}
"dune-site" {= "3.24.2"}
"dyn" {= "3.24.2"}
"fmt" {= "0.11.0"}
"fs-io" {= "3.22.0"}
"fs-io" {= "3.24.2"}
"gen" {= "1.1"}
"hmap" {= "0.8.1"}
"js_of_ocaml-compiler" {= "6.2.0"}
"logs" {= "0.10.0"}
"lwt" {= "5.9.2"}
"menhir" {= "20260209"}
"menhirCST" {= "20260209"}
"menhirGLR" {= "20260209"}
"menhirLib" {= "20260209"}
"menhirSdk" {= "20260209"}
"ocaml-compiler-libs" {= "v0.12.4"}
"ocaml-options-vanilla" {= "1"}
"ocamlbuild" {= "0.16.1"}
"ocamlfind" {= "1.9.8"}
"ocplib-endian" {= "1.2"}
"ocplib-simplex" {= "0.5.1"}
"ordering" {= "3.22.0"}
"ordering" {= "3.24.2"}
"ounit2" {= "2.2.7" & with-test}
"pp" {= "2.0.0"}
"pp_loc" {= "2.1.0"}
"ptime" {= "1.2.0"}
"qcheck" {= "0.25" & with-test}
"qcheck-core" {= "0.25" & with-test}
"qcheck-ounit" {= "0.25" & with-test}
"sedlex" {= "3.7"}
"seq" {= "base"}
"sexplib0" {= "v0.16.0"}
"spelll" {= "0.4"}
"stdlib-shims" {= "0.3.0"}
"stdune" {= "3.22.0"}
"top-closure" {= "3.22.0"}
"stdune" {= "3.24.2"}
"top-closure" {= "3.24.2"}
"topkg" {= "1.1.1"}
"uutf" {= "1.0.4"}
"yojson" {= "2.2.2"}
"zarith" {= "1.14"}
]
conflicts: [
"result" {< "1.5"}
]
build: [
["dune" "subst"] {dev}
[
Expand All @@ -92,9 +84,6 @@ build: [
["dune" "install" "-p" name "--create-install-files" name]
]
dev-repo: "git+https://github.com/OCamlPro/alt-ergo.git"
conflicts: [
"result" {< "1.5"}
]
pin-depends: [
[
"dolmen.dev"
Expand Down
91 changes: 91 additions & 0 deletions alt-ergo.opam.locked
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
opam-version: "2.0"
name: "alt-ergo"
version: "dev"
synopsis: "The Alt-Ergo SMT prover"
description: """\
Alt-Ergo is an automatic theorem prover of mathematical formulas. It was developed at LRI, and is now maintained at OCamlPro.

See more details on https://alt-ergo.ocamlpro.com/"""
maintainer: "Alt-Ergo developers <alt-ergo@ocamlpro.com>"
authors: "Alt-Ergo developers <alt-ergo@ocamlpro.com>"
license: ["LicenseRef-OCamlpro-Non-Commercial" "Apache-2.0"]
tags: "org:OCamlPro"
homepage: "https://alt-ergo.ocamlpro.com/"
doc: "https://ocamlpro.github.io/alt-ergo"
bug-reports: "https://github.com/OCamlPro/alt-ergo/issues"
depends: [
"alt-ergo-lib" {= "dev"}
"base-bigarray" {= "base"}
"base-threads" {= "base"}
"base-unix" {= "base"}
"camlzip" {= "1.14"}
"cmdliner" {= "2.1.1"}
"conf-gmp" {= "5"}
"conf-pkg-config" {= "5"}
"conf-zlib" {= "1"}
"crunch" {= "4.1.0"}
"csexp" {= "1.5.2"}
"dolmen" {= "dev"}
"dolmen_loop" {= "dev"}
"dolmen_type" {= "dev"}
"dune" {= "3.24.2"}
"dune-build-info" {= "3.24.2"}
"dune-private-libs" {= "3.24.2"}
"dune-site" {= "3.24.2"}
"dyn" {= "3.24.2"}
"fmt" {= "0.11.0"}
"fs-io" {= "3.24.2"}
"gen" {= "1.1"}
"hmap" {= "0.8.1"}
"logs" {= "0.10.0"}
"menhir" {= "20260209"}
"menhirCST" {= "20260209"}
"menhirGLR" {= "20260209"}
"menhirLib" {= "20260209"}
"menhirSdk" {= "20260209"}
"ocamlbuild" {= "0.16.1"}
"ocplib-simplex" {= "0.5.1"}
"ordering" {= "3.24.2"}
"pp" {= "2.0.0"}
"pp_loc" {= "2.1.0"}
"ptime" {= "1.2.0"}
"seq" {= "base"}
"spelll" {= "0.4"}
"stdlib-shims" {= "0.3.0"}
"stdune" {= "3.24.2"}
"top-closure" {= "3.24.2"}
"topkg" {= "1.1.1"}
"uutf" {= "1.0.4"}
"zarith" {= "1.14"}
]
build: [
["dune" "subst"] {dev}
[
"dune"
"build"
"-p"
name
"-j"
jobs
"--promote-install-files=false"
"@install"
"@runtest" {with-test}
"@doc" {with-doc}
]
["dune" "install" "-p" name "--create-install-files" name]
]
dev-repo: "git+https://github.com/OCamlPro/alt-ergo.git"
pin-depends: [
[
"dolmen.dev"
"git+https://github.com/Gbury/dolmen.git#a0f1bc66e7256fff1068ac0df525a2d23c1f3ea7"
]
[
"dolmen_loop.dev"
"git+https://github.com/Gbury/dolmen.git#a0f1bc66e7256fff1068ac0df525a2d23c1f3ea7"
]
[
"dolmen_type.dev"
"git+https://github.com/Gbury/dolmen.git#a0f1bc66e7256fff1068ac0df525a2d23c1f3ea7"
]
]
1 change: 1 addition & 0 deletions nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import sources.nixpkgs {
};
});
zarith_stubs_js = self.callPackage ./zarith_stubs_js.nix { };
opam-ed = self.callPackage ./opam-ed.nix { };
});
})
];
Expand Down
25 changes: 25 additions & 0 deletions nix/opam-ed.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{ sources, lib, ocamlPackages, cmdliner_2, opam-file-format }:

let
opam-ed = sources.opam-ed;
in

ocamlPackages.buildDunePackage {
strictDeps = true;
pname = "opam-ed";
inherit (opam-ed) version;

minimalOCamlVersion = "4.08";
duneVersion = "3";

propagatedBuildInputs = with ocamlPackages; [
cmdliner_2
opam-file-format
];

src = opam-ed;

meta = with lib; {
inherit (opam-ed) homepage description;
};
}
13 changes: 13 additions & 0 deletions nix/sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,19 @@
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz",
"version": "0.5.1"
},
"opam-ed": {
"branch": "master",
"description": "A small command-line tool to help with mechanical edition of opam files",
"homepage": null,
"owner": "ocaml-opam",
"repo": "opam-ed",
"rev": "ac93c41d99987f598dffa012f73794cafdc0e487",
"sha256": "1fm38mr439pm1yndskk484z4b7l20bdp7r14ygjxfc7rdny0w31a",
"type": "tarball",
"url": "https://github.com/ocaml-opam/opam-ed/archive/ac93c41d99987f598dffa012f73794cafdc0e487.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz",
"version": "0.5"
},
"pp_loc": {
"branch": "v2.1.0",
"description": "Pretty-printing for error source locations",
Expand Down
29 changes: 29 additions & 0 deletions rsc/extra/filter_depends.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash
set -e

forbidden_fields=(
"\"ocaml\""
"\"ocaml-base-compiler\""
"\"ocaml-system\""
"\"ocaml-config\""
"\"ocaml-variants\""
"\"ocaml-compiler\""
"\"ocaml-compiler-libs\""
"\"ocaml-options-vanilla\""
"\"base-domains\""
"\"base-effects\""
"\"base-nnp\""
"\"ocamlfind\""
"\"host"
)

read input || true

for key in "${forbidden_fields[@]}"
do
if [[ "$input" =~ "$key" ]] then
exit 1
fi
done

exit 0
27 changes: 27 additions & 0 deletions rsc/extra/generate_lock_file.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash
set -e
trap cleanup EXIT
export OPAMYES=true
export OPAMSWITCH="$LOCK_SWITCH"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should either have a hardcoded default value or fail before setting the trap cleanup EXIT otherwise this risks removing the user's switch, no? I'm not too sure about how opam processes OPAMSWITCH.

@Halbaroth Halbaroth Aug 14, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A default value for LOCK_SWITCH is hardcoded in the Makefile. The trap is executed at exit with the environment of the script, so OPAMSWITCH contains the value of LOCK_SWITCH. For instance, this script

#!/usr/bin/env bash
set -e
trap cleanup EXIT

function cleanup() {
  echo "$FOO"
}

export FOO="Hello, bar!"

outputs Hello, bar! although the variable is set after the trap command.

I agree that it is too complicated. I modified the script to make it safer:

  • I moved the default value of LOCK_SWITCH into the bash script. Users can still override it with LOCK_SWITCH=... make lock.
  • The script checks if the switch already exists and fails if it does. No switch is automatically erase.
  • The script fails on unset variables.
  • I renamed LOCK_SWITCH to LOCKED_SWITCH.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A default value for LOCK_SWITCH is hardcoded in the Makefile.

I was more concerned with someone calling the script manually without going through the Makefile (I guess it's not supported but it still shouldn't have that kind of side effects)!

I like the new approach! Two remarks:

  • It should be something like : "${LOCK_SWITCH:=alt-ergo-locked}" instead of export LOCK_SWITCH="alt-ergo-locked" to actually be a default value (but a hardcoded one is fine as well) ;
  • If we fail when the switch already exists it might be a slightly better user experience to remove the one we have just created I'd say?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oups I forgot to translate the strange Makefile syntax to the strange Bash syntax...
In the last commit, the script cleans the switch after the check.


function cleanup() {
opam switch remove "$LOCK_SWITCH"
}

opam switch create "$LOCK_SWITCH" 5.4.1 --no-switch

opam install --deps-only --with-test --assume-depexts \
./alt-ergo-lib.opam \
./alt-ergo.opam

opam exec -- dune build @install @runtest -p \
alt-ergo-lib,alt-ergo

opam lock -w \
./alt-ergo-lib.opam \
./alt-ergo.opam

opam-ed -i \
"filter depends ./rsc/extra/filter_depends.sh" \
-f ./alt-ergo-lib.opam.locked \
-f ./alt-ergo.opam.locked
1 change: 1 addition & 0 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,6 @@ pkgs.mkShell {
landmarks-ppx
qcheck
utop
opam-ed
]);
}
Loading