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
103 104 105 |
# File 'lib/luna/binary/build.rb', line 103 def binary_path_arm return Common.instance.binary_path_arm end |
#binary_path_merged ⇒ Object
99 100 101 |
# File 'lib/luna/binary/build.rb', line 99 def binary_path_merged return Common.instance.binary_path_merged end |
#binary_path_x86 ⇒ Object
107 108 109 |
# File 'lib/luna/binary/build.rb', line 107 def binary_path_x86 return Common.instance.binary_path_x86 end |
#command(c) ⇒ Object
22 23 24 |
# File 'lib/luna/binary/build.rb', line 22 def command(c) return Common.instance.command(c) end |
#createFrameworks ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/luna/binary/build.rb', line 26 def createFrameworks isNext = true puts "请将二进制开关关闭,确保每个模块都是源码运行,因为二进制的因素有可能source缓存还是会引入二进制".yellow Install.new(false) Common.instance.deleteDirectory(binary_path_arm) tempLunaUploaderPath = 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/Debug-iphoneos #{binary_path_arm}") if isNext == true #本可以用CONFIGURATION_BUILD_DIR直接指定结果文件夹,结果经常性的编译报错 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/Debug-iphonesimulator #{binary_path_x86}") if isNext == true mergeFrameWorks(binary_path_arm, binary_path_x86) if isNext == true end |
#findFramework(moduleName, binary_path) ⇒ Object
89 90 91 92 93 94 95 96 |
# File 'lib/luna/binary/build.rb', line 89 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
74 75 76 |
# File 'lib/luna/binary/build.rb', line 74 def lockfile return Common.instance.lockfile end |
#mergeFrameWork(moduleName, path1, path2) ⇒ Object
83 84 85 86 87 |
# File 'lib/luna/binary/build.rb', line 83 def mergeFrameWork(moduleName, path1, path2) command("mkdir -p #{binary_path_merged}; cp -r #{File.dirname(path1)} #{binary_path_merged}; cp -r #{File.dirname(path2)} #{binary_path_merged}; mv #{binary_path_merged}/#{File.basename(File.dirname(path1))} #{binary_path_merged}/#{moduleName};") framework_name = moduleName.gsub("-", "_") return command("lipo -create #{path2}/#{framework_name} #{path1}/#{framework_name} -output #{binary_path_merged}/#{moduleName}/#{framework_name}.framework/#{framework_name}") end |
#mergeFrameWorks(binary_path_arm, binary_path_x86) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/luna/binary/build.rb', line 40 def mergeFrameWorks(binary_path_arm, binary_path_x86) Common.instance.deleteDirectory(binary_path_merged) dedupingMapper = {} failList = [] p lockfile.pod_names lockfile.pod_names.each { |i| item = i.split("/").first if dedupingMapper[item] == nil begin puts item.yellow armPath = findFramework(item,binary_path_arm) x86Path = findFramework(item,binary_path_x86) is_merge = mergeFrameWork(item, armPath, x86Path) if armPath != nil && x86Path != nil trasher_path = "#{Common.instance.tempLunaUploaderPath}/trasher" failList << "#{item} 存在问题,已搬到#{trasher_path}" if is_merge == false command("mkdir #{trasher_path}; mv #{binary_path_merged}/#{item} #{trasher_path}") if is_merge == false dedupingMapper[item] = item rescue => exception failList << "#{item} exception : #{exception}" ensure end end } puts "合并后的framework的路径为:#{binary_path_merged}".green puts "-=-=-=-=-=-=-=-=merge 失败名单-=-=-=-=-=-=-=-=-=-=" if failList.length > 0 failList.each { |item| puts item.red } end |
#run ⇒ Object
18 19 20 |
# File 'lib/luna/binary/build.rb', line 18 def run createFrameworks end |
#xcodeSimulators ⇒ Object
78 79 80 81 |
# File 'lib/luna/binary/build.rb', line 78 def xcodeSimulators # simulators = JSON.parse(%x("xcodebuild -workspace #{workspace} -scheme #{scheme} -showdestinations")) end |