xcake 0.8.12 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +5 -5
  2. data/lib/xcake.rb +3 -4
  3. data/lib/xcake/command/make.rb +1 -3
  4. data/lib/xcake/constants.rb +10 -10
  5. data/lib/xcake/context.rb +0 -2
  6. data/lib/xcake/context/xcodeproj_context.rb +10 -7
  7. data/lib/xcake/core_ext/class.rb +14 -0
  8. data/lib/xcake/dependency_provider.rb +3 -3
  9. data/lib/xcake/dsl/build_phase/copy_files_build_phase.rb +1 -3
  10. data/lib/xcake/dsl/build_phase/shell_script_build_phase.rb +10 -0
  11. data/lib/xcake/dsl/build_rule.rb +76 -0
  12. data/lib/xcake/dsl/configurable.rb +10 -8
  13. data/lib/xcake/dsl/configuration/sugar.rb +1 -1
  14. data/lib/xcake/dsl/project.rb +1 -1
  15. data/lib/xcake/dsl/project/hooks.rb +4 -0
  16. data/lib/xcake/dsl/project/sugar.rb +13 -15
  17. data/lib/xcake/dsl/scheme.rb +2 -3
  18. data/lib/xcake/dsl/target.rb +19 -5
  19. data/lib/xcake/dsl/target/sugar.rb +22 -0
  20. data/lib/xcake/event_hooks.rb +10 -0
  21. data/lib/xcake/generator.rb +1 -0
  22. data/lib/xcake/generator/default_project_structure_generator.rb +5 -6
  23. data/lib/xcake/generator/project_generator.rb +3 -2
  24. data/lib/xcake/generator/scheme_generator.rb +34 -24
  25. data/lib/xcake/generator/target_build_rule_generator.rb +24 -0
  26. data/lib/xcake/generator/target_file_reference_generator.rb +11 -10
  27. data/lib/xcake/generator/target_framework_generator.rb +6 -6
  28. data/lib/xcake/generator/target_library_generator.rb +5 -6
  29. data/lib/xcake/path_classifier.rb +24 -20
  30. data/lib/xcake/ui.rb +9 -1
  31. data/lib/xcake/version.rb +1 -1
  32. data/lib/xcake/xcode/project.rb +16 -2
  33. data/lib/xcake/xcode/scheme_list.rb +0 -2
  34. data/lib/xcake/xcodeproj_ext/PBXGroup.rb +12 -10
  35. data/lib/xcake/xcodeproj_ext/PBXNativeTarget.rb +2 -2
  36. metadata +137 -91
  37. data/.gitattributes +0 -1
  38. data/.gitignore +0 -39
  39. data/.rspec +0 -2
  40. data/.travis.yml +0 -16
  41. data/.yardopts +0 -7
  42. data/CHANGELOG.md +0 -325
  43. data/CODE_OF_CONDUCT.md +0 -13
  44. data/Gemfile +0 -4
  45. data/LICENSE.txt +0 -21
  46. data/README.md +0 -110
  47. data/Rakefile +0 -6
  48. data/bin/console +0 -10
  49. data/bin/setup +0 -7
  50. data/fastlane-plugin-xcake/Gemfile +0 -3
  51. data/fastlane-plugin-xcake/LICENSE +0 -21
  52. data/fastlane-plugin-xcake/README.md +0 -31
  53. data/fastlane-plugin-xcake/Rakefile +0 -6
  54. data/fastlane-plugin-xcake/fastlane-plugin-xcake.gemspec +0 -25
  55. data/fastlane-plugin-xcake/lib/fastlane/plugin/xcake.rb +0 -16
  56. data/fastlane-plugin-xcake/lib/fastlane/plugin/xcake/actions/xcake_action.rb +0 -34
  57. data/fastlane-plugin-xcake/lib/fastlane/plugin/xcake/version.rb +0 -5
  58. data/fastlane-plugin-xcake/spec/spec_helper.rb +0 -8
  59. data/hound.yml +0 -2
  60. data/lib/xcake/core_ext/array.rb +0 -5
  61. data/lib/xcake/core_ext/object.rb +0 -7
  62. data/rubocop.yml +0 -173
  63. data/rubocop_general.yml +0 -113
  64. data/xcake.gemspec +0 -40
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 1dde5e41df8ae9a58444f1ed09ecd44797f5643d
4
- data.tar.gz: 03bb619369f0fbfb00ecd3e2bc9655e487936dc4
2
+ SHA256:
3
+ metadata.gz: 5a7a1127fc030c5c2bb13ee51fdcdf6bd4c6ea99c3b64c6ad00c9853b9f9418a
4
+ data.tar.gz: 037f2aa99231914e51e86e0157768f2bfd839f2ad9583968b2a0feeb095676a1
5
5
  SHA512:
