зеркало из https://github.com/github/ruby.git
* 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:
Родитель
5ddcc93a3f
Коммит
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>
|
||||
|
||||
* 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)
|
||||
RCFILES = $(RUBY_INSTALL_NAME).rc $(RUBYW_INSTALL_NAME).rc $(DLL_BASE_NAME).rc
|
||||
RUBYDEF = $(DLL_BASE_NAME).def
|
||||
STUBPROGRAM = rubystub$(EXEEXT)
|
||||
SCRIPTPROGRAMS = $(addsuffix $(EXEEXT),$(notdir $(wildcard $(srcdir)/bin/*)))
|
||||
|
||||
ruby: $(PROGRAM)
|
||||
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)
|
||||
$(RUBY_EXP) $(LIBRUBY_SO): $(DLL_BASE_NAME).res.@OBJEXT@
|
||||
|
@ -52,6 +59,10 @@ $(WPROGRAM): $(RUBYW_INSTALL_NAME).res.@OBJEXT@
|
|||
@rm -f $@
|
||||
$(PURIFY) $(CC) -mwindows -e _mainCRTStartup $(LDFLAGS) $(XLDFLAGS) \
|
||||
$(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)
|
||||
$(DLLWRAP) \
|
||||
|
|
9
ruby.c
9
ruby.c
|
@ -1506,6 +1506,7 @@ load_file_internal(VALUE arg)
|
|||
NODE *tree = 0;
|
||||
rb_encoding *enc;
|
||||
ID set_encoding;
|
||||
int xflag = 0;
|
||||
|
||||
if (!fname)
|
||||
rb_load_fail(fname);
|
||||
|
@ -1517,8 +1518,10 @@ load_file_internal(VALUE arg)
|
|||
#if defined DOSISH || defined __CYGWIN__
|
||||
{
|
||||
const char *ext = strrchr(fname, '.');
|
||||
if (ext && STRCASECMP(ext, ".exe") == 0)
|
||||
if (ext && STRCASECMP(ext, ".exe") == 0) {
|
||||
mode |= O_BINARY;
|
||||
xflag = 1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if ((fd = open(fname, mode)) < 0) {
|
||||
|
@ -1540,7 +1543,7 @@ load_file_internal(VALUE arg)
|
|||
enc = rb_ascii8bit_encoding();
|
||||
rb_funcall(f, set_encoding, 1, rb_enc_from_encoding(enc));
|
||||
|
||||
if (opt->xflag) {
|
||||
if (xflag || opt->xflag) {
|
||||
search_shebang:
|
||||
forbid_setid("-x");
|
||||
opt->xflag = FALSE;
|
||||
|
@ -1852,7 +1855,7 @@ ruby_set_argv(int argc, char **argv)
|
|||
#endif
|
||||
rb_ary_clear(av);
|
||||
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);
|
||||
rb_ary_push(av, arg);
|
||||
|
|
|
@ -36,7 +36,9 @@ def parse_args(argv = ARGV)
|
|||
$dir_mode = nil
|
||||
$script_mode = nil
|
||||
$strip = false
|
||||
$cmdtype = ('bat' if File::ALT_SEPARATOR == '\\')
|
||||
$cmdtype = (if File::ALT_SEPARATOR == '\\'
|
||||
File.exist?("rubystub.exe") ? 'exe' : 'bat'
|
||||
end)
|
||||
mflags = []
|
||||
opt = OptionParser.new
|
||||
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)
|
||||
if 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
|
||||
if trans = CONFIG["program_transform_name"]
|
||||
exp = []
|
||||
|
@ -456,6 +461,8 @@ install?(:local, :comm, :bin, :'bin-comm') do
|
|||
cmd << ".#{$cmdtype}" if $cmdtype
|
||||
open_for_install(cmd, $script_mode) do
|
||||
case $cmdtype
|
||||
when "exe"
|
||||
stub + shebang + body
|
||||
when "bat"
|
||||
[<<-"EOH".gsub(/^\s+/, ''), shebang, body, "__END__\n:endofruby\n"].join.gsub(/$/, "\r")
|
||||
@echo off
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
#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_BRANCH_NAME "trunk"
|
||||
|
||||
#define RUBY_RELEASE_YEAR 2010
|
||||
#define RUBY_RELEASE_MONTH 11
|
||||
#define RUBY_RELEASE_DAY 9
|
||||
#define RUBY_RELEASE_DAY 10
|
||||
|
||||
#include "ruby/version.h"
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ class Exports
|
|||
def initialize(objs)
|
||||
syms = {}
|
||||
winapis = {}
|
||||
syms["ruby_sysinit_real"] = "ruby_sysinit"
|
||||
each_export(objs) do |internal, export|
|
||||
syms[internal] = export
|
||||
winapis[$1] = internal if /^_?(rb_w32_\w+)(?:@\d+)?$/ =~ internal
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
Загрузка…
Ссылка в новой задаче