|
|
@@ -13,6 +13,12 @@ $engine_src = "../engine/."
|
|
|
$android_src = "../engine/os/android/*.java"
|
|
|
$manifest = "../engine/os/android/AndroidManifest.xml"
|
|
|
|
|
|
+$path = ""
|
|
|
+$engine_dest = ""
|
|
|
+$android_dest = ""
|
|
|
+
|
|
|
+$luajit = "../engine/third/ARMv7/luajit"
|
|
|
+
|
|
|
#------------------------------------------------------------------------------
|
|
|
def parse_command_line(args)
|
|
|
banner = "Usage: crown-android.rb --target <android-target> --name <project-name> --path <project-path>\n"
|
|
|
@@ -56,6 +62,9 @@ end
|
|
|
#------------------------------------------------------------------------------
|
|
|
def create_android_project(target, name, path)
|
|
|
|
|
|
+ engine_dest = path + "/jni"
|
|
|
+ android_dest = path + "/src/crown/android"
|
|
|
+
|
|
|
# Creates path if not exists
|
|
|
if not Dir.exists?(path)
|
|
|
FileUtils.mkdir_p(path)
|
|
|
@@ -70,19 +79,29 @@ def create_android_project(target, name, path)
|
|
|
# Updates android project
|
|
|
system($android_update + " --target " + target + " --name " + name + " --path " + path)
|
|
|
end
|
|
|
-
|
|
|
- engine_dest = path + "/jni"
|
|
|
- android_dest = path + "/src/crown/android"
|
|
|
|
|
|
# if jni dir does not exists, create it!
|
|
|
if not Dir.exists?(engine_dest)
|
|
|
FileUtils.mkdir_p(engine_dest)
|
|
|
- print "Created directory " + path + "/jni\n"
|
|
|
+ print "Created directory " + engine_dest + "\n"
|
|
|
end
|
|
|
+end
|
|
|
+
|
|
|
+#------------------------------------------------------------------------------
|
|
|
+def fill_android_project(path)
|
|
|
+
|
|
|
+ engine_dest = path + "/jni"
|
|
|
+ android_dest = path + "/src/crown/android"
|
|
|
|
|
|
# Copy Engine files
|
|
|
FileUtils.cp_r($engine_src, engine_dest, :remove_destination => true)
|
|
|
- print "Copied Engine to " + engine_dest + "/jni\n"
|
|
|
+ print "Copied Engine to " + engine_dest + "\n"
|
|
|
+
|
|
|
+ # Copy luajit dir
|
|
|
+ FileUtils.cp_r($luajit, engine_dest, :remove_destination => true)
|
|
|
+
|
|
|
+ # Copy luajit lib
|
|
|
+ FileUtils.cp($luajit + "/lib/libluajit-5.1.so.2.0.2", engine_dest + "/libluajit-5.1.so")
|
|
|
|
|
|
# Copy Java files
|
|
|
FileUtils.cp_r(Dir.glob($android_src), android_dest, :remove_destination => true)
|
|
|
@@ -93,6 +112,21 @@ def create_android_project(target, name, path)
|
|
|
print "Copied Android Manifest to " + path + "\n"
|
|
|
end
|
|
|
|
|
|
+#------------------------------------------------------------------------------
|
|
|
+def build_android_project(path)
|
|
|
+ # Move to root directory of Android project
|
|
|
+ Dir.chdir(path)
|
|
|
+
|
|
|
+ # Build libraries
|
|
|
+ system("ndk-build")
|
|
|
+
|
|
|
+ # Build apk
|
|
|
+ system("ant debug")
|
|
|
+end
|
|
|
+
|
|
|
#------------------------------------------------------------------------------
|
|
|
opts = parse_command_line(ARGV)
|
|
|
-create_android_project(opts.target, opts.name, opts.path)
|
|
|
+
|
|
|
+create_android_project(opts.target, opts.name, opts.path)
|
|
|
+fill_android_project(opts.path)
|
|
|
+build_android_project(opts.path)
|