6
- metadata.gz: 95a03f9e827e88375540b34c6a925508d1c368175c650943c8dd4ed1d9a0b42cd392074bba01e880ec6bad817ff21a97975cca29883f3a8ac8cbaa193cf3288f
7
- data.tar.gz: 081eeba95e84cfe935024b6d8eaf71b677e1c6f49fc432fb613645dcaaad0ae62dafd444c6d3b9f06268787396e10a33259705f74166d7571c70575a512f318e
6
+ metadata.gz: 20b1eda82a475705f960ff9f7497511c40ea1fd79545ae2471cb8572b4e6446ac416a22d4123343821478ace940cb1b10fb68fe1abc1f55e9a06fa4881bfa655
7
+ data.tar.gz: c63ee68433c8ee6db3229cac7605c279b18c976fad4297e680cc0a75d192da6d213fc759b58d9c40f6ac96dfd13f67ef55cfb3a823c24262bf1655008c444484
@@ -1,5 +1,4 @@
1
- require 'xcake/core_ext/array'
2
- require 'xcake/core_ext/object'
1
+ require 'xcake/core_ext/class'
3
2
  require 'xcake/core_ext/string'
4
3
 
5
4
  require 'xcake/xcode/project'
@@ -39,12 +38,12 @@ require 'xcake/dsl/project/hooks'
39
38
 
40
39
  require 'xcake/dsl/scheme'
41
40
 
42
- require 'xcake/dsl/scheme'
43
-
44
41
  require 'xcake/dsl/target'
45
42
  require 'xcake/dsl/target/sugar'
46
43
  require 'xcake/dsl/target/configurable'
47
44
 
45
+ require 'xcake/dsl/build_rule'
46
+
48
47
  require 'xcake/dsl/build_phase'
49
48
  require 'xcake/dsl/build_phase/headers_build_phase'
50
49
  require 'xcake/dsl/build_phase/shell_script_build_phase'
@@ -7,9 +7,7 @@ module Xcake
7
7
  def run
8
8
  file_path = "#{Dir.pwd}/Cakefile"
9
9
 
10
- unless File.exist?(file_path)
11
- raise Xcake::Informative, "Couldn't find Cakefile"
12
- end
10
+ raise Xcake::Informative, "Couldn't find Cakefile" unless File.exist?(file_path)
13
11
 
14
12
  EventHooks.run_hook :before_cakefile_read
15
13
  file_contents = File.read(file_path)
@@ -11,10 +11,10 @@ module Xcake
11
11
  ]
12
12
  }.freeze,
13
13
  [:ios, :ui_test_bundle] => {
14
- "LD_RUNPATH_SEARCH_PATHS" => [
15
- "$(inherited)",
16
- "@executable_path/Frameworks",
17
- "@loader_path/Frameworks"
14
+ 'LD_RUNPATH_SEARCH_PATHS' => [
15
+ '$(inherited)',
16
+ '@executable_path/Frameworks',
17
+ '@loader_path/Frameworks'
18
18
  ]
19
19
  }.freeze,
20
20
  [:osx, :unit_test_bundle] => {
@@ -25,10 +25,10 @@ module Xcake
25
25
  ]
26
26
  }.freeze,
