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
- #compile!(environment, root, source_file, object_file, commands) ⇒ Object
- #link_prefix!(environment) ⇒ Object
Instance Method Details
#build_prefix!(environment) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/teapot/build/targets/compiler.rb', line 29 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
68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/teapot/build/targets/compiler.rb', line 68 def compile(environment, root, source_file, commands) object_file = (build_prefix!(environment) + source_file).sub_ext('.o') # The graph is recreated once per file. This could be improved. graph = Build::dependency_graph(environment) if graph.regenerate?(object_file, root + source_file) compile!(environment, root, source_file, object_file, commands) end return object_file end |
#compile!(environment, root, source_file, object_file, commands) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/teapot/build/targets/compiler.rb', line 45 def compile!(environment, root, source_file, object_file, commands) # Ensure there is a directory for the output file: object_file.dirname.mkpath # Make sure there is no pre-existing object file object_file.rmtree if object_file.exist? 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 end |
#link_prefix!(environment) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/teapot/build/targets/compiler.rb', line 37 def link_prefix!(environment) prefix = Pathname.new(environment[:build_prefix]) + "linked" prefix.mkpath return prefix end |