Module: Drakkon::Build
- Extended by:
- PlatformCompat
- Defined in:
- lib/drakkon/build.rb
Overview
Run Command for CLI
Class Method Summary collapse
- .args(raw = nil) ⇒ Object
-
.build!(list, context, package = '--package') ⇒ Object
DEW THE BUILD.
- .force_fonts? ⇒ Boolean
- .force_images? ⇒ Boolean
- .force_manifest? ⇒ Boolean
- .force_sounds? ⇒ Boolean
-
.go!(raw, publish = '--package') ⇒ Object
General Run rubocop:disable Metrics/AbcSize.
- .manifest_compile(context, context_name) ⇒ Object
- .metadata_version(context) ⇒ Object
-
.output(io) ⇒ Object
Send output to console.
- .platform_setup ⇒ Object
- .platforms ⇒ Object
- .prompt ⇒ Object
- .version_dir ⇒ Object
Methods included from PlatformCompat
build_env, path_divider, run_env, windows?
Class Method Details
.args(raw = nil) ⇒ Object
6 7 8 9 10 |
# File 'lib/drakkon/build.rb', line 6 def self.args(raw = nil) @args ||= raw @args end |
.build!(list, context, package = '--package') ⇒ Object
DEW THE BUILD
123 124 125 126 127 128 129 130 131 132 |
# File 'lib/drakkon/build.rb', line 123 def self.build!(list, context, package = '--package') # 5.25 not liking the blank package flag cmd = [] cmd.push './dragonruby-publish' cmd.push package unless package.nil? || package.empty? cmd.push "--platforms=#{list}" cmd.push context cmd end |
.force_fonts? ⇒ Boolean
142 143 144 |
# File 'lib/drakkon/build.rb', line 142 def self.force_fonts? args.include?('fonts') end |
.force_images? ⇒ Boolean
138 139 140 |
# File 'lib/drakkon/build.rb', line 138 def self.force_images? args.include?('images') end |
.force_manifest? ⇒ Boolean
150 151 152 |
# File 'lib/drakkon/build.rb', line 150 def self.force_manifest? args.include?('manifest') end |
.force_sounds? ⇒ Boolean
146 147 148 |
# File 'lib/drakkon/build.rb', line 146 def self.force_sounds? args.include?('sounds') end |
.go!(raw, publish = '--package') ⇒ Object
General Run rubocop:disable Metrics/AbcSize
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 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 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/drakkon/build.rb', line 14 def self.go!(raw, publish = '--package') Settings.ready? args(raw) Settings.update(:platforms, platform_setup) unless Settings.platforms? # Run Index if configured Manifest.index if Settings.config[:manifest] builder = if args.empty? Settings.platforms else platforms.select { |i| args.any? { |a| i.include? a } } end if builder.empty? LogBot.fatal('Build', "No valid platforms found! #{args.inspect.pastel(:red)} : #{builder.inspect.pastel(:red)}") exit(0) end list = builder.join(',') LogBot.info('Build', "Building for platforms: #{list}") # Save Current Directory before changing to Version Directory context = Dir.pwd context_name = File.basename(context) version = (context) # Yes... build.build! :D Dir.chdir(version_dir) do # Clean Up Accidental Leftovers FileUtils.rm_r(context_name) if Dir.exist? context_name if Settings.manifest_compile? manifest_compile(context, context_name) else # DragonRuby Publish doesn't like symlinks or PATH... FileUtils.cp_r(context, context_name) end # Clean Builds Dir FileUtils.rm_r(Dir['builds/*']) # Remove Project's Builds Directory / Copied Version FileUtils.rm_r("#{context_name}/builds") if Dir.exist? "#{context_name}/builds" # Execute io = IO.popen(build_env, build!(list, context_name, publish)) output(io) # Preflight FileUtils.mkdir_p("#{context}/builds") FileUtils.mkdir_p("#{context}/builds/#{version}") # Copy back to Project Dir FileUtils.cp_r(Dir['builds/*'], "#{context}/builds/#{version}/") # Copy Settings copy = Settings.config.dig(:builds, :copy) if copy FileUtils.mkdir_p("#{copy}/#{version}") FileUtils.cp(Dir['builds/*.zip'], "#{copy}/#{version}/") end # Clean Up FileUtils.rm_r(context_name) end end |
.manifest_compile(context, context_name) ⇒ Object
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/drakkon/build.rb', line 95 def self.manifest_compile(context, context_name) # Base Folders Dir.mkdir context_name Dir.mkdir "#{context_name}/app" # Copy Directories that are not being managed FileUtils.cp_r("#{context}/fonts", "#{context_name}/fonts") FileUtils.cp_r("#{context}/sprites", "#{context_name}/sprites") FileUtils.cp_r("#{context}/sounds", "#{context_name}/sounds") FileUtils.cp_r("#{context}/metadata", "#{context_name}/metadata") # Copy over base files FileUtils.cp("#{context}/app/main.rb", "#{context_name}/app/main.rb") FileUtils.cp_r("#{context}/app/drakkon", "#{context_name}/app/drakkon") # Compile into Manifest File.open("#{context_name}/app/drakkon/manifest.rb", 'w') do |f| Manifest.index.reverse.each do |file| f << File.read("#{context}/#{file}") end end end |
.metadata_version(context) ⇒ Object
118 119 120 |
# File 'lib/drakkon/build.rb', line 118 def self.(context) File.read("#{context}/metadata/game_metadata.txt").split("\n").find { |y| y.include? 'version' }.split('=').last end |
.output(io) ⇒ Object
Send output to console
87 88 89 90 91 92 93 |
# File 'lib/drakkon/build.rb', line 87 def self.output(io) loop do next unless io.ready? end rescue SystemExit, Interrupt, EOFError LogBot.info('Build', 'Exiting') end |
.platform_setup ⇒ Object
154 155 156 |
# File 'lib/drakkon/build.rb', line 154 def self.platform_setup prompt.multi_select('Select Platforms to build for (these will be the future default):', platforms, filter: true) end |
.platforms ⇒ Object
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
# File 'lib/drakkon/build.rb', line 158 def self.platforms %w[ windows-amd64 linux-amd64 macos android-0 android googleplay-0 googleplay html5-0 html5 linux-raspberrypi mac-0 oculusquest-0 oculusquest ] end |
.prompt ⇒ Object
176 177 178 |
# File 'lib/drakkon/build.rb', line 176 def self.prompt TTY::Prompt.new(active_color: :cyan, interrupt: :exit) end |