xcake 0.8.12 → 0.9.3

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.
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
@@ -71,5 +71,27 @@ module Xcake
71
71
  build_phases << phase
72
72
  phase
73
73
  end
74
+
75
+ # Creates a new build rule for the
76
+ # target
77
+ #
78
+ # @param [String] name
79
+ # the name to use for the build rule
80
+ #
81
+ # @param [Proc] block
82
+ # an optional block that configures the build rule through the DSL.
83
+ #
84
+ # @return [BuildRule] the new xcode build rule
85
+ #
86
+ def build_rule(name, file_type, output_files, output_files_compiler_flags, script, &block)
87
+ rule = BuildRule.new(&block)
88
+ rule.name = name
89
+ rule.file_type = file_type
90
+ rule.output_files = output_files
91
+ rule.output_files_compiler_flags = output_files_compiler_flags
92
+ rule.script = script
93
+ build_rules << rule
94
+ rule
95
+ end
74
96
  end
75
97
  end
@@ -55,6 +55,11 @@ module Xcake
55
55
  #
56
56
  define_hooks :before_adding_system_framework
57
57
 
58
+ # Defines hook which is ran before we add build rules
59
+ # to a target
60
+ #
61
+ define_hooks :before_adding_build_rules
62
+
58
63
  # Defines hook which is ran before we add build phases
59
64
  # to a target
60
65
  #
@@ -68,6 +73,11 @@ module Xcake
68
73
  #
69
74
  define_hooks :before_adding_file
70
75
 
76
+ # Defines hook which is ran before we add a custom build rule to
77
+ # a target
78
+ #
79
+ define_hooks :before_adding_custom_build_rule
80
+
71
81
  # Defines hook which is ran before we add a custom build phase to
72
82
  # a target
73
83
  #
@@ -3,6 +3,7 @@ module Xcake
3
3
  include Dependency
4
4
  include Plugin
5
5
  include Visitor
6
+ Class.send(:include, CoreExtensions::ClassDescendants) # done with send because of old ruby versions
6
7
 
7
8
  attr_accessor :context
8
9
 
@@ -8,7 +8,6 @@ module Xcake
8
8
  # and targets have all of the same configurations.
9
9
  #
10
10
  class DefaultProjectStructureGenerator < Generator
11
-
12
11
  def self.dependencies
13
12
  [ProjectMetadataGenerator, TargetGenerator]
14
13
  end
@@ -40,11 +39,11 @@ module Xcake
40
39
 
41
40
  target.all_configurations.each do |c|
42
41
  target.scheme "#{target.name}-#{c.name}" do |s|
43
- s.test_configuration = c.name
44
- s.launch_configuration = c.name
45
- s.profile_configuration = c.name
46
- s.analyze_configuration = c.name
47
- s.archive_configuration = c.name
42
+ s.test_configuration = c.name
43
+ s.launch_configuration = c.name
44
+ s.profile_configuration = c.name
45
+ s.analyze_configuration = c.name
46
+ s.archive_configuration = c.name
48
47
  end
49
48
  end
50
49
  end
@@ -1,13 +1,14 @@
1
1
  module Xcake
2
2
  class ProjectGenerator < Generator
3
3
  def self.dependencies
4
- Generator.descendants.select do |g|
5
- g != self
4
+ Generator.descendants.reject do |g|
5
+ g == self
6
6
  end
7
7
  end
8
8
 
9
9
  def leave_project(project)
10
10
  native_project = @context.native_object_for(project)
11
+ project.run_hook :before_save, native_project
11
12
  native_project.save
12
13
  project.run_hook :after_save
13
14
 
@@ -13,42 +13,52 @@ module Xcake
13
13
  scheme_list = @context.scheme_list
14
14
  native_target = @context.native_object_for(target)
15
15
 
16
- target.schemes.each do |scheme|
16
+ target.schemes.each do |scheme|
17
+ scheme_list.supress_autocreation_of_target(native_target)
17
18
 
18
- scheme_list.supress_autocreation_of_target(native_target)
19
+ native_scheme = @context.native_object_for(scheme)
20
+ native_scheme.name = scheme.name
19
21
 
20
- native_scheme = @context.native_object_for(scheme)
21
- native_scheme.name = scheme.name
22
+ native_scheme.configure_with_targets(native_target, nil)
22
23
 
