Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
rhodes-core: common app_bootstrap.rake to omit execution of app-speci…
…fic Rakefile
  • Loading branch information
alex-epifanoff committed Sep 12, 2014
1 parent 5b3197d commit e0f5ebd
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 36 deletions.
14 changes: 10 additions & 4 deletions bin/rho
Expand Up @@ -7,6 +7,7 @@ nativelibdir = File.join( libdir, "x86_64-darwin13.0" )
gemsdir = File.join( rubyroot,'lib','ruby','gems','2.1.0')

rhodesbin = File.join( File.dirname(__FILE__), "rhodes" )
bootstrap = File.expand_path( File.join( File.dirname(__FILE__), '..', 'lib', 'build', 'app_bootstrap.rake' ) )

args = ''
ARGV.each { |arg|
Expand All @@ -25,10 +26,6 @@ rhodes_commands = [
'spec'
]

executable = (ARGV.length==0 or rhodes_commands.include?(ARGV[0])) ? rhodesbin : 'rake'

cmdline = "#{executable} #{args}"

env =
{
"PATH" => "#{bindir}:#{ENV['PATH']}",
Expand All @@ -37,4 +34,13 @@ env =
"GEM_HOME" => gemsdir
}

if ARGV.length==0 or rhodes_commands.include?(ARGV[0])
executable = rhodesbin
else
executable = 'rake'
args += " --rakefile \"#{bootstrap}\""
end

cmdline = "#{executable} #{args}"

exec( env, cmdline )
32 changes: 32 additions & 0 deletions ext/extconf-core.rb
@@ -0,0 +1,32 @@
require 'fileutils'
include FileUtils

#mv File.dirname(__FILE__) +"/../rakefile.rb", File.dirname(__FILE__) +"/../Rakefile"

cp File.dirname(__FILE__) +"/../rhobuild.yml.example", File.dirname(__FILE__) +"/../rhobuild.yml" unless File.exists? File.dirname(__FILE__) +"/../rhobuild.yml"

#hack upon hack. Since build files are modified, all the files need to be writable.
#Only because iphone sim doesn work if you run it with sudo
chmod_R 0777, File.dirname(__FILE__) + "/.."

=begin
File.chmod 0755, File.dirname(__FILE__) + "/../bin/get-rhodes-info"
File.chmod 0755, File.dirname(__FILE__) + "/../bin/migrate-rhodes-app"
File.chmod 0755, File.dirname(__FILE__) + "/../bin/rhodes"
File.chmod 0755, File.dirname(__FILE__) + "/../bin/rhodes-setup"
File.chmod 0755, File.dirname(__FILE__) + "/../bin/rhogen"
File.chmod 0755, File.dirname(__FILE__) + "/../bin/set-rhodes-sdk"
File.chmod 0755, File.dirname(__FILE__) + "/../bin/upgrade-rhodes-app"
=end

#This is the hack, we make all the things to make it look like an extension has compiled

File.open('Makefile', 'w') { |f| f.write "all:\n\ninstall:\n\n" }
File.open('make', 'w') do |f|
f.write '#!/bin/sh'
f.chmod f.stat.mode | 0111
end
File.open('rhodes_postinstallhack' + '.so', 'w') { |f| f.chmod 0777}
File.open('rhodes_postinstallhack' + '.dll', 'w') { |f| f.chmod 0777}
File.open('nmake.bat', 'w') { |f| f.write "ECHO \"Done\""
f.chmod 0777}
34 changes: 34 additions & 0 deletions lib/build/app_bootstrap.rake
@@ -0,0 +1,34 @@
require 'yaml'

unless File.exists? "build.yml"
puts "Cannot find build.yml"
exit 1
end

$app_config = YAML::load_file("build.yml")
$app_path = Dir.getwd

if ENV["RHO_HOME"].nil?
if $app_config["sdk"]
rakefilepath = File.join(File.expand_path($app_config['sdk']), 'Rakefile')
else
begin
rakefilepath = File.expand_path( File.join(File.dirname(__FILE__), '..', '..', 'Rakefile' ) )
rescue
rakefilepath = ""
end
end
else
rakefilepath = "#{ENV["RHO_HOME"]}/Rakefile"
end

unless File.exists? rakefilepath
puts "\nCannot find your Rhodes gem or source path: #{rakefilepath}"
puts "\nIf you have the sdk on your path or have installed the gem this"
puts "can be resolved by running 'set-rhodes-sdk'"
puts "\nYou can also set this manually by modifying your build.yml or"
puts "setting the environment variable RHO_HOME"
exit 1
end

load rakefilepath
43 changes: 11 additions & 32 deletions rhodes-core.gemspec
@@ -1,6 +1,10 @@
# -*- encoding: utf-8 -*-

Gem::Specification.new do |s|

require 'FileUtils'
FileUtils.cp "Rakefile", "rakefile.rb"

s.name = %q{rhodes-core}
s.version = File.read('version').chomp

Expand All @@ -12,6 +16,7 @@ Gem::Specification.new do |s|
s.extra_rdoc_files = ["README.md", "LICENSE"]

folders_to_include = [
"./bin",
"./ext",
"./lib/build",
"./lib/rhodes",
Expand All @@ -20,14 +25,17 @@ Gem::Specification.new do |s|
"./platform/wm/build",
"./platform/wp7/build",
"./platform/wp8/build",
"./platform/linux/tasks/linux.rake",
"./platform/osx/build/osx.rake",
"./res/build-tools/ruby-standalone",
"./res/generators"
]

files = [
'lib/rhodes.rb',
'rakefile.rb',
'rhobuild.yml.example'
'Rakefile',
'rhobuild.yml.example',
'platform/shared/common/RhoDefs.h'
]

require 'find'
Expand All @@ -42,39 +50,10 @@ Gem::Specification.new do |s|
s.homepage = %q{http://www.rhomobile.com}

s.require_paths = ["lib"]
#s.rubyforge_project = %q{rhodes}
#s.rubygems_version = %q{1.3.5}
s.add_dependency('templater', '>= 0.5.0')
s.add_dependency('rake', '>= 0.9.2')
s.add_dependency('uuid', '>= 2.3.2')
s.add_dependency('systemu', '>= 2.5.0')
s.add_dependency('json', '~>1.5.4')
s.add_dependency('rest-client', '~>1.6.6')

s.executables << 'rhogen'
s.executables << 'rhodes'
s.executables << 'upgrade-rhodes-app'
s.executables << 'rhodes-setup'
s.executables << 'set-rhodes-sdk'
s.executables << 'migrate-rhodes-app'
s.executables << 'get-rhodes-info'

s.executables << 'rho'
#this is a hack, we dont have an extension, but we want to run postinstall code. It's done via the 'building' of an extension
s.extensions << 'ext/extconf.rb'
s.extensions << 'ext/extconf-core.rb'
s.summary = %q{The Rhodes framework is the easiest way to develop NATIVE apps with full device capabilities (GPS, PIM, camera, etc.) for any smartphone.}

if s.respond_to? :specification_version then
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
s.specification_version = 2

if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
s.add_runtime_dependency(%q<diff-lcs>, [">= 1.1.2"])
else
s.add_dependency(%q<diff-lcs>, [">= 1.1.2"])
end
else
s.add_dependency(%q<diff-lcs>, [">= 1.1.2"])
end
end

0 comments on commit e0f5ebd

Please sign in to comment.