mirror of
https://github.com/encounter/robovm.git
synced 2026-03-30 11:36:44 -07:00
3d1e6eccf9
- Figured out which OSS RoboVM repositories are needed for libGDX - Put them into a single repository, much easier to maintain, but history got destroyed in the process. Can look up history in original repository if necessary - Set the groupId of all artifacts to my domain com.mobidevelop so I can publish to Maven Central - Set the version to 2.0.0-SNAPSHOT so there's zero chance of a collision with the original RoboVM releases - Couldn't get native bits to compile, so updated minimum iOS and Mac OS X versions for toolchain in vm/CMakeFileList.txt and OS.java until it worked. - Apps wouldn't link due to some missing c++ symbols. Removed linking to libstdc++ in IOSTarget.java. Not sure if that has any detrimental effects but it fixed linking. - When opening a run configuration via the IDEA plugin, it would crash in DeviceType.java:113. It seems that the output of some command line tool is being parsed, and that returns error messages together with the data we need. Fixed via ugly hack. - Updated to the latest commit of https://github.com/robovm/bwdgc.git Probably fixed some GC crashes since the release in October. - Pulled in the IDE plugins for Eclipse and IDEA, the Gradle plugin and the templates project. We don't need the Maven plugin and junit stuff for libGDX. Everything's in the plugin/ directory - Templates: removed the templates that i couldn't get to work, namely the ones relying on storyboards. Seems like the OSS RoboVM couldn't deal with those at all. - IDEA plugin: removed the bridge to the interface builder functionality otherwise the plugin would crash since we miss the artifacts for that - IDEA plugin: removed the whole setup stuff for Android and license checks. The former didn't work for me at all, and the latter would crash because it's missing the actual code. - IDEA plugin: removed the templates in RoboVMTemplateFactory that aren't working. - IDEA plugin: The RoboVmCompileTask doesn't seem to work with that as it can't find the robovm.xml file needed for compilation. Fixed in RoboVmPlugin.java with a very ugly hack. - IDEA plugin: there was a huge memory leak in the compiler code of the plugin. It retained the AppCompiler instance, which was huge. Fixed by nulling that out at the appropriate time - IDEA plugin: fixed template_build.gradle to use the new groupId - Gradle plugin: it seems the Gradle plugin was kept up-to-date with the latest closed source RoboVM. Had to remove a bunch of stuff, like TvOS functionality, as we don't have to sources for that. - Eclipse plugin: just fixed up the poms, don't know if it works.
143 lines
4.3 KiB
C++
Executable File
143 lines
4.3 KiB
C++
Executable File
/*
|
|
* Copyright (C) 2013 The Android Open Source Project
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
#include "JniInvocation.h"
|
|
|
|
#include <dlfcn.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
#include <cstddef>
|
|
|
|
#define LOG_TAG "JniInvocation"
|
|
#include "cutils/log.h"
|
|
|
|
#ifdef HAVE_ANDROID_OS
|
|
#include "cutils/properties.h"
|
|
#endif
|
|
|
|
JniInvocation* JniInvocation::jni_invocation_ = NULL;
|
|
|
|
JniInvocation::JniInvocation() :
|
|
handle_(NULL),
|
|
JNI_GetDefaultJavaVMInitArgs_(NULL),
|
|
JNI_CreateJavaVM_(NULL),
|
|
JNI_GetCreatedJavaVMs_(NULL) {
|
|
|
|
LOG_ALWAYS_FATAL_IF(jni_invocation_ != NULL, "JniInvocation instance already initialized");
|
|
jni_invocation_ = this;
|
|
}
|
|
|
|
JniInvocation::~JniInvocation() {
|
|
jni_invocation_ = NULL;
|
|
if (handle_ != NULL) {
|
|
dlclose(handle_);
|
|
}
|
|
}
|
|
|
|
#ifdef HAVE_ANDROID_OS
|
|
static const char* kLibrarySystemProperty = "persist.sys.dalvik.vm.lib";
|
|
#endif
|
|
static const char* kLibraryFallback = "libdvm.so";
|
|
|
|
bool JniInvocation::Init(const char* library) {
|
|
#ifdef HAVE_ANDROID_OS
|
|
char default_library[PROPERTY_VALUE_MAX];
|
|
property_get(kLibrarySystemProperty, default_library, kLibraryFallback);
|
|
#else
|
|
const char* default_library = kLibraryFallback;
|
|
#endif
|
|
if (library == NULL) {
|
|
library = default_library;
|
|
}
|
|
|
|
handle_ = dlopen(library, RTLD_NOW);
|
|
if (handle_ == NULL) {
|
|
if (strcmp(library, kLibraryFallback) == 0) {
|
|
// Nothing else to try.
|
|
ALOGE("Failed to dlopen %s: %s", library, dlerror());
|
|
return false;
|
|
}
|
|
// Note that this is enough to get something like the zygote
|
|
// running, we can't property_set here to fix this for the future
|
|
// because we are root and not the system user. See
|
|
// RuntimeInit.commonInit for where we fix up the property to
|
|
// avoid future fallbacks. http://b/11463182
|
|
ALOGW("Falling back from %s to %s after dlopen error: %s",
|
|
library, kLibraryFallback, dlerror());
|
|
library = kLibraryFallback;
|
|
handle_ = dlopen(library, RTLD_NOW);
|
|
if (handle_ == NULL) {
|
|
ALOGE("Failed to dlopen %s: %s", library, dlerror());
|
|
return false;
|
|
}
|
|
}
|
|
if (!FindSymbol(reinterpret_cast<void**>(&JNI_GetDefaultJavaVMInitArgs_),
|
|
"JNI_GetDefaultJavaVMInitArgs")) {
|
|
return false;
|
|
}
|
|
if (!FindSymbol(reinterpret_cast<void**>(&JNI_CreateJavaVM_),
|
|
"JNI_CreateJavaVM")) {
|
|
return false;
|
|
}
|
|
if (!FindSymbol(reinterpret_cast<void**>(&JNI_GetCreatedJavaVMs_),
|
|
"JNI_GetCreatedJavaVMs")) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
jint JniInvocation::JNI_GetDefaultJavaVMInitArgs(void* vmargs) {
|
|
return JNI_GetDefaultJavaVMInitArgs_(vmargs);
|
|
}
|
|
|
|
jint JniInvocation::JNI_CreateJavaVM(JavaVM** p_vm, JNIEnv** p_env, void* vm_args) {
|
|
return JNI_CreateJavaVM_(p_vm, p_env, vm_args);
|
|
}
|
|
|
|
jint JniInvocation::JNI_GetCreatedJavaVMs(JavaVM** vms, jsize size, jsize* vm_count) {
|
|
return JNI_GetCreatedJavaVMs_(vms, size, vm_count);
|
|
}
|
|
|
|
bool JniInvocation::FindSymbol(void** pointer, const char* symbol) {
|
|
*pointer = dlsym(handle_, symbol);
|
|
if (*pointer == NULL) {
|
|
ALOGE("Failed to find symbol %s: %s\n", symbol, dlerror());
|
|
dlclose(handle_);
|
|
handle_ = NULL;
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
JniInvocation& JniInvocation::GetJniInvocation() {
|
|
LOG_ALWAYS_FATAL_IF(jni_invocation_ == NULL,
|
|
"Failed to create JniInvocation instance before using JNI invocation API");
|
|
return *jni_invocation_;
|
|
}
|
|
|
|
extern "C" jint JNI_GetDefaultJavaVMInitArgs(void* vm_args) {
|
|
return JniInvocation::GetJniInvocation().JNI_GetDefaultJavaVMInitArgs(vm_args);
|
|
}
|
|
|
|
extern "C" jint JNI_CreateJavaVM(JavaVM** p_vm, JNIEnv** p_env, void* vm_args) {
|
|
return JniInvocation::GetJniInvocation().JNI_CreateJavaVM(p_vm, p_env, vm_args);
|
|
}
|
|
|
|
extern "C" jint JNI_GetCreatedJavaVMs(JavaVM** vms, jsize size, jsize* vm_count) {
|
|
return JniInvocation::GetJniInvocation().JNI_GetCreatedJavaVMs(vms, size, vm_count);
|
|
}
|