Skip to content
Open
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
37 changes: 35 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,28 @@ jobs:
uses: ocaml/setup-ocaml@v3
with:
ocaml-compiler: ${{ matrix.ocaml-version }}
opam-disable-sandboxing: ${{ runner.os == 'macOS' && 'true' || 'false' }}
windows-environment: ${{ matrix.os.windows_environment == '' && 'cygwin' || matrix.os.windows_environment }}
opam-repositories: |
default: git+https://github.com/ocaml/opam-repository.git
archive: git+https://github.com/ocaml/opam-repository-archive.git

- name: Build with make
run: |
opam exec -- ${{ runner.os == 'Windows' && 'sh ' || '' }}./configure
opam exec -- ${{ runner.os == 'Windows' && 'sh ' || '' }}./configure -sitelib .
echo ------------
grep "[\\\\/]" Makefile.config
echo ------------
opam exec -- make all opt

- name: Build and install with opam
run: opam pin add ocamlfind .
id: opam
env:
SOURCE_DATE_EPOCH: 0
OCAMLPARAM: ${{ runner.os == 'macOS' && '|_|cclib=-Wl,-S' || '' }}
run: |
opam pin add ocamlfind .
sh -c 'echo "relocatable=$(test -n "$(opam list --installed --short compiler-cloning.enabled)" && echo "true" || echo "false")" >> "$GITHUB_OUTPUT"'

- name: Test the ocamlfind binary
env:
Expand All @@ -67,3 +74,29 @@ jobs:

- name: Test the toplevel plugin
run: opam exec -- ocaml .github/workflows/toplist.ml

- name: Create second switch (relocatable)
if: steps.opam.outputs.relocatable == 'true'
shell: bash
env:
SOURCE_DATE_EPOCH: 0
OCAMLPARAM: ${{ runner.os == 'macOS' && '|_|cclib=-Wl,-S' || '' }}
run: |
opam switch create second --no-switch $(opam list --color=never --columns=package --short --installed ocaml | tr -d '\r')
opam pin add --switch=second ocamlfind .

- name: Check ocamlfind is relocatable
if: steps.opam.outputs.relocatable == 'true'
shell: bash
run: |
first="$(opam var bin | tr -d '\r')/ocamlfind${{ runner.os == 'Windows' && '.exe' || '' }}"
second="$(opam var --switch=second bin | tr -d '\r')/ocamlfind${{ runner.os == 'Windows' && '.exe' || '' }}"
Comment on lines +91 to +93

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
run: |
first="$(opam var bin | tr -d '\r')/ocamlfind${{ runner.os == 'Windows' && '.exe' || '' }}"
second="$(opam var --switch=second bin | tr -d '\r')/ocamlfind${{ runner.os == 'Windows' && '.exe' || '' }}"
env:
EXE: ${{ runner.os == 'Windows' && '.exe' || '' }}
run: |
first="$(opam var bin | tr -d '\r')/ocamlfind$EXE"
second="$(opam var --switch=second bin | tr -d '\r')/ocamlfind$EXE"

maybe, if only to shorten lines?

sha1sum "$first" "$second"
if ! cmp -s "$first" "$second"; then
if command -v xxd > /dev/null; then
diff <(xxd "$first") <(xxd "$second") || true
else
diff <(od -A x -t x1 -v "$first") <(od -A x -t x1 -v "$second") || true
fi
exit 1
fi
20 changes: 19 additions & 1 deletion .github/workflows/toplist.ml
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
#use "topfind";;
#list;;
#require "unix";;
#require "findlib";;
let realpath = Filename.concat (Sys.getcwd()) "src/findlib/realpath.ml" in
Topdirs.dir_use Format.err_formatter realpath;;
let () =
let ld_conf = Findlib.ocaml_ldconf () in
let print_line = Printf.printf " %s\n" in
let print_line {Findlib.raw = raw; Findlib.eff = eff} =
let real = realpath eff in
let real =
if real = eff then
""
else
"\n -> " ^ real
in
let eff =
if raw ^ real = eff then
""
else
"\n -> " ^ eff
in
Printf.printf " %s%s%s\n" raw eff real
in
Printf.printf "Reading %s\n" ld_conf;
List.iter print_line (Findlib.read_ldconf ld_conf);;
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ findlib.conf
ocargs.log
src/findlib/depend
src/findlib/findlib_config.ml
src/findlib/findlib_config_?.mlp
src/findlib/fl_meta.ml
src/findlib/ocaml_args.ml
src/findlib/ocamlfind
src/findlib/ocamlfind_opt
src/findlib/realpath.ml
src/findlib/topfind
src/findlib/topfind.ml
src/findlib/topfind.compat.in
src/findlib/topfind_??.p
tools/extract_args/extract_args
tools/extract_args/extract_args.ml
16 changes: 16 additions & 0 deletions GNUmakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
include Makefile.config

