Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ocaml #248

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

Ocaml #248

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions classes/ocaml.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
buildTools: [ocaml, ocamlfind]
buildSetup: |
export OCAMLLIB=${BOB_TOOL_PATHS['ocaml']}/../lib
export OCAMLFIND_CONF=${BOB_TOOL_PATHS['ocamlfind']}/../local/etc/findlib.conf

OCAMLPATH=${OCAMLPATH:-""}
for i in "${@:2}" ; do
for j in $i/usr/lib/* ; do
if [[ -d "$j" ]] ; then
if [ -e "$j/META" ] ; then
OCAMLPATH+=""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why add an empty string?

OCAMLPATH+="${OCAMLPATH:+:}$i/usr/lib"
fi
fi
done
done

[ -z "${OCAMLPATH:+true}" ] || export OCAMLPATH

packageSetup: |
ocamlFixupInstall() {
find . -type f -exec \
sed -i "s@#!${BOB_TOOL_PATHS[ocaml]}/ocamlrun@#!/usr/bin/env ocamlrun@g" \
{} \;
}
78 changes: 78 additions & 0 deletions recipes/devel/dune.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
inherit: [cpackage, make]

metaEnvironment:
PKG_VERSION: "3.17.2"

depends:
- libs::zstd-dev
- use: []
depends:
- libs::zstd-tgt

checkoutSCM:
scm: url
url: https://github.com/ocaml/dune/archive/refs/tags/${PKG_VERSION}.tar.gz
digestSHA256: 1b45e34d1eacf40be569e4d7ad055508a3242637b098327c91f7ce67772a1889
stripComponents: 1

multiPackage:
configurator:
depends:
- libs::csexp-dev

buildTools: [ocaml, dune, ocamlfind]
buildSetup: |
export OCAMLLIB=${BOB_TOOL_PATHS['ocaml']}/../lib
buildScript: |
rsync -a --delete $1/ .
dune build dune-configurator.install
dune install dune-configurator \
--prefix "/usr" \
--dest $(pwd)/install
multiPackage:
dev:
provideDeps: ['*-dev']
packageScript: |
rsync -a --delete $1/install/ .
tgt:
provideDeps: ['*-tgt']
packageScript:
installPackageTgt $1/install
stdune:
buildTools: [ocaml, dune, ocamlfind]
buildSetup: |
export OCAMLLIB=${BOB_TOOL_PATHS['ocaml']}/../lib
buildScript: |
rsync -a --delete $1/ .
dune build stdune.install
dune install stdune \
--prefix "/usr" \
--dest $(pwd)/install
multiPackage:
dev:
provideDeps: ['*-dev']
packageScript: |
rsync -a --delete $1/install/ .
tgt:
provideDeps: ['*-tgt']
packageScript:
installPackageTgt $1/install

"":
inherit: [strip]
buildTools: [ocaml]
buildSetup: |
export OCAMLLIB=${BOB_TOOL_PATHS['ocaml']}/../lib
buildScript: |
rsync -a --delete $1/ .

./configure \
--toolchains enable
makeParallel release V=1
make install DESTDIR=$(pwd)/install PREFIX="/usr"

packageScript: |
rsync -a --delete $1/install/ .
stripAll .
provideTools:
dune: "usr/bin"
44 changes: 44 additions & 0 deletions recipes/devel/ocaml.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
inherit: [autotools, autoconf]

metaEnvironment:
PKG_VERSION: "5.3.0"

checkoutSCM:
scm: url
url: https://github.com/ocaml/ocaml/archive/refs/tags/${PKG_VERSION}.tar.gz
digestSHA256: eb9eab2f21758d3cfb1e78c7f83f0b4dd6302824316aba4abee047a5a4f85029
stripComponents: 1

buildTools: [m4, autotools]
buildVars: [STRIP]
buildScript: |
rsync -a --delete $1/ .
mkdir -p .bob
pushd .bob
ln -s $(which ${STRIP}) strip
popd
export PATH=${PATH}:$(pwd)/.bob

./configure \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a particular reason why you do not use autotoolsBuild? This applies to basically all packages.

Copy link
Contributor Author

@rhubert rhubert Feb 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes - because autotoolsBuild is not working. Using autotoolsBuild it fails with:

make: *** No targets specified and no makefile found. Stop.

The reason is, that configure did not produce the makefiles in the current working directory, it's always in the folder of the configure script. - but autotoolsBuild uses a build-folder where it runs configure and assumes the makefiles to be generated.

To use the code from the autotools-class I think we can either

  • move the configure part of the autotools - class into a separate class and reuse it from there
  • add a argument to autotoolsBuild skipping the pushd build

Do you see another option? Which one do you prefer?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh my gosh! It's really that borken. 🤦 In this case I would rather not touch the autotools class. But a small comment with exactly this explanation would be appreciated. Otherwise we'll start wondering again a couple of years down the road why the autotools class isn't use...

${AUTOCONF_BUILD:+--build=${AUTOCONF_BUILD}} \
${AUTOCONF_HOST:+--host=${AUTOCONF_HOST}} \
${AUTOCONF_TARGET:+--target=${AUTOCONF_TARGET}} \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AUTOCONF_TARGET is not part of buildVars. I guess you have never built a cross-compiler?

--prefix="/usr" \
--sysconfdir="/etc" \
--localstatedir="/var" \
--libdir=/usr/lib \
--enable-shared --enable-static \
--enable-unix-lib \
--without-zstd

makeParallel V=1
make install DESTDIR=$(pwd)/install

packageScript: |
rsync -a --delete $1/install/ .
pushd usr/bin
find . -type f -exec sed -i 's@#!/usr/bin/ocamlrun@#!/usr/bin/env ocamlrun@g' {} \;
popd

provideTools:
ocaml: "usr/bin"
52 changes: 52 additions & 0 deletions recipes/devel/ocamlfind.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
inherit: [autotools]

metaEnvironment:
PKG_VERSION: "1.9.8"

depends:
- libs::zstd-dev
- use: []
depends:
- libs::zstd-tgt

checkoutSCM:
scm: url
url: https://github.com/ocaml/ocamlfind/archive/refs/tags/findlib-${PKG_VERSION}.tar.gz
digestSHA256: d6899935ccabf67f067a9af3f3f88d94e310075d13c648fa03ff498769ce039d
stripComponents: 1

buildTools: [ocaml]
buildScript: |
export OCAMLLIB=${BOB_TOOL_PATHS['ocaml']}/../lib
export CAML_LD_LIBRARY_PATH=${BOB_TOOL_PATHS['ocaml']}/../lib
rsync -a --delete $1/ __src__

mkdir -p .bob/ocaml_wrappers
cat > .bob/ocaml_wrappers/ocamlc << EOF
#!/bin/bash
if [[ "\$@" =~ '-custom' ]]; then
exec ${BOB_TOOL_PATHS[ocaml]}/ocamlc \$@
else
exec ${BOB_TOOL_PATHS[ocaml]}/ocamlc -use-runtime $(which ocamlrun) \$@
fi
EOF
chmod +x .bob/ocaml_wrappers/*

export PATH=$(pwd)/.bob/ocaml_wrappers:${PATH}

pushd __src__
./configure \
-bindir "/usr/bin/" \
-sitelib "/usr/lib/" \
-mandir "/usr/man/" \
-with-relative-paths-at "/" \
-no-topfind
makeParallel
make install DESTDIR=$(pwd)/../install
popd

packageScript: |
rsync -a --delete $1/install/ .

provideTools:
ocamlfind: "usr/bin"
33 changes: 33 additions & 0 deletions recipes/devel/opam.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
inherit: [autotools]

metaEnvironment:
PKG_VERSION: "2.3.0"

checkoutSCM:
scm: git
url: [email protected]:hubert/opam.git
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NXDOMAIN 😉

tag: ${PKG_VERSION}
commit: e13109411952d4f723a165c2a24b8c03c4945041

buildTools: [ocaml]
buildScript: |
rsync -a --delete $1/ .
./configure \
${AUTOCONF_BUILD:+--build=${AUTOCONF_BUILD}} \
${AUTOCONF_HOST:+--host=${AUTOCONF_HOST}} \
${AUTOCONF_TARGET:+--target=${AUTOCONF_TARGET}} \
--prefix="/usr" \
--sysconfdir="/etc" \
--localstatedir="/var" \
--libdir=/usr/lib \
--without-mccs \
--without-dune \
--disable-checks \
makeParallel
make install DESTDIR=$(pwd)/install

packageScript:
autotoolsPackageBin

provideTools:
opam: "usr/bin"
25 changes: 25 additions & 0 deletions recipes/libs/bigarray-compat.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
inherit: [ocaml, install]

metaEnvironment:
PKG_VERSION: "1.1.0"

checkoutSCM:
scm: url
url: https://github.com/mirage/bigarray-compat/archive/refs/tags/v${PKG_VERSION}.tar.gz
digestSHA256: cf09354986d1ab7d506949f58e73dd72be8aedb241c1593381c18e92a70c0bb1
stripComponents: 1

buildTools: [dune, ocaml, target-toolchain]
buildScript: |
rsync -a --delete $1/ .
dune build
dune install --prefix "/usr" \
--dest $(pwd)/install

multiPackage:
dev:
packageScript: |
rsync -a --delete $1/install/ .
tgt:
packageScript: |
installPackageTgt $1/install
27 changes: 27 additions & 0 deletions recipes/libs/csexp.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
inherit: [install]

metaEnvironment:
PKG_VERSION: "1.5.2"

checkoutSCM:
scm: url
url: https://github.com/ocaml-dune/csexp/archive/refs/tags/${PKG_VERSION}.tar.gz
digestSHA256: de3fda861ec8210a404fcb76afa162b08ed1cd11228645c78b53e1f82b24e236
stripComponents: 1

buildTools: [dune, ocaml, target-toolchain]
buildSetup: |
export OCAMLLIB=${BOB_TOOL_PATHS['ocaml']}/../lib
buildScript: |
mkdir -p build && pushd build
rsync -aH $1/ .
dune build -p csexp
dune install --prefix "/usr" --dest $(pwd)/../install --relocatable

multiPackage:
dev:
packageScript: |
rsync -a --delete $1/install/ .
tgt:
packageScript: |
installPackageTgt
41 changes: 41 additions & 0 deletions recipes/libs/ocaml-ctypes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
inherit: [make, cpackage, ocaml]

metaEnvironment:
PKG_VERSION: "0.23.0"

depends:
- name: devel::dune
tools:
target-toolchain: host-compat-toolchain
use: [tools]
forward: True
- devel::dune-configurator-dev
- devel::dune-stdune-dev
- libs::bigarray-compat-dev
- libs::ocaml-integers-dev

checkoutSCM:
scm: url
url: https://github.com/yallop/ocaml-ctypes/archive/refs/tags/${PKG_VERSION}.tar.gz
digestSHA256: cae47d815b27dd4c824a007f1145856044542fe2588d23a443ef4eefec360bf1
stripComponents: 1

buildTools: [dune, ocaml, target-toolchain]
buildSetup: |
export OCAMLLIB=${BOB_TOOL_PATHS['ocaml']}/../lib
buildScript: |
rsync -a --delete $1/ .
dune build ctypes.install
dune install ctypes \
--prefix "/usr" \
--dest $(pwd)/install

multiPackage:
dev:
provideDeps: ['*-dev']
packageScript: |
rsync -a --delete $1/install/ .
tgt:
provideDeps: ['*-tgt']
packageScript: |
installPackageTgt $1/install
33 changes: 33 additions & 0 deletions recipes/libs/ocaml-integers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
inherit: [ocaml, install]

metaEnvironment:
PKG_VERSION: "0.7.0"

depends:
- libs::stdlib-shims-dev
- use: []
depends:
- libs::stdlib-shims-tgt

checkoutSCM:
scm: url
url: https://github.com/yallop/ocaml-integers/archive/refs/tags/${PKG_VERSION}.tar.gz
digestSHA256: 8bb517fa9a1818246eb8c4ce34ee1489fbebb4b92defa3a25d13cab8d23ec685
stripComponents: 1

buildTools: [dune, ocaml, target-toolchain]
buildScript: |
rsync -a --delete $1/ .
dune build
dune install --prefix "/usr" \
--dest $(pwd)/install

multiPackage:
dev:
provideDeps: ['*-dev']
packageScript: |
rsync -a --delete $1/install/ .
tgt:
provideDeps: ['*-tgt']
packageScript: |
installPackageTgt $1/install
25 changes: 25 additions & 0 deletions recipes/libs/stdlib-shims.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
inherit: [ocaml, install]

metaEnvironment:
PKG_VERSION: "0.3.0"

checkoutSCM:
scm: url
url: https://github.com/ocaml/stdlib-shims/archive/refs/tags/${PKG_VERSION}.tar.gz
digestSHA256: 6d0386313a021146300011549180fcd4e94f7ac3c3bf021ff165f6558608f0c2
stripComponents: 1

buildTools: [dune, ocaml, target-toolchain]
buildScript: |
rsync -a --delete $1/ .
dune build
dune install --prefix "/usr" \
--dest $(pwd)/install

multiPackage:
dev:
packageScript: |
rsync -a --delete $1/install/ .
tgt:
packageScript: |
installPackageTgt $1/install