You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by ma...@apache.org on 2011/06/19 04:55:53 UTC
[lucy-commits] svn commit: r1137276 - /incubator/lucy/trunk/ruby/Rakefile
Author: marvin
Date: Sun Jun 19 02:55:53 2011
New Revision: 1137276
URL: http://svn.apache.org/viewvc?rev=1137276&view=rev
Log:
Factor out routine to run make in another dir.
Modified:
incubator/lucy/trunk/ruby/Rakefile
Modified: incubator/lucy/trunk/ruby/Rakefile
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/ruby/Rakefile?rev=1137276&r1=1137275&r2=1137276&view=diff
==============================================================================
--- incubator/lucy/trunk/ruby/Rakefile (original)
+++ incubator/lucy/trunk/ruby/Rakefile Sun Jun 19 02:55:53 2011
@@ -28,10 +28,6 @@ def cc_command
RbConfig::CONFIG["CC"]
end
-def make_command
- return cc_command =~ /^cl\b/ ? ["nmake", "-f", "Makefile.win"] : ["make"]
-end
-
def extra_ccflags
""
end
@@ -42,6 +38,23 @@ def all_ccflags
flags
end
+def run_make(dir, params)
+ command = params.clone
+ command.unshift("CC=#{cc_command}")
+ if cc_command =~ /^cl\b/
+ command.unshift("nmake", "-f", "Makefile.win")
+ else
+ command.unshift("make")
+ end
+ current_dir = Dir.pwd
+ chdir(dir) if dir
+ success = system(*command)
+ if !success
+ raise "Make failed"
+ end
+ chdir(current_dir) if dir
+end
+
IS_DISTRO_NOT_DEVEL = File.directory?('core')
BASE_DIR = File.absolute_path(IS_DISTRO_NOT_DEVEL ? '.' : '..')
CHARMONIZER_ORIG_DIR = File.join(BASE_DIR, "charmonizer")
@@ -51,13 +64,7 @@ CHARMONY_PATH = "charmony.h"
desc "Build the charmonize executable"
task :charmonizer do
puts "Building #{CHARMONIZE_EXE_PATH}...\n"
- dir = Dir.pwd
- Dir.chdir(CHARMONIZER_ORIG_DIR)
- success = system(*make_command)
- if !success
- raise "make failed"
- end
- Dir.chdir(dir);
+ run_make(CHARMONIZER_ORIG_DIR, [])
end
desc "Run the charmonize executable, creating the charmony.h file"
@@ -91,27 +98,13 @@ CLEAN.include(CHARMONY_PATH)
desc "Build the charmonizer tests"
task :charmonizer_tests => [:charmony] do
puts "Building Charmonizer Tests...\n"
-
- flags = all_ccflags + ' -I../ruby'
-
- dir = Dir.pwd
- Dir.chdir(CHARMONIZER_ORIG_DIR)
- success = system(*make_command, "CC=\"#{cc_command}\"", "DEFS=#{flags}",
- "tests")
- if !success
- raise "Make failed"
- end
- Dir.chdir(dir)
+ flags = all_ccflags + ' -I' + File.absolute_path(Dir.pwd)
+ args = ["CC=\"#{cc_command}\"", "DEFS=#{flags}", "tests"]
+ run_make(CHARMONIZER_ORIG_DIR, args)
end
task :clean do
- dir = Dir.pwd
- Dir.chdir(CHARMONIZER_ORIG_DIR)
- success = system(*make_command, "clean")
- if !success
- raise "make failed"
- end
- Dir.chdir(dir);
+ run_make(CHARMONIZER_ORIG_DIR, ["clean"])
end
task :test => [:charmonizer_tests] do