23
- native_project = @context.native_object_for(@project)
24
- native_unit_test_target = native_project.find_unit_test_target_for_target(target)
24
+ native_project = @context.native_object_for(@project)
25
+ native_unit_test_target = native_project.find_unit_test_target_for_target(target)
25
26
 
26
- if native_unit_test_target
27
- scheme_list.supress_autocreation_of_target(native_unit_test_target)
28
- end
27
+ if native_unit_test_target
28
+ scheme_list.supress_autocreation_of_target(native_unit_test_target)
29
+ # native_scheme.add_build_target(native_unit_test_target, false)
30
+ native_scheme.add_test_target(native_unit_test_target)
31
+ end
29
32
 
30
- # # TODO: Spec
31
- # if native_target.library_target_type?
32
- # build_action = native_scheme.build_action
33
+ native_ui_test_target = native_project.find_ui_test_target_for_target(target)
33
34
 
34
- # entry = Xcodeproj::XCScheme::BuildAction::Entry.initialize()
35
- # entry.build_for_running(true)
35
+ if native_ui_test_target
36
+ scheme_list.supress_autocreation_of_target(native_ui_test_target)
37
+ # native_scheme.add_build_target(native_ui_test_target, false)
38
+ native_scheme.add_test_target(native_ui_test_target)
39
+ end
36
40
 
37
- # build_action.add_entry(entry)
38
- # end
41
+ # # TODO: Spec
42
+ # if native_target.library_target_type?
43
+ # build_action = native_scheme.build_action
39
44
 
40
- native_scheme.configure_with_targets(native_target, native_unit_test_target)
41
- native_scheme.test_action.build_configuration = scheme.test_configuration
42
- native_scheme.launch_action.build_configuration = scheme.launch_configuration
43
- native_scheme.profile_action.build_configuration = scheme.profile_configuration
44
- native_scheme.analyze_action.build_configuration = scheme.analyze_configuration
45
- native_scheme.archive_action.build_configuration = scheme.archive_configuration
45
+ # entry = Xcodeproj::XCScheme::BuildAction::Entry.initialize()
46
+ # entry.build_for_running(true)
46
47
 
47
- scheme_list.schemes << native_scheme
48
+ # build_action.add_entry(entry)
49
+ # end
50
+
51
+ native_scheme.test_action.build_configuration = scheme.test_configuration
52
+ native_scheme.launch_action.build_configuration = scheme.launch_configuration
53
+ native_scheme.profile_action.build_configuration = scheme.profile_configuration
54
+ native_scheme.analyze_action.build_configuration = scheme.analyze_configuration
55
+ native_scheme.archive_action.build_configuration = scheme.archive_configuration
56
+
57
+ scheme_list.schemes << native_scheme
48
58
  end
49
59
  end
50
60
 
51
- def leave_project(project)
61
+ def leave_project(_project)
52
62
  scheme_list = @context.scheme_list
53
63
  scheme_list.save
54
64
  end
@@ -0,0 +1,24 @@
1
+ module Xcake
2
+ # This generator generates the build phases for each target
3
+ # in the project
4
+ #
5
+ class TargetBuildRuleGenerator < Generator
6
+ def self.dependencies
7
+ [TargetBuildPhaseGenerator]
8
+ end
9
+
10
+ def visit_target(target)
11
+ EventHooks.run_hook :before_adding_build_rules, target
12
+
13
+ native_target = @context.native_object_for(target)
14
+
15
+ target.build_rules.each do |rule|
16
+ EventHooks.run_hook :before_adding_custom_build_rule, rule, target
17
+
18
+ native_build_rule = @context.native_object_for(rule)
19
+ rule.configure_native_build_rule(native_build_rule, @context)
20
+ native_target.build_rules << native_build_rule
21
+ end
22
+ end
23
+ end
24
+ end
@@ -19,12 +19,12 @@ module Xcake
19
19
  paths_without_directories = Dir.glob(reg_exp).reject do |f|
20
20
  file_ext = File.extname(f)
21
21
  disallowed_extensions = [
22
- ".xcdatamodeld",
23
- ".xcassets",
24
- ".framework",
25
- ".bundle"
22
+ '.xcdatamodeld',
23
+ '.xcassets',
24
+ '.framework',
25
+ '.bundle'
26
26
  ]
27
-
27
+
28
28
  File.directory?(f) && !disallowed_extensions.include?(file_ext)
29
29
  end
30
30
  paths = paths_without_directories.map do |f|
