Skip to content

Commit

Permalink
Remove src/client/no-git-version and use the OPAM_BUILD_NO_GIT_VERSIO…
Browse files Browse the repository at this point in the history
…N environment variable as compile-time instead
  • Loading branch information
kit-ty-kate committed Jul 10, 2024
1 parent a1c9c34 commit fb5ff5b
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 38 deletions.
9 changes: 0 additions & 9 deletions .github/scripts/main/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@ set -xue

. .github/scripts/main/preamble.sh

unset-dev-version () {
# disable git versioning to allow OPAMYES use for upgrade
touch src/client/no-git-version
}

export OCAMLRUNPARAM=b

(set +x ; echo -en "::group::build opam\r") 2>/dev/null
Expand Down Expand Up @@ -37,9 +32,6 @@ if [ "$OPAM_TEST" != "1" ]; then
echo 'DUNE_PROFILE=dev' >> Makefile.config
fi

if [ $OPAM_UPGRADE -eq 1 ]; then
unset-dev-version
fi
# Disable implicit transitive deps
sed -i -e '/(implicit_transitive_deps /s/true/false/' dune-project
make all admin
Expand All @@ -60,7 +52,6 @@ if [ "$OPAM_TEST" = "1" ]; then
if [ $rcode -eq 10 ]; then
echo "Recompiling for an opam root upgrade"
(set +x ; echo -en "::group::rebuild opam\r") 2>/dev/null
unset-dev-version
make all admin
rm -f "$PREFIX/bin/opam"
make install
Expand Down
2 changes: 1 addition & 1 deletion .github/scripts/main/preamble.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ PATH=$OPAM_LOCAL/bin:$OCAML_LOCAL/bin:$PATH; export PATH

OPAM_COLD=${OPAM_COLD:-0}
OPAM_TEST=${OPAM_TEST:-0}
OPAM_UPGRADE=${OPAM_UPGRADE:-0}
OPAM_BUILD_NO_GIT_VERSION=${OPAM_BUILD_NO_GIT_VERSION:-0}

OPAM_REPO_MAIN=https://github.com/ocaml/opam-repository.git

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.ml
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ let upgrade_job ~analyse_job ~build_linux_job ~build_windows_job ~build_macOS_jo
++ cache Opam12Root
++ cache OCaml platform ocamlv host
++ build_cache OCaml platform ocamlv host
++ run "Build" ~env:[("OPAM_UPGRADE", "1")] ["bash -exu .github/scripts/main/main.sh " ^ host]
++ run "Build" ~env:[("OPAM_BUILD_NO_GIT_VERSION", "1")] ["bash -exu .github/scripts/main/main.sh " ^ host]
++ run "Test (upgrade)" ["bash -exu .github/scripts/main/upgrade.sh"]
++ end_job f

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ jobs:
run: bash -exu .github/scripts/main/ocaml-cache.sh ${{ runner.os }} ${{ matrix.ocamlv }}
- name: Build
env:
OPAM_UPGRADE: 1
OPAM_BUILD_NO_GIT_VERSION: 1
run: bash -exu .github/scripts/main/main.sh x86_64-pc-linux-gnu
- name: Test (upgrade)
run: bash -exu .github/scripts/main/upgrade.sh
Expand Down Expand Up @@ -553,7 +553,7 @@ jobs:
run: bash -exu .github/scripts/main/ocaml-cache.sh ${{ runner.os }} ${{ matrix.ocamlv }}
- name: Build
env:
OPAM_UPGRADE: 1
OPAM_BUILD_NO_GIT_VERSION: 1
run: bash -exu .github/scripts/main/main.sh x86_64-apple-darwin
- name: Test (upgrade)
run: bash -exu .github/scripts/main/upgrade.sh
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ autom4te.cache
src/ocaml-flags-configure.sexp
src/**/.merlin
src/client/linking.sexp
src/client/no-git-version
src/core/developer
src/manifest/dune
src/manifest/install.inc
Expand Down
17 changes: 6 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ clean-ext:
clean:
$(MAKE) -C doc $@
rm -f *.install *.env *.err *.info *.out opam$(EXE) opam-admin.top$(EXE) opam-installer$(EXE)
rm -f src/client/no-git-version
rm -rf _build Opam.Runtime.*

distclean: clean clean-ext
Expand Down Expand Up @@ -189,7 +188,7 @@ bench:
@$(DUNE) exec --display=quiet $(DUNE_PROFILE_ARG) --root . $(DUNE_ARGS) -- ./tests/bench/bench.exe

.PHONY: tests
tests: $(DUNE_DEP) src/client/no-git-version
tests: $(DUNE_DEP)
@$(DUNE) runtest $(DUNE_PROFILE_ARG) --root . $(DUNE_ARGS) src/ tests/ --no-buffer; \
ret=$$?; \
echo "### TESTS RESULT SUMMARY ###"; \
Expand Down Expand Up @@ -217,25 +216,21 @@ crowbar-afl: $(DUNE_DEP)
echo foo > /tmp/opam-crowbar-input/foo
afl-fuzz -i /tmp/opam-crowbar-input -o /tmp/opam-crowbar-output dune exec src/crowbar/test.exe @@

INTERMEDIATE: src/client/no-git-version
src/client/no-git-version:
touch src/client/no-git-version

# tests-local, tests-git
tests-%: $(DUNE_DEP) src/client/no-git-version
tests-%: $(DUNE_DEP)
$(DUNE) build $(DUNE_ARGS) $(DUNE_PROFILE_ARG) --root . @reftest-legacy-$* --force

reftest-gen: src/client/no-git-version
reftest-gen:
echo >tests/reftests/dune.inc
$(DUNE) build $(DUNE_ARGS) $(DUNE_PROFILE_ARG) --root . @reftest-gen --auto-promote --force

