Compare commits
28 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0cfa27a897 | ||
|
|
d5c0101154 | ||
|
|
5dc20e3c98 | ||
|
|
a60a69d9f4 | ||
|
|
8eae79faa4 | ||
|
|
30cbf7f1c5 | ||
|
|
33ae8908bd | ||
|
|
02383b2538 | ||
|
|
551d99c5d8 | ||
|
|
75f0ae9f2b | ||
|
|
671ebddf20 | ||
|
|
5962d88538 | ||
|
|
33ca8d6705 | ||
|
|
2da0a792bc | ||
|
|
a1e1e7e4a1 | ||
|
|
5518f6aea9 | ||
|
|
0918862b76 | ||
|
|
2d6bf20255 | ||
|
|
6307bf8053 | ||
|
|
fa30f903c0 | ||
|
|
c0a6ebc885 | ||
|
|
950433eb6a | ||
|
|
62eb348180 | ||
|
|
9f737d85cd | ||
|
|
c0c2ddb0e8 | ||
|
|
5c4b3630b7 | ||
|
|
5976dc4abc | ||
|
|
50e3a5b373 |
@ -9,6 +9,7 @@ script:
|
||||
- rake install
|
||||
- cd test
|
||||
- sh test.sh
|
||||
- cd ..
|
||||
|
||||
# auto deploy on tagging
|
||||
# automatically set by `travis setup rubygems`
|
||||
|
||||
@ -55,8 +55,11 @@ 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
|
||||
|
||||
@ -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 child.extname == ".framework"
|
||||
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?
|
||||
@ -167,6 +167,32 @@ 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
|
||||
@ -217,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
|
||||
@ -227,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
|
||||
|
||||
@ -17,12 +17,22 @@ 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
|
||||
@ -54,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
|
||||
@ -70,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
|
||||
|
||||
|
||||
@ -83,17 +83,6 @@ 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|
|
||||
@ -137,10 +126,11 @@ 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
|
||||
@ -177,16 +167,34 @@ module Pod
|
||||
end
|
||||
|
||||
# Remove useless files
|
||||
# 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)
|
||||
# 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
|
||||
end
|
||||
to_delete_files.each do |path|
|
||||
useless_names.each do |name|
|
||||
path = sandbox.framework_folder_path_for_pod_name(name)
|
||||
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
|
||||
|
||||
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
module CocoapodsBinary
|
||||
VERSION = "0.3.5"
|
||||
VERSION = "0.4.2"
|
||||
end
|
||||
|
||||
@ -11,13 +11,16 @@ 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)
|
||||
|
||||
@ -38,5 +38,12 @@ 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
|
||||
|
||||
@ -24,29 +24,50 @@ def build_for_iosish_platform(sandbox,
|
||||
|
||||
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=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)
|
||||
|
||||
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}"
|
||||
# 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
|
||||
|
||||
return unless File.file?(device_lib) && File.file?(simulator_lib)
|
||||
# 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
|
||||
|
||||
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
|
||||
output_path.mkpath unless output_path.exist?
|
||||
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)
|
||||
FileUtils.mv device_framwork_path, output_path, :force => true
|
||||
|
||||
end
|
||||
|
||||
def xcodebuild(sandbox, target, sdk='macosx', deployment_target=nil, other_options=[])
|
||||
@ -124,4 +145,3 @@ module Pod
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -30,6 +30,8 @@ def save_to_podfile(text):
|
||||
def initial():
|
||||
return (wrapper(
|
||||
"""
|
||||
keep_source_code_for_prebuilt_frameworks!
|
||||
|
||||
pod "Masonry"
|
||||
"""),
|
||||
"""
|
||||
@ -39,14 +41,29 @@ import Masonry
|
||||
def addSwiftPod():
|
||||
return (wrapper(
|
||||
"""
|
||||
pod "Masonry", :binary => true
|
||||
keep_source_code_for_prebuilt_frameworks!
|
||||
|
||||
pod "RxCocoa", :binary => true
|
||||
pod "Literal", :binary => true
|
||||
"""),
|
||||
"""
|
||||
import Masonry
|
||||
import RxCocoa
|
||||
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(
|
||||
"""
|
||||
@ -121,18 +138,5 @@ import AFNetworking
|
||||
|
||||
if __name__ == "__main__":
|
||||
arg = sys.argv[1]
|
||||
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())
|
||||
print("===================\nchange Podfile to: " + arg + "\n")
|
||||
save_to_podfile(globals()[arg]())
|
||||
17
test/release_version.rb
Normal file
17
test/release_version.rb
Normal file
@ -0,0 +1,17 @@
|
||||
# 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`
|
||||
@ -5,6 +5,8 @@ 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
|
||||
@ -14,6 +16,11 @@ python change_podfile.py "addSwiftPod"
|
||||
pod install
|
||||
build
|
||||
|
||||
#
|
||||
python change_podfile.py "revertToSourceCode"
|
||||
pod install
|
||||
build
|
||||
|
||||
#
|
||||
python change_podfile.py "addDifferentNamePod"
|
||||
pod install
|
||||
|
||||
Loading…
Reference in New Issue
Block a user