mundler 0.6.1 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 116dbf6f2648c2b5d533e5a03fe121fc9978a8543c19245ecb4cc4867a8ae6b0
4
- data.tar.gz: d413e06db8bc72d52036fc02795f90e7924e381fe0adf64d76819e05fd5ba8a7
3
+ metadata.gz: 48991edd8f68a6db41fc93f84ba8631ffce3e296aecfaeac6bfd8ed1cd8d7a4c
4
+ data.tar.gz: 6b09d50fe5fb6a5b79f6fdf92a87a1968a1e028474a606f98312acd18e00a23a
5
5
  SHA512:
6
- metadata.gz: 1b325ac5b0576556356d973fbe5a34c5f9ea9e1a16bc9e5011fee9f83c6df7d0db2009ae190eaf190de407e12b65bbddb56de2be524b6d97820e1d537af10a23
7
- data.tar.gz: 1d968eec2ce1176215d45e4690dc5b87dcf0e17ce9c7d78c64a94aff4111bd7f0e729bb146806c842572681c56b20fa6248430ea7788367981952c0934ca145c
6
+ metadata.gz: ab39110a71818d4f1f544e7dd6effe6ff2cb88557db5d2d18cd430f70bff5bd6a4947d3533f8b66f4aea3bca12210910ce42f452e089c72138d0e2ed0becf65e
7
+ data.tar.gz: d33d00f82e5be842c712e9b90fba5d101453ce52dcbc3e171d41922c22d4ae0bc7cb14a6fdcc6a4f8f35e9f6cc0b4791368a91589235553b599d62690a292068
@@ -47,29 +47,51 @@ module Mundler
47
47
 
48
48
  private
49
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")
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(attributes)
65
+ type = @config.platform_types[attributes[:name].to_s]
66
+ raise "Can't find platform: #{attributes[:name]}" unless type
67
+ type.config(attributes, self)
68
+ end
69
+
70
+ def env_vars
71
+ str = ""
72
+ @config.env.each do |key, value|
73
+ str = str + "\nENV[\"#{key}\"] = \"#{value}\""
74
+ end
75
+ str
56
76
  end
57
77
 
58
78
  def contents
59
79
  contents = <<~CONTENTS
60
80
  # #{mruby_version}
81
+ #{env_vars}
61
82
 
62
83
  MRuby::Build.new do |conf|
63
84
  toolchain :clang
64
85
 
86
+ #{host_platform}
65
87
  #{gemboxes}
66
88
  #{gems}
67
89
  end
68
90
 
69
- #{platforms}
91
+ #{non_host_platforms}
70
92
  CONTENTS
71
93
 
72
- contents.strip + "\n"
94
+ (contents.strip + "\n").gsub("\n\n\n", "\n\n")
73
95
  end
74
96
  end
75
97
  end
@@ -10,10 +10,12 @@ module Mundler
10
10
  @gemboxes = []
11
11
  @gems = []
12
12
  @platform_types = {}
13
+ @env = {}
13
14
  end
14
15
 
15
16
  attr_reader :mruby
16
17
  attr_reader :platform_types
18
+ attr_reader :env
17
19
 
18
20
  def hex
19
21
  Digest::MD5.hexdigest(to_s)
@@ -36,9 +38,23 @@ module Mundler
36
38
  #{mruby.inspect}
37
39
  #{platforms.inspect}
38
40
  #{platform_types.keys.sort.inspect}
41
+ #{hashable_string_for_hash(env)}
39
42
  #{gemboxes.inspect}
40
43
  #{gems.inspect}
41
44
  HASHABLE
42
45
  end
46
+
47
+ private
48
+
49
+ def hashable_string_for_hash(hash)
50
+ str = "{"
51
+ sorted_keys = hash.keys.sort
52
+
53
+ sorted_keys.each do |key|
54
+ str = str + "#{key}=>#{hash[key]}"
55
+ end
56
+
57
+ str + "}"
58
+ end
43
59
  end
44
60
  end
data/lib/mundler/dsl.rb CHANGED
@@ -41,7 +41,16 @@ module Mundler
41
41
  end
42
42
 
43
43
  def gem(name, core: nil, path: nil, github: nil)
