diff --git a/.gitignore b/.gitignore index e69de29..af56f61 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1,2 @@ +.DS_Store +.idea/ diff --git a/README.md b/README.md index a917419..f2db7b8 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,11 @@ ### 更新 + +- 2021-01-12 + + v0.3.1.2 fix some bugs + - 2020-11-02 v0.3.0.11 支持纯Swift、纯Object-C、Swift-OC混编 diff --git a/cocoapods-imy-bin/cocoapods-imy-bin.gemspec b/cocoapods-imy-bin/cocoapods-imy-bin.gemspec index 7a86301..e20685b 100755 --- a/cocoapods-imy-bin/cocoapods-imy-bin.gemspec +++ b/cocoapods-imy-bin/cocoapods-imy-bin.gemspec @@ -22,7 +22,7 @@ Gem::Specification.new do |spec| spec.add_dependency 'parallel' spec.add_dependency 'cocoapods' - spec.add_dependency 'cocoapods-generate' + spec.add_dependency "cocoapods-generate",'~>2.0.1' spec.add_development_dependency 'bundler' spec.add_development_dependency 'rake' diff --git a/cocoapods-imy-bin/lib/cocoapods-imy-bin/command/bin/auto.rb b/cocoapods-imy-bin/lib/cocoapods-imy-bin/command/bin/auto.rb index 281f834..d6bc2ab 100755 --- a/cocoapods-imy-bin/lib/cocoapods-imy-bin/command/bin/auto.rb +++ b/cocoapods-imy-bin/lib/cocoapods-imy-bin/command/bin/auto.rb @@ -46,11 +46,14 @@ def initialize(argv) super end + def validate! + help! "未找到 podspec文件" unless @podspec + super + end + def run + @specification = Specification.from_file(@podspec) - unless @podspec - raise Informative, "未找到 podspec文件" - end sources_sepc = run_archive fail_push_specs = [] @@ -175,6 +178,7 @@ def spec_file #Dir.glob 可替代 def find_podspec + name = nil Pathname.pwd.children.each do |child| puts child if File.file?(child) @@ -186,6 +190,7 @@ def find_podspec end end end + return name end end diff --git a/cocoapods-imy-bin/lib/cocoapods-imy-bin/command/bin/local.rb b/cocoapods-imy-bin/lib/cocoapods-imy-bin/command/bin/local.rb deleted file mode 100755 index c7cd1f0..0000000 --- a/cocoapods-imy-bin/lib/cocoapods-imy-bin/command/bin/local.rb +++ /dev/null @@ -1,165 +0,0 @@ - -require 'cocoapods-imy-bin/native/podfile' -require 'cocoapods/command/gen' -require 'cocoapods/generate' -require 'cocoapods-imy-bin/helpers/local/local_framework_builder' -require 'cocoapods-imy-bin/helpers/local/local_library_builder' -require 'cocoapods-imy-bin/helpers/local/local_build_helper' -require 'cocoapods-imy-bin/helpers/spec_source_creator' -require 'cocoapods-imy-bin/config/config_builder' - -module Pod - class Command - class Bin < Command - class Local < Bin - self.summary = '根据podfile中信息 将本地已存在的组件静态包 归档,需要归档的组件由外部传入' - self.description = <<-DESC - 根据podfile中信息 将本地已存在的组件静态包 归档,需要归档的组件由外部传入 - 仅支持 iOS 平台 - 此静态 framework/.a 不包含依赖组件的 symbol - - 一个用ccache,一个是cocoapods-imy-bin插件支持下的, - 拿xcodebuild生成的中间构建产物,如生成的 libIMYYQHome.a,利用cocoapods-imy-bin 制作成二进制静态库,保存起来。 - 下次pod update 工程时,在pod update时去捞已经生成的二进制组件打包。这样可以大大减少编译时间 - - 制作流程: - 每次pod update 时记录无二进制组件的库,build完后,自动制作缺失二进制组件库。 - 如果pod update 时无二进制组件的库,采用源码编译,源码编译同时有ccache缓存支持,也能加快速度 - DESC - - def self.options - [ - ['--no-clean', '保留构建中间产物'], - ['--framework-output', '输出framework文件'], - ['--no-zip', '不压缩静态 framework 为 zip'], - ['--make-binary-specs', '需要制作spec集合'], - ['--env', "该组件上传的环境 %w[dev debug_iphoneos release_iphoneos]"] - ].concat(Pod::Command::Gen.options).concat(super).uniq - end - - def initialize(argv) - @env = argv.option('env') || 'dev' - CBin.config.set_configuration_env(@env) - UI.warn "====== cocoapods-imy-bin #{CBin::VERSION} 版本 ======== \n " - UI.warn "====== #{@env} 环境 ======== " - - - @make_binary_specs = argv.option('make-binary-specs') || [] - @framework_output = argv.flag?('framework-output', false) - @clean = argv.flag?('no-clean', true) - @zip = argv.flag?('zip', true) - @sources = argv.option('sources') || [] - @platform = Platform.new(:ios) - - @target_name = CBin::Config::Builder.instance.target_name - @local_build_dir_name = CBin::Config::Builder.instance.xcode_build_name - @local_build_dir = CBin::Config::Builder.instance.xcode_build_dir - - @framework_path - super - end - - def run - # 清除之前的缓存 - # temp = File.join(@local_build_dir, @platform.to_s) - # FileUtils.rm_r(temp) if File.exist? temp - # if File.exist?(CBin::Config::Builder.instance.zip_dir) - # FileUtils.rm_rf(Dir.glob("#{CBin::Config::Builder.instance.zip_dir}/*")) - # end - - sources_spec = [] - Dir.chdir(CBin::Config::Builder.instance.local_psec_dir) do - spec_files = Dir.glob(%w[*.json *.podspec]) - spec_files.each do |file| - spec = Pod::Specification.from_file(file) - sources_spec << spec - end - end - - build(sources_spec) - end - - def build(make_binary_specs) - # 如果没要求,就清空依赖库数据 - sources_sepc = [] - make_binary_specs.uniq.each do |spec| - next if spec.name.include?('/') - next if spec.name == @target_name - #过滤白名单 - next if CBin::Config::Builder.instance.white_pod_list.include?(spec.name) - #过滤 git - if spec.source[:git] && spec.source[:git] - spec_git = spec.source[:git] - spec_git_res = false - CBin::Config::Builder.instance.ignore_git_list.each do |ignore_git| - spec_git_res = spec_git.include?(ignore_git) - break if spec_git_res - end - next if spec_git_res - end - UI.warn "#{spec.name}.podspec 带有 vendored_frameworks 字段,请检查是否有效!!!" if spec.attributes_hash['vendored_frameworks'] - next if spec.attributes_hash['vendored_frameworks'] && @target_name != spec.name #过滤带有vendored_frameworks的 - next if (spec.attributes_hash['ios'] && spec.attributes_hash['ios']['vendored_frameworks']) #过滤带有vendored_frameworks的 - #获取没有制作二进制版本的spec集合 - - next unless library_exist(spec) - - # 获取没有制作二进制版本的spec集合 - sources_sepc << spec - end - - fail_build_specs = [] - sources_sepc.uniq.each do |spec| - begin - builder = CBin::LocalBuild::Helper.new(spec, - @platform, - @framework_output, - @zip, - @clean, - @target_name, - @local_build_dir_name, - @local_build_dir) - builder.build - CBin::Upload::Helper.new(spec, @code_dependencies, @sources).upload - rescue StandardError - fail_build_specs << spec - end - end - - if fail_build_specs.any? - fail_build_specs.uniq.each do |spec| - UI.warn "【#{spec.name} | #{spec.version}】组件二进制版本编译失败 ." - end - end - - success_specs = sources_sepc - fail_build_specs - if success_specs.any? - success_specs.uniq.each do |spec| - UI.warn " =======【 #{spec.name} | #{spec.version} 】二进制组件制作完成 !!!" - end - end - # pod repo update - UI.section("\nUpdating Spec Repositories\n".yellow) do - Pod::Command::Bin::Repo::Update.new(CLAide::ARGV.new([])).run - end - end - - private - - def library_exist(spec) - File.exist?(File.join(@local_build_dir, "lib#{spec.name}.a")) || is_framework(spec) - end - # 使用了user_framework 会有#{@spec.name}.framework - # 未使用的 需要判断文件 - def is_framework(spec) - res = File.exist?(File.join(@local_build_dir, "#{spec.name}.framework")) - unless res - res = File.exist?(File.join(CBin::Config::Builder.instance.xcode_BuildProductsPath_dir, "#{spec.name}","Swift Compatibility Header")) - end - res - end - - end - end - end -end diff --git a/cocoapods-imy-bin/lib/cocoapods-imy-bin/gem_version.rb b/cocoapods-imy-bin/lib/cocoapods-imy-bin/gem_version.rb index bb68fb3..0e0dada 100755 --- a/cocoapods-imy-bin/lib/cocoapods-imy-bin/gem_version.rb +++ b/cocoapods-imy-bin/lib/cocoapods-imy-bin/gem_version.rb @@ -1,6 +1,6 @@ module CBin - VERSION = '0.3.0.12' + VERSION = '0.3.1.2' end module Pod diff --git a/cocoapods-imy-bin/lib/cocoapods-imy-bin/helpers/local/loca_llibrary.rb b/cocoapods-imy-bin/lib/cocoapods-imy-bin/helpers/local/loca_llibrary.rb deleted file mode 100644 index 6f486cf..0000000 --- a/cocoapods-imy-bin/lib/cocoapods-imy-bin/helpers/local/loca_llibrary.rb +++ /dev/null @@ -1,57 +0,0 @@ - - -# copy from https://github.com/CocoaPods/cocoapods-packager -require 'cocoapods-imy-bin/config/config_builder' - -module CBin - class LocalLibrary - attr_reader :headers_path - attr_reader :resources_path - attr_reader :root_path - attr_reader :versions_path - attr_reader :name_path - - def initialize(name, platform, version) - @name = name - @platform = platform - @version = version - end - - def make - make_root - make_library - make_headers - make_resources - end - - def delete_resources - Pathname.new(@resources_path).rmtree - (Pathname.new(@fwk_path) + Pathname.new('Resources')).delete - end - - private - - def make_library - @name_path = CBin::Config::Builder.instance.library_name_version(@name, @version) - @fwk_path = @root_path + Pathname.new(@name_path) - @fwk_path.mkdir unless @fwk_path.exist? - - @versions_path = @fwk_path - end - - def make_headers - @headers_path = @versions_path + Pathname.new('Headers') - # @headers_path.mkpath unless @headers_path.exist? - end - - def make_resources - @resources_path = @versions_path + Pathname.new('Resources') - # @resources_path.mkpath unless @resources_path.exist? - end - - def make_root - @root_path = Pathname.new(@platform) - @root_path.mkpath unless @root_path.exist? - end - end -end diff --git a/cocoapods-imy-bin/lib/cocoapods-imy-bin/helpers/local/local_build_helper.rb b/cocoapods-imy-bin/lib/cocoapods-imy-bin/helpers/local/local_build_helper.rb deleted file mode 100755 index fa65e35..0000000 --- a/cocoapods-imy-bin/lib/cocoapods-imy-bin/helpers/local/local_build_helper.rb +++ /dev/null @@ -1,178 +0,0 @@ - - -# copy from https://github.com/CocoaPods/cocoapods-packager - -require 'cocoapods-imy-bin/native/podfile' -require 'cocoapods/command/gen' -require 'cocoapods/generate' -require 'cocoapods-imy-bin/helpers/framework_builder' -require 'cocoapods-imy-bin/helpers/library_builder' -require 'cocoapods-imy-bin/config/config_builder' - -module CBin - class LocalBuild - class Helper - include Pod -#class var - @@build_defines = "" -#Debug下还待完成 - def initialize(spec, - platform, - framework_output, - zip, - clean, - target_name, - local_build_dir_name, - local_build_dir) - @spec = spec - @target_name = target_name - @platform = platform - - @framework_output = framework_output - @zip = zip - @local_build_dir_name = local_build_dir_name - @local_build_dir = local_build_dir - @clean = clean - @framework_path - @is_library = !is_framework - end - - def build - UI.section("Building static framework #{@spec}") do - - build_static_framework - if @is_library - build_static_library - zip_static_framework if @zip &&= @framework_output - zip_static_library - else - zip_static_framework - end - - clean_workspace if @clean - end - - end - - def build_static_framework - file_accessor = Sandbox::FileAccessor.new(Pathname.new('.').expand_path, @spec.consumer(@platform)) - Dir.chdir(workspace_directory) do - builder = CBin::LocalFramework::Builder.new(@spec, file_accessor, @platform, @local_build_dir_name,@local_build_dir, @is_library, frameWork_dir) - @framework_path = builder.create - end - end - - def build_static_library - source_dir = zip_dir - file_accessor = Sandbox::FileAccessor.new(Pathname.new('.').expand_path, @spec.consumer(@platform)) - Dir.chdir(workspace_directory) do - builder = CBin::LocalLibrary::Builder.new(@spec, file_accessor, @platform, source_dir,@framework_path) - builder.build - end - end - - def zip_static_framework - Dir.chdir(zip_dir) do - # output_name = "#{framework_name}.zip" - output_name = File.join(zip_dir, framework_name_zip) - unless File.exist?(framework_name) - UI.warn "没有需要压缩的 framework 文件:#{framework_name}" - end - - UI.puts "Compressing #{framework_name} into #{output_name}" - `zip --symlinks -r #{output_name} #{framework_name}` - - end - end - - def zip_static_library - Dir.chdir(zip_dir) do - output_library = "#{library_name}.zip" - unless File.exist?(library_name) - raise Informative, "没有需要压缩的 library 文件:#{library_name}" - end - - UI.puts "Compressing #{library_name} into #{output_library}" - - `zip --symlinks -r #{output_library} #{library_name}` - end - - end - - - def clean_workspace - UI.puts 'Cleaning workspace' - - FileUtils.rm_rf(gen_name) - Dir.chdir(zip_dir) do - FileUtils.rm_rf(framework_name) if @zip - FileUtils.rm_rf(library_name) - FileUtils.rm_rf(framework_name) unless @framework_output - FileUtils.rm_rf("#{framework_name}.zip") unless @framework_output - end - end - - def framework_name - CBin::Config::Builder.instance.framework_name(@spec) - end - - def framework_name_zip - CBin::Config::Builder.instance.framework_name_version(@spec) + ".zip" - end - - def library_name - CBin::Config::Builder.instance.library_name(@spec) - end - - def workspace_directory - @local_build_dir - end - - def zip_dir - CBin::Config::Builder.instance.zip_dir - end - - def gen_name - CBin::Config::Builder.instance.gen_name - end - - def is_library - File.exist?(File.join(@local_build_dir, "lib#{@spec.name}.a")) - end - - # 使用了user_framework 会有#{@spec.name}.framework - # 未使用的 需要判断文件 - def is_framework - res = File.exist?(File.join(@local_build_dir, "#{@spec.name}.framework")) - unless res - res = File.exist?(File.join(CBin::Config::Builder.instance.xcode_BuildProductsPath_dir, "#{@spec.name}","Swift Compatibility Header")) - end - res - end - - def frameWork_dir - dir = File.join(@local_build_dir, "#{@spec.name}.framework") - unless File.exist?(dir) - dir = File.join(CBin::Config::Builder.instance.xcode_BuildProductsPath_dir, "#{@spec.name}") - end - dir - end - - def spec_file - @spec_file ||= begin - if @podspec - find_spec_file(@podspec) - else - if code_spec_files.empty? - raise Informative, '当前目录下没有找到可用源码 podspec.' - end - - spec_file = code_spec_files.first - spec_file - end - end - end - - end - end -end diff --git a/cocoapods-imy-bin/lib/cocoapods-imy-bin/helpers/local/local_framework.rb b/cocoapods-imy-bin/lib/cocoapods-imy-bin/helpers/local/local_framework.rb deleted file mode 100755 index 02f993c..0000000 --- a/cocoapods-imy-bin/lib/cocoapods-imy-bin/helpers/local/local_framework.rb +++ /dev/null @@ -1,85 +0,0 @@ - - -# copy from https://github.com/CocoaPods/cocoapods-packager - -module CBin - class LocalFramework - attr_reader :headers_path - attr_reader :module_map_path - attr_reader :resources_path - attr_reader :root_path - attr_reader :versions_path - attr_reader :swift_module_path - attr_reader :fwk_path - - def initialize(name, platform, local_build_dir) - @name = name - @platform = platform - @local_build_dir = local_build_dir - end - - def make - make_root - make_framework - make_headers - make_resources - make_current_version - end - - def delete_resources - Pathname.new(@resources_path).rmtree - (Pathname.new(@fwk_path) + Pathname.new('Resources')).delete - end - - def remove_current_version - FileUtils.rm_f(File.join(@fwk_path,@name)) - FileUtils.rm_f(File.join(@fwk_path,"Headers")) - FileUtils.rm_f(File.join(@fwk_path,"Resources")) - - FileUtils.cp_r("#{@versions_path}/.", @fwk_path) - # FileUtils.remove_dir(@versions_path) - FileUtils.remove_dir("#{@fwk_path}/Versions") - - # current_version_path = @versions_path + Pathname.new('../Current') - # `ln -sf A #{current_version_path}` - # `ln -sf Versions/Current/Headers #{@fwk_path}/` - # `ln -sf Versions/Current/Resources #{@fwk_path}/` - # `ln -sf Versions/Current/#{@name} #{@fwk_path}/` - end - private - - def make_current_version - current_version_path = @versions_path + Pathname.new('../Current') - `ln -sf A #{current_version_path}` - `ln -sf Versions/Current/Headers #{@fwk_path}/` - `ln -sf Versions/Current/Resources #{@fwk_path}/` - `ln -sf Versions/Current/#{@name} #{@fwk_path}/` - end - - def make_framework - @fwk_path = @root_path + Pathname.new(@name + '.framework') - FileUtils.remove_dir(@fwk_path) if @fwk_path.exist? - @fwk_path.mkdir unless @fwk_path.exist? - - @module_map_path = @fwk_path + Pathname.new('Modules') - @versions_path = @fwk_path + Pathname.new('Versions/A') - @fwk_path.exist? - @swift_module_path = @module_map_path + Pathname.new(@name + '.swiftmodule') - end - - def make_headers - @headers_path = @versions_path + Pathname.new('Headers') - @headers_path.mkpath unless @headers_path.exist? - end - - def make_resources - @resources_path = @versions_path + Pathname.new('Resources') - @resources_path.mkpath unless @resources_path.exist? - end - - def make_root - @root_path = Pathname.new(File.join(@local_build_dir, @platform)) - @root_path.mkpath unless @root_path.exist? - end - end -end diff --git a/cocoapods-imy-bin/lib/cocoapods-imy-bin/helpers/local/local_framework_builder.rb b/cocoapods-imy-bin/lib/cocoapods-imy-bin/helpers/local/local_framework_builder.rb deleted file mode 100755 index 99f2a3f..0000000 --- a/cocoapods-imy-bin/lib/cocoapods-imy-bin/helpers/local/local_framework_builder.rb +++ /dev/null @@ -1,227 +0,0 @@ - - -# copy from https://github.com/CocoaPods/cocoapods-packager - -require 'cocoapods-imy-bin/helpers/local/local_framework' -require 'English' -require 'cocoapods-imy-bin/config/config_builder' -require 'shellwords' - -module CBin - class LocalFramework - class Builder - include Pod -#Debug下还待完成 - def initialize(spec, file_accessor, platform, local_build_dir_name, local_build_dir, is_library = true, framework_BuildProductsPath = "") - @spec = spec - @file_accessor = file_accessor - @platform = platform - @local_build_dir_name = local_build_dir_name - @local_build_dir = local_build_dir - @is_library = is_library - @framework_BuildProductsPath = framework_BuildProductsPath - end - - def create - begin - #如果是.a 文件, 或者 swift下,是.a文件的 - if @is_library || (!@is_library && @framework_BuildProductsPath != framework_name) - - UI.section("Building static library #{@spec}") do - output = framework.versions_path + Pathname.new(@spec.name) - build_static_library_for_ios(output) - res = copy_headers - # maybe fails for copy_headers - if res - copy_resources - cp_to_source_dir - else - FileUtils.remove_dir(framework.fwk_path) if File.exist?(framework.fwk_path) - return nil - end - end - - else - UI.section("Building static framework #{@spec}") do - output = File.join(CBin::Config::Builder.instance.zip_dir,"#{@spec.name}.framework") - build_static_framework_for_ios(output) - end - end - - rescue StandardError - UI.warn "【#{spec.name} | #{spec.version}】组件二进制版本组装失败 ." - end - - framework - end - - private - - def cp_to_source_dir - # 删除Versions 软链接 - framework.remove_current_version if CBin::Build::Utils.is_swift_module(@spec) - - target_dir = File.join(CBin::Config::Builder.instance.root_dir,CBin::Config::Builder.instance.framework_file(@spec)) - FileUtils.rm_rf(target_dir) if File.exist?(target_dir) - - zip_dir = CBin::Config::Builder.instance.zip_dir - FileUtils.mkdir_p(zip_dir) unless File.exist?(zip_dir) - - `cp -fa #{@platform}/#{CBin::Config::Builder.instance.framework_name(@spec)} #{target_dir}` - end - - - def copy_headers - #by slj 如果没有头文件,去 "Headers/Public"拿 - # if public_headers.empty? - Dir.chdir(File.join(Pod::Config.instance.installation_root,'Pods')) do - - if File.exist?("./Headers/Public/#{@spec.name}") - #走 podsepc中的public_headers - public_headers = Array.new - - Dir.chdir("./Headers/Public/#{@spec.name}") do - headers = Dir.glob('*.h') - headers.each do |h| - public_headers << Pathname.new(File.join(Dir.pwd,h)) - end - end - - UI.message "Copying public headers #{public_headers.map(&:basename).map(&:to_s)}" - - public_headers.each do |h| - `ditto #{h} #{framework.headers_path}/#{h.basename}` - end - - # If custom 'module_map' is specified add it to the framework distribution - # otherwise check if a header exists that is equal to 'spec.name', if so - # create a default 'module_map' one using it. - if !@spec.module_map.nil? - module_map_file = @file_accessor.module_map - if Pathname(module_map_file).exist? - module_map = File.read(module_map_file) - end - elsif public_headers.map(&:basename).map(&:to_s).include?("#{@spec.name}-umbrella.h") - module_map = <<-MAP - framework module #{@spec.name} { - umbrella header "#{@spec.name}-umbrella.h" - - export * - module * { export * } - } - MAP - end - - unless module_map.nil? - UI.message "Writing module map #{module_map}" - unless framework.module_map_path.exist? - framework.module_map_path.mkpath - end - File.write("#{framework.module_map_path}/module.modulemap", module_map) - - # unless framework.swift_module_path.exist? - # framework.swift_module_path.mkpath - # end - # DO BuildProductsPath swiftModule拷贝到 framework.swift_module_path - swiftmodule_path = File.join(@framework_BuildProductsPath, "#{@spec.name}.swiftmodule") - if File.directory?(swiftmodule_path) - FileUtils.cp_r("#{swiftmodule_path}/.", framework.swift_module_path) - end - swift_Compatibility_Header = "#{@framework_BuildProductsPath}/Swift\ Compatibility\ Header/#{@spec.name}-Swift.h" - FileUtils.cp(swift_Compatibility_Header,framework.headers_path) if File.exist?(swift_Compatibility_Header) - info_plist_file = File.join(File.dirname(File.dirname(__FILE__)),"info.plist") - FileUtils.cp(info_plist_file,framework.fwk_path) - end - else - UI.warn "== Headers/Public/#{@spec.name} no exist" - return false - end - - end - return true - end - - def copy_resources - - - Dir.chdir(Pod::Config.instance.sandbox_root) do - - bundles = Dir.glob('./build/*.bundle') - - bundle_names = [@spec, *@spec.recursive_subspecs].flat_map do |spec| - consumer = spec.consumer(@platform) - consumer.resource_bundles.keys + - consumer.resources.map do |r| - File.basename(r, '.bundle') if File.extname(r) == 'bundle' - end - end.compact.uniq - - bundles.select! do |bundle| - bundle_name = File.basename(bundle, '.bundle') - bundle_names.include?(bundle_name) - end - - if bundles.count > 0 - UI.message "Copying bundle files #{bundles}" - bundle_files = bundles.join(' ') - `cp -rp #{bundle_files} #{framework.resources_path} 2>&1` - end - - real_source_dir = @spec.name - resources = [@spec, *@spec.recursive_subspecs].flat_map do |spec| - expand_paths(real_source_dir, spec.consumer(@platform).resources) - end.compact.uniq - - if (resources.count == 0 || (resources.count == 1 && resources[0].count == 0)) && bundles.count == 0 - framework.delete_resources - return - end - - if resources.count > 0 - #把 路径转义。 避免空格情况下拷贝失败 - escape_resource = [] - resources.each do |source| - escape_resource << Shellwords.join(source) - end - UI.message "Copying resources #{escape_resource}" - `cp -rp #{escape_resource.join(' ')} #{framework.resources_path}` - end - - end - - end - - - def build_static_library_for_ios(output) - `cp -rp #{library_name} #{output}` - end - - def build_static_framework_for_ios(output) - FileUtils.cp_r(framework_name, output) - end - - def library_name - File.join(@local_build_dir, "lib#{@spec.name}.a") - end - - def framework_name - File.join(@local_build_dir, "#{@spec.name}.framework") - end - - def expand_paths(source_dir, path_specs) - path_specs.map do |path_spec| - Dir.glob(File.join(source_dir, path_spec)) - end - end - - def framework - @framework ||= begin - framework = CBin::LocalFramework.new(@spec.name, @platform.name.to_s,@local_build_dir) - framework.make - framework - end - end - - end - end -end diff --git a/cocoapods-imy-bin/lib/cocoapods-imy-bin/helpers/local/local_library_builder.rb b/cocoapods-imy-bin/lib/cocoapods-imy-bin/helpers/local/local_library_builder.rb deleted file mode 100644 index 09b620b..0000000 --- a/cocoapods-imy-bin/lib/cocoapods-imy-bin/helpers/local/local_library_builder.rb +++ /dev/null @@ -1,92 +0,0 @@ - - - -# copy from https://github.com/CocoaPods/cocoapods-packager - -require 'cocoapods-imy-bin/helpers/framework.rb' -require 'cocoapods-imy-bin/helpers/library.rb' - -require 'English' - -module CBin - class LocalLibrary - class Builder - include Pod - - def initialize(spec, file_accessor, platform, source_dir,framework_path) - @spec = spec - @source_dir = source_dir - @file_accessor = file_accessor - @platform = platform - @framework = framework_path - @source_files = "#{@source_dir}/#{library.name_path}" - @source_zip_file = "#{@source_files}.zip" - end - - def build - UI.section("Building static library #{@spec}") do - - clean_source_dir - - copy_headers - copy_library - copy_resources - - cp_to_source_dir - end - end - - private - - def clean_source_dir - FileUtils.rm_rf(@source_files) if File.exist?(@source_files) - FileUtils.rm_rf(@source_zip_file) if File.exist?(@source_zip_file) - end - - def cp_to_source_dir - target_dir = library.versions_path - dest_file = "#{@source_dir}/#{library.name_path}" - FileUtils.rm_rf(dest_file) if File.exist?(dest_file) - - `cp -fa #{target_dir} #{dest_file}/` - end - - def copy_headers - FileUtils.cp_r(framework.headers_path,library.versions_path) if File.exist?(framework.headers_path) - end - - def copy_library - src_file = "#{framework.versions_path}/#{@spec.name}" - unless File.exist?(src_file) - raise Informative, "framework没有文件:#{src_file}" - end - - dest_file = "#{library.versions_path}/#{@spec.name}" - rename_dest_file = "#{library.versions_path}/lib#{@spec.name}.a" - FileUtils.cp_r(src_file,dest_file) - File.rename(dest_file, rename_dest_file ) if File.exist?(dest_file) - end - - def copy_resources - FileUtils.cp_r(framework.resources_path,library.versions_path) if File.exist?(framework.resources_path) - end - - - def framework - @framework ||= begin - framework = Framework.new(@spec.name, @platform.name.to_s) - framework.make - framework - end - end - - def library - @library ||= begin - library = Library.new(@spec.name, @platform.name.to_s,@spec.version) - library.make - library - end - end - end - end -end