mundler 0.5.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/mundle +2 -0
- data/lib/mundler/build_config.rb +177 -0
- data/lib/mundler/cached_git/cached_git +53 -0
- data/lib/mundler/cached_git/git +19 -0
- data/lib/mundler/clean_environment.rb +11 -0
- data/{Users/dan2552/Dropbox/experiments/mundler/lib → lib}/mundler/cli.rb +4 -2
- data/{Users/dan2552/Dropbox/experiments/mundler/lib → lib}/mundler/config.rb +22 -0
- data/{Users/dan2552/Dropbox/experiments/mundler/lib → lib}/mundler/dsl.rb +35 -5
- data/lib/mundler/libraries/example.rb +13 -0
- data/{Users/dan2552/Dropbox/experiments/mundler/lib → lib}/mundler/mruby.rb +26 -26
- data/lib/mundler/platforms/android.rb +54 -0
- data/lib/mundler/platforms/host.rb +23 -0
- data/{Users/dan2552/Dropbox/experiments/mundler/lib → lib}/mundler/platforms/ios.rb +12 -5
- data/{Users/dan2552/Dropbox/experiments/mundler/lib → lib}/mundler/platforms/ios_simulator.rb +11 -5
- data/{Users/dan2552/Dropbox/experiments/mundler/lib → lib}/mundler/project.rb +0 -0
- data/lib/mundler/version.rb +3 -0
- data/{Users/dan2552/Dropbox/experiments/mundler/lib → lib}/mundler.rb +2 -0
- metadata +18 -12
- data/Users/dan2552/Dropbox/experiments/mundler/lib/mundler/build_config.rb +0 -75
- data/Users/dan2552/Dropbox/experiments/mundler/lib/mundler/version.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e34cffc5ea496c40d16c21f544456bf5fa2db7f921e7c70aa000c5b5fdb5cdc5
|
4
|
+
data.tar.gz: 125ad566d2322fa8d931a428c5d8cdfc7df98818dd3e793c1a7a23b66e225758
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 326e51648e28ea76872db38f4d8c03168960fad4ed5ee8c53e37b7d6da3d8605f62152a1aa87d22dd04b6e4070bfa60fad265cb52ec5dc8046c323f5f4488219
|
7
|
+
data.tar.gz: ba5c5387ddfa27ac31e10f53c128e4b26c319c03dcfde893bea970309025bc44d1cfdb568662e60071a3a255d72312b758d870bb180e9407e8626dfb81a90c99
|
data/exe/mundle
CHANGED
@@ -0,0 +1,177 @@
|
|
1
|
+
module Mundler
|
2
|
+
class BuildConfig
|
3
|
+
def initialize(config)
|
4
|
+
@config = config
|
5
|
+
end
|
6
|
+
|
7
|
+
def tempfile
|
8
|
+
tempfile = Tempfile.new("build_config.rb")
|
9
|
+
File.write(tempfile, contents)
|
10
|
+
tempfile
|
11
|
+
end
|
12
|
+
|
13
|
+
def gemboxes
|
14
|
+
@config.gemboxes.map do |gembox|
|
15
|
+
"conf.gembox #{gembox.inspect}"
|
16
|
+
end.join("\n")
|
17
|
+
end
|
18
|
+
|
19
|
+
def gems
|
20
|
+
@config.gems.map do |gem|
|
21
|
+
# e.g. gem = {:name=>"mruby-regexp-pcre", :path=>nil, :github=>nil, :core=>nil}
|
22
|
+
args = ":mgem => #{gem[:name].inspect}"
|
23
|
+
|
24
|
+
if gem[:github]
|
25
|
+
args = ":github => #{gem[:github].inspect}"
|
26
|
+
elsif gem[:path]
|
27
|
+
args = ":path => #{gem[:path].inspect}"
|
28
|
+
elsif gem[:core]
|
29
|
+
args = ":core => #{gem[:core].inspect}"
|
30
|
+
end
|
31
|
+
|
32
|
+
"conf.gem #{args}"
|
33
|
+
end.join("\n ")
|
34
|
+
end
|
35
|
+
|
36
|
+
def mruby_version
|
37
|
+
mruby_url = @config.mruby[:url]
|
38
|
+
|
39
|
+
version = (
|
40
|
+
@config.mruby[:tag] ||
|
41
|
+
@config.mruby[:branch] ||
|
42
|
+
@config.mruby[:version]
|
43
|
+
)
|
44
|
+
|
45
|
+
"#{mruby_url} #{version}"
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def host_platform
|
51
|
+
@config.platforms
|
52
|
+
.select { |attributes| attributes[:name].to_s == "host" }
|
53
|
+
.map { |attributes| platform(attributes) }
|
54
|
+
.join("\n")
|
55
|
+
end
|
56
|
+
|
57
|
+
def non_host_platforms
|
58
|
+
@config.platforms
|
59
|
+
.select { |attributes| attributes[:name].to_s != "host" }
|
60
|
+
.map { |attributes| platform(attributes) }
|
61
|
+
.join("\n")
|
62
|
+
end
|
63
|
+
|
64
|
+
def platform(platform_attrs)
|
65
|
+
platform_name = platform_attrs[:name].to_s
|
66
|
+
type = @config.platform_types[platform_name]
|
67
|
+
raise "Can't find platform: #{platform_name}" unless type
|
68
|
+
|
69
|
+
options = {}
|
70
|
+
@config.libraries.each do |library_name, library_options|
|
71
|
+
library_type = @config.library_types[library_name]
|
72
|
+
|
73
|
+
raise "Unknown library: #{library_name}" unless library_type
|
74
|
+
|
75
|
+
library_builder = library_type.new
|
76
|
+
|
77
|
+
puts "Using #{library_name} library (#{platform_name})"
|
78
|
+
library_builder.build(platform_name, library_options)
|
79
|
+
library_attrs = library_builder.platform_configuration(platform_name, library_options)
|
80
|
+
raise "Library #{library_name} for platform #{platform_name} returned expected result" unless library_attrs.is_a?(Hash)
|
81
|
+
merge_platform_attributes!(options, library_attrs)
|
82
|
+
end
|
83
|
+
|
84
|
+
merge_platform_attributes!(options, platform_attrs[:options])
|
85
|
+
|
86
|
+
type.config(options, self)
|
87
|
+
end
|
88
|
+
|
89
|
+
# Merge with a bit of specific logic to make sure build settings
|
90
|
+
#
|
91
|
+
# E.g. if lhs was something like
|
92
|
+
#
|
93
|
+
# ```
|
94
|
+
# {
|
95
|
+
# cc: { flags: "-I#{sdl_install}/include/SDL2" },
|
96
|
+
# linker: { flags: "-L#{sdl_install}/lib -lSDL2 -lSDL2_image -lSDL2_ttf" }
|
97
|
+
# }
|
98
|
+
# ```
|
99
|
+
#
|
100
|
+
# and rhs was like
|
101
|
+
#
|
102
|
+
# ```
|
103
|
+
# {
|
104
|
+
# cc: { flags: "abc" },
|
105
|
+
# linker: { flags: "def" },
|
106
|
+
# more_options: true
|
107
|
+
# }
|
108
|
+
# ```
|
109
|
+
#
|
110
|
+
# result would be
|
111
|
+
# ```
|
112
|
+
# {
|
113
|
+
# cc: { flags: ["-I#{sdl_install}/include/SDL2", "abc"] },
|
114
|
+
# linker: { flags: ["-L#{sdl_install}/lib -lSDL2 -lSDL2_image -lSDL2_ttf", "def"] }
|
115
|
+
# more_options: true
|
116
|
+
# }
|
117
|
+
# ```
|
118
|
+
#
|
119
|
+
def merge_platform_attributes!(lhs, rhs)
|
120
|
+
rhs = rhs.dup
|
121
|
+
|
122
|
+
[:cc, :linker].each do |cc_or_linker|
|
123
|
+
[:command, :flags].each do |command_or_flags|
|
124
|
+
lhs_flags = lhs.dig(cc_or_linker, command_or_flags)
|
125
|
+
rhs_flags = rhs.dig(cc_or_linker, command_or_flags)
|
126
|
+
|
127
|
+
if rhs_flags
|
128
|
+
lhs[cc_or_linker] ||= {}
|
129
|
+
lhs[cc_or_linker][command_or_flags] ||= []
|
130
|
+
lhs_flags = lhs.dig(cc_or_linker, command_or_flags)
|
131
|
+
|
132
|
+
if lhs_flags.is_a?(String)
|
133
|
+
lhs[cc_or_linker][command_or_flags] = [lhs_flags]
|
134
|
+
end
|
135
|
+
|
136
|
+
if rhs_flags.is_a?(String)
|
137
|
+
rhs[cc_or_linker][command_or_flags] = [rhs_flags]
|
138
|
+
end
|
139
|
+
|
140
|
+
lhs[cc_or_linker][command_or_flags] = lhs[cc_or_linker][command_or_flags] + rhs[cc_or_linker][command_or_flags]
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
rhs.delete(cc_or_linker)
|
145
|
+
end
|
146
|
+
|
147
|
+
lhs.merge!(rhs)
|
148
|
+
end
|
149
|
+
|
150
|
+
def env_vars
|
151
|
+
str = ""
|
152
|
+
@config.env.each do |key, value|
|
153
|
+
str = str + "\nENV[\"#{key}\"] = \"#{value}\""
|
154
|
+
end
|
155
|
+
str
|
156
|
+
end
|
157
|
+
|
158
|
+
def contents
|
159
|
+
contents = <<~CONTENTS
|
160
|
+
# #{mruby_version}
|
161
|
+
#{env_vars}
|
162
|
+
|
163
|
+
MRuby::Build.new do |conf|
|
164
|
+
toolchain :clang
|
165
|
+
|
166
|
+
#{host_platform}
|
167
|
+
#{gemboxes}
|
168
|
+
#{gems}
|
169
|
+
end
|
170
|
+
|
171
|
+
#{non_host_platforms}
|
172
|
+
CONTENTS
|
173
|
+
|
174
|
+
(contents.strip + "\n").gsub("\n\n\n", "\n\n")
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "fileutils"
|
4
|
+
|
5
|
+
paths = ENV["PATH"].split(":")
|
6
|
+
script_dir = File.expand_path(__dir__)
|
7
|
+
paths.delete_if { |p| p.strip == script_dir.strip }
|
8
|
+
|
9
|
+
if ARGV[0] == "clone"
|
10
|
+
repo = ARGV[-2]
|
11
|
+
target = ARGV[-1]
|
12
|
+
original_repo = repo
|
13
|
+
repo = repo.gsub(/.git$/, "")
|
14
|
+
repo_org = repo.split("/")[-2]
|
15
|
+
repo_name = repo.split("/")[-1]
|
16
|
+
|
17
|
+
mundler_root = File.join(ENV["HOME"], ".mundler")
|
18
|
+
cache_root = File.join(mundler_root, "cache")
|
19
|
+
|
20
|
+
unless File.directory?(File.join(cache_root, repo_org, repo_name))
|
21
|
+
FileUtils.mkdir_p(File.join(cache_root, repo_org))
|
22
|
+
FileUtils.cd(File.join(cache_root, repo_org)) do
|
23
|
+
system(
|
24
|
+
{ "PATH" => paths.join(":") },
|
25
|
+
"git clone #{original_repo}"
|
26
|
+
)
|
27
|
+
end
|
28
|
+
status = $?.exitstatus
|
29
|
+
if status != 0
|
30
|
+
puts "Real git failed with status #{status}"
|
31
|
+
exit(status)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
full_target = target.start_with?("/") ? target : File.expand_path(File.join(Dir.pwd, target))
|
36
|
+
|
37
|
+
if File.directory?(full_target) && Dir.glob(File.join(full_target, "**", "*")).count > 0
|
38
|
+
warn "fatal: destination path '#{target}' already exists and is not an empty directory."
|
39
|
+
exit 1
|
40
|
+
else
|
41
|
+
FileUtils.cp_r(
|
42
|
+
File.join(cache_root, repo_org, repo_name, "."),
|
43
|
+
File.join(full_target)
|
44
|
+
)
|
45
|
+
puts "Copied #{repo_name} from cache as #{target} (#{full_target})"
|
46
|
+
end
|
47
|
+
else
|
48
|
+
system(
|
49
|
+
{ "PATH" => paths.join(":") },
|
50
|
+
"git #{ARGV.join(" ")}"
|
51
|
+
)
|
52
|
+
exit($?.exitstatus || 0)
|
53
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
def git
|
4
|
+
dir = __dir__
|
5
|
+
File.expand_path(File.join(dir, "cached_git"))
|
6
|
+
end
|
7
|
+
|
8
|
+
def main
|
9
|
+
system("#{git} #{ARGV.join(" ")}")
|
10
|
+
exit($?.exitstatus || 0)
|
11
|
+
end
|
12
|
+
|
13
|
+
if defined?(Bundler) && Bundler.respond_to?(:with_unbundled_env)
|
14
|
+
Bundler.with_unbundled_env { main }
|
15
|
+
elsif defined?(Bundler)
|
16
|
+
Bundler.with_clean_env { main }
|
17
|
+
else
|
18
|
+
main
|
19
|
+
end
|
@@ -11,11 +11,12 @@ module Mundler
|
|
11
11
|
desc "install", "Download and compile mruby"
|
12
12
|
def install
|
13
13
|
Mundler::Project.new(Dir.pwd).install
|
14
|
+
puts("\e[32mMundle complete!\e[0m")
|
14
15
|
rescue Mundler::CompilationError
|
15
|
-
$stderr.puts("\e[
|
16
|
+
$stderr.puts("\e[31mMundle failed\e[0m")
|
16
17
|
exit 1
|
17
18
|
rescue Interrupt
|
18
|
-
$stderr.puts("\e[
|
19
|
+
$stderr.puts("\e[31mMundle failed (user cancelled)\e[0m")
|
19
20
|
exit 1
|
20
21
|
rescue MundlefileNotFound
|
21
22
|
$stderr.puts("\e[31mMundlefile not found in the current directory\e[0m")
|
@@ -27,6 +28,7 @@ module Mundler
|
|
27
28
|
project = Mundler::Project.new(Dir.pwd)
|
28
29
|
project.clean
|
29
30
|
project.install
|
31
|
+
puts("\e[32mMundle complete!\e[0m")
|
30
32
|
rescue Mundler::CompilationError
|
31
33
|
$stderr.puts("\e[31mFailed to install\e[0m")
|
32
34
|
exit 1
|
@@ -10,10 +10,16 @@ module Mundler
|
|
10
10
|
@gemboxes = []
|
11
11
|
@gems = []
|
12
12
|
@platform_types = {}
|
13
|
+
@library_types = {}
|
14
|
+
@env = {}
|
15
|
+
@libraries = {}
|
13
16
|
end
|
14
17
|
|
15
18
|
attr_reader :mruby
|
16
19
|
attr_reader :platform_types
|
20
|
+
attr_reader :library_types
|
21
|
+
attr_reader :libraries
|
22
|
+
attr_reader :env
|
17
23
|
|
18
24
|
def hex
|
19
25
|
Digest::MD5.hexdigest(to_s)
|
@@ -36,9 +42,25 @@ module Mundler
|
|
36
42
|
#{mruby.inspect}
|
37
43
|
#{platforms.inspect}
|
38
44
|
#{platform_types.keys.sort.inspect}
|
45
|
+
#{library_types.keys.sort.inspect}
|
46
|
+
#{hashable_string_for_hash(env)}
|
39
47
|
#{gemboxes.inspect}
|
40
48
|
#{gems.inspect}
|
49
|
+
#{hashable_string_for_hash(libraries)}
|
41
50
|
HASHABLE
|
42
51
|
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def hashable_string_for_hash(hash)
|
56
|
+
str = "{"
|
57
|
+
sorted_keys = hash.keys.sort
|
58
|
+
|
59
|
+
sorted_keys.map do |key|
|
60
|
+
str = str + "#{key}=>#{hash[key]}"
|
61
|
+
end.join(", ")
|
62
|
+
|
63
|
+
str + "}"
|
64
|
+
end
|
43
65
|
end
|
44
66
|
end
|
@@ -3,13 +3,12 @@ module Mundler
|
|
3
3
|
def initialize(path)
|
4
4
|
@config = Config.new
|
5
5
|
@path = path
|
6
|
+
|
7
|
+
load_libraries
|
8
|
+
load_platforms
|
6
9
|
end
|
7
10
|
|
8
11
|
def evaluate!
|
9
|
-
platforms = Dir.glob(File.join(__dir__, "platforms", "*.rb"))
|
10
|
-
platforms.each do |platform|
|
11
|
-
instance_eval(File.read(platform))
|
12
|
-
end
|
13
12
|
begin
|
14
13
|
instance_eval(File.read(@path), @path)
|
15
14
|
rescue Errno::ENOENT
|
@@ -19,6 +18,20 @@ module Mundler
|
|
19
18
|
|
20
19
|
attr_reader :config
|
21
20
|
|
21
|
+
def load_libraries
|
22
|
+
libraries = Dir.glob(File.join(__dir__, "libraries", "*.rb"))
|
23
|
+
libraries.each do |library|
|
24
|
+
instance_eval(File.read(library))
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def load_platforms
|
29
|
+
platforms = Dir.glob(File.join(__dir__, "platforms", "*.rb"))
|
30
|
+
platforms.each do |platform|
|
31
|
+
instance_eval(File.read(platform))
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
22
35
|
private
|
23
36
|
|
24
37
|
def mruby(url: nil, tag: nil, branch: nil)
|
@@ -36,12 +49,29 @@ module Mundler
|
|
36
49
|
config.platform_types[name.to_s] = platform_class
|
37
50
|
end
|
38
51
|
|
39
|
-
def platform(name, options)
|
52
|
+
def platform(name, options = {})
|
40
53
|
config.platforms << { name: name.to_s, options: options }
|
41
54
|
end
|
42
55
|
|
43
56
|
def gem(name, core: nil, path: nil, github: nil)
|
57
|
+
if path && !path.start_with?("/")
|
58
|
+
app_path = Pathname.new(@path).dirname.to_s
|
59
|
+
path = File.expand_path(File.join(app_path, path))
|
60
|
+
end
|
61
|
+
|
44
62
|
config.gems << { name: name, path: path, github: github, core: core }
|
45
63
|
end
|
64
|
+
|
65
|
+
def env(name, value)
|
66
|
+
config.env[name] = value
|
67
|
+
end
|
68
|
+
|
69
|
+
def library(name, options = {})
|
70
|
+
config.libraries[name.to_s] = options
|
71
|
+
end
|
72
|
+
|
73
|
+
def define_library(name, library_class)
|
74
|
+
config.library_types[name.to_s] = library_class
|
75
|
+
end
|
46
76
|
end
|
47
77
|
end
|
@@ -29,7 +29,8 @@ module Mundler
|
|
29
29
|
FileUtils.rm_rf(@path)
|
30
30
|
FileUtils.mkdir_p(@path)
|
31
31
|
FileUtils.cd(@path)
|
32
|
-
|
32
|
+
|
33
|
+
Mundler.with_clean_env do
|
33
34
|
system(
|
34
35
|
{
|
35
36
|
# The {mundler gem path}/cached_git directory contains a binary called
|
@@ -38,15 +39,7 @@ module Mundler
|
|
38
39
|
"PATH" => ([cached_git_dir] + ENV["PATH"].split(":")).join(":")
|
39
40
|
},
|
40
41
|
"git clone #{mruby_url} . >/dev/null 2>&1"
|
41
|
-
) ||
|
42
|
-
end
|
43
|
-
|
44
|
-
if defined?(Bundler) && Bundler.respond_to?(:with_unbundled_env)
|
45
|
-
Bundler.with_unbundled_env(&git_clone)
|
46
|
-
elsif defined?(Bundler)
|
47
|
-
Bundler.with_clean_env(&git_clone)
|
48
|
-
else
|
49
|
-
git_clone.call
|
42
|
+
) || raise(Mundler::CloneError, "Failed to clone #{mruby_url}")
|
50
43
|
end
|
51
44
|
|
52
45
|
if version
|
@@ -70,6 +63,22 @@ module Mundler
|
|
70
63
|
def compile(build_config)
|
71
64
|
logfile = Tempfile.new(['mundler_build', '.log'])
|
72
65
|
|
66
|
+
version = (
|
67
|
+
@config.mruby[:tag] ||
|
68
|
+
@config.mruby[:branch] ||
|
69
|
+
@config.mruby[:version]
|
70
|
+
)
|
71
|
+
|
72
|
+
@config.gemboxes.each do |gembox|
|
73
|
+
puts "Using #{gembox} gembox"
|
74
|
+
end
|
75
|
+
@config.gems.each do |gem|
|
76
|
+
puts "Using #{gem[:name]} gem"
|
77
|
+
end
|
78
|
+
|
79
|
+
puts "Using mruby (#{version})"
|
80
|
+
|
81
|
+
|
73
82
|
success_indicator = File.join(@path, ".mundler_built_successfully")
|
74
83
|
if File.file?(success_indicator)
|
75
84
|
return
|
@@ -87,14 +96,14 @@ module Mundler
|
|
87
96
|
directory = pathname.directory? ? pathname.to_s : Pathname.new(file).dirname.to_s
|
88
97
|
next if covered.include?(directory)
|
89
98
|
covered << directory
|
90
|
-
print "\e[
|
99
|
+
print "\e[34m.\e[0m"
|
91
100
|
end
|
92
101
|
end
|
93
102
|
sleep(0.3)
|
94
103
|
end
|
95
104
|
end
|
96
105
|
|
97
|
-
|
106
|
+
Mundler.with_clean_env do
|
98
107
|
rake = `which rake`.chomp
|
99
108
|
system(
|
100
109
|
{
|
@@ -108,15 +117,14 @@ module Mundler
|
|
108
117
|
) || begin
|
109
118
|
$stderr.print "\e[31mF\e[0m"
|
110
119
|
$stderr.puts "\n\n"
|
120
|
+
$stderr.puts File.read(build_config)
|
111
121
|
$stderr.puts File.read(logfile)
|
112
122
|
|
113
123
|
raise Mundler::CompilationError
|
114
124
|
end
|
115
125
|
|
116
126
|
cleaned = true
|
117
|
-
end
|
118
127
|
|
119
|
-
compile = Proc.new do
|
120
128
|
rake = `which rake`.chomp
|
121
129
|
system(
|
122
130
|
{
|
@@ -130,26 +138,18 @@ module Mundler
|
|
130
138
|
) || begin
|
131
139
|
$stderr.print "\e[31mF\e[0m"
|
132
140
|
$stderr.puts "\n\n"
|
141
|
+
$stderr.puts File.read(build_config)
|
133
142
|
$stderr.puts File.read(logfile)
|
134
143
|
|
135
144
|
raise Mundler::CompilationError
|
136
145
|
end
|
137
146
|
end
|
138
147
|
|
139
|
-
|
140
|
-
Bundler.with_unbundled_env(&clean)
|
141
|
-
Bundler.with_unbundled_env(&compile)
|
142
|
-
elsif defined?(Bundler)
|
143
|
-
Bundler.with_clean_env(&clean)
|
144
|
-
Bundler.with_clean_env(&compile)
|
145
|
-
else
|
146
|
-
clean.call
|
147
|
-
compile.call
|
148
|
-
end
|
148
|
+
puts "\n\n"
|
149
149
|
|
150
|
-
output_thread.kill
|
151
150
|
FileUtils.touch(success_indicator)
|
152
151
|
ensure
|
152
|
+
output_thread.kill if output_thread
|
153
153
|
logfile.close
|
154
154
|
logfile.delete
|
155
155
|
end
|
@@ -175,7 +175,7 @@ module Mundler
|
|
175
175
|
end
|
176
176
|
|
177
177
|
def cached_git_dir
|
178
|
-
dir = File.expand_path(File.join(__dir__, "
|
178
|
+
dir = File.expand_path(File.join(__dir__, "cached_git"))
|
179
179
|
raise "cached git not found" unless File.file?(File.join(dir, "git"))
|
180
180
|
raise "cached git not found" unless File.file?(File.join(dir, "cached_git"))
|
181
181
|
dir
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module AndroidPlatform
|
2
|
+
def self.config(options, build_config)
|
3
|
+
valid_archs = [:"arm64-v8a", :armeabi, :"armeabi-v7a"]
|
4
|
+
options[:archs] ||= valid_archs
|
5
|
+
|
6
|
+
options[:archs].map do |arch|
|
7
|
+
unless valid_archs.include?(arch)
|
8
|
+
raise "Invalid architecture #{arch}. Valid values: #{valid_archs}"
|
9
|
+
end
|
10
|
+
|
11
|
+
<<~BUILD
|
12
|
+
MRuby::CrossBuild.new("android__#{arch}") do |conf|
|
13
|
+
params = {
|
14
|
+
:arch => #{arch.inspect},
|
15
|
+
:platform => 'android-24',
|
16
|
+
:toolchain => :clang,
|
17
|
+
}
|
18
|
+
|
19
|
+
if #{arch.inspect} == :"armeabi-v7a"
|
20
|
+
params[:mfpu] = "neon"
|
21
|
+
params[:mfloat_abi] = "hard"
|
22
|
+
end
|
23
|
+
|
24
|
+
toolchain :android, params
|
25
|
+
|
26
|
+
#{cc_and_linker(options[:options])}
|
27
|
+
#{build_config.gemboxes}
|
28
|
+
#{build_config.gems}
|
29
|
+
end
|
30
|
+
BUILD
|
31
|
+
end.join("\n")
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.cc_and_linker(options)
|
35
|
+
build = ""
|
36
|
+
if options[:cc]
|
37
|
+
build += " conf.cc do |cc|\n"
|
38
|
+
build += " cc.command = #{options[:cc][:command].inspect}\n" if options[:cc][:command]
|
39
|
+
build += " cc.flags << #{options[:cc][:flags].inspect}\n" if options[:cc][:flags]
|
40
|
+
build += " end\n\n"
|
41
|
+
end
|
42
|
+
|
43
|
+
if options[:linker]
|
44
|
+
build += " conf.linker do |linker|\n"
|
45
|
+
build += " linker.command = #{options[:linker][:command].inspect}\n" if options[:linker][:command]
|
46
|
+
build += " linker.flags << #{options[:linker][:flags].inspect}\n" if options[:linker][:flags]
|
47
|
+
build += " end\n\n"
|
48
|
+
end
|
49
|
+
|
50
|
+
build
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
define_platform "android", AndroidPlatform
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module HostPlatform
|
2
|
+
def self.config(options, build_config)
|
3
|
+
build = ""
|
4
|
+
|
5
|
+
if options[:cc]
|
6
|
+
build += " conf.cc do |cc|\n"
|
7
|
+
build += " cc.command = #{options[:cc][:command].inspect}\n" if options[:cc][:command]
|
8
|
+
build += " cc.flags << #{options[:cc][:flags].inspect}\n" if options[:cc][:flags]
|
9
|
+
build += " end\n\n"
|
10
|
+
end
|
11
|
+
|
12
|
+
if options[:linker]
|
13
|
+
build += " conf.linker do |linker|\n"
|
14
|
+
build += " linker.command = #{options[:linker][:command].inspect}\n" if options[:linker][:command]
|
15
|
+
build += " linker.flags << #{options[:linker][:flags].inspect}\n" if options[:linker][:flags]
|
16
|
+
build += " end\n\n"
|
17
|
+
end
|
18
|
+
|
19
|
+
build
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
define_platform "host", HostPlatform
|
@@ -1,7 +1,8 @@
|
|
1
1
|
module IOSPlatform
|
2
2
|
def self.config(options, build_config)
|
3
3
|
valid_archs = [:armv7, :arm64]
|
4
|
-
|
4
|
+
default_archs = [:arm64]
|
5
|
+
options[:archs] ||= default_archs
|
5
6
|
|
6
7
|
options[:archs].map do |arch|
|
7
8
|
unless valid_archs.include?(arch)
|
@@ -19,19 +20,25 @@ module IOSPlatform
|
|
19
20
|
-isysroot #{ios_sdk}
|
20
21
|
)
|
21
22
|
|
23
|
+
cc_command = options.dig(:cc, :command) || clang
|
24
|
+
linker_command = options.dig(:linker, :command) || clang
|
25
|
+
|
26
|
+
cc_flags = flags + Array(options.dig(:cc, :flags) || [])
|
27
|
+
linker_flags = flags + Array(options.dig(:linker, :flags) || [])
|
28
|
+
|
22
29
|
<<~BUILD
|
23
30
|
MRuby::CrossBuild.new("ios__#{arch}") do |conf|
|
24
31
|
#{build_config.gemboxes}
|
25
32
|
#{build_config.gems}
|
26
33
|
|
27
34
|
conf.cc do |cc|
|
28
|
-
cc.command = #{
|
29
|
-
cc.flags = #{
|
35
|
+
cc.command = #{cc_command.inspect}
|
36
|
+
cc.flags = #{cc_flags.inspect}
|
30
37
|
end
|
31
38
|
|
32
39
|
conf.linker do |l|
|
33
|
-
l.command = #{
|
34
|
-
l.flags = #{
|
40
|
+
l.command = #{linker_command.inspect}
|
41
|
+
l.flags = #{linker_flags.inspect}
|
35
42
|
end
|
36
43
|
end
|
37
44
|
BUILD
|
data/{Users/dan2552/Dropbox/experiments/mundler/lib → lib}/mundler/platforms/ios_simulator.rb
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
module IOSSimulatorPlatform
|
2
2
|
def self.config(options, build_config)
|
3
|
-
valid_archs = [:i386, :x86_64]
|
3
|
+
valid_archs = [:i386, :x86_64, :arm64]
|
4
4
|
options[:archs] ||= valid_archs
|
5
5
|
|
6
6
|
options[:archs].map do |arch|
|
@@ -19,19 +19,25 @@ module IOSSimulatorPlatform
|
|
19
19
|
-isysroot #{ios_simulator_sdk}
|
20
20
|
)
|
21
21
|
|
22
|
+
cc_command = options.dig(:cc, :command) || clang
|
23
|
+
linker_command = options.dig(:linker, :command) || clang
|
24
|
+
|
25
|
+
cc_flags = flags + Array(options.dig(:cc, :flags) || [])
|
26
|
+
linker_flags = flags + Array(options.dig(:linker, :flags) || [])
|
27
|
+
|
22
28
|
<<~BUILD
|
23
29
|
MRuby::CrossBuild.new("ios_simulator__#{arch}") do |conf|
|
24
30
|
#{build_config.gemboxes}
|
25
31
|
#{build_config.gems}
|
26
32
|
|
27
33
|
conf.cc do |cc|
|
28
|
-
cc.command = #{
|
29
|
-
cc.flags = #{
|
34
|
+
cc.command = #{cc_command.inspect}
|
35
|
+
cc.flags = #{cc_flags.inspect}
|
30
36
|
end
|
31
37
|
|
32
38
|
conf.linker do |l|
|
33
|
-
l.command = #{
|
34
|
-
l.flags = #{
|
39
|
+
l.command = #{linker_command.inspect}
|
40
|
+
l.flags = #{linker_flags.inspect}
|
35
41
|
end
|
36
42
|
end
|
37
43
|
BUILD
|
File without changes
|
@@ -8,9 +8,11 @@ require "mundler/build_config"
|
|
8
8
|
require "mundler/dsl"
|
9
9
|
require "mundler/mruby"
|
10
10
|
require "mundler/project"
|
11
|
+
require "mundler/clean_environment"
|
11
12
|
|
12
13
|
module Mundler
|
13
14
|
class CompilationError < StandardError; end
|
15
|
+
class CloneError < CompilationError; end
|
14
16
|
class NotInstalledError < StandardError; end
|
15
17
|
class MundlefileNotFound < StandardError; end
|
16
18
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mundler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Inkpen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-09-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -60,17 +60,23 @@ executables:
|
|
60
60
|
extensions: []
|
61
61
|
extra_rdoc_files: []
|
62
62
|
files:
|
63
|
-
- "/Users/dan2552/Dropbox/experiments/mundler/lib/mundler.rb"
|
64
|
-
- "/Users/dan2552/Dropbox/experiments/mundler/lib/mundler/build_config.rb"
|
65
|
-
- "/Users/dan2552/Dropbox/experiments/mundler/lib/mundler/cli.rb"
|
66
|
-
- "/Users/dan2552/Dropbox/experiments/mundler/lib/mundler/config.rb"
|
67
|
-
- "/Users/dan2552/Dropbox/experiments/mundler/lib/mundler/dsl.rb"
|
68
|
-
- "/Users/dan2552/Dropbox/experiments/mundler/lib/mundler/mruby.rb"
|
69
|
-
- "/Users/dan2552/Dropbox/experiments/mundler/lib/mundler/platforms/ios.rb"
|
70
|
-
- "/Users/dan2552/Dropbox/experiments/mundler/lib/mundler/platforms/ios_simulator.rb"
|
71
|
-
- "/Users/dan2552/Dropbox/experiments/mundler/lib/mundler/project.rb"
|
72
|
-
- "/Users/dan2552/Dropbox/experiments/mundler/lib/mundler/version.rb"
|
73
63
|
- exe/mundle
|
64
|
+
- lib/mundler.rb
|
65
|
+
- lib/mundler/build_config.rb
|
66
|
+
- lib/mundler/cached_git/cached_git
|
67
|
+
- lib/mundler/cached_git/git
|
68
|
+
- lib/mundler/clean_environment.rb
|
69
|
+
- lib/mundler/cli.rb
|
70
|
+
- lib/mundler/config.rb
|
71
|
+
- lib/mundler/dsl.rb
|
72
|
+
- lib/mundler/libraries/example.rb
|
73
|
+
- lib/mundler/mruby.rb
|
74
|
+
- lib/mundler/platforms/android.rb
|
75
|
+
- lib/mundler/platforms/host.rb
|
76
|
+
- lib/mundler/platforms/ios.rb
|
77
|
+
- lib/mundler/platforms/ios_simulator.rb
|
78
|
+
- lib/mundler/project.rb
|
79
|
+
- lib/mundler/version.rb
|
74
80
|
homepage: https://github.com/Dan2552/mundler
|
75
81
|
licenses:
|
76
82
|
- MIT
|
@@ -1,75 +0,0 @@
|
|
1
|
-
module Mundler
|
2
|
-
class BuildConfig
|
3
|
-
def initialize(config)
|
4
|
-
@config = config
|
5
|
-
end
|
6
|
-
|
7
|
-
def tempfile
|
8
|
-
tempfile = Tempfile.new("build_config.rb")
|
9
|
-
File.write(tempfile, contents)
|
10
|
-
tempfile
|
11
|
-
end
|
12
|
-
|
13
|
-
def gemboxes
|
14
|
-
@config.gemboxes.map do |gembox|
|
15
|
-
"conf.gembox #{gembox.inspect}"
|
16
|
-
end.join("\n")
|
17
|
-
end
|
18
|
-
|
19
|
-
def gems
|
20
|
-
@config.gems.map do |gem|
|
21
|
-
# e.g. gem = {:name=>"mruby-regexp-pcre", :path=>nil, :github=>nil, :core=>nil}
|
22
|
-
args = ":mgem => #{gem[:name].inspect}"
|
23
|
-
|
24
|
-
if gem[:github]
|
25
|
-
args = ":github => #{gem[:github].inspect}"
|
26
|
-
elsif gem[:path]
|
27
|
-
args = ":path => #{gem[:path].inspect}"
|
28
|
-
elsif gem[:core]
|
29
|
-
args = ":core => #{gem[:core].inspect}"
|
30
|
-
end
|
31
|
-
|
32
|
-
"conf.gem #{args}"
|
33
|
-
end.join("\n ")
|
34
|
-
end
|
35
|
-
|
36
|
-
def mruby_version
|
37
|
-
mruby_url = @config.mruby[:url]
|
38
|
-
|
39
|
-
version = (
|
40
|
-
@config.mruby[:tag] ||
|
41
|
-
@config.mruby[:branch] ||
|
42
|
-
@config.mruby[:version]
|
43
|
-
)
|
44
|
-
|
45
|
-
"#{mruby_url} #{version}"
|
46
|
-
end
|
47
|
-
|
48
|
-
private
|
49
|
-
|
50
|
-
def platforms
|
51
|
-
@config.platforms.map do |platform|
|
52
|
-
type = @config.platform_types[platform[:name].to_s]
|
53
|
-
raise "Can't find platform: #{platform[:name]}" unless type
|
54
|
-
type.config(platform, self)
|
55
|
-
end.join("\n")
|
56
|
-
end
|
57
|
-
|
58
|
-
def contents
|
59
|
-
contents = <<~CONTENTS
|
60
|
-
# #{mruby_version}
|
61
|
-
|
62
|
-
MRuby::Build.new do |conf|
|
63
|
-
toolchain :clang
|
64
|
-
|
65
|
-
#{gemboxes}
|
66
|
-
#{gems}
|
67
|
-
end
|
68
|
-
|
69
|
-
#{platforms}
|
70
|
-
CONTENTS
|
71
|
-
|
72
|
-
contents.strip + "\n"
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|