Change source file extension
This commit is contained in:
parent
94f7fe3f0e
commit
c6a540000a
56
Rakefile
56
Rakefile
@ -3,42 +3,45 @@ require 'rake/clean'
|
|||||||
require 'open3'
|
require 'open3'
|
||||||
|
|
||||||
M2C = 'gm2' # Modula-2 compiler.
|
M2C = 'gm2' # Modula-2 compiler.
|
||||||
BOOT_OBJECTS = FileList['boot/*.mod']
|
BOOT_OBJECTS = FileList['source/*.elna']
|
||||||
.map do |source|
|
.map do |source|
|
||||||
Pathname.new(source).basename.sub_ext('.o')
|
Pathname.new(source).basename.sub_ext('.o')
|
||||||
end
|
end
|
||||||
|
|
||||||
def source_for_object(out_file)
|
|
||||||
path = Pathname.new(out_file).relative_path_from('build')
|
|
||||||
result = ['build/boot']
|
|
||||||
|
|
||||||
definition = File.join('boot', path.basename.sub_ext('.def'))
|
|
||||||
result << definition if File.exist? definition
|
|
||||||
|
|
||||||
implementation = path.sub_ext('.mod').to_path
|
|
||||||
implementation = File.join 'build', implementation unless File.exist? implementation
|
|
||||||
|
|
||||||
result << implementation
|
|
||||||
end
|
|
||||||
|
|
||||||
directory 'build/boot'
|
directory 'build/boot'
|
||||||
directory 'build/self'
|
directory 'build/self'
|
||||||
|
|
||||||
CLEAN.include 'build'
|
CLEAN.include 'build'
|
||||||
|
|
||||||
rule(/build\/.+\.o$/ => ->(file) { source_for_object(file) }) do |t|
|
rule(/build\/boot\/.+\.o$/ => ->(file) {
|
||||||
|
path = Pathname.new('source') + Pathname.new(file).basename
|
||||||
|
|
||||||
|
['build/boot', path.sub_ext('.def'), path.sub_ext('.elna')]
|
||||||
|
}) do |t|
|
||||||
|
sources = t.prerequisites.filter { |f| f.end_with? '.elna' }
|
||||||
|
|
||||||
|
sh M2C, '-fmod=.elna', '-c', '-I', 'source', '-o', t.name, *sources
|
||||||
|
end
|
||||||
|
|
||||||
|
rule(/build\/self\/.+\.o$/ => ->(file) {
|
||||||
|
path = Pathname.new(file).relative_path_from('build')
|
||||||
|
result = []
|
||||||
|
|
||||||
|
result << File.join('source', path.basename.sub_ext('.def'))
|
||||||
|
result << File.join('build', path.sub_ext('.mod'))
|
||||||
|
}) do |t|
|
||||||
sources = t.prerequisites.filter { |f| f.end_with? '.mod' }
|
sources = t.prerequisites.filter { |f| f.end_with? '.mod' }
|
||||||
|
|
||||||
sh M2C, '-c', '-I', 'boot', '-o', t.name, *sources
|
sh M2C, '-c', '-I', 'source', '-o', t.name, *sources
|
||||||
end
|
end
|
||||||
|
|
||||||
rule(/build\/self\/.+\.mod$/ => [
|
rule(/build\/self\/.+\.mod$/ => [
|
||||||
'build/self', 'build/boot/Compiler',
|
'build/self', 'build/boot/Compiler',
|
||||||
->(file) { File.join('boot', Pathname.new(file).basename) }
|
->(file) { File.join('source', Pathname.new(file).basename.sub_ext('.elna')) }
|
||||||
]) do |t|
|
]) do |t|
|
||||||
sources, compiler = t.prerequisites
|
sources, compiler = t.prerequisites
|
||||||
.reject { |f| File.directory? f }
|
.reject { |f| File.directory? f }
|
||||||
.partition { |f| f.end_with? '.mod' }
|
.partition { |f| f.end_with? '.elna' }
|
||||||
|
|
||||||
File.open t.name, 'w' do |output|
|
File.open t.name, 'w' do |output|
|
||||||
puts
|
puts
|
||||||
@ -62,16 +65,23 @@ end
|
|||||||
end
|
end
|
||||||
|
|
||||||
compiler_object = compiler_binary.sub_ext('.o')
|
compiler_object = compiler_binary.sub_ext('.o')
|
||||||
file compiler_object.to_path => source_for_object(compiler_object) do |t|
|
end
|
||||||
sources = t.prerequisites.filter { |f| f.end_with? '.mod' }
|
|
||||||
|
|
||||||
sh M2C, '-fscaffold-main', '-c', '-I', 'boot', '-o', t.name, *sources
|
file 'build/boot/Compiler.o' => ['build/boot', 'source/Compiler.elna'] do |t|
|
||||||
end
|
sources = t.prerequisites.filter { |f| f.end_with? '.elna' }
|
||||||
|
|
||||||
|
sh M2C, '-fscaffold-main', '-fmod=.elna', '-c', '-I', 'source', '-o', t.name, *sources
|
||||||
|
end
|
||||||
|
|
||||||
|
file 'build/self/Compiler.o' => ['build/self/Compiler.mod'] do |t|
|
||||||
|
sources = t.prerequisites.filter { |f| f.end_with? '.mod' }
|
||||||
|
|
||||||
|
sh M2C, '-fscaffold-main', '-c', '-I', 'source', '-o', t.name, *sources
|
||||||
end
|
end
|
||||||
|
|
||||||
task default: 'build/self/Compiler'
|
task default: 'build/self/Compiler'
|
||||||
task default: 'build/self/Compiler.mod'
|
task default: 'build/self/Compiler.mod'
|
||||||
task default: 'boot/Compiler.mod'
|
task default: 'source/Compiler.elna'
|
||||||
task :default do |t|
|
task :default do |t|
|
||||||
exe, previous_output, source = t.prerequisites
|
exe, previous_output, source = t.prerequisites
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user