cocoapods-meitu-bin 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +20 -0
- data/README.md +56 -0
- data/lib/cocoapods-meitu-bin/command/bin/archive.rb +206 -0
- data/lib/cocoapods-meitu-bin/command/bin/auto.rb +212 -0
- data/lib/cocoapods-meitu-bin/command/bin/build_all.rb +345 -0
- data/lib/cocoapods-meitu-bin/command/bin/header_files_specifications.rb +262 -0
- data/lib/cocoapods-meitu-bin/command/bin/init.rb +72 -0
- data/lib/cocoapods-meitu-bin/command/bin/install.rb +44 -0
- data/lib/cocoapods-meitu-bin/command/bin/lib/lint.rb +67 -0
- data/lib/cocoapods-meitu-bin/command/bin/lock/dependency.rb +89 -0
- data/lib/cocoapods-meitu-bin/command/bin/lock/spec_repo.rb +105 -0
- data/lib/cocoapods-meitu-bin/command/bin/lock/version.rb +68 -0
- data/lib/cocoapods-meitu-bin/command/bin/lock.rb +36 -0
- data/lib/cocoapods-meitu-bin/command/bin/output_source.rb +146 -0
- data/lib/cocoapods-meitu-bin/command/bin/repo/push.rb +88 -0
- data/lib/cocoapods-meitu-bin/command/bin/repo/update.rb +42 -0
- data/lib/cocoapods-meitu-bin/command/bin/repo.rb +14 -0
- data/lib/cocoapods-meitu-bin/command/bin/source/add.rb +148 -0
- data/lib/cocoapods-meitu-bin/command/bin/source/delete.rb +59 -0
- data/lib/cocoapods-meitu-bin/command/bin/source/list.rb +46 -0
- data/lib/cocoapods-meitu-bin/command/bin/source.rb +30 -0
- data/lib/cocoapods-meitu-bin/command/bin/spec/create.rb +73 -0
- data/lib/cocoapods-meitu-bin/command/bin/spec/lint.rb +109 -0
- data/lib/cocoapods-meitu-bin/command/bin/spec.rb +13 -0
- data/lib/cocoapods-meitu-bin/command/bin/update.rb +154 -0
- data/lib/cocoapods-meitu-bin/command/bin/upload.rb +175 -0
- data/lib/cocoapods-meitu-bin/command/bin.rb +69 -0
- data/lib/cocoapods-meitu-bin/command.rb +1 -0
- data/lib/cocoapods-meitu-bin/config/config.rb +149 -0
- data/lib/cocoapods-meitu-bin/config/config_asker.rb +57 -0
- data/lib/cocoapods-meitu-bin/config/config_builder.rb +216 -0
- data/lib/cocoapods-meitu-bin/gem_version.rb +9 -0
- data/lib/cocoapods-meitu-bin/helpers/Info.plist +0 -0
- data/lib/cocoapods-meitu-bin/helpers/buildAll/bin_helper.rb +97 -0
- data/lib/cocoapods-meitu-bin/helpers/buildAll/builder.rb +434 -0
- data/lib/cocoapods-meitu-bin/helpers/buildAll/podspec_util.rb +140 -0
- data/lib/cocoapods-meitu-bin/helpers/buildAll/zip_file_helper.rb +87 -0
- data/lib/cocoapods-meitu-bin/helpers/build_helper.rb +167 -0
- data/lib/cocoapods-meitu-bin/helpers/build_utils.rb +64 -0
- data/lib/cocoapods-meitu-bin/helpers/framework.rb +86 -0
- data/lib/cocoapods-meitu-bin/helpers/framework_builder.rb +551 -0
- data/lib/cocoapods-meitu-bin/helpers/library.rb +54 -0
- data/lib/cocoapods-meitu-bin/helpers/library_builder.rb +90 -0
- data/lib/cocoapods-meitu-bin/helpers/pod_size_helper.rb +54 -0
- data/lib/cocoapods-meitu-bin/helpers/sources_helper.rb +35 -0
- data/lib/cocoapods-meitu-bin/helpers/spec_creator.rb +170 -0
- data/lib/cocoapods-meitu-bin/helpers/spec_files_helper.rb +80 -0
- data/lib/cocoapods-meitu-bin/helpers/spec_source_creator.rb +304 -0
- data/lib/cocoapods-meitu-bin/helpers/upload_helper.rb +104 -0
- data/lib/cocoapods-meitu-bin/helpers.rb +5 -0
- data/lib/cocoapods-meitu-bin/native/acknowledgements.rb +27 -0
- data/lib/cocoapods-meitu-bin/native/analyzer.rb +109 -0
- data/lib/cocoapods-meitu-bin/native/file_accessor.rb +28 -0
- data/lib/cocoapods-meitu-bin/native/gen.rb +79 -0
- data/lib/cocoapods-meitu-bin/native/installation_options.rb +28 -0
- data/lib/cocoapods-meitu-bin/native/installer.rb +259 -0
- data/lib/cocoapods-meitu-bin/native/linter.rb +26 -0
- data/lib/cocoapods-meitu-bin/native/lockfile.rb +85 -0
- data/lib/cocoapods-meitu-bin/native/path_source.rb +33 -0
- data/lib/cocoapods-meitu-bin/native/pod_source_installer.rb +19 -0
- data/lib/cocoapods-meitu-bin/native/pod_target_installer.rb +87 -0
- data/lib/cocoapods-meitu-bin/native/podfile.rb +99 -0
- data/lib/cocoapods-meitu-bin/native/podfile_env.rb +38 -0
- data/lib/cocoapods-meitu-bin/native/podfile_generator.rb +201 -0
- data/lib/cocoapods-meitu-bin/native/podspec_finder.rb +25 -0
- data/lib/cocoapods-meitu-bin/native/resolver.rb +299 -0
- data/lib/cocoapods-meitu-bin/native/sandbox_analyzer.rb +34 -0
- data/lib/cocoapods-meitu-bin/native/source.rb +35 -0
- data/lib/cocoapods-meitu-bin/native/sources_manager.rb +21 -0
- data/lib/cocoapods-meitu-bin/native/specification.rb +31 -0
- data/lib/cocoapods-meitu-bin/native/target_validator.rb +41 -0
- data/lib/cocoapods-meitu-bin/native/validator.rb +40 -0
- data/lib/cocoapods-meitu-bin/native.rb +26 -0
- data/lib/cocoapods-meitu-bin/source_provider_hook.rb +68 -0
- data/lib/cocoapods-meitu-bin.rb +2 -0
- data/lib/cocoapods_plugin.rb +11 -0
- data/spec/command/bin_spec.rb +12 -0
- data/spec/spec_helper.rb +50 -0
- metadata +201 -0
@@ -0,0 +1,85 @@
|
|
1
|
+
module Pod
|
2
|
+
class Lockfile
|
3
|
+
def detect_changes_with_podfile(podfile)
|
4
|
+
result = {}
|
5
|
+
[:added, :changed, :removed, :unchanged].each { |k| result[k] = [] }
|
6
|
+
|
7
|
+
installed_deps = {}
|
8
|
+
dependencies.each do |dep|
|
9
|
+
name = dep.root_name
|
10
|
+
installed_deps[name] ||= dependencies_to_lock_pod_named(name)
|
11
|
+
end
|
12
|
+
|
13
|
+
installed_deps = installed_deps.values.flatten(1).group_by(&:name)
|
14
|
+
|
15
|
+
podfile_dependencies = podfile.dependencies
|
16
|
+
podfile_dependencies_by_name = podfile_dependencies.group_by(&:name)
|
17
|
+
|
18
|
+
all_dep_names = (dependencies + podfile_dependencies).map(&:name).uniq
|
19
|
+
all_dep_names.each do |name|
|
20
|
+
installed_dep = installed_deps[name]
|
21
|
+
installed_dep &&= installed_dep.first
|
22
|
+
|
23
|
+
# 需要将二进制版本的 specific_version 最后一位去掉,否则二进制下依赖解析很慢
|
24
|
+
unless installed_dep.nil?
|
25
|
+
installed_dep_version = installed_dep.specific_version.to_s
|
26
|
+
if installed_dep_version.include?('bin')
|
27
|
+
req_arr = installed_dep_version.split('.').delete_if { |r| r.include?('bin') }
|
28
|
+
installed_dep_version = req_arr.join('.')
|
29
|
+
installed_dep.specific_version = Pod::Version.create(installed_dep_version)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
podfile_dep = podfile_dependencies_by_name[name]
|
34
|
+
podfile_dep &&= podfile_dep.first
|
35
|
+
|
36
|
+
if installed_dep.nil? then key = :added
|
37
|
+
elsif podfile_dep.nil? then key = :removed
|
38
|
+
elsif podfile_dep.compatible?(installed_dep) then key = :unchanged
|
39
|
+
else key = :changed
|
40
|
+
end
|
41
|
+
result[key] << name
|
42
|
+
end
|
43
|
+
result
|
44
|
+
end
|
45
|
+
|
46
|
+
class << self
|
47
|
+
def generate(podfile, specs, checkout_options, spec_repos = {})
|
48
|
+
hash = {
|
49
|
+
'PODS' => generate_pods_data(specs),
|
50
|
+
'DEPENDENCIES' => generate_dependencies_data(podfile),
|
51
|
+
'SPEC REPOS' => generate_spec_repos(spec_repos),
|
52
|
+
'EXTERNAL SOURCES' => generate_external_sources_data(podfile),
|
53
|
+
'CHECKOUT OPTIONS' => checkout_options,
|
54
|
+
'SPEC CHECKSUMS' => generate_checksums(specs),
|
55
|
+
'PODFILE CHECKSUM' => podfile.checksum,
|
56
|
+
'USE BINARY' => "#{podfile.use_binaries?}",
|
57
|
+
'CONFIGURATION' => ENV['configuration'] || podfile.configuration,
|
58
|
+
'COCOAPODS' => CORE_VERSION,
|
59
|
+
}
|
60
|
+
Lockfile.new(hash)
|
61
|
+
end
|
62
|
+
|
63
|
+
def generate_spec_repos(spec_repos)
|
64
|
+
result = Hash.new
|
65
|
+
spec_repos.map do |source, specs|
|
66
|
+
next unless source
|
67
|
+
next if specs.empty?
|
68
|
+
key = source.url || source.name
|
69
|
+
|
70
|
+
# save `trunk` as 'trunk' so that the URL itself can be changed without lockfile churn
|
71
|
+
key = Pod::TrunkSource::TRUNK_REPO_NAME if source.name == Pod::TrunkSource::TRUNK_REPO_NAME
|
72
|
+
|
73
|
+
value = specs.map { |s| s.root.name }.uniq
|
74
|
+
# 合并重复的source源,而不是替换
|
75
|
+
if result[key].nil?
|
76
|
+
result[key] = YAMLHelper.sorted_array(value)
|
77
|
+
else
|
78
|
+
result[key] = YAMLHelper.sorted_array(result[key].concat(value))
|
79
|
+
end
|
80
|
+
end
|
81
|
+
result.compact
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
require 'cocoapods-meitu-bin/native/specification'
|
4
|
+
|
5
|
+
module Pod
|
6
|
+
module ExternalSources
|
7
|
+
# Provides support for fetching a specification file from a path local to
|
8
|
+
# the machine running the installation.
|
9
|
+
#
|
10
|
+
class PathSource < AbstractExternalSource
|
11
|
+
def normalized_podspec_path(declared_path)
|
12
|
+
extension = File.extname(declared_path)
|
13
|
+
|
14
|
+
if extension == '.podspec' || extension == '.json'
|
15
|
+
path_with_ext = declared_path
|
16
|
+
else
|
17
|
+
# 默认先从 binary podspec 找起,因为 binary podspec 的 subspec 可能比 code podspec 多
|
18
|
+
# 这里可能出现 code subspec 和 binary subspec 对应不上的情况,导致 lint 失败
|
19
|
+
# 所以不要在 code podspec 同一目录下保留 binary podspec
|
20
|
+
path_with_ext = Specification::VALID_EXTNAME
|
21
|
+
.map { |extname| "#{declared_path}/#{name}#{extname}" }
|
22
|
+
.find { |file| File.exist?(file) } || "#{declared_path}/#{name}.podspec"
|
23
|
+
end
|
24
|
+
|
25
|
+
UI.message "获取的 podspec 路径为 `#{path_with_ext}`"
|
26
|
+
|
27
|
+
podfile_dir = File.dirname(podfile_path || '')
|
28
|
+
|
29
|
+
File.expand_path(path_with_ext, podfile_dir)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
require 'cocoapods-meitu-bin/native/installation_options'
|
4
|
+
|
5
|
+
module Pod
|
6
|
+
class Installer
|
7
|
+
class PodSourceInstaller
|
8
|
+
attr_accessor :installation_options
|
9
|
+
|
10
|
+
alias old_verify_source_is_secure verify_source_is_secure
|
11
|
+
def verify_source_is_secure(root_spec)
|
12
|
+
# http source 默认不警告
|
13
|
+
if installation_options.warn_for_unsecure_source?
|
14
|
+
old_verify_source_is_secure(root_spec)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
module Pod
|
2
|
+
class Installer
|
3
|
+
class Xcode
|
4
|
+
class PodsProjectGenerator
|
5
|
+
# Creates the target for the Pods libraries in the Pods project and the
|
6
|
+
# relative support files.
|
7
|
+
#
|
8
|
+
class PodTargetInstaller < TargetInstaller
|
9
|
+
require 'cocoapods/installer/xcode/pods_project_generator/app_host_installer'
|
10
|
+
|
11
|
+
# Adds a shell script phase, intended only for library targets that contain swift,
|
12
|
+
# to copy the ObjC compatibility header (the -Swift.h file that the swift compiler generates)
|
13
|
+
# to the built products directory. Additionally, the script phase copies the module map, appending a `.Swift`
|
14
|
+
# submodule that references the (moved) compatibility header. Since the module map has been moved, the umbrella header
|
15
|
+
# is _also_ copied, so that it is sitting next to the module map. This is necessary for a successful archive build.
|
16
|
+
#
|
17
|
+
# @param [PBXNativeTarget] native_target
|
18
|
+
# the native target to add the Swift static library script phase into.
|
19
|
+
#
|
20
|
+
# @return [Void]
|
21
|
+
#
|
22
|
+
alias old_add_swift_library_compatibility_header_phase add_swift_library_compatibility_header_phase
|
23
|
+
|
24
|
+
def add_swift_library_compatibility_header_phase(native_target)
|
25
|
+
if $ARGV[1] == "auto"
|
26
|
+
if custom_module_map
|
27
|
+
raise Informative, 'Using Swift static libraries with custom module maps is currently not supported. ' \
|
28
|
+
"Please build `#{target.label}` as a framework or remove the custom module map."
|
29
|
+
end
|
30
|
+
|
31
|
+
build_phase = native_target.new_shell_script_build_phase('Copy generated compatibility header')
|
32
|
+
|
33
|
+
relative_module_map_path = target.module_map_path.relative_path_from(target.sandbox.root)
|
34
|
+
relative_umbrella_header_path = target.umbrella_header_path.relative_path_from(target.sandbox.root)
|
35
|
+
|
36
|
+
build_phase.shell_script = <<-SH.strip_heredoc
|
37
|
+
COMPATIBILITY_HEADER_PATH="${BUILT_PRODUCTS_DIR}/Swift Compatibility Header/${PRODUCT_MODULE_NAME}-Swift.h"
|
38
|
+
MODULE_MAP_PATH="${BUILT_PRODUCTS_DIR}/${PRODUCT_MODULE_NAME}.modulemap"
|
39
|
+
|
40
|
+
ditto "${DERIVED_SOURCES_DIR}/${PRODUCT_MODULE_NAME}-Swift.h" "${COMPATIBILITY_HEADER_PATH}"
|
41
|
+
ditto "${PODS_ROOT}/#{relative_module_map_path}" "${MODULE_MAP_PATH}"
|
42
|
+
ditto "${PODS_ROOT}/#{relative_umbrella_header_path}" "${BUILT_PRODUCTS_DIR}"
|
43
|
+
|
44
|
+
COPY_PATH="${PODS_CONFIGURATION_BUILD_DIR}/${PRODUCT_MODULE_NAME}"
|
45
|
+
UMBRELLA_PATH="${BUILT_PRODUCTS_DIR}/${PRODUCT_MODULE_NAME}-umbrella.h"
|
46
|
+
SWIFTMODULE_PATH="${BUILT_PRODUCTS_DIR}/${PRODUCT_MODULE_NAME}.swiftmodule"
|
47
|
+
|
48
|
+
ditto "${MODULE_MAP_PATH}" "${PODS_CONFIGURATION_BUILD_DIR}/${PRODUCT_MODULE_NAME}/${PRODUCT_MODULE_NAME}.modulemap"
|
49
|
+
ditto "${COMPATIBILITY_HEADER_PATH}" "${COPY_PATH}/Swift Compatibility Header/${PRODUCT_MODULE_NAME}-Swift.h"
|
50
|
+
ditto "${COMPATIBILITY_HEADER_PATH}" "${COPY_PATH}"
|
51
|
+
ditto "${UMBRELLA_PATH}" "${COPY_PATH}"
|
52
|
+
ditto "${SWIFTMODULE_PATH}" "${COPY_PATH}/${PRODUCT_MODULE_NAME}.swiftmodule"
|
53
|
+
ditto "${SWIFTMODULE_PATH}" "${COPY_PATH}/${PRODUCT_MODULE_NAME}.swiftmodule"
|
54
|
+
|
55
|
+
if [ ${PRODUCT_MODULE_NAME} != ${PRODUCT_NAME} ] ; then
|
56
|
+
ditto "${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}-umbrella.h" "${COPY_PATH}"
|
57
|
+
ditto "${COPY_PATH}" "${PODS_CONFIGURATION_BUILD_DIR}/${PRODUCT_NAME}"
|
58
|
+
fi
|
59
|
+
|
60
|
+
MODULE_MAP_SEARCH_PATH = "${PODS_CONFIGURATION_BUILD_DIR}/${PRODUCT_MODULE_NAME}/${PRODUCT_MODULE_NAME}.modulemap"
|
61
|
+
|
62
|
+
if [${MODULE_MAP_PATH} != ${MODULE_MAP_SEARCH_PATH}] ; then
|
63
|
+
printf "\\n\\nmodule ${PRODUCT_MODULE_NAME}.Swift {\\n header \\"${COPY_PATH}/Swift Compatibility Header/${PRODUCT_MODULE_NAME}-Swift.h\\"\\n requires objc\\n}\\n" >> "${MODULE_MAP_SEARCH_PATH}"
|
64
|
+
fi
|
65
|
+
|
66
|
+
printf "\\n\\nmodule ${PRODUCT_MODULE_NAME}.Swift {\\n header \\"${COMPATIBILITY_HEADER_PATH}\\"\\n requires objc\\n}\\n" >> "${MODULE_MAP_PATH}"
|
67
|
+
|
68
|
+
SH
|
69
|
+
build_phase.input_paths = %W(
|
70
|
+
${DERIVED_SOURCES_DIR}/${PRODUCT_MODULE_NAME}-Swift.h
|
71
|
+
${PODS_ROOT}/#{relative_module_map_path}
|
72
|
+
${PODS_ROOT}/#{relative_umbrella_header_path}
|
73
|
+
)
|
74
|
+
build_phase.output_paths = %W(
|
75
|
+
${BUILT_PRODUCTS_DIR}/${PRODUCT_MODULE_NAME}.modulemap
|
76
|
+
${BUILT_PRODUCTS_DIR}/#{relative_umbrella_header_path.basename}
|
77
|
+
${BUILT_PRODUCTS_DIR}/Swift\ Compatibility\ Header/${PRODUCT_MODULE_NAME}-Swift.h
|
78
|
+
)
|
79
|
+
else
|
80
|
+
old_add_swift_library_compatibility_header_phase(native_target)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
require 'cocoapods'
|
4
|
+
require 'cocoapods-meitu-bin/native/podfile_env'
|
5
|
+
|
6
|
+
module Pod
|
7
|
+
class Podfile
|
8
|
+
# TREAT_DEVELOPMENTS_AS_NORMAL = 'treat_developments_as_normal'.freeze
|
9
|
+
|
10
|
+
module DSL
|
11
|
+
def allow_prerelease!
|
12
|
+
set_internal_hash_value(ALLOW_PRERELEASE, true)
|
13
|
+
end
|
14
|
+
|
15
|
+
def use_binaries!(flag = true)
|
16
|
+
set_internal_hash_value(USE_BINARIES, flag)
|
17
|
+
end
|
18
|
+
|
19
|
+
def use_binaries_with_spec_selector!(&block)
|
20
|
+
raise Informative, '必须提供选择需要二进制组件的 block !' unless block_given?
|
21
|
+
|
22
|
+
set_internal_hash_value(USE_BINARIES_SELECTOR, block)
|
23
|
+
end
|
24
|
+
|
25
|
+
def set_use_source_pods(pods)
|
26
|
+
hash_pods_use_source = get_internal_hash_value(USE_SOURCE_PODS) || []
|
27
|
+
hash_pods_use_source += Array(pods)
|
28
|
+
set_internal_hash_value(USE_SOURCE_PODS, hash_pods_use_source)
|
29
|
+
end
|
30
|
+
|
31
|
+
def set_configuration(config = 'Debug')
|
32
|
+
set_internal_hash_value(CONFIGURATION, config)
|
33
|
+
end
|
34
|
+
|
35
|
+
# 0 dev
|
36
|
+
# 1 debug_iphoneos
|
37
|
+
# 2 release_iphoneos
|
38
|
+
# 需要在podfile_env 先定义 CONFIGURATION_ENV
|
39
|
+
def set_configuration_env(env = "dev")
|
40
|
+
set_internal_hash_value(CONFIGURATION_ENV, env)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
alias old_plugins plugins
|
45
|
+
def plugins
|
46
|
+
if ENV[USE_PLUGINS]
|
47
|
+
env_plugins = ENV[USE_PLUGINS].split(',').each_with_object({}) do |name, result|
|
48
|
+
result[name] = {}
|
49
|
+
end
|
50
|
+
env_plugins.merge!(old_plugins)
|
51
|
+
else
|
52
|
+
old_plugins
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def use_binaries_selector
|
57
|
+
get_internal_hash_value(USE_BINARIES_SELECTOR, nil)
|
58
|
+
end
|
59
|
+
|
60
|
+
def allow_prerelease?
|
61
|
+
get_internal_hash_value(ALLOW_PRERELEASE, false) || ENV[ALLOW_PRERELEASE] == 'true'
|
62
|
+
end
|
63
|
+
|
64
|
+
def use_binaries?
|
65
|
+
get_internal_hash_value(USE_BINARIES, false) || ENV[USE_BINARIES] == 'true'
|
66
|
+
end
|
67
|
+
|
68
|
+
def use_source_pods
|
69
|
+
get_internal_hash_value(USE_SOURCE_PODS, []) + String(ENV[USE_SOURCE_PODS]).split('|').uniq
|
70
|
+
end
|
71
|
+
|
72
|
+
def configuration_env
|
73
|
+
get_internal_hash_value(CONFIGURATION_ENV, "dev") || ENV[CONFIGURATION_ENV] == "dev"
|
74
|
+
end
|
75
|
+
|
76
|
+
def configuration
|
77
|
+
get_internal_hash_value(CONFIGURATION, "Debug")
|
78
|
+
end
|
79
|
+
|
80
|
+
private
|
81
|
+
|
82
|
+
def valid_bin_plugin
|
83
|
+
unless plugins.keys.include?('cocoapods-meitu-bin')
|
84
|
+
raise Pod::Informative, 'You should add `plugin \'cocoapods-meitu-bin\'` before using its DSL'
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
# set_hash_value 有 key 限制
|
89
|
+
def set_internal_hash_value(key, value)
|
90
|
+
valid_bin_plugin
|
91
|
+
|
92
|
+
internal_hash[key] = value
|
93
|
+
end
|
94
|
+
|
95
|
+
def get_internal_hash_value(key, default = nil)
|
96
|
+
internal_hash.fetch(key, default)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
class Podfile
|
5
|
+
USE_BINARIES = 'use_binaries'
|
6
|
+
USE_SOURCE_PODS = 'use_source_pods'
|
7
|
+
USE_BINARIES_SELECTOR = 'use_binaries_selector'
|
8
|
+
ALLOW_PRERELEASE = 'allow_prerelease'
|
9
|
+
USE_PLUGINS = 'use_plugins'
|
10
|
+
CONFIGURATION_ENV = 'configuration_env'
|
11
|
+
CONFIGURATION = 'configuration'
|
12
|
+
|
13
|
+
module ENVExecutor
|
14
|
+
def execute_with_bin_plugin(&block)
|
15
|
+
execute_with_key(USE_PLUGINS, -> { 'cocoapods-meitu-bin' }, &block)
|
16
|
+
end
|
17
|
+
|
18
|
+
def execute_with_allow_prerelease(allow_prerelease, &block)
|
19
|
+
execute_with_key(ALLOW_PRERELEASE, -> { allow_prerelease ? 'true' : 'false' }, &block)
|
20
|
+
end
|
21
|
+
|
22
|
+
def execute_with_use_binaries(use_binaries, &block)
|
23
|
+
execute_with_key(USE_BINARIES, -> { use_binaries ? 'true' : 'false' }, &block)
|
24
|
+
end
|
25
|
+
|
26
|
+
def execute_with_key(key, value_returner)
|
27
|
+
origin_value = ENV[key]
|
28
|
+
ENV[key] = value_returner.call
|
29
|
+
|
30
|
+
yield if block_given?
|
31
|
+
|
32
|
+
ENV[key] = origin_value
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
extend ENVExecutor
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,201 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
require 'parallel'
|
4
|
+
require 'cocoapods'
|
5
|
+
require 'cocoapods-meitu-bin/native/pod_source_installer'
|
6
|
+
|
7
|
+
|
8
|
+
require 'parallel'
|
9
|
+
require 'cocoapods'
|
10
|
+
|
11
|
+
module Pod
|
12
|
+
module Generate
|
13
|
+
# Generates podfiles for pod specifications given a configuration.
|
14
|
+
#
|
15
|
+
class PodfileGenerator
|
16
|
+
# @return [Podfile] a podfile suitable for installing the given spec
|
17
|
+
#
|
18
|
+
# @param [Specification] spec
|
19
|
+
#
|
20
|
+
alias old_podfile_for_spec podfile_for_spec
|
21
|
+
|
22
|
+
def podfile_for_spec(spec)
|
23
|
+
generator = self
|
24
|
+
dir = configuration.gen_dir_for_pod(spec.name)
|
25
|
+
|
26
|
+
Pod::Podfile.new do
|
27
|
+
project "#{spec.name}.xcodeproj"
|
28
|
+
workspace "#{spec.name}.xcworkspace"
|
29
|
+
|
30
|
+
plugin 'cocoapods-generate'
|
31
|
+
|
32
|
+
install! 'cocoapods', generator.installation_options
|
33
|
+
|
34
|
+
generator.podfile_plugins.each do |name, options|
|
35
|
+
plugin(*[name, options].compact)
|
36
|
+
end
|
37
|
+
|
38
|
+
# use_frameworks!(generator.use_frameworks_value)
|
39
|
+
# 强制生成 static framework
|
40
|
+
use_frameworks!({:linkage=>:static, :packaging=>:framework})
|
41
|
+
|
42
|
+
if (supported_swift_versions = generator.supported_swift_versions)
|
43
|
+
supports_swift_versions(supported_swift_versions)
|
44
|
+
end
|
45
|
+
|
46
|
+
# Explicitly set sources
|
47
|
+
generator.configuration.sources.each do |source_url|
|
48
|
+
source(source_url)
|
49
|
+
end
|
50
|
+
|
51
|
+
self.defined_in_file = dir.join('CocoaPods.podfile.yaml')
|
52
|
+
|
53
|
+
test_specs = spec.recursive_subspecs.select(&:test_specification?)
|
54
|
+
app_specs = if spec.respond_to?(:app_specification?)
|
55
|
+
spec.recursive_subspecs.select(&:app_specification?)
|
56
|
+
else
|
57
|
+
[]
|
58
|
+
end
|
59
|
+
|
60
|
+
# Stick all of the transitive dependencies in an abstract target.
|
61
|
+
# This allows us to force CocoaPods to use the versions / sources / external sources
|
62
|
+
# that we want.
|
63
|
+
# By using an abstract target,
|
64
|
+
|
65
|
+
# 会导致多个dependencies出现, 注释by slj
|
66
|
+
# abstract_target 'Transitive Dependencies' do
|
67
|
+
# pods_for_transitive_dependencies = [spec.name]
|
68
|
+
# .concat(test_specs.map(&:name))
|
69
|
+
# .concat(test_specs.flat_map { |ts| ts.dependencies.flat_map(&:name) })
|
70
|
+
# .concat(app_specs.map(&:name))
|
71
|
+
# .concat(app_specs.flat_map { |as| as.dependencies.flat_map(&:name) })
|
72
|
+
#
|
73
|
+
# dependencies = generator
|
74
|
+
# .transitive_dependencies_by_pod
|
75
|
+
# .values_at(*pods_for_transitive_dependencies)
|
76
|
+
# .compact
|
77
|
+
# .flatten(1)
|
78
|
+
# .uniq
|
79
|
+
# .sort_by(&:name)
|
80
|
+
# .reject { |d| d.root_name == spec.root.name }
|
81
|
+
#
|
82
|
+
# dependencies.each do |dependency|
|
83
|
+
# pod_args = generator.pod_args_for_dependency(self, dependency)
|
84
|
+
# pod(*pod_args)
|
85
|
+
# end
|
86
|
+
# end
|
87
|
+
|
88
|
+
# Add platform-specific concrete targets that inherit the
|
89
|
+
# `pod` declaration for the local pod.
|
90
|
+
spec_platform_names = spec.available_platforms.map(&:string_name).flatten.each.reject do |platform_name|
|
91
|
+
!generator.configuration.platforms.nil? && !generator.configuration.platforms.include?(platform_name.downcase)
|
92
|
+
end
|
93
|
+
|
94
|
+
spec_platform_names.sort.each do |platform_name|
|
95
|
+
target "App-#{platform_name}" do
|
96
|
+
current_target_definition.swift_version = generator.swift_version if generator.swift_version
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
# this block has to come _before_ inhibit_all_warnings! / use_modular_headers!,
|
101
|
+
# and the local `pod` declaration
|
102
|
+
# 会导致多个dependencies出现, 注释by slj
|
103
|
+
|
104
|
+
|
105
|
+
inhibit_all_warnings! if generator.inhibit_all_warnings?
|
106
|
+
use_modular_headers! if generator.use_modular_headers?
|
107
|
+
|
108
|
+
# This is the pod declaration for the local pod,
|
109
|
+
# it will be inherited by the concrete target definitions below
|
110
|
+
|
111
|
+
pod_options = generator.dependency_compilation_kwargs(spec.name)
|
112
|
+
pod_options[:path] = spec.defined_in_file.relative_path_from(dir).to_s
|
113
|
+
# generator.configuration.podfile.dependencies[0].external_source
|
114
|
+
|
115
|
+
|
116
|
+
{ testspecs: test_specs, appspecs: app_specs }.each do |key, specs|
|
117
|
+
pod_options[key] = specs.map { |s| s.name.sub(%r{^#{Regexp.escape spec.root.name}/}, '') }.sort unless specs.empty?
|
118
|
+
end
|
119
|
+
|
120
|
+
pod spec.name, **pod_options
|
121
|
+
|
122
|
+
if Pod::Config.instance.podfile
|
123
|
+
target_definitions['Pods'].instance_exec do
|
124
|
+
target_definition = nil
|
125
|
+
Pod::Config.instance.podfile.target_definition_list.each do |target|
|
126
|
+
if target.label == "Pods-#{spec.name}"
|
127
|
+
target_definition = target
|
128
|
+
break
|
129
|
+
end
|
130
|
+
end
|
131
|
+
# setting modular_headers_for
|
132
|
+
if(target_definition && target_definition.use_modular_headers_hash.values.any?)
|
133
|
+
target_definition.use_modular_headers_hash.values.each do |f|
|
134
|
+
f.each { | pod_name| self.set_use_modular_headers_for_pod(pod_name, true) }
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
|
139
|
+
if target_definition
|
140
|
+
value = target_definition.to_hash['dependencies']
|
141
|
+
next if value.blank?
|
142
|
+
#删除 本地库中的 spec.name,因为本地的./spec.name地址是错的
|
143
|
+
value.each do |f|
|
144
|
+
if f.is_a?(Hash) && f.keys.first == spec.name
|
145
|
+
value.delete f
|
146
|
+
break
|
147
|
+
end
|
148
|
+
end
|
149
|
+
old_value = self.to_hash['dependencies'].first
|
150
|
+
value << old_value unless (old_value == nil || value.include?(old_value))
|
151
|
+
|
152
|
+
set_hash_value(%w(dependencies).first, value)
|
153
|
+
|
154
|
+
value = target_definition.to_hash['configuration_pod_whitelist']
|
155
|
+
next if value.blank?
|
156
|
+
set_hash_value(%w(configuration_pod_whitelist).first, value)
|
157
|
+
|
158
|
+
|
159
|
+
end
|
160
|
+
|
161
|
+
|
162
|
+
end
|
163
|
+
|
164
|
+
end
|
165
|
+
|
166
|
+
# if generator.configuration && generator.configuration.podfile
|
167
|
+
# #变量本地podfile下的dependencies 写入新的验证文件中,指定依赖源
|
168
|
+
# generator.configuration.podfile.dependencies.each { |dependencies|
|
169
|
+
# #如果不存在dependencies.external_source,就不变量
|
170
|
+
# next unless dependencies.external_source
|
171
|
+
#
|
172
|
+
# dependencies.external_source.each { |key_d, value|
|
173
|
+
# pod_options = generator.dependency_compilation_kwargs(dependencies.name)
|
174
|
+
# pod_options[key_d] = value.to_s
|
175
|
+
# { testspecs: test_specs, appspecs: app_specs }.each do |key, specs|
|
176
|
+
# pod_options[key] = specs.map { |s| s.name.sub(%r{^#{Regexp.escape spec.root.name}/}, '') }.sort unless specs.empty?
|
177
|
+
# end
|
178
|
+
# # 过滤 dependencies.name == spec.name
|
179
|
+
# pod(dependencies.name, **pod_options) unless dependencies.name == spec.name
|
180
|
+
# }
|
181
|
+
# }
|
182
|
+
# end
|
183
|
+
|
184
|
+
|
185
|
+
# Implement local-sources option to set up dependencies to podspecs in the local filesystem.
|
186
|
+
next if generator.configuration.local_sources.empty?
|
187
|
+
generator.transitive_local_dependencies(spec, generator.configuration.local_sources).each do |dependency, podspec_file|
|
188
|
+
pod_options = generator.dependency_compilation_kwargs(dependency.name)
|
189
|
+
pod_options[:path] = if podspec_file[0] == '/' # absolute path
|
190
|
+
podspec_file
|
191
|
+
else
|
192
|
+
'../../' + podspec_file
|
193
|
+
end
|
194
|
+
pod dependency.name, **pod_options
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
require 'cocoapods-meitu-bin/native/specification'
|
4
|
+
|
5
|
+
module Pod
|
6
|
+
class Sandbox
|
7
|
+
class PodspecFinder
|
8
|
+
def podspecs
|
9
|
+
return @specs_by_name if @specs_by_name
|
10
|
+
|
11
|
+
@specs_by_name = {}
|
12
|
+
spec_files = Pathname.glob(root + '{,*}.podspec{,.json}')
|
13
|
+
# pod 指向分支时,如果目标组件有 subspec ,并且有 template spec ,request 之后使用的 spec 不应该为 template spec
|
14
|
+
# 这里做下过滤
|
15
|
+
spec_files = spec_files.reject { |p| Specification::DEFAULT_TEMPLATE_EXTNAME.find { |e| p.to_s.end_with?(e) } }
|
16
|
+
spec_files.sort_by { |p| -p.to_path.split(File::SEPARATOR).size }.each do |file|
|
17
|
+
spec = Specification.from_file(file)
|
18
|
+
spec.validate_cocoapods_version
|
19
|
+
@specs_by_name[spec.name] = spec
|
20
|
+
end
|
21
|
+
@specs_by_name
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|