make gradle buildable

many tears were shed in this process
main
maia arson crimew 2022-03-23 13:35:33 +01:00
parent 85ef644a8a
commit 7aab3f949e
13 changed files with 369 additions and 29 deletions

1
.gitignore vendored
View File

@ -5,3 +5,4 @@
LatinIME.iml
build/
local.properties
*.hprof

View File

@ -4,15 +4,16 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0-beta03'
classpath 'com.android.tools.build:gradle:7.0.4'
}
}
apply plugin: 'com.android.application'
// TODO: fix weird test build failure
android {
compileSdkVersion 28
buildToolsVersion '28.0.0'
compileSdkVersion 32
buildToolsVersion '32.1.0-rc1'
// Required if using classes in android.test.runner
useLibrary 'android.test.runner'
@ -25,8 +26,9 @@ android {
defaultConfig {
minSdkVersion 21
targetSdkVersion 28
targetSdkVersion 32
versionName "1.0"
versionCode 30
applicationId 'com.android.inputmethod.latin'
testApplicationId 'com.android.inputmethod.latin.tests'
@ -85,6 +87,7 @@ android {
path 'native/jni/Android.mk'
}
}
ndkVersion '25.0.8221429 rc2'
}
repositories {
@ -97,14 +100,15 @@ repositories {
dependencies {
implementation 'androidx.legacy:legacy-support-v4:+'
implementation 'androidx.core:core:1.7.0'
implementation 'com.google.code.findbugs:jsr305:3.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation "org.mockito:mockito-core:1.9.5"
androidTestImplementation 'com.google.dexmaker:dexmaker:1.2'
androidTestImplementation 'com.google.dexmaker:dexmaker-mockito:1.2'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test:rules:1.0.2'
androidTestImplementation 'com.android.support.test.uiautomator:uiautomator-v18:2.1.3'
androidTestImplementation "com.android.support:support-annotations:27.1.1"
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test:rules:1.1.1'
androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
androidTestImplementation 'androidx.annotation:annotation:1.0.0'
}

3
gradle.properties Normal file
View File

@ -0,0 +1,3 @@
android.enableJetifier=true
android.useAndroidX=true
org.gradle.jvmargs=-Xmx6g

View File

@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-all.zip

View File

@ -16,11 +16,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
coreApp="true"
package="com.android.inputmethod.latin"
android:versionCode="30">
<uses-sdk android:minSdkVersion="21"
android:targetSdkVersion="30"/>
package="com.android.inputmethod.latin">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION"/>

82
native/jni/Android.mk Normal file
View File

@ -0,0 +1,82 @@
# Copyright (C) 2011 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.
LOCAL_PATH := $(call my-dir)
############ some local flags
# If you change any of those flags, you need to rebuild both libjni_latinime_common_static
# and the shared library that uses libjni_latinime_common_static.
FLAG_DBG ?= false
FLAG_DO_PROFILE ?= false
######################################
include $(CLEAR_VARS)
LATIN_IME_SRC_DIR := src
LOCAL_C_INCLUDES += $(LOCAL_PATH)/$(LATIN_IME_SRC_DIR)
LOCAL_CFLAGS += -Wall -Wextra -Weffc++ -Wformat=2 -Wcast-qual -Wcast-align \
-Wwrite-strings -Wfloat-equal -Wpointer-arith -Winit-self -Wredundant-decls \
-Woverloaded-virtual -Wsign-promo -Wno-system-headers
# To suppress compiler warnings for unused variables/functions used for debug features etc.
LOCAL_CFLAGS += -Wno-unused-parameter -Wno-unused-function
# HACK: -mstackrealign is required for x86 builds running on pre-KitKat devices to avoid crashes
# with SSE instructions.
ifeq ($(TARGET_ARCH), x86)
LOCAL_CFLAGS += -mstackrealign
endif # x86
include $(LOCAL_PATH)/NativeFileList.mk
LOCAL_SRC_FILES := \
$(LATIN_IME_JNI_SRC_FILES) \
$(addprefix $(LATIN_IME_SRC_DIR)/, $(LATIN_IME_CORE_SRC_FILES))
ifeq ($(FLAG_DO_PROFILE), true)
$(warning Making profiling version of native library)
LOCAL_CFLAGS += -DFLAG_DO_PROFILE -funwind-tables
else # FLAG_DO_PROFILE
ifeq ($(FLAG_DBG), true)
$(warning Making debug version of native library)
LOCAL_CFLAGS += -DFLAG_DBG -funwind-tables -fno-inline
ifeq ($(FLAG_FULL_DBG), true)
$(warning Making full debug version of native library)
LOCAL_CFLAGS += -DFLAG_FULL_DBG
endif # FLAG_FULL_DBG
endif # FLAG_DBG
endif # FLAG_DO_PROFILE
LOCAL_MODULE := libjni_latinime_common_static
LOCAL_MODULE_TAGS := optional
LOCAL_SDK_VERSION := 14
LOCAL_NDK_STL_VARIANT := c++_static
include $(BUILD_STATIC_LIBRARY)
######################################
include $(CLEAR_VARS)
# All code in LOCAL_WHOLE_STATIC_LIBRARIES will be built into this shared library.
LOCAL_WHOLE_STATIC_LIBRARIES := libjni_latinime_common_static
ifeq ($(FLAG_DO_PROFILE), true)
$(warning Making profiling version of native library)
LOCAL_LDFLAGS += -llog
else # FLAG_DO_PROFILE
ifeq ($(FLAG_DBG), true)
$(warning Making debug version of native library)
LOCAL_LDFLAGS += -llog
endif # FLAG_DBG
endif # FLAG_DO_PROFILE
LOCAL_MODULE := libjni_latinime
LOCAL_MODULE_TAGS := optional
LOCAL_SDK_VERSION := 14
LOCAL_NDK_STL_VARIANT := c++_static
LOCAL_CFLAGS := -Wall -Werror
LOCAL_LDFLAGS += -ldl
include $(BUILD_SHARED_LIBRARY)
#################### Clean up the tmp vars
include $(LOCAL_PATH)/CleanupNativeFileList.mk
#################### Unit test on host environment
# include $(LOCAL_PATH)/HostUnitTests.mk
#################### Unit test on target environment
include $(LOCAL_PATH)/TargetUnitTests.mk
//LOCAL_CFLAGS += -Wall -Werror

View File

@ -0,0 +1 @@
APP_STL := c++_static

View File

@ -0,0 +1,18 @@
# 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.
LATIN_IME_CORE_SRC_FILES :=
LATIN_IME_CORE_SRC_FILES_BACKWARD_V401 :=
LATIN_IME_CORE_TEST_FILES :=
LATIN_IME_JNI_SRC_FILES :=
LATIN_IME_SRC_DIR :=

View File

@ -0,0 +1,52 @@
# Copyright (C) 2014 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.
# Host build is never supported in unbundled (NDK/tapas) build
ifeq (,$(TARGET_BUILD_APPS))
# HACK: Temporarily disable host tool build on Mac until the build system is ready for C++11.
LATINIME_HOST_OSNAME := $(shell uname -s)
ifneq ($(LATINIME_HOST_OSNAME), Darwin) # TODO: Remove this
LOCAL_PATH := $(call my-dir)
######################################
include $(CLEAR_VARS)
include $(LOCAL_PATH)/NativeFileList.mk
#################### Host library for unit test
LATIN_IME_SRC_DIR := src
LOCAL_ADDRESS_SANITIZER := true
LOCAL_CFLAGS += -Wno-unused-parameter -Wno-unused-function -Wall -Werror
LOCAL_CXX_STL := libc++
LOCAL_C_INCLUDES += $(LOCAL_PATH)/$(LATIN_IME_SRC_DIR)
LOCAL_MODULE := liblatinime_host_static_for_unittests
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := $(addprefix $(LATIN_IME_SRC_DIR)/, $(LATIN_IME_CORE_SRC_FILES))
include $(BUILD_HOST_STATIC_LIBRARY)
#################### Host native tests
include $(CLEAR_VARS)
LATIN_IME_TEST_SRC_DIR := tests
LOCAL_ADDRESS_SANITIZER := true
LOCAL_CFLAGS += -Wno-unused-parameter -Wno-unused-function
LOCAL_CFLAGS += -Wall -Werror
LOCAL_CXX_STL := libc++
LOCAL_C_INCLUDES += $(LOCAL_PATH)/$(LATIN_IME_SRC_DIR)
LOCAL_MODULE := liblatinime_host_unittests
LOCAL_MODULE_TAGS := tests
LOCAL_SRC_FILES := $(addprefix $(LATIN_IME_TEST_SRC_DIR)/, $(LATIN_IME_CORE_TEST_FILES))
LOCAL_STATIC_LIBRARIES += liblatinime_host_static_for_unittests
include $(BUILD_HOST_NATIVE_TEST)
include $(LOCAL_PATH)/CleanupNativeFileList.mk
endif # Darwin - TODO: Remove this
endif # TARGET_BUILD_APPS
#################### Clean up the tmp vars
LATINIME_HOST_OSNAME :=
LATIN_IME_SRC_DIR :=
LATIN_IME_TEST_SRC_DIR :=

View File

@ -0,0 +1,141 @@
# 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.
LATIN_IME_JNI_SRC_FILES := \
com_android_inputmethod_keyboard_ProximityInfo.cpp \
com_android_inputmethod_latin_BinaryDictionary.cpp \
com_android_inputmethod_latin_BinaryDictionaryUtils.cpp \
com_android_inputmethod_latin_DicTraverseSession.cpp \
jni_common.cpp
LATIN_IME_CORE_SRC_FILES := \
$(addprefix dictionary/header/, \
header_policy.cpp \
header_read_write_utils.cpp) \
dictionary/property/ngram_context.cpp \
dictionary/structure/dictionary_structure_with_buffer_policy_factory.cpp \
$(addprefix dictionary/structure/pt_common/, \
bigram/bigram_list_read_write_utils.cpp \
dynamic_pt_gc_event_listeners.cpp \
dynamic_pt_reading_helper.cpp \
dynamic_pt_reading_utils.cpp \
dynamic_pt_updating_helper.cpp \
dynamic_pt_writing_utils.cpp \
patricia_trie_reading_utils.cpp \
shortcut/shortcut_list_reading_utils.cpp) \
$(addprefix dictionary/structure/v2/, \
patricia_trie_policy.cpp \
ver2_patricia_trie_node_reader.cpp \
ver2_pt_node_array_reader.cpp) \
$(addprefix dictionary/structure/v4/, \
ver4_dict_buffers.cpp \
ver4_dict_constants.cpp \
ver4_patricia_trie_node_reader.cpp \
ver4_patricia_trie_node_writer.cpp \
ver4_patricia_trie_policy.cpp \
ver4_patricia_trie_reading_utils.cpp \
ver4_patricia_trie_writing_helper.cpp \
ver4_pt_node_array_reader.cpp) \
$(addprefix dictionary/structure/v4/content/, \
dynamic_language_model_probability_utils.cpp \
language_model_dict_content.cpp \
language_model_dict_content_global_counters.cpp \
shortcut_dict_content.cpp \
sparse_table_dict_content.cpp \
terminal_position_lookup_table.cpp) \
$(addprefix dictionary/utils/, \
buffer_with_extendable_buffer.cpp \
byte_array_utils.cpp \
dict_file_writing_utils.cpp \
file_utils.cpp \
forgetting_curve_utils.cpp \
format_utils.cpp \
mmapped_buffer.cpp \
multi_bigram_map.cpp \
probability_utils.cpp \
sparse_table.cpp \
trie_map.cpp ) \
suggest/core/suggest.cpp \
$(addprefix suggest/core/dicnode/, \
dic_node.cpp \
dic_node_utils.cpp \
dic_nodes_cache.cpp) \
$(addprefix suggest/core/dictionary/, \
dictionary.cpp \
dictionary_utils.cpp \
digraph_utils.cpp \
error_type_utils.cpp ) \
$(addprefix suggest/core/layout/, \
additional_proximity_chars.cpp \
proximity_info.cpp \
proximity_info_params.cpp \
proximity_info_state.cpp \
proximity_info_state_utils.cpp) \
suggest/core/policy/weighting.cpp \
suggest/core/session/dic_traverse_session.cpp \
$(addprefix suggest/core/result/, \
suggestion_results.cpp \
suggestions_output_utils.cpp) \
suggest/policyimpl/gesture/gesture_suggest_policy_factory.cpp \
$(addprefix suggest/policyimpl/typing/, \
scoring_params.cpp \
typing_scoring.cpp \
typing_suggest_policy.cpp \
typing_traversal.cpp \
typing_weighting.cpp) \
$(addprefix utils/, \
autocorrection_threshold_utils.cpp \
char_utils.cpp \
jni_data_utils.cpp \
log_utils.cpp \
time_keeper.cpp)
LATIN_IME_CORE_SRC_FILES_BACKWARD_V402 := \
$(addprefix dictionary/structure/backward/v402/, \
ver4_dict_buffers.cpp \
ver4_dict_constants.cpp \
ver4_patricia_trie_node_reader.cpp \
ver4_patricia_trie_node_writer.cpp \
ver4_patricia_trie_policy.cpp \
ver4_patricia_trie_reading_utils.cpp \
ver4_patricia_trie_writing_helper.cpp \
ver4_pt_node_array_reader.cpp) \
$(addprefix dictionary/structure/backward/v402/content/, \
bigram_dict_content.cpp \
probability_dict_content.cpp \
shortcut_dict_content.cpp \
sparse_table_dict_content.cpp \
terminal_position_lookup_table.cpp) \
$(addprefix dictionary/structure/backward/v402/bigram/, \
ver4_bigram_list_policy.cpp)
LATIN_IME_CORE_SRC_FILES += $(LATIN_IME_CORE_SRC_FILES_BACKWARD_V402)
LATIN_IME_CORE_TEST_FILES := \
defines_test.cpp \
dictionary/header/header_read_write_utils_test.cpp \
dictionary/structure/v4/content/language_model_dict_content_test.cpp \
dictionary/structure/v4/content/language_model_dict_content_global_counters_test.cpp \
dictionary/structure/v4/content/probability_entry_test.cpp \
dictionary/structure/v4/content/terminal_position_lookup_table_test.cpp \
dictionary/utils/bloom_filter_test.cpp \
dictionary/utils/buffer_with_extendable_buffer_test.cpp \
dictionary/utils/byte_array_utils_test.cpp \
dictionary/utils/format_utils_test.cpp \
dictionary/utils/probability_utils_test.cpp \
dictionary/utils/sparse_table_test.cpp \
dictionary/utils/trie_map_test.cpp \
suggest/core/dicnode/dic_node_pool_test.cpp \
suggest/core/layout/geometry_utils_test.cpp \
suggest/core/layout/normal_distribution_2d_test.cpp \
suggest/policyimpl/utils/damerau_levenshtein_edit_distance_policy_test.cpp \
utils/autocorrection_threshold_utils_test.cpp \
utils/char_utils_test.cpp \
utils/int_array_view_test.cpp \
utils/time_keeper_test.cpp

View File

@ -0,0 +1,44 @@
# Copyright (C) 2014 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.
LOCAL_PATH := $(call my-dir)
######################################
include $(CLEAR_VARS)
include $(LOCAL_PATH)/NativeFileList.mk
#################### Target library for unit test
LATIN_IME_SRC_DIR := src
LOCAL_CFLAGS += -Wno-unused-parameter -Wno-unused-function -Wall -Werror
LOCAL_C_INCLUDES += $(LOCAL_PATH)/$(LATIN_IME_SRC_DIR)
LOCAL_MODULE := liblatinime_target_static_for_unittests
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := $(addprefix $(LATIN_IME_SRC_DIR)/, $(LATIN_IME_CORE_SRC_FILES))
LOCAL_SDK_VERSION := 14
LOCAL_NDK_STL_VARIANT := c++_static
include $(BUILD_STATIC_LIBRARY)
#################### Target native tests
include $(CLEAR_VARS)
LATIN_IME_TEST_SRC_DIR := tests
LOCAL_CFLAGS += -Wno-unused-parameter -Wno-unused-function -Wall -Werror
LOCAL_C_INCLUDES += $(LOCAL_PATH)/$(LATIN_IME_SRC_DIR)
LOCAL_MODULE := liblatinime_target_unittests
LOCAL_MODULE_TAGS := tests
LOCAL_SRC_FILES := \
$(addprefix $(LATIN_IME_TEST_SRC_DIR)/, $(LATIN_IME_CORE_TEST_FILES))
LOCAL_STATIC_LIBRARIES += liblatinime_target_static_for_unittests
LOCAL_SDK_VERSION := 14
LOCAL_NDK_STL_VARIANT := c++_static
include $(BUILD_NATIVE_TEST)
#################### Clean up the tmp vars
LATIN_IME_SRC_DIR :=
LATIN_IME_TEST_SRC_DIR :=
include $(LOCAL_PATH)/CleanupNativeFileList.mk

View File

@ -15,21 +15,19 @@
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.inputmethod.latin.tests"
android:versionCode="30">
package="com.android.inputmethod.latin.tests"
android:versionCode="30">
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="30" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<application android:label="@string/app_name"
android:icon="@drawable/ic_app">
<uses-library android:name="android.test.runner" />
android:icon="@drawable/ic_app">
<uses-library android:name="android.test.runner"/>
<!-- meta-data android:name="com.android.contacts.iconset" android:resource="@xml/iconset" /-->
</application>
<instrumentation android:name="androidx.test.runner.AndroidJUnitRunner"
android:targetPackage="com.android.inputmethod.latin"
android:label="LatinIME tests">
android:targetPackage="com.android.inputmethod.latin"
android:label="LatinIME tests">
</instrumentation>
</manifest>

View File

@ -27,14 +27,14 @@
-->
<target_preparer class="com.android.tradefed.targetprep.TestAppInstallSetup">
<option name="cleanup-apks" value="true" />
<option name="test-file-name" value="LatinIMETests.apk" />
<option name="cleanup-apks" value="true"/>
<option name="test-file-name" value="LatinIMETests.apk"/>
</target_preparer>
<option name="test-tag" value="LatinIMETests" />
<test class="com.android.tradefed.testtype.AndroidJUnitTest" >
<option name="package" value="com.android.inputmethod.latin.tests" />
<option name="runner" value="androidx.test.runner.AndroidJUnitRunner" />
<option name="test-tag" value="LatinIMETests"/>
<test class="com.android.tradefed.testtype.AndroidJUnitTest">
<option name="package" value="com.android.inputmethod.latin.tests"/>
<option name="runner" value="androidx.test.runner.AndroidJUnitRunner"/>
<option name="hidden-api-checks" value="false"/>
</test>
</configuration>