Skip to content
Browse files

Rearranged rake setup a lot, making browsing more intuitive (build se…

…ction should be first for example). Separated out several sections
  • Loading branch information...
1 parent 6d9e0af commit cc280687df69381a91d6ab75b9f210145160224f Ryan Davis committed Feb 4, 2008
Showing with 842 additions and 845 deletions.
  1. +125 −845 Rakefile
  2. +77 −0 rakelib/doc.rake
  3. +103 −0 rakelib/extensions.rake
  4. +537 −0 rakelib/platform.rake
View
970 Rakefile
@@ -4,187 +4,15 @@
$VERBOSE = true
$verbose = Rake.application.options.trace
$dlext = Config::CONFIG["DLEXT"]
-$redcloth_available = nil
$compiler = nil
require 'tsort'
require 'rakelib/rubinius'
require 'rakelib/struct_generator'
require 'rakelib/const_generator'
-begin
- require 'rubygems'
-rescue LoadError
- # Don't show RedCloth warning if gems aren't available
- $redcloth_available = false
-end
-
task :default => :build
-# SPEC TASKS
-desc "Run all 'known good' specs (task alias for spec:ci)"
-task :spec => 'spec:ci'
-
-namespace :spec do
- namespace :setup do
- # Setup for 'Subtend' specs. No need to call this yourself.
- task :subtend do
- Dir["spec/subtend/**/Rakefile"].each do |rakefile|
- sh "rake -f #{rakefile}"
- end
- end
- end
-
- desc "Run continuous integration examples"
- task :ci do
- target = ENV['SPEC_TARGET'] || 'rbx'
- system %(shotgun/rubinius -e 'puts "rbx build: \#{Rubinius::BUILDREV}"') if target == 'rbx'
- sh "bin/ci -t #{target}"
- end
-
- spec_targets = %w(compiler core language library parser rubinius)
- # Build a spec:<task_name> for each group of Rubinius specs
- spec_targets.each do |group|
- desc "Run #{group} examples"
- task group do
- sh "bin/mspec spec/#{group}"
- end
- end
-
- desc "Run subtend (Rubinius C API) examples"
- task :subtend => "spec:setup:subtend" do
- sh "bin/mspec spec/rubinius/subtend"
- end
-
- # Specdiffs to make it easier to see what your changes have affected :)
- desc 'Run specs and produce a diff against current base'
- task :diff => 'diff:run'
-
- namespace :diff do
- desc 'Run specs and produce a diff against current base'
- task :run do
- system 'bin/mspec -f ci -o spec/reports/specdiff.txt spec'
- system 'diff -u spec/reports/base.txt spec/reports/specdiff.txt'
- system 'rm spec/reports/specdiff.txt'
- end
-
- desc 'Replace the base spec file with a new one'
- task :replace do
- system 'bin/mspec -f ci -o spec/reports/base.txt spec'
- end
- end
-
- task :r2r do
- puts ARGV.inspect
- end
-end
-
-# INSTALL TASKS
-
-desc "Install rubinius as rbx"
-task :install => :config_env do
- sh "cd shotgun; #{make "install"}"
-
- mkdir_p ENV['RBAPATH'], :verbose => true
- mkdir_p ENV['CODEPATH'], :verbose => true
-
- rba_files = Rake::FileList.new('runtime/platform.conf',
- 'runtime/**/*.rb{a,c}',
- 'runtime/**/.load_order.txt')
-
- install_files rba_files, ENV['RBAPATH']
-
- lib_files = Rake::FileList.new 'lib/**/*'
-
- install_files lib_files, ENV['CODEPATH']
-
- mkdir_p File.join(ENV['CODEPATH'], 'bin'), :verbose => true
-
- Rake::FileList.new("#{ENV['CODEPATH']}/**/*.rb").sort.each do |rb_file|
- sh File.join(ENV['BINPATH'], 'rbx'), 'compile', rb_file, :verbose => true
- end
-end
-
-desc "Uninstall rubinius and libraries. Helps with build problems."
-task :uninstall => :config_env do
- rm Dir[File.join(ENV['BINPATH'], 'rbx*')]
- rm_r Dir[File.join(ENV['LIBPATH'], '*rubinius*')]
-end
-
-task :config_env => 'shotgun/config.mk' do
- File.foreach 'shotgun/config.mk' do |line|
- next unless line =~ /(.*?)=(.*)/
- ENV[$1] = $2
- end
-end
-
-task :compiledir => :stable_compiler do
- dir = ENV['DIR']
- raise "Use DIR= to set which directory" if !dir or dir.empty?
- compile_dir(dir)
-end
-
-# CLEAN TASKS
-
-desc "Recompile all ruby system files"
-task :rebuild => %w[clean build:all]
-
-desc "Clean up the usuals"
-task :clean => %w[clean:rbc clean:extensions clean:shotgun clean:generated clean:crap]
-
-desc "Remove all ruby system files"
-task :distclean => %w[pristine clean clean:external]
-
-desc "Remove all stray compiled Ruby files"
-task :pristine do
- FileList['**/*.rbc'].each do |fn|
- next if fn =~ %r%^runtime|fixtures/require|lib/complier%
- rm_f fn, :verbose => $verbose
- end
-end
-
-namespace :clean do
-
- desc "Remove all compile system ruby files"
- task :rbc do
- files_to_delete = []
- files_to_delete += Dir["*.rbc"] + Dir["**/*.rbc"]
- files_to_delete += ["runtime/platform.conf"]
- files_to_delete -= ["runtime/stable/loader.rbc"] # never ever delete this
-
- files_to_delete.each do |f|
- rm_f f, :verbose => $verbose
- end
- end
-
- desc "Cleans all compiled extension files (lib/ext)"
- task :extensions do
- Dir["lib/ext/**/*#{$dlext}"].each do |f|
- rm_f f, :verbose => $verbose
- end
- end
-
- desc "Cleans up VM building site"
- task :shotgun do
- sh make('clean')
- end
-
- desc "Cleans up generated files"
- task :generated do
- rm_f Dir["shotgun/lib/grammar.c"], :verbose => $verbose
- end
-
- desc "Cleans up VM and external libs"
- task :external do
- sh "cd shotgun; #{make('distclean')}"
- end
-
- desc "Cleans up editor files and other misc crap"
- task :crap do
- rm_f Dir["*~"] + Dir["**/*~"], :verbose => $verbose
- end
-end
-
# BUILD TASKS
desc "Build everything that needs to be built"
@@ -240,7 +68,6 @@ end
AllPreCompiled = Core.output + Bootstrap.output + PlatformFiles.output
AllPreCompiled << "runtime/loader.rbc"
-
namespace :build do
task :all => %w[
@@ -283,7 +110,7 @@ namespace :build do
task :setup_rbc => :stable_compiler
task :rbc => ([:setup_rbc] + AllPreCompiled)
-
+
task :compiler => :stable_compiler do
compile_dir "lib/compiler"
end
@@ -298,39 +125,6 @@ namespace :build do
runtime/stable/platform.rba
]
- file 'lib/rbconfig.rb' => %w[config_env Rakefile] do
- rbconfig = <<-EOF
-#--
-# This file was generated by the rubinius Rakefile.
-#++
-
-module Config
-
- CONFIG = {}
-
- CONFIG['DLEXT'] = Rubinius::LIBSUFFIX.dup
- CONFIG['EXEEXT'] = ""
- CONFIG['RUBY_SO_NAME'] = "rubinius-#\{Rubinius::RBX_VERSION}"
- CONFIG['arch'] = RUBY_PLATFORM.dup
- CONFIG['bindir'] = "#{ENV['BINPATH']}"
- CONFIG['datadir'] = "#{File.join ENV['PREFIX'], 'share'}"
- CONFIG['libdir'] = "#{ENV['LIBPATH']}"
- CONFIG['ruby_install_name'] = "#{ENV['ENGINE']}"
- CONFIG['ruby_version'] = Rubinius::RUBY_VERSION.dup
- CONFIG['sitedir'] = "#{File.join ENV['LIBPATH'], 'rubinius'}"
- CONFIG['sitelibdir'] = "#{ENV['CODEPATH']}"
- CONFIG['wordsize'] = Rubinius::WORDSIZE
-
-end
-
-RbConfig = Config
- EOF
-
- File.open 'lib/rbconfig.rb', 'w' do |fp|
- fp.write rbconfig
- end
- end
-
desc "Rebuild the .load_order.txt files"
task "load_order" do
# Note: Steps to rebuild load_order were defined above
@@ -349,684 +143,170 @@ RbConfig = Config
task :platform => 'runtime/platform.conf'
end
-file 'runtime/platform.conf' => %w[Rakefile rakelib/struct_generator.rb] do |task|
- addrinfo = StructGenerator.new
- addrinfo.include 'sys/socket.h'
- addrinfo.include 'netdb.h'
- addrinfo.name 'struct addrinfo'
- addrinfo.field :ai_flags, :int
- addrinfo.field :ai_family, :int
- addrinfo.field :ai_socktype, :int
- addrinfo.field :ai_protocol, :int
- addrinfo.field :ai_addrlen, :int
- addrinfo.field :ai_addr, :pointer
- addrinfo.field :ai_canonname, :string
- addrinfo.field :ai_next, :pointer
- addrinfo.calculate
-
- dirent = StructGenerator.new
- dirent.include "dirent.h"
- dirent.name 'struct dirent'
- dirent_d_name = dirent.field :d_name
- dirent.calculate
-
- timeval = StructGenerator.new
- timeval.include "sys/time.h"
- timeval.name 'struct timeval'
- timeval.field :tv_sec
- timeval.field :tv_usec
- timeval.calculate
-
- sockaddr_in = StructGenerator.new
- sockaddr_in.include "netinet/in.h"
- sockaddr_in.include "fcntl.h"
- sockaddr_in.include "sys/socket.h"
- sockaddr_in.include "sys/stat.h"
- sockaddr_in.name 'struct sockaddr_in'
- sockaddr_in.field :sin_family
- sockaddr_in.field :sin_port
- sockaddr_in.field :sin_addr
- sockaddr_in.field :sin_zero
- sockaddr_in.calculate
-
- sockaddr_un = StructGenerator.new
- sockaddr_un.include "sys/un.h"
- sockaddr_un.name 'struct sockaddr_un'
- sockaddr_un.field :sun_family
- sockaddr_un.field :sun_path
- sockaddr_un.calculate
-
- servent = StructGenerator.new
- servent.include "netdb.h"
- servent.name 'struct servent'
- servent.field :s_name, :pointer
- servent.field :s_aliases, :pointer
- servent.field :s_port, :int
- servent.field :s_proto, :pointer
- servent.calculate
-
- # FIXME these constants don't have standard names.
- # LOCK_SH == Linux, O_SHLOCK on Bsd/Darwin, etc.
- # Binary doesn't exist at all in many non-Unix variants.
- # This should come out of something like config.h
- fixme_constants = %w{
- LOCK_SH
- LOCK_EX
- LOCK_NB
- LOCK_UN
- BINARY
- }
-
- file_constants = %w{
- O_RDONLY
- O_WRONLY
- O_RDWR
- O_CREAT
- O_EXCL
- O_NOCTTY
- O_TRUNC
- O_APPEND
- O_NONBLOCK
- O_SYNC
- S_IRUSR
- S_IWUSR
- S_IXUSR
- S_IRGRP
- S_IWGRP
- S_IXGRP
- S_IROTH
- S_IWOTH
- S_IXOTH
- }
-
- io_constants = %w{
- SEEK_SET
- SEEK_CUR
- SEEK_END
- }
-
- fcntl_constants = %w{
- F_DUPFD
- F_GETFD
- F_GETLK
- F_SETFD
- F_GETFL
- F_SETFL
- F_SETLK
- F_SETLKW
- FD_CLOEXEC
- F_RDLCK
- F_UNLCK
- F_WRLCK
- O_CREAT
- O_EXCL
- O_NOCTTY
- O_TRUNC
- O_APPEND
- O_NONBLOCK
- O_NDELAY
- O_RDONLY
- O_RDWR
- O_WRONLY
- O_ACCMODE
- }
-
- socket_constants = %w[
- AF_APPLETALK
- AF_ATM
- AF_AX25
- AF_CCITT
- AF_CHAOS
- AF_CNT
- AF_COIP
- AF_DATAKIT
- AF_DEC
- AF_DLI
- AF_E164
- AF_ECMA
- AF_HYLINK
- AF_IMPLINK
- AF_INET
- AF_INET6
- AF_IPX
- AF_ISDN
- AF_ISO
- AF_LAT
- AF_LINK
- AF_LOCAL
- AF_MAX
- AF_NATM
- AF_NDRV
- AF_NETBIOS
- AF_NETGRAPH
- AF_NS
- AF_OSI
- AF_PPP
- AF_PUP
- AF_ROUTE
- AF_SIP
- AF_SNA
- AF_SYSTEM
- AF_UNIX
- AF_UNSPEC
-
- AI_ADDRCONFIG
- AI_ALL
- AI_CANONNAME
- AI_DEFAULT
- AI_MASK
- AI_NUMERICHOST
- AI_PASSIVE
- AI_V4MAPPED
- AI_V4MAPPED_CFG
-
- EAI_ADDRFAMILY
- EAI_AGAIN
- EAI_BADFLAGS
- EAI_BADHINTS
- EAI_FAIL
- EAI_FAMILY
- EAI_MAX
- EAI_MEMORY
- EAI_NODATA
- EAI_NONAME
- EAI_PROTOCOL
- EAI_SERVICE
- EAI_SOCKTYPE
- EAI_SYSTEM
-
- INADDR_ALLHOSTS_GROUP
- INADDR_ANY
- INADDR_BROADCAST
- INADDR_LOOPBACK
- INADDR_MAX_LOCAL_GROUP
- INADDR_NONE
- INADDR_UNSPEC_GROUP
-
- IPPORT_RESERVED
- IPPORT_USERRESERVED
-
- IPPROTO_BIP
- IPPROTO_EGP
- IPPROTO_EON
- IPPROTO_GGP
- IPPROTO_HELLO
- IPPROTO_ICMP
- IPPROTO_IDP
- IPPROTO_IGMP
- IPPROTO_IP
- IPPROTO_MAX
- IPPROTO_ND
- IPPROTO_PUP
- IPPROTO_RAW
- IPPROTO_TCP
- IPPROTO_TP
- IPPROTO_UDP
- IPPROTO_XTP
-
- IPX_TYPE
-
- IP_ADD_MEMBERSHIP
- IP_DEFAULT_MULTICAST_LOOP
- IP_DEFAULT_MULTICAST_TTL
- IP_DROP_MEMBERSHIP
- IP_HDRINCL
- IP_MAX_MEMBERSHIPS
- IP_MULTICAST_IF
- IP_MULTICAST_LOOP
- IP_MULTICAST_TTL
- IP_OPTIONS
- IP_RECVDSTADDR
- IP_RECVOPTS
- IP_RECVRETOPTS
- IP_RETOPTS
- IP_TOS
- IP_TTL
-
- MSG_COMPAT
- MSG_CTRUNC
- MSG_DONTROUTE
- MSG_DONTWAIT
- MSG_EOF
- MSG_EOR
- MSG_FLUSH
- MSG_HAVEMORE
- MSG_HOLD
- MSG_OOB
- MSG_PEEK
- MSG_RCVMORE
- MSG_SEND
- MSG_TRUNC
- MSG_WAITALL
-
- NI_DGRAM
- NI_MAXHOST
- NI_MAXSERV
- NI_NAMEREQD
- NI_NOFQDN
- NI_NUMERICHOST
- NI_NUMERICSERV
-
- PF_APPLETALK
- PF_AX25
- PF_CCITT
- PF_CHAOS
- PF_CNT
- PF_COIP
- PF_DATAKIT
- PF_DLI
- PF_ECMA
- PF_HYLINK
- PF_IMPLINK
- PF_INET
- PF_INET6
- PF_IPX
- PF_ISDN
- PF_ISO
- PF_KEY
- PF_LAT
- PF_LINK
- PF_LOCAL
- PF_MAX
- PF_NATM
- PF_NDRV
- PF_NETBIOS
- PF_NETGRAPH
- PF_NS
- PF_OSI
- PF_PIP
- PF_PPP
- PF_PUP
- PF_ROUTE
- PF_RTIP
- PF_SIP
- PF_SNA
- PF_SYSTEM
- PF_UNIX
- PF_UNSPEC
- PF_XTP
-
- SHUT_RD
- SHUT_RDWR
- SHUT_WR
-
- SOCK_DGRAM
- SOCK_PACKET
- SOCK_RAW
- SOCK_RDM
- SOCK_SEQPACKET
- SOCK_STREAM
-
- SOL_ATALK
- SOL_AX25
- SOL_IP
- SOL_IPX
- SOL_SOCKET
- SOL_TCP
- SOL_UDP
-
- SOPRI_BACKGROUND
- SOPRI_INTERACTIVE
- SOPRI_NORMAL
-
- SO_ACCEPTCONN
- SO_ACCEPTFILTER
- SO_ATTACH_FILTER
- SO_BINDTODEVICE
- SO_BROADCAST
- SO_DEBUG
- SO_DETACH_FILTER
- SO_DONTROUTE
- SO_DONTTRUNC
- SO_ERROR
- SO_KEEPALIVE
- SO_LINGER
- SO_NKE
- SO_NOSIGPIPE
- SO_NO_CHECK
- SO_NREAD
- SO_OOBINLINE
- SO_PASSCRED
- SO_PEERCRED
- SO_PEERNAME
- SO_PRIORITY
- SO_RCVBUF
- SO_RCVLOWAT
- SO_RCVTIMEO
- SO_REUSEADDR
- SO_REUSEPORT
- SO_SECURITY_AUTHENTICATION
- SO_SECURITY_ENCRYPTION_NETWORK
- SO_SECURITY_ENCRYPTION_TRANSPORT
- SO_SNDBUF
- SO_SNDLOWAT
- SO_SNDTIMEO
- SO_TIMESTAMP
- SO_TYPE
- SO_USELOOPBACK
- SO_WANTMORE
- SO_WANTOOBFLAG
-
- TCP_MAXSEG
- TCP_NODELAY
- ]
+# INSTALL TASKS
- process_constants = %w{
- WNOHANG
- WUNTRACED
- PRIO_PROCESS
- PRIO_PGRP
- PRIO_USER
- RLIMIT_CPU
- RLIMIT_FSIZE
- RLIMIT_DATA
- RLIMIT_STACK
- RLIMIT_CORE
- RLIMIT_RSS
- RLIMIT_NPROC
- RLIMIT_NOFILE
- RLIMIT_MEMLOCK
- RLIMIT_AS
- RLIMIT_SBSIZE
- }
-
- long_process_constants = %w{
- RLIM_INFINITY
- RLIM_SAVED_MAX
- RLIM_SAVED_CUR
- }
-
- # The constants come from MRI's signal.c. This means that some of them might
- # be missing.
- signal_constants = %w{
- SIGHUP
- SIGINT
- SIGQUIT
- SIGILL
- SIGTRAP
- SIGIOT
- SIGABRT
- SIGEMT
- SIGFPE
- SIGKILL
- SIGBUS
- SIGSEGV
- SIGSYS
- SIGPIPE
- SIGALRM
- SIGTERM
- SIGURG
- SIGSTOP
- SIGTSTP
- SIGCONT
- SIGCHLD
- SIGCLD
- SIGCHLD
- SIGTTIN
- SIGTTOU
- SIGIO
- SIGXCPU
- SIGXFSZ
- SIGVTALRM
- SIGPROF
- SIGWINCH
- SIGUSR1
- SIGUSR2
- SIGLOST
- SIGMSG
- SIGPWR
- SIGPOLL
- SIGDANGER
- SIGMIGRATE
- SIGPRE
- SIGGRANT
- SIGRETRACT
- SIGSOUND
- SIGINFO
- }
-
- cg = ConstGenerator.new
- cg.include "stdio.h"
- cg.include "fcntl.h"
- cg.include "sys/types.h"
- cg.include "sys/socket.h"
- cg.include "netdb.h"
- cg.include "sys/stat.h"
- cg.include "sys/resource.h"
- cg.include "netinet/tcp.h"
- cg.include "signal.h"
-
- file_constants.each { |c| cg.const c }
- io_constants.each { |c| cg.const c }
- fcntl_constants.each {|c| cg.const c }
- socket_constants.each { |c| cg.const c }
- process_constants.each { |c| cg.const c }
- long_process_constants.each { |c| cg.const(c, "%llu") }
- signal_constants.each { |c| cg.const c }
- fcntl_constants.each { |c| cg.const c }
-
- cg.calculate
-
- puts "Generating #{task.name}..."
-
- File.open task.name, "w" do |f|
- f.puts addrinfo.generate_config('addrinfo')
- f.puts "rbx.platform.dir.d_name = #{dirent_d_name.offset}"
- f.puts timeval.generate_config('timeval')
- f.puts sockaddr_in.generate_config('sockaddr_in')
- f.puts sockaddr_un.generate_config('sockaddr_un') if sockaddr_un.found?
- f.puts servent.generate_config('servent')
-
- file_constants.each do | name |
- const = cg.constants[name]
- f.puts "rbx.platform.file.#{name} = #{const.converted_value}"
- end
+desc "Install rubinius as rbx"
+task :install => :config_env do
+ sh "cd shotgun; #{make "install"}"
- io_constants.each do |name|
- const = cg.constants[name]
- f.puts "rbx.platform.io.#{name} = #{const.converted_value}"
- end
+ mkdir_p ENV['RBAPATH'], :verbose => true
+ mkdir_p ENV['CODEPATH'], :verbose => true
- fcntl_constants.each do |name|
- const = cg.constants[name]
- next if const.converted_value.nil?
- f.puts "rbx.platform.fcntl.#{name} = #{const.converted_value}"
- end
+ rba_files = Rake::FileList.new('runtime/platform.conf',
+ 'runtime/**/*.rb{a,c}',
+ 'runtime/**/.load_order.txt')
- socket_constants.each do |name|
- const = cg.constants[name]
- next if const.converted_value.nil?
- f.puts "rbx.platform.socket.#{name} = #{const.converted_value}"
- end
+ install_files rba_files, ENV['RBAPATH']
- (process_constants + long_process_constants).each do |name|
- const = cg.constants[name]
- next if const.converted_value.nil?
- f.puts "rbx.platform.process.#{name} = #{const.converted_value}"
- end
+ lib_files = Rake::FileList.new 'lib/**/*'
- signal_constants.each do |name|
- const = cg.constants[name]
- next if const.converted_value.nil?
- f.puts "rbx.platform.signal.#{name} = #{const.converted_value}"
- end
+ install_files lib_files, ENV['CODEPATH']
+
+ mkdir_p File.join(ENV['CODEPATH'], 'bin'), :verbose => true
+
+ Rake::FileList.new("#{ENV['CODEPATH']}/**/*.rb").sort.each do |rb_file|
+ sh File.join(ENV['BINPATH'], 'rbx'), 'compile', rb_file, :verbose => true
end
-
end
-desc "Build extensions from lib/ext"
-task :extensions => %w[
- build:shotgun
- build:rbc
-
- extension:digest_rmd160
- extension:digest_md5
- extension:digest_sha1
- extension:digest_sha2
-
- extension:syck
- extension:zlib
- extension:readline
-]
-
-namespace :extension do
- task :digest_md5 => "lib/ext/digest/md5/md5.#{$dlext}"
-
- file "lib/ext/digest/md5/md5.#{$dlext}" => FileList[
- 'lib/ext/digest/md5/build.rb',
- 'lib/ext/digest/md5/*.c',
- 'lib/ext/digest/md5/*.h',
- 'lib/ext/digest/defs.h',
- ] do
- compile 'lib/ext/digest/md5'
+desc "Uninstall rubinius and libraries. Helps with build problems."
+task :uninstall => :config_env do
+ rm Dir[File.join(ENV['BINPATH'], 'rbx*')]
+ rm_r Dir[File.join(ENV['LIBPATH'], '*rubinius*')]
+end
+
+task :config_env => 'shotgun/config.mk' do
+ File.foreach 'shotgun/config.mk' do |line|
+ next unless line =~ /(.*?)=(.*)/
+ ENV[$1] = $2
end
+end
- task :digest_rmd160 => "lib/ext/digest/rmd160/rmd160.#{$dlext}"
+task :compiledir => :stable_compiler do
+ dir = ENV['DIR']
+ raise "Use DIR= to set which directory" if !dir or dir.empty?
+ compile_dir(dir)
+end
- file "lib/ext/digest/rmd160/rmd160.#{$dlext}" => FileList[
- 'lib/ext/digest/rmd160/build.rb',
- 'lib/ext/digest/rmd160/*.c',
- 'lib/ext/digest/rmd160/*.h',
- 'lib/ext/digest/defs.h',
- ] do
- compile 'lib/ext/digest/rmd160'
- end
+# CLEAN TASKS
- task :digest_sha1 => "lib/ext/digest/sha1/sha1.#{$dlext}"
+desc "Recompile all ruby system files"
+task :rebuild => %w[clean build:all]
- file "lib/ext/digest/sha1/sha1.#{$dlext}" => FileList[
- 'lib/ext/digest/sha1/build.rb',
- 'lib/ext/digest/sha1/*.c',
- 'lib/ext/digest/sha1/*.h',
- 'lib/ext/digest/defs.h',
- ] do
- compile 'lib/ext/digest/sha1'
- end
+desc "Alias for clean:all"
+task :clean => "clean:all"
- task :digest_sha2 => "lib/ext/digest/sha2/sha2.#{$dlext}"
+desc "Alias for clean:distclean"
+task :distclean => "clean:distclean"
- file "lib/ext/digest/sha2/sha2.#{$dlext}" => FileList[
- 'lib/ext/digest/sha2/build.rb',
- 'lib/ext/digest/sha2/*.c',
- 'lib/ext/digest/sha2/*.h',
- 'lib/ext/digest/defs.h',
- ] do
- compile 'lib/ext/digest/sha2'
- end
+namespace :clean do
+ desc "Clean everything but third-party libs"
+ task :all => %w[clean:rbc clean:extensions clean:shotgun clean:generated clean:crap]
- task :syck => "lib/ext/syck/rbxext.#{$dlext}"
+ desc "Clean everything including third-party libs"
+ task :distclean => %w[clean:all clean:external]
+
+ desc "Remove all compile system ruby files"
+ task :rbc do
+ files_to_delete = []
+ files_to_delete += Dir["*.rbc"] + Dir["**/*.rbc"]
+ files_to_delete += Dir["**/.load_order.txt"]
+ files_to_delete += ["runtime/platform.conf"]
+ files_to_delete -= ["runtime/stable/loader.rbc"] # never ever delete this
- file "lib/ext/syck/rbxext.#{$dlext}" => FileList[
- 'shotgun/lib/subtend/ruby.h',
- 'lib/ext/syck/build.rb',
- 'lib/ext/syck/*.c',
- 'lib/ext/syck/*.h',
- ] do
- compile "lib/ext/syck"
+ files_to_delete.each do |f|
+ rm_f f, :verbose => $verbose
+ end
end
-
- task :mongrel => "lib/ext/mongrel/http11.#{$dlext}"
-
- file "lib/ext/mongrel/http11.#{$dlext}" => FileList[
- 'shotgun/lib/subtend/ruby.h',
- 'lib/ext/mongrel/build.rb',
- 'lib/ext/mongrel/*.c',
- 'lib/ext/mongrel/*.h',
- ] do
- compile "lib/ext/mongrel"
+
+ desc "Cleans all compiled extension files (lib/ext)"
+ task :extensions do
+ Dir["lib/ext/**/*#{$dlext}"].each do |f|
+ rm_f f, :verbose => $verbose
+ end
end
- task :zlib => %W[lib/ext/zlib/zlib.#{$dlext} lib/zlib.rb]
+ desc "Cleans up VM building site"
+ task :shotgun do
+ sh make('clean')
+ end
- file "lib/ext/zlib/zlib.#{$dlext}" => FileList[
- 'shotgun/lib/subtend/ruby.h',
- 'lib/ext/zlib/build.rb',
- 'lib/ext/zlib/*.c'
- ] do
- compile "lib/ext/zlib"
+ desc "Cleans up generated files"
+ task :generated do
+ rm_f Dir["shotgun/lib/grammar.c"], :verbose => $verbose
end
- task :readline => %W[lib/ext/readline/readline.#{$dlext} lib/readline.rb]
+ desc "Cleans up VM and external libs"
+ task :external do
+ sh "cd shotgun; #{make('distclean')}"
+ end
- file "lib/ext/readline/readline.#{$dlext}" => FileList[
- 'shotgun/lib/subtend/ruby.h',
- 'lib/ext/readline/build.rb',
- 'lib/ext/readline/*.c'
- ] do
- compile "lib/ext/readline"
+ desc "Cleans up editor files and other misc crap"
+ task :crap do
+ rm_f Dir["*~"] + Dir["**/*~"], :verbose => $verbose
end
end
-# MISC TASKS
-
-desc "Build task for CruiseControl"
-task :ccrb => [:build, 'spec:ci']
+# SPEC TASKS
+desc "Run all 'known good' specs (task alias for spec:ci)"
+task :spec => 'spec:ci'
-## Include tasks to build documentation
-def redcloth_present?
- if $redcloth_available.nil?
- begin
- require 'redcloth'
- $redcloth_available = true
- rescue Exception
- puts
- puts "WARNING: RedCloth 3.x is required to build the VM html docs"
- puts "Run 'gem install redcloth' to install the latest RedCloth gem"
- puts
- $redcloth_available = false
+namespace :spec do
+ namespace :setup do
+ # Setup for 'Subtend' specs. No need to call this yourself.
+ task :subtend do
+ Dir["spec/subtend/**/Rakefile"].each do |rakefile|
+ sh "rake -f #{rakefile}"
+ end
end
end
- $redcloth_available
-end
-namespace "doc" do
- namespace "vm" do
+ desc "Run continuous integration examples"
+ task :ci do
+ target = ENV['SPEC_TARGET'] || 'rbx'
+ system %(shotgun/rubinius -e 'puts "rbx build: \#{Rubinius::BUILDREV}"') if target == 'rbx'
+ sh "bin/ci -t #{target}"
+ end
- desc "Remove all generated HTML files under doc/vm"
- task "clean" do
- Dir.glob('doc/vm/**/*.html').each do |html|
- rm_f html unless html =~ /\/?index.html$/
- end
+ spec_targets = %w(compiler core language library parser rubinius)
+ # Build a spec:<task_name> for each group of Rubinius specs
+ spec_targets.each do |group|
+ desc "Run #{group} examples"
+ task group do
+ sh "bin/mspec spec/#{group}"
end
+ end
- desc "Generate HTML in doc/vm from YAML and Textile sources"
- task "html"
-
- begin
- # Define tasks for each opcode html file on the corresponding YAML file
- require 'doc/vm/op_code_info'
- OpCode::Info.op_codes.each do |op|
- html = "doc/vm/op_codes/#{op}.html"
- yaml = "doc/vm/op_codes/#{op}.yaml"
- file html do
- cd 'doc/vm' do
- ruby "gen_op_code_html.rb #{op}"
- end
- end
- file html => yaml if File.exists?("doc/vm/op_codes/#{op}.yaml")
-
- task "html" => html
- end
+ desc "Run subtend (Rubinius C API) examples"
+ task :subtend => "spec:setup:subtend" do
+ sh "bin/mspec spec/rubinius/subtend"
+ end
- rescue LoadError
+ # Specdiffs to make it easier to see what your changes have affected :)
+ desc 'Run specs and produce a diff against current base'
+ task :diff => 'diff:run'
+ namespace :diff do
+ desc 'Run specs and produce a diff against current base'
+ task :run do
+ system 'bin/mspec -f ci -o spec/reports/specdiff.txt spec'
+ system 'diff -u spec/reports/base.txt spec/reports/specdiff.txt'
+ system 'rm spec/reports/specdiff.txt'
end
- # Define tasks for each section html file on the corresponding textile file
- # Note: requires redcloth gem to convert textile markup to html
- Dir.glob('doc/vm/*.textile').each do |f|
- html = f.chomp('.textile') + '.html'
- file html => f do
- if redcloth_present?
- section = File.basename(f)
- cd 'doc/vm' do
- ruby "gen_section_html.rb #{section}"
- end
- end
- end
-
- task "html" => html
+ desc 'Replace the base spec file with a new one'
+ task :replace do
+ system 'bin/mspec -f ci -o spec/reports/base.txt spec'
end
end
+
+ task :r2r do
+ puts ARGV.inspect
+ end
end
+# MISC TASKS
+
+desc "Build task for CruiseControl"
+task :ccrb => [:build, 'spec:ci']
+
View
77 rakelib/doc.rake
@@ -0,0 +1,77 @@
+$redcloth_available = nil
+
+begin
+ require 'rubygems'
+rescue LoadError
+ # Don't show RedCloth warning if gems aren't available
+ $redcloth_available = false
+end
+
+## Include tasks to build documentation
+def redcloth_present?
+ if $redcloth_available.nil?
+ begin
+ require 'redcloth'
+ $redcloth_available = true
+ rescue Exception
+ puts
+ puts "WARNING: RedCloth 3.x is required to build the VM html docs"
+ puts "Run 'gem install redcloth' to install the latest RedCloth gem"
+ puts
+ $redcloth_available = false
+ end
+ end
+ $redcloth_available
+end
+
+namespace "doc" do
+ namespace "vm" do
+
+ desc "Remove all generated HTML files under doc/vm"
+ task "clean" do
+ Dir.glob('doc/vm/**/*.html').each do |html|
+ rm_f html unless html =~ /\/?index.html$/
+ end
+ end
+
+ desc "Generate HTML in doc/vm from YAML and Textile sources"
+ task "html"
+
+ begin
+ # Define tasks for each opcode html file on the corresponding YAML file
+ require 'doc/vm/op_code_info'
+ OpCode::Info.op_codes.each do |op|
+ html = "doc/vm/op_codes/#{op}.html"
+ yaml = "doc/vm/op_codes/#{op}.yaml"
+ file html do
+ cd 'doc/vm' do
+ ruby "gen_op_code_html.rb #{op}"
+ end
+ end
+ file html => yaml if File.exists?("doc/vm/op_codes/#{op}.yaml")
+
+ task "html" => html
+ end
+
+ rescue LoadError
+
+ end
+
+ # Define tasks for each section html file on the corresponding textile file
+ # Note: requires redcloth gem to convert textile markup to html
+ Dir.glob('doc/vm/*.textile').each do |f|
+ html = f.chomp('.textile') + '.html'
+ file html => f do
+ if redcloth_present?
+ section = File.basename(f)
+ cd 'doc/vm' do
+ ruby "gen_section_html.rb #{section}"
+ end
+ end
+ end
+
+ task "html" => html
+ end
+ end
+end
+
View
103 rakelib/extensions.rake
@@ -0,0 +1,103 @@
+desc "Build extensions from lib/ext"
+task :extensions => %w[
+ build:shotgun
+ build:rbc
+
+ extension:digest_rmd160
+ extension:digest_md5
+ extension:digest_sha1
+ extension:digest_sha2
+
+ extension:syck
+ extension:zlib
+ extension:readline
+]
+
+namespace :extension do
+ task :digest_md5 => "lib/ext/digest/md5/md5.#{$dlext}"
+
+ file "lib/ext/digest/md5/md5.#{$dlext}" => FileList[
+ 'lib/ext/digest/md5/build.rb',
+ 'lib/ext/digest/md5/*.c',
+ 'lib/ext/digest/md5/*.h',
+ 'lib/ext/digest/defs.h',
+ ] do
+ compile 'lib/ext/digest/md5'
+ end
+
+ task :digest_rmd160 => "lib/ext/digest/rmd160/rmd160.#{$dlext}"
+
+ file "lib/ext/digest/rmd160/rmd160.#{$dlext}" => FileList[
+ 'lib/ext/digest/rmd160/build.rb',
+ 'lib/ext/digest/rmd160/*.c',
+ 'lib/ext/digest/rmd160/*.h',
+ 'lib/ext/digest/defs.h',
+ ] do
+ compile 'lib/ext/digest/rmd160'
+ end
+
+ task :digest_sha1 => "lib/ext/digest/sha1/sha1.#{$dlext}"
+
+ file "lib/ext/digest/sha1/sha1.#{$dlext}" => FileList[
+ 'lib/ext/digest/sha1/build.rb',
+ 'lib/ext/digest/sha1/*.c',
+ 'lib/ext/digest/sha1/*.h',
+ 'lib/ext/digest/defs.h',
+ ] do
+ compile 'lib/ext/digest/sha1'
+ end
+
+ task :digest_sha2 => "lib/ext/digest/sha2/sha2.#{$dlext}"
+
+ file "lib/ext/digest/sha2/sha2.#{$dlext}" => FileList[
+ 'lib/ext/digest/sha2/build.rb',
+ 'lib/ext/digest/sha2/*.c',
+ 'lib/ext/digest/sha2/*.h',
+ 'lib/ext/digest/defs.h',
+ ] do
+ compile 'lib/ext/digest/sha2'
+ end
+
+ task :syck => "lib/ext/syck/rbxext.#{$dlext}"
+
+ file "lib/ext/syck/rbxext.#{$dlext}" => FileList[
+ 'shotgun/lib/subtend/ruby.h',
+ 'lib/ext/syck/build.rb',
+ 'lib/ext/syck/*.c',
+ 'lib/ext/syck/*.h',
+ ] do
+ compile "lib/ext/syck"
+ end
+
+ task :mongrel => "lib/ext/mongrel/http11.#{$dlext}"
+
+ file "lib/ext/mongrel/http11.#{$dlext}" => FileList[
+ 'shotgun/lib/subtend/ruby.h',
+ 'lib/ext/mongrel/build.rb',
+ 'lib/ext/mongrel/*.c',
+ 'lib/ext/mongrel/*.h',
+ ] do
+ compile "lib/ext/mongrel"
+ end
+
+ task :zlib => %W[lib/ext/zlib/zlib.#{$dlext} lib/zlib.rb]
+
+ file "lib/ext/zlib/zlib.#{$dlext}" => FileList[
+ 'shotgun/lib/subtend/ruby.h',
+ 'lib/ext/zlib/build.rb',
+ 'lib/ext/zlib/*.c'
+ ] do
+ compile "lib/ext/zlib"
+ end
+
+ task :readline => %W[lib/ext/readline/readline.#{$dlext} lib/readline.rb]
+
+ file "lib/ext/readline/readline.#{$dlext}" => FileList[
+ 'shotgun/lib/subtend/ruby.h',
+ 'lib/ext/readline/build.rb',
+ 'lib/ext/readline/*.c'
+ ] do
+ compile "lib/ext/readline"
+ end
+end
+
View
537 rakelib/platform.rake
@@ -0,0 +1,537 @@
+file 'runtime/platform.conf' => %w[Rakefile rakelib/struct_generator.rb] do |task|
+ addrinfo = StructGenerator.new
+ addrinfo.include 'sys/socket.h'
+ addrinfo.include 'netdb.h'
+ addrinfo.name 'struct addrinfo'
+ addrinfo.field :ai_flags, :int
+ addrinfo.field :ai_family, :int
+ addrinfo.field :ai_socktype, :int
+ addrinfo.field :ai_protocol, :int
+ addrinfo.field :ai_addrlen, :int
+ addrinfo.field :ai_addr, :pointer
+ addrinfo.field :ai_canonname, :string
+ addrinfo.field :ai_next, :pointer
+ addrinfo.calculate
+
+ dirent = StructGenerator.new
+ dirent.include "dirent.h"
+ dirent.name 'struct dirent'
+ dirent_d_name = dirent.field :d_name
+ dirent.calculate
+
+ timeval = StructGenerator.new
+ timeval.include "sys/time.h"
+ timeval.name 'struct timeval'
+ timeval.field :tv_sec
+ timeval.field :tv_usec
+ timeval.calculate
+
+ sockaddr_in = StructGenerator.new
+ sockaddr_in.include "netinet/in.h"
+ sockaddr_in.include "fcntl.h"
+ sockaddr_in.include "sys/socket.h"
+ sockaddr_in.include "sys/stat.h"
+ sockaddr_in.name 'struct sockaddr_in'
+ sockaddr_in.field :sin_family
+ sockaddr_in.field :sin_port
+ sockaddr_in.field :sin_addr
+ sockaddr_in.field :sin_zero
+ sockaddr_in.calculate
+
+ sockaddr_un = StructGenerator.new
+ sockaddr_un.include "sys/un.h"
+ sockaddr_un.name 'struct sockaddr_un'
+ sockaddr_un.field :sun_family
+ sockaddr_un.field :sun_path
+ sockaddr_un.calculate
+
+ servent = StructGenerator.new
+ servent.include "netdb.h"
+ servent.name 'struct servent'
+ servent.field :s_name, :pointer
+ servent.field :s_aliases, :pointer
+ servent.field :s_port, :int
+ servent.field :s_proto, :pointer
+ servent.calculate
+
+ # FIXME these constants don't have standard names.
+ # LOCK_SH == Linux, O_SHLOCK on Bsd/Darwin, etc.
+ # Binary doesn't exist at all in many non-Unix variants.
+ # This should come out of something like config.h
+ fixme_constants = %w{
+ LOCK_SH
+ LOCK_EX
+ LOCK_NB
+ LOCK_UN
+ BINARY
+ }
+
+ file_constants = %w{
+ O_RDONLY
+ O_WRONLY
+ O_RDWR
+ O_CREAT
+ O_EXCL
+ O_NOCTTY
+ O_TRUNC
+ O_APPEND
+ O_NONBLOCK
+ O_SYNC
+ S_IRUSR
+ S_IWUSR
+ S_IXUSR
+ S_IRGRP
+ S_IWGRP
+ S_IXGRP
+ S_IROTH
+ S_IWOTH
+ S_IXOTH
+ }
+
+ io_constants = %w{
+ SEEK_SET
+ SEEK_CUR
+ SEEK_END
+ }
+
+ fcntl_constants = %w{
+ F_DUPFD
+ F_GETFD
+ F_GETLK
+ F_SETFD
+ F_GETFL
+ F_SETFL
+ F_SETLK
+ F_SETLKW
+ FD_CLOEXEC
+ F_RDLCK
+ F_UNLCK
+ F_WRLCK
+ O_CREAT
+ O_EXCL
+ O_NOCTTY
+ O_TRUNC
+ O_APPEND
+ O_NONBLOCK
+ O_NDELAY
+ O_RDONLY
+ O_RDWR
+ O_WRONLY
+ O_ACCMODE
+ }
+
+ socket_constants = %w[
+ AF_APPLETALK
+ AF_ATM
+ AF_AX25
+ AF_CCITT
+ AF_CHAOS
+ AF_CNT
+ AF_COIP
+ AF_DATAKIT
+ AF_DEC
+ AF_DLI
+ AF_E164
+ AF_ECMA
+ AF_HYLINK
+ AF_IMPLINK
+ AF_INET
+ AF_INET6
+ AF_IPX
+ AF_ISDN
+ AF_ISO
+ AF_LAT
+ AF_LINK
+ AF_LOCAL
+ AF_MAX
+ AF_NATM
+ AF_NDRV
+ AF_NETBIOS
+ AF_NETGRAPH
+ AF_NS
+ AF_OSI
+ AF_PPP
+ AF_PUP
+ AF_ROUTE
+ AF_SIP
+ AF_SNA
+ AF_SYSTEM
+ AF_UNIX
+ AF_UNSPEC
+
+ AI_ADDRCONFIG
+ AI_ALL
+ AI_CANONNAME
+ AI_DEFAULT
+ AI_MASK
+ AI_NUMERICHOST
+ AI_PASSIVE
+ AI_V4MAPPED
+ AI_V4MAPPED_CFG
+
+ EAI_ADDRFAMILY
+ EAI_AGAIN
+ EAI_BADFLAGS
+ EAI_BADHINTS
+ EAI_FAIL
+ EAI_FAMILY
+ EAI_MAX
+ EAI_MEMORY
+ EAI_NODATA
+ EAI_NONAME
+ EAI_PROTOCOL
+ EAI_SERVICE
+ EAI_SOCKTYPE
+ EAI_SYSTEM
+
+ INADDR_ALLHOSTS_GROUP
+ INADDR_ANY
+ INADDR_BROADCAST
+ INADDR_LOOPBACK
+ INADDR_MAX_LOCAL_GROUP
+ INADDR_NONE
+ INADDR_UNSPEC_GROUP
+
+ IPPORT_RESERVED
+ IPPORT_USERRESERVED
+
+ IPPROTO_BIP
+ IPPROTO_EGP
+ IPPROTO_EON
+ IPPROTO_GGP
+ IPPROTO_HELLO
+ IPPROTO_ICMP
+ IPPROTO_IDP
+ IPPROTO_IGMP
+ IPPROTO_IP
+ IPPROTO_MAX
+ IPPROTO_ND
+ IPPROTO_PUP
+ IPPROTO_RAW
+ IPPROTO_TCP
+ IPPROTO_TP
+ IPPROTO_UDP
+ IPPROTO_XTP
+
+ IPX_TYPE
+
+ IP_ADD_MEMBERSHIP
+ IP_DEFAULT_MULTICAST_LOOP
+ IP_DEFAULT_MULTICAST_TTL
+ IP_DROP_MEMBERSHIP
+ IP_HDRINCL
+ IP_MAX_MEMBERSHIPS
+ IP_MULTICAST_IF
+ IP_MULTICAST_LOOP
+ IP_MULTICAST_TTL
+ IP_OPTIONS
+ IP_RECVDSTADDR
+ IP_RECVOPTS
+ IP_RECVRETOPTS
+ IP_RETOPTS
+ IP_TOS
+ IP_TTL
+
+ MSG_COMPAT
+ MSG_CTRUNC
+ MSG_DONTROUTE
+ MSG_DONTWAIT
+ MSG_EOF
+ MSG_EOR
+ MSG_FLUSH
+ MSG_HAVEMORE
+ MSG_HOLD
+ MSG_OOB
+ MSG_PEEK
+ MSG_RCVMORE
+ MSG_SEND
+ MSG_TRUNC
+ MSG_WAITALL
+
+ NI_DGRAM
+ NI_MAXHOST
+ NI_MAXSERV
+ NI_NAMEREQD
+ NI_NOFQDN
+ NI_NUMERICHOST
+ NI_NUMERICSERV
+
+ PF_APPLETALK
+ PF_AX25
+ PF_CCITT
+ PF_CHAOS
+ PF_CNT
+ PF_COIP
+ PF_DATAKIT
+ PF_DLI
+ PF_ECMA
+ PF_HYLINK
+ PF_IMPLINK
+ PF_INET
+ PF_INET6
+ PF_IPX
+ PF_ISDN
+ PF_ISO
+ PF_KEY
+ PF_LAT
+ PF_LINK
+ PF_LOCAL
+ PF_MAX
+ PF_NATM
+ PF_NDRV
+ PF_NETBIOS
+ PF_NETGRAPH
+ PF_NS
+ PF_OSI
+ PF_PIP
+ PF_PPP
+ PF_PUP
+ PF_ROUTE
+ PF_RTIP
+ PF_SIP
+ PF_SNA
+ PF_SYSTEM
+ PF_UNIX
+ PF_UNSPEC
+ PF_XTP
+
+ SHUT_RD
+ SHUT_RDWR
+ SHUT_WR
+
+ SOCK_DGRAM
+ SOCK_PACKET
+ SOCK_RAW
+ SOCK_RDM
+ SOCK_SEQPACKET
+ SOCK_STREAM
+
+ SOL_ATALK
+ SOL_AX25
+ SOL_IP
+ SOL_IPX
+ SOL_SOCKET
+ SOL_TCP
+ SOL_UDP
+
+ SOPRI_BACKGROUND
+ SOPRI_INTERACTIVE
+ SOPRI_NORMAL
+
+ SO_ACCEPTCONN
+ SO_ACCEPTFILTER
+ SO_ATTACH_FILTER
+ SO_BINDTODEVICE
+ SO_BROADCAST
+ SO_DEBUG
+ SO_DETACH_FILTER
+ SO_DONTROUTE
+ SO_DONTTRUNC
+ SO_ERROR
+ SO_KEEPALIVE
+ SO_LINGER
+ SO_NKE
+ SO_NOSIGPIPE
+ SO_NO_CHECK
+ SO_NREAD
+ SO_OOBINLINE
+ SO_PASSCRED
+ SO_PEERCRED
+ SO_PEERNAME
+ SO_PRIORITY
+ SO_RCVBUF
+ SO_RCVLOWAT
+ SO_RCVTIMEO
+ SO_REUSEADDR
+ SO_REUSEPORT
+ SO_SECURITY_AUTHENTICATION
+ SO_SECURITY_ENCRYPTION_NETWORK
+ SO_SECURITY_ENCRYPTION_TRANSPORT
+ SO_SNDBUF
+ SO_SNDLOWAT
+ SO_SNDTIMEO
+ SO_TIMESTAMP
+ SO_TYPE
+ SO_USELOOPBACK
+ SO_WANTMORE
+ SO_WANTOOBFLAG
+
+ TCP_MAXSEG
+ TCP_NODELAY
+ ]
+
+ process_constants = %w{
+ WNOHANG
+ WUNTRACED
+ PRIO_PROCESS
+ PRIO_PGRP
+ PRIO_USER
+ RLIMIT_CPU
+ RLIMIT_FSIZE
+ RLIMIT_DATA
+ RLIMIT_STACK
+ RLIMIT_CORE
+ RLIMIT_RSS
+ RLIMIT_NPROC
+ RLIMIT_NOFILE
+ RLIMIT_MEMLOCK
+ RLIMIT_AS
+ RLIMIT_SBSIZE
+ }
+
+ long_process_constants = %w{
+ RLIM_INFINITY
+ RLIM_SAVED_MAX
+ RLIM_SAVED_CUR
+ }
+
+ # The constants come from MRI's signal.c. This means that some of them might
+ # be missing.
+ signal_constants = %w{
+ SIGHUP
+ SIGINT
+ SIGQUIT
+ SIGILL
+ SIGTRAP
+ SIGIOT
+ SIGABRT
+ SIGEMT
+ SIGFPE
+ SIGKILL
+ SIGBUS
+ SIGSEGV
+ SIGSYS
+ SIGPIPE
+ SIGALRM
+ SIGTERM
+ SIGURG
+ SIGSTOP
+ SIGTSTP
+ SIGCONT
+ SIGCHLD
+ SIGCLD
+ SIGCHLD
+ SIGTTIN
+ SIGTTOU
+ SIGIO
+ SIGXCPU
+ SIGXFSZ
+ SIGVTALRM
+ SIGPROF
+ SIGWINCH
+ SIGUSR1
+ SIGUSR2
+ SIGLOST
+ SIGMSG
+ SIGPWR
+ SIGPOLL
+ SIGDANGER
+ SIGMIGRATE
+ SIGPRE
+ SIGGRANT
+ SIGRETRACT
+ SIGSOUND
+ SIGINFO
+ }
+
+ cg = ConstGenerator.new
+ cg.include "stdio.h"
+ cg.include "fcntl.h"
+ cg.include "sys/types.h"
+ cg.include "sys/socket.h"
+ cg.include "netdb.h"
+ cg.include "sys/stat.h"
+ cg.include "sys/resource.h"
+ cg.include "netinet/tcp.h"
+ cg.include "signal.h"
+
+ file_constants.each { |c| cg.const c }
+ io_constants.each { |c| cg.const c }
+ fcntl_constants.each {|c| cg.const c }
+ socket_constants.each { |c| cg.const c }
+ process_constants.each { |c| cg.const c }
+ long_process_constants.each { |c| cg.const(c, "%llu") }
+ signal_constants.each { |c| cg.const c }
+ fcntl_constants.each { |c| cg.const c }
+
+ cg.calculate
+
+ puts "Generating #{task.name}..."
+
+ File.open task.name, "w" do |f|
+ f.puts addrinfo.generate_config('addrinfo')
+ f.puts "rbx.platform.dir.d_name = #{dirent_d_name.offset}"
+ f.puts timeval.generate_config('timeval')
+ f.puts sockaddr_in.generate_config('sockaddr_in')
+ f.puts sockaddr_un.generate_config('sockaddr_un') if sockaddr_un.found?
+ f.puts servent.generate_config('servent')
+
+ file_constants.each do | name |
+ const = cg.constants[name]
+ f.puts "rbx.platform.file.#{name} = #{const.converted_value}"
+ end
+
+ io_constants.each do |name|
+ const = cg.constants[name]
+ f.puts "rbx.platform.io.#{name} = #{const.converted_value}"
+ end
+
+ fcntl_constants.each do |name|
+ const = cg.constants[name]
+ next if const.converted_value.nil?
+ f.puts "rbx.platform.fcntl.#{name} = #{const.converted_value}"
+ end
+
+ socket_constants.each do |name|
+ const = cg.constants[name]
+ next if const.converted_value.nil?
+ f.puts "rbx.platform.socket.#{name} = #{const.converted_value}"
+ end
+
+ (process_constants + long_process_constants).each do |name|
+ const = cg.constants[name]
+ next if const.converted_value.nil?
+ f.puts "rbx.platform.process.#{name} = #{const.converted_value}"
+ end
+
+ signal_constants.each do |name|
+ const = cg.constants[name]
+ next if const.converted_value.nil?
+ f.puts "rbx.platform.signal.#{name} = #{const.converted_value}"
+ end
+ end
+end
+
+file 'lib/rbconfig.rb' => %w[config_env Rakefile] do
+ rbconfig = <<-EOF
+#--
+# This file was generated by the rubinius Rakefile.
+#++
+
+module Config
+
+ CONFIG = {}
+
+ CONFIG['DLEXT'] = Rubinius::LIBSUFFIX.dup
+ CONFIG['EXEEXT'] = ""
+ CONFIG['RUBY_SO_NAME'] = "rubinius-#\{Rubinius::RBX_VERSION}"
+ CONFIG['arch'] = RUBY_PLATFORM.dup
+ CONFIG['bindir'] = "#{ENV['BINPATH']}"
+ CONFIG['datadir'] = "#{File.join ENV['PREFIX'], 'share'}"
+ CONFIG['libdir'] = "#{ENV['LIBPATH']}"
+ CONFIG['ruby_install_name'] = "#{ENV['ENGINE']}"
+ CONFIG['ruby_version'] = Rubinius::RUBY_VERSION.dup
+ CONFIG['sitedir'] = "#{File.join ENV['LIBPATH'], 'rubinius'}"
+ CONFIG['sitelibdir'] = "#{ENV['CODEPATH']}"
+ CONFIG['wordsize'] = Rubinius::WORDSIZE
+
+end
+
+RbConfig = Config
+EOF
+
+ File.open 'lib/rbconfig.rb', 'w' do |fp|
+ fp.write rbconfig
+ end
+end
+

0 comments on commit cc28068

Please sign in to comment.
Something went wrong with that request. Please try again.