Browse Source

added gradle project for Android

dmuratshin 9 years ago
parent
commit
d608af48c8

+ 1 - 0
.gitignore

@@ -29,6 +29,7 @@ oxygine/SDL/android/lib/gen/
 .idea
 .idea
 oxygine/SDL/android/lib/bin/
 oxygine/SDL/android/lib/bin/
 examples/*/data-ram/
 examples/*/data-ram/
+.gradle/
 examples/*/proj.android/libs/
 examples/*/proj.android/libs/
 oxygine/SDL/android/lib/src/org/libsdl/app/SDLActivity.java
 oxygine/SDL/android/lib/src/org/libsdl/app/SDLActivity.java
 oxygine-framework-with-sdl.zip
 oxygine-framework-with-sdl.zip

+ 47 - 0
examples/HelloWorld/proj.android/build.gradle

@@ -0,0 +1,47 @@
+buildscript {
+    repositories {
+        mavenCentral()
+    }
+    dependencies {
+        classpath 'com.android.tools.build:gradle:1.0.+'
+    }
+}
+
+apply plugin: 'com.android.application'
+
+
+
+dependencies {
+		compile(project(':oxygine-extension'))
+        compile(project(':oxygine-lib')) { exclude module: 'oxygine-extension' }
+    }
+
+android {
+		enforceUniquePackageName=false
+		
+        compileSdkVersion 23
+        buildToolsVersion '23.0.2'
+
+        task buildNative(type: Exec) {
+            commandLine 'cmd', '/c', 'build.bat'
+            standardOutput = new ByteArrayOutputStream()
+
+            ext.output = {
+                return standardOutput.toString()
+            }
+        }        
+
+        tasks.withType(JavaCompile) {
+                compileTask -> compileTask.dependsOn buildNative
+        }
+
+  		sourceSets {
+            main {
+                jniLibs.srcDirs = ['libs']
+                manifest.srcFile 'AndroidManifest.xml'
+                java.srcDirs = ['src']
+                res.srcDirs = ['res']
+                assets.srcDirs = ['../data']
+            }
+        }
+}

+ 5 - 0
examples/HelloWorld/proj.android/settings.gradle

@@ -0,0 +1,5 @@
+include 'oxygine-lib'
+project(':oxygine-lib').projectDir = new File('../../../..//oxygine-framework/oxygine/SDL/android/lib')
+
+include 'oxygine-extension'
+project(':oxygine-extension').projectDir = new File('../../../..//oxygine-framework/oxygine/SDL/android/extension')

+ 23 - 0
oxygine/SDL/android/extension/build.gradle

@@ -0,0 +1,23 @@
+buildscript {
+    repositories {
+        mavenCentral()
+    }
+    dependencies {
+        classpath 'com.android.tools.build:gradle:1.0.+'
+    }
+}
+
+apply plugin: 'com.android.library'
+
+android {
+        compileSdkVersion 23
+  		buildToolsVersion '23.0.2'
+
+        sourceSets {
+            main {
+                manifest.srcFile 'AndroidManifest.xml'
+                java.srcDirs = ['src']
+                res.srcDirs = ['res']
+            }
+        }
+}

+ 31 - 0
oxygine/SDL/android/lib/build.gradle

@@ -0,0 +1,31 @@
+buildscript {
+    repositories {
+        mavenCentral()
+    }
+    dependencies {
+        classpath 'com.android.tools.build:gradle:1.0.+'
+    }
+}
+
+apply plugin: 'com.android.library'
+
+dependencies {
+        compile project(':oxygine-extension')
+    }
+
+android {
+		lintOptions {
+        	abortOnError false
+    	}
+
+        compileSdkVersion 23
+  		buildToolsVersion '23.0.2'
+
+  		sourceSets {
+            main {
+                manifest.srcFile 'AndroidManifest.xml'
+                java.srcDirs = ['src']
+                res.srcDirs = ['res']
+            }
+        }
+}

+ 2 - 0
oxygine/SDL/android/lib/settings.gradle

@@ -0,0 +1,2 @@
+include 'oxygine-extension'
+project(':oxygine-extension').projectDir = new File('../extension')

+ 19 - 0
oxygine/src/core/emscripten/emsc.cpp

@@ -0,0 +1,19 @@
+#include "emsc.h"
+namespace oxygine
+{
+	void emscSyncFS(bool read)
+	{
+#ifdef EMSCRIPTEN
+		EM_ASM_ARGS({
+			FS.mkdir('/data');
+		FS.mount(IDBFS,{}, '/data');
+
+		FS.syncfs(true, function(err) {
+			// handle callback
+		});
+		}, 0);
+#else
+
+#endif
+	}
+}

+ 18 - 0
oxygine/src/core/emscripten/emsc.h

@@ -0,0 +1,18 @@
+#pragma once
+#include "oxygine_include.h"
+#include "Event.h"
+namespace oxygine
+{
+	class EmscSyncFsEvent:public Event
+	{
+	public:
+		enum 
+		{
+			EVENT = sysEventID('E', 'S', 'F')
+		};
+	};
+
+
+	/**will dispatch EmscSyncFsEvent to core::dispatcher*/
+	void emscSyncFS(bool read);
+}