* cygwin/GNUmakefile.in (scriptbin): make executable file from
scripts with stub. * ruby.c (load_file_internal): assume xflag for exe file as well as no-shebang file. * tool/rbinstall.rb: install script programs. * win32/mkexports.rb (Exports#initialize): alias ruby_sysinit for stub. * win32/stub.c: stub for scripts. [EXPERIMENTAL] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29738 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
5ddcc93a3f
commit
536e266e58
15
ChangeLog
15
ChangeLog
@ -1,3 +1,18 @@
|
|||||||
|
Wed Nov 10 07:20:10 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* cygwin/GNUmakefile.in (scriptbin): make executable file from
|
||||||
|
scripts with stub.
|
||||||
|
|
||||||
|
* ruby.c (load_file_internal): assume xflag for exe file as well
|
||||||
|
as no-shebang file.
|
||||||
|
|
||||||
|
* tool/rbinstall.rb: install script programs.
|
||||||
|
|
||||||
|
* win32/mkexports.rb (Exports#initialize): alias ruby_sysinit for
|
||||||
|
stub.
|
||||||
|
|
||||||
|
* win32/stub.c: stub for scripts. [EXPERIMENTAL]
|
||||||
|
|
||||||
Tue Nov 9 21:57:45 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Tue Nov 9 21:57:45 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* dln.c (init_funcname): allocate and build initialization
|
* dln.c (init_funcname): allocate and build initialization
|
||||||
|
@ -31,9 +31,16 @@ SOLIBS := $(DLL_BASE_NAME).res.@OBJEXT@ $(SOLIBS)
|
|||||||
EXTOBJS += $(if $(filter-out $(RUBYW_INSTALL_NAME),$(@:$(EXEEXT)=)),$(RUBY_INSTALL_NAME),$(@:$(EXEEXT)=)).res.$(OBJEXT)
|
EXTOBJS += $(if $(filter-out $(RUBYW_INSTALL_NAME),$(@:$(EXEEXT)=)),$(RUBY_INSTALL_NAME),$(@:$(EXEEXT)=)).res.$(OBJEXT)
|
||||||
RCFILES = $(RUBY_INSTALL_NAME).rc $(RUBYW_INSTALL_NAME).rc $(DLL_BASE_NAME).rc
|
RCFILES = $(RUBY_INSTALL_NAME).rc $(RUBYW_INSTALL_NAME).rc $(DLL_BASE_NAME).rc
|
||||||
RUBYDEF = $(DLL_BASE_NAME).def
|
RUBYDEF = $(DLL_BASE_NAME).def
|
||||||
|
STUBPROGRAM = rubystub$(EXEEXT)
|
||||||
|
SCRIPTPROGRAMS = $(addsuffix $(EXEEXT),$(notdir $(wildcard $(srcdir)/bin/*)))
|
||||||
|
|
||||||
ruby: $(PROGRAM)
|
ruby: $(PROGRAM)
|
||||||
rubyw: $(WPROGRAM)
|
rubyw: $(WPROGRAM)
|
||||||
|
stub: $(STUBPROGRAM)
|
||||||
|
scriptbin: $(SCRIPTPROGRAMS)
|
||||||
|
|
||||||
|
%$(EXEEXT): bin/% $(STUBPROGRAM)
|
||||||
|
{ cat $(STUBPROGRAM); echo; sed -e '1{' -e '/^#!.*ruby/!i\' -e '#!/bin/ruby' -e '}' $<; } > $@
|
||||||
|
|
||||||
$(LIBRUBY): $(RUBY_EXP) $(LIBRUBY_SO)
|
$(LIBRUBY): $(RUBY_EXP) $(LIBRUBY_SO)
|
||||||
$(RUBY_EXP) $(LIBRUBY_SO): $(DLL_BASE_NAME).res.@OBJEXT@
|
$(RUBY_EXP) $(LIBRUBY_SO): $(DLL_BASE_NAME).res.@OBJEXT@
|
||||||
@ -52,6 +59,10 @@ $(WPROGRAM): $(RUBYW_INSTALL_NAME).res.@OBJEXT@
|
|||||||
@rm -f $@
|
@rm -f $@
|
||||||
$(PURIFY) $(CC) -mwindows -e _mainCRTStartup $(LDFLAGS) $(XLDFLAGS) \
|
$(PURIFY) $(CC) -mwindows -e _mainCRTStartup $(LDFLAGS) $(XLDFLAGS) \
|
||||||
$(MAINOBJ) $(EXTOBJS) $(LIBRUBYARG) $(LIBS) -o $@
|
$(MAINOBJ) $(EXTOBJS) $(LIBRUBYARG) $(LIBS) -o $@
|
||||||
|
$(STUBPROGRAM): $(RUBY_INSTALL_NAME).res.@OBJEXT@ stub.@OBJEXT@
|
||||||
|
@rm -f $@
|
||||||
|
$(PURIFY) $(CC) $(LDFLAGS) $(XLDFLAGS) \
|
||||||
|
stub.@OBJEXT@ $(EXTOBJS) $(LIBRUBYARG) $(LIBS) -o $@
|
||||||
|
|
||||||
$(RUBY_EXP): $(LIBRUBY_A)
|
$(RUBY_EXP): $(LIBRUBY_A)
|
||||||
$(DLLWRAP) \
|
$(DLLWRAP) \
|
||||||
|
9
ruby.c
9
ruby.c
@ -1506,6 +1506,7 @@ load_file_internal(VALUE arg)
|
|||||||
NODE *tree = 0;
|
NODE *tree = 0;
|
||||||
rb_encoding *enc;
|
rb_encoding *enc;
|
||||||
ID set_encoding;
|
ID set_encoding;
|
||||||
|
int xflag = 0;
|
||||||
|
|
||||||
if (!fname)
|
if (!fname)
|
||||||
rb_load_fail(fname);
|
rb_load_fail(fname);
|
||||||
@ -1517,8 +1518,10 @@ load_file_internal(VALUE arg)
|
|||||||
#if defined DOSISH || defined __CYGWIN__
|
#if defined DOSISH || defined __CYGWIN__
|
||||||
{
|
{
|
||||||
const char *ext = strrchr(fname, '.');
|
const char *ext = strrchr(fname, '.');
|
||||||
if (ext && STRCASECMP(ext, ".exe") == 0)
|
if (ext && STRCASECMP(ext, ".exe") == 0) {
|
||||||
mode |= O_BINARY;
|
mode |= O_BINARY;
|
||||||
|
xflag = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if ((fd = open(fname, mode)) < 0) {
|
if ((fd = open(fname, mode)) < 0) {
|
||||||
@ -1540,7 +1543,7 @@ load_file_internal(VALUE arg)
|
|||||||
enc = rb_ascii8bit_encoding();
|
enc = rb_ascii8bit_encoding();
|
||||||
rb_funcall(f, set_encoding, 1, rb_enc_from_encoding(enc));
|
rb_funcall(f, set_encoding, 1, rb_enc_from_encoding(enc));
|
||||||
|
|
||||||
if (opt->xflag) {
|
if (xflag || opt->xflag) {
|
||||||
search_shebang:
|
search_shebang:
|
||||||
forbid_setid("-x");
|
forbid_setid("-x");
|
||||||
opt->xflag = FALSE;
|
opt->xflag = FALSE;
|
||||||
@ -1852,7 +1855,7 @@ ruby_set_argv(int argc, char **argv)
|
|||||||
#endif
|
#endif
|
||||||
rb_ary_clear(av);
|
rb_ary_clear(av);
|
||||||
for (i = 0; i < argc; i++) {
|
for (i = 0; i < argc; i++) {
|
||||||
VALUE arg = rb_external_str_new(argv[i], strlen(argv[i]));
|
VALUE arg = rb_external_str_new_cstr(argv[i]);
|
||||||
|
|
||||||
OBJ_FREEZE(arg);
|
OBJ_FREEZE(arg);
|
||||||
rb_ary_push(av, arg);
|
rb_ary_push(av, arg);
|
||||||
|
@ -36,7 +36,9 @@ def parse_args(argv = ARGV)
|
|||||||
$dir_mode = nil
|
$dir_mode = nil
|
||||||
$script_mode = nil
|
$script_mode = nil
|
||||||
$strip = false
|
$strip = false
|
||||||
$cmdtype = ('bat' if File::ALT_SEPARATOR == '\\')
|
$cmdtype = (if File::ALT_SEPARATOR == '\\'
|
||||||
|
File.exist?("rubystub.exe") ? 'exe' : 'bat'
|
||||||
|
end)
|
||||||
mflags = []
|
mflags = []
|
||||||
opt = OptionParser.new
|
opt = OptionParser.new
|
||||||
opt.on('-n', '--dry-run') {$dryrun = true}
|
opt.on('-n', '--dry-run') {$dryrun = true}
|
||||||
@ -405,6 +407,9 @@ install?(:local, :comm, :bin, :'bin-comm') do
|
|||||||
ruby_shebang = File.join(bindir, ruby_install_name)
|
ruby_shebang = File.join(bindir, ruby_install_name)
|
||||||
if File::ALT_SEPARATOR
|
if File::ALT_SEPARATOR
|
||||||
ruby_bin = ruby_shebang.tr(File::SEPARATOR, File::ALT_SEPARATOR)
|
ruby_bin = ruby_shebang.tr(File::SEPARATOR, File::ALT_SEPARATOR)
|
||||||
|
if $cmdtype == 'exe'
|
||||||
|
stub = File.open("rubystub.exe", "rb") {|f| f.read} << "\n" rescue nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
if trans = CONFIG["program_transform_name"]
|
if trans = CONFIG["program_transform_name"]
|
||||||
exp = []
|
exp = []
|
||||||
@ -456,6 +461,8 @@ install?(:local, :comm, :bin, :'bin-comm') do
|
|||||||
cmd << ".#{$cmdtype}" if $cmdtype
|
cmd << ".#{$cmdtype}" if $cmdtype
|
||||||
open_for_install(cmd, $script_mode) do
|
open_for_install(cmd, $script_mode) do
|
||||||
case $cmdtype
|
case $cmdtype
|
||||||
|
when "exe"
|
||||||
|
stub + shebang + body
|
||||||
when "bat"
|
when "bat"
|
||||||
[<<-"EOH".gsub(/^\s+/, ''), shebang, body, "__END__\n:endofruby\n"].join.gsub(/$/, "\r")
|
[<<-"EOH".gsub(/^\s+/, ''), shebang, body, "__END__\n:endofruby\n"].join.gsub(/$/, "\r")
|
||||||
@echo off
|
@echo off
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
#define RUBY_VERSION "1.9.3"
|
#define RUBY_VERSION "1.9.3"
|
||||||
#define RUBY_RELEASE_DATE "2010-11-09"
|
#define RUBY_RELEASE_DATE "2010-11-10"
|
||||||
#define RUBY_PATCHLEVEL -1
|
#define RUBY_PATCHLEVEL -1
|
||||||
#define RUBY_BRANCH_NAME "trunk"
|
#define RUBY_BRANCH_NAME "trunk"
|
||||||
|
|
||||||
#define RUBY_RELEASE_YEAR 2010
|
#define RUBY_RELEASE_YEAR 2010
|
||||||
#define RUBY_RELEASE_MONTH 11
|
#define RUBY_RELEASE_MONTH 11
|
||||||
#define RUBY_RELEASE_DAY 9
|
#define RUBY_RELEASE_DAY 10
|
||||||
|
|
||||||
#include "ruby/version.h"
|
#include "ruby/version.h"
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@ class Exports
|
|||||||
def initialize(objs)
|
def initialize(objs)
|
||||||
syms = {}
|
syms = {}
|
||||||
winapis = {}
|
winapis = {}
|
||||||
|
syms["ruby_sysinit_real"] = "ruby_sysinit"
|
||||||
each_export(objs) do |internal, export|
|
each_export(objs) do |internal, export|
|
||||||
syms[internal] = export
|
syms[internal] = export
|
||||||
winapis[$1] = internal if /^_?(rb_w32_\w+)(?:@\d+)?$/ =~ internal
|
winapis[$1] = internal if /^_?(rb_w32_\w+)(?:@\d+)?$/ =~ internal
|
||||||
|
42
win32/stub.c
Normal file
42
win32/stub.c
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
#include <ruby.h>
|
||||||
|
static void stub_sysinit(int *argc, char ***argv);
|
||||||
|
#define ruby_sysinit stub_sysinit
|
||||||
|
#include <main.c>
|
||||||
|
#undef ruby_sysinit
|
||||||
|
|
||||||
|
void
|
||||||
|
stub_sysinit(int *argc, char ***argv)
|
||||||
|
{
|
||||||
|
char exename[4096];
|
||||||
|
size_t lenexe, len0, lenall;
|
||||||
|
int i, ac;
|
||||||
|
char **av, *p;
|
||||||
|
|
||||||
|
lenexe = (size_t)GetModuleFileName(NULL, exename, sizeof exename);
|
||||||
|
ruby_sysinit(argc, argv);
|
||||||
|
ac = *argc;
|
||||||
|
av = *argv;
|
||||||
|
len0 = strlen(av[0]) + 1;
|
||||||
|
lenall = 0;
|
||||||
|
for (i = 1; i < ac; ++i) {
|
||||||
|
lenall += strlen(av[i]) + 1;
|
||||||
|
}
|
||||||
|
*argv = av = realloc(av, lenall + (lenexe + 1) * 2 + sizeof(char *) * (i + 2));
|
||||||
|
*argc = ++ac;
|
||||||
|
p = (char *)(av + i + 2);
|
||||||
|
memmove(p + (lenexe + 1) * 2, (char *)(av + ac) + len0, lenall);
|
||||||
|
memcpy(p, exename, lenexe);
|
||||||
|
p[lenexe] = '\0';
|
||||||
|
*av++ = p;
|
||||||
|
p += lenexe + 1;
|
||||||
|
memcpy(p, exename, lenexe);
|
||||||
|
p[lenexe] = '\0';
|
||||||
|
*av++ = p;
|
||||||
|
p += lenexe + 1;
|
||||||
|
while (--i) {
|
||||||
|
*av++ = p;
|
||||||
|
p += strlen(p) + 1;
|
||||||
|
}
|
||||||
|
*av = NULL;
|
||||||
|
}
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user