mirror of
https://github.com/openresty/openresty.git
synced 2024-10-13 00:29:41 +00:00
* upgraded ngx_lua to 0.9.18rc1 to support Win32 LuaJIT DLL. * upgraded lua-redis-parser to 0.11rc1 for better Win32 support. * upgraded lua-rds-parser to 0.06rc2 for better Win32 support. * upgraded ngx_rds_csv to 0.07rc1 for better Win32 support. * upgraded lua-resty-cli to 0.04rc1 for better Win32 support. * upgraded lua-resty-core to 0.1.2. * applied a patch to LuaJIT to add "!/lualib/" to the default Lua package search paths. * upgraded lua-cjson to 2.1.0.3rc2 for better Win32 support and a suppressed gcc warning. * use OpenResty's nginx tarballs extracted directly from the official nginx code repos, because we need the win32 support which is excluded in the official nginx release tarballs. Our nginx release tarballs are generated by the util/package-nginx.sh script. * added the util/package-win32.sh script to generate the Win32 OpenResty binary distribution file. * applied a patch to always enable C compiler feature tests in nginx's own build system because the MinGW gcc compiler on Win32 is also powerful enough to support advanced features like variadic macros. * added document README-win32. * util/dist-check: do a partial uninstallation before installing anything new. * added util/build-win32.sh to build OpenResty on Win32 using the MinGW/MSYS toolchain. * ./configure: added support for building on Win32 using the MinGW/MSYS toolchain.
247 lines
7.8 KiB
C
Executable File
247 lines
7.8 KiB
C
Executable File
#!/usr/bin/env perl
|
|
|
|
use strict;
|
|
use warnings;
|
|
|
|
use Getopt::Std qw(getopts);
|
|
use Cwd qw/cwd/;
|
|
|
|
sub sh ($);
|
|
sub write_config_file ($);
|
|
|
|
my %opts;
|
|
getopts("lf:", \%opts) or die "Usage: $0 [-f] [-l] <cores>\n";
|
|
|
|
my $jobs = shift || 4;
|
|
|
|
my $cwd = cwd();
|
|
if ($cwd !~ /ngx_openresty-(\d+(?:\.\d+)+(?:rc\d+(?:\.\d+)?)?)$/) {
|
|
die "Bad current working directory: $cwd\n";
|
|
}
|
|
|
|
my $ver = $1;
|
|
|
|
my ($make, $lua);
|
|
|
|
if ($^O eq 'freebsd' || $^O eq 'solaris') {
|
|
$make = 'gmake';
|
|
|
|
} else {
|
|
$make = 'make';
|
|
}
|
|
|
|
my $cfg_opts = "";
|
|
|
|
if ($opts{l}) {
|
|
$lua = 'Lua';
|
|
$cfg_opts .= " --with-lua51";
|
|
|
|
} else {
|
|
$lua = 'LuaJIT';
|
|
#$cfg_opts .= " --with-luajit";
|
|
}
|
|
|
|
if ($^O eq 'solaris') {
|
|
$cfg_opts .= " --with-cc=gcc";
|
|
}
|
|
|
|
if ($^O eq 'darwin') {
|
|
$cfg_opts .= " --with-cc-opt='-I/usr/local/include'"
|
|
. " --with-ld-opt='-L/usr/local/lib'";
|
|
}
|
|
|
|
my $prefix;
|
|
|
|
my $config = do { local $/; <DATA> };
|
|
|
|
sub write_config_file ($) {
|
|
my $outfile = shift;
|
|
warn "Writing file $outfile\n";
|
|
open my $out, ">$outfile" or
|
|
die "Cannot open $outfile for writing: $!\n";
|
|
print $out $config;
|
|
close $out;
|
|
}
|
|
|
|
write_config_file "/tmp/nginx.conf";
|
|
|
|
warn "=== Without Gzip/SSL/PCRE ===\n";
|
|
$prefix = "/usr/local/openresty-nogzip";
|
|
sh "sudo rm -rf $prefix/lualib $prefix/luajit $prefix/bin $prefix/lua $prefix/nginx/sbin $prefix/nginx/html";
|
|
unless ($opts{f}) {
|
|
sh "./configure $cfg_opts --without-http_rewrite_module --without-http_ssl_module --without-pcre --without-http_gzip_module --prefix=$prefix -j$jobs > /dev/null";
|
|
}
|
|
sh "$make -j$jobs > /dev/null";
|
|
sh "sudo $make install > /dev/null";
|
|
sh "sudo cp /tmp/nginx.conf $prefix/nginx/conf/nginx.conf";
|
|
sh "$prefix/nginx/sbin/nginx -V 2>&1 |grep $ver";
|
|
sh "$prefix/nginx/sbin/nginx -V 2>&1 |grep '\\--without-http_gzip_module'";
|
|
sh "$prefix/nginx/sbin/nginx -V 2>&1 |grep -v -q '\\--with-http_ssl_module'";
|
|
sh "$prefix/nginx/sbin/nginx -V 2>&1 |grep '\\--without-pcre'";
|
|
system "sudo killall nginx > /dev/null 2>&1";
|
|
sh "sudo $prefix/nginx/sbin/nginx";
|
|
sh "curl -si localhost/lua|grep $lua";
|
|
sh "curl -si localhost/lua|grep $ver";
|
|
sh "curl -si localhost/cjson|grep 'json.safe: '";
|
|
sh qq{$prefix/bin/resty -e 'ngx.say("Hello World!")'|grep 'Hello World'};
|
|
sh "sudo $prefix/nginx/sbin/nginx -sstop";
|
|
|
|
$cfg_opts .= " --with-http_iconv_module";
|
|
|
|
warn "\n=== --with-threads ===\n";
|
|
$prefix = "/usr/local/openresty-threads";
|
|
sh "sudo rm -rf $prefix/lualib $prefix/luajit $prefix/bin $prefix/lua $prefix/nginx/sbin $prefix/nginx/html";
|
|
unless ($opts{f}) {
|
|
sh "./configure $cfg_opts --with-threads --prefix=$prefix -j$jobs > /dev/null";
|
|
}
|
|
sh "$make -j$jobs > /dev/null";
|
|
sh "sudo $make install > /dev/null";
|
|
sh "sudo cp /tmp/nginx.conf $prefix/nginx/conf/nginx.conf";
|
|
sh "$prefix/nginx/sbin/nginx -V 2>&1 |grep $ver";
|
|
sh "$prefix/nginx/sbin/nginx -V 2>&1 |grep '\\--with-threads'";
|
|
system "sudo killall nginx > /dev/null 2>&1";
|
|
sh "sudo $prefix/nginx/sbin/nginx";
|
|
sh "curl -si localhost/lua|grep $lua";
|
|
sh "curl -si localhost/lua|grep $ver";
|
|
sh "curl -si localhost/cjson|grep 'json.safe: '";
|
|
sh qq{$prefix/bin/resty -e 'ngx.say("Hello World!")'|grep 'Hello World'};
|
|
sh "sudo $prefix/nginx/sbin/nginx -sstop";
|
|
|
|
warn "\n=== No Pool Build ===\n";
|
|
$prefix = "/usr/local/openresty-nopool";
|
|
sh "sudo rm -rf $prefix/lualib $prefix/luajit $prefix/bin $prefix/lua $prefix/nginx/sbin $prefix/nginx/html";
|
|
unless ($opts{f}) {
|
|
sh "./configure --with-no-pool-patch $cfg_opts --prefix=$prefix -j$jobs > /dev/null";
|
|
}
|
|
sh "$make -j$jobs > /dev/null";
|
|
sh "sudo $make install > /dev/null";
|
|
sh "sudo cp /tmp/nginx.conf $prefix/nginx/conf/nginx.conf";
|
|
sh "$prefix/nginx/sbin/nginx -V 2>&1 |grep $ver";
|
|
#sh "$prefix/nginx/sbin/nginx -V 2>&1 |grep '\\--with-no-pool-patch'";
|
|
system "sudo killall nginx > /dev/null 2>&1";
|
|
sh "sudo $prefix/nginx/sbin/nginx";
|
|
sh "curl -si localhost/lua|grep $lua";
|
|
sh "curl -si localhost/lua|grep $ver";
|
|
sh "curl -si localhost/lua|grep 'no pool'";
|
|
sh "curl -si localhost/cjson|grep 'json.safe: '";
|
|
sh qq{$prefix/bin/resty -e 'ngx.say("Hello World!")'|grep 'Hello World'};
|
|
sh "sudo $prefix/nginx/sbin/nginx -sstop";
|
|
|
|
warn "\n=== Normal Build ===\n";
|
|
$prefix = "/usr/local/openresty";
|
|
sh "sudo rm -rf $prefix/lualib $prefix/luajit $prefix/bin $prefix/lua $prefix/nginx/sbin $prefix/nginx/html";
|
|
unless ($opts{f}) {
|
|
sh "./configure $cfg_opts -j$jobs > /dev/null";
|
|
}
|
|
sh "$make -j$jobs > /dev/null";
|
|
sh "sudo $make install > /dev/null";
|
|
sh "sudo cp /tmp/nginx.conf $prefix/nginx/conf/nginx.conf";
|
|
sh "$prefix/nginx/sbin/nginx -V 2>&1 |grep $ver";
|
|
system "sudo killall nginx > /dev/null 2>&1";
|
|
sh "sudo $prefix/nginx/sbin/nginx";
|
|
sh "curl -si localhost/lua|grep $lua";
|
|
sh "curl -si localhost/lua|grep $ver";
|
|
sh "curl -si localhost/cjson|grep 'json.safe: '";
|
|
sh qq{$prefix/bin/resty -e 'ngx.say("Hello World!")'|grep 'Hello World'};
|
|
sh "sudo $prefix/nginx/sbin/nginx -sstop";
|
|
|
|
warn "\n=== Debug Build ===\n";
|
|
$prefix = "/usr/local/openresty-debug";
|
|
sh "sudo rm -rf $prefix/lualib $prefix/luajit $prefix/bin $prefix/lua $prefix/nginx/sbin $prefix/nginx/html";
|
|
unless ($opts{f}) {
|
|
my $more_cfg_opts = '';
|
|
if ($lua eq 'LuaJIT') {
|
|
$more_cfg_opts .= " --with-luajit-xcflags='-DLUA_USE_TRACE_LOGS'"
|
|
}
|
|
sh "./configure --with-debug $cfg_opts $more_cfg_opts --prefix=$prefix -j$jobs > /dev/null";
|
|
}
|
|
sh "$make -j$jobs > /dev/null";
|
|
sh "sudo $make install > /dev/null";
|
|
sh "sudo cp /tmp/nginx.conf $prefix/nginx/conf/nginx.conf";
|
|
sh "$prefix/nginx/sbin/nginx -V 2>&1 |grep $ver";
|
|
sh "$prefix/nginx/sbin/nginx -V 2>&1 |grep '\\--with-debug'";
|
|
system "sudo killall nginx > /dev/null 2>&1";
|
|
sh "sudo $prefix/nginx/sbin/nginx";
|
|
sh "curl -si localhost/lua|grep $lua";
|
|
sh "curl -si localhost/lua|grep $ver";
|
|
sh "curl -si localhost/cjson|grep 'json.safe: '";
|
|
sh qq{$prefix/bin/resty -e 'ngx.say("Hello World!")'|grep 'Hello World'};
|
|
sh "sudo $prefix/nginx/sbin/nginx -sstop";
|
|
|
|
warn "\n=== DTrace Build ===\n";
|
|
$prefix = "/usr/local/openresty-dtrace";
|
|
sh "sudo rm -rf $prefix/lualib $prefix/luajit $prefix/bin $prefix/lua $prefix/nginx/sbin $prefix/nginx/html";
|
|
unless ($opts{f}) {
|
|
sh "./configure $cfg_opts --with-dtrace-probes --prefix=$prefix -j$jobs > /dev/null";
|
|
}
|
|
sh "$make -j$jobs > /dev/null";
|
|
sh "sudo $make install > /dev/null";
|
|
sh "sudo cp /tmp/nginx.conf $prefix/nginx/conf/nginx.conf";
|
|
sh "$prefix/nginx/sbin/nginx -V 2>&1 |grep $ver";
|
|
sh "$prefix/nginx/sbin/nginx -V 2>&1 |grep '\\--with-dtrace-probes'";
|
|
system "sudo killall nginx > /dev/null 2>&1";
|
|
sh "sudo $prefix/nginx/sbin/nginx";
|
|
sh "curl -si localhost/lua|grep $lua";
|
|
sh "curl -si localhost/lua|grep $ver";
|
|
sh "curl -si localhost/cjson|grep 'json.safe: '";
|
|
if ($^O eq 'linux') {
|
|
sh "stap -L 'process(\"$prefix/nginx/sbin/nginx\").mark(\"*\")'|grep http__lua__coroutine__done";
|
|
|
|
} elsif ($^O eq 'freebsd' || $^O eq 'darwin' || $^O eq 'solaris') {
|
|
sh "sudo dtrace -l|grep http-lua-coroutine-done";
|
|
}
|
|
sh qq{$prefix/bin/resty -e 'ngx.say("Hello World!")'|grep 'Hello World'};
|
|
|
|
sh "sudo $prefix/nginx/sbin/nginx -sstop";
|
|
|
|
sub sh ($) {
|
|
my $cmd = shift;
|
|
system($cmd) == 0 or die "Command \"$cmd\" failed";
|
|
}
|
|
|
|
__DATA__
|
|
|
|
user nobody;
|
|
worker_processes 1;
|
|
error_log logs/error.log;
|
|
pid logs/nginx.pid;
|
|
|
|
events {
|
|
accept_mutex off;
|
|
worker_connections 256;
|
|
}
|
|
|
|
http {
|
|
include mime.types;
|
|
default_type application/octet-stream;
|
|
|
|
init_by_lua '
|
|
if jit then
|
|
require "resty.core"
|
|
end
|
|
';
|
|
|
|
server {
|
|
listen *:80;
|
|
server_name localhost;
|
|
|
|
location = /lua {
|
|
content_by_lua '
|
|
local upstream = require "ngx.upstream"
|
|
if jit then
|
|
ngx.say(jit.version)
|
|
else
|
|
ngx.say(_VERSION)
|
|
end
|
|
';
|
|
}
|
|
|
|
location = /cjson {
|
|
content_by_lua '
|
|
local json = require "cjson.safe"
|
|
ngx.say("cjson.safe: ", json.encode{foo = 123})
|
|
';
|
|
}
|
|
}
|
|
}
|