Permalink
Browse files

adding support for vulcan build -d <dep1>,...,<depN>

 dependencies are other vulcan built libraries which are required for the current build
  • Loading branch information...
1 parent 24c1a17 commit 24bf5baeb4dcb31f63faab88cb48f3631412470c @lpetre lpetre committed Mar 22, 2012
Showing with 39 additions and 3 deletions.
  1. +4 −1 lib/vulcan/cli.rb
  2. +33 −1 server/bin/make
  3. +2 −1 server/web.js
View
@@ -25,6 +25,7 @@ class Vulcan::CLI < Thor
method_option :output, :aliases => "-o", :desc => "output build artifacts to this file"
method_option :prefix, :aliases => "-p", :desc => "the build/install --prefix of the software"
method_option :source, :aliases => "-s", :desc => "the source directory to build from"
+ method_option :deps, :aliases => "-d", :desc => "other vulcan compiled libraries to build with"
method_option :verbose, :aliases => "-v", :desc => "show the full build output", :type => :boolean
def build
@@ -35,6 +36,7 @@ def build
output = options[:output] || "/tmp/#{name}.tgz"
prefix = options[:prefix] || "/app/vendor/#{name}"
command = options[:command] || "./configure --prefix #{prefix} && make install"
+ deps = options[:deps] || ""
server = URI.parse(ENV["MAKE_SERVER"] || "http://#{app}.herokuapp.com")
Dir.mktmpdir do |dir|
@@ -47,7 +49,8 @@ def build
"code" => UploadIO.new(input, "application/octet-stream", "input.tgz"),
"command" => command,
"prefix" => prefix,
- "secret" => config[:secret]
+ "secret" => config[:secret],
+ "deps" => deps
puts ">> Building with: #{command}"
response = Net::HTTP.start(server.host, server.port) do |http|
View
@@ -10,7 +10,8 @@ id = ARGV.shift
require "couchrest"
require "fileutils"
require "tmpdir"
-
+require "rest_client"
+
db = CouchRest.database!(ENV["CLOUDANT_URL"] + "/make")
Dir.mktmpdir do |dir|
@@ -19,11 +20,42 @@ Dir.mktmpdir do |dir|
command = doc["command"]
prefix = doc["prefix"]
+ deps = doc["deps"] || ""
File.open("input.tgz", "wb") do |file|
file.print doc.fetch_attachment("input")
end
+ deps.split(",").each_with_index do |dep, index|
+ puts "downloading #{dep}"
+ File.open("dep_#{index}.tgz", "wb") do |file|
+ begin
+ file.print RestClient.get(dep)
+ rescue Exception => ex
+ puts ex.inspect
+ end
+ end
+ end
+
+ FileUtils.mkdir_p "deps"
+
+ Dir.chdir("deps") do
+ deps.split(",").each_with_index do |dep, index|
+ %x{ tar xzf ../dep_#{index}.tgz 2>&1 }
+ end
+ end
+
+ unless deps.empty?
+ ENV["LDFLAGS"] ||= ""
+ ENV["LDFLAGS"] += " -L%s/deps/lib" % dir
+
+ ENV["CFLAGS"] ||= ""
+ ENV["CFLAGS"] += " -I%s/deps/include" % dir
+
+ ENV["CXXFLAGS"] ||= ""
+ ENV["CXXFLAGS"] += " -I%s/deps/include" % dir
+ end
+
FileUtils.mkdir_p "input"
Dir.chdir("input") do
View
@@ -53,10 +53,11 @@ app.post('/make', function(request, response, next) {
var id = uuid();
var command = fields.command;
var prefix = fields.prefix;
+ var deps = fields.deps;
// create a couchdb documents for this build
log_action(id, 'saving to couchdb');
- db.save(id, { command:command, prefix:prefix }, function(err, doc) {
+ db.save(id, { command:command, prefix:prefix, deps:deps }, function(err, doc) {
if (err) { log_error(id, util.inspect(err)); return next(err); }
// save the input tarball as an attachment

0 comments on commit 24bf5ba

Please sign in to comment.