From b839567972c3aa13ebd0c44c8f8059a178e697c7 Mon Sep 17 00:00:00 2001 From: Reini Urban Date: Thu, 16 Oct 2014 17:40:33 +0200 Subject: [PATCH] [build] {en,dis}able-feature, with{,out}-library [GH #1101] now similar to autoconf: deprecate --parrot-is-shared in favor of --enable-shared. allow both variants enable,disable for the features: shared, rpath, threads and set both config->options keys. allow both variants with,without for the libraries: llvm pcre crypto gdbm gettext gmp icu opengl libffi readline pcre threads zlib and set both config->options keys. translate {en,dis}able-threads into without-threads add tests for all options. add api.yaml deprecation note --- ChangeLog | 3 ++ Configure.pl | 13 +++++--- api.yaml | 6 ++++ config/auto/llvm.pm | 4 +-- config/auto/pcre.pm | 11 +++---- config/inter/libparrot.pm | 32 ++++++++++--------- lib/Parrot/Configure/Options.pm | 27 ++++++++++++++-- lib/Parrot/Configure/Options/Conf.pm | 6 ++-- lib/Parrot/Configure/Options/Conf/Shared.pm | 22 ++++++++++++- t/configure/001-options.t | 35 +++++++++++++++++++-- 10 files changed, 123 insertions(+), 36 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3692d8ef7a..84684b7314 100644 --- a/ChangeLog +++ b/ChangeLog @@ -25,6 +25,9 @@ - Build + Fix all -Wshadow instances + Added bootstrap-tables make target + + Configure options consistency: --{en,dis}able- for shared, rpath, + threads, --with{,out}- for: llvm pcre ... + threads. [GH #1101] + + Deprecated --parrot_is_shared in favor of --enable-shared. [GH #1101] - Documentation + Add missing manpages for pbc_disassemble, pbc_dump, pbc_merge + Improved src/string/encoding/tables.c pod. diff --git a/Configure.pl b/Configure.pl index 90aebf4880..2d1ef919a8 100644 --- a/Configure.pl +++ b/Configure.pl @@ -248,9 +248,11 @@ =head2 Compile Options Debugging is turned on by default. Use this to disable it. -=item C<--parrot_is_shared> +=item C<--enable-shared> +=item C<--disable-shared> +=item C<--parrot_is_shared> C -Link parrot dynamically. +Link libparrot static or dynamically. =item C<--m=32> @@ -324,13 +326,14 @@ =head2 Compile Options Use the given loader flags for shared libraries +=item C<--enable-rpath> =item C<--disable-rpath> -Specify that rpath should not be included in linking flags. With this +If rpath should be included in the linking flags. With this configuration option, you must append the library build directory (usually blib/lib) to the LD_LIBRARY_PATH environment variable (or your -platform equivalent). This option is primarily used for building Linux -packages. +platform equivalent). C<--disable-rpath> is primarily used for building Linux +packages, to be prefix independent. =item C<--lex=(lexer)> diff --git a/api.yaml b/api.yaml index 74be76a29e..035bc2e947 100644 --- a/api.yaml +++ b/api.yaml @@ -665,4 +665,10 @@ - 'api' - 'completed' ticket: 'https://github.com/parrot/parrot/issues/937' +- + name: '--parrot_is_shared replaced by --enable-shared' + note: 'Harmonized the Configure.pl options' + tags: + - deprecated + ticket: 'https://github.com/parrot/parrot/issues/1101' - diff --git a/config/auto/llvm.pm b/config/auto/llvm.pm index bd6e304ed1..a9d4df900d 100644 --- a/config/auto/llvm.pm +++ b/config/auto/llvm.pm @@ -34,7 +34,7 @@ sub runstep { my ( $self, $conf ) = @_; my $verbose = $conf->options->get( 'verbose' ); - unless ( $conf->options->get( 'with-llvm' ) ) { + if ( !$conf->options->get('with-llvm') ) { $self->_handle_result( $conf, 0 ); $self->set_result('skipped'); print "--with-llvm not requested.\n" if $verbose; @@ -125,7 +125,7 @@ sub runstep { $verbose, ); if (! $rv) { - uconf->cc_clean(); + $conf->cc_clean(); return 1; } } diff --git a/config/auto/pcre.pm b/config/auto/pcre.pm index d6c079e4c4..4639c716b3 100644 --- a/config/auto/pcre.pm +++ b/config/auto/pcre.pm @@ -32,12 +32,11 @@ sub _init { sub runstep { my ( $self, $conf ) = @_; - my $without = $conf->options->get( qw| without-pcre | ); - - $self->set_result('skipped'); - $conf->data->set( HAS_PCRE => 0 ); - - return 1 if ($without); + unless ( $conf->options->get('without-pcre') ) { + $self->set_result('skipped'); + $conf->data->set( HAS_PCRE => 0 ); + return 1; + } my $osname = $conf->data->get('osname'); diff --git a/config/inter/libparrot.pm b/config/inter/libparrot.pm index b5a8f289e0..f0a938af1a 100644 --- a/config/inter/libparrot.pm +++ b/config/inter/libparrot.pm @@ -32,15 +32,18 @@ sub _init { sub runstep { my ( $self, $conf ) = @_; - my $parrot_is_shared = $conf->options->get('parrot_is_shared'); - my $disable_rpath = $conf->options->get('disable-rpath'); + my $enable_shared = $conf->options->get('enable-shared'); + my $disable_rpath = !$conf->options->get('enable-rpath'); - $parrot_is_shared = integrate( - $conf->data->get('parrot_is_shared'), - $parrot_is_shared + $enable_shared = integrate( + $conf->data->get('enable-shared'), + $enable_shared ); - $parrot_is_shared = 0 unless $conf->data->get('has_dynamic_linking'); + # let the command-line override the failed has_dynamic_linking probe + unless ($conf->data->get('has_dynamic_linking')) { + $enable_shared = 0 unless $conf->options->get('enable-shared'); + } # Parrot can't necessarily handle a pre-existing installed shared # libparrot.so without rpath. @@ -65,18 +68,17 @@ sub runstep { && $conf->data->get('has_dynamic_linking') ) { - $parrot_is_shared = prompt( + $enable_shared = prompt( "\nShould parrot be built using a shared library?", - $parrot_is_shared ? 'y' : 'n' + $enable_shared ? 'y' : 'n' ); - $parrot_is_shared = lc($parrot_is_shared) eq 'y'; + $enable_shared = lc($enable_shared) eq 'y'; } $conf->data->set( - parrot_is_shared => $parrot_is_shared, - - libparrot_for_makefile_only => $parrot_is_shared + parrot_is_shared => $enable_shared, + libparrot_for_makefile_only => $enable_shared ? '$(LIBPARROT_SHARED)' : '$(LIBPARROT_STATIC)', ); @@ -84,7 +86,7 @@ sub runstep { # Set -rpath (or equivalent) for executables to find the # shared libparrot in the build directory. $conf->data->set( rpath_blib => ( ! $disable_rpath - && $parrot_is_shared + && $enable_shared && $conf->data->get('rpath') ) ? '"' . $conf->data->get('rpath') . $conf->data->get('build_dir') @@ -96,7 +98,7 @@ sub runstep { # Set -rpath (or equivalent) for the installed executables to find the # installed shared libparrot. $conf->data->set( rpath_lib => ( ! $disable_rpath - && $parrot_is_shared + && $enable_shared && $conf->data->get('rpath') ) ? $conf->data->get('rpath') . '"' . $conf->data->get('libdir') . '"' @@ -142,7 +144,7 @@ sub runstep { ); } - $self->set_result( $parrot_is_shared ? 'yes' : 'no' ); + $self->set_result( $enable_shared ? 'yes' : 'no' ); return 1; } diff --git a/lib/Parrot/Configure/Options.pm b/lib/Parrot/Configure/Options.pm index 1e9cfa6140..8e217bd970 100644 --- a/lib/Parrot/Configure/Options.pm +++ b/lib/Parrot/Configure/Options.pm @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2011, Parrot Foundation. +# Copyright (C) 2001-2014, Parrot Foundation. package Parrot::Configure::Options; @@ -87,13 +87,36 @@ sub _initial_pass { if ($el =~ m/--([-\w]+)(?:=(.*))?/) { ( $key, $value ) = ($1, $2); } - $key = 'help' unless defined $key; + # threads is a feature, not a library. but we check for without-threads + if ( $key =~ /^(en|dis)able-threads/ ) { + $data->{'without-threads'} = $1 eq 'dis' ? 1 : 0; + } + # binary logic for with/without and enable/disable + # we should only check positive keys in Data + if ($key =~ /^(disable|without)-(.*)/) { + # but traditionally we check against --without in most libs + $data->{$key} = defined $value ? $value : 1; + $key =~ s/^dis/en/; + $key =~ s/^without/with/; + $value = defined $value ? !$value : 0; + } + elsif ($key =~ /^(enable|with)-(.*)/) { + $data->{$key} = defined $value ? $value : 1; + $key =~ s/^en/dis/; + $key =~ s/^with/without/; + $value = defined $value ? !$value : 0; + } $value = 1 unless defined $value; + $key = 'help' unless defined $key; $value =~ s/^(["'])(.*)\1$/$2/; unless ( $valid_opts{$key} ) { die qq/Invalid option "$key". See "perl $script --help" for valid options\n/; } + if ( $key eq 'parrot_is_shared' ) { + warn qq/--parrot_is_shared is deprecated. please use --enable-shared instead/; + $key = 'enable-shared'; + } if ( $key eq 'prefix' and ! File::Spec->file_name_is_absolute( $value) ) { die qq/Relative path given to --prefix, please pass an absolute path/; diff --git a/lib/Parrot/Configure/Options/Conf.pm b/lib/Parrot/Configure/Options/Conf.pm index c9223415eb..419eb5c548 100644 --- a/lib/Parrot/Configure/Options/Conf.pm +++ b/lib/Parrot/Configure/Options/Conf.pm @@ -55,8 +55,8 @@ Compile Options: --inline Compiler supports inline --optimize Optimized compile --optimize=flags Add given optimizer flags - --parrot_is_shared Link parrot dynamically - --disable-rpath Link without rpath (user must set LD_LIBRARY_PATH) + --{en,dis}able-shared How to link libparrot + --{en,dis}able-rpath If without rpath (user must set LD_LIBRARY_PATH) --m=32 Build 32bit executable on 64-bit architecture. --profile Turn on profiled compile (gcc only for now) --cage [CAGE] compile includes many additional warnings @@ -95,7 +95,7 @@ Parrot Options: Build parrot without unnecessary statically compiled NCI call frames -External Library Options: +External Library Options (use --with- or --without-): --with-llvm Link to LLVM if it is available --without-gettext Build parrot without gettext support diff --git a/lib/Parrot/Configure/Options/Conf/Shared.pm b/lib/Parrot/Configure/Options/Conf/Shared.pm index 5ac4452aa0..5cd8f2f7c7 100644 --- a/lib/Parrot/Configure/Options/Conf/Shared.pm +++ b/lib/Parrot/Configure/Options/Conf/Shared.pm @@ -1,4 +1,4 @@ -# Copyright (C) 2007-2012, Parrot Foundation. +# Copyright (C) 2007-2014, Parrot Foundation. package Parrot::Configure::Options::Conf::Shared; use strict; @@ -25,6 +25,8 @@ our @shared_valid_options = qw{ debugging define disable-rpath + disable-shared + disable-threads exec-prefix fatal fatal-step @@ -87,6 +89,24 @@ our @shared_valid_options = qw{ yacc }; +our @reverse_valid_options; +for (@shared_valid_options) { + if (/^with-(.*)/) { + push @reverse_valid_options, "without-$1"; + } + elsif (/^without-(.*)/) { + push @reverse_valid_options, "with-$1"; + } + elsif (/^enable-(.*)/) { + push @reverse_valid_options, "disable-$1"; + } + elsif (/^disable-(.*)/) { + push @reverse_valid_options, "enable-$1"; + } +} + +push @shared_valid_options, @reverse_valid_options; + ################### DOCUMENTATION ################### =head1 NAME diff --git a/t/configure/001-options.t b/t/configure/001-options.t index 9fa9ffc341..084fa758fc 100644 --- a/t/configure/001-options.t +++ b/t/configure/001-options.t @@ -1,5 +1,5 @@ #! perl -# Copyright (C) 2007, Parrot Foundation. +# Copyright (C) 2007,2014, Parrot Foundation. # 001-options.t use strict; @@ -11,7 +11,7 @@ BEGIN { our $topdir = realpath($Bin) . "/../.."; unshift @INC, qq{$topdir/lib}; } -use Test::More tests => 52; +use Test::More tests => 92; use Carp; use Parrot::Configure::Options qw| process_options |; use Parrot::Configure::Options::Conf::CLI (); @@ -34,6 +34,19 @@ ok( defined $valid{verbose}, "verbose option found" ); ok( !defined $valid{$badoption}, "invalid option not found" ); ok( !defined $valid{step}, "invalid 'step' option not found" ); ok( !defined $valid{target}, "invalid 'target' option not found" ); +for my $feat (qw(shared rpath threads)) { + my $key = "enable-".$feat; + ok( defined $valid{$key}, "$key valid" ); + $key = "disable-$feat"; + ok( defined $valid{$key}, "$key valid" ); +} +for my $lib (qw(llvm pcre crypto gdbm gettext gmp icu opengl libffi + readline pcre threads zlib)) { + my $key = "with-".$lib; + ok( defined $valid{$key}, "$key valid" ); + $key = "without-".$lib; + ok( defined $valid{$key}, "$key valid" ); +} open my $FH, '<', "$main::topdir/Configure.pl" or croak "Unable to open handle to $main::topdir/Configure.pl: $!"; @@ -284,6 +297,24 @@ is($data->{cc}, $cc, "Got expected value for cc"); is_deeply($short_circuits_ref, [ ], "Got expected short circuits"); +$args = { + argv => [ q{--verbose}, q{--help}, qq{--without-llvm}, qq{--with-pcre}, qq{--without-libffi}, qq{--disable-threads}, ], + mode => 'configure', +}; +($args, $options_components, $script) = + Parrot::Configure::Options::_process_options_components($args); +($data, $short_circuits_ref) = + Parrot::Configure::Options::_initial_pass( + $args, $options_components, $script); +is($data->{'without-llvm'}, 1, "--without-llvm detected"); +is($data->{'with-pcre'}, 1, "--with-pcre detected"); +is($data->{'without-libffi'}, 1, "--without-libffi detected"); +is($data->{'with-llvm'}, 0, "--without-llvm turns off --with-llvm"); +is($data->{'without-pcre'}, 0, "--with-pcre turns off --without-pcre"); +is($data->{'with-libffi'}, 0, "--without-libffi turns off --with-pcre"); +is($data->{'enable-threads'}, 0, "--disable-threads turns off --enable-threads"); +is($data->{'without-threads'}, 1, "--disable-threads turns on --without-threads"); + pass("Completed all tests in $0"); ################### DOCUMENTATION ###################