Permalink
Browse files

Cleaned up building / packaging.

* Moved the SpiderMonkey build into extconf, no more Rakefile builds
  on gem install.

* Changed to make more effective use of rake-compiler.

* Simplified test load path.
  • Loading branch information...
1 parent 8bdf716 commit a32f6b0aca266aaa5ad04225e225d4a244361717 @jbarnette committed Jul 29, 2009
Showing with 65 additions and 246 deletions.
  1. +0 −4 Manifest.txt
  2. +59 −16 Rakefile
  3. +0 −124 docs/MINGW32.mk
  4. +0 −38 docs/cross-compile.txt
  5. +5 −2 ext/spidermonkey/extconf.rb
  6. +1 −1 lib/johnson/version.rb
  7. +0 −37 lib/tasks/parsing.rake
  8. +0 −20 lib/tasks/vendor.rake
  9. +0 −4 test/helper.rb
View
@@ -4,8 +4,6 @@ Manifest.txt
README.rdoc
Rakefile
bin/johnson
-docs/MINGW32.mk
-docs/cross-compile.txt
ext/spidermonkey/context.c
ext/spidermonkey/context.h
ext/spidermonkey/conversions.c
@@ -64,8 +62,6 @@ lib/johnson/visitors/enumerating_visitor.rb
lib/johnson/visitors/sexp_visitor.rb
lib/johnson/visitors/visitor.rb
lib/rails/init.rb
-lib/tasks/parsing.rake
-lib/tasks/vendor.rake
test/helper.rb
test/johnson/browser_test.rb
test/johnson/conversions/array_test.rb
View
@@ -1,10 +1,14 @@
require "rubygems"
+
+gem "hoe", ">= 2.3"
require "hoe"
+
+gem "rake-compiler", ">= 0.6.0"
require "rake/extensiontask"
-Hoe.plugin :debugging, :git
+Hoe.plugin :debugging, :doofus, :git
-HOE = Hoe.spec "johnson" do
+Hoe.spec "johnson" do
developer "John Barnette", "jbarnette@rubyforge.org"
developer "Aaron Patterson", "aaron.patterson@gmail.com"
developer "Yehuda Katz", "wycats@gmail.com"
@@ -15,26 +19,65 @@ HOE = Hoe.spec "johnson" do
self.readme_file = "README.rdoc"
self.test_globs = %w(test/**/*_test.rb)
- clean_globs << "lib/johnson/spidermonkey.bundle"
- clean_globs << "tmp"
- clean_globs << "vendor/spidermonkey/**/*.OBJ"
- clean_globs << "ext/**/*.{o,so,bundle,a,log}"
+ self.spec_extras = { :extensions => %w(ext/spidermonkey/extconf.rb) }
+
+ extra_dev_deps << ["rake-compiler", ">= 0.6.0"]
- # FIX: this crap needs to die
- extra_deps << "rake"
- extra_dev_deps << "rake-compiler"
- self.spec_extras = { :extensions => %w(Rakefile) }
+ clean_globs << "ext/**/Makefile"
+ clean_globs << "ext/**/*.{o,so,bundle,a,log}"
+ clean_globs << "ext/spidermonkey/immutable_node.c"
+ clean_globs << "lib/johnson/spidermonkey.bundle"
+ clean_globs << "tmp"
+ clean_globs << "vendor/spidermonkey/**/*.OBJ"
+
+ Rake::ExtensionTask.new "spidermonkey", spec do |ext|
+ ext.lib_dir = "lib/johnson"
+ end
end
-Rake::ExtensionTask.new "spidermonkey", HOE.spec do |ext|
- ext.lib_dir = "lib/johnson"
+task :clean do
+ Dir.chdir "vendor/spidermonkey" do
+ sh "make clean -f Makefile.ref" unless Dir["**/libjs.a"].empty?
+ end
end
task :test => :compile
-Dir["lib/tasks/*.rake"].each { |f| load f }
+require "erb"
+
+GENERATED_NODE = "ext/spidermonkey/immutable_node.c"
+
+task :package => GENERATED_NODE
+task :check_manifest => GENERATED_NODE
-# HACK: If Rake is running as part of the gem install, clear out the
-# default task and make the extensions compile instead.
+def jsops
+ ops = []
+ File.open("vendor/spidermonkey/jsopcode.tbl", "rb") { |f|
+ f.each_line do |line|
+ if line =~ /^OPDEF\((\w+),/
+ ops << $1
+ end
+ end
+ }
+ ops
+end
+
+def tokens
+ toks = []
+ File.open("vendor/spidermonkey/jsscan.h", "rb") { |f|
+ f.each_line do |line|
+ line.scan(/TOK_\w+/).each do |token|
+ next if token == "TOK_ERROR"
+ toks << token
+ end
+ end
+ }
+ toks.uniq
+end
+
+file GENERATED_NODE => "ext/spidermonkey/immutable_node.c.erb" do |t|
+ template = ERB.new(File.open(t.prerequisites.first, "rb") { |x| x.read })
+ File.open(GENERATED_NODE, "wb") { |f| f.write template.result(binding) }
+end
-Rake::Task[:default].prerequisites.replace %w(compile) if ENV["RUBYARCHDIR"]
+file "ext/spidermonkey/extconf.rb" => GENERATED_NODE
View
@@ -1,124 +0,0 @@
-# -*- Mode: makefile -*-
-#
-#
-# Based on patch submitted to mozilla.dev.tech.js-engine by 'Andy':
-# http://groups.google.com/group/mozilla.dev.tech.js-engine/browse_thread/thread/16972946bf7df82e
-#
-#
-# ***** BEGIN LICENSE BLOCK *****
-# Version: MPL 1.1/GPL 2.0/LGPL 2.1
-#
-# The contents of this file are subject to the Mozilla Public License Version
-# 1.1 (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-# http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS IS" basis,
-# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-# for the specific language governing rights and limitations under the
-# License.
-#
-# The Original Code is Mozilla Communicator client code, released
-# March 31, 1998.
-#
-# The Initial Developer of the Original Code is
-# Netscape Communications Corporation.
-# Portions created by the Initial Developer are Copyright (C) 1998
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either the GNU General Public License Version 2 or later (the "GPL"), or
-# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
-# in which case the provisions of the GPL or the LGPL are applicable instead
-# of those above. If you wish to allow use of your version of this file only
-# under the terms of either the GPL or the LGPL, and not to allow others to
-# use your version of this file under the terms of the MPL, indicate your
-# decision by deleting the provisions above and replace them with the notice
-# and other provisions required by the GPL or the LGPL. If you do not delete
-# the provisions above, a recipient may use your version of this file under
-# the terms of any one of the MPL, the GPL or the LGPL.
-#
-# ***** END LICENSE BLOCK *****
-
-#
-# Config for all versions of Mingw (copy and modified from Linux)
-#
-
-AR = i586-mingw32msvc-ar
-CC = i586-mingw32msvc-gcc
-LD = i586-mingw32msvc-ld
-CCC = i586-mingw32msvc-g++
-
-CFLAGS += -Wall -Wno-format
-#OS_CFLAGS = -DXP_UNIX -DSVR4 -DSYSV -D_BSD_SOURCE -DPOSIX_SOURCE -DHAVE_LOCALTIME_R -DEXPORT_JS_API
-OS_CFLAGS = -D_X86_=1 -DXP_WIN -DXP_WIN32 -DWIN32 -D_WINDOWS -D_WIN32 $(WIN_CFLAGS) -DEXPORT_JS_API
-JSDLL_CFLAGS = -DEXPORT_JS_API # not work, dunno why?
-SO_SUFFIX = dll
-# libgcc.a:__divdi3 kernel32:DebugBreak,GetSystemTimeAsFileTime
-# winmm:timeBeginPeriod,timeEndPeriod
-WINLIBS = -lmsvcrt -lm -lkernel32 -lwinmm /usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/libgcc.a
-#LDFLAGS += $(WINLIBS) # dont work. rewrite by Makefile.ref
-OTHER_LIBS += $(WINLIBS)
-
-RANLIB = echo
-MKSHLIB = $(LD) -shared $(XMKSHLIBOPTS)
-
-# These don't work :(
-LIBRARY = $(OBJDIR)/js32.lib
-SHARED_LIBRARY = $(OBJDIR)/js32.dll
-PROGRAM = $(OBJDIR)/js.exe
-
-#.c.o:
-# $(CC) -c -MD $*.d $(CFLAGS) $<
-
-CPU_ARCH = $(shell uname -m)
-# don't filter in x86-64 architecture
-ifneq (x86_64,$(CPU_ARCH))
-ifeq (86,$(findstring 86,$(CPU_ARCH)))
-CPU_ARCH = x86
-OS_CFLAGS+= -DX86_LINUX
-
-ifeq (gcc, $(CC))
-# if using gcc on x86, check version for opt bug
-# (http://bugzilla.mozilla.org/show_bug.cgi?id=24892)
-GCC_VERSION := $(shell gcc -v 2>&1 | grep version | awk '{ print $$3 }')
-GCC_LIST:=$(sort 2.91.66 $(GCC_VERSION) )
-
-ifeq (2.91.66, $(firstword $(GCC_LIST)))
-CFLAGS+= -DGCC_OPT_BUG
-endif
-endif
-endif
-endif
-
-GFX_ARCH = x
-
-OS_LIBS = -lm -lc
-
-ASFLAGS += -x assembler-with-cpp
-
-
-ifeq ($(CPU_ARCH),alpha)
-
-# Ask the C compiler on alpha linux to let us work with denormalized
-# double values, which are required by the ECMA spec.
-
-OS_CFLAGS += -mieee
-endif
-
-# Use the editline library to provide line-editing support.
-#JS_EDITLINE = 1 // not support by Mingw
-
-ifeq ($(CPU_ARCH),x86_64)
-# Use VA_COPY() standard macro on x86-64
-# FIXME: better use it everywhere
-OS_CFLAGS += -DHAVE_VA_COPY
-endif
-
-ifeq ($(CPU_ARCH),x86_64)
-# We need PIC code for shared libraries
-# FIXME: better patch rules.mk & fdlibm/Makefile*
-OS_CFLAGS += -DPIC -fPIC
-endif
@@ -1,38 +0,0 @@
-
-CROSS-COMPILING FOR WINDOWS
-
-Based on http://eigenclass.org/hiki.rb?cross+compiling+rcovrt
-
-
-*) Install the MinGW cross-compiler
-
- Debian: apt-get install mingw32 mingw32-binutils mingw32-runtime
-
-*) Download & extract a ruby distribution archive
-
-*) Double the backslashes in the ALT_SEPARATOR definition in Makefile.in
-
-*) Build & install it:
-
- env ac_cv_func_getpgrp_void=no \
- ac_cv_func_setpgrp_void=yes \
- rb_cv_negative_time_t=no \
- ac_cv_func_memcmp_working=yes \
- rb_cv_binary_elf=no \
- ./configure \
- --host=i586-mingw32msvc \
- --target=i386-mingw32 \
- --build=i686-linux \
- --prefix=~/ruby-mingw32
-
- make ruby
-
- make install
-
-*) Build the extension (rake will build spidermonkey for you)
-
- # Remove any native binaries that are already built
- rake clean
-
- rake build CROSS=MINGW32 CROSSLIB=~/ruby-mingw32/lib/ruby/1.8/i386-mingw32
-
@@ -18,9 +18,12 @@
spidermonkey_dir = File.expand_path File.dirname(__FILE__) +
"/../../vendor/spidermonkey"
+Dir.chdir spidermonkey_dir do
+ system "make -f Makefile.ref" if Dir["**/libjs.a"].empty?
+end
+
libjs = Dir[spidermonkey_dir + "/**/libjs.a"].first
-abort "libjs.a isn't built!" unless libjs
-$LOCAL_LIBS<< libjs
+$LOCAL_LIBS << libjs
dir_config "johnson/spidermonkey"
@@ -1,3 +1,3 @@
module Johnson #:nodoc:
- VERSION = "1.1.1"
+ VERSION = "1.1.2"
end
@@ -1,37 +0,0 @@
-require "erb"
-
-GENERATED_NODE = "ext/spidermonkey/immutable_node.c"
-HOE.clean_globs << GENERATED_NODE
-task :check_manifest => GENERATED_NODE
-
-def jsops
- ops = []
- File.open("vendor/spidermonkey/jsopcode.tbl", "rb") { |f|
- f.each_line do |line|
- if line =~ /^OPDEF\((\w+),/
- ops << $1
- end
- end
- }
- ops
-end
-
-def tokens
- toks = []
- File.open("vendor/spidermonkey/jsscan.h", "rb") { |f|
- f.each_line do |line|
- line.scan(/TOK_\w+/).each do |token|
- next if token == "TOK_ERROR"
- toks << token
- end
- end
- }
- toks.uniq
-end
-
-file GENERATED_NODE => "ext/spidermonkey/immutable_node.c.erb" do |t|
- template = ERB.new(File.open(t.prerequisites.first, "rb") { |x| x.read })
- File.open(GENERATED_NODE, "wb") { |f| f.write template.result(binding) }
-end
-
-file "ext/spidermonkey/extconf.rb" => GENERATED_NODE
View
@@ -1,20 +0,0 @@
-namespace :vendor do
- namespace :spidermonkey do
- desc "Clean the vendored SpiderMonkey."
- task :clean do
- Dir.chdir "vendor/spidermonkey" do
- sh "make clean -f Makefile.ref" unless Dir["**/libjs.a"].empty?
- end
- end
-
- desc "Compile the vendored SpiderMonkey."
- task :compile do
- Dir.chdir "vendor/spidermonkey" do
- sh "make -f Makefile.ref" if Dir["**/libjs.a"].empty?
- end
- end
- end
-end
-
-task :clean => "vendor:spidermonkey:clean"
-file "ext/spidermonkey/extconf.rb" => "vendor:spidermonkey:compile"
View
@@ -1,10 +1,6 @@
require "rubygems"
require "test/unit"
-%w(../lib ../ext/spidermonkey).each do |path|
- $LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), path)))
-end
-
require "johnson"
module Johnson

0 comments on commit a32f6b0

Please sign in to comment.