Module: Teapot::Build::Targets::Compiler
- Included in:
- Library
- Defined in:
- lib/teapot/build/targets/compiler.rb
Instance Method Summary collapse
- #build_prefix!(environment) ⇒ Object
- #compile(environment, root, source_file, commands) ⇒ Object
- #link_prefix!(environment) ⇒ Object
Instance Method Details
#build_prefix!(environment) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/teapot/build/targets/compiler.rb', line 27 def build_prefix!(environment) build_prefix = Pathname.new(environment[:build_prefix]) + "compiled" build_prefix.mkpath return build_prefix end |
#compile(environment, root, source_file, commands) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/teapot/build/targets/compiler.rb', line 43 def compile(environment, root, source_file, commands) object_file = (build_prefix!(environment) + source_file).sub_ext('.o') # Ensure there is a directory for the output file: object_file.dirname.mkpath case source_file.extname when ".cpp", ".mm" commands.run( environment[:cxx], environment[:cxxflags], "-c", root + source_file, "-o", object_file ) when ".c", ".m" commands.run( environment[:cc], environment[:cflags], "-c", root + source_file, "-o", object_file ) end return Array object_file end |
#link_prefix!(environment) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/teapot/build/targets/compiler.rb', line 35 def link_prefix!(environment) prefix = Pathname.new(environment[:build_prefix]) + "linked" prefix.mkpath return prefix end |