Skip to content

Instantly share code, notes, and snippets.

@warmwaffles
Created April 28, 2015 05:57
Show Gist options
  • Save warmwaffles/5fdaab72cdf63b613350 to your computer and use it in GitHub Desktop.
Save warmwaffles/5fdaab72cdf63b613350 to your computer and use it in GitHub Desktop.
A way to have multiple rust projects in one directory and work with them in a Rakefile
def run(cmd)
puts "===> #{cmd}"
system cmd
end
projects = %w(client editor server)
projects.each do |project|
namespace(project) do
desc "Cleans the #{project} project"
task :clean do
run %Q(cargo clean --manifest-path "./#{project}/Cargo.toml")
end
desc "Builds the #{project} project"
task :build => [:clean] do
run %Q(cargo build --manifest-path "./#{project}/Cargo.toml")
end
desc "Runs the #{project} project"
task :run => [:clean] do
run %Q(cargo run --manifest-path "./#{project}/Cargo.toml")
end
desc "Tests the #{project} project"
task :test => [:clean] do
run %Q(cargo test --manifest-path "./#{project}/Cargo.toml")
end
desc "Documents the #{project} project"
task :doc => [:clean] do
run %Q(cargo doc --manifest-path "./#{project}/Cargo.toml")
end
end
end
namespace :clean do
desc 'Clean ALL of the projects'
task :all => projects.map { |p| "#{p}:clean" }
end
namespace :build do
desc 'Build ALL of the projects'
task :all => projects.map { |p| "#{p}:build" }
end
namespace :test do
desc 'Tests ALL of the projects'
task :all => projects.map { |p| "#{p}:test" }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment