Skip to content

Commit

Permalink
* Disabled Lightning's dissembler on amd64
Browse files Browse the repository at this point in the history
* Split specrunner into bin/mspec and a wrapper
  • Loading branch information
Eero Saynatkari committed May 14, 2007
1 parent 3ed75ad commit 34ad791
Show file tree
Hide file tree
Showing 9 changed files with 1,614 additions and 1,858 deletions.
72 changes: 70 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ namespace :build do
desc "Build the VM bootstrap archive."
task :bootstrap => 'kernel/hints' do
Dir.chdir "kernel" do
files = Dir["bootstrap/*.rb"].sort
files = Dir["kernel/bootstrap/*.rb"].sort

changed = []
files.each do |file|
Expand All @@ -289,7 +289,7 @@ namespace :build do
f.puts files.join("\n")
end

archive = "../runtime/bootstrap.rba"
archive = "runtime/bootstrap.rba"

if File.exists? archive
if changed.empty?
Expand All @@ -302,6 +302,37 @@ namespace :build do
end
end
end

desc "Build the VM bootstrap archive with rubinius."
task :rbs_bootstrap => 'kernel/hints' do
files = Dir["kernel/bootstrap/*.rb"].sort

changed = []
files.each do |file|
cmp = "#{file}c"
unless newer?(file, cmp) # File.exists?(cmp) and File.mtime(cmp) >= File.mtime(file)
changed << cmp
system "shotgun/rubinius -c #{file}"
end
file << "c"
end

File.open(".load_order.txt","w") do |f|
f.puts files.join("\n")
end

archive = "runtime/bootstrap.rba"

if File.exists? archive
if changed.empty?
puts "No kernel/bootstrap files to update."
else
system "zip -u #{archive} .load_order.txt #{changed.join(' ')}"
end
else
system "zip #{archive} .load_order.txt #{files.join(' ')}"
end
end

desc "Build the core classes and methods archive."
task :core => 'kernel/hints' do
Expand Down Expand Up @@ -340,6 +371,43 @@ namespace :build do
end
end
end

desc "Build the core classes and methods archive."
task :rbs_core => 'kernel/hints' do
files = nil
files = Dir["kernel/core/*.rb"].sort
files.delete "kernel/core/__loader.rb"

files << "kernel/core/__loader.rb"

changed = []
files.each do |file|
cmp = "#{file}c"
unless newer?(file, cmp) # File.exists?(cmp) and File.mtime(cmp) >= File.mtime(file)
changed << cmp
system "shotgun/rubinius -c #{file}"
# system "#{COMPILER} #{file}"
# raise "Failed to compile #{file}" if $?.exitstatus != 0
end
file << "c"
end

File.open(".load_order.txt","w") do |f|
f.puts files.join("\n")
end

archive = "runtime/core.rba"

if File.exists? archive
if changed.empty?
puts "No kernel/core files to update."
else
system "zip -u #{archive} .load_order.txt #{changed.join(' ')}"
end
else
system "zip #{archive} .load_order.txt #{files.join(' ')}"
end
end

desc "Build the standard library."
task :library do
Expand Down
70 changes: 70 additions & 0 deletions bin/mspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/usr/bin/env bash
# Fear my elite bash skills

__SR_GOODFILE="/tmp/mini_spec_specrunner.txt"
__SR_ERRFILE="/tmp/mini_spec_specrunner_error.txt"

__SR_GOODFIFO="/tmp/mini_spec_good_fifo"

# Pre-cleanup
rm $__SR_GOODFILE $__SR_ERRFILE $__SR_GOODFIFO 2>/dev/null


# Target VM is MRI by default
if [[ $SR_TARGET = "" ]]; then
SR_TARGET=ruby
fi

# Files to run
if [[ -d $1 ]]; then
# Incompatible specs can only run under rubinius
if [[ $SR_TARGET = "shotgun/rubinius" ]]; then
__SR_SOURCE=`find $1 -name *_spec.rb | sort`
else
__SR_SOURCE=`find $1 -name *_spec.rb | grep -v 'incompatible' | sort`
fi
elif [[ -f $1 ]]; then
__SR_SOURCE=$1
else
echo "Usage: [__SR_TARGET=<vm>] specrunner <file|directory>"
exit 1
fi

__SR_TOTAL_SPECS="0"
__SR_TOTAL_FAILS="0"

# Dup some fds
exec 3>&1 4>&2

# Need some fifos too, hooray
mkfifo $__SR_GOODFIFO


