mundler 0.5.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 +7 -0
- data/Users/dan2552/Dropbox/experiments/mundler/lib/mundler.rb +16 -0
- data/Users/dan2552/Dropbox/experiments/mundler/lib/mundler/build_config.rb +75 -0
- data/Users/dan2552/Dropbox/experiments/mundler/lib/mundler/cli.rb +90 -0
- data/Users/dan2552/Dropbox/experiments/mundler/lib/mundler/config.rb +44 -0
- data/Users/dan2552/Dropbox/experiments/mundler/lib/mundler/dsl.rb +47 -0
- data/Users/dan2552/Dropbox/experiments/mundler/lib/mundler/mruby.rb +184 -0
- data/Users/dan2552/Dropbox/experiments/mundler/lib/mundler/platforms/ios.rb +42 -0
- data/Users/dan2552/Dropbox/experiments/mundler/lib/mundler/platforms/ios_simulator.rb +42 -0
- data/Users/dan2552/Dropbox/experiments/mundler/lib/mundler/project.rb +51 -0
- data/Users/dan2552/Dropbox/experiments/mundler/lib/mundler/version.rb +3 -0
- data/exe/mundle +7 -0
- metadata +97 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8bff85e95c9055e66797b7e104e4781625b8184b0d9a8e1992e0e05a2db566ec
|
4
|
+
data.tar.gz: b1afb00af0ef0a556f7be323cbe7dab1e8e14ce84026e75079c5498173a291ce
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cb8b8c78f8d369b30d670b60da360c7ee33a6c990a82bf424aa309ac49ecde96c1a525baf4b0e182ff670288093b7321c073540f41082d3b15ef2f53d2b4fff1
|
7
|
+
data.tar.gz: 07da326cea2279e896f5f05b33c74f71e1fcd7b0245d5f2f1794d6ccd916aef652a798c9f1a8613ab4b5010628fd0ce4b03e130a9da4c84eb46bf41186448f3d
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require "digest"
|
2
|
+
require "fileutils"
|
3
|
+
require "tempfile"
|
4
|
+
|
5
|
+
require "mundler/version"
|
6
|
+
require "mundler/config"
|
7
|
+
require "mundler/build_config"
|
8
|
+
require "mundler/dsl"
|
9
|
+
require "mundler/mruby"
|
10
|
+
require "mundler/project"
|
11
|
+
|
12
|
+
module Mundler
|
13
|
+
class CompilationError < StandardError; end
|
14
|
+
class NotInstalledError < StandardError; end
|
15
|
+
class MundlefileNotFound < StandardError; end
|
16
|
+
end
|
@@ -0,0 +1,75 @@
|
|
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
|
@@ -0,0 +1,90 @@
|
|
1
|
+
require "thor"
|
2
|
+
|
3
|
+
module Mundler
|
4
|
+
class CLI < Thor
|
5
|
+
include Thor::Actions
|
6
|
+
|
7
|
+
def self.exit_on_failure?
|
8
|
+
true
|
9
|
+
end
|
10
|
+
|
11
|
+
desc "install", "Download and compile mruby"
|
12
|
+
def install
|
13
|
+
Mundler::Project.new(Dir.pwd).install
|
14
|
+
rescue Mundler::CompilationError
|
15
|
+
$stderr.puts("\e[31mFailed to install\e[0m")
|
16
|
+
exit 1
|
17
|
+
rescue Interrupt
|
18
|
+
$stderr.puts("\e[31mUser cancelled\e[0m")
|
19
|
+
exit 1
|
20
|
+
rescue MundlefileNotFound
|
21
|
+
$stderr.puts("\e[31mMundlefile not found in the current directory\e[0m")
|
22
|
+
exit 1
|
23
|
+
end
|
24
|
+
|
25
|
+
desc "update", "Same as install except it forces recompile"
|
26
|
+
def update
|
27
|
+
project = Mundler::Project.new(Dir.pwd)
|
28
|
+
project.clean
|
29
|
+
project.install
|
30
|
+
rescue Mundler::CompilationError
|
31
|
+
$stderr.puts("\e[31mFailed to install\e[0m")
|
32
|
+
exit 1
|
33
|
+
rescue Interrupt
|
34
|
+
$stderr.puts("\e[31mUser cancelled\e[0m")
|
35
|
+
exit 1
|
36
|
+
rescue MundlefileNotFound
|
37
|
+
$stderr.puts("\e[31mMundlefile not found in the current directory\e[0m")
|
38
|
+
exit 1
|
39
|
+
end
|
40
|
+
|
41
|
+
desc "summary", "Print a summary of installed libraries and binaries"
|
42
|
+
def summary
|
43
|
+
project = Mundler::Project.new(Dir.pwd)
|
44
|
+
project.print_summary
|
45
|
+
rescue Interrupt
|
46
|
+
$stderr.puts("\e[31mUser cancelled\e[0m")
|
47
|
+
exit 1
|
48
|
+
rescue MundlefileNotFound
|
49
|
+
$stderr.puts("\e[31mMundlefile not found in the current directory\e[0m")
|
50
|
+
exit 1
|
51
|
+
end
|
52
|
+
|
53
|
+
desc "clean", "Removes cached versions of mruby."
|
54
|
+
def clean
|
55
|
+
Mundler::Project.new(Dir.pwd).clean
|
56
|
+
rescue Interrupt
|
57
|
+
$stderr.puts("\e[31mUser cancelled\e[0m")
|
58
|
+
exit 1
|
59
|
+
rescue MundlefileNotFound
|
60
|
+
$stderr.puts("\e[31mMundlefile not found in the current directory\e[0m")
|
61
|
+
exit 1
|
62
|
+
end
|
63
|
+
|
64
|
+
desc "exec", "Execute command with mruby's bin prepended to $PATH"
|
65
|
+
def exec(*args)
|
66
|
+
Mundler::Project.new(Dir.pwd).exec(args)
|
67
|
+
rescue Interrupt
|
68
|
+
exit 1
|
69
|
+
rescue NotInstalledError
|
70
|
+
$stderr.puts("\e[31mChanges to the Mundlefile have been detected. Run `mundle install` and try again.\e[0m")
|
71
|
+
exit 1
|
72
|
+
rescue MundlefileNotFound
|
73
|
+
$stderr.puts("\e[31mMundlefile not found in the current directory\e[0m")
|
74
|
+
exit 1
|
75
|
+
end
|
76
|
+
|
77
|
+
desc "path", "Prints out the path relevant to the compiled version of mruby relevant to the `Mundlefile`"
|
78
|
+
def path
|
79
|
+
puts Mundler::Project.new(Dir.pwd).path
|
80
|
+
rescue Interrupt
|
81
|
+
$stderr.puts("\e[31mUser cancelled\e[0m")
|
82
|
+
exit 1
|
83
|
+
rescue MundlefileNotFound
|
84
|
+
$stderr.puts("\e[31mMundlefile not found in the current directory\e[0m")
|
85
|
+
exit 1
|
86
|
+
end
|
87
|
+
|
88
|
+
default_task :install
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Mundler
|
2
|
+
class Config
|
3
|
+
def initialize
|
4
|
+
@mruby = {
|
5
|
+
url: "https://github.com/mruby/mruby",
|
6
|
+
branch: "stable"
|
7
|
+
}
|
8
|
+
|
9
|
+
@platforms = []
|
10
|
+
@gemboxes = []
|
11
|
+
@gems = []
|
12
|
+
@platform_types = {}
|
13
|
+
end
|
14
|
+
|
15
|
+
attr_reader :mruby
|
16
|
+
attr_reader :platform_types
|
17
|
+
|
18
|
+
def hex
|
19
|
+
Digest::MD5.hexdigest(to_s)
|
20
|
+
end
|
21
|
+
|
22
|
+
def gemboxes
|
23
|
+
@gemboxes.sort!
|
24
|
+
end
|
25
|
+
|
26
|
+
def gems
|
27
|
+
@gems.sort_by! { |platform| platform[:name] }
|
28
|
+
end
|
29
|
+
|
30
|
+
def platforms
|
31
|
+
@platforms.sort_by! { |platform| platform[:name] }
|
32
|
+
end
|
33
|
+
|
34
|
+
def to_s
|
35
|
+
<<~HASHABLE
|
36
|
+
#{mruby.inspect}
|
37
|
+
#{platforms.inspect}
|
38
|
+
#{platform_types.keys.sort.inspect}
|
39
|
+
#{gemboxes.inspect}
|
40
|
+
#{gems.inspect}
|
41
|
+
HASHABLE
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Mundler
|
2
|
+
class DSL
|
3
|
+
def initialize(path)
|
4
|
+
@config = Config.new
|
5
|
+
@path = path
|
6
|
+
end
|
7
|
+
|
8
|
+
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
|
+
begin
|
14
|
+
instance_eval(File.read(@path), @path)
|
15
|
+
rescue Errno::ENOENT
|
16
|
+
raise MundlefileNotFound
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
attr_reader :config
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def mruby(url: nil, tag: nil, branch: nil)
|
25
|
+
branch = "stable" if tag.nil? && branch.nil?
|
26
|
+
config.mruby[:url] = url if url
|
27
|
+
config.mruby[:branch] = branch if branch
|
28
|
+
config.mruby[:tag] = tag if tag
|
29
|
+
end
|
30
|
+
|
31
|
+
def gembox(name)
|
32
|
+
config.gemboxes << name.to_s
|
33
|
+
end
|
34
|
+
|
35
|
+
def define_platform(name, platform_class)
|
36
|
+
config.platform_types[name.to_s] = platform_class
|
37
|
+
end
|
38
|
+
|
39
|
+
def platform(name, options)
|
40
|
+
config.platforms << { name: name.to_s, options: options }
|
41
|
+
end
|
42
|
+
|
43
|
+
def gem(name, core: nil, path: nil, github: nil)
|
44
|
+
config.gems << { name: name, path: path, github: github, core: core }
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,184 @@
|
|
1
|
+
module Mundler
|
2
|
+
class MRuby
|
3
|
+
def initialize(config)
|
4
|
+
@config = config
|
5
|
+
@path = File.join(ENV["HOME"], ".mundler", config.hex)
|
6
|
+
|
7
|
+
# Protect just incase, as we're doing an rm_rf
|
8
|
+
raise "Something went wrong" if config.hex.length == 0
|
9
|
+
end
|
10
|
+
|
11
|
+
attr_reader :path
|
12
|
+
|
13
|
+
def delete_repository
|
14
|
+
FileUtils.rm_rf(@path)
|
15
|
+
end
|
16
|
+
|
17
|
+
def clone_repository
|
18
|
+
success_indicator = File.join(@path, ".mundler_cloned_successfully")
|
19
|
+
return if File.file?(success_indicator)
|
20
|
+
|
21
|
+
mruby_url = @config.mruby[:url]
|
22
|
+
|
23
|
+
version = (
|
24
|
+
@config.mruby[:tag] ||
|
25
|
+
@config.mruby[:branch] ||
|
26
|
+
@config.mruby[:version]
|
27
|
+
)
|
28
|
+
|
29
|
+
FileUtils.rm_rf(@path)
|
30
|
+
FileUtils.mkdir_p(@path)
|
31
|
+
FileUtils.cd(@path)
|
32
|
+
git_clone = Proc.new do
|
33
|
+
system(
|
34
|
+
{
|
35
|
+
# The {mundler gem path}/cached_git directory contains a binary called
|
36
|
+
# `git` that will run instead of normal git, making a cache of a
|
37
|
+
# clone.
|
38
|
+
"PATH" => ([cached_git_dir] + ENV["PATH"].split(":")).join(":")
|
39
|
+
},
|
40
|
+
"git clone #{mruby_url} . >/dev/null 2>&1"
|
41
|
+
) || error_out("Failed to clone mruby: #{mruby_url}")
|
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
|
50
|
+
end
|
51
|
+
|
52
|
+
if version
|
53
|
+
system("git reset --hard #{version} >/dev/null 2>&1") ||
|
54
|
+
error_out("Failed to set version to #{version}")
|
55
|
+
end
|
56
|
+
|
57
|
+
FileUtils.touch(success_indicator)
|
58
|
+
end
|
59
|
+
|
60
|
+
def exec(args)
|
61
|
+
raise NotInstalledError unless installed?
|
62
|
+
|
63
|
+
bin_dir = File.join(@path, "bin")
|
64
|
+
path = bin_dir + ":" + ENV['PATH']
|
65
|
+
Process.spawn({ "PATH" => path }, *args)
|
66
|
+
Process.wait
|
67
|
+
exit($?.exitstatus) if $?.exitstatus
|
68
|
+
end
|
69
|
+
|
70
|
+
def compile(build_config)
|
71
|
+
logfile = Tempfile.new(['mundler_build', '.log'])
|
72
|
+
|
73
|
+
success_indicator = File.join(@path, ".mundler_built_successfully")
|
74
|
+
if File.file?(success_indicator)
|
75
|
+
return
|
76
|
+
end
|
77
|
+
|
78
|
+
FileUtils.cd(@path)
|
79
|
+
|
80
|
+
cleaned = false
|
81
|
+
covered = []
|
82
|
+
output_thread = Thread.new do
|
83
|
+
loop do
|
84
|
+
if cleaned
|
85
|
+
Dir.glob(File.join(Dir.pwd, "build", "*", "*", "*")).each do |file|
|
86
|
+
pathname = Pathname.new(file)
|
87
|
+
directory = pathname.directory? ? pathname.to_s : Pathname.new(file).dirname.to_s
|
88
|
+
next if covered.include?(directory)
|
89
|
+
covered << directory
|
90
|
+
print "\e[32m.\e[0m"
|
91
|
+
end
|
92
|
+
end
|
93
|
+
sleep(0.3)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
clean = Proc.new do
|
98
|
+
rake = `which rake`.chomp
|
99
|
+
system(
|
100
|
+
{
|
101
|
+
"MRUBY_CONFIG" => build_config,
|
102
|
+
# The {mundler gem path}/cached_git directory contains a binary called
|
103
|
+
# `git` that will run instead of normal git, making a cache of a
|
104
|
+
# clone.
|
105
|
+
"PATH" => ([cached_git_dir] + ENV["PATH"].split(":")).join(":")
|
106
|
+
},
|
107
|
+
"#{rake} clean >#{logfile.path} 2>&1 && #{rake} deep_clean >#{logfile.path} 2>&1"
|
108
|
+
) || begin
|
109
|
+
$stderr.print "\e[31mF\e[0m"
|
110
|
+
$stderr.puts "\n\n"
|
111
|
+
$stderr.puts File.read(logfile)
|
112
|
+
|
113
|
+
raise Mundler::CompilationError
|
114
|
+
end
|
115
|
+
|
116
|
+
cleaned = true
|
117
|
+
end
|
118
|
+
|
119
|
+
compile = Proc.new do
|
120
|
+
rake = `which rake`.chomp
|
121
|
+
system(
|
122
|
+
{
|
123
|
+
"MRUBY_CONFIG" => build_config,
|
124
|
+
# The {mundler gem path}/cached_git directory contains a binary called
|
125
|
+
# `git` that will run instead of normal git, making a cache of a
|
126
|
+
# clone.
|
127
|
+
"PATH" => ([cached_git_dir] + ENV["PATH"].split(":")).join(":")
|
128
|
+
},
|
129
|
+
"#{rake} >#{logfile.path} 2>&1"
|
130
|
+
) || begin
|
131
|
+
$stderr.print "\e[31mF\e[0m"
|
132
|
+
$stderr.puts "\n\n"
|
133
|
+
$stderr.puts File.read(logfile)
|
134
|
+
|
135
|
+
raise Mundler::CompilationError
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
if defined?(Bundler) && Bundler.respond_to?(:with_unbundled_env)
|
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
|
149
|
+
|
150
|
+
output_thread.kill
|
151
|
+
FileUtils.touch(success_indicator)
|
152
|
+
ensure
|
153
|
+
logfile.close
|
154
|
+
logfile.delete
|
155
|
+
end
|
156
|
+
|
157
|
+
def print_summary
|
158
|
+
FileUtils.cd(@path)
|
159
|
+
puts "Libraries:"
|
160
|
+
Dir.glob(File.join(Dir.pwd, "**", "*.a")).each { |a| puts "* " + a.split("build/").last }
|
161
|
+
|
162
|
+
binaries = Dir.glob(File.join(Dir.pwd, "build", "host", "bin", "*"))
|
163
|
+
if binaries.count > 0
|
164
|
+
puts ""
|
165
|
+
puts "Binaries:"
|
166
|
+
binaries.each { |a| puts "* " + a.split("/").last }
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
private
|
171
|
+
|
172
|
+
def installed?
|
173
|
+
success_indicator = File.join(@path, ".mundler_built_successfully")
|
174
|
+
File.file?(success_indicator)
|
175
|
+
end
|
176
|
+
|
177
|
+
def cached_git_dir
|
178
|
+
dir = File.expand_path(File.join(__dir__, "..", "..", "cached_git"))
|
179
|
+
raise "cached git not found" unless File.file?(File.join(dir, "git"))
|
180
|
+
raise "cached git not found" unless File.file?(File.join(dir, "cached_git"))
|
181
|
+
dir
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module IOSPlatform
|
2
|
+
def self.config(options, build_config)
|
3
|
+
valid_archs = [:armv7, :arm64]
|
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
|
+
minimum_ios_version = options[:minimum_ios_sdk_version] || "10.0"
|
12
|
+
ios_sdk = `xcrun --sdk iphoneos --show-sdk-path`.chomp
|
13
|
+
|
14
|
+
clang = `xcrun -find clang`.chomp
|
15
|
+
flags = %W(
|
16
|
+
-O3
|
17
|
+
-miphoneos-version-min=#{minimum_ios_version}
|
18
|
+
-arch #{arch}
|
19
|
+
-isysroot #{ios_sdk}
|
20
|
+
)
|
21
|
+
|
22
|
+
<<~BUILD
|
23
|
+
MRuby::CrossBuild.new("ios__#{arch}") do |conf|
|
24
|
+
#{build_config.gemboxes}
|
25
|
+
#{build_config.gems}
|
26
|
+
|
27
|
+
conf.cc do |cc|
|
28
|
+
cc.command = #{clang.inspect}
|
29
|
+
cc.flags = #{flags.inspect}
|
30
|
+
end
|
31
|
+
|
32
|
+
conf.linker do |l|
|
33
|
+
l.command = #{clang.inspect}
|
34
|
+
l.flags = #{flags.inspect}
|
35
|
+
end
|
36
|
+
end
|
37
|
+
BUILD
|
38
|
+
end.join("\n")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
define_platform "ios", IOSPlatform
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module IOSSimulatorPlatform
|
2
|
+
def self.config(options, build_config)
|
3
|
+
valid_archs = [:i386, :x86_64]
|
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
|
+
minimum_ios_version = options[:minimum_ios_sdk_version] || "10.0"
|
12
|
+
ios_simulator_sdk = `xcrun --sdk iphonesimulator --show-sdk-path`.chomp
|
13
|
+
|
14
|
+
clang = `xcrun -find clang`.chomp
|
15
|
+
flags = %W(
|
16
|
+
-O3
|
17
|
+
-mios-simulator-version-min=#{minimum_ios_version}
|
18
|
+
-arch #{arch}
|
19
|
+
-isysroot #{ios_simulator_sdk}
|
20
|
+
)
|
21
|
+
|
22
|
+
<<~BUILD
|
23
|
+
MRuby::CrossBuild.new("ios_simulator__#{arch}") do |conf|
|
24
|
+
#{build_config.gemboxes}
|
25
|
+
#{build_config.gems}
|
26
|
+
|
27
|
+
conf.cc do |cc|
|
28
|
+
cc.command = #{clang.inspect}
|
29
|
+
cc.flags = #{flags.inspect}
|
30
|
+
end
|
31
|
+
|
32
|
+
conf.linker do |l|
|
33
|
+
l.command = #{clang.inspect}
|
34
|
+
l.flags = #{flags.inspect}
|
35
|
+
end
|
36
|
+
end
|
37
|
+
BUILD
|
38
|
+
end.join("\n")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
define_platform "ios_simulator", IOSSimulatorPlatform
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Mundler
|
2
|
+
class Project
|
3
|
+
def initialize(project_path)
|
4
|
+
@project_path = project_path
|
5
|
+
@mruby = MRuby.new(config)
|
6
|
+
end
|
7
|
+
|
8
|
+
def install(&blk)
|
9
|
+
@mruby.clone_repository
|
10
|
+
build_config = BuildConfig.new(config).tempfile
|
11
|
+
@mruby.compile(build_config.path)
|
12
|
+
FileUtils.cp(build_config.path, File.join(@project_path, "Mundlefile.lock"))
|
13
|
+
ensure
|
14
|
+
if build_config
|
15
|
+
build_config.close
|
16
|
+
build_config.delete
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def print_summary
|
21
|
+
@mruby.print_summary
|
22
|
+
end
|
23
|
+
|
24
|
+
def clean
|
25
|
+
@mruby.delete_repository
|
26
|
+
end
|
27
|
+
|
28
|
+
def exec(args)
|
29
|
+
@mruby.exec(args)
|
30
|
+
end
|
31
|
+
|
32
|
+
def path
|
33
|
+
@mruby.path
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def config
|
39
|
+
@config ||= begin
|
40
|
+
mundlefile_path = (
|
41
|
+
ENV["MUNDLEFILE_PATH"] ||
|
42
|
+
File.join(@project_path, "Mundlefile")
|
43
|
+
)
|
44
|
+
|
45
|
+
dsl = DSL.new(mundlefile_path)
|
46
|
+
dsl.evaluate!
|
47
|
+
dsl.config
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/exe/mundle
ADDED
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mundler
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Daniel Inkpen
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-07-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: thor
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: A simple tool help download and compile mruby when gems change
|
56
|
+
email:
|
57
|
+
- dan2552@gmail.com
|
58
|
+
executables:
|
59
|
+
- mundle
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
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
|
+
- exe/mundle
|
74
|
+
homepage: https://github.com/Dan2552/mundler
|
75
|
+
licenses:
|
76
|
+
- MIT
|
77
|
+
metadata: {}
|
78
|
+
post_install_message:
|
79
|
+
rdoc_options: []
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
requirements: []
|
93
|
+
rubygems_version: 3.0.3
|
94
|
+
signing_key:
|
95
|
+
specification_version: 4
|
96
|
+
summary: A simple tool help download and compile mruby when gems change
|
97
|
+
test_files: []
|