Skip to content

Commit 512da67

Browse files
committed
Dunify the build
1 parent 39df015 commit 512da67

File tree

9 files changed

+211
-38
lines changed

9 files changed

+211
-38
lines changed

.github/workflows/CI.yml

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,20 @@ jobs:
77
runs-on: ubuntu-latest
88
steps:
99
- name: Install packages
10-
run: sudo apt-get install ocaml-nox libgmp-dev
10+
run: sudo apt-get install ocaml-nox ocaml-dune libgmp-dev
1111
- name: Checkout
1212
uses: actions/checkout@v2
13-
- name: configure tree
14-
run: ./configure
1513
- name: Build
16-
run: make
17-
- name: Run the testsuite
18-
run: make -C tests test
14+
run: rm -rf tests && dune build
1915

2016
MacOS:
2117
runs-on: macos-latest
2218
steps:
2319
- name: Install packages
24-
run: brew install ocaml ocaml-findlib gmp
20+
run: brew install ocaml gmp dune
2521
- name: Checkout
2622
uses: actions/checkout@v2
27-
- name: configure tree
28-
run: ./configure
2923
- name: Build
30-
run: make
24+
run: dune build
3125
- name: Run the testsuite
32-
run: make -C tests test
26+
run: dune test

CHANGES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
## 1.12+dune (2022-04-01)
2+
3+
- PR #1: dunify the package and allow the cross-compilation via `opam monorepo`
4+
[Romain Calascibetta, Lucas Pluvinage, Thomas Gazagnaire]

Changes

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Release 1.9 (2019-08-22):
3131
- Issue #50: add opam file, make it easy to "opam publish" new versions
3232
- Issue #38: configure detects 32bit OCaml switch on 64bit host
3333
- Fix #36: change Q.equal, leq, geq comparisons for undef
34-
- Request #47: move infix comparison operators of Z in submodule
34+
- Request #47: move infix comparison operators of Z in submodule
3535
avoid shadowing the polymorphic compare [Bernhard Schommer]
3636
- Fix #49: INT_MAX undeclared
3737
- Request #46: add prefixnonocaml option [Et7f3]
@@ -47,9 +47,9 @@ Release 1.8 (2019-03-30):
4747
- Issue #22: wrong stack marking directive in caml_z_x86_64_mingw64.S
4848
[Bernhard Schommer]
4949
- Issue #24: generate and install .cmti files for easy access to documentation
50-
- Issue #25: false alarm in tests/zq.ml owing to unreliable printing
50+
- Issue #25: false alarm in tests/zq.ml owing to unreliable printing
5151
of FP values
52-
- Request #28: better handling of absolute paths in "configure"
52+
- Request #28: better handling of absolute paths in "configure"
5353

5454
Release 1.7 (2017-10-13):
5555
- Issue#14, pull request#15: ARM assembly code was broken.
@@ -117,7 +117,7 @@ Release 1.1 (2012-03-24):
117117
- PR#1034: support for static linking of GMP/MPIR
118118
- PR#1046: autodetection of ocamlopt and dynlink
119119
- PR#1048: autodetection of more platforms that we support
120-
- PR#1051: support architectures with strict alignment constraints for
120+
- PR#1051: support architectures with strict alignment constraints for
121121
64-bit integers (e.g. Sparc)
122122
- Fixed 1-bit precision loss when converting doubles to rationals
123123
- Improved support for the forthcoming release 4.00 of OCaml