@@ -51,11 +51,12 @@ module Xcake
51
51
 
52
52
  build_phase_symbol = PathClassifier.classification_for_path(path)
53
53
 
54
- if PathClassifier.should_create_build_phase_for_classification?(build_phase_symbol)
55
- build_phase_class = Xcodeproj::Project::Object.const_get(build_phase_symbol)
56
- build_phase = native_target.build_phase_by_class(build_phase_class)
57
- build_phase.add_file_reference(file_reference)
58
- end
54
+ return unless PathClassifier.should_create_build_phase_for_classification?(build_phase_symbol)
55
+ return if target.info_plist_paths.include?(path)
56
+
57
+ build_phase_class = Xcodeproj::Project::Object.const_get(build_phase_symbol)
58
+ build_phase = native_target.build_phase_by_class(build_phase_class)
59
+ build_phase.add_file_reference(file_reference)
59
60
  end
60
61
  end
61
62
  end
@@ -5,14 +5,14 @@ module Xcake
5
5
  end
6
6
 
7
7
  def visit_target(target)
8
- unless target.system_frameworks.nil?
9
- EventHooks.run_hook :before_adding_system_framework, target
8
+ return if target.system_frameworks.nil?
10
9
 
11
- native_target = @context.native_object_for(target)
10
+ EventHooks.run_hook :before_adding_system_framework, target
12
11
 
13
- system_frameworks = target.system_frameworks
14
- native_target.add_system_frameworks(system_frameworks)
15
- end
12
+ native_target = @context.native_object_for(target)
13
+
14
+ system_frameworks = target.system_frameworks
15
+ native_target.add_system_frameworks(system_frameworks)
16
16
  end
17
17
  end
18
18
  end
@@ -5,15 +5,14 @@ module Xcake
5
5
  end
6
6
 
7
7
  def visit_target(target)
8
-
9
8
  system_libraries = target.system_libraries.to_a
10
9
 
11
- unless system_libraries.empty?
12
- EventHooks.run_hook :before_adding_system_library, target
10
+ return if system_libraries.empty?
11
+
12
+ EventHooks.run_hook :before_adding_system_library, target
13
13
 
14
- native_target = @context.native_object_for(target)
15
- native_target.add_system_libraries(system_libraries)
16
- end
14
+ native_target = @context.native_object_for(target)
15
+ native_target.add_system_libraries(system_libraries)
17
16
  end
18
17
  end
19
18
  end
@@ -7,7 +7,7 @@ module Xcake
7
7
  EXTENSION_MAPPINGS = {
8
8
  PBXFrameworksBuildPhase: %w(.a .dylib .so .framework).freeze,
9
9
  PBXHeadersBuildPhase: %w(.h .hpp).freeze,
10
- PBXSourcesBuildPhase: %w(.c .m .mm .cpp .swift .xcdatamodeld).freeze,
10
+ PBXSourcesBuildPhase: %w(.c .m .mm .cpp .swift .xcdatamodeld .java).freeze,
11
11
  PBXResourcesBuildPhase: %w(.xcassets).freeze
12
12
  }.freeze
13
13
 
@@ -20,8 +20,9 @@ module Xcake
20
20
  # into the project
21
21
  #
22
22
  def self.should_include_path?(path)
23
- return false if is_locale_container?(path)
24
- return false if is_inside_classified_container?(path)
23
+ return false if locale_container?(path)
24
+ return false if inside_classified_container?(path)
25
+
25
26
  true
26
27
  end
27
28
 
@@ -31,6 +32,7 @@ module Xcake
31
32
  end
32
33
 
33
34
  return :PBXResourcesBuildPhase if classification.nil?
35
+
34
36
  classification.first
35
37
  end
36
38
 
@@ -38,29 +40,31 @@ module Xcake
38
40
  classification != :PBXHeadersBuildPhase
39
41
  end
40
42
 
41
- private_class_method
43
+ class << self
44
+ private
42
45
 
43
- def self.is_locale_container?(path)
44
- components = path.split('/')
45
- File.extname(components.last) == '.lproj'
46
- end
46
+ def locale_container?(path)
47
+ components = path.split('/')
48
+ File.extname(components.last) == '.lproj'
49
+ end
47
50
 
48
- def self.is_inside_classified_container?(path)
49
- components = path.split('/')
51
+ def inside_classified_container?(path)
52
+ components = path.split('/')
50
53
 
