Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0cfa27a897 | ||
|
|
d5c0101154 | ||
|
|
5dc20e3c98 | ||
|
|
a60a69d9f4 | ||
|
|
8eae79faa4 | ||
|
|
30cbf7f1c5 | ||
|
|
33ae8908bd | ||
|
|
02383b2538 | ||
|
|
551d99c5d8 | ||
|
|
75f0ae9f2b | ||
|
|
671ebddf20 | ||
|
|
5962d88538 |
@ -1,5 +1,4 @@
|
||||
|
||||
<p align="center"><img src="/test/logo.png" width="622"></p>
|
||||
# cocoapods-binary
|
||||
|
||||
[](https://travis-ci.org/leavez/cocoapods-binary)
|
||||
|
||||
|
||||
@ -2,8 +2,6 @@ require_relative 'helper/podfile_options'
|
||||
require_relative 'helper/feature_switches'
|
||||
require_relative 'helper/prebuild_sandbox'
|
||||
require_relative 'helper/passer'
|
||||
require_relative 'helper/names'
|
||||
|
||||
|
||||
|
||||
# NOTE:
|
||||
@ -26,9 +24,13 @@ module Pod
|
||||
|
||||
# make a symlink to target folder
|
||||
prebuild_sandbox = Pod::PrebuildSandbox.from_standard_sandbox(standard_sanbox)
|
||||
# if spec used in multiple platforms, it may return multiple paths
|
||||
target_names = prebuild_sandbox.existed_target_names_for_pod_name(self.name)
|
||||
|
||||
real_file_folder = prebuild_sandbox.framework_folder_path_for_pod_name(self.name)
|
||||
|
||||
target_folder = standard_sanbox.pod_dir(self.name)
|
||||
target_folder.rmtree if target_folder.exist?
|
||||
target_folder.mkdir
|
||||
|
||||
# make a relatvie symbol link for all children
|
||||
def walk(path, &action)
|
||||
path.children.each do |child|
|
||||
result = action.call(child, &action)
|
||||
@ -48,51 +50,31 @@ module Pod
|
||||
target = target_folder + source.relative_path_from(basefolder)
|
||||
make_link(source, target)
|
||||
end
|
||||
|
||||
target_names.each do |name|
|
||||
|
||||
# symbol link copy all substructure
|
||||
real_file_folder = prebuild_sandbox.framework_folder_path_for_target_name(name)
|
||||
|
||||
# If have only one platform, just place int the root folder of this pod.
|
||||
# If have multiple paths, we use a sperated folder to store different
|
||||
# platform frameworks. e.g. AFNetworking/AFNetworking-iOS/AFNetworking.framework
|
||||
|
||||
target_folder = standard_sanbox.pod_dir(self.name)
|
||||
if target_names.count > 1
|
||||
target_folder += real_file_folder.basename
|
||||
# symbol link copy all substructure
|
||||
walk(real_file_folder) do |child|
|
||||
source = child
|
||||
# only make symlink to file and `.framework` folder
|
||||
if child.directory? and [".framework", ".dSYM"].include? child.extname
|
||||
mirror_with_symlink(source, real_file_folder, target_folder)
|
||||
next false # return false means don't go deeper
|
||||
elsif child.file?
|
||||
mirror_with_symlink(source, real_file_folder, target_folder)
|
||||
next true
|
||||
else
|
||||
next true
|
||||
end
|
||||
target_folder.rmtree if target_folder.exist?
|
||||
target_folder.mkpath
|
||||
end
|
||||
|
||||
|
||||
walk(real_file_folder) do |child|
|
||||
source = child
|
||||
# only make symlink to file and `.framework` folder
|
||||
if child.directory? and child.extname == ".framework"
|
||||
mirror_with_symlink(source, real_file_folder, target_folder)
|
||||
next false # return false means don't go deeper
|
||||
elsif child.file?
|
||||
mirror_with_symlink(source, real_file_folder, target_folder)
|
||||
next true
|
||||
else
|
||||
next true
|
||||
end
|
||||
# symbol link copy resource for static framework
|
||||
hash = Prebuild::Passer.resources_to_copy_for_static_framework || {}
|
||||
path_objects = hash[self.name]
|
||||
if path_objects != nil
|
||||
path_objects.each do |object|
|
||||
make_link(object.real_file_path, object.target_file_path)
|
||||
end
|
||||
|
||||
|
||||
# symbol link copy resource for static framework
|
||||
hash = Prebuild::Passer.resources_to_copy_for_static_framework || {}
|
||||
|
||||
path_objects = hash[name]
|
||||
if path_objects != nil
|
||||
path_objects.each do |object|
|
||||
make_link(object.real_file_path, object.target_file_path)
|
||||
end
|
||||
end
|
||||
end # of for each
|
||||
|
||||
end # of method
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
@ -113,7 +95,7 @@ module Pod
|
||||
changes = Pod::Prebuild::Passer.prebuild_pods_changes
|
||||
updated_names = []
|
||||
if changes == nil
|
||||
updated_names = PrebuildSandbox.from_standard_sandbox(self.sandbox).exsited_framework_pod_names
|
||||
updated_names = PrebuildSandbox.from_standard_sandbox(self.sandbox).exsited_framework_names
|
||||
else
|
||||
added = changes.added
|
||||
changed = changes.changed
|
||||
@ -145,66 +127,71 @@ module Pod
|
||||
|
||||
# call original
|
||||
old_method2.bind(self).()
|
||||
# ...
|
||||
# ...
|
||||
# ...
|
||||
# after finishing the very complex orginal function
|
||||
|
||||
|
||||
# prepare
|
||||
# make sturcture to fast get target by name
|
||||
pod_name_to_targets_hash = self.pod_targets.reduce({}) do |sum, target|
|
||||
array = sum[target.pod_name] || []
|
||||
array << target
|
||||
sum[target.pod_name] = array
|
||||
sum
|
||||
end
|
||||
def get_corresponding_targets(spec, pod_name_to_targets_hash)
|
||||
corresponding_targets = pod_name_to_targets_hash[spec.root.name] || []
|
||||
corresponding_targets = corresponding_targets.reject do |target|
|
||||
Prebuild::Passer.target_names_to_skip_integration_framework.include? target.name
|
||||
end
|
||||
corresponding_targets
|
||||
end
|
||||
def add_vendered_framework(spec, platform, added_framework_file_path)
|
||||
if spec.attributes_hash[platform] == nil
|
||||
spec.attributes_hash[platform] = {}
|
||||
end
|
||||
vendored_frameworks = spec.attributes_hash[platform]["vendored_frameworks"] || []
|
||||
vendored_frameworks = [vendored_frameworks] if vendored_frameworks.kind_of?(String)
|
||||
vendored_frameworks += [added_framework_file_path]
|
||||
spec.attributes_hash[platform]["vendored_frameworks"] = vendored_frameworks
|
||||
end
|
||||
def empty_source_files(spec)
|
||||
spec.attributes_hash["source_files"] = []
|
||||
["ios", "watchos", "tvos", "osx"].each do |plat|
|
||||
if spec.attributes_hash[plat] != nil
|
||||
spec.attributes_hash[plat]["source_files"] = []
|
||||
end
|
||||
end
|
||||
|
||||
# check the prebuilt targets
|
||||
targets = self.prebuild_pod_targets
|
||||
targets_have_different_platforms = targets.select {|t| t.pod_name != t.name }
|
||||
|
||||
if targets_have_different_platforms.count > 0
|
||||
names = targets_have_different_platforms.map(&:pod_name)
|
||||
STDERR.puts "[!] Binary doesn't support pods who integrate in 2 or more platforms simultaneously: #{names}".red
|
||||
exit
|
||||
end
|
||||
|
||||
|
||||
specs = self.analysis_result.specifications
|
||||
prebuilt_specs = (specs.select do |spec|
|
||||
self.prebuild_pod_names.include? spec.root.name
|
||||
end)
|
||||
|
||||
# make sturcture to fast get target by name
|
||||
name_to_target_hash = self.pod_targets.reduce({}) do |sum, target|
|
||||
sum[target.name] = target
|
||||
sum
|
||||
end
|
||||
|
||||
prebuilt_specs.each do |spec|
|
||||
# `spec` may be a subspec, so we use the root's name
|
||||
root_name = spec.root.name
|
||||
|
||||
target = name_to_target_hash[root_name]
|
||||
next if Prebuild::Passer.target_names_to_skip_integration_framework.include? target.pod_name
|
||||
|
||||
# Use the prebuild framworks as vendered frameworks
|
||||
targets = get_corresponding_targets(spec, pod_name_to_targets_hash)
|
||||
targets.each do |target|
|
||||
# the framework_file_path rule is decided when `install_for_prebuild`,
|
||||
# as to compitable with older version and be less wordy.
|
||||
framework_file_path = target.framework_name
|
||||
framework_file_path = target.name + "/" + framework_file_path if targets.count > 1
|
||||
add_vendered_framework(spec, target.platform.name.to_s, framework_file_path)
|
||||
# use the prebuilt framework
|
||||
original_vendored_frameworks = spec.attributes_hash["vendored_frameworks"] || []
|
||||
if original_vendored_frameworks.kind_of?(String)
|
||||
original_vendored_frameworks = [original_vendored_frameworks]
|
||||
end
|
||||
original_vendored_frameworks += [target.framework_name]
|
||||
spec.attributes_hash["vendored_frameworks"] = original_vendored_frameworks
|
||||
spec.attributes_hash["source_files"] = []
|
||||
|
||||
# to remove the resurce bundle target.
|
||||
# When specify the "resource_bundles" in podspec, xcode will generate a bundle
|
||||
# target after pod install. But the bundle have already built when the prebuit
|
||||
# phase and saved in the framework folder. We will treat it as a normal resource
|
||||
# file.
|
||||
# https://github.com/leavez/cocoapods-binary/issues/29
|
||||
if spec.attributes_hash["resource_bundles"]
|
||||
bundle_names = spec.attributes_hash["resource_bundles"].keys
|
||||
spec.attributes_hash["resource_bundles"] = nil
|
||||
spec.attributes_hash["resources"] ||= []
|
||||
spec.attributes_hash["resources"] += bundle_names.map{|n| n+".bundle"}
|
||||
end
|
||||
|
||||
# to remove the resurce bundle target.
|
||||
# When specify the "resource_bundles" in podspec, xcode will generate a bundle
|
||||
# target after pod install. But the bundle have already built when the prebuit
|
||||
# phase and saved in the framework folder. We will treat it as a normal resource
|
||||
# file.
|
||||
# https://github.com/leavez/cocoapods-binary/issues/29
|
||||
if spec.attributes_hash["resource_bundles"]
|
||||
bundle_names = spec.attributes_hash["resource_bundles"].keys
|
||||
spec.attributes_hash["resource_bundles"] = nil
|
||||
spec.attributes_hash["resources"] ||= []
|
||||
spec.attributes_hash["resources"] += bundle_names.map{|n| n+".bundle"}
|
||||
end
|
||||
# Clean the source files
|
||||
# we just add the prebuilt framework to specific platform and set no source files
|
||||
# for all platform, so it doesn't support the sence that 'a pod perbuild for one
|
||||
# platform and not for another platform.'
|
||||
empty_source_files(spec)
|
||||
|
||||
# to avoid the warning of missing license
|
||||
spec.attributes_hash["license"] = {}
|
||||
@ -256,8 +243,9 @@ module Pod
|
||||
# ---- this is added by cocoapods-binary ---
|
||||
# Readlink cannot handle relative symlink well, so we override it to a new one
|
||||
# If the path isn't an absolute path, we add a realtive prefix.
|
||||
old_read_link=`which readlink`
|
||||
readlink () {
|
||||
path=`/usr/bin/readlink $1`;
|
||||
path=`$old_read_link $1`;
|
||||
if [ $(echo "$path" | cut -c 1-1) = '/' ]; then
|
||||
echo $path;
|
||||
else
|
||||
@ -266,6 +254,10 @@ module Pod
|
||||
}
|
||||
# ---
|
||||
SH
|
||||
|
||||
# patch the rsync for copy dSYM symlink
|
||||
script = script.gsub "rsync --delete", "rsync --copy-links --delete"
|
||||
|
||||
patch + script
|
||||
end
|
||||
end
|
||||
|
||||
@ -48,7 +48,7 @@ Pod::HooksManager.register('cocoapods-binary', :pre_install) do |installer_conte
|
||||
# check user_framework is on
|
||||
podfile = installer_context.podfile
|
||||
podfile.target_definition_list.each do |target_definition|
|
||||
next if target_definition.prebuild_framework_pod_names.empty?
|
||||
next if target_definition.prebuild_framework_names.empty?
|
||||
if not target_definition.uses_frameworks?
|
||||
STDERR.puts "[!] Cocoapods-binary requires `use_frameworks!`".red
|
||||
exit
|
||||
@ -64,6 +64,18 @@ Pod::HooksManager.register('cocoapods-binary', :pre_install) do |installer_conte
|
||||
|
||||
Pod::UI.puts "🚀 Prebuild frameworks"
|
||||
|
||||
# Fetch original installer (which is running this pre-install hook) options,
|
||||
# then pass them to our installer to perform update if needed
|
||||
# Looks like this is the most appropriate way to figure out that something should be updated
|
||||
|
||||
update = nil
|
||||
repo_update = nil
|
||||
|
||||
include ObjectSpace
|
||||
ObjectSpace.each_object(Pod::Installer) { |installer|
|
||||
update = installer.update
|
||||
repo_update = installer.repo_update
|
||||
}
|
||||
|
||||
# control features
|
||||
Pod.is_prebuild_stage = true
|
||||
@ -80,13 +92,14 @@ Pod::HooksManager.register('cocoapods-binary', :pre_install) do |installer_conte
|
||||
prebuild_podfile = Pod::Podfile.from_ruby(podfile.defined_in_file)
|
||||
|
||||
# install
|
||||
binary_installer = Pod::Installer.new(prebuild_sandbox, prebuild_podfile , nil)
|
||||
lockfile = installer_context.lockfile
|
||||
binary_installer = Pod::Installer.new(prebuild_sandbox, prebuild_podfile, lockfile)
|
||||
|
||||
if binary_installer.have_exact_prebuild_cache?
|
||||
if binary_installer.have_exact_prebuild_cache? && !update
|
||||
binary_installer.install_when_cache_hit!
|
||||
else
|
||||
binary_installer.repo_update = false
|
||||
binary_installer.update = false
|
||||
binary_installer.update = update
|
||||
binary_installer.repo_update = repo_update
|
||||
binary_installer.install!
|
||||
end
|
||||
|
||||
@ -97,7 +110,6 @@ Pod::HooksManager.register('cocoapods-binary', :pre_install) do |installer_conte
|
||||
Pod::Podfile::DSL.enable_prebuild_patch false
|
||||
Pod::Config.force_disable_write_lockfile false
|
||||
Pod::Installer.disable_install_complete_message false
|
||||
Pod::UserInterface.warnings = [] # clean the warning in the prebuild step, it's duplicated.
|
||||
|
||||
|
||||
# -- step 2: pod install ---
|
||||
|
||||
@ -43,9 +43,11 @@ module Pod
|
||||
unchanged = changes.unchanged
|
||||
deleted = changes.deleted
|
||||
|
||||
exsited_framework_pod_names = sandbox.exsited_framework_pod_names
|
||||
unchange_framework_names = (added + unchanged)
|
||||
|
||||
exsited_framework_names = sandbox.exsited_framework_names
|
||||
missing = unchanged.select do |pod_name|
|
||||
not exsited_framework_pod_names.include?(pod_name)
|
||||
not exsited_framework_names.include?(pod_name)
|
||||
end
|
||||
|
||||
needed = (added + changed + deleted + missing)
|
||||
@ -56,7 +58,7 @@ module Pod
|
||||
# The install method when have completed cache
|
||||
def install_when_cache_hit!
|
||||
# just print log
|
||||
self.sandbox.exsited_framework_target_names.each do |name|
|
||||
self.sandbox.exsited_framework_names.each do |name|
|
||||
UI.puts "Using #{name}"
|
||||
end
|
||||
end
|
||||
@ -80,23 +82,24 @@ module Pod
|
||||
deleted = changes.deleted
|
||||
|
||||
existed_framework_folder.mkdir unless existed_framework_folder.exist?
|
||||
exsited_framework_pod_names = sandbox.exsited_framework_pod_names
|
||||
exsited_framework_names = sandbox.exsited_framework_names
|
||||
|
||||
# additions
|
||||
missing = unchanged.select do |pod_name|
|
||||
not exsited_framework_pod_names.include?(pod_name)
|
||||
not exsited_framework_names.include?(pod_name)
|
||||
end
|
||||
|
||||
|
||||
root_names_to_update = (added + changed + missing)
|
||||
|
||||
# transform names to targets
|
||||
def targets_for_pod_names(root_pod_names)
|
||||
self.pod_targets.select do |target|
|
||||
target.pod_name == root_pod_names
|
||||
end
|
||||
name_to_target_hash = self.pod_targets.reduce({}) do |sum, target|
|
||||
sum[target.name] = target
|
||||
sum
|
||||
end
|
||||
targets = targets_for_pod_names(root_names_to_update)
|
||||
targets = root_names_to_update.map do |root_name|
|
||||
name_to_target_hash[root_name]
|
||||
end || []
|
||||
|
||||
# add the dendencies
|
||||
dependency_targets = targets.map {|t| t.recursive_dependent_targets }.flatten.uniq || []
|
||||
@ -114,8 +117,8 @@ module Pod
|
||||
Pod::Prebuild.remove_build_dir(sandbox_path)
|
||||
targets.each do |target|
|
||||
next unless target.should_build?
|
||||
output_path = sandbox.framework_folder_path_for_target_name(target.name)
|
||||
|
||||
output_path = sandbox.framework_folder_path_for_pod_name(target.name)
|
||||
output_path.mkpath unless output_path.exist?
|
||||
Pod::Prebuild.build(sandbox_path, target, output_path, bitcode_enabled)
|
||||
|
||||
@ -123,17 +126,15 @@ module Pod
|
||||
if target.static_framework? and !target.resource_paths.empty?
|
||||
framework_path = output_path + target.framework_name
|
||||
standard_sandbox_path = sandbox.standard_sanbox_path
|
||||
path_objects = target.resource_paths.select{|f| f.start_with? "${PODS_ROOT}"}.map do |path|
|
||||
path_objects = target.resource_paths.map do |path|
|
||||
object = Prebuild::Passer::ResourcePath.new
|
||||
object.real_file_path = framework_path + File.basename(path)
|
||||
object.target_file_path = path.gsub('${PODS_ROOT}', standard_sandbox_path.to_s)
|
||||
object.target_file_path = path.gsub('${PODS_ROOT}', standard_sandbox_path.to_s) if path.start_with? '${PODS_ROOT}'
|
||||
object.target_file_path = path.gsub("${PODS_CONFIGURATION_BUILD_DIR}", standard_sandbox_path.to_s) if path.start_with? "${PODS_CONFIGURATION_BUILD_DIR}"
|
||||
object
|
||||
end
|
||||
Prebuild::Passer.resources_to_copy_for_static_framework[target.name] = path_objects
|
||||
end
|
||||
|
||||
# save the pod_name for prebuild framwork in sandbox
|
||||
sandbox.save_pod_name_for_target target
|
||||
end
|
||||
Pod::Prebuild.remove_build_dir(sandbox_path)
|
||||
|
||||
@ -141,12 +142,12 @@ module Pod
|
||||
# copy vendored libraries and frameworks
|
||||
targets.each do |target|
|
||||
root_path = self.sandbox.pod_dir(target.name)
|
||||
target_folder = sandbox.framework_folder_path_for_target_name(target.name)
|
||||
target_folder = sandbox.framework_folder_path_for_pod_name(target.name)
|
||||
|
||||
# If target shouldn't build, we copy all the original files
|
||||
# This is for target with only .a and .h files
|
||||
if not target.should_build?
|
||||
Prebuild::Passer.target_names_to_skip_integration_framework << target.name
|
||||
Prebuild::Passer.target_names_to_skip_integration_framework << target.pod_name
|
||||
FileUtils.cp_r(root_path, target_folder, :remove_destination => true)
|
||||
next
|
||||
end
|
||||
@ -168,11 +169,11 @@ module Pod
|
||||
# Remove useless files
|
||||
# remove useless pods
|
||||
all_needed_names = self.pod_targets.map(&:name).uniq
|
||||
useless_target_names = sandbox.exsited_framework_target_names.reject do |name|
|
||||
useless_names = sandbox.exsited_framework_names.reject do |name|
|
||||
all_needed_names.include? name
|
||||
end
|
||||
useless_target_names.each do |name|
|
||||
path = sandbox.framework_folder_path_for_target_name(name)
|
||||
useless_names.each do |name|
|
||||
path = sandbox.framework_folder_path_for_pod_name(name)
|
||||
path.rmtree if path.exist?
|
||||
end
|
||||
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
module CocoapodsBinary
|
||||
VERSION = "0.4.1"
|
||||
VERSION = "0.4.2"
|
||||
end
|
||||
|
||||
@ -38,6 +38,11 @@ module Pod
|
||||
end
|
||||
|
||||
if should_prebuild and (not local)
|
||||
if current_target_definition.platform == :watchos
|
||||
# watchos isn't supported currently
|
||||
Pod::UI.warn "Binary doesn't support watchos currently: #{name}. You can manually set `binary => false` for this pod to suppress this warning."
|
||||
return
|
||||
end
|
||||
old_method.bind(self).(name, *args)
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,57 +0,0 @@
|
||||
#
|
||||
# There are many kinds of name in cocoapods. Two main names are widely used in this plugin.
|
||||
# - root_spec.name (spec.root_name, targe.pod_name):
|
||||
# aka "pod_name"
|
||||
# the name we use in podfile. the concept.
|
||||
#
|
||||
# - target.name:
|
||||
# aka "target_name"
|
||||
# the name of the final target in xcode project. the final real thing.
|
||||
#
|
||||
# One pod may have multiple targets in xcode project, due to one pod can be used in mutiple
|
||||
# platform simultaneously. So one `root_spec.name` may have multiple coresponding `target.name`s.
|
||||
# Therefore, map a spec to/from targets is a little complecated. It's one to many.
|
||||
#
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Target:
|
||||
|
||||
# def pod_name
|
||||
# root_spec.name
|
||||
# end
|
||||
|
||||
# def name
|
||||
# pod_name + #{scope_suffix}
|
||||
# end
|
||||
|
||||
# def product_module_name
|
||||
# root_spec.module_name
|
||||
# end
|
||||
|
||||
# def framework_name
|
||||
# "#{product_module_name}.framework"
|
||||
# end
|
||||
|
||||
# def product_name
|
||||
# if requires_frameworks?
|
||||
# framework_name
|
||||
# else
|
||||
# static_library_name
|
||||
# end
|
||||
# end
|
||||
|
||||
# def product_basename
|
||||
# if requires_frameworks?
|
||||
# product_module_name
|
||||
# else
|
||||
# label
|
||||
# end
|
||||
# end
|
||||
|
||||
# def framework_name
|
||||
# "#{product_module_name}.framework"
|
||||
# end
|
||||
@ -11,37 +11,43 @@ module Pod
|
||||
|
||||
## --- option for setting using prebuild framework ---
|
||||
def parse_prebuild_framework(name, requirements)
|
||||
should_prebuild = Pod::Podfile::DSL.prebuild_all
|
||||
|
||||
options = requirements.last
|
||||
return requirements unless options.is_a?(Hash)
|
||||
if options.is_a?(Hash) && options[Pod::Prebuild.keyword] != nil
|
||||
should_prebuild = options.delete(Pod::Prebuild.keyword)
|
||||
requirements.pop if options.empty?
|
||||
end
|
||||
|
||||
should_prebuild_framework = options.delete(Pod::Prebuild.keyword)
|
||||
pod_name = Specification.root_name(name)
|
||||
set_prebuild_for_pod(pod_name, should_prebuild_framework)
|
||||
requirements.pop if options.empty?
|
||||
set_prebuild_for_pod(pod_name, should_prebuild)
|
||||
end
|
||||
|
||||
def set_prebuild_for_pod(pod_name, should_prebuild)
|
||||
|
||||
if should_prebuild == true
|
||||
@prebuild_framework_pod_names ||= []
|
||||
@prebuild_framework_pod_names.push pod_name
|
||||
# watchos isn't supported currently
|
||||
return if self.platform == :watchos
|
||||
|
||||
@prebuild_framework_names ||= []
|
||||
@prebuild_framework_names.push pod_name
|
||||
else
|
||||
@should_not_prebuild_framework_pod_names ||= []
|
||||
@should_not_prebuild_framework_pod_names.push pod_name
|
||||
@should_not_prebuild_framework_names ||= []
|
||||
@should_not_prebuild_framework_names.push pod_name
|
||||
end
|
||||
end
|
||||
|
||||
def prebuild_framework_pod_names
|
||||
names = @prebuild_framework_pod_names || []
|
||||
def prebuild_framework_names
|
||||
names = @prebuild_framework_names || []
|
||||
if parent != nil and parent.kind_of? TargetDefinition
|
||||
names += parent.prebuild_framework_pod_names
|
||||
names += parent.prebuild_framework_names
|
||||
end
|
||||
names
|
||||
end
|
||||
def should_not_prebuild_framework_pod_names
|
||||
names = @should_not_prebuild_framework_pod_names || []
|
||||
def should_not_prebuild_framework_names
|
||||
names = @should_not_prebuild_framework_names || []
|
||||
if parent != nil and parent.kind_of? TargetDefinition
|
||||
names += parent.should_not_prebuild_framework_pod_names
|
||||
names += parent.should_not_prebuild_framework_names
|
||||
end
|
||||
names
|
||||
end
|
||||
@ -68,13 +74,13 @@ module Pod
|
||||
|
||||
all = []
|
||||
|
||||
aggregate_targets = self.aggregate_targets
|
||||
aggregate_targets = self.aggregate_targets.select { |a| a.platform != :watchos }
|
||||
aggregate_targets.each do |aggregate_target|
|
||||
target_definition = aggregate_target.target_definition
|
||||
targets = aggregate_target.pod_targets || []
|
||||
|
||||
# filter prebuild
|
||||
prebuild_names = target_definition.prebuild_framework_pod_names
|
||||
prebuild_names = target_definition.prebuild_framework_names
|
||||
if not Podfile::DSL.prebuild_all
|
||||
targets = targets.select { |pod_target| prebuild_names.include?(pod_target.pod_name) }
|
||||
end
|
||||
@ -82,7 +88,7 @@ module Pod
|
||||
targets = (targets + dependency_targets).uniq
|
||||
|
||||
# filter should not prebuild
|
||||
explict_should_not_names = target_definition.should_not_prebuild_framework_pod_names
|
||||
explict_should_not_names = target_definition.should_not_prebuild_framework_names
|
||||
targets = targets.reject { |pod_target| explict_should_not_names.include?(pod_target.pod_name) }
|
||||
|
||||
all += targets
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
require_relative "names"
|
||||
|
||||
module Pod
|
||||
class PrebuildSandbox < Sandbox
|
||||
|
||||
@ -21,51 +19,31 @@ module Pod
|
||||
self.root + "GeneratedFrameworks"
|
||||
end
|
||||
|
||||
# @param name [String] pass the target.name (may containing platform suffix)
|
||||
# @return [Pathname] the folder containing the framework file.
|
||||
def framework_folder_path_for_target_name(name)
|
||||
def framework_folder_path_for_pod_name(name)
|
||||
self.generate_framework_path + name
|
||||
end
|
||||
|
||||
|
||||
def exsited_framework_target_names
|
||||
exsited_framework_name_pairs.map {|pair| pair[0]}.uniq
|
||||
end
|
||||
def exsited_framework_pod_names
|
||||
exsited_framework_name_pairs.map {|pair| pair[1]}.uniq
|
||||
end
|
||||
def existed_target_names_for_pod_name(pod_name)
|
||||
exsited_framework_name_pairs.select {|pair| pair[1] == pod_name }.map { |pair| pair[0]}
|
||||
end
|
||||
|
||||
|
||||
|
||||
def save_pod_name_for_target(target)
|
||||
folder = framework_folder_path_for_target_name(target.name)
|
||||
flag_file_path = folder + "#{target.pod_name}.pod_name"
|
||||
File.write(flag_file_path.to_s, "")
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
|
||||
def pod_name_for_target_folder(target_folder_path)
|
||||
name = Pathname.new(target_folder_path).children.first do |child|
|
||||
child.to_s.end_with? ".pod_name"
|
||||
end.basename(".pod_name").to_s
|
||||
name ||= Pathname.new(target_folder_path).basename.to_s # for compatibility with older version
|
||||
end
|
||||
|
||||
# Array<[target_name, pod_name]>
|
||||
def exsited_framework_name_pairs
|
||||
def exsited_framework_names
|
||||
return [] unless generate_framework_path.exist?
|
||||
generate_framework_path.children().map do |framework_path|
|
||||
if framework_path.directory? && (not framework_path.children.empty?)
|
||||
[framework_path.basename.to_s, pod_name_for_target_folder(framework_path)]
|
||||
generate_framework_path.children().map do |framework_name|
|
||||
if framework_name.directory?
|
||||
if not framework_name.children.empty?
|
||||
File.basename(framework_name)
|
||||
else
|
||||
nil
|
||||
end
|
||||
else
|
||||
nil
|
||||
end
|
||||
end.reject(&:nil?).uniq
|
||||
end.reject(&:nil?)
|
||||
end
|
||||
|
||||
def framework_existed?(root_name)
|
||||
return false unless generate_framework_path.exist?
|
||||
generate_framework_path.children().any? do |child|
|
||||
child.basename.to_s == root_name
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@ -15,26 +15,25 @@ def build_for_iosish_platform(sandbox,
|
||||
target,
|
||||
device,
|
||||
simulator,
|
||||
bitcode_enabled,
|
||||
simulator_default_arch)
|
||||
bitcode_enabled)
|
||||
|
||||
deployment_target = target.platform.deployment_target.to_s
|
||||
|
||||
target_label = target.label # name with platform if it's used in multiple platforms
|
||||
target_label = target.label
|
||||
Pod::UI.puts "Prebuilding #{target_label}..."
|
||||
|
||||
other_options = []
|
||||
if bitcode_enabled
|
||||
other_options += ['OTHER_CFLAGS="-fembed-bitcode"']
|
||||
other_options += ['BITCODE_GENERATION_MODE=bitcode']
|
||||
end
|
||||
xcodebuild(sandbox, target_label, device, deployment_target, other_options)
|
||||
xcodebuild(sandbox, target_label, simulator, deployment_target, other_options + ["ARCHS=#{simulator_default_arch}",'ONLY_ACTIVE_ARCH=NO'])
|
||||
xcodebuild(sandbox, target_label, simulator, deployment_target, other_options + ['ARCHS=x86_64', 'ONLY_ACTIVE_ARCH=NO'])
|
||||
|
||||
# paths
|
||||
target_name = target.name # equals target.label, like "AFNeworking-iOS" when AFNetworking is used in multiple platforms.
|
||||
root_name = target.pod_name
|
||||
module_name = target.product_module_name
|
||||
device_framwork_path = "#{build_dir}/#{CONFIGURATION}-#{device}/#{target_name}/#{module_name}.framework"
|
||||
simulator_framwork_path = "#{build_dir}/#{CONFIGURATION}-#{simulator}/#{target_name}/#{module_name}.framework"
|
||||
device_framwork_path = "#{build_dir}/#{CONFIGURATION}-#{device}/#{root_name}/#{module_name}.framework"
|
||||
simulator_framwork_path = "#{build_dir}/#{CONFIGURATION}-#{simulator}/#{root_name}/#{module_name}.framework"
|
||||
|
||||
device_binary = device_framwork_path + "/#{module_name}"
|
||||
simulator_binary = simulator_framwork_path + "/#{module_name}"
|
||||
@ -42,7 +41,7 @@ def build_for_iosish_platform(sandbox,
|
||||
|
||||
# the device_lib path is the final output file path
|
||||
# combine the bianries
|
||||
tmp_lipoed_binary_path = "#{build_dir}/#{target_name}"
|
||||
tmp_lipoed_binary_path = "#{build_dir}/#{root_name}"
|
||||
lipo_log = `lipo -create -output #{tmp_lipoed_binary_path} #{device_binary} #{simulator_binary}`
|
||||
puts lipo_log unless File.exist?(tmp_lipoed_binary_path)
|
||||
FileUtils.mv tmp_lipoed_binary_path, device_binary, :force => true
|
||||
@ -54,6 +53,17 @@ def build_for_iosish_platform(sandbox,
|
||||
FileUtils.cp_r simulator_swiftmodule_path + "/.", device_swiftmodule_path
|
||||
end
|
||||
|
||||
# handle the dSYM files
|
||||
device_dsym = "#{device_framwork_path}.dSYM"
|
||||
if File.exist? device_dsym
|
||||
# lipo the simulator dsym
|
||||
tmp_lipoed_binary_path = "#{output_path}/#{module_name}.draft"
|
||||
lipo_log = `lipo -create -output #{tmp_lipoed_binary_path} #{device_dsym}/Contents/Resources/DWARF/#{module_name} #{simulator_framwork_path}.dSYM/Contents/Resources/DWARF/#{module_name}`
|
||||
puts lipo_log unless File.exist?(tmp_lipoed_binary_path)
|
||||
FileUtils.mv tmp_lipoed_binary_path, "#{device_framwork_path}.dSYM/Contents/Resources/DWARF/#{module_name}", :force => true
|
||||
FileUtils.mv device_dsym, output_path, :force => true
|
||||
end
|
||||
|
||||
# output
|
||||
output_path.mkpath unless output_path.exist?
|
||||
FileUtils.mv device_framwork_path, output_path, :force => true
|
||||
@ -94,10 +104,10 @@ module Pod
|
||||
|
||||
# -- build the framework
|
||||
case target.platform.name
|
||||
when :ios then build_for_iosish_platform(sandbox, build_dir, output_path, target, 'iphoneos', 'iphonesimulator', bitcode_enabled, "x86_64")
|
||||
when :ios then build_for_iosish_platform(sandbox, build_dir, output_path, target, 'iphoneos', 'iphonesimulator', bitcode_enabled)
|
||||
when :osx then xcodebuild(sandbox, target.label)
|
||||
# when :tvos then build_for_iosish_platform(sandbox, build_dir, target, 'appletvos', 'appletvsimulator')
|
||||
when :watchos then build_for_iosish_platform(sandbox, build_dir, output_path, target, 'watchos', 'watchsimulator', true, "i386")
|
||||
# when :watchos then build_for_iosish_platform(sandbox, build_dir, target, 'watchos', 'watchsimulator')
|
||||
else raise "Unsupported platform for '#{target.name}': '#{target.platform.name}'" end
|
||||
|
||||
raise Pod::Informative, 'The build directory was not found in the expected location.' unless build_dir.directory?
|
||||
@ -135,4 +145,3 @@ module Pod
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
BIN
test/logo.png
BIN
test/logo.png
Binary file not shown.
|
Before Width: | Height: | Size: 1.2 KiB |
Loading…
Reference in New Issue
Block a user