Class: Rscons::Builders::Program
- Inherits:
-
Rscons::Builder
- Object
- Rscons::Builder
- Rscons::Builders::Program
- Defined in:
- lib/rscons/builders/program.rb
Overview
A default Rscons builder that knows how to link object files into an executable program.
Instance Method Summary collapse
-
#create_build_target(options) ⇒ BuildTarget
Create a BuildTarget object for this build target.
-
#default_variables(env) ⇒ Hash
Return default construction variables for the builder.
-
#finalize(options) ⇒ String?
Finalize a build.
-
#run(options) ⇒ String, false
Run the builder to produce a build target.
-
#setup(options) ⇒ Object
Set up a build operation using this builder.
Methods inherited from Rscons::Builder
#features, #name, #produces?, #standard_build, #standard_finalize, #standard_threaded_build
Instance Method Details
#create_build_target(options) ⇒ BuildTarget
Create a BuildTarget object for this build target.
The build target filename is given a “.exe” suffix if Rscons is executing on a Windows platform and no other suffix is given.
41 42 43 44 45 46 47 48 |
# File 'lib/rscons/builders/program.rb', line 41 def create_build_target() env, target, vars = .values_at(:env, :target, :vars) = .dup unless File.basename(target)["."] [:target] += env.("${PROGSUFFIX}", vars) end super() end |
#default_variables(env) ⇒ Hash
Return default construction variables for the builder.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/rscons/builders/program.rb', line 12 def default_variables(env) { 'OBJSUFFIX' => '.o', 'PROGSUFFIX' => (Object.const_get("RUBY_PLATFORM") =~ /mingw|cygwin/ ? ".exe" : ""), 'LD' => nil, 'LIBSUFFIX' => '.a', 'LDFLAGS' => [], 'LIBPATH' => [], 'LIBDIRPREFIX' => '-L', 'LIBLINKPREFIX' => '-l', 'LIBS' => [], 'LDCMD' => ['${LD}', '-o', '${_TARGET}', '${LDFLAGS}', '${_SOURCES}', '${LIBDIRPREFIX}${LIBPATH}', '${LIBLINKPREFIX}${LIBS}'] } end |
#finalize(options) ⇒ String?
Finalize a build.
99 100 101 |
# File 'lib/rscons/builders/program.rb', line 99 def finalize() standard_finalize() end |
#run(options) ⇒ String, false
Run the builder to produce a build target.
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/rscons/builders/program.rb', line 70 def run() target, sources, cache, env, vars, objects = .values_at(:target, :sources, :cache, :env, :vars, :setup_info) ld = env.("${LD}", vars) ld = if ld != "" ld elsif sources.find {|s| s.end_with?(*env.("${DSUFFIX}", vars))} "${DC}" elsif sources.find {|s| s.end_with?(*env.("${CXXSUFFIX}", vars))} "${CXX}" else "${CC}" end vars = vars.merge({ '_TARGET' => target, '_SOURCES' => objects, 'LD' => ld, }) [:sources] = objects command = env.build_command("${LDCMD}", vars) standard_threaded_build("LD #{target}", target, command, objects, env, cache) end |
#setup(options) ⇒ Object
Set up a build operation using this builder.
57 58 59 60 61 62 |
# File 'lib/rscons/builders/program.rb', line 57 def setup() target, sources, env, vars = .values_at(:target, :sources, :env, :vars) suffixes = env.(["${OBJSUFFIX}", "${LIBSUFFIX}"], vars) # Register builders to build each source to an object file or library. env.register_builds(target, sources, suffixes, vars) end |