discover.ml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
let () = Printexc.record_backtrace true
2+
3+
let () =
4+
if Array.length Sys.argv <> 2 then (
5+
print_endline "Usage: ./configure_env.exe %{cc}";
6+
exit 1)
7+
8+
let uname () =
9+
let ic = Unix.open_process_in "uname -s" in
10+
let s = input_line ic in
11+
String.trim s
12+
13+
module Var : sig
14+
val os : string
15+
val is_homebrew_amr64 : bool
16+
end = struct
17+
let is_homebrew_amr64 = Sys.file_exists "/opt/homebrew/bin/brew"
18+
19+
let normalise raw =
20+
match String.lowercase_ascii raw with "darwin" | "osx" -> "macos" | s -> s
21+
22+
let os = normalise (match Sys.os_type with "Unix" -> uname () | s -> s)
23+
end
24+
25+
let cc = Sys.argv.(1)
26+
27+
let ldflags =
28+
match Unix.getenv "LDFLAGS" with exception Not_found -> "" | s -> s
29+
30+
let cflags =
31+
match Unix.getenv "CFLAGS" with exception Not_found -> "" | s -> s
32+
33+
let flags =
34+
match Var.os with
35+
| "openbsd" | "freebsd" ->
36+
Printf.sprintf
37+
"LDFLAGS=\"%s -L/usr/local/lib\" CFLAGS=\"%s -I/usr/local/include\""
38+
ldflags cflags
39+
| "macos" when Var.is_homebrew_amr64 ->
40+
Printf.sprintf
41+
"LDFLAGS=\"%s -L/opt/homebrew/lib\" CFLAGS=\"%s \
42+
-I/opt/homebrew/include\""
43+
ldflags cflags
44+
| "macos" ->
45+
Printf.sprintf
46+
"LDFLAGS=\"%s -L/opt/local/lib -L/usr/local/lib\" CFLAGS=\"%s \
47+
-I/opt/local/include -I/usr/local/include\""
48+
ldflags cflags
49+
| _ -> ""
50+
51+
let () = Printf.printf "CC=\"%s\" %s%!" cc flags

dune

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
(env
2+
(dev
3+
(flags
4+
(:standard -w -6))))
5+
6+
(library
7+
(name zarith)
8+
(public_name zarith)
9+
(modules z q big_int_Z zarith_version)
10+
(wrapped false)
11+
(foreign_stubs
12+
(language c)
13+
(names caml_z)
14+
(flags
15+
:standard
16+
(:include cflags.sexp)))
17+
(c_library_flags
18+
(:include libs.sexp)))
19+
20+
(executable
21+
(name discover)
22+
(libraries unix)
23+
(modules discover))
24+
25+
(rule
26+
(target Makefile)
27+
(deps configure config.guess gmp.env)
28+
(action
29+
(with-stdout-to
30+
configure.out
31+
(bash "env %{read:gmp.env} ./configure"))))
32+
33+
(rule
34+
(target gmp.env)
35+
(deps
36+
(:exe discover.exe))
37+
(action
38+
(with-stdout-to
39+
%{target}
40+
(run %{exe} "%{cc}"))))
41+
42+
(rule
43+
(target cflags.sexp)
44+
(deps Makefile)
45+
(action
46+
(with-stdout-to
47+
%{target}
48+
(progn
49+
(bash "echo -n '('")
50+
(bash "cat Makefile | sed -n -e 's/CFLAGS=//p'")
51+
(bash "echo -n ')'")))))
52+
53+
(rule
54+
(target libs.sexp)
55+
(deps Makefile)
56+
(action
57+
(with-stdout-to
58+
%{target}
59+
(progn
60+
(bash "echo -n '('")
61+
(bash "cat Makefile | sed -n -e 's/LIBS=//p'")
62+
(bash "echo -n ')'")))))
63+
64+
(rule
65+
(deps META)
66+
(action
67+
(with-stdout-to
68+
zarith_version.ml
69+
(progn
70+
(run echo "let")
71+
(bash "grep \"version\" META | head -1")))))
72+
73+
(library
74+
(name zarith_top)
75+
(optional)
76+
(public_name zarith.top)
77+
(modules zarith_top)
78+
(libraries zarith compiler-libs.toplevel))

dune-project

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
(lang dune 2.0)
2+
(name zarith)
3+
(formatting disabled)

