configure: Rewrite implementation of --update.

Previously --update was kind of a hack, as it just dumped all
the variables from BuildConfig back into ./configure and attempted
to rerun from there.

Instead, now we store all of the variables and environs configure
was invoked with in the top of BuildConfig and re-call it using them.
This is much more robust, as configure will actually recompute
all of the values from the BuildConfig.

As a side effect, if configure was originally invoked to build crosstools,
it would have done so again, so instead add a check to see if they
exist, and skip them if they do. It's easy enough to delete the
directory if you want to force a crosstools rebuild.

Briefly discussed with mmlr on IRC.
This commit is contained in:
Augustin Cavalier 2017-12-04 20:14:18 -05:00
parent bf1a86c199
commit 825700d34a
2 changed files with 47 additions and 48 deletions

View File

@ -1,23 +0,0 @@
#!/usr/bin/perl
use warnings;
use strict;
=head1 convert_build_config_to_shell_format
This simple script converts its standard input from the jam-specific format
that is being used in BuildSetup into a format that's understood by sh.
=cut
my $data;
while (my $line = <>) {
$data .= $line;
if ($data =~ m{\s*([+\w]+)\s*\?=\s*\"?([^;]*?)\"?\s*;}gms) {
my ($variable, $value) = ($1, $2);
$variable =~ tr{+}{X}; # '+' is illegal as part of shell variable
print "$variable='$value'\n";
$data = '';
}
}

72
configure vendored
View File

@ -12,6 +12,9 @@ usage()
Usage: $0 <options>
options:
--help Prints out this help.
--update Re-runs last configure invocation [must be given
as first option!]
--bootstrap <haikuporter> <HaikuPorts cross repo> <HaikuPorts repo>
Prepare for a bootstrap build. No pre-built
packages will be used, instead they will be built
@ -51,7 +54,6 @@ options:
official -- the official Haiku distribution.
compatible -- a Haiku Compatible (tm) distro.
default -- any other distro (default value).
--help Prints out this help.
--host-only Configure for building tools for the build host
only. Haiku cannot be built when configured like
this.
@ -59,7 +61,7 @@ options:
ideas and techniques. If this option is not
specified, the resulting distribution may still
implement patented ideas and techniques. This
option only disables code that is currently known
option only enables code that is currently known
to be problematic.
--include-sources Includes the source code of projects that require
either an offer of source code or a copy of the
@ -81,8 +83,6 @@ options:
first occurrence specifies the primary
architecture of the Haiku to build, subsequent
ones the secondary architectures.
--update re-runs last configure invocation [must be given
as first option!]
--use-clang <arch> Build with host Clang instead of GCC cross
compiler, targeting <arch>
--use-gcc-pipe Build with GCC option -pipe. Speeds up the build
@ -415,6 +415,17 @@ cd "$currentDir"
# backup the passed arguments
configureArgs="$@"
configurePath=$0
# backup relevant environs
configureEnvirons=
for var in `env`; do
case "$var" in
CC\=*|HAIKU*\=*)
configureEnvirons="$configureEnvirons $var"
;;
esac
done
# internal default parameter values
#
@ -502,17 +513,20 @@ if [ "$1" = "--update" ]; then
echo $0 --update: \'$buildConfigFile\' not found - updating not possible.
exit 1
fi
if ! type perl >/dev/null 2>&1; then
echo $0 --update: \'perl\' not found - updating not possible.
# get last configure invocation and flags from BuildConfig and call ourselves with it
lastPwd=`grep "#d " "$buildConfigFile" | cut -c 4-`
lastConfig=`grep "#c " "$buildConfigFile" | cut -c 4-`
lastEnv=`grep "#e " "$buildConfigFile" | cut -c 4-`
lastArgs=`grep "#a " "$buildConfigFile" | cut -c 4-`
if [ -z "$lastConfig" ]; then
echo "$0 --update: The previous configure invocation was not properly" \
"encoded into '$buildConfigFile' - updating not possible."
exit 1
fi
# convert BuildConfig from jam format to shell format and evaluate it
shellConfigFile="${buildConfigFile}.shell"
perl "$sourceDir/build/scripts/convert_build_config_to_shell_format.pl" \
<"$buildConfigFile" >"$shellConfigFile"
. "$shellConfigFile"
rm "$shellConfigFile"
shift
cd $lastPwd
export $lastEnv
$lastConfig $lastArgs
exit $?
fi
# parse parameters
@ -791,14 +805,18 @@ else
*) MAKE=make;;
esac
MAKE=$MAKE \
SECONDARY_ARCH=$secondaryArch \
HAIKU_USE_GCC_GRAPHITE=`get_variable \
HAIKU_USE_GCC_GRAPHITE_$targetArch` \
HAIKU_USE_GCC_PIPE=$HAIKU_USE_GCC_PIPE \
HAIKU_USE_GDB="$gdbSources" \
"$script" $scriptArgs "$sourceDir" "$buildCrossTools" \
"$crossToolsDir" $buildCrossToolsJobs || exit 1
if [ ! -d "$crossToolsDir" ]; then
MAKE=$MAKE \
SECONDARY_ARCH=$secondaryArch \
HAIKU_USE_GCC_GRAPHITE=`get_variable \
HAIKU_USE_GCC_GRAPHITE_$targetArch` \
HAIKU_USE_GCC_PIPE=$HAIKU_USE_GCC_PIPE \
HAIKU_USE_GDB="$gdbSources" \
"$script" $scriptArgs "$sourceDir" "$buildCrossTools" \
"$crossToolsDir" $buildCrossToolsJobs || exit 1
else
echo "$targetArch crosstools already exist in $crossToolsDir; skipping build"
fi
crossToolsPrefix="$crossToolsDir/bin/${targetMachine}-"
fi
@ -863,10 +881,14 @@ fi
# Generate BuildConfig
cat << EOF > "$buildConfigFile"
# BuildConfig
# Note: This file has been automatically generated by configure with the
# following arguments:
# ${configureArgs}
# -- WARNING --
# This file was AUTOMATICALLY GENERATED by configure, and will be completely
# overwritten the next time configure is run.
#
#d ${currentDir}
#c ${configurePath}
#e ${configureEnvirons}
#a ${configureArgs}
TARGET_PLATFORM ?= "${TARGET_PLATFORM}" ;
HOST_PLATFORM ?= "${HOST_PLATFORM}" ;