Class: Luna::Binary::Build
- Inherits:
-
Object
- Object
- Luna::Binary::Build
- Defined in:
- lib/luna/binary/build.rb
Instance Attribute Summary collapse
-
#scheme ⇒ Object
Returns the value of attribute scheme.
-
#workspace ⇒ Object
Returns the value of attribute workspace.
Instance Method Summary collapse
- #binary_path_arm ⇒ Object
- #binary_path_merged ⇒ Object
- #binary_path_x86 ⇒ Object
- #command(c) ⇒ Object
- #createFrameworks ⇒ Object
- #findFramework(moduleName, binary_path) ⇒ Object
-
#initialize ⇒ Build
constructor
A new instance of Build.
- #lockfile ⇒ Object
- #mergeFrameWork(moduleName, path1, path2) ⇒ Object
- #mergeFrameWorks(binary_path_arm, binary_path_x86) ⇒ Object
- #run ⇒ Object
- #xcodeSimulators ⇒ Object
Constructor Details
#initialize ⇒ Build
Returns a new instance of Build.
14 15 16 |
# File 'lib/luna/binary/build.rb', line 14 def initialize end |
Instance Attribute Details
#scheme ⇒ Object
Returns the value of attribute scheme.
13 14 15 |
# File 'lib/luna/binary/build.rb', line 13 def scheme @scheme end |
#workspace ⇒ Object
Returns the value of attribute workspace.
12 13 14 |
# File 'lib/luna/binary/build.rb', line 12 def workspace @workspace end |
Instance Method Details
#binary_path_arm ⇒ Object
96 97 98 |
# File 'lib/luna/binary/build.rb', line 96 def binary_path_arm return Luna::Binary::Common.instance.binary_path_arm end |
#binary_path_merged ⇒ Object
92 93 94 |
# File 'lib/luna/binary/build.rb', line 92 def binary_path_merged return Luna::Binary::Common.instance.binary_path_merged end |
#binary_path_x86 ⇒ Object
100 101 102 |
# File 'lib/luna/binary/build.rb', line 100 def binary_path_x86 return Luna::Binary::Common.instance.binary_path_x86 end |
#command(c) ⇒ Object
22 23 24 |
# File 'lib/luna/binary/build.rb', line 22 def command(c) return Luna::Binary::Common.instance.command(c) end |
#createFrameworks ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/luna/binary/build.rb', line 26 def createFrameworks isNext = true Pod::UserInterface.puts "请将二进制开关关闭,确保每个模块都是源码运行,因为二进制的因素有可能source缓存还是会引入二进制".yellow command("rm -rf #{Dir.pwd}/Pods") isNext = command("pod install") Luna::Binary::Common.instance.deleteDirectory(binary_path_arm) tempLunaUploaderPath = Luna::Binary::Common.instance.tempLunaUploaderPath isNext = command("xcodebuild -workspace #{workspace} -scheme #{scheme} -configuration Debug -derivedDataPath '#{tempLunaUploaderPath}/build/arm/temp'") if isNext == true isNext = command("cp -r #{tempLunaUploaderPath}/build/arm/temp/Build/Products #{binary_path_arm}") if isNext == true #本可以用CONFIGURATION_BUILD_DIR直接指定结果文件夹,结果经常性的编译报错 Luna::Binary::Common.instance.deleteDirectory(binary_path_x86) isNext = command("xcodebuild -workspace #{workspace} -scheme #{scheme} -configuration Debug -derivedDataPath '#{tempLunaUploaderPath}/build/x86/temp' -destination 'platform=iOS Simulator,name=iPhone 11'") if isNext == true isNext = command("cp -r #{tempLunaUploaderPath}/build/x86/temp/Build/Products #{binary_path_x86}") if isNext == true mergeFrameWorks(binary_path_arm, binary_path_x86) if isNext == true end |
#findFramework(moduleName, binary_path) ⇒ Object
82 83 84 85 86 87 88 89 |
# File 'lib/luna/binary/build.rb', line 82 def findFramework(moduleName, binary_path) pathArr = Dir.glob("#{binary_path}/**/#{moduleName.sub('-', '_')}.framework") if pathArr != nil return pathArr.first else return nil end end |
#lockfile ⇒ Object
67 68 69 |
# File 'lib/luna/binary/build.rb', line 67 def lockfile return Luna::Binary::Common.instance.lockfile end |
#mergeFrameWork(moduleName, path1, path2) ⇒ Object
76 77 78 79 80 |
# File 'lib/luna/binary/build.rb', line 76 def mergeFrameWork(moduleName, path1, path2) command("mkdir -p #{binary_path_merged}; cp -r #{File.dirname(path1)} #{binary_path_merged}; mv #{binary_path_merged}/#{File.basename(File.dirname(path1))} #{binary_path_merged}/#{moduleName};") command("lipo -create #{path2}/#{moduleName} #{path1}/#{moduleName} -output #{binary_path_merged}/#{moduleName}/#{moduleName}.framework/#{moduleName}") command("cp -r #{path2}/Modules/#{moduleName}.swiftmodule #{binary_path_merged}/#{moduleName}/#{moduleName}.framework/Modules") end |
#mergeFrameWorks(binary_path_arm, binary_path_x86) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/luna/binary/build.rb', line 42 def mergeFrameWorks(binary_path_arm, binary_path_x86) Luna::Binary::Common.instance.deleteDirectory(binary_path_merged) dedupingMapper = {} failList = [] lockfile.pod_names.each { |item| if item["/"] == nil && dedupingMapper[item] == nil begin Pod::UserInterface.puts item.yellow armPath = findFramework(item,binary_path_arm) x86Path = findFramework(item,binary_path_x86) mergeFrameWork(item, armPath, x86Path) if armPath != nil && x86Path != nil dedupingMapper[item] = item rescue => exception failList << "#{item} exception : #{exception}" ensure end end } Pod::UserInterface.puts "合并后的framework的路径为:#{binary_path_merged}".yellow Pod::UserInterface.puts "失败的名单为:#{failList}".yellow end |
#run ⇒ Object
18 19 20 |
# File 'lib/luna/binary/build.rb', line 18 def run createFrameworks end |
#xcodeSimulators ⇒ Object
71 72 73 74 |
# File 'lib/luna/binary/build.rb', line 71 def xcodeSimulators # simulators = JSON.parse(%x("xcodebuild -workspace #{workspace} -scheme #{scheme} -showdestinations")) end |