Permalink
Browse files

Use DependencyGrapher in C exts.

  • Loading branch information...
1 parent c937e5d commit 24f0e34c66a1d793132798cf6d654712a86c282f Brian Ford committed Mar 29, 2010
View
@@ -21,6 +21,7 @@
.hgignore
.libs
.spec/bm.yml
+.depends.mf
/rubinius_tasks.dot
/nbproject
CI-specs
@@ -1,3 +1,5 @@
+require 'rake/loaders/makefile'
+
# Setup project files
project_files = common_headers + headers + sources + objects
@@ -24,5 +26,9 @@ bigdecimal = "bigdecimal.#{$DLEXT}"
file bigdecimal => project_files
+graph_dependencies sources
+
+import dependency_file
+
desc "Build Bigdecimal extension"
task :build => bigdecimal
@@ -21,7 +21,6 @@
#include <errno.h>
#include <float.h>
#include <math.h>
-#include "math.h"
/* #define ENABLE_NUMERIC_STRING */
View
@@ -1,3 +1,5 @@
+require 'rake/loaders/makefile'
+
# Setup project files
project_files = common_headers + headers + sources + objects
@@ -9,5 +11,9 @@ digest = "digest.#{$DLEXT}"
file digest => project_files
+graph_dependencies sources
+
+import dependency_file
+
desc "Build Digest extension"
task :build => digest
@@ -1,3 +1,5 @@
+require 'rake/loaders/makefile'
+
# Setup project files
project_files = common_headers + headers + sources + objects
@@ -10,5 +12,9 @@ bubblebabble = "bubblebabble.#{$DLEXT}"
file bubblebabble => project_files
+graph_dependencies sources, "./../"
+
+import dependency_file
+
desc "Build Digest/bubblebabble extension"
task :build => bubblebabble
@@ -1,3 +1,5 @@
+require 'rake/loaders/makefile'
+
# Setup project files
project_files = common_headers + headers + sources + objects
@@ -10,5 +12,9 @@ md5 = "md5.#{$DLEXT}"
file md5 => project_files
+graph_dependencies sources, "./../"
+
+import dependency_file
+
desc "Build Digest/md5 extension"
task :build => md5
@@ -1,3 +1,5 @@
+require 'rake/loaders/makefile'
+
# Setup project files
project_files = common_headers + headers + sources + objects
@@ -10,5 +12,9 @@ rmd160 = "rmd160.#{$DLEXT}"
file rmd160 => project_files
+graph_dependencies sources, "./../"
+
+import dependency_file
+
desc "Build Digest/rmd160 extension"
task :build => rmd160
@@ -1,3 +1,5 @@
+require 'rake/loaders/makefile'
+
# Setup project files
project_files = common_headers + headers + sources + objects
@@ -10,5 +12,9 @@ sha1 = "sha1.#{$DLEXT}"
file sha1 => project_files
+graph_dependencies sources, "./../"
+
+import dependency_file
+
desc "Build Digest/sha1 extension"
task :build => sha1
@@ -1,3 +1,5 @@
+require 'rake/loaders/makefile'
+
# Setup project files
project_files = common_headers + headers + sources + objects
@@ -10,5 +12,9 @@ sha2 = "sha2.#{$DLEXT}"
file sha2 => project_files
+graph_dependencies sources, "./../"
+
+import dependency_file
+
desc "Build Digest/sha2 extension"
task :build => sha2
View
@@ -1,3 +1,5 @@
+require 'rake/loaders/makefile'
+
# Special rule for putting .o files in the implementation-specific
# subdirectory so this single extension can be built for both MRI
# and Rubinius
@@ -18,9 +20,13 @@ def ext_dir
@ext_dir
end
+def source_files
+ sources("grammar.cpp")
+end
+
# Setup project files
def add_objects(files, dir)
- sources("grammar.cpp").zip(objects(dir)).each do |source, obj|
+ source_files.zip(objects(dir)).each do |source, obj|
file obj => source
file obj => __FILE__ # depend on the Rakefile, it might change
files << source << obj
@@ -56,6 +62,10 @@ melbourne_mri = "ruby/melbourne.#{$DLEXT}"
file melbourne_mri => project_files
+graph_dependencies source_files
+
+import dependency_file
+
# Build tasks
namespace :build do
desc "Build Melbourne for Rubinius"
@@ -22,7 +22,11 @@
/* Optionally include a mechanism for debugging memory */
#if defined(MEMORY_DEBUG) || defined(BSTRLIB_MEMORY_DEBUG)
-#include "memdbg.h"
+/* TODO: temporarily disable include until dependency grapher
+ * properly parses expressions.
+ *
+ * #include "memdbg.h"
+ */
#endif
#ifndef bstr__alloc
@@ -1,3 +1,5 @@
+require 'rake/loaders/makefile'
+
# Setup project files
project_files = common_headers + headers + sources + objects
@@ -16,5 +18,9 @@ readline = "readline.#{$DLEXT}"
file readline => project_files
+graph_dependencies sources
+
+import dependency_file
+
desc "Build Readline extension"
task :build => readline
View
@@ -1,3 +1,5 @@
+require 'rake/loaders/makefile'
+
# Setup project files
project_files = common_headers + headers + sources + objects
@@ -7,5 +9,9 @@ syck = "syck.#{$DLEXT}"
file syck => project_files
+graph_dependencies sources
+
+import dependency_file
+
desc "Build Syck extension"
task :build => syck
View
@@ -201,6 +201,22 @@ def objects(dir=nil)
@objects ||= dir ? sources.pathmap("#{dir}/%X.o") : sources.ext(".o")
end
+def dependency_file
+ ".depends.mf"
+end
+
+def graph_dependencies(sources, directories=[])
+ directories = Array(directories)
+ directories.concat [".", File.expand_path("../../vm/capi", __FILE__)]
+
+ grapher = DependencyGrapher.new sources, directories
+ grapher.process
+
+ File.open dependency_file, "w" do |file|
+ grapher.print_dependencies file
+ end
+end
+
# Helper methods for invoking and reporting on commands
#
def report_command(notice)
@@ -229,6 +245,7 @@ def tr_cpp
strip.upcase.tr_s("^A-Z0-9_", "_")
end
end
+
class Array
# Wraps all strings in escaped quotes if they contain whitespace.
def quote
View
@@ -37,9 +37,10 @@ def compile_ext(name, opts={})
rbx = File.expand_path "../bin/rbx-build", File.dirname(__FILE__)
ext_helper = File.expand_path "../ext_helper.rb", __FILE__
+ dep_grapher = File.expand_path "../dependency_grapher.rb", __FILE__
Dir.chdir ext_dir do
if File.exists? "Rakefile"
- ruby "-S rake #{'-t' if $verbose} -r #{ext_helper} #{ext_task_name}"
+ ruby "-S rake #{'-t' if $verbose} -r #{ext_helper} -r #{dep_grapher} #{ext_task_name}"
else
unless File.directory? BUILD_CONFIG[:runtime]
ENV["CFLAGS"] = "-Ivm/capi"

0 comments on commit 24f0e34

Please sign in to comment.