Compare commits

..

No commits in common. "0.4.2" and "no_source" have entirely different histories.

12 changed files with 61 additions and 185 deletions

View File

@ -9,7 +9,6 @@ script:
- rake install
- cd test
- sh test.sh
- cd ..
# auto deploy on tagging
# automatically set by `travis setup rubygems`

View File

@ -55,11 +55,8 @@ end
If you want to disable binary for a specific pod when using `all_binary!`, place a `:binary => false` to it.
If your `Pods` folder is excluded from git, you may add `keep_source_code_for_prebuilt_frameworks!` in the head of Podfile to speed up pod install, as it won't download all the sources every time prebuilt pods have changes.
If bitcode is needed, add a `enable_bitcode_for_prebuilt_frameworks!` before all targets in Podfile
#### Known Issues
- doesn't support watchos now

View File

@ -55,7 +55,7 @@ module Pod
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
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?
@ -167,32 +167,6 @@ module Pod
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
# to avoid the warning of missing license
spec.attributes_hash["license"] = {}
end
@ -243,9 +217,8 @@ 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=`$old_read_link $1`;
path=`/usr/bin/readlink $1`;
if [ $(echo "$path" | cut -c 1-1) = '/' ]; then
echo $path;
else
@ -254,10 +227,6 @@ module Pod
}
# ---
SH
# patch the rsync for copy dSYM symlink
script = script.gsub "rsync --delete", "rsync --copy-links --delete"
patch + script
end
end

View File

@ -17,22 +17,12 @@ module Pod
DSL.bitcode_enabled = true
end
# Don't remove source code of prebuilt pods
# It may speed up the pod install if git didn't
# include the `Pods` folder
def keep_source_code_for_prebuilt_frameworks!
DSL.dont_remove_source_code = true
end
private
class_attr_accessor :prebuild_all
prebuild_all = false
class_attr_accessor :bitcode_enabled
bitcode_enabled = false
class_attr_accessor :dont_remove_source_code
dont_remove_source_code = false
end
end
end
@ -64,18 +54,6 @@ 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
@ -92,14 +70,13 @@ Pod::HooksManager.register('cocoapods-binary', :pre_install) do |installer_conte
prebuild_podfile = Pod::Podfile.from_ruby(podfile.defined_in_file)
# install
lockfile = installer_context.lockfile
binary_installer = Pod::Installer.new(prebuild_sandbox, prebuild_podfile, lockfile)
binary_installer = Pod::Installer.new(prebuild_sandbox, prebuild_podfile , nil)
if binary_installer.have_exact_prebuild_cache? && !update
if binary_installer.have_exact_prebuild_cache?
binary_installer.install_when_cache_hit!
else
binary_installer.update = update
binary_installer.repo_update = repo_update
binary_installer.repo_update = false
binary_installer.update = false
binary_installer.install!
end

View File

@ -83,6 +83,17 @@ module Pod
existed_framework_folder.mkdir unless existed_framework_folder.exist?
exsited_framework_names = sandbox.exsited_framework_names
# deletions
# remove all frameworks except ones to remain
unchange_framework_names = (added + unchanged)
to_delete = exsited_framework_names.select do |framework_name|
not unchange_framework_names.include?(framework_name)
end
to_delete.each do |framework_name|
path = sandbox.framework_folder_path_for_pod_name(framework_name)
path.rmtree if path.exist?
end
# additions
missing = unchanged.select do |pod_name|
@ -126,11 +137,10 @@ 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.map do |path|
path_objects = target.resource_paths.select{|f| f.start_with? "${PODS_ROOT}"}.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) 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.target_file_path = path.gsub('${PODS_ROOT}', standard_sandbox_path.to_s)
object
end
Prebuild::Passer.resources_to_copy_for_static_framework[target.name] = path_objects
@ -167,34 +177,16 @@ module Pod
end
# Remove useless files
# remove useless pods
all_needed_names = self.pod_targets.map(&:name).uniq
useless_names = sandbox.exsited_framework_names.reject do |name|
all_needed_names.include? name
# only keep manifest.lock and framework folder
to_remain_files = ["Manifest.lock", File.basename(existed_framework_folder)]
to_delete_files = sandbox_path.children.select do |file|
filename = File.basename(file)
not to_remain_files.include?(filename)
end
useless_names.each do |name|
path = sandbox.framework_folder_path_for_pod_name(name)
to_delete_files.each do |path|
path.rmtree if path.exist?
end
if not Podfile::DSL.dont_remove_source_code
# only keep manifest.lock and framework folder in _Prebuild
to_remain_files = ["Manifest.lock", File.basename(existed_framework_folder)]
to_delete_files = sandbox_path.children.select do |file|
filename = File.basename(file)
not to_remain_files.include?(filename)
end
to_delete_files.each do |path|
path.rmtree if path.exist?
end
else
# just remove the tmp files
path = sandbox.root + 'Manifest.lock.tmp'
path.rmtree if path.exist?
end
end

View File

@ -1,3 +1,3 @@
module CocoapodsBinary
VERSION = "0.4.2"
VERSION = "0.3.5"
end

View File

