Skip to content

Commit

Permalink
Edited a little bit to build shoes.exe on Windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
ashbb committed Mar 25, 2012
1 parent 75ae4a9 commit 938e470
Show file tree
Hide file tree
Showing 3 changed files with 130 additions and 2 deletions.
127 changes: 127 additions & 0 deletions Rakefile_for_windows
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
$:.unshift '.'

require 'rubygems'
require 'rake'
require 'rake/clean'
if RUBY_VERSION != '1.8.7'
require_relative 'platform/skel'
else
require File.join(File.dirname(__FILE__), 'platform/skel')
end
require 'fileutils'
require 'find'
require 'yaml'
include FileUtils

APP = YAML.load_file(File.join(ENV['APP'] || ".", "app.yaml"))
APPNAME = APP['name']
RELEASE_ID, RELEASE_NAME = APP['version'], APP['release']
NAME = APP['shortname'] || APP['name'].downcase.gsub(/\W+/, '')
SONAME = 'shoes'

GIT = ENV['GIT'] || "git"
REVISION = (`#{GIT} rev-list HEAD`.split.length + 1).to_s
VERS = ENV['VERSION'] || "0.r#{REVISION}"
PKG = "#{NAME}-#{VERS}"
APPARGS = APP['run']
FLAGS = %w[DEBUG VIDEO]
VLC_VERSION = (RUBY_PLATFORM =~ /win32/ ? "0.8": `vlc --version 2>/dev/null`.split[2])
VLC_0_8 = VLC_VERSION !~ /^0\.9/

BIN = "*.{bundle,jar,o,so,obj,pdb,pch,res,lib,def,exp,exe,ilk}"
CLEAN.include ["{bin,shoes}/#{BIN}", "req/**/#{BIN}", "dist"]

RUBY_SO = RbConfig::CONFIG['RUBY_SO_NAME']
RUBY_V = RbConfig::CONFIG['ruby_version']
RUBY_LIB_BASE = File.basename(RbConfig::CONFIG['libdir'])
RUBY_PROGRAM_VERSION = RbConfig::CONFIG['RUBY_PROGRAM_VERSION']
SHOES_RUBY_ARCH = RbConfig::CONFIG['arch']
RUBY_1_9 = (RUBY_V =~ /^1\.9/)
if RUBY_1_9
$: << "."
end

if ENV['APP']
%w[dmg icons].each do |subk|
APP[subk].keys.each do |name|
APP[subk][name] = File.join(ENV['APP'], APP[subk][name])
end
end
end

if File.exists? ".git/refs/tags/#{RELEASE_ID}/#{RELEASE_NAME}"
abort "** Rename this release (and add to lib/shoes.rb) #{RELEASE_NAME} has already been tagged."
end

case RUBY_PLATFORM
when /mingw/
require File.expand_path('rakefile_mingw')
Builder = MakeMinGW
when /darwin/
require File.expand_path('rakefile_darwin')
Builder = MakeDarwin
when /linux/
require File.expand_path('rakefile_linux')
Builder = MakeLinux
else
puts "Sorry, your platform [#{RUBY_PLATFORM}] is not supported..."
end

# --------------------------
# common platform tasks

desc "Same as `rake build'"
task :default => [:build]

desc "Does a full compile, with installer"
task :package => [:build, :installer]

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}
end
end

task "dist/VERSION.txt" do |t|
File.open(t.name, 'w') do |f|
f << %{shoes #{RELEASE_NAME.downcase} (0.r#{REVISION}) [#{RUBY_PLATFORM} Ruby#{RUBY_VERSION}]}
%w[VIDEO DEBUG].each { |x| f << " +#{x.downcase}" if ENV[x] }
f << "\n"
end
end

# shoes is small, if any include changes, go ahead and build from scratch.
SRC.zip(OBJ).each do |c, o|
file o => [c] + Dir["shoes/*.h"]
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
Builder.common_build
Builder.copy_deps_to_dist
Builder.copy_files_to_dist
Builder.setup_system_resources
end

task "dist/#{NAME}" => ["dist/lib#{SONAME}.#{DLEXT}", "bin/main.o"] + ADD_DLL do |t|
Builder.make_app t.name
end

task "dist/lib#{SONAME}.#{DLEXT}" => ['shoes/version.h'] + OBJ do |t|
Builder.make_so t.name
end

rule ".o" => ".m" do |t|
Builder.cc t
end

rule ".o" => ".c" do |t|
Builder.cc t
end

task :installer do
Builder.make_installer
end
2 changes: 1 addition & 1 deletion lib/shoes/encoding.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Only needed on windows (encoding.data not installed for linux/darwin)
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw/
if RUBY_PLATFORM =~ /mswin|mingw/
IO.read(File.join DIR, 'encoding.data').
each_line{|file| require File.join(DIR, 'ruby/lib/i386-mingw32/enc', file.chomp)}
end
3 changes: 2 additions & 1 deletion shoes/world.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ shoes_ruby_embed()
char** sysinit_argv = NULL;
RUBY_INIT_STACK;
#ifdef SHOES_WIN32
ruby_sysinit(0, 0);
int sysinit_argc = 0;
ruby_sysinit( &sysinit_argc, &sysinit_argv );
#endif
ruby_init();
v = (VALUE)ruby_options(3, argv);
Expand Down

1 comment on commit 938e470

@ashbb
Copy link
Owner Author

@ashbb ashbb commented on 938e470 Mar 25, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't merge Rakefile. So, I added Rakefile for Windows as named Rakefile_for_windows. Now, you can build shoes.exe after renaming from Rakefile_for_windows to Rakefile.

Please sign in to comment.