canoe 0.3.1.1 → 0.3.2
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.
- checksums.yaml +4 -4
- data/bin/canoe +1 -2
- data/lib/canoe.rb +23 -21
- data/lib/cmd.rb +71 -84
- data/lib/compiler.rb +44 -45
- data/lib/config_reader.rb +2 -2
- data/lib/default_files.rb +14 -31
- data/lib/dependence.rb +111 -111
- data/lib/source_files.rb +3 -3
- data/lib/util.rb +81 -0
- data/lib/workspace/add.rb +19 -17
- data/lib/workspace/build.rb +117 -98
- data/lib/workspace/clean.rb +29 -20
- data/lib/workspace/dep.rb +8 -6
- data/lib/workspace/generate.rb +8 -3
- data/lib/workspace/help.rb +14 -6
- data/lib/workspace/make.rb +227 -180
- data/lib/workspace/new.rb +27 -24
- data/lib/workspace/run.rb +10 -7
- data/lib/workspace/test.rb +125 -30
- data/lib/workspace/update.rb +5 -3
- data/lib/workspace/version.rb +7 -5
- data/lib/workspace/workspace.rb +55 -45
- metadata +3 -3
- data/lib/err.rb +0 -21
data/lib/workspace/clean.rb
CHANGED
|
@@ -1,27 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
module Canoe
|
|
2
|
+
class WorkSpace
|
|
3
|
+
# valid options: none, 'all', 'target', 'tests'
|
|
4
|
+
def clean(args)
|
|
5
|
+
options = {
|
|
6
|
+
[] => 'all', ['all'] => 'all',
|
|
7
|
+
['target'] => 'target', ['tests'] => 'tests', ['obj'] => 'obj'
|
|
8
|
+
}
|
|
9
|
+
if options.include?(args)
|
|
10
|
+
send "clean_#{options[args]}"
|
|
11
|
+
else
|
|
12
|
+
abort_on_err "Unkown subcommand #{args.join(' ').red}"
|
|
13
|
+
end
|
|
14
|
+
end
|
|
5
15
|
|
|
6
|
-
|
|
16
|
+
private
|
|
7
17
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
18
|
+
def clean_all
|
|
19
|
+
clean_target
|
|
20
|
+
clean_obj
|
|
21
|
+
end
|
|
12
22
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
end
|
|
23
|
+
def clean_target
|
|
24
|
+
issue_command 'rm ./target/* -rf'
|
|
25
|
+
end
|
|
17
26
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
end
|
|
27
|
+
def clean_obj
|
|
28
|
+
issue_command 'rm ./obj/* -rf'
|
|
29
|
+
end
|
|
22
30
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
31
|
+
def clean_tests
|
|
32
|
+
issue_command 'rm ./obj/test_* -rf'
|
|
33
|
+
issue_command 'rm ./target/test_* -rf'
|
|
34
|
+
end
|
|
26
35
|
end
|
|
27
36
|
end
|
data/lib/workspace/dep.rb
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
module Canoe
|
|
2
|
+
class WorkSpace
|
|
3
|
+
def dep
|
|
4
|
+
deps = DepAnalyzer.read_from(@deps) if File.exist?(@deps)
|
|
5
|
+
deps.each do |k, v|
|
|
6
|
+
next if v.empty?
|
|
7
|
+
|
|
6
8
|
puts "#{k.blue} depends on: "
|
|
7
9
|
v.each { |f| puts " #{f.blue}" }
|
|
8
|
-
puts
|
|
10
|
+
puts ''
|
|
9
11
|
end
|
|
10
12
|
end
|
|
11
13
|
end
|
data/lib/workspace/generate.rb
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
module Canoe
|
|
2
|
+
class WorkSpace
|
|
3
|
+
def generate
|
|
4
|
+
DepAnalyzer.new(@src_short, @source_suffix, @header_suffix)
|
|
5
|
+
.build_to_file [@src_short, @components_short], @deps
|
|
6
|
+
DepAnalyzer.new(@tests_short, @source_suffix, @header_suffix)
|
|
7
|
+
.build_to_file [@src_short, @components_short], @test_deps
|
|
8
|
+
end
|
|
4
9
|
end
|
|
5
10
|
end
|
data/lib/workspace/help.rb
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
module Canoe
|
|
2
|
+
class WorkSpace
|
|
3
|
+
def self.help
|
|
4
|
+
info = <<~INFO
|
|
4
5
|
canoe is a C/C++ project manager, inspired by Rust cargo.
|
|
5
6
|
usage:
|
|
6
7
|
canoe new tada: create a project named 'tada' in current directory
|
|
7
8
|
|
|
8
9
|
canoe build: compile current project (execute this command in project directory)
|
|
10
|
+
|
|
11
|
+
canoe test: build and run tests
|
|
9
12
|
|
|
10
13
|
canoe generate: generate dependency relationships and store it in '.canoe.deps' file. Alias: update
|
|
11
14
|
|
|
@@ -47,8 +50,12 @@ class WorkSpace
|
|
|
47
50
|
So when a file includes new headers or some headers are removed, users have to use 'canoe udpate'
|
|
48
51
|
to update dependency relationships.
|
|
49
52
|
|
|
50
|
-
build [
|
|
51
|
-
build current project,
|
|
53
|
+
build [all|test]:
|
|
54
|
+
build current project, 'all' builds both target and tests, 'test' builds tests only
|
|
55
|
+
|
|
56
|
+
test [tests]:
|
|
57
|
+
build and run tests
|
|
58
|
+
[tests]: 'all' for all tests, or a name of a test for a single test
|
|
52
59
|
|
|
53
60
|
run [options]:
|
|
54
61
|
build current project with no specific compilation flags, and run this project, passing [options] as command line arguments to the binary
|
|
@@ -71,6 +78,7 @@ class WorkSpace
|
|
|
71
78
|
@author: written by XIONG Ziwei, ICT, CAS
|
|
72
79
|
@contact: noahxiong@outlook.com
|
|
73
80
|
INFO
|
|
74
|
-
|
|
81
|
+
puts info
|
|
82
|
+
end
|
|
75
83
|
end
|
|
76
84
|
end
|
data/lib/workspace/make.rb
CHANGED
|
@@ -1,233 +1,280 @@
|
|
|
1
1
|
# If the project has circular dependency, this command would fail
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
module Canoe
|
|
3
|
+
class Makefile
|
|
4
|
+
include WorkSpaceUtil
|
|
5
|
+
def initialize(workspace)
|
|
6
|
+
@workspace = workspace
|
|
7
|
+
@all_names = []
|
|
8
|
+
@common_variables = {}
|
|
9
|
+
@src_variables = {}
|
|
10
|
+
@hdr_variables = {}
|
|
11
|
+
@obj_variables = {}
|
|
12
|
+
@config = {}
|
|
13
|
+
end
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
def configure(config)
|
|
16
|
+
@config = config
|
|
17
|
+
end
|
|
16
18
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
def make!(deps)
|
|
20
|
+
File.open('Makefile', 'w') do |f|
|
|
21
|
+
if cxx?(get_compiler)
|
|
22
|
+
make_cxx(f, deps)
|
|
23
|
+
else
|
|
24
|
+
make_c(f, deps)
|
|
25
|
+
end
|
|
23
26
|
end
|
|
24
27
|
end
|
|
25
|
-
end
|
|
26
28
|
|
|
27
|
-
|
|
29
|
+
private
|
|
28
30
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
def get_compiler
|
|
32
|
+
@config['compiler']
|
|
33
|
+
end
|
|
32
34
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
def get_header_suffix
|
|
36
|
+
@workspace.header_suffix
|
|
37
|
+
end
|
|
36
38
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
def get_source_suffix
|
|
40
|
+
@workspace.source_suffix
|
|
41
|
+
end
|
|
40
42
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
def get_compiling_flags
|
|
44
|
+
flags = @config['flags']['compile'].values.join ' '
|
|
45
|
+
flags + ' -I./src/components'
|
|
46
|
+
end
|
|
45
47
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
def get_ldflags
|
|
49
|
+
@config['flags']['link'].values.select { |v| v.start_with?('-L') }.join ' '
|
|
50
|
+
end
|
|
49
51
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
def get_ldlibs
|
|
53
|
+
(@config['flags']['link'].values - (get_ldflags.split)).join ' '
|
|
54
|
+
end
|
|
53
55
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
def cxx?(name)
|
|
57
|
+
return get_compiler.end_with? '++'
|
|
58
|
+
end
|
|
57
59
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
60
|
+
def make_cxx(makefile, deps)
|
|
61
|
+
make_common(makefile, 'CXX', deps)
|
|
62
|
+
end
|
|
61
63
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
64
|
+
def make_c(makefile, deps)
|
|
65
|
+
make_common(makefile, 'CC', deps)
|
|
66
|
+
end
|
|
65
67
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
def make_common(makefile, compiler_prefix, deps)
|
|
69
|
+
make_compiling_info(makefile, compiler_prefix)
|
|
70
|
+
define_variables(makefile, deps)
|
|
71
|
+
make_rules(makefile, deps)
|
|
72
|
+
end
|
|
71
73
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
74
|
+
def make_compiling_info(makefile, compiler_prefix)
|
|
75
|
+
makefile.puts("#{compiler_prefix}=#{get_compiler}")
|
|
76
|
+
makefile.puts("#{compiler_prefix}FLAGS=#{get_compiling_flags}")
|
|
77
|
+
makefile.puts("LDFLAGS=#{get_ldflags}")
|
|
78
|
+
makefile.puts("LDLIBS=#{get_ldlibs}")
|
|
79
|
+
makefile.puts ''
|
|
80
|
+
end
|
|
79
81
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
82
|
+
def define_variables(makefile, deps)
|
|
83
|
+
define_dirs(makefile)
|
|
84
|
+
src_files = deps.keys.select { |f| f.end_with? get_source_suffix }
|
|
85
|
+
|
|
86
|
+
generate_all_names(src_files)
|
|
87
|
+
define_srcs(makefile, src_files)
|
|
88
|
+
makefile.puts ''
|
|
89
|
+
define_hdrs(makefile, src_files)
|
|
90
|
+
makefile.puts ''
|
|
91
|
+
define_objs(makefile, src_files)
|
|
92
|
+
makefile.puts ''
|
|
93
|
+
define_tests(makefile, src_files)
|
|
94
|
+
makefile.puts ''
|
|
95
|
+
end
|
|
92
96
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
name.delete_suffix(File.extname(name))[prefix.length..].gsub("/", "_")
|
|
96
|
-
else
|
|
97
|
-
File.basename(name.split("/")[-1], ".*")
|
|
97
|
+
def extract_name(name, _)
|
|
98
|
+
File.basename(file_to_obj(name), '.*')
|
|
98
99
|
end
|
|
99
|
-
end
|
|
100
100
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
101
|
+
def generate_all_names(files)
|
|
102
|
+
files.each do |f|
|
|
103
|
+
name = extract_name(f, @workspace.components_prefix).upcase
|
|
104
|
+
@all_names << name
|
|
105
|
+
@src_variables[name] = f
|
|
106
|
+
@hdr_variables[name] = f.gsub @workspace.source_suffix, @workspace.header_suffix
|
|
107
|
+
@obj_variables[name] = file_to_obj(f)
|
|
108
|
+
end
|
|
108
109
|
end
|
|
109
|
-
end
|
|
110
110
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
111
|
+
def define_dirs(makefile)
|
|
112
|
+
makefile.puts("TARGET_DIR=./target")
|
|
113
|
+
if @workspace.mode == :bin
|
|
114
|
+
makefile.puts("TARGET=$(TARGET_DIR)/#{@workspace.name}")
|
|
115
|
+
else
|
|
116
|
+
makefile.puts("TARGET=$(TARGET_DIR)/lib#{@workspace.name.downcase}.so")
|
|
117
|
+
end
|
|
118
|
+
# note the ending slash
|
|
119
|
+
makefile.puts("OBJ_DIR=#{@workspace.obj_prefix[..-2]}")
|
|
120
|
+
makefile.puts("SRC_DIR=#{@workspace.src_prefix[..-2]}")
|
|
121
|
+
makefile.puts("COMPONENTS_DIR=#{@workspace.components_prefix[..-2]}")
|
|
122
|
+
makefile.puts ""
|
|
123
|
+
end
|
|
124
124
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
125
|
+
def define_srcs(makefile, files)
|
|
126
|
+
@src_variables.each do |k, v|
|
|
127
|
+
makefile.puts("SRC_#{k}=#{v}")
|
|
128
|
+
end
|
|
128
129
|
end
|
|
129
|
-
end
|
|
130
130
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
131
|
+
def define_hdrs(makefile, files)
|
|
132
|
+
@hdr_variables.each do |k, v|
|
|
133
|
+
next if k == "MAIN"
|
|
134
|
+
makefile.puts("HDR_#{k}=#{v}") if File.exist? v
|
|
135
|
+
end
|
|
135
136
|
end
|
|
136
|
-
end
|
|
137
137
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
138
|
+
def define_objs(makefile, files)
|
|
139
|
+
@obj_variables.each do |k, v|
|
|
140
|
+
makefile.puts("OBJ_#{k}=#{v}")
|
|
141
|
+
end
|
|
142
|
+
objs = @obj_variables.keys.map { |k| "$(OBJ_#{k})" }
|
|
143
|
+
bin_objs = objs.reject { |o| o.start_with? '$(OBJ_TEST'}
|
|
144
|
+
test_objs = objs - bin_objs
|
|
145
|
+
makefile.puts ''
|
|
146
|
+
makefile.puts("OUT_OBJS=#{bin_objs.join ' '}")
|
|
147
|
+
makefile.puts("TEST_OBJS=#{test_objs.join ' '}")
|
|
141
148
|
end
|
|
142
|
-
objs = @obj_variables.keys.map { |k| "$(OBJ_#{k})" }.join " "
|
|
143
|
-
makefile.puts("OBJS=#{objs}")
|
|
144
|
-
makefile.puts ""
|
|
145
|
-
end
|
|
146
149
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
150
|
+
def define_tests(makefile, files)
|
|
151
|
+
test_files = files.select { |f| File.basename(f, '.*').start_with? 'test_'}
|
|
152
|
+
test_files.each do |f|
|
|
153
|
+
basename = File.basename(f, '.*')
|
|
154
|
+
test = "#{@workspace.target_short}/#{basename}"
|
|
155
|
+
makefile.puts("#{basename.upcase}=#{test}")
|
|
156
|
+
end
|
|
157
|
+
tests = test_files.map do |f|
|
|
158
|
+
"$(#{File.basename(f, '.*').upcase})"
|
|
155
159
|
end
|
|
156
|
-
|
|
160
|
+
makefile.puts("TESTS=#{tests.join ' '}")
|
|
157
161
|
end
|
|
158
|
-
end
|
|
159
162
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
if
|
|
163
|
-
[
|
|
163
|
+
def get_all_dep_name(file_name, deps)
|
|
164
|
+
dep = deps[file_name]
|
|
165
|
+
if dep.empty?
|
|
166
|
+
[]
|
|
164
167
|
else
|
|
165
|
-
|
|
168
|
+
tmp = dep.map { |n| extract_name(n, @workspace.components_prefix).upcase }
|
|
169
|
+
dep.each do |d|
|
|
170
|
+
tmp += get_all_dep_name(d, deps)
|
|
171
|
+
end
|
|
172
|
+
tmp
|
|
173
|
+
end
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
def emit_dependencies(makefile, name, deps)
|
|
177
|
+
as_str = deps.map do |n|
|
|
178
|
+
if n == name
|
|
179
|
+
["$(SRC_#{n})"] + ["$(HDR_#{n})"] * (name == "MAIN" ? 0 : 1)
|
|
180
|
+
else
|
|
181
|
+
"$(#{n}_DEP)"
|
|
182
|
+
end
|
|
183
|
+
end.flatten.join " "
|
|
184
|
+
makefile.puts("#{name}_DEP=#{as_str}")
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
def make_dependencies(makefile, deps)
|
|
188
|
+
dep_variables = Hash[@all_names.map { |n| [n, []] }]
|
|
189
|
+
reference = Hash[@all_names.map { |n| [n, []] }]
|
|
190
|
+
@all_names.each do |n|
|
|
191
|
+
dep_variables[n] = ([n] + get_all_dep_name(@src_variables[n], deps)).uniq
|
|
192
|
+
reference[n] = ([n] + get_all_dep_name(@src_variables[n], deps)).uniq
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
# deduplication
|
|
196
|
+
dep_variables.each do |k, v|
|
|
197
|
+
v.each do |n|
|
|
198
|
+
next if n == k
|
|
199
|
+
v = v - reference[n] + [n] if v.include? n
|
|
200
|
+
end
|
|
201
|
+
dep_variables[k] = v
|
|
166
202
|
end
|
|
167
|
-
end.flatten.join " "
|
|
168
|
-
makefile.puts("#{name}_DEP=#{as_str}")
|
|
169
|
-
end
|
|
170
203
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
@all_names.each do |n|
|
|
175
|
-
dep_variables[n] = ([n] + get_all_dep_name(@src_variables[n], deps)).uniq
|
|
176
|
-
reference[n] = ([n] + get_all_dep_name(@src_variables[n], deps)).uniq
|
|
204
|
+
dep_variables.each do |k, v|
|
|
205
|
+
emit_dependencies(makefile, k, v)
|
|
206
|
+
end
|
|
177
207
|
end
|
|
178
208
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
209
|
+
def make_obj_rules(makefile, deps)
|
|
210
|
+
cmplr = cxx?(get_compiler) ? 'CXX' : 'CC'
|
|
211
|
+
makefile.puts("all: OUT\n")
|
|
212
|
+
makefile.puts ''
|
|
213
|
+
|
|
214
|
+
@all_names.each do |n|
|
|
215
|
+
makefile.puts("$(OBJ_#{n}): $(#{n}_DEP)\n\t$(#{cmplr}) $(#{cmplr}FLAGS) -o $@ -c $(SRC_#{n})")
|
|
216
|
+
makefile.puts ''
|
|
184
217
|
end
|
|
185
|
-
|
|
218
|
+
|
|
186
219
|
end
|
|
187
220
|
|
|
188
|
-
|
|
189
|
-
|
|
221
|
+
def make_out_rules(makefile, deps)
|
|
222
|
+
cmplr = cxx?(get_compiler) ? 'CXX' : 'CC'
|
|
223
|
+
if @workspace.mode == :bin
|
|
224
|
+
makefile.puts("OUT: $(OUT_OBJS)\n\t$(#{cmplr}) $(#{cmplr}FLAGS) -o $(TARGET) $(OUT_OBJS) $(LDFLAGS) $(LDLIBS)")
|
|
225
|
+
else
|
|
226
|
+
makefile.puts("OUT: $(OUT_OBJS)\n\t$(#{cmplr}) $(#{cmplr}FLAGS) -shared -o $(TARGET) $(OUT_OBJS) -fPIC $(LDFLAGS) $(LDLIBS)")
|
|
227
|
+
end
|
|
228
|
+
makefile.puts ''
|
|
229
|
+
makefile.puts("test: $(TESTS)")
|
|
190
230
|
end
|
|
191
|
-
end
|
|
192
231
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
232
|
+
def make_tests_rules(makefile, deps)
|
|
233
|
+
cmplr = cxx?(get_compiler) ? 'CXX' : 'CC'
|
|
234
|
+
@all_names.each do |n|
|
|
235
|
+
next unless n.start_with? 'TEST_'
|
|
236
|
+
filename = "#{@workspace.tests_short}/#{n.downcase}.#{@workspace.source_suffix}"
|
|
237
|
+
objs = ["$(OBJ_#{n})"] + extract_one_file_obj(filename, deps).map do |o|
|
|
238
|
+
"$(OBJ_#{File.basename(o, '.*').upcase})"
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
makefile.puts("$(#{n}): #{objs.join ' '}\n\t$(#{cmplr}) $(#{cmplr}FLAGS) -o $@ $^ $(LDFLAGS) $(LDLIBS)")
|
|
242
|
+
makefile.puts ''
|
|
243
|
+
end
|
|
202
244
|
end
|
|
203
245
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
246
|
+
def make_clean(makefile)
|
|
247
|
+
clean = <<~DOC
|
|
248
|
+
.PHONY: clean
|
|
249
|
+
clean:
|
|
250
|
+
\trm ./target/*
|
|
251
|
+
\trm ./obj/*.o
|
|
252
|
+
DOC
|
|
253
|
+
makefile.puts(clean)
|
|
208
254
|
end
|
|
209
|
-
makefile.puts ""
|
|
210
255
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
256
|
+
def make_rules(makefile, deps)
|
|
257
|
+
make_dependencies makefile, deps
|
|
258
|
+
makefile.puts ''
|
|
259
|
+
make_obj_rules makefile, deps
|
|
260
|
+
makefile.puts ''
|
|
261
|
+
make_out_rules makefile, deps
|
|
262
|
+
makefile.puts ''
|
|
263
|
+
make_tests_rules makefile, deps
|
|
264
|
+
makefile.puts ''
|
|
265
|
+
make_clean makefile
|
|
266
|
+
end
|
|
218
267
|
end
|
|
219
|
-
end
|
|
220
268
|
|
|
221
|
-
class WorkSpace
|
|
222
|
-
|
|
223
|
-
|
|
269
|
+
class WorkSpace
|
|
270
|
+
def make
|
|
271
|
+
config = ConfigReader.extract_flags "config.json"
|
|
224
272
|
|
|
225
|
-
|
|
226
|
-
DepAnalyzer.read_from(@deps) :
|
|
227
|
-
DepAnalyzer.new("./src").build_to_file(["./src", "./src/components"], @deps)
|
|
273
|
+
deps = target_deps.merge tests_deps
|
|
228
274
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
275
|
+
makefile = Makefile.new self
|
|
276
|
+
makefile.configure config
|
|
277
|
+
makefile.make! deps
|
|
278
|
+
end
|
|
232
279
|
end
|
|
233
280
|
end
|