Skip to content

Commit 80fb126

Browse files
authored
Add FreeBSD (#26)
1 parent 117ce15 commit 80fb126

File tree

3 files changed

+48
-20
lines changed

3 files changed

+48
-20
lines changed

lib/cluster_build.ml

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,26 +48,34 @@ module Op = struct
4848
k.version
4949
(Current_git.Commit_id.hash k.commit)
5050

51+
let spec (k : Key.t) =
52+
Fmt.to_to_string Obuilder_spec.pp
53+
@@
54+
match Conf.DD.distro_of_tag k.distro with
55+
| None ->
56+
let os_family =
57+
if String.equal k.distro "macos-homebrew" then `Macos
58+
else if String.equal k.distro "freebsd" then `Freebsd
59+
else
60+
raise
61+
(Failure (Printf.sprintf "Distro '%s' is not available" k.distro))
62+
in
63+
Spec.v k.opam_repo_commit
64+
(Printf.sprintf "%s-ocaml-%s" k.distro k.version)
65+
os_family k.arch
66+
| Some d ->
67+
Spec.v k.opam_repo_commit k.docker_tag
68+
(Conf.DD.os_family_of_distro d)
69+
k.arch
70+
5171
let run t job (k : Key.t) () =
5272
Current.Job.on_cancel job (fun reason ->
5373
Logs.debug (fun l ->
5474
l "Calling the cluster on_cancel callback with reason: %s" reason);
5575
if reason <> "Job complete" then t.on_cancel reason;
5676
Lwt.return_unit)
5777
>>= fun () ->
58-
let spec =
59-
Fmt.to_to_string Obuilder_spec.pp
60-
@@
61-
match Conf.DD.distro_of_tag k.distro with
62-
| None ->
63-
Spec.v k.opam_repo_commit
64-
(Printf.sprintf "macos-homebrew-ocaml-%s" k.version)
65-
`Macos k.arch
66-
| Some d ->
67-
Spec.v k.opam_repo_commit k.docker_tag
68-
(Conf.DD.os_family_of_distro d)
69-
k.arch
70-
in
78+
let spec = spec k in
7179
let action = Cluster_api.Submission.obuilder_build spec in
7280
let src = Current_git.Commit_id.(repo k.commit, [ hash k.commit ]) in
7381
let cache_hint = get_cache_hint k in

lib/conf.ml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,12 @@ module Platform = struct
6969
let distro_to_os = function
7070
| "debian-11" -> "linux"
7171
| "macos-homebrew" -> "macos"
72+
| "freebsd" -> "freebsd"
7273
| s ->
7374
failwith
7475
(Printf.sprintf
7576
"Unexpected distro: '%s'. Must be one of: 'debian-11', \
76-
'macos-homebrew'"
77+
'macos-homebrew', 'freebsd'"
7778
s)
7879

7980
let label t =
@@ -125,6 +126,19 @@ let macos_platforms : Platform.t list =
125126
};
126127
]
127128

129+
let freebsd_platforms : Platform.t list =
130+
[
131+
{
132+
builder = Builders.local;
133+
pool = "freebsd-x86_64";
134+
distro = "freebsd";
135+
arch = `X86_64;
136+
docker_tag = "homebrew/brew";
137+
docker_tag_with_digest = None;
138+
ocaml_version = "5.1";
139+
};
140+
]
141+
128142
let pool_of_arch : arch -> string = function
129143
(* | `X86_64 | `I386 -> "linux-x86_64"
130144
| `Riscv64 -> "linux-riscv64" *)
@@ -203,4 +217,4 @@ let platforms () =
203217
|> List.map (fun (ocaml_version, distro, arch) ->
204218
v ~arch distro ocaml_version)
205219
in
206-
platforms @ macos_platforms |> get_digests
220+
platforms @ macos_platforms @ freebsd_platforms |> get_digests

lib/spec.ml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ let install_project_deps opam_repo_commit os arch =
33
match os with
44
| `Macos -> "~/local"
55
| `Linux -> "/usr"
6+
| `Freebsd -> "/usr/local"
67
| `Windows | `Cygwin -> failwith "Windows and Cygwin not supported"
78
in
89
let ln =
910
match os with
1011
| `Macos -> "ln"
11-
| `Linux -> "sudo ln"
12+
| `Linux | `Freebsd -> "sudo ln"
1213
| `Windows | `Cygwin -> failwith "Windows and Cygwin not supported"
1314
in
1415
let open Obuilder_spec in
@@ -26,19 +27,24 @@ let install_project_deps opam_repo_commit os arch =
2627
Obuilder_spec.Cache.v "homebrew"
2728
~target:"/Users/mac1000/Library/Caches/Homebrew";
2829
]
30+
| `Freebsd ->
31+
[
32+
Obuilder_spec.Cache.v "opam-archives"
33+
~target:"/usr/home/opam/.opam/download-cache";
34+
]
2935
| `Windows | `Cygwin -> failwith "Windows and Cygwin not supported"
3036
in
3137
let network = [ "host" ] in
3238
let home_dir =
3339
match os with
3440
| `Macos -> None
35-
| `Linux -> Some "/src"
41+
| `Linux | `Freebsd -> Some "/src"
3642
| `Windows | `Cygwin -> failwith "Windows and Cygwin not supported"
3743
in
3844
let work_dir =
3945
match os with
4046
| `Macos -> "./src/"
41-
| `Linux -> "./"
47+
| `Linux | `Freebsd -> "./"
4248
| `Windows | `Cygwin -> failwith "Windows and Cygwin not supported"
4349
in
4450
let setup_pins =
@@ -103,7 +109,7 @@ let v opam_repo_commit base os arch =
103109
let home_dir =
104110
match os with
105111
| `Macos -> "./src"
106-
| `Linux -> "/src"
112+
| `Linux | `Freebsd -> "/src"
107113
| `Windows | `Cygwin -> failwith "Windows and Cygwin not supported"
108114
in
109115
let run_build =
@@ -116,7 +122,7 @@ let v opam_repo_commit base os arch =
116122
in
117123
match os with
118124
| `Macos -> run "cd ./src && %s" build_and_test
119-
| `Linux -> run "%s" build_and_test
125+
| `Linux | `Freebsd -> run "%s" build_and_test
120126
| `Windows | `Cygwin -> failwith "Windows and Cygwin not supported"
121127
in
122128
let opam_repo_commit = Current_git.Commit_id.hash opam_repo_commit in

0 commit comments

Comments
 (0)