-
Notifications
You must be signed in to change notification settings - Fork 1
/
common.rb
66 lines (56 loc) · 1.42 KB
/
common.rb
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
require "#{File.dirname(__FILE__)}/config.rb"
require File.expand_path(ENV['MOSYNCDIR']+'/rules/cLib.rb')
require File.expand_path(ENV['MOSYNCDIR']+'/rules/cExe.rb')
class GenTask < FileTask
def initialize(src, extraPrereqs = [])
@src = src
@dst = src.ext('.c')
@prerequisites = [FileTask.new(@src)] + extraPrereqs
super(@dst)
end
end
class YaccTask < GenTask
def fileExecute
sh "bison -y -o #{@dst} #{@src}"
end
end
class FlexTask < GenTask
def fileExecute
sh "flex -o #{@dst} #{@src}"
end
end
class ConfigHeaderTask < CopyFileTask
def initialize()
super('../config.h', FileTask.new('../config.h.example'))
end
end
module BinutilsModule
def initialize(compilerModule = DefaultCCompilerModule, &block)
@compilerModule = compilerModule
extend compilerModule
setCompilerVersion
@REQUIREMENTS ||= []
@REQUIREMENTS << ConfigHeaderTask.new()
@EXTRA_INCLUDES ||= []
@EXTRA_INCLUDES += ['../include', '..']
@EXTRA_CFLAGS ||= ''
@EXTRA_CFLAGS << ' -Wno-declaration-after-statement'
@EXTRA_CFLAGS << ' -DARCH_SIZE=32'
@EXTRA_CFLAGS << ' -Wno-c++-compat' if(@GCC_V4_SUB >= 5)
if(HOST == :darwin)
@EXTRA_INCLUDES << '/opt/local/include'
@EXTRA_CFLAGS << ' -Wno-unreachable-code'
end
super
end
end
class BinutilsLibWork < LibWork
include BinutilsModule
end
class BinutilsExeWork < ExeWork
include BinutilsModule
def initialize
@INSTALLDIR = CONFIG_INSTALLDIR if(CONFIG_INSTALLDIR)
super
end
end