8 options = OpenStruct.new
9 options.output_dir = File.expand_path(Dir.pwd)
11 opts = OptionParser.new do |opts|
12 opts.banner += " DIRECTORIES"
13 opts.on("-oDIRECTORY", "--output-dir=DIRECTORY",
14 "Output generated gem to DIRECTORY",
15 "[#{options.output_dir}]") do |dir|
16 options.output_dir = File.expand_path(dir)
21 opts.on("-h", "--help", "Show this message") do
27 target_dirs = opts.parse!(ARGV)
33 target_dirs.each do |dir|
34 next unless File.basename(dir) == "ruby"
35 base_dir = File.expand_path(dir)
36 $LOAD_PATH.unshift(File.join(base_dir, "ext"))
37 $LOAD_PATH.unshift(File.join(base_dir, "lib"))
43 archive_dir = File.join(Dir.tmpdir, "svn-ruby-gem-#{Process.pid}")
44 FileUtils.mkdir(archive_dir)
45 at_exit {FileUtils.rm_rf(archive_dir)}
47 target_dirs.each do |dir|
48 FileUtils.cp_r(dir, archive_dir)
52 generated_gem_file = nil
53 Dir.chdir(archive_dir) do
57 spec = Gem::Specification.new do |s|
60 s.version = Svn::Core::VER_NUM
61 s.summary = "The Ruby bindings for Subversion."
62 s.email = "dev@subversion.tigris.org"
63 s.homepage = "http://subversion.tigris.org/"
64 s.description = s.summary
65 s.authors = ["Kouhei Sutou"]
66 s.files = Dir.glob(File.join("**", "*")).delete_if {|x| /\.gem$/i =~ x}
67 s.require_paths = ["ruby/ext", "ruby/lib"]
68 s.platform = Gem::Platform::WIN32
69 s.required_ruby_version = '>= 1.8.2'
72 generated_gem_file = File.expand_path(Gem::Builder.new(spec).build)
75 gem_file = File.join(options.output_dir, File.basename(generated_gem_file))
76 FileUtils.mv(generated_gem_file, gem_file)