27
27
  [:osx, :ui_test_bundle] => {
28
- "LD_RUNPATH_SEARCH_PATHS" => [
29
- "$(inherited)",
30
- "@executable_path/../Frameworks",
31
- "@loader_path/../Frameworks"
28
+ 'LD_RUNPATH_SEARCH_PATHS' => [
29
+ '$(inherited)',
30
+ '@executable_path/../Frameworks',
31
+ '@loader_path/../Frameworks'
32
32
  ]
33
33
  }.freeze
34
34
  ).freeze
@@ -60,8 +60,8 @@ module Xcake
60
60
  #
61
61
  # @return [Hash] The common build settings
62
62
  #
63
- def self.common_build_settings(type, platform = nil, deployment_target = nil, target_product_type = nil, language = :objc)
64
- target_product_type = (PRODUCT_TYPE_UTI.find { |_, v| v == target_product_type } || [target_product_type || :application])[0]
63
+ def self.common_build_settings(type, platform = nil, deployment_target = nil, target_product_type = nil, language = :objc) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/LineLength
64
+ target_product_type = (PRODUCT_TYPE_UTI.find { |_, v| v == target_product_type } || [target_product_type || :application])[0] # rubocop:disable Metrics/LineLength
65
65
  common_settings = COMMON_BUILD_SETTINGS
66
66
 
67
67
  # Use intersecting settings for all key sets as base
@@ -14,8 +14,6 @@ module Xcake
14
14
  # The internal hash of native objects reference by their
15
15
  # related DSL object
16
16
  #
17
- attr_accessor :object_hash
18
-
19
17
  def object_hash
20
18
  @object_hash ||= {}
21
19
  end
@@ -7,10 +7,12 @@ module Xcake
7
7
 
8
8
  attr_accessor :project
9
9
 
10
- def create_object_for(dsl_object)
10
+ def create_object_for(dsl_object) # rubocop:disable Metrics/CyclomaticComplexity
11
11
  case dsl_object
12
12
  when BuildPhase
13
13
  create_object_for_build_phase(dsl_object)
14
+ when BuildRule
15
+ create_object_for_build_rule(dsl_object)
14
16
  when Project
15
17
  create_object_for_project(dsl_object)
16
18
  when Target
@@ -26,13 +28,14 @@ module Xcake
26
28
  @project.new(build_phase.build_phase_type)
27
29
  end
28
30
 
31
+ def create_object_for_build_rule(_build_rule)
32
+ @project.new(Xcodeproj::Project::Object::PBXBuildRule)
33
+ end
34
+
29
35
  def create_object_for_project(project)
30
-
31
36
  project_path = "./#{project.name}.xcodeproj"
32
-
33
- if File.exist?(project_path)
34
- FileUtils.remove_dir(project_path)
35
- end
37
+
38
+ FileUtils.remove_dir(project_path) if File.exist?(project_path)
36
39
 
37
40
  @project = Xcode::Project.new(project_path, true)
38
41
  @project.setup_for_xcake
@@ -47,7 +50,7 @@ module Xcake
47
50
  @project.new_configuration(configuration)
48
51
  end
49
52
 
50
- def create_object_for_scheme(scheme)
53
+ def create_object_for_scheme(_scheme)
51
54
  Xcode::Scheme.new
52
55
  end
53
56
 
@@ -0,0 +1,14 @@
1
+ module Xcake
2
+ module CoreExtensions
3
+ # @example Including in a class
4
+ # Class.send(:include, Xcake::CoreExtensions::ClassDescendants) # done with send because of old ruby versions
5
+ #
6
+ module ClassDescendants
7
+ # Returns all descendants of a class
8
+ #
9
+ def descendants
10
+ ObjectSpace.each_object(singleton_class).select { |klass| klass < self }
11
+ end
12
+ end
13
+ end
14
+ end
@@ -7,9 +7,9 @@ module Xcake
7
7
  def initialize(dependency_class)
8
8
  plugins = dependency_class.load_plugins
9
9
 
10
- @dependency_graph = plugins.map do |p|
11
- [p, p.dependencies]
12
- end.to_h
10
+ @dependency_graph = plugins.each_with_object({}) do |p, hash|
11
+ hash[p] = p.dependencies
12
+ end
13
13
  end
14
14
 
15
15
  def tsort_each_node(&block)
@@ -29,9 +29,7 @@ module Xcake
29
29
  @files.each do |file|
30
30
  file_reference = context.file_reference_for_path(file)
31
31
  build_file = native_build_phase.add_file_reference(file_reference)
32
- if code_sign
33
- build_file.settings = { 'ATTRIBUTES' => ['CodeSignOnCopy'] }
34
- end
32
+ build_file.settings = { 'ATTRIBUTES' => ['CodeSignOnCopy'] } if code_sign
35
33
  end
36
34
  end
37
35
 
@@ -8,6 +8,12 @@ module Xcake
8
8
  # String coataining the contents of the script to run
9
9
  attr_accessor :script
10
10
 
11
+ # input/output paths
12
+ attr_accessor :input_paths
13
+ attr_accessor :output_paths
14
+ attr_accessor :input_file_list_paths
15
+ attr_accessor :output_file_list_paths
16
+
11
17
  def build_phase_type
12
18
  Xcodeproj::Project::Object::PBXShellScriptBuildPhase
13
19
  end
@@ -15,6 +21,10 @@ module Xcake
15
21
  def configure_native_build_phase(native_build_phase, _context)
16
22
  native_build_phase.name = name
17
23
  native_build_phase.shell_script = script.strip_heredoc
24
+ native_build_phase.input_paths = input_paths || []
25
+ native_build_phase.output_paths = output_paths || []
26
+ native_build_phase.input_file_list_paths = input_file_list_paths || []
27
+ native_build_phase.output_file_list_paths = output_file_list_paths || []
18
28
  end
19
29
 
20
30
  def to_s
@@ -0,0 +1,76 @@
1
+ module Xcake
2
+ # This class is used to describe a build rule for a
3
+ # Xcode project; This forms part of the DSL
4
+ # and is usually stored in files named `Cakefile`.
5
+ #
6
+ class BuildRule
7
+ # @return [String] the name of the rule.
8
+ #
9
+ attr_accessor :name
10
+
11
+ # @return [String] the type of the files that should be processed by
12
+ # this rule.
13
+ #
14
+ # @example
15
+ # `pattern.proxy`.
16
+ #
17
+ attr_accessor :file_type
18
+
19
+ # @return [ObjectList<PBXFileReference>] the file references for the
20
+ # output files.
21
+ #
22
+ attr_accessor :output_files
23
+
24
+ # @return [ObjectList<String>] the compiler flags used when creating the
25
+ # respective output files.
26
+ #
27
+ attr_accessor :output_files_compiler_flags
28
+
29
+ # @return [String] the content of the script to use for the build rule.
30
+ #
31
+ # @note This attribute is present if the #{#compiler_spec} is
32
+ # `com.apple.compilers.proxy.script`
33
+ #
34
+ attr_accessor :script
35
+
36
+ # @param [Proc] block
37
+ # an optional block that configures the build rule through the DSL.
38
+ #
39
+ # @example Creating a Build Rule.
40
+ #
41
+ # BuildRule.new do |p|
42
+ # p.name "test"
43
+ # end
44
+ #
45
+ def initialize
46
+ @output_files = []
47
+ @output_files_compiler_flags = []
48
+
49
+ yield(self) if block_given?
50
+ end
51
+
52
+ # This method is called when generating the build rules
53
+ # subclasses should implement this to handle the
54
+ # configuration of the build phase
55
+ #
56
+ def configure_native_build_rule(native_build_rule, _context)
57
+ native_build_rule.name = name
58
+ native_build_rule.compiler_spec = 'com.apple.compilers.proxy.script'
59
+ native_build_rule.file_type = file_type
60
+ native_build_rule.script = script.strip_heredoc
61
+ if output_files_compiler_flags.empty?
62
+ output_files.each do |file|
63
+ native_build_rule.add_output_file(file)
64
+ end
65
+ else
66
+ output_files.zip(output_files_compiler_flags).each do |file, flag|
67
+ native_build_rule.add_output_file(file, flag)
68
+ end
69
+ end
70
+ end
71
+
72
+ def to_s
73
+ "BuildRule<#{name}>"
74
+ end
75
+ end
76
+ end
@@ -39,9 +39,11 @@ module Xcake
39
39
  private
