Permalink
Browse files

Starting rakefile refactor.

  • Loading branch information...
1 parent 2be3a77 commit 57831d19733ef4b2c3f20473388220ed47ee898a @philcrissman philcrissman committed Sep 8, 2011
Showing with 112 additions and 18 deletions.
  1. +1 −0 Gemfile
  2. +12 −4 Gemfile.lock
  3. +98 −10 Rakefile
  4. +0 −1 make/rakefile_common.rb
  5. +1 −1 rakefile_darwin.rb
  6. +0 −1 rakefile_linux.rb
  7. +0 −1 rakefile_mingw.rb
View
@@ -1,6 +1,7 @@
source "http://rubygems.org"
gem "mechanize"
+gem "gherkin"
gem "cucumber"
gem "rspec"
gem "rake"
View
@@ -9,12 +9,17 @@ GEM
json (>= 1.4.6)
term-ansicolor (>= 1.0.5)
diff-lcs (1.1.2)
- gherkin (2.4.11)
+ gherkin (2.4.16)
json (>= 1.4.6)
json (1.5.3)
- mechanize (1.0.0)
- nokogiri (>= 1.2.1)
- nokogiri (1.4.4)
+ mechanize (2.0.1)
+ net-http-digest_auth (~> 1.1, >= 1.1.1)
+ net-http-persistent (~> 1.8)
+ nokogiri (~> 1.4)
+ webrobots (~> 0.0, >= 0.0.9)
+ net-http-digest_auth (1.1.1)
+ net-http-persistent (1.8.1)
+ nokogiri (1.5.0)
rake (0.9.2)
rspec (2.6.0)
rspec-core (~> 2.6.0)
@@ -28,12 +33,15 @@ GEM
cucumber
rspec
term-ansicolor (1.0.6)
+ webrobots (0.0.11)
+ nokogiri (>= 1.4.4)
PLATFORMS
ruby
DEPENDENCIES
cucumber
+ gherkin
mechanize
rake
rspec
View
108 Rakefile
@@ -1,7 +1,7 @@
require 'rubygems'
require 'rake'
require 'rake/clean'
-require_relative 'platform/skel'
+# require_relative 'platform/skel'
require 'fileutils'
require 'find'
require 'yaml'
@@ -57,17 +57,27 @@ def osx_bootstrap_env
ENV['SHOES_DEPS_PATH'] = '/usr/local'
end
+
+
case RUBY_PLATFORM
when /mingw/
require File.expand_path('rakefile_mingw')
Builder = MakeMinGW
+ NAMESPACE = :win32
when /darwin/
osx_bootstrap_env
- require File.expand_path('rakefile_darwin')
+ require File.expand_path('make/darwin/env')
+ require File.expand_path('make/darwin/tasks')
+
+ task :stub do
+ MakeDarwin.make_stub
+ end
Builder = MakeDarwin
+ NAMESPACE = :osx
when /linux/
require File.expand_path('rakefile_linux')
Builder = MakeLinux
+ NAMESPACE = :linux
else
puts "Sorry, your platform [#{RUBY_PLATFORM}] is not supported..."
end
@@ -81,6 +91,8 @@ task :default => [:build]
desc "Does a full compile, with installer"
task :package => [:build, :installer]
+task :build_os => [:build_skel, "dist/#{NAME}"]
+
task "shoes/version.h" do |t|
File.open(t.name, 'w') do |f|
f << %{#define SHOES_RELEASE_ID #{RELEASE_ID}\n#define SHOES_RELEASE_NAME "#{RELEASE_NAME}"\n#define SHOES_REVISION #{REVISION}\n#define SHOES_BUILD_DATE #{Time.now.strftime("%Y%m%d")}\n#define SHOES_PLATFORM "#{RUBY_PLATFORM}"\n}
@@ -100,11 +112,46 @@ SRC.zip(OBJ).each do |c, o|
file o => [c] + Dir["shoes/*.h"]
end
+# ------
+# skel
+
+def skel_replace(line)
+ line.gsub! /\s+%DEFAULTS%/ do
+ if APPARGS
+ args = APPARGS.split(/\s+/)
+ %{
+ char *default_argv[] = {argv[0], #{args.inspect[1..-2]}};
+ argv = default_argv;
+ argc = #{args.length + 1};
+ }
+ end
+ end
+ line
+end
+
+# preprocess .skel
+task :build_skel do |t|
+ Dir["bin/*.skel"].each do |src|
+ name = src.gsub(/\.skel$/, '.c')
+ File.open(src) do |skel|
+ File.open(name, 'w') do |c|
+ skel.each_line do |line|
+ c << skel_replace(line)
+ end
+ end
+ end
+ end
+end
+
# --------------------------
# tasks depending on Builder = MakeLinux|MakeDarwin|MakeMinGW
desc "Does a full compile, for the OS you're running on"
-task :build => [:build_os, "dist/VERSION.txt"] do
+task :build => ["#{NAMESPACE}:build"]
+
+# first refactor ; build calls platform namespaced build;
+# for now, each of those calls the old build method.
+task :old_build => [:build_os, "dist/VERSION.txt"] do
Builder.common_build
Builder.copy_deps_to_dist
Builder.copy_files_to_dist
@@ -113,13 +160,9 @@ end
directory 'dist'
-task "dist/#{NAME}" => ["dist/lib#{SONAME}.#{DLEXT}", "bin/main.o"] + ADD_DLL do |t|
- Builder.make_app t.name
-end
+task "dist/#{NAME}" => ["dist/lib#{SONAME}.#{DLEXT}", "bin/main.o"] + ADD_DLL + ["#{NAMESPACE}:make_app"]
-task "dist/lib#{SONAME}.#{DLEXT}" => ['shoes/version.h', 'dist'] + OBJ do |t|
- Builder.make_so t.name
-end
+task "dist/lib#{SONAME}.#{DLEXT}" => ['shoes/version.h', 'dist'] + OBJ + ["#{NAMESPACE}:make_so"]
rule ".o" => ".m" do |t|
Builder.cc t
@@ -140,6 +183,7 @@ end
namespace :osx do
namespace :deps do
+ desc "Installs OS X dependencies"
task :install => :bootstrap do
homebrew_install "cairo"
sh "brew link cairo" unless File.exist?("/usr/local/lib/libcairo.2.dylib")
@@ -151,7 +195,7 @@ namespace :osx do
homebrew_install "cairo"
homebrew_install "gettext"
end
-
+
task :bootstrap do
# For now, pull in this patched glib formula
cd `brew --prefix`.chomp do
@@ -163,6 +207,50 @@ namespace :osx do
end
end
end
+
+ task :build => [:build_skel, "dist/#{NAME}", "dist/VERSION.txt"] do
+ Builder.common_build
+ Builder.copy_deps_to_dist
+ Builder.copy_files_to_dist
+ Builder.setup_system_resources
+ end
+
+ task :make_app do
+ Builder.make_app "dist/#{NAME}"
+ end
+
+ task :make_so do
+ name = "dist/lib#{SONAME}.#{DLEXT}"
+ ldflags = LINUX_LDFLAGS.sub! /INSTALL_NAME/, "-install_name @executable_path/lib#{SONAME}.#{DLEXT}"
+ sh "#{CC} -o #{name} #{OBJ.join(' ')} #{LINUX_LDFLAGS} #{LINUX_LIBS}"
+ %w[libpostproc.dylib libavformat.dylib libavcodec.dylib libavutil.dylib libruby.dylib].each do |libn|
+ sh "install_name_tool -change /tmp/dep/lib/#{libn} ./deps/lib/#{libn} #{name}"
+ end
+ end
+end
+
+namespace :win32 do
+ task :build => [:old_build]
+
+ task :make_app do
+ Builder.make_app "dist/#{NAME}"
+ end
+
+ task :make_so do
+ Builder.make_so "dist/lib#{SONAME}.#{DLEXT}"
+ end
+end
+
+namespace :linux do
+ task :build => [:old_build]
+
+ task :make_app do
+ Builder.make_app "dist/#{NAME}"
+ end
+
+ task :make_so do
+ Builder.make_so "dist/lib#{SONAME}.#{DLEXT}"
+ end
end
def homebrew_install package
View
@@ -1 +0,0 @@
-task :build_os => [:build_skel, "dist/#{NAME}"]
View
@@ -1,4 +1,4 @@
-require File.expand_path('make/rakefile_common')
+
require File.expand_path('make/darwin/env')
require File.expand_path('make/darwin/tasks')
View
@@ -1,3 +1,2 @@
-require File.expand_path('make/rakefile_common')
require File.expand_path('make/linux/env')
require File.expand_path('make/linux/tasks')
View
@@ -1,4 +1,3 @@
-require File.expand_path('make/rakefile_common')
require File.expand_path('make/mingw/env')
require File.expand_path('make/mingw/tasks')

0 comments on commit 57831d1

Please sign in to comment.