mirror of
https://github.com/SleepingInsomniac/pixelfaucet
synced 2025-01-08 05:24:20 +01:00
Add script to build all examples
This commit is contained in:
parent
cef302ec1b
commit
3db76bcd44
2 changed files with 48 additions and 0 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -7,3 +7,4 @@
|
|||
# Libraries don't need dependency lock
|
||||
# Dependencies will be locked in applications that use them
|
||||
/shard.lock
|
||||
/examples/build/*
|
||||
|
|
47
scripts/build_examples.rb
Executable file
47
scripts/build_examples.rb
Executable file
|
@ -0,0 +1,47 @@
|
|||
#!/usr/bin/env ruby
|
||||
|
||||
require 'optparse'
|
||||
require 'fileutils'
|
||||
|
||||
options = {
|
||||
release: true,
|
||||
debug: false,
|
||||
clean: false,
|
||||
}
|
||||
|
||||
OptionParser.new do |opts|
|
||||
opts.banner = "Usage: build_examples.rb [options]"
|
||||
|
||||
opts.on("--release", "Build in release mode") do
|
||||
options[:release] = true
|
||||
end
|
||||
|
||||
opts.on("--no-release", "Build faster") do
|
||||
options[:release] = false
|
||||
end
|
||||
|
||||
opts.on("--clean", "Remove built examples") do
|
||||
options[:clean] = true
|
||||
end
|
||||
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__, '..')
|
||||
FileUtils.mkdir_p("examples/build")
|
||||
FileUtils.rm("examples/build/assets")
|
||||
FileUtils.ln_s("../../assets", "examples/build/assets")
|
||||
Dir.glob("examples/*.cr").each do |path|
|
||||
full_cmd = %'#{cmd} #{flags.join(" ")} "#{path}"'
|
||||
puts full_cmd
|
||||
system full_cmd
|
||||
bin_name = File.basename(path, ".cr")
|
||||
FileUtils.mv(bin_name, "examples/build/#{bin_name}")
|
||||
end
|
||||
else
|
||||
# TODO
|
||||
end
|
Loading…
Reference in a new issue