Skip to content

Commit 5f393ff

Browse files
authored
Merge pull request ocaml#21756 from jonahbeckford/opam-publish-dkml-component-staging-ocamlrun.4.12.1-v0.4.1-prerel6
Package dkml-component-staging-ocamlrun.4.12.1~v1.0.0
2 parents 53693bc + 5ae41c5 commit 5f393ff

File tree

1 file changed

+232
-0
lines changed
  • packages/dkml-component-staging-ocamlrun/dkml-component-staging-ocamlrun.4.12.1~v1.0.0

1 file changed

+232
-0
lines changed
Lines changed: 232 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,232 @@
1+
opam-version: "2.0"
2+
synopsis: "DKML component for ocamlrun"
3+
description:
4+
"Standalone distribution of OCaml in <share>/staging-files containing just ocamlrun, the OCaml Stdlib and the other OCaml libraries (str, unix, bigarray, etc.)"
5+
maintainer: ["[email protected]"]
6+
authors: ["Diskuv, Inc. <[email protected]>"]
7+
license: "Apache-2.0"
8+
homepage: "https://github.com/diskuv/dkml-component-ocamlcompiler"
9+
bug-reports: "https://github.com/diskuv/dkml-component-ocamlcompiler/issues"
10+
depends: [
11+
"dkml-install" {>= "0.2.0"}
12+
"dune" {>= "2.9"}
13+
]
14+
available: [ os = "macos" | (os = "linux" & (arch = "x86_32" | arch = "x86_64")) | os = "win32" ]
15+
build: [
16+
# Homebrew's bundle tap, needed for reproducible build auditing in drc's crossplatform-functions.sh.
17+
#
18+
# The Opam sandbox will stop Homebrew from auto-installing its own tap. In particular 'brew bundle ...'
19+
# is automatically installed per https://github.com/Homebrew/homebrew-bundle/tree/4756e4c4cf95485c5ea4da27375946c1dac2c71d#installation,
20+
# and it is an "official" tap per
21+
# https://github.com/Homebrew/brew/blob/master/Library/Homebrew/official_taps.rb#L11-L18 .
22+
#
23+
# So our solution is to:
24+
# a) Use extra-source:[] to download a Git tarball without tripping over the sandbox firewall
25+
# b) Recreate a local file git repository
26+
# c) Use the next build:[] steps to let Homebrew know about the bundle tap
27+
#
28+
# Test with: brew untap homebrew/bundle
29+
["install" "-d" "dl/homebrew-bundle"] {os = "macos"}
30+
["tar" "xCfz" "dl/homebrew-bundle" "dl/homebrew-bundle.tar.gz" "--strip-components=1"] {os = "macos"}
31+
["sh" "-c" """#!/bin/sh
32+
set -eufx
33+
if command -v brew; then
34+
eval $(brew shellenv)
35+
HOMEBREW_BREW_FILE="$(command -v brew)"
36+
HOMEBREW_LIBRARY="${HOMEBREW_REPOSITORY}/Library"
37+
HOMEBREW_PATH="$PATH"
38+
HOMEBREW_CACHE="$PWD/dl/homebrew-cache"
39+
export HOMEBREW_BREW_FILE HOMEBREW_PATH HOMEBREW_CACHE
40+
41+
# Clone the Library which contains the Taps/
42+
# (and also Homebrew/ which is all the core scripts).
43+
# * [-a] will copy and continue even if there are errors (like dangling symlinks).
44+
install -d dl/homebrew
45+
cp -a "$HOMEBREW_LIBRARY" dl/homebrew/ || true
46+
HOMEBREW_LIBRARY="$PWD/dl/homebrew/Library"
47+
export HOMEBREW_LIBRARY
48+
49+
# Install the tap manually by copying it. If we had used
50+
# 'brew tap homebrew/bundle [URL]' or more specifically
51+
# '/bin/bash "${HOMEBREW_LIBRARY}/Homebrew/brew.sh" tap homebrew/bundle [URL]'
52+
# then brew would try to update its own configuration repository to say the tap was installed.
53+
# It would fail with 'error: could not lock config file .git/config: Operation not permitted'
54+
# because we are in a sandbox. We would have to ignore that error even though the tap was installed.
55+
# too many sandbox permissions, even with a file:// URL).
56+
install -d "${HOMEBREW_LIBRARY}/Taps/homebrew"
57+
cp -rp dl/homebrew-bundle "${HOMEBREW_LIBRARY}/Taps/homebrew/"
58+
59+
/bin/bash "${HOMEBREW_LIBRARY}/Homebrew/brew.sh" bundle dump
60+
test -e Brewfile
61+
fi
62+
"""] {os = "macos"}
63+
64+
# OCaml source code
65+
["install" "-d" "dl/ocaml/flexdll"]
66+
["tar" "xCfz" "dl/ocaml" "dl/ocaml.tar.gz" "--strip-components=1"]
67+
["tar" "xCfz" "dl/ocaml/flexdll" "dl/flexdll.tar.gz" "--strip-components=1"]
68+
69+
# Create a DKMLDIR. Its structure mimics a git submodule setup.
70+
# <dkmldir>/vendor/drc/
71+
["install" "-d" "dkmldir/vendor/drc"]
72+
["tar" "xCfz" "dkmldir/vendor/drc" "dl/dkml-runtime-common.tar.gz" "--strip-components=1"]
73+
# <dkmldir>/.dkmlroot
74+
["install" "dkmldir/vendor/drc/.template.dkmlroot" "dkmldir/.dkmlroot"]
75+
76+
# <dkmldir>/vendor/dkml-compiler/
77+
["install" "-d" "dkmldir/vendor/dkml-compiler/src"]
78+
["tar" "xCfz" "dkmldir/vendor/dkml-compiler" "dl/dkml-compiler.tar.gz" "--strip-components=1"]
79+
80+
# Developers:
81+
# Uncomment to test your own scripts
82+
#[ "diskuvbox" "copy-file" "r-c-ocaml-1-setup.sh" "dkmldir/vendor/dkml-compiler/src/r-c-ocaml-1-setup.sh" ]
83+
84+
# --------------
85+
# Build component and .api library
86+
# --------------
87+
88+
["dune" "subst"] {dev}
89+
[
90+
"dune"
91+
"build"
92+
"-p"
93+
name
94+
"-j"
95+
jobs
96+
"--promote-install-files=false"
97+
"@install"
98+
"@runtest" {with-test}
99+
"@doc" {with-doc}
100+
]
101+
["dune" "install" "-p" name "--create-install-files" name]
102+
]
103+
install: [
104+
# --------------
105+
# First pass
106+
# --------------
107+
108+
# [1] Run r-c-ocaml-1-setup.sh
109+
[
110+
"env" "TOPDIR=dkmldir/vendor/drc/all/emptytop"
111+
"DKML_REPRODUCIBLE_SYSTEM_BREWFILE=%{_:build}%/Brewfile"
112+
"dkmldir/vendor/dkml-compiler/src/r-c-ocaml-1-setup.sh"
113+
"-d" "dkmldir"
114+
"-f" "src/ocaml-1"
115+
"-k" "vendor/dkml-compiler/src/standard-compiler-env-to-ocaml-configure-env.sh"
116+
"-v" "dl/ocaml"
117+
# Host-compile into staging-files/<host-abi>
118+
"-t" "%{_:share}%/staging-files"
119+
"-pwindows_x86_64" { os = "win32" }
120+
"-plinux_x86" { os = "linux" & arch = "x86_32" }
121+
"-plinux_x86_64" { os = "linux" & arch = "x86_64" }
122+
"-pdarwin_x86_64" { os = "macos" }
123+
# ABIs
124+
"-ewindows_x86_64" { os = "win32" }
125+
"-elinux_x86" { os = "linux" & arch = "x86_32" }
126+
"-elinux_x86_64" { os = "linux" & arch = "x86_64" }
127+
"-edarwin_x86_64" { os = "macos" }
128+
# Cross-compile into staging-files/<cross-abi>
129+
"-g" "."
130+
# Target architectures (if cross-compiling)
131+
"-adarwin_arm64=vendor/dkml-compiler/src/standard-compiler-env-to-ocaml-configure-env.sh" { os = "macos" }
132+
# For any non cross-compiling platforms we save time and space by
133+
# only building the runtime.
134+
"-r" { os = "win32" | (os = "linux" & (arch = "x86_32" | arch = "x86_64")) }
135+
]
136+
137+
# [1] Run r-c-ocaml-2-build_host-noargs.sh
138+
[
139+
"sh" "-eufc"
140+
"cd '%{_:share}%/staging-files' && echo 1 - host && share/dkml/repro/100co/vendor/dkml-compiler/src/r-c-ocaml-2-build_host-noargs.sh"
141+
]
142+
143+
# [1] Run r-c-ocaml-3-build_cross-noargs.sh if cross-compiling,
144+
# which will place its output into staging-files/<cross-abi>
145+
# (confer: "-g" "%{_:share}%/staging-files")
146+
[
147+
"sh" "-eufc"
148+
"cd '%{_:share}%/staging-files' && echo 1 - cross && share/dkml/repro/100co/vendor/dkml-compiler/src/r-c-ocaml-3-build_cross-noargs.sh"
149+
] { os = "macos" }
150+
151+
# --------------
152+
# Second pass
153+
# For platforms that can do multiple _host_ ABIs _without_ cross-compiling.
154+
# * MSVC can trivially do 32-bit and 64-bit without cross-compiling.
155+
# * Most often Linux can as well as long as `gcc -m32` is configured.
156+
# However for ease of use in GitHub Actions we expect Linux 32-bit and
157+
# Linux 64-bit to be done with different Opam switches.
158+
# --------------
159+
160+
# [2] Run r-c-ocaml-1-setup.sh
161+
[
162+
"env" "TOPDIR=dkmldir/vendor/drc/all/emptytop"
163+
"DKML_REPRODUCIBLE_SYSTEM_BREWFILE=%{_:build}%/Brewfile"
164+
"dkmldir/vendor/dkml-compiler/src/r-c-ocaml-1-setup.sh"
165+
"-d" "dkmldir"
166+
"-f" "src/ocaml-2"
167+
"-r" # Build runtime only
168+
"-k" "vendor/dkml-compiler/src/standard-compiler-env-to-ocaml-configure-env.sh"
169+
"-v" "dl/ocaml"
170+
# Host-compile into staging-files/<host-abi>
171+
"-t" "%{_:share}%/staging-files"
172+
"-pwindows_x86" { os = "win32" }
173+
# ABIs
174+
"-ewindows_x86" { os = "win32" }
175+
] { !(os = "macos") & !(os = "linux") }
176+
177+
# [2] Run r-c-ocaml-2-build_host-noargs.sh
178+
[
179+
"sh" "-eufc"
180+
"cd '%{_:share}%/staging-files' && echo 2 - host && share/dkml/repro/100co/vendor/dkml-compiler/src/r-c-ocaml-2-build_host-noargs.sh"
181+
] { !(os = "macos") & !(os = "linux") }
182+
183+
# --------------
184+
# Clean build files
185+
# --------------
186+
187+
[ "rm" "-rf" "%{_:share}%/staging-files/share" ]
188+
[ "rm" "-rf" "%{_:share}%/staging-files/src" ]
189+
]
190+
dev-repo: "git+https://github.com/diskuv/dkml-component-ocamlcompiler.git"
191+
extra-source "dl/ocaml.tar.gz" {
192+
src: "https://github.com/ocaml/ocaml/archive/4.12.1.tar.gz"
193+
checksum: "sha256=f5a48a90557cb47ace7b1590fcab1362a1af38629a218350f69c225c57e96a41"
194+
}
195+
extra-source "dl/flexdll.tar.gz" {
196+
src: "https://github.com/alainfrisch/flexdll/archive/0.39.tar.gz"
197+
checksum: "sha256=51a6ef2e67ff475c33a76b3dc86401a0f286c9a3339ee8145053ea02d2fb5974"
198+
}
199+
extra-source "dl/homebrew-bundle.tar.gz" {
200+
src: "https://github.com/Homebrew/homebrew-bundle/archive/4756e4c4cf95485c5ea4da27375946c1dac2c71d.tar.gz"
201+
checksum: [
202+
"sha256=10c024ca7871cea36b4c27b2601971d3fa6cba6f37855613baf0026d0f555e76"
203+
]
204+
}
205+
extra-source "dl/dkml-compiler.tar.gz" {
206+
src: "https://github.com/diskuv/dkml-compiler/archive/refs/tags/4.12.1-v1.0.0.tar.gz"
207+
checksum: [
208+
"sha256=8beda92f97cde6d4a55a836ca6dc9f860bb5f1a6b765b80be4594943288571cf"
209+
]
210+
}
211+
extra-source "dl/dkml-runtime-common.tar.gz" {
212+
# This violates the v1.0.0 versioning, but this future patch is needed to allow the 'bundle'
213+
# brew tap to be used on macOS in the Opam sandbox.
214+
src: "https://github.com/diskuv/dkml-runtime-common/archive/refs/tags/v1.0.1-prerel0b.tar.gz"
215+
checksum: [
216+
"sha256=563b89382f07a4ce56917a8eb7034c5fa6993572f087ad909e58229e78748056"
217+
]
218+
}
219+
extra-source "dl/dkml-runtime-distribution.tar.gz" {
220+
src: "https://github.com/diskuv/dkml-runtime-distribution/archive/refs/tags/v1.0.0.tar.gz"
221+
checksum: [
222+
"sha256=bface5c975172f3d07636e5207806e8c0e43928ada1643ee3a2d4044c6fe6beb"
223+
]
224+
}
225+
url {
226+
src:
227+
"https://github.com/diskuv/dkml-component-ocamlrun/archive/4.12.1-v1.0.0.tar.gz"
228+
checksum: [
229+
"md5=9621ea195048f2ae0a01940e4f628d17"
230+
"sha512=5c872c48456cf4699f1c57304f97a35512bf5fa0d079a5d8315dbeea6253ee65b4f4ae012475f584815245a9e5e195140fd225d6189fd03253ab52cc8f9b3ec8"
231+
]
232+
}

0 commit comments

Comments
 (0)