Allow by-host worktree-sharable configure caches
The Git configuration value ocaml.configure-cache can be used to specify a directory to keep autoconf cache files in, relative to the worktree root (so `git config ocaml.configure-cache .` enables the feature, and `git config --global ocaml.configure-cache ..` enables it for all worktrees, assuming they're at the same level). autoconf's --cache-file option speeds up future runs of configure by caching the results of previous tests. The cache is invalidated if any environment variables differ (e.g. LDFLAGS) or if the build-host-target triplet differs. This is a nuisance on Windows, where configure is both very slow and it's also common to build with multiple different --host values. This PR allows a tree to be quickly reconfigured from one Windows port to another.master
parent
345fd4c3f9
commit
4f09104d88
|
@ -45,6 +45,7 @@ _build
|
||||||
/autom4te.cache
|
/autom4te.cache
|
||||||
/ocamlc
|
/ocamlc
|
||||||
/config.cache
|
/config.cache
|
||||||
|
/ocaml-*.cache
|
||||||
/config.log
|
/config.log
|
||||||
/config.status
|
/config.status
|
||||||
/libtool
|
/libtool
|
||||||
|
|
4
Changes
4
Changes
|
@ -266,7 +266,9 @@ Working version
|
||||||
(David Allsopp, review by Nicolás Ojeda Bär, report by Sebastian Rasmussen)
|
(David Allsopp, review by Nicolás Ojeda Bär, report by Sebastian Rasmussen)
|
||||||
|
|
||||||
- #8995: allow developers to specify frequently-used configure options in
|
- #8995: allow developers to specify frequently-used configure options in
|
||||||
Git (ocaml.configure option) See HACKING.adoc for further details.
|
Git (ocaml.configure option) and a directory for host-specific, shareable
|
||||||
|
config.cache files (ocaml.configure-cache option). See HACKING.adoc for
|
||||||
|
further details.
|
||||||
(David Allsopp, review by Gabriel Scherer)
|
(David Allsopp, review by Gabriel Scherer)
|
||||||
|
|
||||||
### Compiler user-interface and warnings:
|
### Compiler user-interface and warnings:
|
||||||
|
|
17
HACKING.adoc
17
HACKING.adoc
|
@ -249,6 +249,23 @@ debug runtime, since the enable flag appears after the disable flag. You can
|
||||||
also use the full power of Git's `config` command and have options specific to
|
also use the full power of Git's `config` command and have options specific to
|
||||||
particular clone or worktree.
|
particular clone or worktree.
|
||||||
|
|
||||||
|
=== Speeding up configure
|
||||||
|
|
||||||
|
`configure` includes the standard `-C` option which caches various test results
|
||||||
|
in the file `config.cache` and can use those results to avoid running tests in
|
||||||
|
subsequent invocations. This mechanism works fine, except that it is easy to
|
||||||
|
clean the cache by mistake (e.g. with `git clean -dfX`). The cache is also
|
||||||
|
host-specific which means the file has to be deleted if you run `configure` with
|
||||||
|
a new `--host` value (this is quite common on Windows, where `configure` is
|
||||||
|
also quite slow to run).
|
||||||
|
|
||||||
|
You can elect to have host-specific cache files by issuing
|
||||||
|
`git config --global ocaml.configure-cache .`. The `configure` script will now
|
||||||
|
automatically create `ocaml-host.cache` (e.g. `ocaml-x86_64-pc-windows.cache`,
|
||||||
|
or `ocaml-default.cache`). If you work with multiple worktrees, you can share
|
||||||
|
these cache files by issuing `git config --global ocaml.configure-cache ..`. The
|
||||||
|
directory is interpreted _relative_ to the `configure` script.
|
||||||
|
|
||||||
=== Bootstrapping
|
=== Bootstrapping
|
||||||
|
|
||||||
The OCaml compiler is bootstrapped. This means that
|
The OCaml compiler is bootstrapped. This means that
|
||||||
|
|
|
@ -1,16 +1,57 @@
|
||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
|
|
||||||
if test -e '.git' ; then :
|
if test -e '.git' ; then :
|
||||||
extra_args=$(git config ocaml.configure 2>/dev/null)
|
if test -z "$ac_read_git_config" ; then :
|
||||||
if test -n "$extra_args" ; then :
|
extra_args=$(git config ocaml.configure 2>/dev/null)
|
||||||
if test -z "$ac_read_git_config" ; then :
|
extended_cache=$(git config ocaml.configure-cache 2>/dev/null)
|
||||||
|
cache_file=
|
||||||
|
|
||||||
|
# If ocaml.configure-cache is set, parse the command-line for the --host
|
||||||
|
# option, in order to determine the name of the cache file.
|
||||||
|
if test -n "$extended_cache" ; then :
|
||||||
|
echo "Detected Git configuration option ocaml.configure-cache set to \
|
||||||
|
\"$extended_cache\""
|
||||||
|
dashdash=
|
||||||
|
prev=
|
||||||
|
host=default
|
||||||
|
# The logic here is pretty borrowed from autoconf's
|
||||||
|
for option in $extra_args "$@"
|
||||||
|
do
|
||||||
|
if test -n "$prev" ; then :
|
||||||
|
host=$option
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
case $dashdash$option in
|
||||||
|
--)
|
||||||
|
dashdash=yes ;;
|
||||||
|
-host | --host | --hos | --ho)
|
||||||
|
prev=host ;;
|
||||||
|
-host=* | --host=* | --hos=* | --ho=*)
|
||||||
|
case $option in
|
||||||
|
*=?*) host=$(expr "X$option" : '[^=]*=\(.*\)') ;;
|
||||||
|
*=) host= ;;
|
||||||
|
esac ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
cache_file="`dirname "$0"`/$extended_cache/ocaml-$host.cache"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If either option has a value, re-invoke configure
|
||||||
|
if test -n "$extra_args$cache_file" ; then :
|
||||||
echo "Detected Git configuration option ocaml.configure set to \
|
echo "Detected Git configuration option ocaml.configure set to \
|
||||||
\"$extra_args\""
|
\"$extra_args\""
|
||||||
# Too much effort to get the echo to show appropriate quoting - the
|
# Too much effort to get the echo to show appropriate quoting - the
|
||||||
# invocation itself intentionally quotes $0 and passes $@ exactly as given
|
# invocation itself intentionally quotes $0 and passes $@ exactly as given
|
||||||
# but allows a single expansion of ocaml.configure
|
# but allows a single expansion of ocaml.configure
|
||||||
echo "Re-running $0 $extra_args $@"
|
if test -n "$cache_file" ; then :
|
||||||
ac_read_git_config=true exec "$0" $extra_args "$@"
|
echo "Re-running $0 $extra_args --cache-file \"$cache_file\" $@"
|
||||||
|
ac_read_git_config=true exec "$0" $extra_args \
|
||||||
|
--cache-file "$cache_file" "$@"
|
||||||
|
else
|
||||||
|
echo "Re-running $0 $extra_args $@"
|
||||||
|
ac_read_git_config=true exec "$0" $extra_args "$@"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -15,16 +15,57 @@
|
||||||
|
|
||||||
# This script should have the same shebang as configure
|
# This script should have the same shebang as configure
|
||||||
if test -e '.git' ; then :
|
if test -e '.git' ; then :
|
||||||
extra_args=$(git config ocaml.configure 2>/dev/null)
|
if test -z "$ac_read_git_config" ; then :
|
||||||
if test -n "$extra_args" ; then :
|
extra_args=$(git config ocaml.configure 2>/dev/null)
|
||||||
if test -z "$ac_read_git_config" ; then :
|
extended_cache=$(git config ocaml.configure-cache 2>/dev/null)
|
||||||
|
cache_file=
|
||||||
|
|
||||||
|
# If ocaml.configure-cache is set, parse the command-line for the --host
|
||||||
|
# option, in order to determine the name of the cache file.
|
||||||
|
if test -n "$extended_cache" ; then :
|
||||||
|
echo "Detected Git configuration option ocaml.configure-cache set to \
|
||||||
|
\"$extended_cache\""
|
||||||
|
dashdash=
|
||||||
|
prev=
|
||||||
|
host=default
|
||||||
|
# The logic here is pretty borrowed from autoconf's
|
||||||
|
for option in $extra_args "$@"
|
||||||
|
do
|
||||||
|
if test -n "$prev" ; then :
|
||||||
|
host=$option
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
case $dashdash$option in
|
||||||
|
--)
|
||||||
|
dashdash=yes ;;
|
||||||
|
-host | --host | --hos | --ho)
|
||||||
|
prev=host ;;
|
||||||
|
-host=* | --host=* | --hos=* | --ho=*)
|
||||||
|
case $option in
|
||||||
|
*=?*) host=$(expr "X$option" : '[^=]*=\(.*\)') ;;
|
||||||
|
*=) host= ;;
|
||||||
|
esac ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
cache_file="`dirname "$0"`/$extended_cache/ocaml-$host.cache"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If either option has a value, re-invoke configure
|
||||||
|
if test -n "$extra_args$cache_file" ; then :
|
||||||
echo "Detected Git configuration option ocaml.configure set to \
|
echo "Detected Git configuration option ocaml.configure set to \
|
||||||
\"$extra_args\""
|
\"$extra_args\""
|
||||||
# Too much effort to get the echo to show appropriate quoting - the
|
# Too much effort to get the echo to show appropriate quoting - the
|
||||||
# invocation itself intentionally quotes $0 and passes $@ exactly as given
|
# invocation itself intentionally quotes $0 and passes $@ exactly as given
|
||||||
# but allows a single expansion of ocaml.configure
|
# but allows a single expansion of ocaml.configure
|
||||||
echo "Re-running $0 $extra_args $@"
|
if test -n "$cache_file" ; then :
|
||||||
ac_read_git_config=true exec "$0" $extra_args "$@"
|
echo "Re-running $0 $extra_args --cache-file \"$cache_file\" $@"
|
||||||
|
ac_read_git_config=true exec "$0" $extra_args \
|
||||||
|
--cache-file "$cache_file" "$@"
|
||||||
|
else
|
||||||
|
echo "Re-running $0 $extra_args $@"
|
||||||
|
ac_read_git_config=true exec "$0" $extra_args "$@"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue