diff --git a/native/tools/simulator/frameworks/runtime-src/proj.android-studio/.gitignore b/native/tools/simulator/frameworks/runtime-src/proj.android-studio/.gitignore new file mode 100755 index 0000000000..9c4de5825b --- /dev/null +++ b/native/tools/simulator/frameworks/runtime-src/proj.android-studio/.gitignore @@ -0,0 +1,7 @@ +.gradle +/local.properties +/.idea/workspace.xml +/.idea/libraries +.DS_Store +/build +/captures diff --git a/native/tools/simulator/frameworks/runtime-src/proj.android-studio/app/.gitignore b/native/tools/simulator/frameworks/runtime-src/proj.android-studio/app/.gitignore new file mode 100755 index 0000000000..1de99493d6 --- /dev/null +++ b/native/tools/simulator/frameworks/runtime-src/proj.android-studio/app/.gitignore @@ -0,0 +1,2 @@ +/build +/jniLibs diff --git a/native/tools/simulator/frameworks/runtime-src/proj.android-studio/app/AndroidManifest.xml b/native/tools/simulator/frameworks/runtime-src/proj.android-studio/app/AndroidManifest.xml new file mode 100755 index 0000000000..e05719fcf3 --- /dev/null +++ b/native/tools/simulator/frameworks/runtime-src/proj.android-studio/app/AndroidManifest.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/native/tools/simulator/frameworks/runtime-src/proj.android-studio/app/assets/config.json b/native/tools/simulator/frameworks/runtime-src/proj.android-studio/app/assets/config.json new file mode 100644 index 0000000000..6b6a7d02bc --- /dev/null +++ b/native/tools/simulator/frameworks/runtime-src/proj.android-studio/app/assets/config.json @@ -0,0 +1,65 @@ +{ + "init_cfg":{ + "isLandscape": true, + "isWindowTop": false, + "name": "Simulator", + "width": 960, + "height": 640, + "entry": "main.js", + "consolePort": 6050, + "uploadPort": 6060, + "debugPort": 5086 + }, + "simulator_screen_size": [ + { + "title": "iPhone 3Gs (480x320)", + "width": 480, + "height": 320 + }, + { + "title": "iPhone 4 (960x640)", + "width": 960, + "height": 640 + }, + { + "title": "iPhone 5 (1136x640)", + "width": 1136, + "height": 640 + }, + { + "title": "iPhone 6 (1334x750)", + "width": 1334, + "height": 750 + }, + { + "title": "iPhone 6 Plus (1920x1080)", + "width": 1920, + "height": 1080 + }, + { + "title": "iPad (1024x768)", + "width": 1024, + "height": 768 + }, + { + "title": "iPad Retina (2048x1536)", + "width": 2048, + "height": 1536 + }, + { + "title": "Android (800x480)", + "width": 800, + "height": 480 + }, + { + "title": "Android (854x480)", + "width": 854, + "height": 480 + }, + { + "title": "Android (1280x720)", + "width": 1280, + "height": 720 + } + ] +} diff --git a/native/tools/simulator/frameworks/runtime-src/proj.android-studio/app/build.gradle b/native/tools/simulator/frameworks/runtime-src/proj.android-studio/app/build.gradle new file mode 100755 index 0000000000..7c529111af --- /dev/null +++ b/native/tools/simulator/frameworks/runtime-src/proj.android-studio/app/build.gradle @@ -0,0 +1,107 @@ +import org.apache.tools.ant.taskdefs.condition.Os + +apply plugin: 'com.android.application' + +android { + compileSdkVersion 22 + buildToolsVersion "25.0.0" + + defaultConfig { + applicationId "org.cocos2d.helloworld" + minSdkVersion 10 + targetSdkVersion PROP_TARGET_SDK_VERSION + versionCode 1 + versionName "1.0" + + externalNativeBuild { + ndkBuild { + if (!project.hasProperty("PROP_NDK_MODE") || PROP_NDK_MODE.compareTo('none') != 0) { + // skip the NDK Build step if PROP_NDK_MODE is none + targets 'cocos2djs' + arguments 'NDK_TOOLCHAIN_VERSION=4.9' + arguments 'APP_PLATFORM=android-'+PROP_TARGET_SDK_VERSION + + def module_paths = [project.file("../../../../../.."), + project.file("../../../../../../cocos"), + project.file("../../../../../../external")] + if (Os.isFamily(Os.FAMILY_WINDOWS)) { + arguments 'NDK_MODULE_PATH=' + module_paths.join(";") + } + else { + arguments 'NDK_MODULE_PATH=' + module_paths.join(':') + } + + arguments '-j' + Runtime.runtime.availableProcessors() + abiFilters.addAll(PROP_APP_ABI.split(':').collect{it as String}) + } + } + } + } + + sourceSets.main { + java.srcDir "src" + res.srcDir "res" + manifest.srcFile "AndroidManifest.xml" + } + + externalNativeBuild { + ndkBuild { + if (!project.hasProperty("PROP_NDK_MODE") || PROP_NDK_MODE.compareTo('none') != 0) { + // skip the NDK Build step if PROP_NDK_MODE is none + path "jni/Android.mk" + } + } + } + + signingConfigs { + release { + if (project.hasProperty("RELEASE_STORE_FILE")) { + storeFile file('/Users/jryin/.android/debug.keystore') + storePassword 'android' + keyAlias 'androiddebugkey' + keyPassword 'android' + } + } + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + if (project.hasProperty("RELEASE_STORE_FILE")) { + signingConfig signingConfigs.release + } + + externalNativeBuild { + ndkBuild { + arguments 'NDK_DEBUG=0' + } + } + } + + debug { + externalNativeBuild { + ndkBuild { + arguments 'NDK_DEBUG=1' + } + } + } + } +} + +android.applicationVariants.all { variant -> + // delete previous files first + delete "${buildDir}/intermediates/assets/${variant.dirName}" + + variant.mergeAssets.doLast { + copy { + from "${buildDir}/../../../../../config.json" + into "${buildDir}/intermediates/assets/${variant.dirName}" + } + } +} + +dependencies { + compile fileTree(dir: 'libs', include: ['*.jar']) + compile project(':libcocos2dx') +} diff --git a/native/tools/simulator/frameworks/runtime-src/proj.android-studio/app/jni/Android.mk b/native/tools/simulator/frameworks/runtime-src/proj.android-studio/app/jni/Android.mk new file mode 100755 index 0000000000..f5e8a600a7 --- /dev/null +++ b/native/tools/simulator/frameworks/runtime-src/proj.android-studio/app/jni/Android.mk @@ -0,0 +1,37 @@ +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_MODULE := cocos2djs_shared + +LOCAL_MODULE_FILENAME := libcocos2djs + +ifeq ($(COCOS_SIMULATOR_BUILD),1) +LOCAL_ARM_MODE := arm +endif + +FILE_LIST := hellojavascript/main.cpp +FILE_LIST += $(wildcard $(LOCAL_PATH)/../../../Classes/*.cpp) +FILE_LIST += $(wildcard $(LOCAL_PATH)/../../../Classes/ide-support/*.cpp) +FILE_LIST += $(wildcard $(LOCAL_PATH)/../../../Classes/ide-support/*.c) + +LOCAL_SRC_FILES := $(FILE_LIST:$(LOCAL_PATH)/%=%) + +LOCAL_C_INCLUDES := \ +$(LOCAL_PATH)/../../../Classes/protobuf-lite \ +$(LOCAL_PATH)/../../../Classes/runtime \ +$(LOCAL_PATH)/../../../Classes/jsb \ +$(LOCAL_PATH)/../../../Classes \ +$(LOCAL_PATH)/../../../../../../../external \ +$(LOCAL_PATH)/../../../../../../../tools/simulator/libsimulator/lib \ +$(LOCAL_PATH)/../../../../../../../tools/simulator/libsimulator/lib/protobuf-lite + +LOCAL_STATIC_LIBRARIES := cocos2d_simulator_static +LOCAL_STATIC_LIBRARIES += cocos2d_js_static + +LOCAL_EXPORT_CFLAGS := -DCOCOS2D_DEBUG=2 -DCOCOS2D_JAVASCRIPT + +include $(BUILD_SHARED_LIBRARY) + +$(call import-module,scripting/js-bindings/proj.android) +$(call import-module,tools/simulator/libsimulator/proj.android) diff --git a/native/tools/simulator/frameworks/runtime-src/proj.android-studio/app/jni/Application.mk b/native/tools/simulator/frameworks/runtime-src/proj.android-studio/app/jni/Application.mk new file mode 100755 index 0000000000..18cecb0948 --- /dev/null +++ b/native/tools/simulator/frameworks/runtime-src/proj.android-studio/app/jni/Application.mk @@ -0,0 +1,17 @@ +APP_STL := gnustl_static + +APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -std=c++11 -fsigned-char +APP_LDFLAGS := -latomic + + +ifeq ($(NDK_DEBUG),1) + APP_CPPFLAGS += -DCOCOS2D_DEBUG=1 + APP_OPTIM := debug +else + APP_CPPFLAGS += -DNDEBUG + APP_CPPFLAGS += -DCOCOS2D_DEBUG=1 + APP_OPTIM := release +endif + +COCOS_SIMULATOR_BUILD := 1 +USE_ARM_MODE := 1 diff --git a/native/tools/simulator/frameworks/runtime-src/proj.android-studio/app/jni/hellojavascript/main.cpp b/native/tools/simulator/frameworks/runtime-src/proj.android-studio/app/jni/hellojavascript/main.cpp new file mode 100755 index 0000000000..f95bc05293 --- /dev/null +++ b/native/tools/simulator/frameworks/runtime-src/proj.android-studio/app/jni/hellojavascript/main.cpp @@ -0,0 +1,37 @@ +#include "AppDelegate.h" +#include "cocos2d.h" +#include "platform/android/jni/JniHelper.h" +#include +#include +#if PACKAGE_AS +#include "PluginJniHelper.h" +#include "SDKManager.h" +#endif + +#define LOG_TAG "main" +#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__) + +using namespace cocos2d; +#if PACKAGE_AS +using namespace anysdk::framework; +#endif + +void cocos_android_app_init (JNIEnv* env) { + LOGD("cocos_android_app_init"); + AppDelegate *pAppDelegate = new AppDelegate(); +#if PACKAGE_AS + JavaVM* vm; + env->GetJavaVM(&vm); + PluginJniHelper::setJavaVM(vm); +#endif +} + +extern "C" +{ + void Java_org_cocos2dx_javascript_SDKWrapper_nativeLoadAllPlugins(JNIEnv* env, jobject thiz) + { +#if PACKAGE_AS + SDKManager::getInstance()->loadAllPlugins(); +#endif + } +} diff --git a/native/tools/simulator/frameworks/runtime-src/proj.android-studio/app/proguard-rules.pro b/native/tools/simulator/frameworks/runtime-src/proj.android-studio/app/proguard-rules.pro new file mode 100755 index 0000000000..6618e28017 --- /dev/null +++ b/native/tools/simulator/frameworks/runtime-src/proj.android-studio/app/proguard-rules.pro @@ -0,0 +1,17 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in E:\developSoftware\Android\SDK/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/native/tools/simulator/frameworks/runtime-src/proj.android-studio/app/project.properties b/native/tools/simulator/frameworks/runtime-src/proj.android-studio/app/project.properties new file mode 100755 index 0000000000..f049142c17 --- /dev/null +++ b/native/tools/simulator/frameworks/runtime-src/proj.android-studio/app/project.properties @@ -0,0 +1,11 @@ +# This file is automatically generated by Android Tools. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must be checked in Version Control Systems. +# +# To customize properties used by the Ant build system use, +# "ant.properties", and override values to adapt the script to your +# project structure. + +# Project target. +target=android-10 diff --git a/native/tools/simulator/frameworks/runtime-src/proj.android-studio/app/res/mipmap-hdpi/ic_launcher.png b/native/tools/simulator/frameworks/runtime-src/proj.android-studio/app/res/mipmap-hdpi/ic_launcher.png new file mode 100755 index 0000000000..8aa4767c2f Binary files /dev/null and b/native/tools/simulator/frameworks/runtime-src/proj.android-studio/app/res/mipmap-hdpi/ic_launcher.png differ diff --git a/native/tools/simulator/frameworks/runtime-src/proj.android-studio/app/res/mipmap-mdpi/ic_launcher.png b/native/tools/simulator/frameworks/runtime-src/proj.android-studio/app/res/mipmap-mdpi/ic_launcher.png new file mode 100755 index 0000000000..d53fbdd8cb Binary files /dev/null and b/native/tools/simulator/frameworks/runtime-src/proj.android-studio/app/res/mipmap-mdpi/ic_launcher.png differ diff --git a/native/tools/simulator/frameworks/runtime-src/proj.android-studio/app/res/mipmap-xhdpi/ic_launcher.png b/native/tools/simulator/frameworks/runtime-src/proj.android-studio/app/res/mipmap-xhdpi/ic_launcher.png new file mode 100755 index 0000000000..2f72eac17f Binary files /dev/null and b/native/tools/simulator/frameworks/runtime-src/proj.android-studio/app/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/native/tools/simulator/frameworks/runtime-src/proj.android-studio/app/res/mipmap-xxhdpi/ic_launcher.png b/native/tools/simulator/frameworks/runtime-src/proj.android-studio/app/res/mipmap-xxhdpi/ic_launcher.png new file mode 100755 index 0000000000..1526615c02 Binary files /dev/null and b/native/tools/simulator/frameworks/runtime-src/proj.android-studio/app/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/native/tools/simulator/frameworks/runtime-src/proj.android-studio/app/res/values/strings.xml b/native/tools/simulator/frameworks/runtime-src/proj.android-studio/app/res/values/strings.xml new file mode 100755 index 0000000000..02634ac6bd --- /dev/null +++ b/native/tools/simulator/frameworks/runtime-src/proj.android-studio/app/res/values/strings.xml @@ -0,0 +1,3 @@ + + HelloJavascript + diff --git a/native/tools/simulator/frameworks/runtime-src/proj.android-studio/app/src/org/cocos2dx/javascript/AppActivity.java b/native/tools/simulator/frameworks/runtime-src/proj.android-studio/app/src/org/cocos2dx/javascript/AppActivity.java new file mode 100755 index 0000000000..e678b3ce41 --- /dev/null +++ b/native/tools/simulator/frameworks/runtime-src/proj.android-studio/app/src/org/cocos2dx/javascript/AppActivity.java @@ -0,0 +1,130 @@ +/**************************************************************************** +Copyright (c) 2008-2010 Ricardo Quesada +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ +package org.cocos2dx.lua; + +import java.net.InetAddress; +import java.net.NetworkInterface; +import java.net.SocketException; +import java.util.Enumeration; +import java.util.ArrayList; + +import org.cocos2dx.lib.Cocos2dxActivity; + +import android.app.AlertDialog; +import android.content.Context; +import android.content.DialogInterface; +import android.content.Intent; +import android.content.pm.ApplicationInfo; +import android.content.pm.ActivityInfo; +import android.net.ConnectivityManager; +import android.net.NetworkInfo; +import android.net.wifi.WifiInfo; +import android.net.wifi.WifiManager; +import android.os.Bundle; +import android.provider.Settings; +import android.text.format.Formatter; +import android.util.Log; +import android.view.WindowManager; +import android.widget.Toast; + + +public class AppActivity extends Cocos2dxActivity{ + + static String hostIPAdress = "0.0.0.0"; + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + if(nativeIsLandScape()) { + setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE); + } else { + setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT); + } + + //2.Set the format of window + + // Check the wifi is opened when the native is debug. + if(nativeIsDebug()) + { + getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON, WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); + if(!isNetworkConnected()) + { + AlertDialog.Builder builder=new AlertDialog.Builder(this); + builder.setTitle("Warning"); + builder.setMessage("Please open WIFI for debuging..."); + builder.setPositiveButton("OK",new DialogInterface.OnClickListener() { + + @Override + public void onClick(DialogInterface dialog, int which) { + startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS)); + finish(); + System.exit(0); + } + }); + + builder.setNegativeButton("Cancel", null); + builder.setCancelable(true); + builder.show(); + } + } + hostIPAdress = getHostIpAddress(); + } + private boolean isNetworkConnected() { + ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); + if (cm != null) { + NetworkInfo networkInfo = cm.getActiveNetworkInfo(); + ArrayList networkTypes = new ArrayList(); + networkTypes.add(ConnectivityManager.TYPE_WIFI); + try { + networkTypes.add(ConnectivityManager.class.getDeclaredField("TYPE_ETHERNET").getInt(null)); + } catch (NoSuchFieldException nsfe) { + } + catch (IllegalAccessException iae) { + throw new RuntimeException(iae); + } + if (networkInfo != null && networkTypes.contains(networkInfo.getType())) { + return true; + } + } + return false; + } + + public String getHostIpAddress() { + WifiManager wifiMgr = (WifiManager) getSystemService(WIFI_SERVICE); + WifiInfo wifiInfo = wifiMgr.getConnectionInfo(); + int ip = wifiInfo.getIpAddress(); + return ((ip & 0xFF) + "." + ((ip >>>= 8) & 0xFF) + "." + ((ip >>>= 8) & 0xFF) + "." + ((ip >>>= 8) & 0xFF)); + } + + public static String getLocalIpAddress() { + return hostIPAdress; + } + + private static native boolean nativeIsLandScape(); + private static native boolean nativeIsDebug(); + +} diff --git a/native/tools/simulator/frameworks/runtime-src/proj.android-studio/build-cfg.json b/native/tools/simulator/frameworks/runtime-src/proj.android-studio/build-cfg.json new file mode 100755 index 0000000000..4d56ca71ea --- /dev/null +++ b/native/tools/simulator/frameworks/runtime-src/proj.android-studio/build-cfg.json @@ -0,0 +1,16 @@ +{ + "ndk_module_path" :[ + "../../../../../", + "../../../../../cocos/", + "../../../../../external", + "../../../../../cocos/scripting" + ], + "copy_resources": [ + ], + "must_copy_resources": [ + { + "from": "../../../config.json", + "to": "" + } + ] +} diff --git a/native/tools/simulator/frameworks/runtime-src/proj.android-studio/build.gradle b/native/tools/simulator/frameworks/runtime-src/proj.android-studio/build.gradle new file mode 100755 index 0000000000..f46d6535c5 --- /dev/null +++ b/native/tools/simulator/frameworks/runtime-src/proj.android-studio/build.gradle @@ -0,0 +1,19 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +buildscript { + repositories { + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:2.2.3' + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +allprojects { + repositories { + jcenter() + } +} diff --git a/native/tools/simulator/frameworks/runtime-src/proj.android-studio/gradle.properties b/native/tools/simulator/frameworks/runtime-src/proj.android-studio/gradle.properties new file mode 100755 index 0000000000..b0fc42cea2 --- /dev/null +++ b/native/tools/simulator/frameworks/runtime-src/proj.android-studio/gradle.properties @@ -0,0 +1,21 @@ +# Project-wide Gradle settings. + +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. + +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html + +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +# Default value: -Xmx10248m -XX:MaxPermSize=256m +# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 + +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true + +PROP_TARGET_SDK_VERSION=22 +PROP_APP_ABI=armeabi-v7a diff --git a/native/tools/simulator/frameworks/runtime-src/proj.android-studio/gradle/wrapper/gradle-wrapper.jar b/native/tools/simulator/frameworks/runtime-src/proj.android-studio/gradle/wrapper/gradle-wrapper.jar new file mode 100755 index 0000000000..8c0fb64a86 Binary files /dev/null and b/native/tools/simulator/frameworks/runtime-src/proj.android-studio/gradle/wrapper/gradle-wrapper.jar differ diff --git a/native/tools/simulator/frameworks/runtime-src/proj.android-studio/gradle/wrapper/gradle-wrapper.properties b/native/tools/simulator/frameworks/runtime-src/proj.android-studio/gradle/wrapper/gradle-wrapper.properties new file mode 100755 index 0000000000..5695367ecb --- /dev/null +++ b/native/tools/simulator/frameworks/runtime-src/proj.android-studio/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Fri Jul 31 20:40:49 CST 2015 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip diff --git a/native/tools/simulator/frameworks/runtime-src/proj.android-studio/gradlew b/native/tools/simulator/frameworks/runtime-src/proj.android-studio/gradlew new file mode 100755 index 0000000000..91a7e269e1 --- /dev/null +++ b/native/tools/simulator/frameworks/runtime-src/proj.android-studio/gradlew @@ -0,0 +1,164 @@ +#!/usr/bin/env bash + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn ( ) { + echo "$*" +} + +die ( ) { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; +esac + +# For Cygwin, ensure paths are in UNIX format before anything is touched. +if $cygwin ; then + [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` +fi + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >&- +APP_HOME="`pwd -P`" +cd "$SAVED" >&- + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") +} +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" + +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/native/tools/simulator/frameworks/runtime-src/proj.android-studio/gradlew.bat b/native/tools/simulator/frameworks/runtime-src/proj.android-studio/gradlew.bat new file mode 100755 index 0000000000..8a0b282aa6 --- /dev/null +++ b/native/tools/simulator/frameworks/runtime-src/proj.android-studio/gradlew.bat @@ -0,0 +1,90 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windowz variants + +if not "%OS%" == "Windows_NT" goto win9xME_args +if "%@eval[2+2]" == "4" goto 4NT_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* +goto execute + +:4NT_args +@rem Get arguments from the 4NT Shell from JP Software +set CMD_LINE_ARGS=%$ + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/native/tools/simulator/frameworks/runtime-src/proj.android-studio/settings.gradle b/native/tools/simulator/frameworks/runtime-src/proj.android-studio/settings.gradle new file mode 100755 index 0000000000..c43ce5b13a --- /dev/null +++ b/native/tools/simulator/frameworks/runtime-src/proj.android-studio/settings.gradle @@ -0,0 +1,4 @@ +include ':libcocos2dx' +project(':libcocos2dx').projectDir = new File(settingsDir, '../../../../../cocos/platform/android/libcocos2dx') +include ':HelloJavascript' +project(':HelloJavascript').projectDir = new File(settingsDir, 'app')