/
Rakefile
1032 lines (883 loc) · 22 KB
/
Rakefile
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# NOTE! When updating this file, also update INSTALL, if necessary.
# NOTE! Please keep your tasks grouped together.
$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"
task :build => 'build:all'
task :stable_compiler do
if ENV['USE_CURRENT']
puts "Use current versions, not stable."
else
ENV['RBX_BOOTSTRAP'] = "runtime/stable/bootstrap.rba"
ENV['RBX_CORE'] = "runtime/stable/core.rba"
ENV['RBX_LOADER'] = "runtime/stable/loader.rbc"
ENV['RBX_PLATFORM'] = "runtime/stable/platform.rba"
end
end
rule ".rbc" => %w[.rb] do |t|
compile t.source, t.name
end
files = FileList['kernel/core/*.rb']
unless files.include?("kernel/core/dir.rb")
files.add("kernel/core/dir.rb")
end
Core = CodeGroup.new(files, 'runtime/core', 'core')
Bootstrap = CodeGroup.new 'kernel/bootstrap/*.rb', 'runtime/bootstrap',
'bootstrap'
PlatformFiles = CodeGroup.new 'kernel/platform/*.rb', 'runtime/platform', 'platform'
file 'runtime/loader.rbc' => 'kernel/loader.rb' do
compile 'kernel/loader.rb', 'runtime/loader.rbc'
end
file 'runtime/stable/loader.rbc' => 'runtime/loader.rbc' do
cp 'runtime/loader.rbc', 'runtime/stable', :verbose => $verbose
end
file 'runtime/stable/compiler.rba' => 'build:compiler' do
sh "cd lib; zip -r ../runtime/stable/compiler.rba compiler -x \\*.rb"
end
Rake::StructGeneratorTask.new do |t|
t.dest = "lib/etc.rb"
end
Rake::StructGeneratorTask.new do |t|
t.dest = 'lib/zlib.rb'
end
AllPreCompiled = Core.output + Bootstrap.output + PlatformFiles.output
AllPreCompiled << "runtime/loader.rbc"
namespace :build do
task :all => %w[
build:shotgun
build:platform
build:rbc
compiler
lib/etc.rb
lib/rbconfig.rb
extensions
]
# This nobody rule lets use use all the shotgun files as
# prereqs. This rule is run for all those prereqs and just
# (obviously) does nothing, but it makes rake happy.
rule '^shotgun/.+'
c_source = FileList[
"shotgun/config.h",
"shotgun/lib/*.[chy]",
"shotgun/lib/*.rb",
"shotgun/lib/subtend/*.[chS]",
"shotgun/main.c",
].exclude(/auto/, /instruction_names/, /node_types/, /grammar.c/)
file "shotgun/rubinius.bin" => c_source do
sh make('vm')
end
file 'shotgun/mkconfig.sh' => 'configure'
file 'shotgun/config.mk' => %w[shotgun/config.h shotgun/mkconfig.sh shotgun/vars.mk]
file 'shotgun/config.h' => %w[shotgun/mkconfig.sh shotgun/vars.mk] do
sh "./configure"
raise 'Failed to configure Rubinius' unless $?.success?
end
desc "Compiles shotgun (the C-code VM)"
task :shotgun => %w[configure shotgun/rubinius.bin]
task :setup_rbc => :stable_compiler
task :rbc => ([:setup_rbc] + AllPreCompiled)
task :compiler => :stable_compiler do
compile_dir "lib/compiler"
end
desc "Rebuild runtime/stable/*. If you don't know why you're running this, don't."
task :stable => %w[
build:all
runtime/stable/bootstrap.rba
runtime/stable/core.rba
runtime/stable/compiler.rba
runtime/stable/loader.rbc
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
end
namespace :vm do
task "clean" do
sh "cd shotgun/lib; make clean"
end
task "dev" do
sh "cd shotgun/lib; make DEV=1"
end
end
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
]
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
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
# MISC TASKS
desc "Build task for CruiseControl"
task :ccrb => [:build, '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
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"