Skip to content

Instantly share code, notes, and snippets.

@burke
Created February 16, 2009 23:31
Show Gist options
  • Save burke/65457 to your computer and use it in GitHub Desktop.
Save burke/65457 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# -*- mode: ruby -*-
# Copyright Burke Libbey 2009, MIT License.
HOME_DIR = "/Users/burke" # Home directory
SVN_DIR = "#{HOME_DIR}/src/clojure/svn" # Clojure SVN checkout path
BRANCHES_DIR = "#{SVN_DIR}/branches" # Clojure SVN branches path
TRUNK_DIR = "#{SVN_DIR}/trunk" # Clojure SVN trunk path
INSTALL_DIR = "#{HOME_DIR}/lib/clj" # Path to managed jar symlinks
M_INSTALL_DIR = "#{INSTALL_DIR}/mclj" # Path for generated jars
CONTRIB_TRUNK = "#{HOME_DIR}/src/clojure/contrib-svn/trunk" # Path to clojure-contrib checkout
def build(name, path)
puts ">>>>> BUILDING #{name}"
system "cd '#{path}' && ant"
end
def install(name, path)
puts "Installing #{name}"
install_path = "#{M_INSTALL_DIR}/#{name}"
`mkdir "#{install_path}"`
`cp #{path}/*.jar "#{install_path}"`
end
def rebuild
puts "===== UPDATING SVN ====="
system "cd #{SVN_DIR} && svn up"
puts "===== BUILDING BRANCHES ====="
build("master", TRUNK_DIR)
branches = Dir.entries(BRANCHES_DIR).reject{|e| e =~ /^\./}
branches.each do |branch|
build(branch, "#{BRANCHES_DIR}/#{branch}")
end
puts "===== REMOVING PREVIOUS BRANCHES ====="
installs = Dir.entries(M_INSTALL_DIR).reject{|e| e =~ /^\./}
installs.each do |install|
puts "removing #{install}"
`rm -r #{M_INSTALL_DIR}/#{install}`
end
puts "===== INSTALLING NEW BRANCHES ====="
install("master", TRUNK_DIR)
branches.each do |branch|
install(branch, "#{BRANCHES_DIR}/#{branch}")
end
puts "===== UPDATING CONTRIB ====="
system "cd #{CONTRIB_TRUNK} && svn up"
system "cd '#{CONTRIB_TRUNK}' && ant"
system "cp #{CONTRIB_TRUNK}/*.jar #{INSTALL_DIR}"
end
def switch(clj)
if File.exists? "#{M_INSTALL_DIR}/#{clj}"
`ln -sf #{M_INSTALL_DIR}/#{clj}/clojure.jar #{INSTALL_DIR}`
`ln -sf #{M_INSTALL_DIR}/#{clj}/clojure-slim.jar #{INSTALL_DIR}`
end
end
if __FILE__ == $0
if ARGV[0] == "update"
rebuild
else
switch(ARGV[0])
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment