lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject [lucy-commits] [2/16] git commit: refs/heads/master - Start using cached charmonizer.c in Ruby bindings.
Date Sat, 03 Nov 2012 18:21:54 GMT
Start using cached charmonizer.c in Ruby bindings.

Simplify the build instructions for the Ruby bindings of both Lucy and
the Clownfish runtime by using the version of charmonizer.c cached in
version control.


Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/e50366f9
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/e50366f9
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/e50366f9

Branch: refs/heads/master
Commit: e50366f92430a945172ef039e73663b3a9b9115f
Parents: cd9aece
Author: Marvin Humphrey <marvin@rectangular.com>
Authored: Sat Nov 3 11:19:58 2012 -0700
Committer: Marvin Humphrey <marvin@rectangular.com>
Committed: Sat Nov 3 11:19:58 2012 -0700

----------------------------------------------------------------------
 clownfish/runtime/ruby/Rakefile |   83 ++++++++++++++++-----------------
 ruby/Rakefile                   |   85 +++++++++++++++++----------------
 2 files changed, 84 insertions(+), 84 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/e50366f9/clownfish/runtime/ruby/Rakefile
----------------------------------------------------------------------
diff --git a/clownfish/runtime/ruby/Rakefile b/clownfish/runtime/ruby/Rakefile
index bc5b6bb..b2fc539 100644
--- a/clownfish/runtime/ruby/Rakefile
+++ b/clownfish/runtime/ruby/Rakefile
@@ -21,9 +21,15 @@ def rbconfig
   RbConfig::CONFIG
 end
 
+def exe_path(*args)
+  File.join(args).ext(RbConfig::CONFIG["EXEEXT"])
+end
+
 BASE_PATH = '..'
 CHARMONIZER_ORIG_DIR = File.absolute_path( File.join( BASE_PATH, '..', '..', 'charmonizer'
) )
-CHARMONIZE_EXE_PATH  = './charmonize' #TODO: probably will not work on win32
+COMMON_SOURCE_DIR    = File.join(BASE_PATH, "common")
+CHARMONIZER_C        = File.join(COMMON_SOURCE_DIR, 'charmonizer.c')
+CHARMONIZER_EXE_PATH = File.absolute_path(exe_path('charmonizer'))
 CHARMONY_H_PATH      = 'charmony.h'
 CHARMONY_RB_PATH     = 'Charmony.rb'
 CORE_SOURCE_DIR      = File.absolute_path( BASE_PATH, 'core' );
@@ -86,57 +92,48 @@ task :build_charmonizer_tests => [:charmonize] do
   run_make( :dir => CHARMONIZER_ORIG_DIR, :args => [ "DEFS=#{flags}", "tests"])
 end
 
-desc "Charmonize"
-task :charmonize => [:build_charmonize] do 
-  puts "Charmonizing"
-  #return if !uptodate?(CHARMONIZE_EXE_PATH, [ CHARMONY_H_PATH, CHARMONY_RB_PATH ] )
-  puts "Running #{CHARMONIZE_EXE_PATH}...\n"
-  CLEAN.include(CHARMONY_H_PATH)
-  CLEAN.include(CHARMONY_RB_PATH)
-  CLEAN.include('_charm*')
+desc "Build and run charmonizer, creating charmony.h and charmony.rb"
+task :charmony do
+  # Compile charmonizer executable.
+  if !uptodate? CHARMONIZER_EXE_PATH, [CHARMONIZER_C]
+    outflag = cc_command.match(/cl\b/) ? "/Fe" : "-o "
+    command = "#{cc_command} #{outflag}#{CHARMONIZER_EXE_PATH} #{CHARMONIZER_C}"
+    puts command
+    if !system(command)
+      raise "Failed to compile #{CHARMONIZER_EXE_PATH}"
+    end
+  end
 
-  # TODO: no clue if this is correct
+  # Return if charmonizer output is current.
+  if uptodate? CHARMONY_RB_PATH, [CHARMONIZER_EXE_PATH]
+    next
+  end
+  puts "Running #{CHARMONIZER_EXE_PATH}...\n"
+
+  # Prepare arguments to charmonizer.
   command = [
-    CHARMONIZE_EXE_PATH,
-    '--cc=' + quotify( cc_command ),
+    CHARMONIZER_EXE_PATH,
+    '--cc=' + quotify(cc_command),
     '--enable-c',
     '--enable-ruby',
     '--',
-    extra_ccflags,
+    all_ccflags,
   ]
-
-  if ( ENV['CHARM_VALGRIND'] )
+  if (ENV['CHARM_VALGRIND'])
     command.unshift("valgrind", "--leak-check=yes")
   end
 
-  if system(*command).nil?
-    abort "Failed to run #{CHARMONIZE_EXE_PATH}"
-  end
-
-end
-
-desc "Building Charmonize"
-task :build_charmonize do 
-  puts "Buildling #{CHARMONIZE_EXE_PATH}"
-  meld_c = File.absolute_path('charmonize.c')
-
-  CLEAN.include(meld_c)
-  CLEAN.include(CHARMONIZE_EXE_PATH)
-
-  charmonize_main = File.join( CHARMONIZER_ORIG_DIR, 'charmonize.c' )
-
-  # TODO: Build.PL "PERL=$^X" Right is defaulting to system perl?
-  run_make(:dir => CHARMONIZER_ORIG_DIR, :args => [ "meld", "FILES=#{charmonize_main}",
"OUT=#{meld_c}" ])
-
-  if !uptodate?(CHARMONIZE_EXE_PATH, [meld_c])
-    cc = cc_command
-    outflag = $cc =~ /cl\b/ ? "/Fe" : "-o ";
-    if system("#{cc} #{meld_c} #{outflag}#{CHARMONIZE_EXE_PATH}").nil?
-      abort "Failed to compile #{CHARMONIZE_EXE_PATH}"
-    end
+  # Run charmonizer.
+  puts command.join(" ")
+  if !system(*command)
+    raise "Failed to run #{CHARMONIZER_EXE_PATH}: " + $?
   end
-
 end
+CLEAN.include(CHARMONIZER_EXE_PATH)
+CLEAN.include(CHARMONY_H_PATH)
+CLEAN.include(CHARMONY_RB_PATH)
+# Clean up after charmonizer if it doesn't succeed on its own.
+CLEAN.include("_charm*")
 
 task :default => [:build_clownfish]
 
@@ -181,7 +178,7 @@ def make_command
   return command
 end
 
-def extra_ccflags 
+def all_ccflags
   ccflags = '-DCFCRUBY '
   
   if defined?(rbconfig["CFLAGS"])
@@ -214,7 +211,7 @@ def extra_ccflags
 end
 
 def quotify(string)
