rakefile.rb in rhodes-2.2.6 vs rakefile.rb in rhodes-2.3.0.beta.1

- old
+ new

@@ -49,98 +49,97 @@ puts `#{rhoruby} -I#{File.expand_path('spec/framework_spec/app/')} -I#{File.expand_path('lib/framework')} -I#{File.expand_path('lib/test')} -Clib/test framework_test.rb` end end -$application_build_configs_keys = ['security_token'] +$application_build_configs_keys = ['security_token', 'encrypt_database'] def make_application_build_config_header_file - inc_file = File.join($startdir, "platform", "shared", "common", "app_build_configs.c") - File.open(inc_file, "w") do |f| + f = StringIO.new("", "w+") + f.puts "// WARNING! THIS FILE IS GENERATED AUTOMATICALLY! DO NOT EDIT IT MANUALLY!" + #f.puts "// Generated #{Time.now.to_s}" + f.puts "" + f.puts "#include <string.h>" + f.puts "" + f.puts '#include "app_build_configs.h"' + f.puts "" + + f.puts 'static const char* keys[] = { ""' + $application_build_configs.keys.each do |key| + f.puts ',"'+key+'"' + end + f.puts '};' + f.puts '' + + count = 1 + + f.puts 'static const char* values[] = { ""' + $application_build_configs.keys.each do |key| + f.puts ',"'+$application_build_configs[key]+'"' + count = count + 1 + end + f.puts '};' + f.puts '' + + f.puts '#define APP_BUILD_CONFIG_COUNT '+count.to_s + f.puts '' + f.puts 'const char* get_app_build_config_item(const char* key) {' + f.puts ' int i;' + f.puts ' for (i = 1; i < APP_BUILD_CONFIG_COUNT; i++) {' + f.puts ' if (strcmp(key, keys[i]) == 0) {' + f.puts ' return values[i];' + f.puts ' }' + f.puts ' }' + f.puts ' return 0;' + f.puts '}' + f.puts '' + + Jake.modify_file_if_content_changed(File.join($startdir, "platform", "shared", "common", "app_build_configs.c"), f) +end + +def make_application_build_config_java_file + + f = StringIO.new("", "w+") f.puts "// WARNING! THIS FILE IS GENERATED AUTOMATICALLY! DO NOT EDIT IT MANUALLY!" - f.puts "// Generated #{Time.now.to_s}" + #f.puts "// Generated #{Time.now.to_s}" + + f.puts "package com.rho;" f.puts "" - f.puts "#include <string.h>" - f.puts "" - f.puts '#include "app_build_configs.h"' - f.puts "" - - f.puts 'static const char* keys[] = { ""' + f.puts "public class AppBuildConfig {" + + f.puts 'static final String keys[] = { ""' $application_build_configs.keys.each do |key| f.puts ',"'+key+'"' end f.puts '};' f.puts '' count = 1 - f.puts 'static const char* values[] = { ""' + f.puts 'static final String values[] = { ""' $application_build_configs.keys.each do |key| f.puts ',"'+$application_build_configs[key]+'"' count = count + 1 end f.puts '};' f.puts '' - f.puts '#define APP_BUILD_CONFIG_COUNT '+count.to_s + f.puts 'static final int APP_BUILD_CONFIG_COUNT = '+count.to_s + ';' f.puts '' - f.puts 'const char* get_app_build_config_item(const char* key) {' - f.puts ' int i;' - f.puts ' for (i = 1; i < APP_BUILD_CONFIG_COUNT; i++) {' - f.puts ' if (strcmp(key, keys[i]) == 0) {' + f.puts 'public static String getItem(String key){' + f.puts ' for (int i = 1; i < APP_BUILD_CONFIG_COUNT; i++) {' + f.puts ' if ( key.compareTo( keys[i]) == 0) {' f.puts ' return values[i];' f.puts ' }' f.puts ' }' - f.puts ' return 0;' + f.puts ' return null;' f.puts '}' - f.puts '' + f.puts "}" - end + Jake.modify_file_if_content_changed( File.join( $startdir, "platform/bb/RubyVM/src/com/rho/AppBuildConfig.java" ), f ) end -def make_application_build_config_java_file - file_name = $startdir + "/platform/bb/RubyVM/src/com/rho/AppBuildConfig.java" - - File.open(file_name, "w") do |f| - f.puts "// WARNING! THIS FILE IS GENERATED AUTOMATICALLY! DO NOT EDIT IT MANUALLY!" - f.puts "// Generated #{Time.now.to_s}" - - f.puts "package com.rho;" - f.puts "" - f.puts "public class AppBuildConfig {" - - f.puts 'static final String keys[] = { ""' - $application_build_configs.keys.each do |key| - f.puts ',"'+key+'"' - end - f.puts '};' - f.puts '' - - count = 1 - - f.puts 'static final String values[] = { ""' - $application_build_configs.keys.each do |key| - f.puts ',"'+$application_build_configs[key]+'"' - count = count + 1 - end - f.puts '};' - f.puts '' - - f.puts 'static final int APP_BUILD_CONFIG_COUNT = '+count.to_s + ';' - f.puts '' - f.puts 'public static String getItem(String key){' - f.puts ' for (int i = 1; i < APP_BUILD_CONFIG_COUNT; i++) {' - f.puts ' if ( key.compareTo( keys[i]) == 0) {' - f.puts ' return values[i];' - f.puts ' }' - f.puts ' }' - f.puts ' return null;' - f.puts '}' - f.puts "}" - end -end - namespace "config" do task :common do $startdir = File.dirname(__FILE__) $binextensions = [] buildyml = 'rhobuild.yml' @@ -303,11 +302,11 @@ def init_extensions(startdir, dest) extentries = [] extlibs = [] extpaths = $app_config["extpaths"] - + $app_config["extensions"].each do |extname| extpath = nil extpaths.each do |p| ep = File.join(p, extname) if File.exists? ep @@ -348,22 +347,24 @@ end end end + exts = File.join($startdir, "platform", "shared", "ruby", "ext", "rho", "extensions.c") + + #if $config["platform"] != "bb" && !FileUtils.uptodate?(exts,[File.join($app_path, "build.yml")]) if $config["platform"] != "bb" - exts = File.join($startdir, "platform", "shared", "ruby", "ext", "rho", "extensions.c") exists = [] File.new(exts, "r").read.split("\n").each do |line| next if line !~ /^\s*extern\s+void\s+([A-Za-z_][A-Za-z0-9_]*)/ exists << $1 end if exists.sort! != extentries.sort! File.open(exts, "w") do |f| f.puts "// WARNING! THIS FILE IS GENERATED AUTOMATICALLY! DO NOT EDIT IT MANUALLY!" - f.puts "// Generated #{Time.now.to_s}" + #f.puts "// Generated #{Time.now.to_s}" if $config["platform"] == "wm" || $config["platform"] == "win32" # Add libraries through pragma extlibs.each do |lib| f.puts "#pragma comment(lib, \"#{lib}\")" end @@ -432,10 +433,11 @@ cp_r app + '/public', File.join($srcdir,'apps'), :preserve => true if File.exists? app + '/public' cp app + '/rhoconfig.txt', File.join($srcdir,'apps'), :preserve => true app_version = "\r\napp_version='#{$app_config["version"]}'" File.open(File.join($srcdir,'apps/rhoconfig.txt'), "a"){ |f| f.write(app_version) } + File.open(File.join($srcdir,'apps/rhoconfig.txt.timestamp'), "w"){ |f| f.write(Time.now.to_f().to_s()) } unless $debug rm_rf $srcdir + "/apps/app/test" rm_rf $srcdir + "/apps/app/SpecRunner" rm_rf $srcdir + "/apps/app/mspec" @@ -444,28 +446,31 @@ end copy_assets($assetfolder) if ($assetfolder and File.exists? $assetfolder) - chdir File.join($srcdir,'apps') - replace_platform = $config['platform'] replace_platform = "bb6" if $bb6 - Dir.glob("**/*.#{replace_platform}.*").each do |file| - oldfile = file.gsub(Regexp.new(Regexp.escape('.') + replace_platform + Regexp.escape('.')),'.') - rm oldfile if File.exists? oldfile - mv file,oldfile - end + replace_platform = "wm" if replace_platform == 'win32' - Dir.glob("**/*.wm.*").each { |f| rm f } - Dir.glob("**/*.iphone.*").each { |f| rm f } - Dir.glob("**/*.bb.*").each { |f| rm f } - Dir.glob("**/*.bb6.*").each { |f| rm f } - Dir.glob("**/*.android.*").each { |f| rm f } - Dir.glob("**/.svn").each { |f| rm_rf f } - Dir.glob("**/CVS").each { |f| rm_rf f } - + [File.join($srcdir,'apps'), ($current_platform == "bb" ? File.join($srcdir,'res') : File.join($srcdir,'lib/res'))].each do |folder| + chdir folder + + Dir.glob("**/*.#{replace_platform}.*").each do |file| + oldfile = file.gsub(Regexp.new(Regexp.escape('.') + replace_platform + Regexp.escape('.')),'.') + rm oldfile if File.exists? oldfile + mv file,oldfile + end + + Dir.glob("**/*.wm.*").each { |f| rm f } + Dir.glob("**/*.iphone.*").each { |f| rm f } + Dir.glob("**/*.bb.*").each { |f| rm f } + Dir.glob("**/*.bb6.*").each { |f| rm f } + Dir.glob("**/*.android.*").each { |f| rm f } + Dir.glob("**/.svn").each { |f| rm_rf f } + Dir.glob("**/CVS").each { |f| rm_rf f } + end end def create_manifest dir = File.join($srcdir, 'apps') #fname = "config.rb" @@ -929,6 +934,6 @@ chdir startdir rm_rf bin_dir end -end \ No newline at end of file +end