akro 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/akro.rb +38 -11
- data/lib/akrobuild.rake +39 -22
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9cde35182bf4c229ae6c69f93d9b93845dd465b
|
4
|
+
data.tar.gz: b4eddd80a57434cc08afa83573c224a6eacdb4c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee4b34956e2f1e70b517f42aaa7fa58fe27a355695c71d80b2c1ca24beb16e41d7b4eecac1695df45d9d886917876951b72894d4965ce963dbd45372f5a960d7
|
7
|
+
data.tar.gz: c48a54a82ab33aa85a42b5047bc42fa774fcc84222879adbd2813300cdf9de6d7a1c1c3f0eed9417f6c7be4bdbc3bd5bcbd0333738c79ec86ffc6aa379786ca4
|
data/lib/akro.rb
CHANGED
@@ -42,15 +42,30 @@ $MODE_LINK_FLAGS = nil
|
|
42
42
|
# $ADDITIONAL_LINK_FLAGS is for third party libraries and objects
|
43
43
|
$ADDITIONAL_LINK_FLAGS = ""
|
44
44
|
|
45
|
-
|
46
|
-
|
45
|
+
def windows?
|
46
|
+
(RUBY_PLATFORM =~ /cygwin|mswin|mingw|bccwin|wince|emx/) != nil
|
47
|
+
end
|
48
|
+
|
49
|
+
if windows?
|
50
|
+
$HEADER_EXTENSIONS = [".H", ".hpp"]
|
51
|
+
$CPP_EXTENSIONS = [".C", ".cc", ".cpp", ".cxx", ".c++"]
|
52
|
+
else
|
53
|
+
$HEADER_EXTENSIONS = [".h", ".hpp", ".H"]
|
54
|
+
$CPP_EXTENSIONS = [".c", ".cc", ".cpp", ".cxx", ".c++", ".C"]
|
55
|
+
end
|
47
56
|
$OBJ_EXTENSION = ".o"
|
48
57
|
$STATIC_LIB_EXTENSION = ".a"
|
49
|
-
|
58
|
+
if windows?
|
59
|
+
$DYNAMIC_LIB_EXTENSION = ".dll"
|
60
|
+
else
|
61
|
+
$DYNAMIC_LIB_EXTENSION = ".so"
|
62
|
+
end
|
50
63
|
|
51
64
|
$LIB_CAPTURE_MAP = Hash.new
|
52
65
|
$CAPTURING_LIBS = Set.new
|
53
66
|
|
67
|
+
$PER_FILE_COMPILE_FLAGS = lambda {|mode, src| ""}
|
68
|
+
|
54
69
|
AkroTest = Struct.new("AkroTest", :name, :script, :binary, :cmdline)
|
55
70
|
$AKRO_TESTS = []
|
56
71
|
$AKRO_TESTS_MAP = Hash.new
|
@@ -65,9 +80,7 @@ def add_test(name: nil, script: nil, binary: nil, cmdline: nil)
|
|
65
80
|
end
|
66
81
|
|
67
82
|
$AKRO_BINARIES = []
|
68
|
-
|
69
|
-
$AKRO_BINARIES << path.to_str()
|
70
|
-
end
|
83
|
+
$BIN_EXTRA_FLAGS = Hash.new
|
71
84
|
|
72
85
|
def add_binaries(*paths)
|
73
86
|
paths.each do |path|
|
@@ -75,6 +88,14 @@ def add_binaries(*paths)
|
|
75
88
|
end
|
76
89
|
end
|
77
90
|
|
91
|
+
def add_binary(path: nil, additional_link_params: nil)
|
92
|
+
raise "Must specify path for binary" if path.nil?
|
93
|
+
if !additional_link_params.nil? && additional_link_params != ""
|
94
|
+
$BIN_EXTRA_FLAGS[path] = additional_link_params
|
95
|
+
end
|
96
|
+
$AKRO_BINARIES << path.to_str()
|
97
|
+
end
|
98
|
+
|
78
99
|
AkroLibrary = Struct.new("AkroLibrary", :path, :sources, :static, :recurse, :capture_deps, :additional_params)
|
79
100
|
$AKRO_LIBS = []
|
80
101
|
|
@@ -104,17 +125,23 @@ end
|
|
104
125
|
|
105
126
|
# Module with overrideable command line functions
|
106
127
|
module CmdLine
|
107
|
-
def CmdLine.compile_base_cmdline(mode)
|
108
|
-
|
128
|
+
def CmdLine.compile_base_cmdline(mode, src)
|
129
|
+
per_file_flags = $PER_FILE_COMPILE_FLAGS.call(mode, src)
|
130
|
+
if per_file_flags.size() > 0
|
131
|
+
per_file_flags = " " + per_file_flags
|
132
|
+
end
|
133
|
+
"#{$COMPILER_PREFIX}#{$COMPILER} #{$COMPILE_FLAGS} #{$MODE_COMPILE_FLAGS[mode]}#{per_file_flags}"
|
109
134
|
end
|
110
135
|
def CmdLine.dependency_cmdline(mode, src)
|
111
|
-
"#{CmdLine.compile_base_cmdline(mode)} -M #{src}"
|
136
|
+
"#{CmdLine.compile_base_cmdline(mode, src)} -M #{src}"
|
112
137
|
end
|
113
138
|
def CmdLine.compile_cmdline(mode, src, obj)
|
114
|
-
"#{CmdLine.compile_base_cmdline(mode)} -c #{src} -o #{obj}"
|
139
|
+
"#{CmdLine.compile_base_cmdline(mode, src)} -c #{src} -o #{obj}"
|
115
140
|
end
|
116
141
|
def CmdLine.link_cmdline(mode, objs, bin)
|
117
|
-
|
142
|
+
nomodebin = FileMapper.strip_mode(bin)
|
143
|
+
per_file_flags = if $BIN_EXTRA_FLAGS.has_key?(nomodebin) then " " + $BIN_EXTRA_FLAGS[nomodebin] else "" end
|
144
|
+
"#{$LINKER_PREFIX}#{$LINKER} #{$LINK_FLAGS} #{$MODE_LINK_FLAGS[mode]} #{objs.join(' ')} #{$ADDITIONAL_LINK_FLAGS}#{per_file_flags} -o #{bin}"
|
118
145
|
end
|
119
146
|
def CmdLine.static_lib_cmdline(objs, bin)
|
120
147
|
"#{$AR} rcs #{bin} #{objs.join(' ')}"
|
data/lib/akrobuild.rake
CHANGED
@@ -48,7 +48,7 @@ module FileMapper
|
|
48
48
|
raise "Unknown mode #{mode} for #{path}" if !$MODES.include?(mode)
|
49
49
|
mode
|
50
50
|
end
|
51
|
-
def FileMapper.
|
51
|
+
def FileMapper.get_mode_from_akpath(path)
|
52
52
|
rel_path = Util.make_relative_path(path)
|
53
53
|
raise "Path #{path} does not belong to #{Dir.pwd}" if rel_path.nil?
|
54
54
|
mode = rel_path[/^\.akro\/([^\/]*)/, 1]
|
@@ -106,6 +106,15 @@ module FileMapper
|
|
106
106
|
raise "#{path} is not a .depcache file" if !path.end_with?('.depcache') || !path.start_with?('.akro')
|
107
107
|
path.gsub(/\.depcache$/, ".compcmd" )
|
108
108
|
end
|
109
|
+
def FileMapper.map_compcmd_to_cpp(path)
|
110
|
+
raise "#{path} is not a .compcmd file" if !path.end_with?('.compcmd') || !path.start_with?('.akro')
|
111
|
+
file = path[/^\.akro\/(.*)\.compcmd$/, 1]
|
112
|
+
file = FileMapper.strip_mode(file)
|
113
|
+
srcs = $CPP_EXTENSIONS.map{|ext| file + ext}.select{|fname| File.exist?(fname)}
|
114
|
+
raise "Multiple sources for base name #{file}: #{srcs.join(' ')}" if srcs.length > 1
|
115
|
+
raise "No sources for base name #{file}" if srcs.length == 0
|
116
|
+
srcs[0]
|
117
|
+
end
|
109
118
|
def FileMapper.map_exe_to_linkcmd(path)
|
110
119
|
".akro/#{path.gsub(/\.exe$/, ".linkcmd" )}"
|
111
120
|
end
|
@@ -151,7 +160,7 @@ end
|
|
151
160
|
module Builder
|
152
161
|
def Builder.create_depcache(src, dc)
|
153
162
|
success = false
|
154
|
-
mode = FileMapper.
|
163
|
+
mode = FileMapper.get_mode_from_akpath(dc)
|
155
164
|
basedir, _ = File.split(dc)
|
156
165
|
FileUtils.mkdir_p(basedir)
|
157
166
|
output = File.open(dc, "w")
|
@@ -162,12 +171,15 @@ module Builder
|
|
162
171
|
puts cmdline if $VERBOSE_BUILD
|
163
172
|
deps = `#{cmdline}`
|
164
173
|
raise "Dependency determination failed for #{src}" if $?.to_i != 0
|
165
|
-
#
|
166
|
-
|
174
|
+
# Replace quoted spaces with placeholders
|
175
|
+
deps.gsub!(/\\ /, '<*%#?>') # a string that never exists in filenames
|
176
|
+
# Get rid of endlines completeley
|
167
177
|
deps.gsub!(/\\\n/, '')
|
168
178
|
# also get rid of <filename>: at the beginning
|
179
|
+
# split by spaces
|
169
180
|
deps[/^[^:]*:(.*)$/, 1].split(' ').each do |line|
|
170
181
|
# Output either a relative path if the file is local, or the original line.
|
182
|
+
line.gsub!('<*%#?>', ' ')
|
171
183
|
output << (Util.make_relative_path(line.strip) || line) << "\n"
|
172
184
|
end
|
173
185
|
output.close
|
@@ -240,10 +252,11 @@ end
|
|
240
252
|
#Phony task that forces anything depending on it to run
|
241
253
|
task "always"
|
242
254
|
|
243
|
-
rule ".compcmd" => ->(
|
244
|
-
mode = FileMapper.
|
245
|
-
|
246
|
-
|
255
|
+
rule ".compcmd" => ->(compcmd) {
|
256
|
+
mode = FileMapper.get_mode_from_akpath(compcmd)
|
257
|
+
src = FileMapper.map_compcmd_to_cpp(compcmd)
|
258
|
+
cmd = CmdLine.compile_base_cmdline(mode, src)
|
259
|
+
if File.exists?(compcmd) && File.read(compcmd).strip == cmd.strip then
|
247
260
|
[]
|
248
261
|
else
|
249
262
|
"always"
|
@@ -252,16 +265,17 @@ rule ".compcmd" => ->(dc) {
|
|
252
265
|
basedir, _ = File.split(task.name)
|
253
266
|
FileUtils.mkdir_p(basedir)
|
254
267
|
output = File.open(task.name, "w")
|
255
|
-
mode = FileMapper.
|
256
|
-
|
268
|
+
mode = FileMapper.get_mode_from_akpath(task.name)
|
269
|
+
src = FileMapper.map_compcmd_to_cpp(task.name)
|
270
|
+
output << CmdLine.compile_base_cmdline(mode, src) << "\n"
|
257
271
|
output.close
|
258
272
|
end
|
259
273
|
|
260
274
|
rule ".linkcmd" => ->(dc) {
|
261
275
|
binary = FileMapper.map_linkcmd_to_exe(dc)
|
262
276
|
raise "Internal error - linkcmd not mapped for #{binary}" if !$LINK_BINARY_OBJS.has_key?(binary)
|
263
|
-
mode = FileMapper.
|
264
|
-
cmd = CmdLine.link_cmdline(mode, $LINK_BINARY_OBJS[binary],
|
277
|
+
mode = FileMapper.get_mode_from_akpath(dc)
|
278
|
+
cmd = CmdLine.link_cmdline(mode, $LINK_BINARY_OBJS[binary], binary)
|
265
279
|
if File.exists?(dc) && File.read(dc).strip == cmd.strip then
|
266
280
|
[]
|
267
281
|
else
|
@@ -272,16 +286,16 @@ rule ".linkcmd" => ->(dc) {
|
|
272
286
|
binary = FileMapper.map_linkcmd_to_exe(task.name)
|
273
287
|
FileUtils.mkdir_p(basedir)
|
274
288
|
output = File.open(task.name, "w")
|
275
|
-
mode = FileMapper.
|
276
|
-
output << CmdLine.link_cmdline(mode, $LINK_BINARY_OBJS[binary],
|
289
|
+
mode = FileMapper.get_mode_from_akpath(task.name)
|
290
|
+
output << CmdLine.link_cmdline(mode, $LINK_BINARY_OBJS[binary], binary) << "\n"
|
277
291
|
output.close
|
278
292
|
end
|
279
293
|
|
280
294
|
rule ".dynlinkcmd" => ->(dc) {
|
281
295
|
dynlib = FileMapper.map_linkcmd_to_dynamic_lib(dc)
|
282
296
|
raise "Internal error - linkcmd not mapped for #{dynlib}" if !$LINK_BINARY_OBJS.has_key?(dynlib)
|
283
|
-
mode = FileMapper.
|
284
|
-
cmd = CmdLine.dynamic_lib_cmdline(mode, $LINK_BINARY_OBJS[dynlib], "",
|
297
|
+
mode = FileMapper.get_mode_from_akpath(dc)
|
298
|
+
cmd = CmdLine.dynamic_lib_cmdline(mode, $LINK_BINARY_OBJS[dynlib], "", dynlib)
|
285
299
|
if File.exists?(dc) && File.read(dc).strip == cmd.strip then
|
286
300
|
[]
|
287
301
|
else
|
@@ -292,16 +306,16 @@ rule ".dynlinkcmd" => ->(dc) {
|
|
292
306
|
dynlib = FileMapper.map_linkcmd_to_dynamic_lib(task.name)
|
293
307
|
FileUtils.mkdir_p(basedir)
|
294
308
|
output = File.open(task.name, "w")
|
295
|
-
mode = FileMapper.
|
296
|
-
output << CmdLine.dynamic_lib_cmdline(mode, $LINK_BINARY_OBJS[dynlib], "",
|
309
|
+
mode = FileMapper.get_mode_from_akpath(task.name)
|
310
|
+
output << CmdLine.dynamic_lib_cmdline(mode, $LINK_BINARY_OBJS[dynlib], "", dynlib) << "\n"
|
297
311
|
output.close
|
298
312
|
end
|
299
313
|
|
300
314
|
rule ".stlinkcmd" => ->(dc) {
|
301
315
|
stlib = FileMapper.map_linkcmd_to_static_lib(dc)
|
302
316
|
raise "Internal error - linkcmd not mapped for #{stlib}" if !$LINK_BINARY_OBJS.has_key?(stlib)
|
303
|
-
mode = FileMapper.
|
304
|
-
cmd = CmdLine.static_lib_cmdline($LINK_BINARY_OBJS[stlib],
|
317
|
+
mode = FileMapper.get_mode_from_akpath(dc)
|
318
|
+
cmd = CmdLine.static_lib_cmdline($LINK_BINARY_OBJS[stlib], stlib)
|
305
319
|
if File.exists?(dc) && File.read(dc).strip == cmd.strip then
|
306
320
|
[]
|
307
321
|
else
|
@@ -312,8 +326,8 @@ rule ".stlinkcmd" => ->(dc) {
|
|
312
326
|
stlib = FileMapper.map_linkcmd_to_static_lib(task.name)
|
313
327
|
FileUtils.mkdir_p(basedir)
|
314
328
|
output = File.open(task.name, "w")
|
315
|
-
mode = FileMapper.
|
316
|
-
output << CmdLine.static_lib_cmdline($LINK_BINARY_OBJS[stlib],
|
329
|
+
mode = FileMapper.get_mode_from_akpath(task.name)
|
330
|
+
output << CmdLine.static_lib_cmdline($LINK_BINARY_OBJS[stlib], stlib) << "\n"
|
317
331
|
output.close
|
318
332
|
end
|
319
333
|
|
@@ -473,6 +487,9 @@ $MODES.each do |mode|
|
|
473
487
|
raise "Binary cannot start with mode #{bin}" if bin.start_with?(mode + "/")
|
474
488
|
Rake::Task[mode].enhance(["#{mode}/#{bin}"])
|
475
489
|
end
|
490
|
+
# Build all non-capturing libs by default.
|
491
|
+
# Capturing libs are automatically invoked by binaries anyway.
|
492
|
+
Rake::Task[mode].enhance($AKRO_LIBS.select{|l| !l.capture_deps}.map{|l| libname(mode, l)})
|
476
493
|
$AKRO_TESTS.each do |test|
|
477
494
|
test_dep =
|
478
495
|
if !test.binary.nil?
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: akro
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vlad Petric
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '11.
|
19
|
+
version: '11.3'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '11.
|
26
|
+
version: '11.3'
|
27
27
|
description:
|
28
28
|
email: vlad@impaler.org
|
29
29
|
executables:
|