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
82 83 84 |
# File 'lib/luna/binary/build.rb', line 82 def binary_path_arm return Luna::Binary::Common.instance.binary_path_arm end |
#binary_path_merged ⇒ Object
78 79 80 |
# File 'lib/luna/binary/build.rb', line 78 def binary_path_merged return Luna::Binary::Common.instance.binary_path_merged end |
#binary_path_x86 ⇒ Object
86 87 88 |
# File 'lib/luna/binary/build.rb', line 86 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 |
# File 'lib/luna/binary/build.rb', line 26 def createFrameworks isNext = true Pod::UserInterface.puts "请将二进制开关关闭,确保每个模块都是源码运行,因为二进制的因素有可能source缓存还是会引入二进制".yellow Luna::Binary::Common.instance.deleteDirectory(Dir.pwd + "/Pods") isNext = command("pod install") Luna::Binary::Common.instance.deleteDirectory(binary_path_arm) isNext = command("xcodebuild -workspace #{workspace} -scheme #{scheme} -configuration Debug -derivedDataPath '#{Dir.pwd}/build/arm' CONFIGURATION_BUILD_DIR='#{binary_path_arm}'") if isNext == true Luna::Binary::Common.instance.deleteDirectory(binary_path_x86) isNext = command("xcodebuild -workspace #{workspace} -scheme #{scheme} -configuration Debug -derivedDataPath '#{Dir.pwd}/build/x86' CONFIGURATION_BUILD_DIR='#{binary_path_x86}' -destination 'platform=iOS Simulator,name=iPhone 11'") if isNext == true mergeFrameWorks(binary_path_arm, binary_path_x86) if isNext == true end |
#findFramework(moduleName, binary_path) ⇒ Object
68 69 70 71 72 73 74 75 |
# File 'lib/luna/binary/build.rb', line 68 def findFramework(moduleName, binary_path) pathArr = Dir.glob("#{binary_path}/**/#{moduleName}.framework") if pathArr != nil return pathArr.first else return nil end end |
#lockfile ⇒ Object
54 55 56 |
# File 'lib/luna/binary/build.rb', line 54 def lockfile return Luna::Binary::Common.instance.lockfile end |
#mergeFrameWork(moduleName, path1, path2) ⇒ Object
63 64 65 66 |
# File 'lib/luna/binary/build.rb', line 63 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};") return command("lipo -create #{path2}/#{moduleName} #{path1}/#{moduleName} -output #{binary_path_merged}/#{moduleName}/#{moduleName}.framework/#{moduleName}") end |
#mergeFrameWorks(binary_path_arm, binary_path_x86) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/luna/binary/build.rb', line 38 def mergeFrameWorks(binary_path_arm, binary_path_x86) Luna::Binary::Common.instance.deleteDirectory(binary_path_merged) dedupingMapper = {} lockfile.pod_names.each { |item| if item["/"] == nil && dedupingMapper[item] == nil 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 end } Pod::UserInterface.puts "合并后的framework的路径为:#{binary_path_merged}".yellow end |
#run ⇒ Object
18 19 20 |
# File 'lib/luna/binary/build.rb', line 18 def run createFrameworks end |
#xcodeSimulators ⇒ Object
58 59 60 61 |
# File 'lib/luna/binary/build.rb', line 58 def xcodeSimulators # simulators = JSON.parse(%x("xcodebuild -workspace #{workspace} -scheme #{scheme} -showdestinations")) end |