xcake 0.7.1 → 0.8.1
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 +4 -4
- data/.travis.yml +11 -3
- data/CHANGELOG.md +15 -0
- data/README.md +3 -1
- data/bin/xcake +0 -1
- data/docs/Cakefile.md +82 -1
- data/docs/Xcode Project Support.md +5 -0
- data/example/app/CakeMania/CakeMania.xcodeproj/project.pbxproj +973 -0
- data/example/app/CakeMania/CakeMania.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- data/example/app/CakeMania/CakeMania.xcodeproj/project.xcworkspace/xcuserdata/maxim.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- data/example/app/CakeMania/CakeMania.xcodeproj/xcshareddata/xcschemes/CakeMania-AppStore.xcscheme +91 -0
- data/example/app/CakeMania/CakeMania.xcodeproj/xcshareddata/xcschemes/CakeMania-Debug.xcscheme +91 -0
- data/example/app/CakeMania/CakeMania.xcodeproj/xcshareddata/xcschemes/CakeMania-Production.xcscheme +91 -0
- data/example/app/CakeMania/CakeMania.xcodeproj/xcshareddata/xcschemes/CakeMania-RC.xcscheme +91 -0
- data/example/app/CakeMania/CakeMania.xcodeproj/xcshareddata/xcschemes/CakeMania-Staging.xcscheme +91 -0
- data/example/app/CakeMania/CakeMania.xcodeproj/xcuserdata/maxim.xcuserdatad/xcschemes/CakeManiaTst.xcscheme +56 -0
- data/example/app/CakeMania/CakeMania.xcodeproj/xcuserdata/maxim.xcuserdatad/xcschemes/CakeManiaUITst.xcscheme +56 -0
- data/example/app/CakeMania/CakeMania.xcodeproj/xcuserdata/maxim.xcuserdatad/xcschemes/xcschememanagement.plist +72 -0
- data/{docs/Sample → example/app/CakeMania}/Cakefile +80 -47
- data/example/app/CakeMania/Info/CakeMania.plist +38 -0
- data/example/app/CakeMania/Info/CakeManiaTst.plist +22 -0
- data/example/app/CakeMania/Info/CakeManiaUITst.plist +22 -0
- data/example/app/CakeMania/Res/CakeMania-test.entitlements +10 -0
- data/example/app/CakeMania/Res/CakeMania.entitlements +10 -0
- data/example/app/CakeMania/Res/CakeMania.xcassets/AppIcon.appiconset/Contents.json +48 -0
- data/example/app/CakeMania/Src/AppDelegate.swift +46 -0
- data/example/app/CakeMania/Src/Base.lproj/LaunchScreen.storyboard +27 -0
- data/example/app/CakeMania/Src/Base.lproj/Main.storyboard +26 -0
- data/example/app/CakeMania/Src/ObjC/CakeMania-Bridging-Header.h +3 -0
- data/example/app/CakeMania/Src/ObjC/Prefix.pch +14 -0
- data/example/app/CakeMania/Src/ViewController.swift +25 -0
- data/example/app/CakeMania/Tst/Main.swift +36 -0
- data/example/app/CakeMania/UITst/Main.swift +36 -0
- data/example/framework/Cakefile +133 -0
- data/gemfiles/Gemfile.xcodeproj-1.3.x +5 -0
- data/gemfiles/Gemfile.xcodeproj-1.4.x +5 -0
- data/gemfiles/Gemfile.xcodeproj-edge +5 -0
- data/lib/xcake/build_phase/headers_build_phase.rb +47 -0
- data/lib/xcake/build_phase/shell_script_build_phase.rb +24 -0
- data/lib/xcake/build_phase.rb +36 -0
- data/lib/xcake/constants.rb +82 -0
- data/lib/xcake/context/xcodeproj_context.rb +10 -0
- data/lib/xcake/context.rb +24 -0
- data/lib/xcake/generator/scheme_generator.rb +13 -2
- data/lib/xcake/generator/target_build_phase_generator.rb +11 -3
- data/lib/xcake/generator/target_dependency_generator.rb +1 -1
- data/lib/xcake/generator/target_file_reference_generator.rb +4 -5
- data/lib/xcake/generator/target_link_generator.rb +25 -0
- data/lib/xcake/informative.rb +0 -1
- data/lib/xcake/path_classifier.rb +5 -5
- data/lib/xcake/project/sugar.rb +7 -5
- data/lib/xcake/project.rb +0 -1
- data/lib/xcake/target/configurable.rb +2 -6
- data/lib/xcake/target/sugar.rb +28 -3
- data/lib/xcake/target.rb +34 -18
- data/lib/xcake/ui.rb +1 -4
- data/lib/xcake/version.rb +1 -1
- data/lib/xcake/xcode/project.rb +25 -13
- data/lib/xcake/xcode/scheme.rb +3 -0
- data/lib/xcake/xcode/scheme_list.rb +0 -23
- data/lib/xcake/xcodeproj_ext/PBXGroup.rb +3 -3
- data/lib/xcake/xcodeproj_ext/PBXNativeTarget.rb +0 -1
- data/lib/xcake.rb +10 -5
- data/rubocop.yml +0 -4
- data/xcake.gemspec +8 -7
- metadata +112 -80
- data/lib/xcake/generator/target_custom_build_phase_generator.rb +0 -16
- data/lib/xcake/shell_script_build_phase.rb +0 -15
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# https://github.com/jcampbell05/xcake
|
|
2
|
+
# http://www.rubydoc.info/github/jcampbell05/xcake/master/file/docs/Cakefile.md
|
|
3
|
+
|
|
4
|
+
iOSdeploymentTarget = "8.0"
|
|
5
|
+
currentSwiftVersion = "3.0.1" # to set "Use Legacy Swift ..." to "No"
|
|
6
|
+
companyIdentifier = "com.CakeMania"
|
|
7
|
+
developmentTeamId = "XYZXYZ" # for automatic debug signing in Xcode 8
|
|
8
|
+
testSuffix = "Tst"
|
|
9
|
+
|
|
10
|
+
#===
|
|
11
|
+
|
|
12
|
+
project.name = "CakeFamework"
|
|
13
|
+
project.class_prefix = "CFW"
|
|
14
|
+
project.organization = "CakeMania Inc."
|
|
15
|
+
|
|
16
|
+
#=== DEFAULT target settings
|
|
17
|
+
|
|
18
|
+
project.all_configurations.each do |configuration|
|
|
19
|
+
|
|
20
|
+
# for all configurations
|
|
21
|
+
|
|
22
|
+
configuration.settings["SDKROOT"] = "iphoneos"
|
|
23
|
+
configuration.settings["DEBUG_INFORMATION_FORMAT"] = "dwarf"
|
|
24
|
+
configuration.settings["CODE_SIGN_IDENTITY[sdk=iphoneos*]"] = "iPhone Developer"
|
|
25
|
+
configuration.settings["TARGETED_DEVICE_FAMILY"] = "1,2"
|
|
26
|
+
configuration.settings["IPHONEOS_DEPLOYMENT_TARGET"] = iOSdeploymentTarget
|
|
27
|
+
configuration.settings["VERSIONING_SYSTEM"] = "apple-generic"
|
|
28
|
+
|
|
29
|
+
configuration.settings["GCC_NO_COMMON_BLOCKS"] = "YES"
|
|
30
|
+
configuration.settings["GCC_WARN_ABOUT_RETURN_TYPE"] = "YES_ERROR"
|
|
31
|
+
configuration.settings["GCC_WARN_UNINITIALIZED_AUTOS"] = "YES_AGGRESSIVE"
|
|
32
|
+
configuration.settings["CLANG_WARN_DIRECT_OBJC_ISA_USAGE"] = "YES_ERROR"
|
|
33
|
+
configuration.settings["CLANG_WARN_OBJC_ROOT_CLASS"] = "YES_ERROR"
|
|
34
|
+
|
|
35
|
+
configuration.settings["SWIFT_OPTIMIZATION_LEVEL"] = "-Onone"
|
|
36
|
+
|
|
37
|
+
configuration.settings["CURRENT_PROJECT_VERSION"] = "1" # just default non-empty value
|
|
38
|
+
|
|
39
|
+
configuration.settings["CLANG_WARN_INFINITE_RECURSION"] = "YES" # Xcode 8
|
|
40
|
+
configuration.settings["CLANG_WARN_SUSPICIOUS_MOVE"] = "YES" # Xcode 8
|
|
41
|
+
configuration.settings["ENABLE_STRICT_OBJC_MSGSEND"] = "YES" # Xcode 8
|
|
42
|
+
|
|
43
|
+
#===
|
|
44
|
+
|
|
45
|
+
if configuration.name == "Release"
|
|
46
|
+
|
|
47
|
+
configuration.settings["DEBUG_INFORMATION_FORMAT"] = "dwarf-with-dsym"
|
|
48
|
+
configuration.settings["SWIFT_OPTIMIZATION_LEVEL"] = "-Owholemodule" # Xcode 8
|
|
49
|
+
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
#===
|
|
55
|
+
|
|
56
|
+
# Imagine we have project folder structure like this:
|
|
57
|
+
#
|
|
58
|
+
# - Cakefile
|
|
59
|
+
# - Info/
|
|
60
|
+
# | - CakeFamework.plist
|
|
61
|
+
# | - CakeFameworkTst.plist
|
|
62
|
+
# - Src/
|
|
63
|
+
# | - ...
|
|
64
|
+
# - Tst/
|
|
65
|
+
# | - ...
|
|
66
|
+
#
|
|
67
|
+
|
|
68
|
+
#=== TARGETS
|
|
69
|
+
|
|
70
|
+
target do |target|
|
|
71
|
+
|
|
72
|
+
target.name = project.name
|
|
73
|
+
target.type = :framework
|
|
74
|
+
target.language = :swift
|
|
75
|
+
target.platform = :ios
|
|
76
|
+
target.deployment_target = iOSdeploymentTarget
|
|
77
|
+
|
|
78
|
+
#=== CUSTOM settings for the target
|
|
79
|
+
|
|
80
|
+
target.all_configurations.each do |configuration|
|
|
81
|
+
|
|
82
|
+
#=== Build Settings - Core
|
|
83
|
+
|
|
84
|
+
configuration.product_bundle_identifier = companyIdentifier + "." + target.name
|
|
85
|
+
|
|
86
|
+
configuration.settings["INFOPLIST_FILE"] = "Info/" + target.name + ".plist"
|
|
87
|
+
|
|
88
|
+
configuration.settings["PRODUCT_NAME"] = "$(TARGET_NAME)"
|
|
89
|
+
|
|
90
|
+
# Xcode 8 automati c signing support
|
|
91
|
+
configuration.settings["CODE_SIGN_IDENTITY[sdk=iphoneos*]"] = "iPhone Developer"
|
|
92
|
+
configuration.settings["DEVELOPMENT_TEAM"] = developmentTeamId
|
|
93
|
+
|
|
94
|
+
configuration.settings["SWIFT_VERSION"] = currentSwiftVersion # Xcode 8
|
|
95
|
+
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
#=== Source Files
|
|
99
|
+
|
|
100
|
+
# assume all source files are located inside "/Src" folder and its subfolders
|
|
101
|
+
|
|
102
|
+
target.include_files = ["Src/**/*.*"]
|
|
103
|
+
|
|
104
|
+
#=== TEST TARGETS
|
|
105
|
+
|
|
106
|
+
unit_tests_for target do |test_target|
|
|
107
|
+
|
|
108
|
+
test_target.name = target.name + testSuffix
|
|
109
|
+
test_target.deployment_target = iOSdeploymentTarget
|
|
110
|
+
|
|
111
|
+
test_target.all_configurations.each do |configuration|
|
|
112
|
+
|
|
113
|
+
configuration.product_bundle_identifier = companyIdentifier + "." + test_target.name
|
|
114
|
+
|
|
115
|
+
configuration.settings["INFOPLIST_FILE"] = "Info/" + test_target.name + ".plist"
|
|
116
|
+
|
|
117
|
+
configuration.settings["LD_RUNPATH_SEARCH_PATHS"] = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"
|
|
118
|
+
|
|
119
|
+
# Xcode 8 automati c signing support
|
|
120
|
+
configuration.settings["CODE_SIGN_IDENTITY[sdk=iphoneos*]"] = "iPhone Developer"
|
|
121
|
+
configuration.settings["DEVELOPMENT_TEAM"] = developmentTeamId
|
|
122
|
+
|
|
123
|
+
configuration.settings["SWIFT_VERSION"] = currentSwiftVersion # Xcode 8
|
|
124
|
+
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
#=== Source Files
|
|
128
|
+
|
|
129
|
+
test_target.include_files = [testSuffix + "/**/*.*"]
|
|
130
|
+
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
module Xcake
|
|
2
|
+
PUBLIC_HEADER_ATTRIBUTE = { 'ATTRIBUTES' => ['Public'] }.freeze
|
|
3
|
+
PRIVATE_HEADER_ATTRIBUTE = { 'ATTRIBUTES' => ['Private'] }.freeze
|
|
4
|
+
|
|
5
|
+
# This class is used to represent a copy headers build phase
|
|
6
|
+
#
|
|
7
|
+
class HeadersBuildPhase < BuildPhase
|
|
8
|
+
attr_accessor :public
|
|
9
|
+
attr_accessor :private
|
|
10
|
+
attr_accessor :project
|
|
11
|
+
|
|
12
|
+
def initialize
|
|
13
|
+
@public = []
|
|
14
|
+
@private = []
|
|
15
|
+
@project = []
|
|
16
|
+
|
|
17
|
+
yield(self) if block_given?
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def build_phase_type
|
|
21
|
+
Xcodeproj::Project::Object::PBXHeadersBuildPhase
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def configure_native_build_phase(native_build_phase, context)
|
|
25
|
+
@public.each do |file|
|
|
26
|
+
file_reference = context.file_reference_for_path(file)
|
|
27
|
+
build_file = native_build_phase.add_file_reference(file_reference)
|
|
28
|
+
build_file.settings = PUBLIC_HEADER_ATTRIBUTE
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
@private.each do |file|
|
|
32
|
+
file_reference = context.file_reference_for_path(file)
|
|
33
|
+
build_file = native_build_phase.add_file_reference(file_reference)
|
|
34
|
+
build_file.settings = PRIVATE_HEADER_ATTRIBUTE
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
@project.each do |file|
|
|
38
|
+
file_reference = context.file_reference_for_path(file)
|
|
39
|
+
native_build_phase.add_file_reference(file_reference)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def to_s
|
|
44
|
+
'BuildPhase<Copy Headers>'
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module Xcake
|
|
2
|
+
# This class is used to represent a shell script build phase
|
|
3
|
+
#
|
|
4
|
+
class ShellScriptBuildPhase < BuildPhase
|
|
5
|
+
# The name of the build phase as shown in Xcode
|
|
6
|
+
attr_accessor :name
|
|
7
|
+
|
|
8
|
+
# String coataining the contents of the script to run
|
|
9
|
+
attr_accessor :script
|
|
10
|
+
|
|
11
|
+
def build_phase_type
|
|
12
|
+
Xcodeproj::Project::Object::PBXShellScriptBuildPhase
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def configure_native_build_phase(native_build_phase, _context)
|
|
16
|
+
native_build_phase.name = name
|
|
17
|
+
native_build_phase.shell_script = script.strip_heredoc
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def to_s
|
|
21
|
+
"BuildPhase<#{name}>"
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
module Xcake
|
|
2
|
+
# This class is used to describe a build phase for a
|
|
3
|
+
# Xcode project; This forms part of the DSL
|
|
4
|
+
# and is usually stored in files named `Cakefile`.
|
|
5
|
+
#
|
|
6
|
+
class BuildPhase
|
|
7
|
+
# @param [Proc] block
|
|
8
|
+
# an optional block that configures the build phase through the DSL.
|
|
9
|
+
#
|
|
10
|
+
# @example Creating a Build Phase.
|
|
11
|
+
#
|
|
12
|
+
# BuildPhase.new do |p|
|
|
13
|
+
# p.name "test"
|
|
14
|
+
# end
|
|
15
|
+
#
|
|
16
|
+
def initialize
|
|
17
|
+
yield(self) if block_given?
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# This method is called when generating the build phases
|
|
21
|
+
# subclasses should implement this to allow xcake to know
|
|
22
|
+
# what native build phase type this DSL Object represents
|
|
23
|
+
#
|
|
24
|
+
def build_phase_type
|
|
25
|
+
raise 'build_phase_type not implemented'
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# This method is called when generating the build phases
|
|
29
|
+
# subclasses should implement this to handle the
|
|
30
|
+
# configuration of the build phase
|
|
31
|
+
#
|
|
32
|
+
def configure_native_build_phase(_native_build_phase, _context)
|
|
33
|
+
raise 'configure_native_build_phase not implemented'
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
module Xcake
|
|
2
|
+
module Constants
|
|
3
|
+
COMMON_BUILD_SETTINGS = Xcodeproj::Constants::COMMON_BUILD_SETTINGS.deep_merge(
|
|
4
|
+
[:ios, :unit_test_bundle] => {
|
|
5
|
+
'LD_RUNPATH_SEARCH_PATHS' => [
|
|
6
|
+
'$(inherited)',
|
|
7
|
+
'@executable_path/Frameworks',
|
|
8
|
+
'@loader_path/Frameworks'
|
|
9
|
+
]
|
|
10
|
+
}.freeze,
|
|
11
|
+
[:osx, :unit_test_bundle] => {
|
|
12
|
+
'LD_RUNPATH_SEARCH_PATHS' => [
|
|
13
|
+
'$(inherited)',
|
|
14
|
+
'@executable_path/../Frameworks',
|
|
15
|
+
'@loader_path/../Frameworks'
|
|
16
|
+
]
|
|
17
|
+
}.freeze
|
|
18
|
+
).freeze
|
|
19
|
+
|
|
20
|
+
PRODUCT_TYPE_UTI = Xcodeproj::Constants::PRODUCT_TYPE_UTI
|
|
21
|
+
|
|
22
|
+
# Returns the common build settings for a given platform and configuration
|
|
23
|
+
# name.
|
|
24
|
+
#
|
|
25
|
+
# @param [Symbol] type
|
|
26
|
+
# the type of the build configuration, can be `:release` or
|
|
27
|
+
# `:debug`.
|
|
28
|
+
#
|
|
29
|
+
# @param [Symbol] platform
|
|
30
|
+
# the platform for the build settings, can be `:ios` or `:osx`.
|
|
31
|
+
#
|
|
32
|
+
# @param [String] deployment_target
|
|
33
|
+
# the deployment target for the platform.
|
|
34
|
+
#
|
|
35
|
+
# @param [Symbol] target_product_type
|
|
36
|
+
# the product type of the target, can be any of
|
|
37
|
+
# `Constants::PRODUCT_TYPE_UTI.values`
|
|
38
|
+
# or `Constants::PRODUCT_TYPE_UTI.keys`. Default is :application.
|
|
39
|
+
#
|
|
40
|
+
# @param [Symbol] language
|
|
41
|
+
# the primary language of the target, can be `:objc` or `:swift`.
|
|
42
|
+
#
|
|
43
|
+
# @return [Hash] The common build settings
|
|
44
|
+
#
|
|
45
|
+
def self.common_build_settings(type, platform = nil, deployment_target = nil, target_product_type = nil, language = :objc)
|
|
46
|
+
target_product_type = (PRODUCT_TYPE_UTI.find { |_, v| v == target_product_type } || [target_product_type || :application])[0]
|
|
47
|
+
common_settings = COMMON_BUILD_SETTINGS
|
|
48
|
+
|
|
49
|
+
# Use intersecting settings for all key sets as base
|
|
50
|
+
settings = deep_dup(common_settings[:all])
|
|
51
|
+
|
|
52
|
+
# Match further common settings by key sets
|
|
53
|
+
keys = [type, platform, target_product_type, language].compact
|
|
54
|
+
key_combinations = (1..keys.length).flat_map { |n| keys.combination(n).to_a }
|
|
55
|
+
key_combinations.each do |key_combination|
|
|
56
|
+
settings.merge!(deep_dup(common_settings[key_combination] || {}))
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
if deployment_target
|
|
60
|
+
case platform
|
|
61
|
+
when :ios then settings['IPHONEOS_DEPLOYMENT_TARGET'] = deployment_target
|
|
62
|
+
when :osx then settings['MACOSX_DEPLOYMENT_TARGET'] = deployment_target
|
|
63
|
+
when :tvos then settings['TVOS_DEPLOYMENT_TARGET'] = deployment_target
|
|
64
|
+
when :watchos then settings['WATCHOS_DEPLOYMENT_TARGET'] = deployment_target
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
settings
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# Creates a deep copy of the given object
|
|
72
|
+
#
|
|
73
|
+
# @param [Object] object
|
|
74
|
+
# the object to copy.
|
|
75
|
+
#
|
|
76
|
+
# @return [Object] The deeply copy of the obejct object.
|
|
77
|
+
#
|
|
78
|
+
def self.deep_dup(object)
|
|
79
|
+
Xcodeproj::Project::ProjectHelper.deep_dup(object)
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
@@ -9,6 +9,8 @@ module Xcake
|
|
|
9
9
|
|
|
10
10
|
def create_object_for(dsl_object)
|
|
11
11
|
case dsl_object
|
|
12
|
+
when BuildPhase
|
|
13
|
+
create_object_for_build_phase(dsl_object)
|
|
12
14
|
when Project
|
|
13
15
|
create_object_for_project(dsl_object)
|
|
14
16
|
when Target
|
|
@@ -20,6 +22,10 @@ module Xcake
|
|
|
20
22
|
end
|
|
21
23
|
end
|
|
22
24
|
|
|
25
|
+
def create_object_for_build_phase(build_phase)
|
|
26
|
+
@project.new(build_phase.build_phase_type)
|
|
27
|
+
end
|
|
28
|
+
|
|
23
29
|
def create_object_for_project(project)
|
|
24
30
|
@project = Xcode::Project.new("./#{project.name}.xcodeproj", true)
|
|
25
31
|
@project.setup_for_xcake
|
|
@@ -42,5 +48,9 @@ module Xcake
|
|
|
42
48
|
pathname = Pathname.new path
|
|
43
49
|
@project.file_reference_for_path(pathname)
|
|
44
50
|
end
|
|
51
|
+
|
|
52
|
+
def scheme_list
|
|
53
|
+
@scheme_list ||= Xcode::SchemeList.new(@project)
|
|
54
|
+
end
|
|
45
55
|
end
|
|
46
56
|
end
|
data/lib/xcake/context.rb
CHANGED
|
@@ -1,18 +1,42 @@
|
|
|
1
1
|
require 'xcodeproj'
|
|
2
2
|
|
|
3
3
|
module Xcake
|
|
4
|
+
# The Context is an object that tracking of native objects in the project
|
|
5
|
+
# format.
|
|
6
|
+
#
|
|
7
|
+
# It allows components of the Xcake generator system to retrieve the
|
|
8
|
+
# native representation of a DSL object which is useful for operations
|
|
9
|
+
# which require multiple steps.
|
|
10
|
+
#
|
|
11
|
+
# See XcodeprojContext and the Genrators for how this is used.
|
|
12
|
+
#
|
|
4
13
|
module Context
|
|
14
|
+
# The internal hash of native objects reference by their
|
|
15
|
+
# related DSL object
|
|
16
|
+
#
|
|
5
17
|
attr_accessor :object_hash
|
|
6
18
|
|
|
7
19
|
def object_hash
|
|
8
20
|
@object_hash ||= {}
|
|
9
21
|
end
|
|
10
22
|
|
|
23
|
+
# This method returns or creates a native object
|
|
24
|
+
# for a DSL object
|
|
25
|
+
#
|
|
11
26
|
def native_object_for(dsl_object)
|
|
12
27
|
object_hash[dsl_object] ||= create_object_for(dsl_object)
|
|
13
28
|
end
|
|
14
29
|
|
|
30
|
+
# This method returns or creates a file reference
|
|
31
|
+
# for a path
|
|
32
|
+
#
|
|
15
33
|
def file_reference_for_path(path)
|
|
16
34
|
end
|
|
35
|
+
|
|
36
|
+
# This method returns or creates a scheme list for
|
|
37
|
+
# the project
|
|
38
|
+
#
|
|
39
|
+
def scheme_list
|
|
40
|
+
end
|
|
17
41
|
end
|
|
18
42
|
end
|
|
@@ -4,11 +4,22 @@ module Xcake
|
|
|
4
4
|
[TargetGenerator, ConfigurationGenerator]
|
|
5
5
|
end
|
|
6
6
|
|
|
7
|
-
def visit_project(
|
|
7
|
+
def visit_project(_project)
|
|
8
8
|
EventHooks.run_hook :before_adding_user_schemes
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def visit_target(target)
|
|
12
|
+
scheme_list = @context.scheme_list
|
|
13
|
+
native_target = @context.native_object_for(target)
|
|
9
14
|
|
|
15
|
+
scheme_list.create_schemes_for_target(native_target) unless native_target.test_target_type?
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def leave_project(project)
|
|
19
|
+
scheme_list = @context.scheme_list
|
|
10
20
|
native_project = @context.native_object_for(project)
|
|
11
|
-
|
|
21
|
+
|
|
22
|
+
scheme_list.save(native_project.path)
|
|
12
23
|
end
|
|
13
24
|
end
|
|
14
25
|
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
module Xcake
|
|
2
|
-
#
|
|
3
|
-
#
|
|
4
|
-
#
|
|
2
|
+
# This generator generates the build phases for each target
|
|
3
|
+
# in the project
|
|
4
|
+
#
|
|
5
5
|
class TargetBuildPhaseGenerator < Generator
|
|
6
6
|
def self.dependencies
|
|
7
7
|
[TargetGenerator, TargetDependencyGenerator]
|
|
@@ -12,6 +12,14 @@ module Xcake
|
|
|
12
12
|
|
|
13
13
|
native_target = @context.native_object_for(target)
|
|
14
14
|
|
|
15
|
+
target.build_phases.each do |phase|
|
|
16
|
+
EventHooks.run_hook :before_adding_custom_build_phase, phase, target
|
|
17
|
+
|
|
18
|
+
native_build_phase = @context.native_object_for(phase)
|
|
19
|
+
phase.configure_native_build_phase(native_build_phase, @context)
|
|
20
|
+
native_target.build_phases << native_build_phase
|
|
21
|
+
end
|
|
22
|
+
|
|
15
23
|
target.target_dependencies.each do |dep|
|
|
16
24
|
native_dep = @context.native_object_for(dep)
|
|
17
25
|
|
|
@@ -14,13 +14,12 @@ module Xcake
|
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
def visit_target(target)
|
|
17
|
-
|
|
18
|
-
paths_to_include = Dir.glob(target.include_files).map { |f|
|
|
17
|
+
paths_to_include = Dir.glob(target.include_files).map do |f|
|
|
19
18
|
Pathname.new(f).cleanpath.to_s
|
|
20
|
-
|
|
21
|
-
paths_to_exclude = Dir.glob(target.exclude_files).map
|
|
19
|
+
end
|
|
20
|
+
paths_to_exclude = Dir.glob(target.exclude_files).map do |f|
|
|
22
21
|
Pathname.new(f).cleanpath.to_s
|
|
23
|
-
|
|
22
|
+
end
|
|
24
23
|
|
|
25
24
|
paths = paths_to_include - paths_to_exclude
|
|
26
25
|
paths.each do |p|
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module Xcake
|
|
2
|
+
# This generator handles linking targets
|
|
3
|
+
# specified as being linked in the Cakefile
|
|
4
|
+
#
|
|
5
|
+
class TargetLinkGenerator < Generator
|
|
6
|
+
def self.dependencies
|
|
7
|
+
[TargetGenerator]
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def visit_target(target)
|
|
11
|
+
return if target.linked_targets.empty?
|
|
12
|
+
|
|
13
|
+
native_target = @context.native_object_for(target)
|
|
14
|
+
frameworks_build_phase = native_target.frameworks_build_phase
|
|
15
|
+
|
|
16
|
+
target.linked_targets.each do |linked_target|
|
|
17
|
+
native_linked_target = @context.native_object_for(linked_target)
|
|
18
|
+
target.target_dependencies << linked_target
|
|
19
|
+
|
|
20
|
+
linked_product = native_linked_target.product_reference
|
|
21
|
+
frameworks_build_phase.add_file_reference(linked_product)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
data/lib/xcake/informative.rb
CHANGED
|
@@ -5,10 +5,10 @@ module Xcake
|
|
|
5
5
|
#
|
|
6
6
|
class PathClassifier
|
|
7
7
|
EXTENSION_MAPPINGS = {
|
|
8
|
-
PBXFrameworksBuildPhase: %w
|
|
9
|
-
PBXHeadersBuildPhase: %w
|
|
10
|
-
PBXSourcesBuildPhase: %w
|
|
11
|
-
PBXResourcesBuildPhase: %w
|
|
8
|
+
PBXFrameworksBuildPhase: %w(.a .dylib .so .framework).freeze,
|
|
9
|
+
PBXHeadersBuildPhase: %w(.h .hpp).freeze,
|
|
10
|
+
PBXSourcesBuildPhase: %w(.c .m .mm .cpp .swift .xcdatamodeld).freeze,
|
|
11
|
+
PBXResourcesBuildPhase: %w(.xcassets).freeze
|
|
12
12
|
}.freeze
|
|
13
13
|
|
|
14
14
|
# @note This should be overidden
|
|
@@ -27,7 +27,7 @@ module Xcake
|
|
|
27
27
|
|
|
28
28
|
def self.classification_for_path(path)
|
|
29
29
|
classification = EXTENSION_MAPPINGS.detect do |_key, ext_group|
|
|
30
|
-
ext_group.any? {|ext| File.extname(path) == ext}
|
|
30
|
+
ext_group.any? { |ext| File.extname(path) == ext }
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
return :PBXResourcesBuildPhase if classification.nil?
|
data/lib/xcake/project/sugar.rb
CHANGED
|
@@ -94,11 +94,13 @@ module Xcake
|
|
|
94
94
|
test_target.language = host_target.language
|
|
95
95
|
|
|
96
96
|
host_path = "#{host_target.name}.app/#{host_target.name}"
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
97
|
+
|
|
98
|
+
# TODO: Custom Xcode setting constant
|
|
99
|
+
if host_target.type == :application
|
|
100
|
+
test_target.all_configurations.each do |c|
|
|
101
|
+
c.settings['TEST_HOST'] = "$(BUILT_PRODUCTS_DIR)/#{host_path}"
|
|
102
|
+
c.settings['BUNDLE_LOADER'] = '$(TEST_HOST)'
|
|
103
|
+
end
|
|
102
104
|
end
|
|
103
105
|
end
|
|
104
106
|
|
data/lib/xcake/project.rb
CHANGED
|
@@ -4,10 +4,6 @@ module Xcake
|
|
|
4
4
|
@project
|
|
5
5
|
end
|
|
6
6
|
|
|
7
|
-
# TODO: Move this to a constant, maybe Xcodeproj ones should be brought
|
|
8
|
-
# into here?
|
|
9
|
-
#
|
|
10
|
-
# Perhaps these could be made into a Gem itself?
|
|
11
7
|
def default_settings
|
|
12
8
|
{
|
|
13
9
|
'INFOPLIST_FILE' => "#{name}/Supporting Files/Info.plist"
|
|
@@ -15,7 +11,7 @@ module Xcake
|
|
|
15
11
|
end
|
|
16
12
|
|
|
17
13
|
def default_debug_settings
|
|
18
|
-
|
|
14
|
+
Xcake::Constants
|
|
19
15
|
.common_build_settings(:debug,
|
|
20
16
|
platform,
|
|
21
17
|
deployment_target.to_s,
|
|
@@ -26,7 +22,7 @@ module Xcake
|
|
|
26
22
|
end
|
|
27
23
|
|
|
28
24
|
def default_release_settings
|
|
29
|
-
|
|
25
|
+
Xcake::Constants
|
|
30
26
|
.common_build_settings(:release,
|
|
31
27
|
platform,
|
|
32
28
|
deployment_target.to_s,
|
data/lib/xcake/target/sugar.rb
CHANGED
|
@@ -2,10 +2,35 @@ require 'xcodeproj'
|
|
|
2
2
|
|
|
3
3
|
module Xcake
|
|
4
4
|
class Target
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
# Creates a new Copy Headers build phase for the
|
|
6
|
+
# target
|
|
7
|
+
#
|
|
8
|
+
# @param [Proc] block
|
|
9
|
+
# an optional block that configures the build phase through the DSL.
|
|
10
|
+
#
|
|
11
|
+
# @return [HeadersBuildPhase] the new xcode build phase
|
|
12
|
+
#
|
|
13
|
+
def headers_build_phase(&block)
|
|
14
|
+
phase = HeadersBuildPhase.new(&block)
|
|
15
|
+
build_phases << phase
|
|
16
|
+
phase
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Creates a new Shell Script build phase for the
|
|
20
|
+
# target
|
|
21
|
+
#
|
|
22
|
+
# @param [String] name
|
|
23
|
+
# the name to use for the build phase
|
|
24
|
+
#
|
|
25
|
+
# @param [Proc] block
|
|
26
|
+
# an optional block that configures the build phase through the DSL.
|
|
27
|
+
#
|
|
28
|
+
# @return [ShellScriptBuildPhase] the new xcode build phase
|
|
29
|
+
#
|
|
30
|
+
def shell_script_build_phase(name, script, &block)
|
|
31
|
+
phase = ShellScriptBuildPhase.new(&block)
|
|
7
32
|
phase.name = name
|
|
8
|
-
phase.script = script
|
|
33
|
+
phase.script = script
|
|
9
34
|
build_phases << phase
|
|
10
35
|
phase
|
|
11
36
|
end
|