mirror of
https://github.com/SleepingInsomniac/pixelfaucet
synced 2025-02-02 20:45:54 +01:00
Update build script
This commit is contained in:
parent
172478cffa
commit
0ff6a69305
1 changed files with 29 additions and 28 deletions
|
@ -1,48 +1,49 @@
|
||||||
#!/usr/bin/env ruby
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
|
v_major, v_minor, v_patch = RUBY_VERSION.split('.').map(&:to_i)
|
||||||
|
unless v_major == 3 && v_minor >= 2
|
||||||
|
$stderr.puts "Warn: script designed for Ruby 3.2.x, running: #{RUBY_VERSION}"
|
||||||
|
end
|
||||||
|
|
||||||
require 'optparse'
|
require 'optparse'
|
||||||
require 'fileutils'
|
require 'fileutils'
|
||||||
|
|
||||||
|
OUT_PATH = 'examples/build'
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
release: true,
|
release: true,
|
||||||
debug: false,
|
debug: false,
|
||||||
clean: false,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OptionParser.new do |opts|
|
OptionParser.new do |opts|
|
||||||
opts.banner = "Usage: build_examples.rb [options]"
|
opts.banner = "Usage: build_examples.rb [options]"
|
||||||
|
|
||||||
opts.on("--release", "Build in release mode") do
|
opts.on("--[no-]release", "Build in release mode (default: #{options[:release]})") do |value|
|
||||||
options[:release] = true
|
options[:release] = value
|
||||||
end
|
end
|
||||||
|
|
||||||
opts.on("--no-release", "Build faster") do
|
opts.on("--[no-]debug", "Include debug information (default: #{options[:debug]})") do |value|
|
||||||
options[:release] = false
|
options[:debug] = value
|
||||||
end
|
|
||||||
|
|
||||||
opts.on("--clean", "Remove built examples") do
|
|
||||||
options[:clean] = true
|
|
||||||
end
|
end
|
||||||
end.parse!
|
end.parse!
|
||||||
|
|
||||||
unless options[:clean]
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
cmd = "crystal build"
|
|
||||||
flags = []
|
|
||||||
flags << "--release" if options[:release]
|
|
||||||
flags << "--no-debug" unless options[:debug]
|
|
||||||
|
|
||||||
Dir.chdir File.join(__dir__, '..')
|
cmd = "crystal build"
|
||||||
FileUtils.mkdir_p("examples/build")
|
flags = []
|
||||||
unless File.exists?("examples/build/assets")
|
flags << "--release" if options[:release]
|
||||||
FileUtils.ln_s("../../assets", "examples/build/assets")
|
flags << "--no-debug" unless options[:debug]
|
||||||
end
|
|
||||||
Dir.glob("examples/*.cr").each do |path|
|
Dir.chdir File.join(__dir__, '..')
|
||||||
full_cmd = %'#{cmd} #{flags.join(" ")} "#{path}"'
|
FileUtils.mkdir_p(OUT_PATH)
|
||||||
|
|
||||||
|
unless File.exist?("#{OUT_PATH}/assets")
|
||||||
|
FileUtils.ln_s("../../assets", "#{OUT_PATH}/assets")
|
||||||
|
end
|
||||||
|
|
||||||
|
Dir.glob("examples/*.cr").each do |path|
|
||||||
|
bin_name = File.basename(path, ".cr")
|
||||||
|
full_cmd = %'#{cmd} #{flags.join(" ")} "#{path}" -o #{OUT_PATH}/#{bin_name}'
|
||||||
puts full_cmd
|
puts full_cmd
|
||||||
system full_cmd
|
system full_cmd
|
||||||
bin_name = File.basename(path, ".cr")
|
|
||||||
FileUtils.mv(bin_name, "examples/build/#{bin_name}")
|
|
||||||
end
|
|
||||||
else
|
|
||||||
# TODO
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue