-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
79 lines (65 loc) · 2.17 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
require 'erb'
require 'yaml'
require 'rake/clean'
require 'rake/loaders/makefile'
RELEASE_NAME = "kyushu"
RELEASE_MAJOR = 0
RELEASE_MINOR = 1
RELEASE_MICRO = 0
Dir.glob( './scripts/**/*.rake' ).each { |rake_ext| import rake_ext }
# rake defaults
task :default => :kernel
desc "Build hotarubi.elf"
task :kernel => 'hotarubi.elf' do
puts "Ready."
end
# collect sources and options files
GENERATED = FileList.new( 'kernel/**/*.erb' ).map{ |name| name.sub( '.erb', '' ) }
SOURCES = FileList.new( 'kernel/**/*.c', 'kernel/**/*.cc', 'kernel/**/*.S' )
SOURCES_64 = FileList.new( SOURCES )
SOURCES_32 = FileList.new
OBJECTS = SOURCES.ext( '.o' )
DEPENDS = SOURCES.ext( '.d' )
# split sources into 64bit and 32bit
Dir.glob( 'kernel/**/options.yaml' ).each do |option_file|
{ :sources_32 => [] }.merge( YAML::load_file( option_file ) )[ :sources_32 ].each do |src|
SOURCES_32 << SOURCES_64.delete( "#{File.dirname( option_file )}/#{src}" )
end
end
# file targets for kernel and *.o
file 'hotarubi.elf' => [ *OBJECTS, 'Rakefile', 'scripts/link.ld' ] do |t|
cc_link( OBJECTS, t.name.ext( '.elf64' ), :kernel => true )
cc_64to32( t.name.ext( '.elf64' ), t.name, :cleanup => true )
end
SOURCES_64.each do |src|
file src.ext( '.o' ) => [ src, 'Rakefile' ] do |t|
cc_compile( src, t.name )
end
end
SOURCES_32.each do |src|
file src.ext( '.o' ) => [ src, 'Rakefile' ] do |t|
cc_compile( src, t.name, :use32 => true )
end
end
GENERATED.each do |t|
file t => [ "#{t}.erb", 'Rakefile' ]
end
unless Rake.application.top_level_tasks.join( ' ' ) =~ /^(toolchain[:\/].*|travis:prepare|clean)/
# include autogenerated depends
file '.depends.mf' => [ 'templates:check', *GENERATED, *DEPENDS ] do |t|
unless uptodate? t.name, t.prerequisites[1..-1]
puts "GEN #{t.name}"
sh "cat #{t.prerequisites[1..-1].join( ' ' )} > #{t.name}", :verbose => false
end
end
import '.depends.mf'
end
CLEAN.include( 'kernel/**/*.d' )
CLEAN.include( 'kernel/**/*.o' )
CLEAN.include( '**/*.o32' )
CLEAN.include( '**/*.o64' )
CLEAN.include( '**/*.elf32' )
CLEAN.include( '**/*.elf64' )
CLEAN.include( '.depends.mf' )
CLOBBER.include( 'hotarubi.elf' )
CLOBBER.include( 'Symbols.map' )