44
+ if path && !path.start_with?("/")
45
+ app_path = Pathname.new(@path).dirname.to_s
46
+ path = File.expand_path(File.join(app_path, path))
47
+ end
48
+
44
49
  config.gems << { name: name, path: path, github: github, core: core }
45
50
  end
51
+
52
+ def env(name, value)
53
+ config.env[name] = value
54
+ end
46
55
  end
47
56
  end
data/lib/mundler/mruby.rb CHANGED
@@ -108,6 +108,7 @@ module Mundler
108
108
  ) || begin
109
109
  $stderr.print "\e[31mF\e[0m"
110
110
  $stderr.puts "\n\n"
111
+ $stderr.puts File.read(build_config)
111
112
  $stderr.puts File.read(logfile)
112
113
 
113
114
  raise Mundler::CompilationError
@@ -130,6 +131,7 @@ module Mundler
130
131
  ) || begin
131
132
  $stderr.print "\e[31mF\e[0m"
132
133
  $stderr.puts "\n\n"
134
+ $stderr.puts File.read(build_config)
133
135
  $stderr.puts File.read(logfile)
134
136
 
135
137
  raise Mundler::CompilationError
@@ -23,12 +23,32 @@ module AndroidPlatform
23
23
 
24
24
  toolchain :android, params
25
25
 
26
+ #{cc_and_linker(options[:options])}
26
27
  #{build_config.gemboxes}
27
28
  #{build_config.gems}
28
29
  end
29
30
  BUILD
30
31
  end.join("\n")
31
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
32
52
  end
33
53
 
34
54
  define_platform "android", AndroidPlatform
@@ -0,0 +1,24 @@
1
+ module HostPlatform
2
+ def self.config(host_options, build_config)
3
+ build = ""
4
+ options = host_options[:options]
5
+
6
+ if options[:cc]
7
+ build += " conf.cc do |cc|\n"
8
+ build += " cc.command = #{options[:cc][:command].inspect}\n" if options[:cc][:command]
9
+ build += " cc.flags << #{options[:cc][:flags].inspect}\n" if options[:cc][:flags]
10
+ build += " end\n\n"
11
+ end
12
+
13
+ if options[:linker]
14
+ build += " conf.linker do |linker|\n"
15
+ build += " linker.command = #{options[:linker][:command].inspect}\n" if options[:linker][:command]
16
+ build += " linker.flags << #{options[:linker][:flags].inspect}\n" if options[:linker][:flags]
17
+ build += " end\n\n"
18
+ end
19
+
20
+ build
21
+ end
22
+ end
23
+
24
+ define_platform "host", HostPlatform
@@ -19,19 +19,25 @@ module IOSPlatform
19
19
  -isysroot #{ios_sdk}
20
20
  )
21
21
 
22
+ cc_command = options.dig(:options, :cc, :command) || clang
23
+ linker_command = options.dig(:options, :linker, :command) || clang
24
+
25
+ cc_flags = flags + Array(options.dig(:options, :cc, :flags) || [])
26
+ linker_flags = flags + Array(options.dig(:options, :linker, :flags) || [])
27
+
22
28
  <<~BUILD
23
29
  MRuby::CrossBuild.new("ios__#{arch}") do |conf|
24
30
  #{build_config.gemboxes}
25
31
  #{build_config.gems}
26
32
 
27
33
  conf.cc do |cc|
28
- cc.command = #{clang.inspect}
29
- cc.flags = #{flags.inspect}
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 = #{clang.inspect}
34
- l.flags = #{flags.inspect}
39
+ l.command = #{linker_command.inspect}
40
+ l.flags = #{linker_flags.inspect}
35
41
  end
36
42
  end
37
43
  BUILD
@@ -1,3 +1,3 @@
1
1
  module Mundler
2
- VERSION = "0.6.1"
2
+ VERSION = "0.7.0"
3
3
  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.6.1
4
+ version: 0.7.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-07-25 00:00:00.000000000 Z
11
+ date: 2021-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -70,6 +70,7 @@ files:
70
70
  - lib/mundler/dsl.rb
71
71
  - lib/mundler/mruby.rb
72
72
  - lib/mundler/platforms/android.rb
73
+ - lib/mundler/platforms/host.rb
73
74
  - lib/mundler/platforms/ios.rb
74
75
  - lib/mundler/platforms/ios_simulator.rb
75
76
  - lib/mundler/project.rb