3 # Ruby program to generate config.rb
5 default_architecture
= ENV['DEFAULT_ARCHITECTURE']
6 default_format
= ENV['DEFAULT_FORMAT']
7 gas_command
= ENV['GAS'] || 'as'
8 nasm_command
= ENV['NASM'] || ENV['YASM'] || 'nasm'
9 version = open(File
.join(File
.dirname(__FILE__
), '..', '..', 'VERSION')) { |f
|
14 # Methods to get and set configuration parameters
16 IMPLEMENTATION_NAME = 'Voodoo Compiler'
17 IMPLEMENTATION_VERSION = '#{version.chop}'
19 # Class that holds configuration parameters
22 @default_architecture = #{default_architecture.to_sym.inspect}
23 @default_format = #{default_format.to_sym.inspect}
24 @gas_command = #{gas_command.inspect}
25 @nasm_command = #{nasm_command.inspect}
28 attr_accessor :default_format,
32 attr_writer :default_architecture
34 # Returns the default architecture for this compiler
35 def default_architecture
36 if @default_architecture == :auto
37 # If @default_architecture has been set to :auto,
38 # return the host architecture, falling back to :i386
39 # if the host architecture cannot be determined
40 host_architecture || :i386
46 # Returns the architecture of the machine running the program,
47 # or nil if that architecture cannot be determined
49 arch, = RUBY_PLATFORM.split '-'
51 when 'x86_64', 'amd64'
67 DEFAULT_CONFIGURATION = Configuration.new
73 [:default_architecture,
80 DEFAULT_CONFIGURATION.#{symbol}
84 DEFAULT_CONFIGURATION.#{symbol} = value