40
40
 
41
41
  def copy_parent_configurations
42
+ return unless parent_configurable
43
+
42
44
  parent_configurable.all_configurations.each do |c|
43
45
  configuration(c.name, c.type)
44
- end if parent_configurable
46
+ end
45
47
  end
46
48
 
47
49
  public
@@ -93,13 +95,13 @@ module Xcake
93
95
  default_settings = default_settings_for_type(type)
94
96
  configurations = configurations_of_type(type)
95
97
 
96
- if name.nil?
97
- build_configuration = configurations.first
98
- else
99
- build_configuration = configurations.detect do |c|
100
- c.name == name.to_s
101
- end
102
- end
98
+ build_configuration = if name.nil?
99
+ configurations.first
100
+ else
101
+ configurations.detect do |c|
102
+ c.name == name.to_s
103
+ end
104
+ end
103
105
 
104
106
  if build_configuration.nil?
105
107
 
@@ -17,7 +17,7 @@ module Xcake
17
17
  #
18
18
  # @example Using Supported Devices
19
19
  #
20
- # Target.new do |t|
20
+ # Target.new(project) do |t|
21
21
  # t.all_configurations.each do |c|
22
22
  # c.supported_devices = :ipad_only
23
23
  # end
@@ -63,7 +63,7 @@ module Xcake
63
63
  # the newly created target
64
64
  #
65
65
  def target(&block)
66
- target = Target.new(&block)
66
+ target = Target.new(self, &block)
67
67
  targets << target
68
68
  target
69
69
  end
@@ -5,6 +5,10 @@ module Xcake
5
5
  include Hooks
6
6
  include Hooks::InstanceHooks
7
7
 
8
+ # Defines hook which is ran before project is saved.
9
+ #
10
+ define_hooks :before_save
11
+
8
12
  # Defines hook which is ran after project is saved.
9
13
  #
10
14
  define_hooks :after_save
@@ -89,26 +89,24 @@ module Xcake
89
89
  private
90
90
 
91
91
  def configure_test_target_for_host_target(test_target, host_target)
92
-
93
92
  test_target.target_dependencies << host_target
94
93
  test_target.platform = host_target.platform
95
94
  test_target.deployment_target = host_target.deployment_target
96
95
  test_target.language = host_target.language
97
96
 
98
- if host_target.type == :application
99
- test_target.all_configurations.each do |c|
100
- if test_target.type == :ui_test_bundle
101
- # Do nothing as they break UITests
102
- # For more details https://github.com/jcampbell05/xcake/issues/115
103
- else
104
- c.settings["BUNDLE_LOADER"] = "$(TEST_HOST)"
105
- if host_target.platform == :osx
106
- c.settings["TEST_HOST"] = "$(BUILT_PRODUCTS_DIR)/#{host_target.name}.app/Contents/MacOS/#{host_target.name}"
107
- else
108
- c.settings["TEST_HOST"] = "$(BUILT_PRODUCTS_DIR)/#{host_target.name}.app/#{host_target.name}"
109
- end
110
- end
111
- end
97
+ return unless host_target.type == :application
98
+
99
+ test_target.all_configurations.each do |c|
100
+ # Do nothing as they break UITests
101
+ # For more details https://github.com/jcampbell05/xcake/issues/115
102
+ next if test_target.type == :ui_test_bundle
103
+
104
+ c.settings['BUNDLE_LOADER'] = '$(TEST_HOST)'
105
+ c.settings['TEST_HOST'] = if host_target.platform == :osx
106
+ "$(BUILT_PRODUCTS_DIR)/#{host_target.name}.app/Contents/MacOS/#{host_target.name}"
107
+ else
108
+ "$(BUILT_PRODUCTS_DIR)/#{host_target.name}.app/#{host_target.name}"
109
+ end
112
110
  end
