cocoapods-kz 0.0.2 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cocoapods-kz/command/install.rb +12 -9
- data/lib/cocoapods-kz/command/kz.rb +1 -0
- data/lib/cocoapods-kz/command/repair.rb +47 -0
- data/lib/cocoapods-kz/command/update.rb +12 -8
- data/lib/cocoapods-kz/gem_version.rb +1 -1
- data/lib/cocoapods-kz/helpers/kz_analyzer.rb +46 -3
- data/lib/cocoapods-kz/helpers/kz_framework_manager.rb +1 -1
- data/lib/cocoapods-kz/helpers/kz_generator.rb +256 -0
- data/lib/cocoapods-kz/helpers/kz_global_helper.rb +127 -0
- data/lib/cocoapods-kz/helpers/kz_pod_target.rb +95 -24
- data/lib/cocoapods-kz/helpers/repair_dynamic_swift.rb +373 -0
- data/lib/cocoapods-kz/helpers/repair_module_import.rb +113 -0
- data/lib/cocoapods-kz/native/acknowledgements.rb +8 -15
- data/lib/cocoapods-kz/native/analyzer.rb +5 -4
- data/lib/cocoapods-kz/native/dls.rb +2 -1
- data/lib/cocoapods-kz/native/file_accessor.rb +25 -8
- data/lib/cocoapods-kz/native/installer.rb +9 -22
- data/lib/cocoapods-kz/native/pod_target.rb +17 -0
- data/lib/cocoapods-kz/native/pod_target_installer.rb +30 -0
- data/lib/cocoapods-kz/native/target.rb +34 -0
- data/lib/cocoapods-kz/native/target_installer_helper.rb +105 -0
- data/lib/cocoapods-kz/native.rb +4 -1
- metadata +13 -10
- data/lib/cocoapods-kz/helpers/build_framework_config.rb +0 -48
- data/lib/cocoapods-kz/helpers/create_hamp.rb +0 -214
- data/lib/cocoapods-kz/helpers/global_helper.rb +0 -71
- data/lib/cocoapods-kz/helpers/strip_framework_config.rb +0 -40
- data/lib/cocoapods-kz/helpers/xml_build_config.rb +0 -53
- data/lib/cocoapods-kz/native/user_project_integrator.rb +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f8cee909ef575acab6b79cbcc8bb35111b0828bdac5b60ff697e09f72939373
|
4
|
+
data.tar.gz: 71d9afa7f5b11a7e517c4e2a59fcf91d8b1f9f5ff1e55656187fe23468eb86ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b313218bd5b0dddd59a8f757306c9d1075d4269867b4f092d643fec4d91640d775c496e18ed35936b5a634daf70ed629cd780e55b1962d88ef4707fc5784137b
|
7
|
+
data.tar.gz: 0dfbce6a258f4d94eec260e16856088d9f97533a63f394be0e9cff6ca66e47f4af68048015c0970454b235d72bbd12e55d65054abbd75c000005f484cc656b2b
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'cocoapods-kz/helpers/
|
1
|
+
require 'cocoapods-kz/helpers/kz_global_helper'
|
2
2
|
require 'cocoapods-kz/gem_version'
|
3
3
|
|
4
4
|
module Pod
|
@@ -19,28 +19,31 @@ module Pod
|
|
19
19
|
['--deployment', 'Disallow any changes to the Podfile or the Podfile.lock during installation'],
|
20
20
|
['--clean-install', 'Ignore the contents of the project cache and force a full pod installation. This only ' \
|
21
21
|
'applies to projects that have enabled incremental installation'],
|
22
|
-
['--framework', "后面需要跟上pod名(多个pod,使用英文逗号隔开)"],
|
23
|
-
['--code', "后面需要跟上pod名(多个pod,使用英文逗号隔开)"],
|
22
|
+
['--framework', "后面需要跟上pod名(多个pod,使用英文逗号隔开),支持追加*匹配任意内容"],
|
23
|
+
['--code', "后面需要跟上pod名(多个pod,使用英文逗号隔开),支持追加*匹配任意内容"],
|
24
24
|
['--debug', "debug模式,会打印调试日志或生成调试文件"],
|
25
|
+
['--no-framework-update', "build后不再生成frameowrk"]
|
25
26
|
].concat(super).reject { |(name, _)| name == '--no-repo-update' }
|
26
27
|
end
|
27
28
|
|
28
29
|
def initialize(argv)
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
KZ::KZGlobalHelper.instance.analyze_special_parameters(@use_code_tag, @use_framework_tag, argv.arguments!)
|
30
|
+
use_code_tag = argv.flag?('code')
|
31
|
+
use_framework_tag = argv.flag?('framework')
|
32
|
+
help! if use_code_tag && use_framework_tag
|
33
|
+
KZ::KZGlobalHelper.instance.analyze_special_parameters(use_code_tag, use_framework_tag, argv.arguments!)
|
34
34
|
if Pod.match_version?('~> 1.4')
|
35
35
|
KZ::KZGlobalHelper.instance.kz_pod_enable = true
|
36
|
+
KZ::KZGlobalHelper.instance.generate_kz_pod_targets = true
|
36
37
|
end
|
37
|
-
KZ::KZGlobalHelper.instance.debug = true if
|
38
|
+
KZ::KZGlobalHelper.instance.debug = true if argv.flag?('debug')
|
39
|
+
KZ::KZGlobalHelper.instance.disable_generate_framework = true if argv.flag?('framework-update') != nil
|
38
40
|
|
39
41
|
super
|
40
42
|
@additional_args = argv.remainder!
|
41
43
|
end
|
42
44
|
|
43
45
|
def run
|
46
|
+
KZ::KZGlobalHelper.instance.prepare
|
44
47
|
install = Pod::Command::Install.new(CLAide::ARGV.new([*@additional_args]))
|
45
48
|
install.validate!
|
46
49
|
install.run
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'cocoapods-kz/helpers/repair_dynamic_swift'
|
2
|
+
require 'cocoapods-kz/helpers/repair_module_import'
|
3
|
+
|
4
|
+
module Pod
|
5
|
+
class Command
|
6
|
+
class Kz < Command
|
7
|
+
class Repair < Kz
|
8
|
+
self.summary = 'pod kz repair,用于修复各种不符合规范的场景'
|
9
|
+
|
10
|
+
self.description = <<-DESC
|
11
|
+
结合可选子命令用于执行各种修补脚本
|
12
|
+
DESC
|
13
|
+
|
14
|
+
def self.options
|
15
|
+
[
|
16
|
+
['--module-import', "指定组件名(只针对开发组件),修复该组件所有文件头文件导入方式,壳工程使用“Main”,如果不指定,默认对所有开发组件进行修复"],
|
17
|
+
['--dynamic-swift', "指定组件名(只针对开发组件),将该组件中所有swift文件添加OC特性,壳工程使用“Main”,如果不指定,默认对所有开发组件进行修复"]
|
18
|
+
]
|
19
|
+
end
|
20
|
+
|
21
|
+
def initialize(argv)
|
22
|
+
help! if argv.arguments == 0
|
23
|
+
@repair_module_import = argv.flag?('module-import')
|
24
|
+
@repair_dynamic_swift = argv.flag?('dynamic-swift')
|
25
|
+
help! if !@repair_module_import && !@repair_dynamic_swift
|
26
|
+
|
27
|
+
KZ::KZGlobalHelper.instance.analyze_special_parameters(true, false, argv.arguments!)
|
28
|
+
KZ::KZGlobalHelper.instance.generate_kz_pod_targets = true
|
29
|
+
|
30
|
+
super
|
31
|
+
end
|
32
|
+
|
33
|
+
def run
|
34
|
+
installer = installer_for_config
|
35
|
+
installer.prepare
|
36
|
+
installer.resolve_dependencies.analyze
|
37
|
+
|
38
|
+
if @repair_dynamic_swift
|
39
|
+
KZ::KZSwiftAttachOCFeature.new.repair
|
40
|
+
else @repair_module_import
|
41
|
+
KZ::KZRepairModuleImport.new(installer.aggregate_targets.first.user_project).repair
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'cocoapods-kz/helpers/
|
1
|
+
require 'cocoapods-kz/helpers/kz_global_helper'
|
2
2
|
|
3
3
|
module Pod
|
4
4
|
class Command
|
@@ -19,27 +19,31 @@ module Pod
|
|
19
19
|
['--exclude-pods=podName', 'Pods to exclude during update. Multiple pods must be comma-delimited'],
|
20
20
|
['--clean-install', 'Ignore the contents of the project cache and force a full pod installation. This only ' \
|
21
21
|
'applies to projects that have enabled incremental installation'],
|
22
|
-
['--framework', "后面需要跟上pod名(多个pod,使用英文逗号隔开)"],
|
23
|
-
['--code', "后面需要跟上pod名(多个pod,使用英文逗号隔开)"],
|
22
|
+
['--framework', "后面需要跟上pod名(多个pod,使用英文逗号隔开),支持追加*匹配任意内容"],
|
23
|
+
['--code', "后面需要跟上pod名(多个pod,使用英文逗号隔开),支持追加*匹配任意内容"],
|
24
24
|
['--debug', "debug模式,会打印调试日志或生成调试文件"],
|
25
|
+
['--no-framework-update', "build后不再生成frameowrk"]
|
25
26
|
].concat(super)
|
26
27
|
end
|
27
28
|
|
28
29
|
def initialize(argv)
|
29
|
-
|
30
|
-
|
31
|
-
help! if
|
32
|
-
KZ::KZGlobalHelper.instance.analyze_special_parameters(
|
30
|
+
use_code_tag = argv.flag?('code')
|
31
|
+
use_framework_tag = argv.flag?('framework')
|
32
|
+
help! if use_code_tag && use_framework_tag
|
33
|
+
KZ::KZGlobalHelper.instance.analyze_special_parameters(use_code_tag, use_framework_tag, argv.arguments!)
|
33
34
|
if Pod.match_version?('~> 1.4')
|
34
35
|
KZ::KZGlobalHelper.instance.kz_pod_enable = true
|
36
|
+
KZ::KZGlobalHelper.instance.generate_kz_pod_targets = true
|
35
37
|
end
|
36
|
-
KZ::KZGlobalHelper.instance.debug = true if
|
38
|
+
KZ::KZGlobalHelper.instance.debug = true if argv.flag?('debug')
|
39
|
+
KZ::KZGlobalHelper.instance.disable_generate_framework = true if argv.flag?('framework-update') != nil
|
37
40
|
|
38
41
|
super
|
39
42
|
@additional_args = argv.remainder!
|
40
43
|
end
|
41
44
|
|
42
45
|
def run
|
46
|
+
KZ::KZGlobalHelper.instance.prepare
|
43
47
|
update = Pod::Command::Update.new(CLAide::ARGV.new([*@additional_args]))
|
44
48
|
update.validate!
|
45
49
|
update.run
|
@@ -1,6 +1,8 @@
|
|
1
1
|
require_relative 'kz_pod_target'
|
2
|
+
require_relative 'kz_global_helper'
|
2
3
|
|
3
4
|
module KZ
|
5
|
+
|
4
6
|
class KZAnalyzer
|
5
7
|
attr_accessor :all_kz_pod_targets
|
6
8
|
|
@@ -14,6 +16,24 @@ module KZ
|
|
14
16
|
@native_pod_targets.each { |native_pod_target|
|
15
17
|
create_kz_pod_target_from(native_pod_target, :kz_pod_origin_mode)
|
16
18
|
}
|
19
|
+
|
20
|
+
# 检测是否有product名称相同的target
|
21
|
+
temp_repeat_product_name = []
|
22
|
+
@all_kz_pod_targets.each do |name, kz_pod_target|
|
23
|
+
if temp_repeat_product_name.include?(kz_pod_target.product_name)
|
24
|
+
kz_pod_target.product_name = "#{kz_pod_target.name}.framework"
|
25
|
+
kz_pod_target.product_basename = kz_pod_target.name
|
26
|
+
result = KZGlobalHelper.instance.pod_config_result_with_target(kz_pod_target)
|
27
|
+
if result
|
28
|
+
kz_pod_target.repair_modulemap_path = result.resource_path + kz_pod_target.product_name + "Modules/module.modulemap"
|
29
|
+
else
|
30
|
+
kz_pod_target.repair_modulemap_path = "${PODS_CONFIGURATION_BUILD_DIR}/#{kz_pod_target.name}/#{kz_pod_target.product_name}/Modules/module.modulemap"
|
31
|
+
end
|
32
|
+
kz_pod_target.need_repair_module_import = true
|
33
|
+
else
|
34
|
+
temp_repeat_product_name << kz_pod_target.product_name
|
35
|
+
end
|
36
|
+
end
|
17
37
|
end
|
18
38
|
|
19
39
|
def create_kz_pod_target_from(native_pod_target, config_pod_mode)
|
@@ -33,6 +53,14 @@ module KZ
|
|
33
53
|
end
|
34
54
|
@all_kz_pod_targets[native_pod_target_name] = kz_pod_target
|
35
55
|
|
56
|
+
if is_dev_pod && native_pod_target.test_dependent_targets_by_spec_name.count > 0
|
57
|
+
test_pod_targets = native_pod_target.test_dependent_targets_by_spec_name.values.flatten
|
58
|
+
test_pod_targets.each do |test_pod_target|
|
59
|
+
kz_test_pod_target = create_kz_pod_target_from(test_pod_target, :kz_pod_framework_mode)
|
60
|
+
@all_kz_pod_targets[test_pod_target.name] = kz_test_pod_target
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
36
64
|
kz_dependent_target_info = {}
|
37
65
|
native_pod_target.dependent_targets.each do |native_dependent_target|
|
38
66
|
kz_dependent_pod_target = create_kz_pod_target_from(native_dependent_target, kz_pod_target.config_pod_mode)
|
@@ -68,7 +96,7 @@ module KZ
|
|
68
96
|
end
|
69
97
|
|
70
98
|
def get_real_config_pod_mode(kz_pod_target)
|
71
|
-
if
|
99
|
+
if specify_pod_names_contain(kz_pod_target.name)
|
72
100
|
return KZGlobalHelper.instance.specify_pod_mode
|
73
101
|
end
|
74
102
|
:kz_pod_origin_mode
|
@@ -76,11 +104,26 @@ module KZ
|
|
76
104
|
|
77
105
|
def get_use_config_pod_mode(kz_pod_target)
|
78
106
|
if KZGlobalHelper.instance.specify_pod_mode == :kz_pod_framework_mode
|
79
|
-
|
107
|
+
specify_pod_names_contain(kz_pod_target.name) ? :kz_pod_framework_mode : :kz_pod_code_mode
|
80
108
|
elsif KZGlobalHelper.instance.specify_pod_mode == :kz_pod_code_mode
|
81
|
-
|
109
|
+
specify_pod_names_contain(kz_pod_target.name) ? :kz_pod_code_mode : :kz_pod_framework_mode
|
82
110
|
end
|
83
111
|
end
|
84
112
|
|
113
|
+
def specify_pod_names_contain(target_name)
|
114
|
+
if KZGlobalHelper.instance.specify_pod_names.count > 0
|
115
|
+
KZGlobalHelper.instance.specify_pod_names.each do |specify_pod_name|
|
116
|
+
if specify_pod_name.end_with?("*")
|
117
|
+
_specify_pod_name = specify_pod_name.sub('*', '')
|
118
|
+
return true if target_name.start_with?(_specify_pod_name)
|
119
|
+
else
|
120
|
+
return true if specify_pod_name == target_name
|
121
|
+
end
|
122
|
+
end
|
123
|
+
false
|
124
|
+
else
|
125
|
+
true
|
126
|
+
end
|
127
|
+
end
|
85
128
|
end
|
86
129
|
end
|
@@ -0,0 +1,256 @@
|
|
1
|
+
require 'xcodeproj'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
module KZ
|
5
|
+
class HmapContentStyle
|
6
|
+
QUOTES_PRIVATE = 1
|
7
|
+
QUOTES_REPAIR = 2
|
8
|
+
end
|
9
|
+
|
10
|
+
class KZGenerator
|
11
|
+
|
12
|
+
def initialize(main_project)
|
13
|
+
@all_kz_pod_targets = KZGlobalHelper.instance.kz_analyzer.all_kz_pod_targets
|
14
|
+
@main_project = main_project
|
15
|
+
end
|
16
|
+
|
17
|
+
def add_framework_generator_build_phase(native_target)
|
18
|
+
return if KZ::KZGlobalHelper.instance.disable_generate_framework
|
19
|
+
|
20
|
+
build_phase = native_target.new_shell_script_build_phase('[KZ] Generate Framework')
|
21
|
+
build_phase.show_env_vars_in_log = '0'
|
22
|
+
build_phase.output_paths = ['${KZ_FRAMEWORK_CACHE_PATH}/${FULL_PRODUCT_NAME}']
|
23
|
+
build_phase.shell_script = %q{
|
24
|
+
if [ "${MACH_O_TYPE}" != "staticlib" ]; then
|
25
|
+
exit 0
|
26
|
+
fi
|
27
|
+
|
28
|
+
PRODUCT_DIR=${PODS_BUILD_DIR}/Debug-iphoneos/${TARGET_NAME}/${FULL_PRODUCT_NAME}
|
29
|
+
PRODUCT_SIMULATOR_DIR=${PODS_BUILD_DIR}/Debug-iphonesimulator/${TARGET_NAME}/${FULL_PRODUCT_NAME}
|
30
|
+
CURRENT_PRODUCT_DIR=${PODS_CONFIGURATION_BUILD_DIR}/${TARGET_NAME}
|
31
|
+
|
32
|
+
if [ -d "${KZ_FRAMEWORK_CACHE_PATH}" ]; then
|
33
|
+
rm -r "${KZ_FRAMEWORK_CACHE_PATH}"
|
34
|
+
fi
|
35
|
+
mkdir -p "${KZ_FRAMEWORK_CACHE_PATH}"
|
36
|
+
|
37
|
+
if [ -d "${KZ_FRAMEWORK_CACHE_PATH}/${FULL_PRODUCT_NAME}" ]; then
|
38
|
+
rm -r "${KZ_FRAMEWORK_CACHE_PATH}/${FULL_PRODUCT_NAME}"
|
39
|
+
fi
|
40
|
+
cp -r ${CURRENT_PRODUCT_DIR}/${FULL_PRODUCT_NAME} "${KZ_FRAMEWORK_CACHE_PATH}"
|
41
|
+
|
42
|
+
find "${CURRENT_PRODUCT_DIR}" -iname "*.bundle" | while read -r BUNDLE_FILE; do
|
43
|
+
BUNDLE_NAME=$(basename ${BUNDLE_FILE})
|
44
|
+
if [ -d "${KZ_FRAMEWORK_CACHE_PATH}/${BUNDLE_NAME}" ]; then
|
45
|
+
rm -r "${KZ_FRAMEWORK_CACHE_PATH}/${BUNDLE_NAME}"
|
46
|
+
fi
|
47
|
+
cp -r ${BUNDLE_FILE} "${KZ_FRAMEWORK_CACHE_PATH}"
|
48
|
+
done
|
49
|
+
|
50
|
+
if [ -f ${PRODUCT_DIR}/${PRODUCT_NAME} ] && [ -f ${PRODUCT_SIMULATOR_DIR}/${PRODUCT_NAME} ]; then
|
51
|
+
lipo -create ${PRODUCT_DIR}/${PRODUCT_NAME} ${PRODUCT_SIMULATOR_DIR}/${PRODUCT_NAME} -output "${KZ_FRAMEWORK_CACHE_PATH}/${PRODUCT_NAME}.framework/${PRODUCT_NAME}"
|
52
|
+
fi
|
53
|
+
}
|
54
|
+
end
|
55
|
+
|
56
|
+
def add_flexlib_xml_build_rules(project, native_target)
|
57
|
+
return unless KZ::KZGlobalHelper.instance.have_flexLib_pod_target
|
58
|
+
|
59
|
+
native_target.build_configurations.each do |config|
|
60
|
+
config.build_settings["KZ_XML_FLEX_COMPILER"] = FLEX_COMPLIER_PATH.to_s
|
61
|
+
config.build_settings["KZ_XML_FLEX_DIR"] = "${TARGET_TEMP_DIR}/XmlFlexs"
|
62
|
+
config.build_settings["KZ_XML_FLEX_BUILD_DIR"] = "${TARGET_BUILD_DIR}/${PRODUCT_NAME}.bundle"
|
63
|
+
end
|
64
|
+
|
65
|
+
xml_rule = new_build_rule(project, native_target, '[KZ] Custom Xml Build')
|
66
|
+
xml_rule.file_type = 'text.xml'
|
67
|
+
xml_rule.output_files = Array['${KZ_XML_FLEX_DIR}/${INPUT_FILE_BASE}.flex']
|
68
|
+
xml_rule.script = %Q{FLEX_PATH=${KZ_XML_FLEX_DIR}/${INPUT_FILE_BASE}.flex
|
69
|
+
rm -rf ${FLEX_PATH}
|
70
|
+
$KZ_XML_FLEX_COMPILER $INPUT_FILE_PATH $FLEX_PATH
|
71
|
+
if [ -f $FLEX_PATH ] ; then
|
72
|
+
cp $FLEX_PATH $KZ_XML_FLEX_BUILD_DIR
|
73
|
+
exit 0
|
74
|
+
else
|
75
|
+
exit 1
|
76
|
+
fi}
|
77
|
+
end
|
78
|
+
|
79
|
+
def new_build_rule(project, native_target, name)
|
80
|
+
new_rule = nil
|
81
|
+
native_target.build_rules.each do |build_rule|
|
82
|
+
new_rule = build_rule if build_rule.name == name
|
83
|
+
end
|
84
|
+
|
85
|
+
if new_rule == nil
|
86
|
+
new_rule = project.new(Xcodeproj::Project::PBXBuildRule)
|
87
|
+
native_target.build_rules << new_rule
|
88
|
+
end
|
89
|
+
|
90
|
+
new_rule.name = name
|
91
|
+
new_rule.compiler_spec = 'com.apple.compilers.proxy.script'
|
92
|
+
new_rule
|
93
|
+
end
|
94
|
+
|
95
|
+
def create_hamp
|
96
|
+
# 创建壳工程hmap
|
97
|
+
main_sources_path = @main_project.project_dir + @main_project.root_object.display_name
|
98
|
+
private_hmap_hash = {}
|
99
|
+
traverse_folder(main_sources_path) do |header_path|
|
100
|
+
header_pathname = Pathname.new(header_path)
|
101
|
+
header_pathname_basename = header_pathname.basename.to_s
|
102
|
+
|
103
|
+
header_hmap_value = {}
|
104
|
+
header_hmap_value['suffix'] = header_pathname_basename
|
105
|
+
header_hmap_value['prefix'] = header_pathname.dirname.to_s + '/'
|
106
|
+
|
107
|
+
private_hmap_hash[header_pathname_basename] = header_hmap_value
|
108
|
+
end
|
109
|
+
|
110
|
+
unless private_hmap_hash.empty?
|
111
|
+
save_hmap_file(private_hmap_hash, KZ_POD_CONFIG_ROOT, @main_project.root_object.display_name)
|
112
|
+
end
|
113
|
+
|
114
|
+
# 创建pod hmap
|
115
|
+
@all_kz_pod_targets.each do |target_name, kz_pod_target|
|
116
|
+
clean_hmap_cache(kz_pod_target)
|
117
|
+
|
118
|
+
# 修复头文件导入方式
|
119
|
+
all_repair_hmap_info = {}
|
120
|
+
need_repair_import_targets = kz_pod_target.repair_import
|
121
|
+
if need_repair_import_targets.count > 0
|
122
|
+
need_repair_import_targets.each { |need_repair_import_target|
|
123
|
+
repair_hmap_info = get_hmap_info_from(need_repair_import_target, HmapContentStyle::QUOTES_REPAIR)
|
124
|
+
all_repair_hmap_info.merge!(repair_hmap_info)
|
125
|
+
}
|
126
|
+
end
|
127
|
+
|
128
|
+
kz_pod_target.recursive_dependent_targets.each do |recursive_dependent_target|
|
129
|
+
if recursive_dependent_target.need_repair_module_import
|
130
|
+
header_paths = recursive_dependent_target.public_headers
|
131
|
+
header_paths.each do |header_pathname|
|
132
|
+
header_pathname_basename = header_pathname.basename.to_s
|
133
|
+
|
134
|
+
header_hmap_value_quotes = {}
|
135
|
+
header_hmap_value_quotes['suffix'] = header_pathname_basename
|
136
|
+
header_hmap_value_quotes['prefix'] = recursive_dependent_target.product_basename + '/'
|
137
|
+
all_repair_hmap_info["#{recursive_dependent_target.root_name}/#{header_pathname_basename}"] = header_hmap_value_quotes
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
if all_repair_hmap_info.count > 0
|
143
|
+
hmap_cache_path = kz_pod_target.pod_config_cache_path(false)
|
144
|
+
save_hmap_file(all_repair_hmap_info, hmap_cache_path, target_name + '_repair')
|
145
|
+
kz_pod_target.repair_header_search_path = hmap_cache_path + "#{target_name}_repair.hmap"
|
146
|
+
end
|
147
|
+
|
148
|
+
# 添加私有头文件引用
|
149
|
+
if kz_pod_target.should_build?
|
150
|
+
private_hamp_info = get_hmap_info_from(kz_pod_target, HmapContentStyle::QUOTES_PRIVATE)
|
151
|
+
if private_hamp_info.count > 0
|
152
|
+
hmap_cache_path = kz_pod_target.pod_config_cache_path(false)
|
153
|
+
save_hmap_file(private_hamp_info, hmap_cache_path, target_name)
|
154
|
+
kz_pod_target.private_header_search_path = hmap_cache_path + "#{target_name}.hmap"
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
def traverse_folder(folder_path)
|
161
|
+
Dir.foreach(folder_path) do |file_name|
|
162
|
+
next if file_name == '.' || file_name == '..'
|
163
|
+
|
164
|
+
file_path = File.join(folder_path, file_name)
|
165
|
+
if File.file?(file_path)
|
166
|
+
yield(file_path) if file_name.end_with?('.h')
|
167
|
+
elsif File.directory?(file_path)
|
168
|
+
traverse_folder(file_path) do |path|
|
169
|
+
yield(path)
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
def clean_hmap_cache(kz_pod_target)
|
176
|
+
hmap_cache_path = kz_pod_target.pod_config_cache_path(false)
|
177
|
+
Dir.foreach(hmap_cache_path) do |file_name|
|
178
|
+
next if file_name == '.' || file_name == '..'
|
179
|
+
|
180
|
+
if file_name.end_with?(".hmap", ".json")
|
181
|
+
FileUtils.rm(hmap_cache_path + file_name) if File.exist?(hmap_cache_path + file_name)
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
def get_hmap_info_from(kz_pod_target, hmap_content_style)
|
187
|
+
header_paths = kz_pod_target.public_headers
|
188
|
+
header_paths = kz_pod_target.all_headers if hmap_content_style == HmapContentStyle::QUOTES_PRIVATE
|
189
|
+
hmap_info = {}
|
190
|
+
header_paths.each do |header_pathname|
|
191
|
+
header_pathname_basename = header_pathname.basename.to_s
|
192
|
+
|
193
|
+
header_hmap_value_quotes = {}
|
194
|
+
header_hmap_value_quotes['suffix'] = header_pathname_basename
|
195
|
+
header_hmap_value_quotes['prefix'] = header_pathname.dirname.to_s + '/'
|
196
|
+
hmap_info[header_pathname_basename] = header_hmap_value_quotes
|
197
|
+
|
198
|
+
if hmap_content_style == HmapContentStyle::QUOTES_PRIVATE
|
199
|
+
# pch
|
200
|
+
pchfile_path = kz_pod_target.prefix_header_path
|
201
|
+
if pchfile_path.exist?
|
202
|
+
suffix = pchfile_path.basename.to_s
|
203
|
+
hmap_info[suffix] = { 'suffix' => suffix, 'prefix' => "#{pchfile_path.dirname.to_s}/" }
|
204
|
+
end
|
205
|
+
|
206
|
+
unless kz_pod_target.is_dev_pod
|
207
|
+
# 各别第三方在使用自己组件文件时,会使用#import <xx/xx.h>的方式
|
208
|
+
hmap_info[kz_pod_target.name + '/' + header_pathname_basename] = header_hmap_value_quotes
|
209
|
+
end
|
210
|
+
|
211
|
+
if kz_pod_target.uses_swift && kz_pod_target.is_dev_pod
|
212
|
+
# 修改SPBoss-Swift.h文件的导入方式
|
213
|
+
swift_bridge_file_name = "#{kz_pod_target.name}-Swift.h"
|
214
|
+
hmap_info[swift_bridge_file_name] = { 'suffix' => swift_bridge_file_name, 'prefix' => "#{kz_pod_target.name}/" }
|
215
|
+
|
216
|
+
# 以SPBoss为例,在混编模式中,SPBoss-Swift.h会使用#import <SPBoss/SPBoss.h>方式导入swift需要使用的OC头文件
|
217
|
+
# SPBoss中头文件会存在当前组件与framework的Headers中,有两份。SPBoss-Swift.h只在framework中
|
218
|
+
# 编译默认从SPBoss-Swift.h找SPBoss.h,然后找SPBoss.h中的头文件也都会在framework中寻在,会造成与当前组件头文件重复
|
219
|
+
# 需要重新将#import <SPBoss/SPBoss.h>方式修复为寻找当前组件中的SPBoss.h文件,而不是framework中的SPBoss.h
|
220
|
+
if header_pathname_basename == "#{kz_pod_target.name}.h"
|
221
|
+
hmap_info[kz_pod_target.name + '/' + header_pathname_basename] = header_hmap_value_quotes
|
222
|
+
end
|
223
|
+
end
|
224
|
+
elsif hmap_content_style == HmapContentStyle::QUOTES_REPAIR
|
225
|
+
header_hmap_value_slash = {}
|
226
|
+
header_hmap_value_slash['suffix'] = header_pathname_basename
|
227
|
+
prefix_name = kz_pod_target.name
|
228
|
+
if header_pathname.dirname.to_s.include?('.framework')
|
229
|
+
header_pathname.dirname.to_s.split('/').each do |name|
|
230
|
+
if name.include?('.framework')
|
231
|
+
prefix_name = name.split('.').first
|
232
|
+
end
|
233
|
+
end
|
234
|
+
end
|
235
|
+
header_hmap_value_slash['prefix'] = prefix_name + '/'
|
236
|
+
hmap_info[header_pathname_basename] = header_hmap_value_slash
|
237
|
+
end
|
238
|
+
end
|
239
|
+
hmap_info
|
240
|
+
end
|
241
|
+
|
242
|
+
def save_hmap_file(hmap_hash, save_path, file_name)
|
243
|
+
hmap_json = JSON.pretty_generate(hmap_hash)
|
244
|
+
hmap_json_path = save_path + "#{file_name}.json"
|
245
|
+
hmap_path = save_path + "#{file_name}.hmap"
|
246
|
+
json_file = File.new(hmap_json_path, 'w')
|
247
|
+
return unless json_file
|
248
|
+
|
249
|
+
json_file.syswrite(hmap_json)
|
250
|
+
system "#{HMAP_EXECUTE_PATH} convert #{hmap_json_path} #{hmap_path}"
|
251
|
+
|
252
|
+
FileUtils.rm(hmap_json_path) unless KZ::KZGlobalHelper.instance.debug
|
253
|
+
end
|
254
|
+
|
255
|
+
end
|
256
|
+
end
|
@@ -0,0 +1,127 @@
|
|
1
|
+
require 'cocoapods'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'json'
|
4
|
+
require_relative 'kz_analyzer'
|
5
|
+
require_relative 'kz_framework_manager'
|
6
|
+
require_relative 'kz_config_result'
|
7
|
+
require_relative 'kz_pod_target'
|
8
|
+
|
9
|
+
module KZ
|
10
|
+
KZ_POD_CONFIG_ROOT = Pod::Config.instance.installation_root + 'Pods/KZPodConfigure'
|
11
|
+
KZ_POD_CONFIG_ROOT_STR = "${PODS_ROOT}/KZPodConfigure"
|
12
|
+
# 修复pod lib报错问题
|
13
|
+
Pod::Config.instance.installation_root = nil
|
14
|
+
|
15
|
+
HMAP_EXECUTE_PATH = File.dirname(__FILE__) + '/../resources/hmap'
|
16
|
+
FLEX_COMPLIER_PATH = KZ_POD_CONFIG_ROOT + 'FlexCompiler'
|
17
|
+
KZ_LOCK_FILE_PATH = KZ_POD_CONFIG_ROOT + 'KZConfigLock'
|
18
|
+
|
19
|
+
def self.deal_path_for_xcconfig(path, add_quotes = false)
|
20
|
+
if path.is_a?(String)
|
21
|
+
path_str = path.sub(KZ::KZ_POD_CONFIG_ROOT.to_s, KZ::KZ_POD_CONFIG_ROOT_STR)
|
22
|
+
path_str = ('"' + path_str + '"') if add_quotes
|
23
|
+
return path_str
|
24
|
+
elsif path.is_a?(Pathname)
|
25
|
+
path_str = path.to_s.sub(KZ::KZ_POD_CONFIG_ROOT.to_s, KZ::KZ_POD_CONFIG_ROOT_STR)
|
26
|
+
path_str = ('"' + path_str + '"') if add_quotes
|
27
|
+
return path_str
|
28
|
+
end
|
29
|
+
path
|
30
|
+
end
|
31
|
+
|
32
|
+
class KZGlobalHelper
|
33
|
+
attr_accessor :kz_pod_enable
|
34
|
+
attr_accessor :kz_pod_config
|
35
|
+
attr_accessor :kz_analyzer
|
36
|
+
attr_accessor :kz_generator
|
37
|
+
attr_accessor :specify_pod_names
|
38
|
+
attr_accessor :specify_pod_mode
|
39
|
+
attr_accessor :debug
|
40
|
+
attr_accessor :kz_config_lock
|
41
|
+
attr_accessor :disable_generate_framework
|
42
|
+
attr_accessor :generate_kz_pod_targets
|
43
|
+
|
44
|
+
private_class_method :new
|
45
|
+
|
46
|
+
def initialize
|
47
|
+
@kz_pod_enable = false
|
48
|
+
@specify_pod_mode = :kz_pod_origin_mode
|
49
|
+
@pods_config_cache = {}
|
50
|
+
@debug = false
|
51
|
+
@kz_config_lock = {}
|
52
|
+
@disable_generate_framework = false
|
53
|
+
@generate_kz_pod_targets = false
|
54
|
+
end
|
55
|
+
|
56
|
+
@@instance = nil
|
57
|
+
def self.instance
|
58
|
+
@@instance ||= new
|
59
|
+
end
|
60
|
+
|
61
|
+
def prepare
|
62
|
+
FileUtils.rm(KZ_LOCK_FILE_PATH) if File.exist?(KZ_LOCK_FILE_PATH)
|
63
|
+
FileUtils.mkdir_p(KZ_POD_CONFIG_ROOT) unless File.exist?(KZ_POD_CONFIG_ROOT)
|
64
|
+
|
65
|
+
flex_compiler_de_path = KZ_POD_CONFIG_ROOT + 'FlexCompiler'
|
66
|
+
FileUtils.rm(flex_compiler_de_path) if File.exist?(flex_compiler_de_path)
|
67
|
+
FileUtils.cp_r(File.dirname(__FILE__) + '/../resources/FlexCompiler', KZ_POD_CONFIG_ROOT)
|
68
|
+
system("chmod +x #{flex_compiler_de_path}")
|
69
|
+
|
70
|
+
Pod::Config.instance.podfile.use_frameworks!(:linkage => :static) if Pod::Config.instance.podfile
|
71
|
+
end
|
72
|
+
|
73
|
+
def analyze_special_parameters(use_code_tag, use_framework_tag, pod_names)
|
74
|
+
specify_pod_names = []
|
75
|
+
if pod_names.count > 0
|
76
|
+
pod_names.each do |param|
|
77
|
+
if param.include?(',')
|
78
|
+
specify_pod_names.concat(param.split(","))
|
79
|
+
else
|
80
|
+
specify_pod_names << param
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
@specify_pod_names = specify_pod_names
|
85
|
+
if use_code_tag
|
86
|
+
@specify_pod_mode = :kz_pod_code_mode
|
87
|
+
elsif use_framework_tag
|
88
|
+
@specify_pod_mode = :kz_pod_framework_mode
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def pod_config_result_with_target(kz_pod_target)
|
93
|
+
return nil unless @kz_pod_enable
|
94
|
+
return nil unless kz_pod_target && kz_pod_target.config_pod_mode == :kz_pod_framework_mode
|
95
|
+
|
96
|
+
return @pods_config_cache[kz_pod_target.name] if @pods_config_cache.has_key?(kz_pod_target.name)
|
97
|
+
|
98
|
+
result = KZFrameworkManager.validate_framework_and_get_result(kz_pod_target)
|
99
|
+
|
100
|
+
@pods_config_cache[kz_pod_target.name] = result if result
|
101
|
+
result
|
102
|
+
end
|
103
|
+
|
104
|
+
def have_flexLib_pod_target
|
105
|
+
@kz_analyzer.kz_pod_targets_with("FlexLib").count > 0
|
106
|
+
end
|
107
|
+
|
108
|
+
def write_lock_file
|
109
|
+
self.kz_analyzer.all_kz_pod_targets.values.each do |kz_pod_target|
|
110
|
+
result = pod_config_result_with_target(kz_pod_target)
|
111
|
+
|
112
|
+
@kz_config_lock[kz_pod_target.name] ||= {}
|
113
|
+
@kz_config_lock[kz_pod_target.name]["dev_pod"] = kz_pod_target.is_dev_pod
|
114
|
+
@kz_config_lock[kz_pod_target.name]["use_framework"] = (result != nil)
|
115
|
+
@kz_config_lock[kz_pod_target.name]["version"] = kz_pod_target.version
|
116
|
+
end
|
117
|
+
|
118
|
+
if @kz_config_lock.count > 0
|
119
|
+
lock_file_content = JSON.pretty_generate(@kz_config_lock)
|
120
|
+
File.open(KZ_LOCK_FILE_PATH, 'w') do |file|
|
121
|
+
file.write(lock_file_content)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
end
|
127
|
+
end
|