rscons 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/rscons/builder.rb +15 -0
- data/lib/rscons/builders/library.rb +4 -9
- data/lib/rscons/builders/object.rb +14 -12
- data/lib/rscons/builders/program.rb +4 -8
- data/lib/rscons/environment.rb +4 -3
- data/lib/rscons/version.rb +1 -1
- metadata +4 -4
data/lib/rscons/builder.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require "fileutils"
|
2
|
+
|
1
3
|
module Rscons
|
2
4
|
# Class to hold an object that knows how to build a certain type of file.
|
3
5
|
class Builder
|
@@ -16,5 +18,18 @@ module Rscons
|
|
16
18
|
def produces?(target, source, env)
|
17
19
|
false
|
18
20
|
end
|
21
|
+
|
22
|
+
# Check if the cache is up to date for the target and if not execute the
|
23
|
+
# build command.
|
24
|
+
# Return the name of the target or false on failure.
|
25
|
+
def standard_build(short_cmd_string, target, command, sources, env, cache)
|
26
|
+
unless cache.up_to_date?(target, command, sources)
|
27
|
+
FileUtils.mkdir_p(File.dirname(target))
|
28
|
+
FileUtils.rm_f(target)
|
29
|
+
return false unless env.execute(short_cmd_string, command)
|
30
|
+
cache.register_build(target, command, sources)
|
31
|
+
end
|
32
|
+
target
|
33
|
+
end
|
19
34
|
end
|
20
35
|
end
|
@@ -8,7 +8,7 @@ module Rscons
|
|
8
8
|
'AR' => 'ar',
|
9
9
|
'LIBSUFFIX' => '.a',
|
10
10
|
'ARFLAGS' => [],
|
11
|
-
'ARCOM' => ['$AR', 'rcs', '$ARFLAGS', '$
|
11
|
+
'ARCOM' => ['$AR', 'rcs', '$ARFLAGS', '$_TARGET', '$_SOURCES']
|
12
12
|
}
|
13
13
|
end
|
14
14
|
|
@@ -17,16 +17,11 @@ module Rscons
|
|
17
17
|
objects = env.build_sources(sources, [env['OBJSUFFIX'], env['LIBSUFFIX']].flatten, cache, vars)
|
18
18
|
if objects
|
19
19
|
vars = vars.merge({
|
20
|
-
'
|
21
|
-
'
|
20
|
+
'_TARGET' => target,
|
21
|
+
'_SOURCES' => objects,
|
22
22
|
})
|
23
23
|
command = env.build_command(env['ARCOM'], vars)
|
24
|
-
|
25
|
-
FileUtils.rm_f(target)
|
26
|
-
return false unless env.execute("AR #{target}", command)
|
27
|
-
cache.register_build(target, command, objects)
|
28
|
-
end
|
29
|
-
target
|
24
|
+
standard_build("AR #{target}", target, command, objects, env, cache)
|
30
25
|
end
|
31
26
|
end
|
32
27
|
end
|
@@ -11,8 +11,8 @@ module Rscons
|
|
11
11
|
'ASSUFFIX' => '.S',
|
12
12
|
'ASPPPATH' => '$CPPPATH',
|
13
13
|
'ASPPFLAGS' => '$CPPFLAGS',
|
14
|
-
'ASDEPGEN' => ['-MMD', '-MF', '$
|
15
|
-
'ASCOM' => ['$AS', '-c', '-o', '$
|
14
|
+
'ASDEPGEN' => ['-MMD', '-MF', '$_DEPFILE'],
|
15
|
+
'ASCOM' => ['$AS', '-c', '-o', '$_TARGET', '$ASDEPGEN', '-I$[ASPPPATH]', '$ASPPFLAGS', '$ASFLAGS', '$_SOURCES'],
|
16
16
|
|
17
17
|
'CPPFLAGS' => [],
|
18
18
|
'CPPPATH' => [],
|
@@ -20,14 +20,14 @@ module Rscons
|
|
20
20
|
'CC' => 'gcc',
|
21
21
|
'CFLAGS' => [],
|
22
22
|
'CSUFFIX' => '.c',
|
23
|
-
'CCDEPGEN' => ['-MMD', '-MF', '$
|
24
|
-
'CCCOM' => ['$CC', '-c', '-o', '$
|
23
|
+
'CCDEPGEN' => ['-MMD', '-MF', '$_DEPFILE'],
|
24
|
+
'CCCOM' => ['$CC', '-c', '-o', '$_TARGET', '$CCDEPGEN', '-I$[CPPPATH]', '$CPPFLAGS', '$CFLAGS', '$_SOURCES'],
|
25
25
|
|
26
26
|
'CXX' => 'g++',
|
27
27
|
'CXXFLAGS' => [],
|
28
28
|
'CXXSUFFIX' => '.cc',
|
29
|
-
'CXXDEPGEN' => ['-MMD', '-MF', '$
|
30
|
-
'CXXCOM' =>['$CXX', '-c', '-o', '$
|
29
|
+
'CXXDEPGEN' => ['-MMD', '-MF', '$_DEPFILE'],
|
30
|
+
'CXXCOM' =>['$CXX', '-c', '-o', '$_TARGET', '$CXXDEPGEN', '-I$[CPPPATH]', '$CPPFLAGS', '$CXXFLAGS', '$_SOURCES'],
|
31
31
|
}
|
32
32
|
end
|
33
33
|
|
@@ -40,9 +40,9 @@ module Rscons
|
|
40
40
|
|
41
41
|
def run(target, sources, cache, env, vars = {})
|
42
42
|
vars = vars.merge({
|
43
|
-
'
|
44
|
-
'
|
45
|
-
'
|
43
|
+
'_TARGET' => target,
|
44
|
+
'_SOURCES' => sources,
|
45
|
+
'_DEPFILE' => target.set_suffix('.mf'),
|
46
46
|
})
|
47
47
|
com_prefix = if sources.first.has_suffix?(env['ASSUFFIX'])
|
48
48
|
'AS'
|
@@ -55,11 +55,13 @@ module Rscons
|
|
55
55
|
end
|
56
56
|
command = env.build_command(env["#{com_prefix}COM"], vars)
|
57
57
|
unless cache.up_to_date?(target, command, sources)
|
58
|
+
FileUtils.mkdir_p(File.dirname(target))
|
59
|
+
FileUtils.rm_f(target)
|
58
60
|
return false unless env.execute("#{com_prefix} #{target}", command)
|
59
61
|
deps = sources
|
60
|
-
if File.exists?(vars['
|
61
|
-
deps += env.parse_makefile_deps(vars['
|
62
|
-
FileUtils.rm_f(vars['
|
62
|
+
if File.exists?(vars['_DEPFILE'])
|
63
|
+
deps += env.parse_makefile_deps(vars['_DEPFILE'], target)
|
64
|
+
FileUtils.rm_f(vars['_DEPFILE'])
|
63
65
|
end
|
64
66
|
cache.register_build(target, command, deps.uniq)
|
65
67
|
end
|
@@ -10,7 +10,7 @@ module Rscons
|
|
10
10
|
'LDFLAGS' => [],
|
11
11
|
'LIBPATH' => [],
|
12
12
|
'LIBS' => [],
|
13
|
-
'LDCOM' => ['$LD', '-o', '$
|
13
|
+
'LDCOM' => ['$LD', '-o', '$_TARGET', '$LDFLAGS', '$_SOURCES', '-L$[LIBPATH]', '-l$[LIBS]']
|
14
14
|
}
|
15
15
|
end
|
16
16
|
|
@@ -23,16 +23,12 @@ module Rscons
|
|
23
23
|
end.any?
|
24
24
|
ld_alt = use_cxx ? env['CXX'] : env['CC']
|
25
25
|
vars = vars.merge({
|
26
|
-
'
|
27
|
-
'
|
26
|
+
'_TARGET' => target,
|
27
|
+
'_SOURCES' => objects,
|
28
28
|
'LD' => env['LD'] || ld_alt,
|
29
29
|
})
|
30
30
|
command = env.build_command(env['LDCOM'], vars)
|
31
|
-
|
32
|
-
return false unless env.execute("LD #{target}", command)
|
33
|
-
cache.register_build(target, command, objects)
|
34
|
-
end
|
35
|
-
target
|
31
|
+
standard_build("LD #{target}", target, command, objects, env, cache)
|
36
32
|
end
|
37
33
|
end
|
38
34
|
end
|
data/lib/rscons/environment.rb
CHANGED
@@ -11,9 +11,10 @@ module Rscons
|
|
11
11
|
|
12
12
|
# Create an Environment object.
|
13
13
|
# @param variables [Hash]
|
14
|
-
# The variables hash can contain
|
15
|
-
# uppercase strings (such as "CC" or "LDFLAGS"),
|
16
|
-
#
|
14
|
+
# The variables hash can contain construction variables, which are
|
15
|
+
# uppercase strings (such as "CC" or "LDFLAGS"), user variables, which
|
16
|
+
# are lowercase strings (such as "sources"), and RScons options, which
|
17
|
+
# are lowercase symbols (such as :echo).
|
17
18
|
# If a block is given, the Environment object is yielded to the block and
|
18
19
|
# when the block returns, the {#process} method is automatically called.
|
19
20
|
def initialize(variables = {})
|
data/lib/rscons/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rscons
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-09-
|
12
|
+
date: 2013-09-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec-core
|
@@ -220,7 +220,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
220
220
|
version: '0'
|
221
221
|
segments:
|
222
222
|
- 0
|
223
|
-
hash:
|
223
|
+
hash: 1121865149781113593
|
224
224
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
225
225
|
none: false
|
226
226
|
requirements:
|
@@ -229,7 +229,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
229
229
|
version: '0'
|
230
230
|
segments:
|
231
231
|
- 0
|
232
|
-
hash:
|
232
|
+
hash: 1121865149781113593
|
233
233
|
requirements: []
|
234
234
|
rubyforge_project:
|
235
235
|
rubygems_version: 1.8.23
|