this repo has no description
1opam-version: "2.0"
2synopsis: "OCaml cross-compiler and libraries from the DKML distribution that works with at least Win32 and macOS"
3description:
4 """The DKML distribution of the OCaml bytecode and native compiler, Stdlib and the other OCaml libraries (str, unix, bigarray, etc.).
5A cross-compiler for macOS x86_64 to macOS arm64 is included; for build consistency the regular OCaml compiler will be for x86_64 regardless of whether the build machine is Apple Silicon.
6Install with something like: opam switch create dkml-4.12.1 '--formula="dkml-base-compiler" {>= "4.12.1~" & < "4.13.0~"}'"""
7maintainer: ["opensource+diskuv-ocaml@support.diskuv.com"]
8authors: ["Diskuv, Inc. <opensource+diskuv-ocaml@support.diskuv.com>"]
9license: "Apache-2.0"
10homepage: "https://github.com/diskuv/dkml-compiler"
11bug-reports: "https://github.com/diskuv/dkml-compiler/issues"
12depends: [
13 "ocaml" {= "4.12.1" & post}
14
15 "base-unix" {post}
16 "base-bigarray" {post}
17 "base-threads" {post}
18]
19conflict-class: "ocaml-core-compiler"
20flags: [ compiler avoid-version ]
21available: [
22 opam-version >= "2.1.0" &
23 ( (arch = "x86_64" & (os = "linux" | os = "win32" | os = "macos")) |
24 (arch = "arm64" & os = "macos") )
25]
26build: [
27 # Homebrew's bundle tap, needed for reproducible build auditing in drc's crossplatform-functions.sh.
28 #
29 # The Opam sandbox will stop Homebrew from auto-installing its own tap. In particular 'brew bundle ...'
30 # is automatically installed per https://github.com/Homebrew/homebrew-bundle/tree/4756e4c4cf95485c5ea4da27375946c1dac2c71d#installation,
31 # and it is an "official" tap per
32 # https://github.com/Homebrew/brew/blob/master/Library/Homebrew/official_taps.rb#L11-L18 .
33 #
34 # So our solution is to:
35 # a) Use extra-source:[] to download a Git tarball without tripping over the sandbox firewall
36 # b) Recreate a local file git repository
37 # c) Use the next build:[] steps to let Homebrew know about the bundle tap
38 #
39 # Test with: brew untap homebrew/bundle
40 ["install" "-d" "dl/homebrew-bundle"] {os = "macos"}
41 ["tar" "xCfz" "dl/homebrew-bundle" "dl/homebrew-bundle.tar.gz" "--strip-components=1"] {os = "macos"}
42 ["sh" "-c" """#!/bin/sh
43 set -eufx
44 if command -v brew; then
45 eval $(brew shellenv)
46 HOMEBREW_BREW_FILE="$(command -v brew)"
47 HOMEBREW_LIBRARY="${HOMEBREW_REPOSITORY}/Library"
48 HOMEBREW_PATH="$PATH"
49 HOMEBREW_CACHE="$PWD/dl/homebrew-cache"
50 export HOMEBREW_BREW_FILE HOMEBREW_PATH HOMEBREW_CACHE
51
52 # Clone the Library which contains the Taps/
53 # (and also Homebrew/ which is all the core scripts).
54 # * [-a] will copy and continue even if there are errors (like dangling symlinks).
55 install -d dl/homebrew
56 cp -a "$HOMEBREW_LIBRARY" dl/homebrew/ || true
57 HOMEBREW_LIBRARY="$PWD/dl/homebrew/Library"
58 export HOMEBREW_LIBRARY
59
60 # Install the tap manually by copying it. If we had used
61 # 'brew tap homebrew/bundle [URL]' or more specifically
62 # '/bin/bash "${HOMEBREW_LIBRARY}/Homebrew/brew.sh" tap homebrew/bundle [URL]'
63 # then brew would try to update its own configuration repository to say the tap was installed.
64 # It would fail with 'error: could not lock config file .git/config: Operation not permitted'
65 # because we are in a sandbox. We would have to ignore that error even though the tap was installed.
66 # too many sandbox permissions, even with a file:// URL).
67 install -d "${HOMEBREW_LIBRARY}/Taps/homebrew"
68 cp -rp dl/homebrew-bundle "${HOMEBREW_LIBRARY}/Taps/homebrew/"
69
70 /bin/bash "${HOMEBREW_LIBRARY}/Homebrew/brew.sh" bundle dump
71 test -e Brewfile
72 fi
73 """] {os = "macos"}
74
75 # OCaml source code
76 ["install" "-d" "dl/ocaml/flexdll"]
77 ["tar" "xCfz" "dl/ocaml" "dl/ocaml.tar.gz" "--strip-components=1"]
78 ["tar" "xCfz" "dl/ocaml/flexdll" "dl/flexdll.tar.gz" "--strip-components=1"]
79
80 # Create a DKMLDIR. Its structure mimics a git submodule setup.
81 # <dkmldir>/.dkmlroot
82 ["install" "-d" "dkmldir"]
83 # 4.12.1~v0.4.1 --dkml-semver--> 0.4.1
84 # 4.12.1~v0.4.1~prerel69 --dkml-semver--> 0.4.1-prerel69
85 ["sh" "-c" "printf 'dkml_root_version=%s\\n' '%{version}%' | sed 's/[0-9.]*~v//; s/~/-/' > dkmldir/.dkmlroot"]
86
87 # <dkmldir>/vendor/drc/
88 ["install" "-d" "dkmldir/vendor/drc"]
89 ["tar" "xCfz" "dkmldir/vendor/drc" "dl/dkml-runtime-common.tar.gz" "--strip-components=1"]
90
91 # <dkmldir>/vendor/dkml-compiler/
92 ["install" "-d" "dkmldir/vendor/dkml-compiler/src"]
93 ["sh" "-eufc" "tar cCf src/ - . | tar xCf dkmldir/vendor/dkml-compiler/src/ -"]
94]
95install: [
96 # Run r-c-ocaml-1-setup.sh
97 [
98 "env" "TOPDIR=dkmldir/vendor/drc/all/emptytop"
99 "DKML_REPRODUCIBLE_SYSTEM_BREWFILE=%{_:build}%/Brewfile"
100 "dkmldir/vendor/dkml-compiler/src/r-c-ocaml-1-setup.sh"
101 "-d" "dkmldir"
102 "-t" "%{prefix}%"
103 "-f" "src-ocaml"
104 "-g" "%{_:share}%/mlcross"
105 "-v" "dl/ocaml"
106 # Host architectures
107 "-ewindows_x86_64" { os = "win32" }
108 "-elinux_x86_64" { os = "linux" }
109 "-edarwin_x86_64" { os = "macos" }
110 # Target architectures (if cross-compiling)
111 "-adarwin_arm64=vendor/dkml-compiler/src/standard-compiler-env-to-ocaml-configure-env.sh" { os = "macos" }
112 # TODO: Would be nice to bundle the 3 Android cross-compilers here since they are already supported
113 # by DKML, but I (jonahbeckford@) doubt there is an Android NDK available on the Opam hosts.
114 # Confer: https://github.com/diskuv/diskuv-ocaml-ghmirror/runs/4831077050
115 # Perhaps the Android NDK should just be downloaded via an 'android-option-ndk23' package? That would give control of the NDK version.
116 # "-aandroid_arm64v8a=vendor/dkml-compiler/src/ci/github-actions-ci-to-ocaml-configure-env.sh;android_x86_64=vendor/dkml-compiler/src/ci/github-actions-ci-to-ocaml-configure-env.sh"] { os = "linux" & !ocaml-option-32bit:installed }
117 # "-aandroid_arm32v7a=vendor/dkml-compiler/src/ci/github-actions-ci-to-ocaml-configure-env.sh" { os = "linux" & ocaml-option-32bit:installed }
118 "-k" "vendor/dkml-compiler/src/standard-compiler-env-to-ocaml-configure-env.sh"
119 ]
120
121 # Run r-c-ocaml-2-build_host-noargs.sh
122 [
123 "sh" "-eufc"
124 """
125 cd '%{prefix}%'
126 share/dkml/repro/100co/vendor/dkml-compiler/src/r-c-ocaml-2-build_host-noargs.sh
127 """
128 ]
129
130 # Run r-c-ocaml-3-build_cross-noargs.sh (typically a no-op unless we are cross-compiling)
131 [
132 "sh" "-eufc"
133 """
134 cd '%{prefix}%'
135 share/dkml/repro/100co/vendor/dkml-compiler/src/r-c-ocaml-3-build_cross-noargs.sh
136 """
137 ]
138]
139dev-repo: "git+https://github.com/diskuv/dkml-component-ocamlcompiler.git"
140extra-source "dl/ocaml.tar.gz" {
141 src: "https://github.com/ocaml/ocaml/archive/4.12.1.tar.gz"
142 checksum: "sha256=f5a48a90557cb47ace7b1590fcab1362a1af38629a218350f69c225c57e96a41"
143}
144extra-source "dl/flexdll.tar.gz" {
145 src: "https://github.com/alainfrisch/flexdll/archive/0.39.tar.gz"
146 checksum: "sha256=51a6ef2e67ff475c33a76b3dc86401a0f286c9a3339ee8145053ea02d2fb5974"
147}
148extra-source "dl/homebrew-bundle.tar.gz" {
149 src: "https://github.com/Homebrew/homebrew-bundle/archive/4756e4c4cf95485c5ea4da27375946c1dac2c71d.tar.gz"
150 checksum: [
151 "sha256=10c024ca7871cea36b4c27b2601971d3fa6cba6f37855613baf0026d0f555e76"
152 ]
153}
154extra-source "dl/dkml-runtime-common.tar.gz" {
155 # This violates the v1.0.0 versioning, but this future patch is needed to allow the 'bundle'
156 # brew tap to be used on macOS in the Opam sandbox.
157 src: "https://github.com/diskuv/dkml-runtime-common/archive/refs/tags/v1.0.1-prerel0b.tar.gz"
158 checksum: [
159 "sha256=563b89382f07a4ce56917a8eb7034c5fa6993572f087ad909e58229e78748056"
160 ]
161}
162url {
163 src: "https://github.com/diskuv/dkml-compiler/releases/download/4.12.1-v1.0.0/src.tar.gz"
164 checksum: [
165 "md5=94f9e2619e329ec6b28c0c42c4e0ced5"
166 "sha512=9bb83aeccb9054153d879c33d0999e5c648bdf2dbded6f7fc3115c984592fd117ff2d7858edb38c53389bbf480050451e4bcb86ea7e7ff59279e175b48183013"
167 ]
168}