library "dl";
};
};
+ if_arch "android"
+ {
+ build_info
+ {
+ library "android";
+ library "log";
+ };
+ };
feature "zlib" "Support compression with zlib"
{
{
overlay "osx";
};
+ if_arch "android"
+ {
+ overlay "android";
+ build_info
+ {
+ keep_symbol "ANativeActivity_onCreate";
+ };
+ };
if_arch "!windows"
{
overlay "unix";
--- /dev/null
+#include <typeinfo>
+#include <android/log.h>
+#include <msp/debug/demangle.h>
+#include "errorlogger.h"
+
+using namespace std;
+
+namespace Msp {
+namespace Android {
+
+bool ErrorLogger::report_uncaught_exception(const exception &e) const
+{
+ __android_log_write(ANDROID_LOG_ERROR, "Msp", "An uncaught exception occurred.");
+ __android_log_print(ANDROID_LOG_ERROR, "Msp", " type: %s", Debug::demangle(typeid(e).name()).c_str());
+ __android_log_print(ANDROID_LOG_ERROR, "Msp", " what(): %s", e.what());
+ return true;
+}
+
+} // namespace Android
+} // namespace Msp
--- /dev/null
+#ifndef MSP_CORE_ERRORLOGGER_ANDROID_H_
+#define MSP_CORE_ERRORLOGGER_ANDROID_H_
+
+#include <msp/debug/errorreporter.h>
+
+namespace Msp {
+namespace Android {
+
+class ErrorLogger: public Debug::ErrorReporter
+{
+public:
+ virtual bool report_uncaught_exception(const std::exception &) const;
+};
+
+} // namespace Android
+} // namespace Msp
+
+#endif
--- /dev/null
+#include "mainthread.h"
+
+extern "C" void ANativeActivity_onCreate(ANativeActivity *activity, void * /*saved_state*/, size_t /*state_size*/)
+{
+ new Msp::Android::MainThread(activity);
+}
--- /dev/null
+#include <cstring>
+#include <msp/fs/path.h>
+#include "application.h"
+#include "errorlogger.h"
+#include "mainthread.h"
+
+using namespace std;
+
+namespace Msp {
+namespace Android {
+
+MainThread::MainThread(ANativeActivity *a):
+ activity(a)
+{
+ launch();
+}
+
+void MainThread::main()
+{
+ /* I have no idea how dependable this is, but it seems to be the only way
+ to get the package name aside from making a Java call through JNI */
+ char *appname = strdup(FS::Path(activity->internalDataPath)[-2].c_str());
+ char *argv[] = { appname, 0 };
+ Msp::Android::ErrorLogger err_logger;
+ Msp::Application::run(1, argv, activity);
+ free(appname);
+ ANativeActivity_finish(activity);
+}
+
+} // namespace Android
+} // namespace Msp
--- /dev/null
+#ifndef MSP_CORE_ANDROID_MAINTHREAD_H_
+#define MSP_CORE_ANDROID_MAINTHREAD_H_
+
+#include <android/native_activity.h>
+#include "thread.h"
+
+namespace Msp {
+namespace Android {
+
+class MainThread: public Thread
+{
+private:
+ ANativeActivity *activity;
+
+public:
+ MainThread(ANativeActivity *);
+
+private:
+ virtual void main();
+};
+
+} // namespace Android
+} // namespace Msp
+
+#endif
--- /dev/null
+#include <grp.h>
+#include <pwd.h>
+#include <msp/strings/format.h>
+#include "stat.h"
+#include "stat_private.h"
+
+namespace Msp {
+namespace FS {
+
+void Stat::Private::fill_owner_info(Stat::OwnerInfo &result)
+{
+ struct passwd *owner;
+ if((owner = getpwuid(owner_id)))
+ result.owner = owner->pw_name;
+ else
+ result.owner = format("%d", owner_id);
+
+ struct group *group;
+ if((group = getgrgid(group_id)))
+ result.group = group->gr_name;
+ else
+ result.group = format("%d", group_id);
+}
+
+} // namespace FS
+} // namespace Msp
#include <cerrno>
#include <unistd.h>
#include <sys/stat.h>
-#include <grp.h>
-#include <pwd.h>
#include <msp/core/systemerror.h>
-#include <msp/strings/format.h>
#include "stat.h"
#include "stat_private.h"
return result;
}
-void Stat::Private::fill_owner_info(Stat::OwnerInfo &result)
-{
- char buf[1024];
-
- struct passwd pw;
- struct passwd *owner;
- if(!getpwuid_r(owner_id, &pw, buf, sizeof(buf), &owner) && owner)
- result.owner = owner->pw_name;
- else
- result.owner = format("%d", owner_id);
-
- struct group gr;
- struct group *group;
- if(!getgrgid_r(group_id, &gr, buf, sizeof(buf), &group) && group)
- result.group = group->gr_name;
- else
- result.group = format("%d", group_id);
-}
-
Stat Stat::stat(const Path &path)
{
--- /dev/null
+#include <grp.h>
+#include <pwd.h>
+#include <msp/strings/format.h>
+#include "stat.h"
+#include "stat_private.h"
+
+namespace Msp {
+namespace FS {
+
+void Stat::Private::fill_owner_info(Stat::OwnerInfo &result)
+{
+ char buf[1024];
+
+ struct passwd pw;
+ struct passwd *owner;
+ if(!getpwuid_r(owner_id, &pw, buf, sizeof(buf), &owner) && owner)
+ result.owner = owner->pw_name;
+ else
+ result.owner = format("%d", owner_id);
+
+ struct group gr;
+ struct group *group;
+ if(!getgrgid_r(group_id, &gr, buf, sizeof(buf), &group) && group)
+ result.group = group->gr_name;
+ else
+ result.group = format("%d", group_id);
+}
+
+} // namespace FS
+} // namespace Msp