reftest-runner: $(DUNE_DEP) src/client/no-git-version
reftest-runner: $(DUNE_DEP)
$(DUNE) build $(DUNE_ARGS) $(DUNE_PROFILE_ARG) --root . tests/reftests/run.exe

reftests: $(DUNE_DEP) src/client/no-git-version
reftests: $(DUNE_DEP)
$(DUNE) build $(DUNE_ARGS) $(DUNE_PROFILE_ARG) --root . @reftest

reftest-%: $(DUNE_DEP) src/client/no-git-version
reftest-%: $(DUNE_DEP)
$(DUNE) build $(DUNE_ARGS) $(DUNE_PROFILE_ARG) --root . @reftest-$* --force

reftests-meld:
Expand Down
33 changes: 33 additions & 0 deletions master_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,39 @@ users)

## Build
* Synchronise opam-core.opam with opam-repository changes [#6043 @dra27]
* Bump src_exts and fix build compat with Dune 2.9.0 [#4752 @dra27]
* Upgrade to dose3 >= 6.1 and vendor dose3 7.0.0 [#4760 @kit-ty-kate]
* Change minimum required OCaml to 4.03.0 [#4770 @dra27]
* Change minimum required Dune to 2.0 [#4770 @dra27]
* Change minimum required OCaml to 4.08.0 for everything except opam-core, opam-format and opam-installer [#4775 @dra27]
* Fix the cold target in presence of an older OCaml compiler version on macOS [#4802 @kit-ty-kate - fix #4801]
* Harden the check for a C++ compiler [#4776 @dra27 - fix #3843]
* Add `--without-dune` to configure to force compiling vendored Dune [#4776 @dra27]
* Use `--without-dune` in `make cold` to avoid picking up external Dune [#4776 @dra27 - fix #3987]
* Add `--with-vendored-deps` to replace `make lib-ext` instruction [#4776 @dra27 - fix #4772]
* Fix vendored build on mingw-w64 with g++ 11.2 [#4835 @dra27]
* Switch to vendored build if spdx_licenses is missing [#4842 @dra27]
* Check versions of findlib packages in configure [#4842 @dra27]
* Fix dose3 download url since gforge is gone [#4870 @avsm]
* Update bootstrap ocaml to 4.12.1 to integrate mingw fix [#4927 @rjbou]
* Update bootstrap to use `-j` for Unix (Windows already does) [#4988 @dra27]
* Update cold compiler to 4.13 [#5017 @dra27]
* Bring the autogen script from ocaml/ocaml to be compatible with non-ubuntu-patched autoconf [#5090 @kit-ty-kate #5093 @dra27]
* configure: Use gmake instead of make on Unix systems (fixes BSDs) [#5090 @kit-ty-kate]
* Patch AltGr/ocaml-mccs#36 in the src_ext build to fix Cygwin32 [#5094 @dra27]
* Silence warning 70 [#5104 @dra27]
* Add `jsonm` (and `uutf`) dependency [#5098 @rjbou - fix #5085]
* Bump opam-file-format to 2.1.4 [#5117 @kit-ty-kate - fix #5116]
* Add `sha` dependency [#5042 @kit-ty-kate]
* Add a 'test' target [#5129 @kit-ty-kate @mehdid - partially fixes #5058]
* Add `with-tools` handling in selection process [#5016 @rjbou]
* Bump cudf to 0.10 [#5195 @kit-ty-kate]
* shell/bootstrap-ocaml.sh: do not fail if curl/wget is missing [#5223 #5233 @kit-ty-kate]
* Upgrade to cmdliner >= 1.1 [#5269 @kit-ty-kate]
* Cleared explanation of dependency vendoring in configure [#5277 @dra27 - fix #5271]
* Switch autoconf required version to 2.71 [#5161 @dra27]
* Remove src/client/no-git-version when calling make clean [#5290 @kit-ty-kate]
* Remove src/client/no-git-version and use the OPAM_BUILD_NO_GIT_VERSION environment variable as compile-time instead [#5291 @kit-ty-kate]

## Infrastructure

Expand Down
23 changes: 10 additions & 13 deletions src/client/dune
Original file line number Diff line number Diff line change
Expand Up @@ -53,23 +53,20 @@
(deps (universe))
(action (ignore-stderr (with-stdout-to %{targets} (system "git describe --exact HEAD || echo [dev]")))))

(rule
(targets no-git-version)
(mode fallback)
(action (copy git-sha %{targets})))

(rule
(with-stdout-to get_git_version.ml
(echo "print_string @@ \
let v = \"%{read-lines:no-git-version}\" in \
let w = \"%{read-lines:git-describe}\" in \
if v = \"\" || v = \".\" || w <> \"[dev]\" then \
\"let version = None\" \
else \
\"let version = Some \\\"\" ^ v ^ \"\\\"\"")))
(progn
(echo "print_endline @@\n")
(echo " let force_no_git_version = int_of_string Sys.argv.(1) in\n")
(echo " let v = \"%{read-lines:git-sha}\" in\n")
(echo " let w = \"%{read-lines:git-describe}\" in\n")
(echo " if force_no_git_version = 1 || v = \".\" || w <> \"[dev]\" then\n")
(echo " \"let version = None\"\n")
(echo " else\n")
(echo " \"let version = Some \\\"\" ^ v ^ \"\\\"\"\n"))))

(rule
(with-stdout-to opamGitVersion.ml (run ocaml %{dep:get_git_version.ml})))
(with-stdout-to opamGitVersion.ml (run ocaml %{dep:get_git_version.ml} %{env:OPAM_BUILD_NO_GIT_VERSION=0})))

(rule
(targets linking.sexp)
Expand Down

0 comments on commit fb5ff5b

Please sign in to comment.