@ -11,16 +11,13 @@ module Pod
## --- option for setting using prebuild framework ---
def parse_prebuild_framework(name, requirements)
should_prebuild = Pod::Podfile::DSL.prebuild_all
options = requirements.last
if options.is_a?(Hash) && options[Pod::Prebuild.keyword] != nil
should_prebuild = options.delete(Pod::Prebuild.keyword)
requirements.pop if options.empty?
end
return requirements unless options.is_a?(Hash)
should_prebuild_framework = options.delete(Pod::Prebuild.keyword)
pod_name = Specification.root_name(name)
set_prebuild_for_pod(pod_name, should_prebuild)
set_prebuild_for_pod(pod_name, should_prebuild_framework)
requirements.pop if options.empty?
end
def set_prebuild_for_pod(pod_name, should_prebuild)

View File

@ -38,12 +38,5 @@ module Pod
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

View File

@ -24,50 +24,29 @@ def build_for_iosish_platform(sandbox,
other_options = []
if bitcode_enabled
other_options += ['BITCODE_GENERATION_MODE=bitcode']
other_options += ['OTHER_CFLAGS="-fembed-bitcode"']
end
xcodebuild(sandbox, target_label, device, deployment_target, other_options)
xcodebuild(sandbox, target_label, simulator, deployment_target, other_options + ['ARCHS=x86_64', 'ONLY_ACTIVE_ARCH=NO'])
# paths
root_name = target.pod_name
module_name = target.product_module_name
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}"
return unless File.file?(device_binary) && File.file?(simulator_binary)
# the device_lib path is the final output file path
# combine the bianries
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
# collect the swiftmodule file for various archs.
device_swiftmodule_path = device_framwork_path + "/Modules/#{module_name}.swiftmodule"
simulator_swiftmodule_path = simulator_framwork_path + "/Modules/#{module_name}.swiftmodule"
if File.exist?(device_swiftmodule_path)
FileUtils.cp_r simulator_swiftmodule_path + "/.", device_swiftmodule_path
end
executable_path = "#{build_dir}/#{root_name}"
device_lib = "#{build_dir}/#{CONFIGURATION}-#{device}/#{root_name}/#{module_name}.framework/#{module_name}"
device_framework_lib = File.dirname(device_lib)
simulator_lib = "#{build_dir}/#{CONFIGURATION}-#{simulator}/#{root_name}/#{module_name}.framework/#{module_name}"
# 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
return unless File.file?(device_lib) && File.file?(simulator_lib)
# output
lipo_log = `lipo -create -output #{executable_path} #{device_lib} #{simulator_lib}`
puts lipo_log unless File.exist?(executable_path)
FileUtils.mv executable_path, device_lib, :force => true
output_path.mkpath unless output_path.exist?
FileUtils.mv device_framwork_path, output_path, :force => true
FileUtils.mv device_framework_lib, output_path, :force => true
FileUtils.rm simulator_lib if File.file?(simulator_lib)
FileUtils.rm device_lib if File.file?(device_lib)
end
def xcodebuild(sandbox, target, sdk='macosx', deployment_target=nil, other_options=[])
@ -145,3 +124,4 @@ module Pod
end
end

View File

@ -30,8 +30,6 @@ def save_to_podfile(text):
def initial():
return (wrapper(
"""
keep_source_code_for_prebuilt_frameworks!
pod "Masonry"
"""),
"""
@ -41,29 +39,14 @@ import Masonry
def addSwiftPod():
return (wrapper(
"""
keep_source_code_for_prebuilt_frameworks!
pod "RxCocoa", :binary => true
pod "Masonry", :binary => true
pod "Literal", :binary => true
"""),
"""
import RxCocoa
import Masonry
import Literal
""")
def revertToSourceCode():
return (wrapper(
"""
keep_source_code_for_prebuilt_frameworks!
pod "RxCocoa", :binary => true
pod "Literal"
"""),
"""
import RxCocoa
import Literal
""")
def addDifferentNamePod():
return (wrapper(
"""
@ -138,5 +121,18 @@ import AFNetworking
if __name__ == "__main__":
arg = sys.argv[1]
print("===================\nchange Podfile to: " + arg + "\n")
save_to_podfile(globals()[arg]())
print("change Podfile to: " + arg)
if arg == "initial":
save_to_podfile(initial())
elif arg == "addSwiftPod":
save_to_podfile(addSwiftPod())
elif arg == "addDifferentNamePod":
save_to_podfile(addDifferentNamePod())
elif arg == "addSubPod":
save_to_podfile(addSubPod())
elif arg == "deleteAPod":
save_to_podfile(deleteAPod())
elif arg == "addVendoredLibPod":
save_to_podfile(addVendoredLibPod())
elif arg == "universalFlag":
save_to_podfile(universalFlag())

View File

@ -1,17 +0,0 @@
# update version
version = ARGV[0]
if version == nil
puts "please input a version"
exit
end
path = "lib/cocoapods-binary/gem_version.rb"
content = <<-eos
module CocoapodsBinary
VERSION = "#{version}"
end
eos
File.write(path, content)
`git add -A; git commit -m "bump version"; git push`
`rake install`
`gem push pkg/cocoapods-binary-#{version}.gem`

View File

@ -5,8 +5,6 @@ build() {
xcodebuild -workspace Binary.xcworkspace -scheme Binary ONLY_ACTIVE_ARCH=YES CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO -quiet || exit 1
}
rm -rf Pods
python change_podfile.py "initial"
pod install
build
@ -16,11 +14,6 @@ python change_podfile.py "addSwiftPod"
pod install
build
#
python change_podfile.py "revertToSourceCode"
pod install
build
#
python change_podfile.py "addDifferentNamePod"
pod install