Skip to content

Commit

Permalink
[build] {en,dis}able-feature, with{,out}-library [GH #1101]
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Reini Urban committed Oct 16, 2014
1 parent 9f4a807 commit b839567
Show file tree
Hide file tree
Showing 10 changed files with 123 additions and 36 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Expand Up @@ -25,6 +25,9 @@
- Build
+ Fix all -Wshadow instances
+ Added bootstrap-tables make target
+ Configure options consistency: --{en,dis}able-<feature> for shared, rpath,
threads, --with{,out}-<library> 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.
Expand Down
13 changes: 8 additions & 5 deletions Configure.pl
Expand Up @@ -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<DEPRECATED>
Link parrot dynamically.
Link libparrot static or dynamically.
=item C<--m=32>
Expand Down Expand Up @@ -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)>
Expand Down
6 changes: 6 additions & 0 deletions api.yaml
Expand Up @@ -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'
-
4 changes: 2 additions & 2 deletions config/auto/llvm.pm
Expand Up @@ -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;
Expand Down Expand Up @@ -125,7 +125,7 @@ sub runstep {
$verbose,
);
if (! $rv) {
uconf->cc_clean();
$conf->cc_clean();
return 1;
}
}
Expand Down
11 changes: 5 additions & 6 deletions config/auto/pcre.pm
Expand Up @@ -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');

Expand Down
32 changes: 17 additions & 15 deletions config/inter/libparrot.pm
Expand Up @@ -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.
Expand All @@ -65,26 +68,25 @@ 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)',
);

# 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')
Expand All @@ -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') . '"'
Expand Down Expand Up @@ -142,7 +144,7 @@ sub runstep {
);
}

$self->set_result( $parrot_is_shared ? 'yes' : 'no' );
$self->set_result( $enable_shared ? 'yes' : 'no' );

return 1;
}
Expand Down
27 changes: 25 additions & 2 deletions 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;

Expand Down Expand Up @@ -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/;
Expand Down
6 changes: 3 additions & 3 deletions lib/Parrot/Configure/Options/Conf.pm
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
22 changes: 21 additions & 1 deletion 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;
Expand All @@ -25,6 +25,8 @@ our @shared_valid_options = qw{
debugging
define
disable-rpath
disable-shared
disable-threads
exec-prefix
fatal
fatal-step
Expand Down Expand Up @@ -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
Expand Down
35 changes: 33 additions & 2 deletions 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;
Expand All @@ -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 ();
Expand All @@ -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: $!";
Expand Down Expand Up @@ -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 ###################
Expand Down

0 comments on commit b839567

Please sign in to comment.