# Run the specs
for i in $__SR_SOURCE; do
# tee helps keep the screen updating snappily
tee $__SR_GOODFILE < $__SR_GOODFIFO >&3 &
__SR_TEE_PID=$?

$SR_TARGET -rspec/mini_rspec.rb $i > $__SR_GOODFIFO 2> $__SR_ERRFILE

if [[ -s $__SR_ERRFILE ]]; then
echo "Errors:"
cat $__SR_ERRFILE
echo ""
echo ""
fi

__SR_TOTAL_SPECS=$(($__SR_TOTAL_SPECS + $(cat $__SR_GOODFILE | grep "^ -" | wc -l)))
__SR_TOTAL_FAILS=$(($__SR_TOTAL_FAILS + $(cat $__SR_GOODFILE | grep "FAILED" | wc -l)))

rm $__SR_GOODFILE $__SR_ERRFILE 2>/dev/null
kill -3 $__SR_TEE_PID
done

echo ""
echo "$__SR_TOTAL_SPECS specifications, $__SR_TOTAL_FAILS failures"
echo ""

# Post-cleanup
rm $__SR_GOODFILE $__SR_ERRFILE $__SR_GOODFIFO 2>/dev/null
28 changes: 27 additions & 1 deletion bin/rasm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,33 @@
# pp sexp
io.close
end

#
#def indent_print(array, indent = 0)
# print "#{' ' * indent}["
#
# array.each_with_index {|elem, i|
# if elem.kind_of? Array
# indent_print elem, indent + 2
# print ",\n"
# next
# end
#
# if i == 0
# print ' '
# else
# print ' '
# print ' ' * indent
# end
#
# print elem.inspect
# print ",\n"
# }
#
## print "\n"
# print "#{' ' * indent}]"
#end
#
#indent_print sexp
comp = Bytecode::Compiler.new
comp.load_hints "kernel/hints"
meth = comp.compile_as_script(sexp, :__script__)
Expand Down
70 changes: 4 additions & 66 deletions bin/specrunner
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,70 +1,8 @@
#!/usr/bin/env bash
# Fear my elite bash skills
#! /usr/bin/env bash

__SR_GOODFILE="/tmp/mini_spec_specrunner.txt"
__SR_ERRFILE="/tmp/mini_spec_specrunner_error.txt"

__SR_GOODFIFO="/tmp/mini_spec_good_fifo"

# Pre-cleanup
rm $__SR_GOODFILE $__SR_ERRFILE $__SR_GOODFIFO 2>/dev/null


# Target VM
# Switch to default rubinius
if [[ $SR_TARGET = "" ]]; then
SR_TARGET=shotgun/rubinius
fi

# Files to run
if [[ -d $1 ]]; then
# Incompatible specs can only run under rubinius
if [[ $SR_TARGET = "shotgun/rubinius" ]]; then
__SR_SOURCE=`find $1 -name *_spec.rb | sort`
else
__SR_SOURCE=`find $1 -name *_spec.rb | grep -v 'incompatible' | sort`
fi
elif [[ -f $1 ]]; then
__SR_SOURCE=$1
SR_TARGET=./shotgun/rubinius exec ./bin/mspec $@
else
echo "Usage: [__SR_TARGET=<vm>] specrunner <file|directory>"
exit 1
exec ./bin/mspec $@
fi

__SR_TOTAL_SPECS="0"
__SR_TOTAL_FAILS="0"

# Dup some fds
exec 3>&1 4>&2

# Need some fifos too, hooray
mkfifo $__SR_GOODFIFO


# Run the specs
for i in $__SR_SOURCE; do
# tee helps keep the screen updating snappily
tee $__SR_GOODFILE < $__SR_GOODFIFO >&3 &
__SR_TEE_PID=$?

$SR_TARGET -rspec/mini_rspec.rb $i > $__SR_GOODFIFO 2> $__SR_ERRFILE

if [[ -s $__SR_ERRFILE ]]; then
echo "Errors:"
cat $__SR_ERRFILE
echo ""
echo ""
fi

__SR_TOTAL_SPECS=$(($__SR_TOTAL_SPECS + $(cat $__SR_GOODFILE | grep "^ -" | wc -l)))
__SR_TOTAL_FAILS=$(($__SR_TOTAL_FAILS + $(cat $__SR_GOODFILE | grep "FAILED" | wc -l)))

rm $__SR_GOODFILE $__SR_ERRFILE 2>/dev/null
kill -3 $__SR_TEE_PID
done

echo ""
echo "$__SR_TOTAL_SPECS examples, $__SR_TOTAL_FAILS failures"
echo ""

