public
Rubygem
Description: Johnson wraps JavaScript in a loving Ruby embrace.
Homepage: http://github.com/jbarnette/johnson/wikis
Clone URL: git://github.com/jbarnette/johnson.git
Search Repo:
First cut of a cross-compilation process so we can build for Windows.
matthewd (author)
Wed Apr 23 08:10:04 -0700 2008
commit  1524e7377caaf59b005ff13c73b61448aaff475d
tree    624419380689c4376a9de5672002705be0a23718
parent  02a2b511c648be94f37cb5f81abcbd39c74a468e
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
0
@@ -1 +1,125 @@
0
+# -*- Mode: makefile -*-
0
+#
0
+#
0
+# Based on patch submitted to mozilla.dev.tech.js-engine by 'Andy':
0
+# http://groups.google.com/group/mozilla.dev.tech.js-engine/browse_thread/thread/16972946bf7df82e
0
+#
0
+#
0
+# ***** BEGIN LICENSE BLOCK *****
0
+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
0
+#
0
+# The contents of this file are subject to the Mozilla Public License Version
0
+# 1.1 (the "License"); you may not use this file except in compliance with
0
+# the License. You may obtain a copy of the License at
0
+# http://www.mozilla.org/MPL/
0
+#
0
+# Software distributed under the License is distributed on an "AS IS" basis,
0
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
0
+# for the specific language governing rights and limitations under the
0
+# License.
0
+#
0
+# The Original Code is Mozilla Communicator client code, released
0
+# March 31, 1998.
0
+#
0
+# The Initial Developer of the Original Code is
0
+# Netscape Communications Corporation.
0
+# Portions created by the Initial Developer are Copyright (C) 1998
0
+# the Initial Developer. All Rights Reserved.
0
+#
0
+# Contributor(s):
0
+#
0
+# Alternatively, the contents of this file may be used under the terms of
0
+# either the GNU General Public License Version 2 or later (the "GPL"), or
0
+# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
0
+# in which case the provisions of the GPL or the LGPL are applicable instead
0
+# of those above. If you wish to allow use of your version of this file only
0
+# under the terms of either the GPL or the LGPL, and not to allow others to
0
+# use your version of this file under the terms of the MPL, indicate your
0
+# decision by deleting the provisions above and replace them with the notice
0
+# and other provisions required by the GPL or the LGPL. If you do not delete
0
+# the provisions above, a recipient may use your version of this file under
0
+# the terms of any one of the MPL, the GPL or the LGPL.
0
+#
0
+# ***** END LICENSE BLOCK *****
0
+
0
+#
0
+# Config for all versions of Mingw (copy and modified from Linux)
0
+#
0
+
0
+AR = i586-mingw32msvc-ar
0
+CC = i586-mingw32msvc-gcc
0
+LD = i586-mingw32msvc-ld
0
+CCC = i586-mingw32msvc-g++
0
+
0
+CFLAGS += -Wall -Wno-format
0
+#OS_CFLAGS = -DXP_UNIX -DSVR4 -DSYSV -D_BSD_SOURCE -DPOSIX_SOURCE -DHAVE_LOCALTIME_R -DEXPORT_JS_API
0
+OS_CFLAGS = -D_X86_=1 -DXP_WIN -DXP_WIN32 -DWIN32 -D_WINDOWS -D_WIN32 $(WIN_CFLAGS) -DEXPORT_JS_API
0
+JSDLL_CFLAGS = -DEXPORT_JS_API # not work, dunno why?
0
+SO_SUFFIX = dll
0
+# libgcc.a:__divdi3 kernel32:DebugBreak,GetSystemTimeAsFileTime
0
+# winmm:timeBeginPeriod,timeEndPeriod
0
+WINLIBS = -lmsvcrt -lm -lkernel32 -lwinmm /usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/libgcc.a
0
+#LDFLAGS += $(WINLIBS) # dont work. rewrite by Makefile.ref
0
+OTHER_LIBS += $(WINLIBS)
0
+
0
+RANLIB = echo
0
+MKSHLIB = $(LD) -shared $(XMKSHLIBOPTS)
0
+
0
+# These don't work :(
0
+LIBRARY = $(OBJDIR)/js32.lib
0
+SHARED_LIBRARY = $(OBJDIR)/js32.dll
0
+PROGRAM = $(OBJDIR)/js.exe
0
+
0
+#.c.o:
0
+# $(CC) -c -MD $*.d $(CFLAGS) $<
0
+
0
+CPU_ARCH = $(shell uname -m)
0
+# don't filter in x86-64 architecture
0
+ifneq (x86_64,$(CPU_ARCH))
0
+ifeq (86,$(findstring 86,$(CPU_ARCH)))
0
+CPU_ARCH = x86
0
+OS_CFLAGS+= -DX86_LINUX
0
+
0
+ifeq (gcc, $(CC))
0
+# if using gcc on x86, check version for opt bug
0
+# (http://bugzilla.mozilla.org/show_bug.cgi?id=24892)
0
+GCC_VERSION := $(shell gcc -v 2>&1 | grep version | awk '{ print $$3 }')
0
+GCC_LIST:=$(sort 2.91.66 $(GCC_VERSION) )
0
+
0
+ifeq (2.91.66, $(firstword $(GCC_LIST)))
0
+CFLAGS+= -DGCC_OPT_BUG
0
+endif
0
+endif
0
+endif
0
+endif
0
+
0
+GFX_ARCH = x
0
+
0
+OS_LIBS = -lm -lc
0
+
0
+ASFLAGS += -x assembler-with-cpp
0
+
0
+
0
+ifeq ($(CPU_ARCH),alpha)
0
+
0
+# Ask the C compiler on alpha linux to let us work with denormalized
0
+# double values, which are required by the ECMA spec.
0
+
0
+OS_CFLAGS += -mieee
0
+endif
0
+
0
+# Use the editline library to provide line-editing support.
0
+#JS_EDITLINE = 1 // not support by Mingw
0
+
0
+ifeq ($(CPU_ARCH),x86_64)
0
+# Use VA_COPY() standard macro on x86-64
0
+# FIXME: better use it everywhere
0
+OS_CFLAGS += -DHAVE_VA_COPY
0
+endif
0
+
0
+ifeq ($(CPU_ARCH),x86_64)
0
+# We need PIC code for shared libraries
0
+# FIXME: better patch rules.mk & fdlibm/Makefile*
0
+OS_CFLAGS += -DPIC -fPIC
0
+endif
...
33
34
35
 
 
36
37
38
39
40
 