project.mak

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# This file is part of the Zarith library
1+
# This file is part of the Zarith library
22
# http://forge.ocamlcore.org/projects/zarith .
33
# It is distributed under LGPL 2 licensing, with static linking exception.
44
# See the LICENSE file included in the distribution.
5-
#
5+
#
66
# Copyright (c) 2010-2011 Antoine Miné, Abstraction project.
77
# Abstraction is part of the LIENS (Laboratoire d'Informatique de l'ENS),
88
# a joint laboratory by:

tests/dune

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
(env
2+
(dev
3+
(flags
4+
(:standard -w -27-35))))
5+
6+
(executable
7+
(name zq)
8+
(modes byte exe)
9+
(modules zq)
10+
(libraries zarith))
11+
12+
(rule
13+
(alias runtest)
14+
(action
15+
(progn
16+
(with-stdout-to zq.out (run ./zq.exe))
17+
(diff zq.output%{ocaml-config:word_size} zq.out))))
18+
19+
(rule
20+
(alias runtest)
21+
(action
22+
(progn
23+
(with-stdout-to zq.out.bc (run ./zq.bc))
24+
(diff zq.output%{ocaml-config:word_size} zq.out.bc))))
25+
26+
(executable
27+
(name pi)
28+
(modes exe)
29+
(modules pi)
30+
(libraries zarith))
31+
32+
(rule
33+
(alias runtest)
34+
(action
35+
(progn
36+
(with-stdout-to pi.out (run ./pi.exe 500))
37+
(diff pi.output pi.out))))
38+
39+
(test
40+
(name ofstring)
41+
(modules ofstring)
42+
(modes exe)
43+
(libraries zarith))
44+
45+
(test
46+
(name timings)
47+
(modules timings)
48+
(modes exe)
49+
(libraries zarith))
50+
51+
(test
52+
(name tofloat)
53+
(modules tofloat)
54+
(modes exe)
55+
(foreign_stubs (language c) (names setround))
56+
(libraries zarith))

zarith.opam

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,21 @@
11
opam-version: "2.0"
2-
name: "zarith"
32
maintainer: "Xavier Leroy <[email protected]>"
43
authors: [
54
"Antoine Miné"
65
"Xavier Leroy"
76
"Pascal Cuoq"
87
]
9-
homepage: "https://github.com/ocaml/Zarith"
10-
bug-reports: "https://github.com/ocaml/Zarith/issues"
11-
dev-repo: "git+https://github.com/ocaml/Zarith.git"
8+
homepage: "https://github.com/dune-universe/Zarith"
9+
bug-reports: "https://github.com//Zarith/issues"
10+
dev-repo: "git+https://github.com/dune-universe/Zarith.git"
1211
build: [
13-
["./configure"] {os != "openbsd" & os != "freebsd" & os != "macos"}
14-
[
15-
"sh"
16-
"-exc"
17-
"LDFLAGS=\"$LDFLAGS -L/usr/local/lib\" CFLAGS=\"$CFLAGS -I/usr/local/include\" ./configure"
18-
] {os = "openbsd" | os = "freebsd"}
19-
[
20-
"sh"
21-
"-exc"
22-
"LDFLAGS=\"$LDFLAGS -L/opt/local/lib -L/usr/local/lib\" CFLAGS=\"$CFLAGS -I/opt/local/include -I/usr/local/include\" ./configure"
23-
] {os = "macos"}
24-
[make]
25-
]
26-
install: [
27-
[make "install"]
12+
[ "dune" "subst" ] {pinned}
13+
[ "dune" "build" "-p" name "-j" jobs ]
14+
[ "dune" "runtest" "-p" name "-j" jobs ]
2815
]
2916
depends: [
30-
"ocaml" {>= "4.04.0"}
31-
"ocamlfind"
17+
"ocaml" {>="4.05.0"}
18+
"dune" {>="2.0"}
3219
"conf-gmp"
3320
]
3421
synopsis:

0 commit comments

Comments
 (0)