diff --git a/bin/rbpkg b/bin/rbpkg
index 471de61..3b5c6d1 100755
--- a/bin/rbpkg
+++ b/bin/rbpkg
@@ -20,11 +20,10 @@ Source directory commands :
checkout TREE shortcut for git checkout
Build commands :
- autogen -post checkout command usually named autogen
- configure .configure build for this system
- clean-configure -remove configure-done tag file
- build -run parallel build
- clean-build -remove object files
+ configure configure build for this system
+ clean-configure remove configure-done tag file
+ build .run parallel build
+ clean-build .remove object files
test -run tests
Package commands :
@@ -57,8 +56,6 @@ def rbpkg
usage()
when "clone"
Rbpkg.git_clone($ARGS)
- when "clean-configure"
- Rbpkg.clean_configure($ARGS)
when "clean-sources"
Rbpkg.clean_sources($ARGS)
when "fetch"
@@ -70,6 +67,12 @@ def rbpkg
Rbpkg.checkout(branch, $ARGS)
when "configure"
Rbpkg.configure($ARGS)
+ when "clean-configure"
+ Rbpkg.clean_configure($ARGS)
+ when "build"
+ Rbpkg.build($ARGS)
+ when "clean-build"
+ Rbpkg.clean_build($ARGS)
when "info"
Rbpkg.info($ARGS)
else
diff --git a/lib/rbpkg.rb b/lib/rbpkg.rb
index a2c1062..4ed150c 100644
--- a/lib/rbpkg.rb
+++ b/lib/rbpkg.rb
@@ -3,6 +3,12 @@ require __FILE__ + '/../rbpkg/repos'
module Rbpkg
+ def self.build(repos)
+ repos.each do |name|
+ Repos.repo(name).build()
+ end
+ end
+
def self.cc
if `which cc`
"cc"
@@ -25,6 +31,12 @@ module Rbpkg
end
end
+ def self.clean_build(repos)
+ repos.each do |name|
+ Repos.repo(name).clean_build()
+ end
+ end
+
def self.clean_configure(repos)
repos.each do |name|
Repos.repo(name).clean_configure()
@@ -95,6 +107,7 @@ module Rbpkg
"""%Rbpkg{
dir: #{dir.inspect},
CC: #{cc.inspect},
+ ncpu: #{ncpu.inspect},
target: #{target.inspect}
}"""
end
@@ -125,6 +138,15 @@ module Rbpkg
"#{log_dir}/#{name}_#{date}_#{$$}.log"
end
+ @@ncpu = nil
+ def self.ncpu
+ @@ncpu || @@ncpu = self.ncpu_fetch
+ end
+
+ def self.ncpu_fetch
+ `which nproc >/dev/null 2>&1 && nproc || which sysctl >/dev/null 2>&1 && sysctl -n hw.ncpu || echo 1`.strip.to_i
+ end
+
def self.pull(repos)
repos.each do |name|
Repos.repo(name).pull()
diff --git a/lib/rbpkg/repo.rb b/lib/rbpkg/repo.rb
index da52c23..384aa16 100644
--- a/lib/rbpkg/repo.rb
+++ b/lib/rbpkg/repo.rb
@@ -16,6 +16,15 @@ class Rbpkg::Repo
raise "autogen failed" unless r
true
end
+
+ def build
+ if ! tag_present?("build-done")
+ if File.file?("#{src_dir}/Makefile")
+ cmd! "cd #{sh_quote(src_dir)} && make -j #{Rbpkg.ncpu}"
+ end
+ end
+ end
+
def checkout(branch)
sh_branch=sh_quote(branch)
cmd! "cd #{sh_quote(src_dir!)} && git fetch #{sh_quote(git_remote)} #{sh_branch} && git checkout #{sh_branch} && git submodule update"