41
 
 
 
 
 
 
 
 
 
 
 
 
 
42
43
44
45
46
47
48
 
 
49
50
51
52
53
 
 
 
 
 
 
 
54
55
56
 
 
 
 
 
57
58
59
...
81
82
83
84
 
85
86
87
...
33
34
35
36
37
38
39
40
41
 
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
 
 
 
61
62
63
64
 
65
66
67
68
69
70
71
72
73
74
 
 
75
76
77
78
79
80
81
82
...
104
105
106
 
107
108
109
110
0
@@ -33,27 +33,50 @@
0
 Rake::Task[:test].prerequisites << :extensions
0
 Rake::Task[:check_manifest].prerequisites << GENERATED_NODE
0
 
0
+task :build => :extensions
0
+
0
 # gem depends on the native extension actually building
0
 Rake::Task[:gem].prerequisites << :extensions
0
 
0
 desc "Our johnson requires extensions."
0
-task :extensions => [:submodules, "lib/johnson/spidermonkey.#{kind}"]
0
+task :extensions => ["lib/johnson/spidermonkey.#{kind}"]
0
 
0
+task :spidermonkey => :submodules do
0
+ if ENV['CROSS']
0
+ Dir.chdir("vendor/spidermonkey") { sh "make -f Makefile.ref OS_CONFIG=#{ENV['CROSS']}" }
0
+ else
0
+ Dir.chdir("vendor/spidermonkey") { sh "make -f Makefile.ref" }
0
+ end
0
+end
0
+task :spidermonkey => "vendor/spidermonkey/config/#{ENV['CROSS']}.mk" if ENV['CROSS']
0
+
0
+file "vendor/spidermonkey/config/MINGW32.mk" => "MINGW32.mk" do |t|
0
+ File.copy(t.prerequisites.first, t.name)
0
+end
0
+
0
 task :submodules do
0
   sh "git submodule init && git submodule update"
0
 end
0
 
0
-# for testing, we toss the SpiderMonkey extension in lib/johnson
0
-file "lib/johnson/spidermonkey.#{kind}" =>
0
- FileList["ext/spidermonkey/Makefile", "ext/spidermonkey/*.{c,h}"] do
0
+file "ext/spidermonkey/spidermonkey.#{kind}" =>
0
+ ["ext/spidermonkey/Makefile"] + FileList["ext/spidermonkey/*.{c,h}"].to_a do
0
   
0
   Dir.chdir("ext/spidermonkey") { sh "make" }
0
- sh "cp ext/spidermonkey/spidermonkey.#{kind} lib/johnson/spidermonkey.#{kind}"
0
 end
0
 
0
+# for testing, we toss the SpiderMonkey extension in lib/johnson
0
+file "lib/johnson/spidermonkey.#{kind}" =>
0
+ "ext/spidermonkey/spidermonkey.#{kind}" do |t|
0
+
0
+ File.copy(t.prerequisites.first, t.name)
0
+end
0
+
0
 file "ext/spidermonkey/Makefile" =>
0
- [GENERATED_NODE, "ext/spidermonkey/extconf.rb"] do
0
- Dir.chdir("ext/spidermonkey") { ruby "extconf.rb" }
0
+ [:spidermonkey, GENERATED_NODE, "ext/spidermonkey/extconf.rb"] do
0
+
0
+ dirs = (ENV['CROSS'] ? [ENV["CROSSLIB"]] : []) + $:
0
+ command = ["ruby"] + dirs.map{|dir| "-I#{File.expand_path dir}"} + ["extconf.rb"]
0
+ Dir.chdir("ext/spidermonkey") { sh *command }
0
 end
0
 
0
 def jsops
0
@@ -81,7 +104,7 @@
0
   toks.uniq
0
 end
0
 
0
-file GENERATED_NODE => "ext/spidermonkey/immutable_node.c.erb" do |t|
0
+file GENERATED_NODE => ["ext/spidermonkey/immutable_node.c.erb", "vendor/spidermonkey/jsopcode.tbl", "vendor/spidermonkey/jsscan.h"] do |t|
0
   template = ERB.new(File.open(t.prerequisites.first, 'rb') { |x| x.read })
0
   File.open(GENERATED_NODE, 'wb') { |f|
0
     f.write template.result(binding)
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
0
@@ -1 +1,31 @@
0
+
0
+CROSS-COMPILING FOR WINDOWS
0
+
0
+Based on http://eigenclass.org/hiki.rb?cross+compiling+rcovrt
0
+
0
+
0
+*) Download & extract a ruby tar.gz
0
+
0
+*) Double the backslashes in the ALT_SEPARATOR definition in Makefile.in
0
+
0
+*) Build & install it:
0
+
0
+ env ac_cv_func_getpgrp_void=no \
0
+ ac_cv_func_setpgrp_void=yes \
0
+ rb_cv_negative_time_t=no \
0
+ ac_cv_func_memcmp_working=yes \
0
+ rb_cv_binary_elf=no \
0
+ ./configure \
0
+ --host=i586-mingw32msvc \
0
+ --target=i386-mingw32 \
0
+ --build=i686-linux \
0
+ --prefix=~/ruby-mingw32
0
+
0
+ make ruby
0
+
0
+ make install
0
+
0
+*) Build the extension (rake will build spidermonkey for you)
0
+
0
+ rake build CROSS=MINGW32 CROSSLIB=~/ruby-mingw32/lib/ruby/1.8/i386-mingw32
...
3
4
5
6
 
 
 
 
 
 
7
8
9
10
11
12
13
 
14
15
16
...
3
4
5
 
6
7
8
9
10
11
12
13
14
 
 
 
 
15
16
17
18
0
@@ -3,14 +3,16 @@
0
 
0
 require "mkmf"
0
 
0
-$CFLAGS << " -g -DXP_UNIX"
0
+if Config::CONFIG['target_os'] == 'mingw32'
0
+ $libs = append_library($libs, "winmm")
0
+ $CFLAGS << " -DXP_WIN -DXP_WIN32"
0
+else
0
+ $CFLAGS << " -g -DXP_UNIX"
0
+end
0
 
0
 spidermonkey_base_dir = "../../vendor/spidermonkey"
0
 
0
-# we can't even run the extconf unless Spidermonkey has built
0
-Dir.chdir(spidermonkey_base_dir) { system "make -f Makefile.ref" }
0
-
0
-spidermonkey_obj_dir = Dir[spidermonkey_base_dir + "/*.OBJ"].first
0
+spidermonkey_obj_dir = Dir[spidermonkey_base_dir + "/#{ENV['CROSS'] || ''}*.OBJ"].first
0
 
0
 dir_config("johnson/spidermonkey")
0
 

Comments

    No one has commented yet.