ifeq "$(IS_RELOCATABLE)" "1"
HASH := \#
SRCDIR_ENCODED = $(subst =,%+,$(subst :,%.,$(subst %,%$(HASH),$(SRCDIR_ABS))))
SRCDIR_ABS_REAL := $(shell realpath $(SRCDIR_ABS) 2>/dev/null)
SRCDIR_REAL_ENCODED = \
$(subst =,%+,$(subst :,%.,$(subst %,%$(HASH),$(SRCDIR_ABS_REAL))))
BUILD_PATH_PREFIX_MAP ?=
export BUILD_PATH_PREFIX_MAP := \
$(BUILD_PATH_PREFIX_MAP)$\
:.=$(SRCDIR_ENCODED)$\
$(if $(SRCDIR_REAL_ENCODED),:.=$(SRCDIR_REAL_ENCODED))
endif

include Makefile
22 changes: 20 additions & 2 deletions Makefile.config.pattern
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
# Note that there are other files containing parts of the
# configuration, especially the site-lib/*/META files.
#
#----------------------------------------------------------------------
# Where is findlib being compiled:
#----------------------------------------------------------------------
SRCDIR_ABS=/home/user/ocamlfind

#----------------------------------------------------------------------
# Where the OCAML core is installed:
#----------------------------------------------------------------------
Expand All @@ -21,7 +26,13 @@ OCAML_THREADS=vm
# Where the site-lib directory will be
#----------------------------------------------------------------------
OCAML_SITELIB=/usr/local/lib/ocaml/site-lib
OCAML_SITELIB_NATIVE=$(OCAML_SITELIB)

#----------------------------------------------------------------------
# For Relocatable Findlib, the path of site-lib relative to the OCaml
# Standard Library directory. For normal Findlib, equal to

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
# Standard Library directory. For normal Findlib, equal to
# Standard Library directory. For non-relocatable Findlib, equal to

I’d like to see the relocatable version be the new normal one.

# $(OCAML_SITELIB)
#----------------------------------------------------------------------
OCAML_SITELIB_FROM_STDLIB=$(OCAML_SITELIB)

#----------------------------------------------------------------------
# Where binaries and manual pages will be installed
Expand All @@ -32,8 +43,9 @@ OCAMLFIND_MAN=/usr/local/man
#----------------------------------------------------------------------
# The absolute location of the configuration file
#----------------------------------------------------------------------
OCAMLFIND_CONF=/usr/local/etc/ocamlfind.conf
OCAMLFIND_CONF=/usr/local/etc/$(OCAMLFIND_CONF_NAME)
OCAMLFIND_CONF_NATIVE=$(OCAMLFIND_CONF)
OCAMLFIND_CONF_NAME=ocamlfind.conf

#----------------------------------------------------------------------
# Autolinking is usually on
Expand Down Expand Up @@ -67,6 +79,12 @@ INSTALL_TOPFIND=1
#----------------------------------------------------------------------
RELATIVE_PATHS=0

#----------------------------------------------------------------------
# Whether Relocatable Findlib is being built
#----------------------------------------------------------------------
IS_RELOCATABLE=0
RELOCATABLE=

#----------------------------------------------------------------------
# Whether make install should update Makefile.packages just before
# running
Expand Down
Loading
Loading