diff --git a/app/build.gradle.kts b/app/build.gradle.kts index fd45bfdb..f9e5c9ba 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -71,23 +71,6 @@ android { arg("room.expandProjection", "true") } - externalNativeBuild { - cmake { - targets("florisboard-native") - cppFlags("-std=c++20", "-stdlib=libc++") - arguments( - "-DCMAKE_ANDROID_API=" + minSdk.toString(), - "-DICU_ASSET_EXPORT_DIR=" + project.file("src/main/assets/icu4c").absolutePath, - "-DBUILD_SHARED_LIBS=false", - "-DANDROID_STL=c++_static", - ) - } - } - - ndk { - abiFilters += listOf("armeabi-v7a", "arm64-v8a") - } - sourceSets { maybeCreate("main").apply { assets { @@ -118,11 +101,11 @@ android { kotlinCompilerExtensionVersion = libs.versions.androidx.compose.compiler.get() } - externalNativeBuild { - cmake { - path("src/main/cpp/CMakeLists.txt") - } - } + //externalNativeBuild { + // cmake { + // path("src/main/cpp/CMakeLists.txt") + // } + //} buildTypes { named("debug") { @@ -132,11 +115,6 @@ android { isDebuggable = true isJniDebuggable = false - ndk { - // For running FlorisBoard on the emulator - abiFilters += listOf("x86", "x86_64") - } - resValue("mipmap", "floris_app_icon", "@mipmap/ic_app_icon_debug") resValue("mipmap", "floris_app_icon_round", "@mipmap/ic_app_icon_debug_round") resValue("drawable", "floris_app_icon_foreground", "@drawable/ic_app_icon_debug_foreground") diff --git a/app/src/main/cpp/CMakeLists.txt b/app/src/main/cpp/CMakeLists.txt deleted file mode 100644 index ef0e6453..00000000 --- a/app/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,29 +0,0 @@ -cmake_minimum_required(VERSION 3.22) - -project(florisboard) - -set(CMAKE_CXX_STANDARD 20) - -include_directories(.) - -### FlorisBoard ### -add_subdirectory(utils) -add_subdirectory(nlp) - -add_library( - florisboard-native - SHARED - dev_patrickgold_florisboard_FlorisApplication.cpp -) - -target_compile_options(florisboard-native PRIVATE -ffunction-sections -fdata-sections -fexceptions) -target_link_libraries( - # Destination - florisboard-native - - # Sources - android - log - fl::nlp::core - utils -) diff --git a/app/src/main/cpp/dev_patrickgold_florisboard_FlorisApplication.cpp b/app/src/main/cpp/dev_patrickgold_florisboard_FlorisApplication.cpp deleted file mode 100644 index 7cfbd3df..00000000 --- a/app/src/main/cpp/dev_patrickgold_florisboard_FlorisApplication.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2021 Patrick Goldinger - * - * 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 -#include -#include -#include -#include "utils/jni_utils.h" - -#include "fl_icuext.hpp" - -#pragma ide diagnostic ignored "UnusedLocalVariable" - -extern "C" -JNIEXPORT jint JNICALL -Java_dev_patrickgold_florisboard_FlorisApplication_00024Companion_nativeInitICUData( - JNIEnv *env, jobject thiz, jobject path) -{ - auto path_str = utils::j2std_string(env, path); - auto status = fl::icuext::loadAndSetCommonData(path_str); - return status; -} diff --git a/app/src/main/cpp/utils/CMakeLists.txt b/app/src/main/cpp/utils/CMakeLists.txt deleted file mode 100644 index f51710e0..00000000 --- a/app/src/main/cpp/utils/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -add_library( - # Name - utils - SHARED - - # Headers - jni_utils.h - log.h - - # Sources - jni_utils.cpp - log.cpp -) - -target_link_libraries(utils PUBLIC log) diff --git a/app/src/main/cpp/utils/jni_utils.cpp b/app/src/main/cpp/utils/jni_utils.cpp deleted file mode 100644 index d61d42c0..00000000 --- a/app/src/main/cpp/utils/jni_utils.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2021 Patrick Goldinger - * - * 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 "jni_utils.h" -#include "log.h" - -std::string utils::j2std_string(JNIEnv *env, jobject jStr) { - auto cStr = reinterpret_cast(env->GetDirectBufferAddress(jStr)); - auto size = env->GetDirectBufferCapacity(jStr); - std::string stdStr(cStr, size); - utils::log(ANDROID_LOG_DEBUG, "spell j2s", stdStr); - return stdStr; -} - -jobject utils::std2j_string(JNIEnv *env, const std::string& stdStr) { - utils::log(ANDROID_LOG_DEBUG, "spell s2j", stdStr); - size_t byteCount = stdStr.length(); - auto cStr = stdStr.c_str(); - auto buffer = env->NewDirectByteBuffer((void *) cStr, byteCount); - return buffer; -} diff --git a/app/src/main/cpp/utils/jni_utils.h b/app/src/main/cpp/utils/jni_utils.h deleted file mode 100644 index d9d72232..00000000 --- a/app/src/main/cpp/utils/jni_utils.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2021 Patrick Goldinger - * - * 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. - */ - -#ifndef FLORISBOARD_JNI_UTILS_H -#define FLORISBOARD_JNI_UTILS_H - -#include -#include - -namespace utils { - -std::string j2std_string(JNIEnv *env, jobject jStr); -jobject std2j_string(JNIEnv *env, const std::string& in); - -} // namespace utils - -#endif // FLORISBOARD_JNI_UTILS_H diff --git a/app/src/main/cpp/utils/log.cpp b/app/src/main/cpp/utils/log.cpp deleted file mode 100644 index aa1481be..00000000 --- a/app/src/main/cpp/utils/log.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2021 Patrick Goldinger - * - * 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 -#include -#include -#include -#include -#include -#include - -#include "log.h" - -void utils::log(int log_priority, const std::string &tag, const std::string &msg) { - __android_log_print(log_priority, tag.c_str(), "%s", msg.c_str()); -} - -/** - * Code below based on: - * https://codelab.wordpress.com/2014/11/03/how-to-use-standard-output-streams-for-logging-in-android-apps/ - */ -int utils::start_stdout_stderr_logger(const std::string &app_name) { - static bool already_started = false; - if (already_started) - return 0; - - int piperw[2]; - if (pipe(piperw) < 0) { - std::string msg = "pipe(): "; - msg += strerror(errno); - utils::log(ANDROID_LOG_ERROR, "stdout/stderr logger", std::ref(msg)); - return 1; - } - - /* make stdout line-buffered and stderr unbuffered */ - setvbuf(stdout, nullptr, _IOLBF, 0); - setvbuf(stderr, nullptr, _IONBF, 0); - - /* create the pipe and redirect stdout and stderr */ - dup2(piperw[0], STDIN_FILENO); - dup2(piperw[1], STDOUT_FILENO); - dup2(piperw[1], STDERR_FILENO); - close(piperw[0]); - close(piperw[1]); - - auto f = [](const std::string &tag) { - std::string buf; - while (std::getline(std::cin, buf)) { - char &back = buf.back(); - if (back == '\n') - back = '\0'; - utils::log(ANDROID_LOG_DEBUG, tag, std::ref(buf)); - } - }; - - /* spawn the logging thread */ - std::thread thr(f, app_name); - thr.detach(); - - already_started = true; - return 0; -} diff --git a/app/src/main/cpp/utils/log.h b/app/src/main/cpp/utils/log.h deleted file mode 100644 index 5c8636bd..00000000 --- a/app/src/main/cpp/utils/log.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2021 Patrick Goldinger - * - * 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. - */ - -#ifndef FLORISBOARD_LOG_H -#define FLORISBOARD_LOG_H - -#include -#include - -namespace utils { - -void log(int log_priority, const std::string &tag, const std::string &msg); - -int start_stdout_stderr_logger(const std::string &app_name); - -} // namespace utils - -#endif // FLORISBOARD_LOG_H