113
111
  end
114
112
 
@@ -7,13 +7,13 @@ module Xcake
7
7
  include Visitable
8
8
 
9
9
  # The name for the scheme
10
- #
10
+ #
11
11
  attr_accessor :name
12
12
 
13
13
  # The configuration to use when testing
14
14
  #
15
15
  # Defaults to "Debug"
16
- #
16
+ #
17
17
  attr_accessor :test_configuration
18
18
 
19
19
  # The configuration to use when launching
@@ -41,7 +41,6 @@ module Xcake
41
41
  attr_accessor :archive_configuration
42
42
 
43
43
  def initialize(name)
44
-
45
44
  @name = name
46
45
  @test_configuration = 'Debug'
47
46
  @launch_configuration = 'Debug'
@@ -42,6 +42,11 @@ module Xcake
42
42
  #
43
43
  attr_accessor :build_phases
44
44
 
45
+ # @return [Array<BuildRule>] the list
46
+ # of build rules for the project.
47
+ #
48
+ attr_accessor :build_rules
49
+
45
50
  # @!group File patterns
46
51
 
47
52
  #
@@ -131,7 +136,7 @@ module Xcake
131
136
  #
132
137
  # spec.include_files = "Classes/**/*.{h,m}"
133
138
  #
134
- attr_accessor :include_files
139
+ attr_writer :include_files
135
140
 
136
141
  # @return [Array or String] files to exclude for the target.
137
142
  # Supports regular expressions
@@ -153,7 +158,7 @@ module Xcake
153
158
  #
154
159
  # spec.system_frameworks = ["Foundation"]
155
160
  #
156
- attr_accessor :system_frameworks
161
+ attr_writer :system_frameworks
157
162
 
158
163
  # @return [Array<String>] system libraries to include for the target
159
164
  #
@@ -177,23 +182,28 @@ module Xcake
177
182
  #
178
183
  attr_accessor :schemes
179
184
 
185
+ # @param [Project] project
186
+ # the project the target belongs to.
187
+ #
180
188
  # @param [Proc] block
181
189
  # an optional block that configures the target through the DSL.
182
190
  #
183
191
  # @example Creating a Target.
184
192
  #
185
- # Target.new do |t|
193
+ # Target.new(project) do |t|
186
194
  # t.name "test"
187
195
  # end
188
196
  #
189
- def initialize
197
+ def initialize(project)
190
198
  @pinned_build_phases = []
191
199
  @build_phases = []
200
+ @build_rules = []
192
201
  @exclude_files = []
193
202
  @linked_targets = []
194
203
  @system_libraries = []
195
204
  @target_dependencies = []
196
205
  @schemes = []
206
+ @project = project
197
207
 
198
208
  yield(self) if block_given?
199
209
  end
@@ -203,7 +213,7 @@ module Xcake
203
213
  # Creates a new scheme for the target
204
214
  #
205
215
  # @param [String] name
206
- # the name of the new scheme
216
+ # the name of the new scheme
207
217
  #
208
218
  # @return [Scheme] the scheme
209
219
  # the newly created scheme
@@ -226,6 +236,10 @@ module Xcake
226
236
  @system_frameworks ||= default_system_frameworks_for(platform)
227
237
  end
228
238
 
239
+ def info_plist_paths
240
+ all_configurations.map { |config| config.settings['INFOPLIST_FILE'] }.uniq
241
+ end
242
+
229
243
  # @!group Conversion
230
244
 
231
245
  def to_s