added a test for --with-luajit.

This commit is contained in:
agentzh (章亦春) 2011-03-07 02:19:54 +08:00
parent 8d2fd89284
commit 215f852bc2
4 changed files with 137 additions and 22 deletions

View File

@ -7,5 +7,5 @@ test: all
prove -r t
try: all
cd ngx_openresty-`./util/ver` && ./configure
cd ngx_openresty-`./util/ver` && ./configure --with-luajit

View File

@ -12,12 +12,16 @@ sub run_test ($);
sub shell (@);
sub cd ($);
our $BuildRoot;
sub run_tests {
my $ver = `bash util/ver`;
chomp $ver;
cd "ngx_openresty-$ver";
$BuildRoot = File::Spec->rel2abs("./build");
for my $block (blocks()) {
run_test($block);
}
@ -42,11 +46,15 @@ sub run_test ($) {
my $expected_err = $block->err;
if (!defined $expected_err) {
$expected_err = '';
} else {
$expected_err =~ s/\$OPENRESTY_BUILD_DIR\b/$BuildRoot/gs;
}
my $expected_out = $block->out;
if (!defined $expected_out) {
$expected_out = '';
} else {
$expected_out =~ s/\$OPENRESTY_BUILD_DIR\b/$BuildRoot/gs;
}
is($stdout, $expected_out, "$name - stdout ok");

View File

@ -12,8 +12,6 @@ __DATA__
=== TEST 1: --help
--- cmd: ./configure --help
--- exit: 0
--- err
--- out
--help this message
@ -172,14 +170,17 @@ Options directly inherited from nginx
=== TEST 2: default
--- cmd: ./configure --dry-run
--- exit: 0
--- err
--- out
cp -r bundle/ build/
cd build
cd lua-5.1.4
make linux
make install INSTALL_TOP=$OPENRESTY_BUILD_DIR/lua-root/usr/local/openresty/lua
export LUA_LIB='$OPENRESTY_BUILD_DIR/lua-root/usr/local/openresty/lua/lib'
export LUA_INC='$OPENRESTY_BUILD_DIR/lua-root/usr/local/openresty/lua/include'
cd ..
cd nginx-0.8.54
./configure --prefix=/usr/local/openresty/nginx \
--with-ld-opt='-Wl,-rpath=/usr/local/openresty/lib' \
--with-cc-opt='-O2' \
--add-module=../echo-nginx-module-0.36rc1 \
--add-module=../xss-nginx-module-0.03rc2 \
@ -205,9 +206,14 @@ cd nginx-0.8.54
--- out
cp -r bundle/ build/
cd build
cd lua-5.1.4
make linux
make install INSTALL_TOP=$OPENRESTY_BUILD_DIR/lua-root/usr/local/openresty/lua
export LUA_LIB='$OPENRESTY_BUILD_DIR/lua-root/usr/local/openresty/lua/lib'
export LUA_INC='$OPENRESTY_BUILD_DIR/lua-root/usr/local/openresty/lua/include'
cd ..
cd nginx-0.8.54
./configure --prefix=/usr/local/openresty/nginx \
--with-ld-opt='-Wl,-rpath=/usr/local/openresty/lib' \
--with-cc-opt='-O0' \
--with-debug \
--add-module=../echo-nginx-module-0.36rc1 \
@ -236,3 +242,37 @@ cd nginx-0.8.54
--with-http_ssl_module conflicts with --without-http_ssl_module
--- out
=== TEST 5: --with-luajit
--- cmd: ./configure --with-luajit --dry-run
--- out
cp -r bundle/ build/
cd build
cd LuaJIT-2.0.0-beta6
make PREFIX=/usr/local/openresty/luajit
make PREFIX=/usr/local/openresty/luajit DESTDIR=$OPENRESTY_BUILD_DIR/luajit-root install
export LUAJIT_LIB='$OPENRESTY_BUILD_DIR/luajit-root/usr/local/openresty/luajit/lib'
export LUAJIT_INC='$OPENRESTY_BUILD_DIR/luajit-root/usr/local/openresty/luajit/include/luajit-2.0'
cd ..
cd nginx-0.8.54
./configure --prefix=/usr/local/openresty/nginx \
--with-cc-opt='-O2' \
--add-module=../echo-nginx-module-0.36rc1 \
--add-module=../xss-nginx-module-0.03rc2 \
--add-module=../ngx_devel_kit-0.2.14 \
--add-module=../set-misc-nginx-module-0.21rc2 \
--add-module=../form-input-nginx-module-0.07rc4 \
--add-module=../encrypted-session-nginx-module-0.01 \
--add-module=../drizzle-nginx-module-0.0.15rc9 \
--add-module=../lua-nginx-module-0.1.6rc1 \
--add-module=../headers-more-nginx-module-0.14 \
--add-module=../srcache-nginx-module-0.12rc1 \
--add-module=../array-var-nginx-module-0.02 \
--add-module=../memc-nginx-module-0.12rc1 \
--add-module=../upstream-keepalive-nginx-module-0.3 \
--add-module=../auth-request-nginx-module-0.2 \
--add-module=../rds-json-nginx-module-0.11rc2 \
--with-ld-opt='-Wl,-rpath=/usr/local/openresty/luajit/lib' \
--with-http_ssl_module

97
util/configure vendored
View File

@ -6,7 +6,8 @@ use warnings;
use File::Spec;
sub shell (@);
sub shell ($@);
sub env ($$);
sub cd ($);
sub auto_complete ($);
sub usage ($);
@ -64,6 +65,7 @@ my $with_resty_mods_regex;
my $prefix = '/usr/local/openresty';
my %resty_opts;
my $dry_run;
my @ngx_rpaths;
my @ngx_opts;
for my $opt (@ARGV) {
@ -112,21 +114,29 @@ for my $opt (@ARGV) {
my $ngx_prefix = "$prefix/nginx";
my $cmd = "./configure --prefix=$ngx_prefix"
. " \\\n --with-ld-opt='-Wl,-rpath=$prefix/lib'"
. build_resty_opts(\%resty_opts)
. (@ngx_rpaths ? " \\\n --with-ld-opt='-Wl,-rpath="
. join(":", @ngx_rpaths) . "'" : "")
. (@ngx_opts ? " \\\n " . join(" ", @ngx_opts) : "");
;
if ($dry_run) {
print "$cmd\n";
exit 0;
shell $cmd, $dry_run;
sub env ($$) {
my ($name, $val) = @_;
print "export $name='$val'\n";
$ENV{$name} = $val;
}
shell $cmd;
sub shell ($@) {
my ($cmd, $dry_run) = @_;
sub shell (@) {
print "@_\n";
system(@_) == 0 or die "failed to run command @_\n";
print "$cmd\n";
unless ($dry_run) {
system($cmd) == 0 or
die "failed to run command @_\n";
}
}
sub auto_complete ($) {
@ -160,8 +170,8 @@ sub build_resty_opts {
}
}
if ($opts->{luajit}) {
$opts->{no_lua} = 1;
if (! $opts->{luajit} && ! $opts->{no_http_lua}) {
$opts->{lua} = 1;
}
if (! $opts->{no_http_drizzle}) {
@ -173,13 +183,13 @@ sub build_resty_opts {
}
if (! $opts->{no_http_ssl} && ! $opts->{http_ssl}) {
$resty_opts{http_ssl} = 1;
$opts->{http_ssl} = 1;
push @ngx_opts, '--with-http_ssl_module';
}
my $opts_line = '';
if ($resty_opts{debug}) {
if ($opts->{debug}) {
$opts_line .= " \\\n --with-cc-opt='-O0' \\\n --with-debug";
} else {
$opts_line .= " \\\n --with-cc-opt='-O2'";
@ -197,6 +207,62 @@ sub build_resty_opts {
cd 'build';
# build 3rd-party C libraries if required
if ($opts->{luajit}) {
my $luajit_src = auto_complete 'LuaJIT';
my $luajit_prefix = "$prefix/luajit";
my $luajit_root = File::Spec->rel2abs("luajit-root");
if (-d $luajit_root) {
shell "rm -rf $luajit_root";
}
mkdir $luajit_root or
die "create create directory luajit-root: $!\n";
cd $luajit_src;
shell "make PREFIX=$luajit_prefix", $dry_run;
shell "make PREFIX=$luajit_prefix DESTDIR=$luajit_root install", $dry_run;
env LUAJIT_LIB => "$luajit_root$luajit_prefix/lib";
env LUAJIT_INC => "$luajit_root$luajit_prefix/include/luajit-2.0";
push @ngx_rpaths, "$luajit_prefix/lib";
cd '..';
} elsif ($opts->{lua}) {
my $lua_src = glob('lua-5.*');
if (!defined $lua_src) {
die "No lua5 found";
}
my $lua_prefix = "$prefix/lua";
my $lua_root = File::Spec->rel2abs("lua-root");
if (-d $lua_root) {
shell "rm -rf $lua_root";
}
mkdir $lua_root or
die "create create directory lua-root: $!\n";
cd $lua_src;
shell "make linux", $dry_run;
shell "make install INSTALL_TOP=$lua_root$lua_prefix", $dry_run;
env LUA_LIB => "$lua_root$lua_prefix/lib";
env LUA_INC => "$lua_root$lua_prefix/include";
cd '..';
}
# prepare nginx configure line
my $ngx_dir = auto_complete "nginx";
cd $ngx_dir;
@ -205,9 +271,10 @@ sub build_resty_opts {
my ($name, $prefix, $attr) = @$mod;
if ($attr && $attr eq 'disabled') {
next if not $resty_opts{"$name"};
next if not $opts->{"$name"};
} else {
next if $resty_opts{"no_$name"};
next if $opts->{"no_$name"};
}
my $dir = auto_complete "../$prefix";