# Post-cleanup
rm $__SR_GOODFILE $__SR_ERRFILE $__SR_GOODFIFO 2>/dev/null
22 changes: 14 additions & 8 deletions shotgun/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,18 @@ endif

DEPS=../include/rubinius.h

ALIBS=external_libs/lightning/opcode/libdisass.a external_libs/libtommath/libtommath.a external_libs/onig/.libs/libonig.a external_libs/libzip/lib/.libs/libzip.a external_libs/libltdl/.libs/libltdl.a external_libs/libevent/.libs/libevent.a

# No disass support for 64
ifeq ($(MARCH),amd64)
__RBS_LIGHTNING_DISASS=''

ALIBS=external_libs/libtommath/libtommath.a external_libs/onig/.libs/libonig.a external_libs/libzip/lib/.libs/libzip.a external_libs/libltdl/.libs/libltdl.a external_libs/libevent/.libs/libevent.a

else
__RBS_LIGHTNING_DISASS='--enable-disassembling'

ALIBS=external_libs/lightning/opcode/libdisass.a external_libs/libtommath/libtommath.a external_libs/onig/.libs/libonig.a external_libs/libzip/lib/.libs/libzip.a external_libs/libltdl/.libs/libltdl.a external_libs/libevent/.libs/libevent.a
endif

LIBS=`pkg-config glib-2.0 --libs` $(ALIBS) -lz -lm
LDFLAGS=
Expand All @@ -43,15 +54,10 @@ ifeq ($(UNAME),SunOS)
endif

# Support *BSD libexecinfo for backtrace etc.
ifeq ($(UNAME),FreeBSD)
ifeq ($(findstring BSD,$(UNAME)),BSD)
LIBS+=-lexecinfo
endif

ifeq ($(UNAME),OpenBSD)
LIBS+=-lexecinfo
endif


ifeq ($(UNAME),Linux)
LIBS+=-ldl
endif
Expand All @@ -75,7 +81,7 @@ config.h:
$(COMP) $(CFLAGS) -c $<

external_libs/lightning/opcode/libdisass.a:
cd external_libs/lightning; ./configure --enable-disassembling; $(MAKE)
cd external_libs/lightning; CFLAGS=-fPIC ./configure $(__RBS_LIGHTNING_DISASS); $(MAKE)

external_libs/libtommath/libtommath.a:
cd external_libs/libtommath; $(MAKE)
Expand Down
11 changes: 10 additions & 1 deletion shotgun/lib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ COMP=$(LIBTOOL) --mode=compile $(CC)
LINKER=$(LIBTOOL) --mode=link $(CC)
UNAME=$(shell uname)
CPU=$(shell uname -p)
MARCH=$(shell uname -m)

ifeq ($(UNAME),Darwin)
SINGLE_MODULE=-Wl,-single_module
Expand All @@ -21,7 +22,15 @@ CPPFLAGS=-I../../include -I .. -iquote . -I../external_libs/lightning -I../exter

WARNINGS=-Wall -Winline

LIBS=`pkg-config glib-2.0 --libs` -lz ../external_libs/lightning/opcode/libdisass.a ../external_libs/libtommath/libtommath.a ../external_libs/onig/.libs/libonig.a ../external_libs/libzip/lib/.libs/libzip.a $(SINGLE_MODULE) ../external_libs/libevent/.libs/libevent.a ../external_libs/libltdl/.libs/libltdl.a -lm -lcrypt
# No disass support for 64
ifeq ($(MARCH),amd64)
LIBS=`pkg-config glib-2.0 --libs` -lz ../external_libs/libtommath/libtommath.a ../external_libs/onig/.libs/libonig.a ../external_libs/libzip/lib/.libs/libzip.a $(SINGLE_MODULE) ../external_libs/libevent/.libs/libevent.a ../external_libs/libltdl/.libs/libltdl.a -lm -lcrypt

else
CFLAGS+="-DRBS_DISASS=1"

LIBS=`pkg-config glib-2.0 --libs` -lz ../external_libs/lightning/opcode/libdisass.a ../external_libs/libtommath/libtommath.a ../external_libs/onig/.libs/libonig.a ../external_libs/libzip/lib/.libs/libzip.a $(SINGLE_MODULE) ../external_libs/libevent/.libs/libevent.a ../external_libs/libltdl/.libs/libltdl.a -lm -lcrypt
endif

ifdef USE_CINVOKE
CPPFLAGS+= -I../external_libs/cinvoke/lib
Expand Down
Loading

0 comments on commit 34ad791

Please sign in to comment.