[前][次][番号順一覧][スレッド一覧]

ruby-changes:26739

From: nobu <ko1@a...>
Date: Sat, 12 Jan 2013 16:13:01 +0900 (JST)
Subject: [ruby-changes:26739] nobu:r38791 (trunk): setup.mak: -runtime-

nobu	2013-01-12 16:12:49 +0900 (Sat, 12 Jan 2013)

  New Revision: 38791

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=38791

  Log:
    setup.mak: -runtime-
    
    * win32/setup.mak (-runtime-): see msvcrt from link header on mswin
      instead of running testing executable file, for cross compiling.

  Added files:
    trunk/win32/rtname.cmd
  Modified files:
    trunk/ChangeLog
    trunk/win32/setup.mak

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 38790)
+++ ChangeLog	(revision 38791)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat Jan 12 16:12:46 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* win32/setup.mak (-runtime-): see msvcrt from link header on mswin
+	  instead of running testing executable file, for cross compiling.
+
 Sat Jan 12 08:58:47 2013  Aaron Patterson <aaron@t...>
 
 	* ext/psych/lib/psych/visitors/to_ruby.rb: merge key values that
Index: win32/rtname.cmd
===================================================================
--- win32/rtname.cmd	(revision 0)
+++ win32/rtname.cmd	(revision 38791)
@@ -0,0 +1,18 @@ https://github.com/ruby/ruby/blob/trunk/win32/rtname.cmd#L1
+@echo off
+set rt=
+set rtver=
+set osver=
+for /f "usebackq" %%I in (`dumpbin -dependents %1 ^| findstr -r -i "\<msvcr.*\.dll$"`) do set rt=%%~nI
+if "%rt%" == "" (
+    (echo %0: %1 is not linked to msvcrt) 1>&2
+    exit 1
+)
+for %%i in (a b c d e f g h i j k l m n o p q r s t u v w x y z) do @call set rt=%%rt:%%i=%%i%%
+if "%rt%" == "msvcrt" (
+    call set rtver=60
+) else (
+    call set rtver=%%rt:msvcr=%%
+    call set rt=msvcr%%rtver%%
+    call set osver=_%%rtver%%
+)
+for %%I in ("PLATFORM = $(TARGET_OS)%osver%" "RT = %rt%" "RT_VER = %rtver%") do @echo %%~I

Property changes on: win32/rtname.cmd
___________________________________________________________________
Added: svn:eol-style
   + LF

Index: win32/setup.mak
===================================================================
--- win32/setup.mak	(revision 38790)
+++ win32/setup.mak	(revision 38791)
@@ -77,10 +77,10 @@ USE_RUBYGEMS = $(USE_RUBYGEMS) https://github.com/ruby/ruby/blob/trunk/win32/setup.mak#L77
 -system-vars64-: -osname64- -runtime-
 
 -osname32-: nul
-	@echo TARGET_OS = mswin32 >>$(MAKEFILE)
+	@echo TARGET_OS = mswin32>>$(MAKEFILE)
 
 -osname64-: nul
-	@echo TARGET_OS = mswin64 >>$(MAKEFILE)
+	@echo TARGET_OS = mswin64>>$(MAKEFILE)
 
 -osname-: nul
 	@echo !ifndef TARGET_OS>>$(MAKEFILE)
@@ -93,69 +93,12 @@ USE_RUBYGEMS = $(USE_RUBYGEMS) https://github.com/ruby/ruby/blob/trunk/win32/setup.mak#L93
 	@$(WIN32DIR:/=\)\rm.bat conftest.*
 
 -runtime-: nul
-	@$(CC) -MD <<rtname.c user32.lib -link > nul
-#include <windows.h>
-#include <memory.h>
-#include <string.h>
-#include <stddef.h>
+	@$(CC) -MD <<conftest.c user32.lib -link > nul
 #include <stdio.h>
-#include <stdlib.h>
-#ifndef MAXPATHLEN
-# define MAXPATHLEN 1024
-#endif
-
-int
-runtime_name()
-{
-    char libpath[MAXPATHLEN+1];
-    char *p, *base = NULL, *ver = NULL;
-    HMODULE msvcrt = NULL;
-    MEMORY_BASIC_INFORMATION m;
-
-    memset(&m, 0, sizeof(m));
-    if (VirtualQuery(stdin, &m, sizeof(m)) && m.State == MEM_COMMIT)
-	msvcrt = (HMODULE)m.AllocationBase;
-    GetModuleFileName(msvcrt, libpath, sizeof libpath);
-
-    libpath[sizeof(libpath) - 1] = '\0';
-    for (p = libpath; *p; p = CharNext(p)) {
-	if (*p == '\\') {
-	    base = ++p;
-	}
-    }
-    if (!base) return 0;
-    if (p = strchr(base, '.')) *p = '\0';
-    for (p = base; *p; p = CharNext(p)) {
-	if (!isascii(*p)) continue;
-	if (isupper(*p)) {
-	    *p = tolower(*p);
-	}
-	if (!isdigit(*p)) {
-	    ver = NULL;
-	} else if (!ver) {
-	    ver = p;
-	}
-    }
-    if (ver) {
-	printf("PLATFORM = $$(TARGET_OS)_%s\n", ver);
-    }
-    else {
-	printf("PLATFORM = $$(TARGET_OS)\n");
-	ver = "60";
-    }
-    printf("RT = %s\n", base);
-    printf("RT_VER = %s\n", ver);
-    return 1;
-}
-
-int main(int argc, char **argv)
-{
-    if (!runtime_name()) return EXIT_FAILURE;
-    return EXIT_SUCCESS;
-}
+int main(void) {FILE *volatile f = stdin; return 0;}
 <<
-	@.\rtname >>$(MAKEFILE)
-	@for %I in (rtname.*) do @del %I
+	@$(WIN32DIR:/=\)\rtname conftest.exe >>$(MAKEFILE)
+	@$(WIN32DIR:/=\)\rm.bat conftest.*
 
 -version-: nul
 	@$(APPEND)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]