-  return '"' + string.gsub(/[\\\"]/,'\\1') + '"'
+  return '"' + string.gsub(/([\\\"])/,'\\\\\\1') + '"'
 end
 
 def autogen_header

http://git-wip-us.apache.org/repos/asf/lucy/blob/e50366f9/ruby/Rakefile
----------------------------------------------------------------------
diff --git a/ruby/Rakefile b/ruby/Rakefile
index 474197b..9481380 100644
--- a/ruby/Rakefile
+++ b/ruby/Rakefile
@@ -78,14 +78,20 @@ def run_make(dir, params)
   chdir(current_dir) if dir
 end
 
+def quotify(string)
+  return '"' + string.gsub(/([\\\"])/,'\\\\\\1') + '"'
+end
+
 IS_DISTRO_NOT_DEVEL  = File.directory?('core')
 AUTOGEN_DIR          = "autogen"
 BASE_DIR             = File.absolute_path(IS_DISTRO_NOT_DEVEL ? '.' : '..')
 CHARMONIZER_ORIG_DIR = File.join(BASE_DIR, "charmonizer")
-CHARMONIZE_C_PATH    = File.absolute_path('charmonize.c')
-CHARMONIZE_EXE_PATH  = File.absolute_path(exe_path('charmonize'))
+COMMON_SOURCE_DIR    = File.join(BASE_DIR, "common")
+CHARMONIZER_C        = File.join(COMMON_SOURCE_DIR, 'charmonizer.c')
+CHARMONIZER_EXE_PATH = File.absolute_path(exe_path('charmonizer'))
 CLOWNFISH_PATH       = File.join(BASE_DIR,"clownfish","ruby")
-CHARMONY_PATH        = "charmony.h"
+CHARMONY_H_PATH      = "charmony.h"
+CHARMONY_RB_PATH     = "Charmony.rb"
 CORE_SOURCE_DIR      = File.join(BASE_DIR, "core")
 
 desc "Build clownfish"
@@ -109,51 +115,48 @@ task :clownfish => [:charmonizer_tests] do
 
 end
 
-desc "Build the charmonize executable"
-task :charmonize do
-  puts "Building #{CHARMONIZE_EXE_PATH}...\n"
-  meld_c = File.absolute_path("charmonize.c")
-  charmonize_main = File.join(CHARMONIZER_ORIG_DIR, 'charmonize.c')
-  run_make_args = [ "meld", "FILES=#{charmonize_main}", "OUT=#{meld_c}" ]
-  run_make(CHARMONIZER_ORIG_DIR, run_make_args)
-
-  if !uptodate?(CHARMONIZE_EXE_PATH, [meld_c])
+desc "Build and run charmonizer, creating charmony.h and charmony.rb"
+task :charmony do
+  # Compile charmonizer executable.
+  if !uptodate? CHARMONIZER_EXE_PATH, [CHARMONIZER_C]
     outflag = cc_command.match(/cl\b/) ? "/Fe" : "-o "
-    command = "#{cc_command} #{outflag}#{CHARMONIZE_EXE_PATH} #{meld_c}"
+    command = "#{cc_command} #{outflag}#{CHARMONIZER_EXE_PATH} #{CHARMONIZER_C}"
     puts command
-    success = system(command)
-    if !success
-      raise "Failed to write charmony.h"
+    if !system(command)
+      raise "Failed to compile #{CHARMONIZER_EXE_PATH}"
     end
   end
-end
-CLEAN.include(CHARMONIZE_C_PATH)
-CLEAN.include(CHARMONIZE_EXE_PATH)
-
-desc "Run the charmonize executable, creating the charmony.h file"
-task :charmony => [:charmonize] do
-  if !uptodate? CHARMONY_PATH, [CHARMONIZE_EXE_PATH]
-    puts "Writing #{CHARMONY_PATH}...\n"
-    command = [
-      CHARMONIZE_EXE_PATH, 
-      "--cc=\"#{cc_command}\"", 
-      "--enable-c",
-      "--",
-      all_ccflags
-    ]
-    if ENV["CHARM_VALGRIND"]
-      command.unshift("valgrind", "--leak-check=yes")
-    end
-    puts command.join(" ")
-    success = system(*command);
-    if !success
-      raise "Failed to write charmony.h"
-    end
+
+  # Return if charmonizer output is current.
+  if uptodate? CHARMONY_RB_PATH, [CHARMONIZER_EXE_PATH]
+    next
+  end
+  puts "Running #{CHARMONIZER_EXE_PATH}...\n"
+
+  # Prepare arguments to charmonizer.
+  command = [
+    CHARMONIZER_EXE_PATH,
+    '--cc=' + quotify(cc_command),
+    '--enable-c',
+    '--enable-ruby',
+    '--',
+    all_ccflags,
+  ]
+  if (ENV['CHARM_VALGRIND'])
+    command.unshift("valgrind", "--leak-check=yes")
+  end
+
+  # Run charmonizer.
+  puts command.join(" ")
+  if !system(*command)
+    raise "Failed to run #{CHARMONIZER_EXE_PATH}: " + $?
   end
 end
-# Clean up after charmonize if it doesn't succeed on its own.
+CLEAN.include(CHARMONIZER_EXE_PATH)
+CLEAN.include(CHARMONY_H_PATH)
+CLEAN.include(CHARMONY_RB_PATH)
+# Clean up after charmonizer if it doesn't succeed on its own.
 CLEAN.include("_charm*")
-CLEAN.include(CHARMONY_PATH)
 
 desc "Build the charmonizer tests"
 task :charmonizer_tests => [:charmony] do


Mime
View raw message