Skip to content

Commit

Permalink
fix: header module path find error
Browse files Browse the repository at this point in the history
  • Loading branch information
dabing1022 committed Jan 19, 2021
1 parent e923621 commit 40ee28c
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 38 deletions.
Binary file added cocoapods-imy-bin/cocoapods-imy-bin-0.3.1.2.gem
Binary file not shown.
37 changes: 26 additions & 11 deletions cocoapods-imy-bin/lib/cocoapods-imy-bin/helpers/build_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,35 @@ def Utils.is_framework(spec)
end

def Utils.spec_header_dir(spec)
spec_header_dir = "./Headers/Public/#{spec.name}"

unless File.exist?(spec_header_dir)
spec_header_dir = "./Pods/Headers/Public/#{spec.name}"
end
header_dir = "./Headers/Public/#{spec.name}"
header_dir = "./Pods/Headers/Public/#{spec.name}" unless File.exist?(header_dir)

unless File.exist?(spec_header_dir)
unless File.exist?(header_dir)
# 一些库名称中使用了中划线如AAA-BBB,public header中库名称会默认处理成下划线AAA_BBB
module_name = spec.name.gsub("-", "_")
spec_header_dir = "./Pods/Headers/Public/#{module_name}"
header_dir = "./Pods/Headers/Public/#{module_name}"
end

# 暂时只支持:ios
consumer = Pod::Specification::Consumer.new(spec, :ios)
unless consumer.header_dir.nil?
header_dir = File.join(header_dir, consumer.header_dir)
end

header_dir
end

def Utils.spec_module_dir(spec)
if spec.module_name.nil?
module_dir = "./Headers/Public/#{spec.name}"
module_dir = "./Pods/Headers/Public/#{spec.name}" unless File.exist?(module_dir)
else
module_dir = "./Headers/Public/#{spec.module_name}"
module_dir = "./Pods/Headers/Public/#{spec.module_name}" unless File.exist?(module_dir)
end

spec_header_dir
module_dir
end

def Utils.is_swift_module(spec)
Expand All @@ -37,10 +53,9 @@ def Utils.is_swift_module(spec)
#auto 走这里
if File.exist?(dir)
Dir.chdir(dir) do
spec_header_dir = Utils.spec_header_dir(spec)
return false unless File.exist?(spec_header_dir)

is_framework = File.exist?(File.join(spec_header_dir, "#{spec.name}-umbrella.h"))
spec_module_dir = Utils.spec_module_dir(spec)
return false unless File.exist?(spec_module_dir)
is_framework = File.exist?(File.join(spec_module_dir, "#{spec.name}-umbrella.h"))
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module CBin
class Framework
class Builder
include Pod
#Debug下还待完成
#Debug下还待完成
def initialize(spec, file_accessor, platform, source_dir, isRootSpec = true, build_model="Debug")
@spec = spec
@source_dir = source_dir
Expand Down Expand Up @@ -93,22 +93,22 @@ def build_static_library_for_ios(output)
UI.message "Building ios libraries with archs #{ios_architectures}"
static_libs = static_libs_in_sandbox('build') + static_libs_in_sandbox('build-simulator') + @vendored_libraries
# if is_debug_model
ios_architectures.map do |arch|
static_libs += static_libs_in_sandbox("build-#{arch}") + @vendored_libraries
end
ios_architectures_sim do |arch|
static_libs += static_libs_in_sandbox("build-#{arch}") + @vendored_libraries
end
ios_architectures.map do |arch|
static_libs += static_libs_in_sandbox("build-#{arch}") + @vendored_libraries
end
ios_architectures_sim do |arch|
static_libs += static_libs_in_sandbox("build-#{arch}") + @vendored_libraries
end
# end

build_path = Pathname("build")
build_path.mkpath unless build_path.exist?

# if is_debug_model
libs = (ios_architectures + ios_architectures_sim) .map do |arch|
library = "build-#{arch}/lib#{@spec.name}.a"
library
end
libs = (ios_architectures + ios_architectures_sim) .map do |arch|
library = "build-#{arch}/lib#{@spec.name}.a"
library
end
# else
# libs = ios_architectures.map do |arch|
# library = "build/package-#{@spec.name}-#{arch}.a"
Expand Down Expand Up @@ -163,13 +163,13 @@ def compile

options = ios_build_options
# if is_debug_model
archs = ios_architectures
# archs = %w[arm64 armv7 armv7s]
archs.map do |arch|
xcodebuild(defines, "ARCHS=\'#{arch}\' OTHER_CFLAGS=\'-fembed-bitcode -Qunused-arguments\'","build-#{arch}",@build_model)
end
archs = ios_architectures
# archs = %w[arm64 armv7 armv7s]
archs.map do |arch|
xcodebuild(defines, "ARCHS=\'#{arch}\' OTHER_CFLAGS=\'-fembed-bitcode -Qunused-arguments\'","build-#{arch}",@build_model)
end
# else
# xcodebuild(defines,options)
# xcodebuild(defines,options)
# end

defines
Expand Down Expand Up @@ -253,8 +253,8 @@ module * { export * }
MAP
else
# by ChildhoodAndy
# try to read modulemap file from public header
module_map_file = File.join(spec_header_dir, "#{@spec.name}.modulemap")
# try to read modulemap file from module dir
module_map_file = File.join(CBin::Build::Utils.spec_module_dir(@spec), "#{@spec.name}.modulemap")
if Pathname(module_map_file).exist?
module_map = File.read(module_map_file)
end
Expand Down Expand Up @@ -285,9 +285,9 @@ def copy_resources
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
consumer.resources.map do |r|
File.basename(r, '.bundle') if File.extname(r) == 'bundle'
end
end.compact.uniq

bundles.select! do |bundle|
Expand All @@ -300,7 +300,7 @@ def copy_resources
bundle_files = bundles.join(' ')
`cp -rp #{bundle_files} #{framework.resources_path} 2>&1`
end

real_source_dir = @source_dir
unless @isRootSpec
spec_source_dir = File.join(Dir.pwd,"#{@spec.name}")
Expand Down Expand Up @@ -339,10 +339,10 @@ def expand_paths(source_dir, path_specs)

def framework
@framework ||= begin
framework = Framework.new(@spec.name, @platform.name.to_s)
framework.make
framework
end
framework = Framework.new(@spec.name, @platform.name.to_s)
framework.make
framework
end
end


Expand Down

0 comments on commit 40ee28c

Please sign in to comment.