add build_dist.rb to create dist/rscons as a standalone script
This commit is contained in:
parent
5cf77f1f58
commit
bcd33fe098
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,5 +3,6 @@
|
||||
/_yardoc/
|
||||
/build_test_run/
|
||||
/coverage/
|
||||
/dist/
|
||||
/doc/
|
||||
/pkg/
|
||||
|
@ -13,6 +13,10 @@ require "rake/clean"
|
||||
CLEAN.include %w[build_test_run .yardoc doc coverage]
|
||||
CLOBBER.include %w[pkg]
|
||||
|
||||
task :build_dist do
|
||||
sh "ruby build_dist.rb"
|
||||
end
|
||||
|
||||
RSpec::Core::RakeTask.new(:spec, :example_string) do |task, args|
|
||||
if args.example_string
|
||||
ENV["partial_specs"] = "1"
|
||||
|
39
build_dist.rb
Executable file
39
build_dist.rb
Executable file
@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
require "fileutils"
|
||||
|
||||
PROG_NAME = "rscons"
|
||||
START_FILE = "bin/#{PROG_NAME}"
|
||||
LIB_DIR = "lib"
|
||||
DIST = "dist"
|
||||
|
||||
files_processed = {}
|
||||
|
||||
process_file = lambda do |file, fh|
|
||||
File.read(file, mode: "rb").each_line do |line|
|
||||
if line =~ /^\s*require(?:_relative)?\s*"(.*)"$/
|
||||
require_name = $1
|
||||
if require_name =~ %r{^#{PROG_NAME}(?:/.*)?$}
|
||||
path = "#{LIB_DIR}/#{require_name}.rb"
|
||||
if File.exists?(path)
|
||||
unless files_processed[path]
|
||||
files_processed[path] = true
|
||||
process_file[path, fh]
|
||||
end
|
||||
else
|
||||
raise "require path #{path.inspect} not found"
|
||||
end
|
||||
else
|
||||
fh.write(line)
|
||||
end
|
||||
else
|
||||
fh.write(line)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
FileUtils.mkdir_p(DIST)
|
||||
|
||||
File.open("#{DIST}/#{PROG_NAME}", "wb", 0755) do |fh|
|
||||
process_file[START_FILE, fh]
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user