magica 0.7.2 → 0.8.0
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/magica +3 -1
- data/lib/Magicafile +1 -1
- data/lib/magica.rb +34 -2
- data/lib/magica/all.rb +13 -15
- data/lib/magica/application.rb +27 -24
- data/lib/magica/build.rb +68 -44
- data/lib/magica/command.rb +2 -1
- data/lib/magica/commands/compiler.rb +35 -22
- data/lib/magica/commands/git.rb +41 -33
- data/lib/magica/commands/linker.rb +33 -26
- data/lib/magica/dependency.rb +55 -31
- data/lib/magica/dsl.rb +3 -2
- data/lib/magica/extension.rb +2 -0
- data/lib/magica/framework.rb +2 -2
- data/lib/magica/i18n.rb +3 -0
- data/lib/magica/initialize.rb +1 -1
- data/lib/magica/package_config.rb +34 -11
- data/lib/magica/target.rb +3 -2
- data/lib/magica/tasks/framework.rake +2 -8
- data/lib/magica/tasks/initialize.rake +5 -5
- data/lib/magica/templates/Magicafile +2 -2
- data/lib/magica/toolchain.rb +5 -3
- data/lib/magica/toolchains/gcc.rake +8 -7
- data/lib/magica/version.rb +1 -1
- metadata +2 -4
- data/lib/magica/magica.rb +0 -33
- data/lib/magica/tasks/build.rake +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9648f787f745dd428414d6a0df22c41c5cc5c230
|
|
4
|
+
data.tar.gz: 5942123320392e91dca6b4dddef6cae2ac19b1f5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 110f0160763ae847e2cad0c6a10c191d00bf456fc2a9a265160fe4d44e876bf1670c74827902813766e4b2e60bfb605d90d0745d64d3ab9daf87617928667981
|
|
7
|
+
data.tar.gz: e9e0031a46b037893bd71ef1e722af4e7c9f1a5119c337af99ed596b6105554ffc2190c9689598ae7c31eb7e987d8bcf45942b4f0a441c23ecef5323a7aba65b
|
data/bin/magica
CHANGED
data/lib/Magicafile
CHANGED
data/lib/magica.rb
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'magica/version'
|
|
2
|
+
require 'magica/all'
|
|
2
3
|
|
|
4
|
+
# Magica
|
|
3
5
|
module Magica
|
|
4
|
-
|
|
6
|
+
class << self
|
|
7
|
+
attr_accessor :default_toolchain, :toolchain_params
|
|
8
|
+
|
|
9
|
+
def builds
|
|
10
|
+
@builds ||= {}
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def each_build(&block)
|
|
14
|
+
return to_enum(:each_build) if block.nil?
|
|
15
|
+
@builds.each do |_, build|
|
|
16
|
+
build.instance_eval(&block)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def root
|
|
21
|
+
Dir.pwd
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def default_compile_task
|
|
25
|
+
proc { |options|
|
|
26
|
+
clean if options[:clean]
|
|
27
|
+
|
|
28
|
+
do_target(options[:target])
|
|
29
|
+
|
|
30
|
+
objects = objfile(@sources)
|
|
31
|
+
@sources.each { |source| compile source }
|
|
32
|
+
|
|
33
|
+
link exefile, objects
|
|
34
|
+
}
|
|
35
|
+
end
|
|
36
|
+
end
|
|
5
37
|
end
|
data/lib/magica/all.rb
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'rake'
|
|
2
2
|
|
|
3
|
-
require
|
|
4
|
-
require
|
|
5
|
-
require
|
|
6
|
-
require
|
|
7
|
-
require
|
|
8
|
-
require
|
|
9
|
-
require
|
|
10
|
-
require
|
|
3
|
+
require 'magica/version'
|
|
4
|
+
require 'magica/package_config'
|
|
5
|
+
require 'magica/extension'
|
|
6
|
+
require 'magica/i18n'
|
|
7
|
+
require 'magica/dsl'
|
|
8
|
+
require 'magica/toolchain'
|
|
9
|
+
require 'magica/dependency'
|
|
10
|
+
require 'magica/application'
|
|
11
11
|
|
|
12
|
-
require
|
|
13
|
-
require
|
|
14
|
-
require
|
|
15
|
-
require
|
|
16
|
-
|
|
17
|
-
require "magica/magica"
|
|
12
|
+
require 'magica/command'
|
|
13
|
+
require 'magica/commands/compiler'
|
|
14
|
+
require 'magica/commands/linker'
|
|
15
|
+
require 'magica/commands/git'
|
data/lib/magica/application.rb
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
module Magica
|
|
2
|
+
# :nodoc:
|
|
2
3
|
class Application < Rake::Application
|
|
3
|
-
|
|
4
4
|
DEFAULT_MAGICAFILES = [
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
'magicafile',
|
|
6
|
+
'Magicafile',
|
|
7
|
+
'magicafile.rb',
|
|
8
|
+
'Magicafile.rb'
|
|
9
9
|
].freeze
|
|
10
10
|
|
|
11
11
|
def initialize
|
|
@@ -14,7 +14,7 @@ module Magica
|
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
def name
|
|
17
|
-
|
|
17
|
+
'magica'
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
def run
|
|
@@ -23,22 +23,24 @@ module Magica
|
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
def handle_options
|
|
26
|
-
options.rakelib = [
|
|
26
|
+
options.rakelib = ['rakelib']
|
|
27
27
|
options.trace_output = $stderr
|
|
28
28
|
|
|
29
29
|
OptionParser.new do |opts|
|
|
30
|
-
opts.on_tail(
|
|
30
|
+
opts.on_tail('-h', '--help', '-H', 'Display this help message.') do
|
|
31
31
|
puts opts
|
|
32
32
|
exit
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
standard_rake_options.each { |args| opts.on(*args) }
|
|
36
|
-
opts.environment(
|
|
36
|
+
opts.environment('RAKEOPT')
|
|
37
37
|
end.parse!
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
def sort_options(options)
|
|
41
|
-
|
|
41
|
+
# rubocop:disable Metrics/LineLength
|
|
42
|
+
not_applicable_to_magica = %w[verbose execute execute-continue libdir no-search rakefile rakelibdir require system no-system where no-deprecation-warnings]
|
|
43
|
+
# rubocop:enable Metrics/LineLEngth
|
|
42
44
|
|
|
43
45
|
options.reject! do |(switch, *)|
|
|
44
46
|
switch =~ /--#{Regexp.union(not_applicable_to_magica)}/
|
|
@@ -48,31 +50,32 @@ module Magica
|
|
|
48
50
|
end
|
|
49
51
|
|
|
50
52
|
def top_level_tasks
|
|
51
|
-
unless File.
|
|
53
|
+
unless File.exist?('Magicafile')
|
|
52
54
|
@top_level_tasks.unshift(warning_not_init.to_s) unless default_tasks.include?(@top_level_tasks.first)
|
|
53
55
|
end
|
|
54
56
|
@top_level_tasks
|
|
55
57
|
end
|
|
56
58
|
|
|
57
59
|
private
|
|
60
|
+
|
|
58
61
|
def magicafile
|
|
59
|
-
File.expand_path(
|
|
62
|
+
File.expand_path('../../Magicafile', __FILE__)
|
|
60
63
|
end
|
|
61
64
|
|
|
62
65
|
def warning_not_init
|
|
63
66
|
Rake::Task.define_task(:warning_not_init) do
|
|
64
|
-
puts I18n.t(
|
|
67
|
+
puts I18n.t('not_init_project', scope: :magica)
|
|
65
68
|
exit 1
|
|
66
69
|
end
|
|
67
70
|
end
|
|
68
71
|
|
|
69
72
|
def default_tasks
|
|
70
|
-
%
|
|
73
|
+
%(init)
|
|
71
74
|
end
|
|
72
75
|
|
|
73
76
|
def version
|
|
74
|
-
[
|
|
75
|
-
|
|
77
|
+
['--version', '-V',
|
|
78
|
+
'Display the program version.',
|
|
76
79
|
lambda do |_value|
|
|
77
80
|
puts "Magica Version: #{Magica::VERSION} (Rake Version: #{Rake::VERSION})"
|
|
78
81
|
exit
|
|
@@ -80,16 +83,16 @@ module Magica
|
|
|
80
83
|
end
|
|
81
84
|
|
|
82
85
|
def clean
|
|
83
|
-
[
|
|
84
|
-
|
|
86
|
+
['--clean', '-c',
|
|
87
|
+
'Clean all files before build',
|
|
85
88
|
lambda do |_value|
|
|
86
89
|
options.clean = true
|
|
87
90
|
end]
|
|
88
91
|
end
|
|
89
92
|
|
|
90
93
|
def clean_all
|
|
91
|
-
[
|
|
92
|
-
|
|
94
|
+
['--clean-all', '-C',
|
|
95
|
+
'Clean all files before build include dependency',
|
|
93
96
|
lambda do |_value|
|
|
94
97
|
options.clean = true
|
|
95
98
|
options.clean_all = true
|
|
@@ -97,10 +100,10 @@ module Magica
|
|
|
97
100
|
end
|
|
98
101
|
|
|
99
102
|
def target
|
|
100
|
-
[
|
|
101
|
-
|
|
102
|
-
lambda do |
|
|
103
|
-
options.target =
|
|
103
|
+
['--target', '-t TARGET',
|
|
104
|
+
'Specify the build to use',
|
|
105
|
+
lambda do |value|
|
|
106
|
+
options.target = value
|
|
104
107
|
end]
|
|
105
108
|
end
|
|
106
109
|
end
|
data/lib/magica/build.rb
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
include Magica::DSL
|
|
2
2
|
|
|
3
|
-
require
|
|
4
|
-
|
|
5
|
-
load File.expand_path("../tasks/build.rake", __FILE__)
|
|
3
|
+
require 'magica/framework'
|
|
6
4
|
|
|
5
|
+
# rubocop:disable Metrics/ClassLength
|
|
6
|
+
# rubocop:disable Metrics/LineLength
|
|
7
|
+
# rubocop:disable Metrics/MethodLength
|
|
7
8
|
module Magica
|
|
9
|
+
# :nodoc:
|
|
8
10
|
class Build
|
|
9
11
|
class << self
|
|
10
12
|
attr_accessor :current
|
|
@@ -12,41 +14,42 @@ module Magica
|
|
|
12
14
|
|
|
13
15
|
include Rake::DSL
|
|
14
16
|
|
|
15
|
-
COMPILERS = %w
|
|
16
|
-
COMMANDS = COMPILERS + %w
|
|
17
|
+
COMPILERS = %w[cc cxx].freeze
|
|
18
|
+
COMMANDS = COMPILERS + %w[linker git]
|
|
17
19
|
|
|
18
|
-
attr_reader :options, :defines, :include_paths, :flags
|
|
20
|
+
attr_reader :sources, :options, :defines, :include_paths, :flags
|
|
19
21
|
attr_block COMMANDS
|
|
20
22
|
|
|
21
23
|
Exts = Struct.new(:object, :executable, :library)
|
|
22
24
|
|
|
23
|
-
|
|
25
|
+
# rubocop:disable Metrics/AbcSize
|
|
26
|
+
def initialize(name = 'host', options = { dest: 'build' }, &block)
|
|
24
27
|
@name = name.to_s
|
|
25
28
|
@dest = (options[:dest] || 'build').to_s
|
|
26
|
-
@sources = FileList[
|
|
29
|
+
@sources = FileList['src/**/*.cpp']
|
|
27
30
|
@options = OpenStruct.new(options.merge(Rake.application.options.to_h))
|
|
28
31
|
@default_target = nil
|
|
29
32
|
@config_block = block
|
|
30
33
|
@targets = {}
|
|
31
34
|
|
|
32
35
|
@exe_name = @name
|
|
33
|
-
@exe_path =
|
|
36
|
+
@exe_path = 'bin'
|
|
34
37
|
|
|
35
38
|
@exts = Exts.new('.o', '', '.a')
|
|
36
39
|
|
|
37
|
-
@cc = Command::Compiler.new(self, %w
|
|
38
|
-
@cxx = Command::Compiler.new(self, %w
|
|
40
|
+
@cc = Command::Compiler.new(self, %w[.c])
|
|
41
|
+
@cxx = Command::Compiler.new(self, %w[.cpp])
|
|
39
42
|
@linker = Command::Linker.new(self)
|
|
40
43
|
|
|
41
44
|
@compiler = @cc
|
|
42
45
|
|
|
43
46
|
@git = Command::Git.new(self)
|
|
44
47
|
|
|
45
|
-
@defines = %w
|
|
46
|
-
@include_paths = %w
|
|
47
|
-
@libraries = %w
|
|
48
|
-
@library_paths = %w
|
|
49
|
-
@flags = %w
|
|
48
|
+
@defines = %w[]
|
|
49
|
+
@include_paths = %w[]
|
|
50
|
+
@libraries = %w[]
|
|
51
|
+
@library_paths = %w[]
|
|
52
|
+
@flags = %w[]
|
|
50
53
|
|
|
51
54
|
@dependencies = []
|
|
52
55
|
@static_libraries = []
|
|
@@ -57,32 +60,35 @@ module Magica
|
|
|
57
60
|
|
|
58
61
|
Magica.default_toolchain.setup(self, Magica.toolchain_params) if Magica.default_toolchain
|
|
59
62
|
end
|
|
63
|
+
# rubocop:enable Metrics/AbcSize
|
|
60
64
|
|
|
61
65
|
def target(name, **options, &block)
|
|
62
66
|
return if block.nil?
|
|
63
67
|
name = name.to_sym
|
|
64
68
|
@targets[name] = block
|
|
65
69
|
@default_target = name if options[:default]
|
|
66
|
-
Target.new("#{@name}:#{name}", @options.to_h.merge(
|
|
70
|
+
Target.new("#{@name}:#{name}", @options.to_h.merge(target: name), &@config_block) if Magica.const_defined?('Target')
|
|
67
71
|
end
|
|
68
72
|
|
|
69
73
|
def define(name, value = nil)
|
|
70
74
|
if name.is_a?(Array)
|
|
71
75
|
name.flatten.map { |n| define(n, value) }
|
|
72
76
|
else
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
+
define_name = name.to_s.upcase
|
|
78
|
+
unless value.nil? || value.is_a?(Numeric)
|
|
79
|
+
value = format('\"%s\"', value)
|
|
80
|
+
end
|
|
81
|
+
define_name << "=#{value}" unless value.nil?
|
|
82
|
+
@defines.push(define_name)
|
|
77
83
|
end
|
|
78
|
-
@defines
|
|
84
|
+
@defines.uniq!
|
|
79
85
|
end
|
|
80
86
|
|
|
81
87
|
def include_path(path)
|
|
82
88
|
if path.is_a?(Array)
|
|
83
|
-
path.flatten.map
|
|
89
|
+
path.flatten.map { |p| include_path(p) }
|
|
84
90
|
else
|
|
85
|
-
@include_paths
|
|
91
|
+
@include_paths.push(path.to_s)
|
|
86
92
|
end
|
|
87
93
|
@include_paths
|
|
88
94
|
end
|
|
@@ -91,24 +97,24 @@ module Magica
|
|
|
91
97
|
if flag.is_a?(Array)
|
|
92
98
|
flag.flatten.map { |f| flag(f) }
|
|
93
99
|
else
|
|
94
|
-
@flags
|
|
100
|
+
@flags.push(flag.to_s)
|
|
95
101
|
end
|
|
96
102
|
@flags
|
|
97
103
|
end
|
|
98
104
|
|
|
99
105
|
def library(name, path = nil)
|
|
100
|
-
@libraries
|
|
101
|
-
@library_paths
|
|
106
|
+
@libraries.push(name.to_s).uniq!
|
|
107
|
+
@library_paths.push(path.to_s).uniq! if path
|
|
102
108
|
end
|
|
103
109
|
|
|
104
110
|
def library_path(path)
|
|
105
|
-
@
|
|
111
|
+
@library_paths.push(path.to_s).uniq!
|
|
106
112
|
end
|
|
107
113
|
|
|
108
114
|
def dynamic_library(name)
|
|
109
115
|
config = PackageConfig[name]
|
|
110
|
-
@libraries.push(*config.libraries)
|
|
111
|
-
@library_paths.push(*config.library_paths)
|
|
116
|
+
@libraries.push(*config.libraries).uniq!
|
|
117
|
+
@library_paths.push(*config.library_paths).uniq!
|
|
112
118
|
|
|
113
119
|
include_path(config.include_paths)
|
|
114
120
|
define(config.defines)
|
|
@@ -133,9 +139,9 @@ module Magica
|
|
|
133
139
|
end
|
|
134
140
|
|
|
135
141
|
def dependency(name, options = {}, &block)
|
|
136
|
-
Dependency.new(name, options, &block)
|
|
142
|
+
Dependency.new(self, name, options, &block)
|
|
137
143
|
desc "The targets #{@name}'s dependency project : #{name}"
|
|
138
|
-
task "#{@name}:dependency:#{name}" do
|
|
144
|
+
task "#{@name}:dependency:#{name}" do
|
|
139
145
|
Dependency[name].build(self)
|
|
140
146
|
end
|
|
141
147
|
@dependencies << "#{@name}:dependency:#{name}"
|
|
@@ -143,12 +149,12 @@ module Magica
|
|
|
143
149
|
end
|
|
144
150
|
|
|
145
151
|
def use(compiler)
|
|
146
|
-
return @compiler =
|
|
152
|
+
return @compiler = send(compiler.to_s) if COMPILERS.include?(compiler.to_s)
|
|
147
153
|
@compiler = @cc
|
|
148
154
|
end
|
|
149
155
|
|
|
150
156
|
def filename(name)
|
|
151
|
-
'"%s"'
|
|
157
|
+
format('"%s"', name)
|
|
152
158
|
end
|
|
153
159
|
|
|
154
160
|
def exe_path(path)
|
|
@@ -164,18 +170,21 @@ module Magica
|
|
|
164
170
|
if name.is_a?(Array)
|
|
165
171
|
name.flatten.map { |n| exefile(n) }
|
|
166
172
|
else
|
|
167
|
-
File.join(
|
|
173
|
+
File.join(
|
|
174
|
+
*[Magica.root, @exe_path, "#{name}#{@exts.executable}"]
|
|
175
|
+
.flatten.reject(&:empty?)
|
|
176
|
+
)
|
|
168
177
|
end
|
|
169
178
|
end
|
|
170
179
|
|
|
171
|
-
def libfile
|
|
172
|
-
end
|
|
173
|
-
|
|
174
180
|
def objfile(name)
|
|
175
181
|
if name.is_a?(Array)
|
|
176
182
|
name.flatten.map { |n| objfile(n) }
|
|
177
183
|
else
|
|
178
|
-
File.join(
|
|
184
|
+
File.join(
|
|
185
|
+
*[Magica.root, @dest, "#{name}#{@exts.object}"]
|
|
186
|
+
.flatten.reject(&:empty?)
|
|
187
|
+
)
|
|
179
188
|
end
|
|
180
189
|
end
|
|
181
190
|
|
|
@@ -195,28 +204,43 @@ module Magica
|
|
|
195
204
|
end
|
|
196
205
|
|
|
197
206
|
def add(source)
|
|
198
|
-
FileUtils.cp(
|
|
207
|
+
FileUtils.cp(
|
|
208
|
+
source,
|
|
209
|
+
File.join(*[Magica.root, @dest].flatten.reject(&:empty?))
|
|
210
|
+
)
|
|
199
211
|
end
|
|
200
212
|
|
|
201
213
|
def toolchain(name, params = {})
|
|
202
214
|
toolchain = Toolchain.toolchains[name]
|
|
203
|
-
|
|
215
|
+
raise I18n.t('magica.unknow_toolchain', toolchain: name) unless toolchain
|
|
204
216
|
toolchain.setup(self, params)
|
|
205
217
|
end
|
|
206
218
|
|
|
207
219
|
def compile(source)
|
|
208
220
|
return if Rake::Task.task_defined?(objfile(source))
|
|
209
221
|
file objfile(source) => source do |t|
|
|
210
|
-
@compiler.run
|
|
222
|
+
@compiler.run(
|
|
223
|
+
t.name,
|
|
224
|
+
t.prerequisites.first,
|
|
225
|
+
Build.current.defines,
|
|
226
|
+
Build.current.include_paths,
|
|
227
|
+
Build.current.flags
|
|
228
|
+
)
|
|
211
229
|
end
|
|
212
230
|
end
|
|
213
231
|
|
|
214
232
|
def link(exec, objects)
|
|
215
233
|
desc "Build #{@name}'s executable file"
|
|
216
|
-
task
|
|
234
|
+
task @name.to_s do
|
|
217
235
|
Build.current = Magica.builds[@name]
|
|
218
236
|
task "#{@name}:build" => @dependencies + objects do
|
|
219
|
-
@linker.run
|
|
237
|
+
@linker.run(
|
|
238
|
+
exec.to_s,
|
|
239
|
+
objects + @static_libraries,
|
|
240
|
+
@libraries,
|
|
241
|
+
@library_paths,
|
|
242
|
+
@flags
|
|
243
|
+
)
|
|
220
244
|
end.invoke
|
|
221
245
|
end
|
|
222
246
|
end
|
data/lib/magica/command.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
require 'forwardable'
|
|
2
2
|
|
|
3
3
|
module Magica
|
|
4
|
+
# :nodoc:
|
|
4
5
|
class Command
|
|
5
6
|
include Rake::DSL
|
|
6
7
|
extend Forwardable
|
|
@@ -13,9 +14,9 @@ module Magica
|
|
|
13
14
|
end
|
|
14
15
|
|
|
15
16
|
private
|
|
17
|
+
|
|
16
18
|
def _run(options, params = {})
|
|
17
19
|
sh command + ' ' + (options % params), verbose: false
|
|
18
20
|
end
|
|
19
|
-
|
|
20
21
|
end
|
|
21
22
|
end
|
|
@@ -1,31 +1,44 @@
|
|
|
1
1
|
module Magica
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
# rubocop:disable Style/FormatStringToken
|
|
3
|
+
class Command
|
|
4
|
+
# :nodoc:
|
|
5
|
+
class Compiler < Command
|
|
6
|
+
attr_accessor :flags
|
|
4
7
|
|
|
5
|
-
|
|
6
|
-
|
|
8
|
+
def initialize(build, source_exts = [])
|
|
9
|
+
super(build)
|
|
7
10
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
@command = ENV['CC'] || 'cc'
|
|
12
|
+
@flags = [ENV['CFLAGS'] || []]
|
|
13
|
+
@source_exts = source_exts
|
|
14
|
+
@compile_options = '%{flags} -o %{outfile} -c %{infile}'
|
|
15
|
+
@include_paths = ['include']
|
|
16
|
+
@defines = %w[]
|
|
14
17
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
@option_include_path = '-I%s'
|
|
19
|
+
@option_defines = '-D%s'
|
|
20
|
+
end
|
|
18
21
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
def combine_flags(defines = [], include_paths = [], flags = [])
|
|
23
|
+
define_flags = [
|
|
24
|
+
@defines, defines
|
|
25
|
+
].flatten.map { |define| @option_defines % define }
|
|
26
|
+
include_path_flags = [
|
|
27
|
+
@include_paths, include_paths
|
|
28
|
+
].flatten.map do |include_path|
|
|
29
|
+
@option_include_path % filename(include_path)
|
|
30
|
+
end
|
|
31
|
+
[define_flags, include_path_flags, flags].flatten.uniq.join(' ')
|
|
32
|
+
end
|
|
24
33
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
34
|
+
def run(outfile, infile, defines = [], include_paths = [], flags = [])
|
|
35
|
+
FileUtils.mkdir_p File.dirname(outfile)
|
|
36
|
+
puts "COMPILE\t#{outfile}"
|
|
37
|
+
_run(@compile_options,
|
|
38
|
+
outfile: outfile,
|
|
39
|
+
infile: infile,
|
|
40
|
+
flags: combine_flags(defines, include_paths, flags))
|
|
41
|
+
end
|
|
29
42
|
end
|
|
30
43
|
end
|
|
31
44
|
end
|
data/lib/magica/commands/git.rb
CHANGED
|
@@ -1,45 +1,53 @@
|
|
|
1
1
|
module Magica
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
# rubocop:disable Style/FormatStringToken
|
|
3
|
+
class Command
|
|
4
|
+
# :nodoc:
|
|
5
|
+
class Git < Command
|
|
6
|
+
attr_accessor :flags
|
|
7
|
+
attr_accessor :clone_options, :pull_options, :checkout_options
|
|
5
8
|
|
|
6
|
-
|
|
7
|
-
|
|
9
|
+
def initialize(build)
|
|
10
|
+
super
|
|
8
11
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
@command = 'git'
|
|
13
|
+
@flags = %w[]
|
|
14
|
+
@clone_options = 'clone %{flags} %{url} %{dir}'
|
|
15
|
+
@pull_options = 'pull %{flags} %{remote} %{branch}'
|
|
16
|
+
@checkout_options = 'checkout %{flags} %{checksum_hash}'
|
|
17
|
+
end
|
|
15
18
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
end
|
|
19
|
+
def clone(dir, url, flags = [])
|
|
20
|
+
_run format(@clone_options,
|
|
21
|
+
flags: [@flags, flags].flatten.join(' '),
|
|
22
|
+
dir: filename(dir),
|
|
23
|
+
url: url)
|
|
24
|
+
end
|
|
23
25
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
def pull(dir, remote = 'origin', branch = 'master')
|
|
27
|
+
workin dir do
|
|
28
|
+
_run format(@pull_options,
|
|
29
|
+
remote: remote,
|
|
30
|
+
branch: branch,
|
|
31
|
+
flags: @flags.join(' '))
|
|
32
|
+
end
|
|
27
33
|
end
|
|
28
|
-
end
|
|
29
34
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
35
|
+
def checkout(dir, checksum_hash)
|
|
36
|
+
workin dir do
|
|
37
|
+
_run format(@checkout_options,
|
|
38
|
+
checksum_hash: checksum_hash,
|
|
39
|
+
flags: @flags.join(' '))
|
|
40
|
+
end
|
|
33
41
|
end
|
|
34
|
-
end
|
|
35
42
|
|
|
36
|
-
|
|
37
|
-
def workin(dir)
|
|
38
|
-
root = Dir.pwd
|
|
39
|
-
Dir.chdir dir
|
|
40
|
-
yield if block_given?
|
|
41
|
-
Dir.chdir root
|
|
42
|
-
end
|
|
43
|
+
private
|
|
43
44
|
|
|
45
|
+
def workin(dir)
|
|
46
|
+
root = Dir.pwd
|
|
47
|
+
Dir.chdir dir
|
|
48
|
+
yield if block_given?
|
|
49
|
+
Dir.chdir root
|
|
50
|
+
end
|
|
51
|
+
end
|
|
44
52
|
end
|
|
45
53
|
end
|
|
@@ -1,37 +1,44 @@
|
|
|
1
1
|
module Magica
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
# rubocop:disable Style/FormatStringToken
|
|
3
|
+
class Command
|
|
4
|
+
# :nodoc:
|
|
5
|
+
class Linker < Command
|
|
6
|
+
attr_accessor :flags
|
|
4
7
|
|
|
5
|
-
|
|
6
|
-
|
|
8
|
+
def initialize(build)
|
|
9
|
+
super
|
|
7
10
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
@command = ENV['LD'] || 'ld'
|
|
12
|
+
@flags = (ENV['LDFLAGS'] || [])
|
|
13
|
+
@link_options = '%{flags} -o %{outfile} %{objects} %{libs}'
|
|
14
|
+
@libraries = []
|
|
15
|
+
@library_paths = []
|
|
13
16
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
@option_library = '-l%s'
|
|
18
|
+
@option_library_path = '-L%s'
|
|
19
|
+
end
|
|
17
20
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
def combine_flags(library_paths = [], flags = [])
|
|
22
|
+
library_paths = [
|
|
23
|
+
@library_paths, library_paths
|
|
24
|
+
].flatten.map { |path| @option_library_path % filename(path) }
|
|
25
|
+
[flags, library_paths, flags].flatten.uniq.join(' ')
|
|
26
|
+
end
|
|
22
27
|
|
|
23
|
-
|
|
24
|
-
|
|
28
|
+
def run(outfile, objects, libraries = [], library_paths = [], flags = [])
|
|
29
|
+
FileUtils.mkdir_p File.dirname(outfile)
|
|
25
30
|
|
|
26
|
-
|
|
31
|
+
library_flags = [
|
|
32
|
+
@libraries, libraries
|
|
33
|
+
].flatten.map { |library| @option_library % library }
|
|
27
34
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
+
puts "LINK\t#{outfile}"
|
|
36
|
+
_run(@link_options,
|
|
37
|
+
outfile: outfile,
|
|
38
|
+
objects: objects.join(' '),
|
|
39
|
+
libs: library_flags.uniq.join(' '),
|
|
40
|
+
flags: combine_flags(library_paths, flags))
|
|
41
|
+
end
|
|
35
42
|
end
|
|
36
43
|
end
|
|
37
44
|
end
|
data/lib/magica/dependency.rb
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
module Magica
|
|
2
|
+
# :nodoc:
|
|
3
|
+
# rubocop:disable Metrics/ClassLength
|
|
2
4
|
class Dependency
|
|
3
5
|
class << self
|
|
4
6
|
def [](name)
|
|
@@ -14,23 +16,27 @@ module Magica
|
|
|
14
16
|
|
|
15
17
|
include Rake::DSL
|
|
16
18
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
# rubocop:disable Metrics/MethodLength
|
|
20
|
+
def initialize(builder, name, _options = {}, &block)
|
|
21
|
+
@builder = builder
|
|
19
22
|
@name = name.to_s
|
|
20
23
|
@vcs = nil
|
|
21
24
|
@command = :git
|
|
22
|
-
@source =
|
|
25
|
+
@source = ''
|
|
23
26
|
@version = nil
|
|
24
27
|
@dir = "lib/#{@name}"
|
|
25
28
|
@install_dir = "#{@dir}/build"
|
|
26
|
-
@build_command =
|
|
29
|
+
@build_command = 'make'
|
|
27
30
|
@environments = {}
|
|
28
31
|
|
|
29
32
|
@static_libraries = []
|
|
30
33
|
|
|
31
34
|
Dependency[name] = self
|
|
32
35
|
Dependency[name].instance_eval(&block)
|
|
36
|
+
|
|
37
|
+
add_header "#{@dir}/include" if Dir.exist?("#{@dir}/include")
|
|
33
38
|
end
|
|
39
|
+
# rubocop:enable Metrics/MethodLength
|
|
34
40
|
|
|
35
41
|
def use(name)
|
|
36
42
|
@vcs = name.to_sym
|
|
@@ -40,24 +46,24 @@ module Magica
|
|
|
40
46
|
@environments[name.to_s] = value
|
|
41
47
|
end
|
|
42
48
|
|
|
43
|
-
def source(
|
|
44
|
-
@source =
|
|
49
|
+
def source(source)
|
|
50
|
+
@source = source.to_s
|
|
45
51
|
end
|
|
46
52
|
|
|
47
|
-
def dir(
|
|
48
|
-
@dir =
|
|
53
|
+
def dir(dir)
|
|
54
|
+
@dir = dir.to_s
|
|
49
55
|
end
|
|
50
56
|
|
|
51
|
-
def install_dir(
|
|
52
|
-
@install_dir =
|
|
57
|
+
def install_dir(dir)
|
|
58
|
+
@install_dir = dir.to_s
|
|
53
59
|
end
|
|
54
60
|
|
|
55
|
-
def version(
|
|
56
|
-
@version =
|
|
61
|
+
def version(version)
|
|
62
|
+
@version = version.to_s
|
|
57
63
|
end
|
|
58
64
|
|
|
59
|
-
def command(
|
|
60
|
-
@build_command =
|
|
65
|
+
def command(command)
|
|
66
|
+
@build_command = command.to_s
|
|
61
67
|
end
|
|
62
68
|
|
|
63
69
|
def static_library(*name)
|
|
@@ -65,38 +71,57 @@ module Magica
|
|
|
65
71
|
end
|
|
66
72
|
|
|
67
73
|
def build(builder)
|
|
68
|
-
|
|
74
|
+
clean if @builder.options[:clean_all]
|
|
69
75
|
|
|
70
|
-
|
|
71
|
-
clean if options[:clean_all]
|
|
72
|
-
|
|
73
|
-
return if !options[:clean_all] & File.exists?(@install_dir)
|
|
76
|
+
return unless exec?
|
|
74
77
|
|
|
75
78
|
setup_environment
|
|
79
|
+
clone(builder)
|
|
80
|
+
exec
|
|
81
|
+
end
|
|
76
82
|
|
|
77
|
-
|
|
78
|
-
@
|
|
79
|
-
|
|
83
|
+
def add_src(*paths)
|
|
84
|
+
@builder.source(@builder.sources + paths)
|
|
85
|
+
end
|
|
80
86
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
Dir.chdir root
|
|
87
|
+
def add_header(*paths)
|
|
88
|
+
@builder.include_path(paths)
|
|
84
89
|
end
|
|
85
90
|
|
|
86
91
|
def static_libraries
|
|
87
92
|
@static_libraries.map do |library|
|
|
88
|
-
File.join(*[
|
|
93
|
+
File.join(*[
|
|
94
|
+
Magica.root, @install_dir, library
|
|
95
|
+
].flatten.reject(&:empty?))
|
|
89
96
|
end
|
|
90
97
|
end
|
|
91
98
|
|
|
92
99
|
private
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
100
|
+
|
|
101
|
+
def exec?
|
|
102
|
+
clean_all = @builder.options[:clean_all]
|
|
103
|
+
return false if !clean_all & File.exist?(@install_dir)
|
|
104
|
+
return false if !clean_all & @build_command.empty? & File.exist?(@dir)
|
|
105
|
+
true
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def exec
|
|
109
|
+
root = Dir.pwd
|
|
110
|
+
Dir.chdir source_dir
|
|
111
|
+
sh @build_command, verbose: false unless @build_command.empty?
|
|
112
|
+
Dir.chdir root
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def clone(builder)
|
|
116
|
+
@vcs = builder.send(@command)
|
|
117
|
+
@vcs.flags = %w[--quiet]
|
|
118
|
+
|
|
119
|
+
puts "UPDATE DEPENDENCY\t #{[@name, @version].join(' ')}"
|
|
120
|
+
|
|
121
|
+
if Dir.exist?(source_dir)
|
|
96
122
|
checkout if @version
|
|
97
123
|
pull
|
|
98
124
|
else
|
|
99
|
-
puts "DOWNLOAD DEPENDENCY\t#{@name}-#{@version}"
|
|
100
125
|
@vcs.clone(source_dir, @source)
|
|
101
126
|
checkout if @version
|
|
102
127
|
end
|
|
@@ -123,6 +148,5 @@ module Magica
|
|
|
123
148
|
def clean
|
|
124
149
|
FileUtils.rm_r(@install_dir, force: true)
|
|
125
150
|
end
|
|
126
|
-
|
|
127
151
|
end
|
|
128
152
|
end
|
data/lib/magica/dsl.rb
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
module Magica
|
|
2
|
+
# :nodoc:
|
|
2
3
|
module DSL
|
|
3
4
|
def toolchain(name, params = {})
|
|
4
5
|
toolchain = Toolchain.toolchains[name.to_s]
|
|
5
|
-
|
|
6
|
+
raise I18n.t('magica.unknow_toolchain', toolchain: name) if toolchain.nil?
|
|
6
7
|
Magica.default_toolchain = toolchain
|
|
7
8
|
Magica.toolchain_params = params
|
|
8
9
|
end
|
|
9
10
|
|
|
10
|
-
def build(name = 'host', options = {dest: 'build'}, &block)
|
|
11
|
+
def build(name = 'host', options = { dest: 'build' }, &block)
|
|
11
12
|
Build.new(name, options, &block)
|
|
12
13
|
end
|
|
13
14
|
|
data/lib/magica/extension.rb
CHANGED
data/lib/magica/framework.rb
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
load File.expand_path(
|
|
2
|
-
require
|
|
1
|
+
load File.expand_path('../tasks/framework.rake', __FILE__)
|
|
2
|
+
require 'magica/initialize'
|
data/lib/magica/i18n.rb
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
require 'i18n'
|
|
2
2
|
|
|
3
|
+
# rubocop:disable Metrics/LineLength
|
|
4
|
+
# rubocop:disable Style/FormatStringToken
|
|
3
5
|
en = {
|
|
4
6
|
not_init_project: 'The project is not initialize, please run "magica init" before start use it',
|
|
5
7
|
unknow_toolchain: 'Unknow %{toolchain} toolchain',
|
|
6
8
|
unknow_build: 'Unknow %{build} build'
|
|
7
9
|
}
|
|
10
|
+
# rubocop:enable Metrics/LineLength
|
|
8
11
|
|
|
9
12
|
I18n.backend.store_translations(:en, magica: en)
|
|
10
13
|
|
data/lib/magica/initialize.rb
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
load File.expand_path(
|
|
1
|
+
load File.expand_path('../tasks/initialize.rake', __FILE__)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
module Magica
|
|
2
|
+
# :nodoc:
|
|
2
3
|
class PackageConfig
|
|
3
4
|
class << self
|
|
4
5
|
def [](name)
|
|
@@ -16,23 +17,45 @@ module Magica
|
|
|
16
17
|
DEFINE_RULE = /-D([^\s]+)/
|
|
17
18
|
FLAG_RULE = /-[^ID][^\s]+/
|
|
18
19
|
|
|
19
|
-
attr_reader :library_paths, :libraries, :library_flags,
|
|
20
|
+
attr_reader :library_paths, :libraries, :library_flags,
|
|
21
|
+
:include_paths, :defines, :flags, :version
|
|
20
22
|
|
|
21
23
|
def initialize(name)
|
|
22
|
-
|
|
24
|
+
raise "Cannot found library #{name}" unless package_exist?(name)
|
|
25
|
+
@name = name
|
|
23
26
|
|
|
24
|
-
@package_libraries = `pkg-config --libs #{name}`.strip
|
|
27
|
+
@package_libraries = `pkg-config --libs #{@name}`.strip
|
|
28
|
+
@package_cflags = `pkg-config --cflags #{@name}`.strip
|
|
25
29
|
|
|
26
|
-
@
|
|
27
|
-
|
|
28
|
-
|
|
30
|
+
@version = `pkg-config --modversion #{@name}`.strip
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def package_exist?(name)
|
|
34
|
+
system "pkg-config --exists #{name}"
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def libraries
|
|
38
|
+
@libraries ||= @package_libraries.scan(LIBRARY_RULE).flatten
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def library_flags
|
|
42
|
+
@library_flags ||= @package_libraries.scan(LIBRARY_FLAG_RULE).flatten
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def library_paths
|
|
46
|
+
@library_paths ||= @package_libraries.scan(LIBRARY_PATH_RULE).flatten
|
|
47
|
+
end
|
|
29
48
|
|
|
30
|
-
|
|
31
|
-
@
|
|
32
|
-
|
|
33
|
-
|
|
49
|
+
def flags
|
|
50
|
+
@flags ||= @package_cflags.scan(FLAG_RULE).flatten
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def defines
|
|
54
|
+
@defines ||= @package_cflags.scan(DEFINE_RULE).flatten
|
|
55
|
+
end
|
|
34
56
|
|
|
35
|
-
|
|
57
|
+
def include_paths
|
|
58
|
+
@include_paths ||= @package_cflags.scan(INCLUDE_RULE).flatten
|
|
36
59
|
end
|
|
37
60
|
end
|
|
38
61
|
end
|
data/lib/magica/target.rb
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
include Magica::DSL
|
|
2
2
|
|
|
3
|
-
require
|
|
3
|
+
require 'magica/framework'
|
|
4
4
|
|
|
5
5
|
module Magica
|
|
6
|
+
# :nodoc:
|
|
6
7
|
class Target < Build
|
|
7
8
|
def target(name, **options, &block)
|
|
8
9
|
return if block.nil?
|
|
@@ -13,7 +14,7 @@ module Magica
|
|
|
13
14
|
|
|
14
15
|
def dependency(name, options = {}, &block)
|
|
15
16
|
Dependency.new(name, options, &block)
|
|
16
|
-
task "#{@name}:dependency:#{name}" do
|
|
17
|
+
task "#{@name}:dependency:#{name}" do
|
|
17
18
|
Dependency[name].build(self)
|
|
18
19
|
end
|
|
19
20
|
@dependencies << "#{@name}:dependency:#{name}"
|
|
@@ -1,17 +1,11 @@
|
|
|
1
1
|
task default: :_all
|
|
2
2
|
|
|
3
|
-
task :_all do
|
|
3
|
+
task :_all do
|
|
4
4
|
if Rake::Task.task_defined?(:all)
|
|
5
5
|
Rake::Task[:all].invoke
|
|
6
6
|
else
|
|
7
7
|
Magica.each_build do
|
|
8
|
-
Rake::Task[
|
|
8
|
+
Rake::Task[@name.to_s].invoke
|
|
9
9
|
end
|
|
10
10
|
end
|
|
11
11
|
end
|
|
12
|
-
|
|
13
|
-
task :environment do |t|
|
|
14
|
-
p "ENV ===>"
|
|
15
|
-
p Magica::Build.current
|
|
16
|
-
t.reenable
|
|
17
|
-
end
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
task :init do
|
|
2
|
-
magicafile = File.expand_path(
|
|
2
|
+
magicafile = File.expand_path('../../templates/Magicafile', __FILE__)
|
|
3
3
|
|
|
4
|
-
if File.exist?(
|
|
5
|
-
warn
|
|
4
|
+
if File.exist?('Magicafile')
|
|
5
|
+
warn '[Skip] Magica is already exists'
|
|
6
6
|
else
|
|
7
|
-
FileUtils.cp(magicafile,
|
|
7
|
+
FileUtils.cp(magicafile, 'Magicafile')
|
|
8
8
|
puts "create\tMagicafile"
|
|
9
|
-
puts "Magica
|
|
9
|
+
puts "Magica\tInitialized"
|
|
10
10
|
end
|
|
11
11
|
end
|
|
@@ -5,7 +5,6 @@ require "magica/target"
|
|
|
5
5
|
toolchain :gcc
|
|
6
6
|
|
|
7
7
|
# Define Build Task
|
|
8
|
-
# build :main, {clean: true}
|
|
9
8
|
build :main, {clean: true} do
|
|
10
9
|
# define :debug
|
|
11
10
|
# dynamic_library "sdl2"
|
|
@@ -13,8 +12,9 @@ build :main, {clean: true} do
|
|
|
13
12
|
# dependency :mruby do
|
|
14
13
|
# source "git@github.com:mruby/mruby.git"
|
|
15
14
|
# version "1.2.0"
|
|
16
|
-
# command "./minirake
|
|
15
|
+
# command "./minirake --quiet"
|
|
17
16
|
#
|
|
17
|
+
# install_dir "#{@dir}/build/host/lib"
|
|
18
18
|
# static_library "libmruby.a"
|
|
19
19
|
# end
|
|
20
20
|
|
data/lib/magica/toolchain.rb
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
# :nodoc:
|
|
1
2
|
module Magica
|
|
3
|
+
# :nodoc:
|
|
2
4
|
class Toolchain
|
|
3
5
|
include Rake::DSL
|
|
4
6
|
|
|
@@ -7,7 +9,8 @@ module Magica
|
|
|
7
9
|
end
|
|
8
10
|
|
|
9
11
|
def initialize(name, &block)
|
|
10
|
-
@name
|
|
12
|
+
@name = name.to_s
|
|
13
|
+
@initializer = block
|
|
11
14
|
Toolchain.toolchains ||= {}
|
|
12
15
|
Toolchain.toolchains[@name] = self
|
|
13
16
|
end
|
|
@@ -17,7 +20,7 @@ module Magica
|
|
|
17
20
|
end
|
|
18
21
|
|
|
19
22
|
def self.load
|
|
20
|
-
builtin_path = File.join(File.dirname(__FILE__),
|
|
23
|
+
builtin_path = File.join(File.dirname(__FILE__), 'toolchains')
|
|
21
24
|
Dir.glob("#{builtin_path}/*.rake").each do |file|
|
|
22
25
|
Kernel.load file
|
|
23
26
|
end
|
|
@@ -26,4 +29,3 @@ module Magica
|
|
|
26
29
|
|
|
27
30
|
Toolchain.load
|
|
28
31
|
end
|
|
29
|
-
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
# rubocop:disable Matrics/LineLength
|
|
2
|
+
Magica::Toolchain.new :gcc do |config, _|
|
|
2
3
|
config.cc do |cc|
|
|
3
|
-
cc.command = ENV['CC'] ||
|
|
4
|
-
cc.flags = [ENV['CFLAGS'] || %w
|
|
4
|
+
cc.command = ENV['CC'] || 'gcc'
|
|
5
|
+
cc.flags = [ENV['CFLAGS'] || %w[-g -std=gnu99 -O3 -Wall -Werror-implicit-function-declaration -Wdeclaration-after-statement -Wwrite-strings]]
|
|
5
6
|
end
|
|
6
7
|
|
|
7
8
|
config.cxx do |cxx|
|
|
8
|
-
cxx.command = ENV['CXX'] ||
|
|
9
|
-
cxx.flags = [ENV['CXXFLAGS'] || %w
|
|
9
|
+
cxx.command = ENV['CXX'] || 'g++'
|
|
10
|
+
cxx.flags = [ENV['CXXFLAGS'] || %w[-g -O3 -Wall -Werror-implicit-function-declaration]]
|
|
10
11
|
end
|
|
11
12
|
|
|
12
13
|
config.linker do |linker|
|
|
13
|
-
linker.command = ENV['LD'] ||
|
|
14
|
-
linker.flags = [ENV['LDFLAGS'] || %w
|
|
14
|
+
linker.command = ENV['LD'] || 'gcc'
|
|
15
|
+
linker.flags = [ENV['LDFLAGS'] || %w[]]
|
|
15
16
|
end
|
|
16
17
|
end
|
data/lib/magica/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: magica
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.8.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- 蒼時弦也
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2017-06-
|
|
11
|
+
date: 2017-06-05 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rake
|
|
@@ -97,10 +97,8 @@ files:
|
|
|
97
97
|
- lib/magica/framework.rb
|
|
98
98
|
- lib/magica/i18n.rb
|
|
99
99
|
- lib/magica/initialize.rb
|
|
100
|
-
- lib/magica/magica.rb
|
|
101
100
|
- lib/magica/package_config.rb
|
|
102
101
|
- lib/magica/target.rb
|
|
103
|
-
- lib/magica/tasks/build.rake
|
|
104
102
|
- lib/magica/tasks/framework.rake
|
|
105
103
|
- lib/magica/tasks/initialize.rake
|
|
106
104
|
- lib/magica/templates/Magicafile
|
data/lib/magica/magica.rb
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
module Magica
|
|
2
|
-
class << self
|
|
3
|
-
attr_accessor :default_toolchain, :toolchain_params
|
|
4
|
-
|
|
5
|
-
def builds
|
|
6
|
-
@builds ||= {}
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
def each_build(&block)
|
|
10
|
-
return to_enum(:each_build) if block.nil?
|
|
11
|
-
@builds.each do |key, build|
|
|
12
|
-
build.instance_eval(&block)
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def root
|
|
17
|
-
Dir.pwd
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def default_compile_task
|
|
21
|
-
proc { |options|
|
|
22
|
-
clean if options[:clean]
|
|
23
|
-
|
|
24
|
-
do_target(options[:target])
|
|
25
|
-
|
|
26
|
-
objects = objfile(@sources)
|
|
27
|
-
@sources.each { |source| compile source }
|
|
28
|
-
|
|
29
|
-
link exefile, objects
|
|
30
|
-
}
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
data/lib/magica/tasks/build.rake
DELETED
|
File without changes
|