Class: Luna::Binary::Build
- Inherits:
-
Object
- Object
- Luna::Binary::Build
- Defined in:
- lib/luna/binary/build.rb
Instance Attribute Summary collapse
-
#needPodInstall ⇒ Object
Returns the value of attribute needPodInstall.
-
#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.
15 16 17 |
# File 'lib/luna/binary/build.rb', line 15 def initialize needPodInstall = true end |
Instance Attribute Details
#needPodInstall ⇒ Object
Returns the value of attribute needPodInstall.
14 15 16 |
# File 'lib/luna/binary/build.rb', line 14 def needPodInstall @needPodInstall end |
#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
106 107 108 |
# File 'lib/luna/binary/build.rb', line 106 def binary_path_arm return Common.instance.binary_path_arm end |
#binary_path_merged ⇒ Object
102 103 104 |
# File 'lib/luna/binary/build.rb', line 102 def binary_path_merged return Common.instance.binary_path_merged end |
#binary_path_x86 ⇒ Object
110 111 112 |
# File 'lib/luna/binary/build.rb', line 110 def binary_path_x86 return Common.instance.binary_path_x86 end |
#command(c) ⇒ Object
23 24 25 |
# File 'lib/luna/binary/build.rb', line 23 def command(c) return Common.instance.command(c) end |
#createFrameworks ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/luna/binary/build.rb', line 27 def createFrameworks isNext = true if needPodInstall Install.new(false) end 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 return isNext end |
#findFramework(moduleName, binary_path) ⇒ Object
92 93 94 95 96 97 98 99 |
# File 'lib/luna/binary/build.rb', line 92 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
77 78 79 |
# File 'lib/luna/binary/build.rb', line 77 def lockfile return Common.instance.lockfile end |
#mergeFrameWork(moduleName, path1, path2) ⇒ Object
86 87 88 89 90 |
# File 'lib/luna/binary/build.rb', line 86 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
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 73 74 75 |
# File 'lib/luna/binary/build.rb', line 43 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
19 20 21 |
# File 'lib/luna/binary/build.rb', line 19 def run return createFrameworks end |
#xcodeSimulators ⇒ Object
81 82 83 84 |
# File 'lib/luna/binary/build.rb', line 81 def xcodeSimulators # simulators = JSON.parse(%x("xcodebuild -workspace #{workspace} -scheme #{scheme} -showdestinations")) end |