-
Notifications
You must be signed in to change notification settings - Fork 569
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OCaml solutions: update to fix failing builds (#962)
- Loading branch information
Showing
20 changed files
with
192 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
_build | ||
*.native | ||
**/.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
_build | ||
*.native | ||
**/.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,14 @@ | ||
FROM primeimages/ocaml:4.12-r1 AS build | ||
FROM primeimages/ocaml:5.1 AS build | ||
|
||
RUN mkdir /home/opam/primeocaml | ||
WORKDIR /prime-ocaml | ||
|
||
WORKDIR /home/opam/primeocaml | ||
COPY . . | ||
|
||
COPY *.ml ./ | ||
RUN dune build | ||
|
||
RUN corebuild PrimeOCaml.native | ||
|
||
FROM alpine:3.13 | ||
FROM alpine:3.19 | ||
|
||
WORKDIR /app | ||
COPY --from=build /home/opam/primeocaml/PrimeOCaml.native PrimeOCaml.native | ||
COPY --from=build /prime-ocaml/_build/install/default/bin/prime-ocaml prime-ocaml.exe | ||
|
||
ENTRYPOINT [ "./PrimeOCaml.native" ] | ||
ENTRYPOINT [ "./prime-ocaml.exe" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
(executable | ||
(public_name prime-ocaml) | ||
(name main) | ||
(libraries core PrimeOCaml)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
open Core | ||
open PrimeOCaml | ||
|
||
let () = | ||
let now_in_seconds_as_float () = (Int63.to_float (Time_ns.to_int63_ns_since_epoch (Time_ns.now ()))) /. 1000000000.0 in | ||
let start_time = now_in_seconds_as_float () in | ||
let limit = 1000000 in | ||
let sieve = Ref.create (new prime_sieve limit) in | ||
let passes = Ref.create 0 in | ||
while Float.(<) ((now_in_seconds_as_float ()) -. start_time) 5.0 do | ||
sieve := new prime_sieve limit; | ||
!sieve#run_sieve; | ||
passes := !passes + 1 | ||
done; | ||
let duration = (now_in_seconds_as_float ()) -. start_time in | ||
!sieve#print_results false duration !passes; | ||
;; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
(lang dune 3.13) | ||
|
||
(name prime-ocaml) | ||
|
||
(generate_opam_files true) | ||
|
||
(authors "Greyson Potter <https://github.com/gkpotter>") | ||
|
||
(package | ||
(name prime-ocaml) | ||
(synopsis "A faithful implementation of Dave Plummer's prime | ||
sieving algorithm in OCaml.") | ||
(depends ocaml core dune)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
(library | ||
(name PrimeOCaml) | ||
(libraries core)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# This file is generated by dune, edit dune-project instead | ||
opam-version: "2.0" | ||
synopsis: """ | ||
A faithful implementation of Dave Plummer's prime | ||
sieving algorithm in OCaml.""" | ||
authors: ["Greyson Potter <https://github.com/gkpotter>"] | ||
depends: [ | ||
"ocaml" | ||
"core" | ||
"dune" {>= "3.13"} | ||
"odoc" {with-doc} | ||
] | ||
build: [ | ||
["dune" "subst"] {dev} | ||
[ | ||
"dune" | ||
"build" | ||
"-p" | ||
name | ||
"-j" | ||
jobs | ||
"@install" | ||
"@runtest" {with-test} | ||
"@doc" {with-doc} | ||
] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
_build | ||
*.native | ||
**/.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
_build | ||
*.native | ||
**/.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,14 @@ | ||
FROM primeimages/ocaml:4.12-r1 AS build | ||
FROM primeimages/ocaml:5.1 AS build | ||
|
||
RUN mkdir /home/opam/primeocaml | ||
WORKDIR /prime-ocaml-functional | ||
|
||
WORKDIR /home/opam/primeocaml | ||
COPY . . | ||
|
||
COPY *.ml ./ | ||
RUN dune build | ||
|
||
RUN corebuild PrimeOCamlFunctional.native | ||
|
||
FROM alpine:3.13 | ||
FROM alpine:3.19 | ||
|
||
WORKDIR /app | ||
COPY --from=build /home/opam/primeocaml/PrimeOCamlFunctional.native PrimeOCamlFunctional.native | ||
COPY --from=build /prime-ocaml-functional/_build/install/default/bin/prime-ocaml-functional prime-ocaml-functional.exe | ||
|
||
ENTRYPOINT [ "./PrimeOCamlFunctional.native" ] | ||
ENTRYPOINT [ "./prime-ocaml-functional.exe" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
(executable | ||
(public_name prime-ocaml-functional) | ||
(name main) | ||
(libraries core PrimeOCamlFunctional)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
open Core | ||
open PrimeOCamlFunctional | ||
|
||
let () = | ||
let now_in_seconds_as_float () = (Int63.to_float (Time_ns.to_int63_ns_since_epoch (Time_ns.now ()))) /. 1000000000.0 in | ||
let start_time = now_in_seconds_as_float () in | ||
let limit = 1000000 in | ||
let rec run_test sieve passes = | ||
if Float.(>) ((now_in_seconds_as_float ()) -. start_time) 5.0 then | ||
let duration = ((now_in_seconds_as_float ()) -. start_time) in | ||
print_results sieve false duration passes | ||
else | ||
let sieve = (create_sieve limit) in | ||
run_sieve sieve; | ||
run_test sieve (passes+1) | ||
in | ||
run_test (create_sieve limit) 0 | ||
;; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
(lang dune 3.13) | ||
|
||
(name prime-ocaml-functional) | ||
|
||
(generate_opam_files true) | ||
|
||
(authors "Greyson Potter <https://github.com/gkpotter>") | ||
|
||
(package | ||
(name prime-ocaml-functional) | ||
(synopsis "A functional implementation of Dave Plummer's prime | ||
sieving algorithm in OCaml.") | ||
(depends ocaml core dune)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
(library | ||
(name PrimeOCamlFunctional) | ||
(libraries core)) |
Oops, something went wrong.