Add intermediate assembler representation
This commit is contained in:
23
Rakefile
23
Rakefile
@ -17,18 +17,25 @@ directory 'build'
|
||||
CLEAN.include 'build'
|
||||
CLEAN.include '.dub'
|
||||
|
||||
rule(/build\/tests\/[^\/\.]+$/ => ->(file) { test_for_out(file) }) do |t|
|
||||
sh 'gcc', '-o', t.name, "#{t.name}.o"
|
||||
rule(/build\/tests\/[^\/\.]+$/ => ->(file) { test_for_out(file, '.o') }) do |t|
|
||||
sh 'ld.gold', '-L/usr/lib64',
|
||||
'--dynamic-linker', '/lib64/ld-linux-x86-64.so.2',
|
||||
'-o', t.name,
|
||||
'/usr/lib64/crt1.o', '/usr/lib64/crti.o', '-lc', t.source, '/usr/lib64/crtn.o'
|
||||
end
|
||||
|
||||
rule(/build\/asm\/[^\/\.]+$/ => ->(file) { test_for_object(file) }) do |t|
|
||||
Pathname.new(t.name).dirname.mkpath
|
||||
Open3.pipeline [BINARY, t.source], ['gcc', '-x', 'assembler', '-o', t.name, '-']
|
||||
rule(/build\/asm\/[^\/\.]+$/ => ->(file) { test_for_out(file, '.s') }) do |t|
|
||||
sh 'gcc', '-x', 'assembler', '-o', t.name, t.source
|
||||
end
|
||||
|
||||
rule(/build\/tests\/.+\.o$/ => ->(file) { test_for_object(file) }) do |t|
|
||||
Pathname.new(t.name).dirname.mkpath
|
||||
sh BINARY, t.source
|
||||
sh BINARY, '-o', t.name, t.source
|
||||
end
|
||||
|
||||
rule(/build\/asm\/.+\.s$/ => ->(file) { test_for_object(file) }) do |t|
|
||||
Pathname.new(t.name).dirname.mkpath
|
||||
sh BINARY, '-s', '-o', t.name, t.source
|
||||
end
|
||||
|
||||
file BINARY => SOURCES do |t|
|
||||
@ -70,9 +77,9 @@ def test_for_object(out_file)
|
||||
[test_source, BINARY]
|
||||
end
|
||||
|
||||
def test_for_out(out_file)
|
||||
def test_for_out(out_file, extension)
|
||||
Pathname
|
||||
.new(out_file)
|
||||
.sub_ext('.o')
|
||||
.sub_ext(extension)
|
||||
.to_path
|
||||
end
|
||||
|
Reference in New Issue
Block a user