From 07b12e72497b3f0e6e53eebab032e92e1f789f0a Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Tue, 7 Jul 2020 07:57:32 +0100 Subject: Various improvements to the build system. - Fix running configure where configure is not in the PWD. - Only show relative paths when generating files from templates. --- make/configure.pm | 52 +++++++++++++++++++++++++--------------------------- 1 file changed, 25 insertions(+), 27 deletions(-) (limited to 'make/configure.pm') diff --git a/make/configure.pm b/make/configure.pm index bd3591e3c..87a968a5b 100644 --- a/make/configure.pm +++ b/make/configure.pm @@ -30,10 +30,9 @@ use feature ':5.10'; use strict; use warnings FATAL => qw(all); -use Cwd qw(getcwd); use Exporter qw(import); use File::Basename qw(basename dirname); -use File::Spec::Functions qw(catdir catfile); +use File::Spec::Functions qw(abs2rel catdir catfile); use make::common; use make::console; @@ -59,7 +58,7 @@ our @EXPORT = qw(CONFIGURE_CACHE_FILE sub __get_socketengines { my @socketengines; - foreach () { + foreach (<${\CONFIGURE_ROOT}/src/socketengines/socketengine_*.cpp>) { s/src\/socketengines\/socketengine_(\w+)\.cpp/$1/; push @socketengines, $1; } @@ -106,7 +105,6 @@ sub cmd_clean { } sub cmd_help { - my $PWD = getcwd(); my $SELIST = join ', ', __get_socketengines(); print < ...\n"; + print_format "Creating <|GREEN ${\abs2rel CONFIGURE_DIRECTORY, CONFIGURE_ROOT}|> ...\n"; create_directory CONFIGURE_DIRECTORY, 0750 or print_error "unable to create ${\CONFIGURE_DIRECTORY}: $!"; } - print_format "Writing <|GREEN ${\CONFIGURE_CACHE_FILE}|> ...\n"; + print_format "Writing <|GREEN ${\abs2rel CONFIGURE_CACHE_FILE, CONFIGURE_ROOT}|> ...\n"; my %config = @_; write_config_file CONFIGURE_CACHE_FILE, %config; } @@ -262,9 +260,9 @@ sub parse_templates($$$) { my %settings = __get_template_settings($config, $compiler, $version); # Iterate through files in make/template. - foreach () { - print_format "Parsing <|GREEN $_|> ...\n"; - open(my $fh, $_) or print_error "unable to read $_: $!"; + foreach my $template (<${\CONFIGURE_ROOT}/make/template/*>) { + print_format "Parsing <|GREEN ${\abs2rel $template, CONFIGURE_ROOT}|> ...\n"; + open(my $fh, $template) or print_error "unable to read $template: $!"; my (@lines, $mode, @platforms, @targets); # First pass: parse template variables and directives. @@ -279,7 +277,7 @@ sub parse_templates($$$) { } elsif (defined $default) { $line =~ s/\Q$variable\E/$default/; } else { - print_warning "unknown template variable '$name' in $_!"; + print_warning "unknown template variable '$name' in $template!"; last; } } @@ -297,9 +295,9 @@ sub parse_templates($$$) { } elsif ($2 eq 'platform') { push @platforms, $3; } elsif ($2 eq 'target') { - push @targets, $3 + push @targets, catfile CONFIGURE_ROOT, $3; } else { - print_warning "unknown template command '$2' in $_!"; + print_warning "unknown template command '$2' in $template!"; push @lines, $line; } next; @@ -313,7 +311,7 @@ sub parse_templates($$$) { # Add a default target if the template has not defined one. unless (@targets) { - push @targets, catfile(CONFIGURE_DIRECTORY, basename $_); + push @targets, catfile(CONFIGURE_DIRECTORY, basename $template); } # Write the templated files to disk. @@ -322,12 +320,12 @@ sub parse_templates($$$) { # Create the directory if it doesn't already exist. my $directory = dirname $target; unless (-e $directory) { - print_format "Creating <|GREEN $directory|> ...\n"; + print_format "Creating <|GREEN ${\abs2rel $directory, CONFIGURE_ROOT}|> ...\n"; create_directory $directory, 0750 or print_error "unable to create $directory: $!"; }; # Write the template file. - print_format "Writing <|GREEN $target|> ...\n"; + print_format "Writing <|GREEN ${\abs2rel $target, CONFIGURE_ROOT}|> ...\n"; open(my $fh, '>', $target) or print_error "unable to write $target: $!"; foreach (@lines) { say $fh $_; -- cgit v1.2.3