Skip to content

Commit

Permalink
Use DependencyGrapher in C exts.
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Ford committed Mar 29, 2010
1 parent c937e5d commit 24f0e34
Show file tree
Hide file tree
Showing 15 changed files with 90 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -21,6 +21,7 @@
.hgignore
.libs
.spec/bm.yml
.depends.mf
/rubinius_tasks.dot
/nbproject
CI-specs
Expand Down
6 changes: 6 additions & 0 deletions lib/ext/bigdecimal/Rakefile
@@ -1,3 +1,5 @@
require 'rake/loaders/makefile'

# Setup project files
project_files = common_headers + headers + sources + objects

Expand All @@ -24,5 +26,9 @@ bigdecimal = "bigdecimal.#{$DLEXT}"

file bigdecimal => project_files

graph_dependencies sources

import dependency_file

desc "Build Bigdecimal extension"
task :build => bigdecimal
1 change: 0 additions & 1 deletion lib/ext/bigdecimal/bigdecimal.c
Expand Up @@ -21,7 +21,6 @@
#include <errno.h>
#include <float.h>
#include <math.h>
#include "math.h"

/* #define ENABLE_NUMERIC_STRING */

Expand Down
6 changes: 6 additions & 0 deletions lib/ext/digest/Rakefile
@@ -1,3 +1,5 @@
require 'rake/loaders/makefile'

# Setup project files
project_files = common_headers + headers + sources + objects

Expand All @@ -9,5 +11,9 @@ digest = "digest.#{$DLEXT}"

file digest => project_files

graph_dependencies sources

import dependency_file

desc "Build Digest extension"
task :build => digest
6 changes: 6 additions & 0 deletions lib/ext/digest/bubblebabble/Rakefile
@@ -1,3 +1,5 @@
require 'rake/loaders/makefile'

# Setup project files
project_files = common_headers + headers + sources + objects

Expand All @@ -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
6 changes: 6 additions & 0 deletions lib/ext/digest/md5/Rakefile
@@ -1,3 +1,5 @@
require 'rake/loaders/makefile'

# Setup project files
project_files = common_headers + headers + sources + objects

Expand All @@ -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
6 changes: 6 additions & 0 deletions lib/ext/digest/rmd160/Rakefile
@@ -1,3 +1,5 @@
require 'rake/loaders/makefile'

# Setup project files
project_files = common_headers + headers + sources + objects

Expand All @@ -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
6 changes: 6 additions & 0 deletions lib/ext/digest/sha1/Rakefile
@@ -1,3 +1,5 @@
require 'rake/loaders/makefile'

# Setup project files
project_files = common_headers + headers + sources + objects

Expand All @@ -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
6 changes: 6 additions & 0 deletions lib/ext/digest/sha2/Rakefile
@@ -1,3 +1,5 @@
require 'rake/loaders/makefile'

# Setup project files
project_files = common_headers + headers + sources + objects

Expand All @@ -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
12 changes: 11 additions & 1 deletion lib/ext/melbourne/Rakefile
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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"
Expand Down
6 changes: 5 additions & 1 deletion lib/ext/melbourne/bstrlib.c
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions lib/ext/readline/Rakefile
@@ -1,3 +1,5 @@
require 'rake/loaders/makefile'

# Setup project files
project_files = common_headers + headers + sources + objects

Expand All @@ -16,5 +18,9 @@ readline = "readline.#{$DLEXT}"

file readline => project_files

graph_dependencies sources

import dependency_file

desc "Build Readline extension"
task :build => readline
6 changes: 6 additions & 0 deletions lib/ext/syck/Rakefile
@@ -1,3 +1,5 @@
require 'rake/loaders/makefile'

# Setup project files
project_files = common_headers + headers + sources + objects

Expand All @@ -7,5 +9,9 @@ syck = "syck.#{$DLEXT}"

file syck => project_files

graph_dependencies sources

import dependency_file

desc "Build Syck extension"
task :build => syck
17 changes: 17 additions & 0 deletions rakelib/ext_helper.rb
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion rakelib/extensions.rake
Expand Up @@ -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"
Expand Down

0 comments on commit 24f0e34

Please sign in to comment.