51
- classified_component_index = components.index do |c|
52
- is_classified?(c)
53
- end
54
+ classified_component_index = components.index do |c|
55
+ classified?(c)
56
+ end
54
57
 
55
- if !classified_component_index.nil?
56
- classified_component_index < (components.length - 1)
57
- else
58
- false
58
+ if !classified_component_index.nil?
59
+ classified_component_index < (components.length - 1)
60
+ else
61
+ false
62
+ end
59
63
  end
60
- end
61
64
 
62
- def self.is_classified?(path)
63
- EXTENSION_MAPPINGS.values.flatten.any? { |ext| File.extname(path) == ext }
65
+ def classified?(path)
66
+ EXTENSION_MAPPINGS.values.flatten.any? { |ext| File.extname(path) == ext }
67
+ end
64
68
  end
65
69
  end
66
70
  end
@@ -38,7 +38,7 @@ module Xcake
38
38
  end
39
39
 
40
40
  EventHooks.before_attaching_xcconfig do |configuration|
41
- board.puts_indented "- Attaching XCConfig #{configuration.configuration_file} to build configuration #{configuration.name}"
41
+ board.puts_indented "- Attaching XCConfig #{configuration.configuration_file} to build configuration #{configuration.name}" # rubocop:disable Metrics/LineLength
42
42
  end
43
43
 
44
44
  EventHooks.before_adding_system_library do |target|
@@ -53,6 +53,10 @@ module Xcake
53
53
  board.puts_indented "- Integrating System Frameworks #{target.system_frameworks} for #{target}"
54
54
  end
55
55
 
56
+ EventHooks.before_adding_build_rules do |target|
57
+ board.puts_indented "- Creating build rules for #{target}"
58
+ end
59
+
56
60
  EventHooks.before_adding_build_phases do |target|
57
61
  board.puts_indented "- Creating build phases for #{target}"
58
62
  end
@@ -65,6 +69,10 @@ module Xcake
65
69
  board.puts "- Adding #{node.path}"
66
70
  end
67
71
 
72
+ EventHooks.before_adding_custom_build_rule do |rule, target|
73
+ board.puts "- Adding \"#{rule}\" to #{target}"
74
+ end
75
+
68
76
  EventHooks.before_adding_custom_build_phase do |phase, target|
69
77
  board.puts "- Adding \"#{phase}\" to #{target}"
70
78
  end
@@ -1,3 +1,3 @@
1
1
  module Xcake
2
- VERSION = '0.8.12'.freeze
2
+ VERSION = '0.9.3'.freeze
3
3
  end
@@ -140,9 +140,8 @@ module Xcake
140
140
  # @return [PBXGroup] existing or new xcode group
141
141
  #
142
142
  def group_for_file_reference_path(path)
143
- clean_path = path.cleanpath
144
143
  group = variant_group_for_path(path)
145
- group = group_for_path(path) unless group
144
+ group ||= group_for_path(path)
146
145
  group
147
146
  end
148
147
 
@@ -163,6 +162,7 @@ module Xcake
163
162
  base_name = group_path.basename
164
163
 
165
164
  return nil unless base_name.to_s.include?('.lproj')
165
+
166
166
  parent_group = group_for_path(group_path)
167
167
 
168
168
  group = parent_group[path.basename.to_s]
@@ -181,6 +181,7 @@ module Xcake
181
181
  group_path = path.dirname.cleanpath
182
182
 
183
183
  return main_group unless group_path.to_s != '.'
184
+
184
185
  main_group.child_for_path(group_path.to_s)
185
186
  end
186
187
 
@@ -198,6 +199,19 @@ module Xcake
198
199
  t.name == "#{target.name}Tests"
199
200
  end
200
201
  end
202
+
203
+ # Finds a ui test target for a xcode target
204
+ #
205
+ # @param [Target] target
206
+ # target to find a xcode target for.
207
+ #
208
+ # @return [Target] ui test target
209
+ #
210
+ def find_ui_test_target_for_target(target)
211
+ targets.find do |t|
212
+ t.name == "#{target.name}UITests"
213
+ end
214
+ end
201
215
  end
202
216
  end
203
217
  end
@@ -18,8 +18,6 @@ module Xcake
18
18
  #
19
19
  attr_accessor :xcschememanagement
20
20
 
21
- public
22
-
23
21
  # @param [Project] project
24
22
  # project to create scheme list for.
25
23
  #