Skip to content

Commit

Permalink
android project
Browse files Browse the repository at this point in the history
  • Loading branch information
weihuoya committed Jan 13, 2020
1 parent ddb7ead commit 3ec17dd
Show file tree
Hide file tree
Showing 433 changed files with 15,987 additions and 2,810 deletions.
25 changes: 18 additions & 7 deletions CMakeLists.txt
Expand Up @@ -73,6 +73,19 @@ endif()
# Detect current compilation architecture and create standard definitions
# =======================================================================

include(CheckAndAddFlag)
check_and_add_flag(VISIBILITY_INLINES_HIDDEN -fvisibility-inlines-hidden)
check_and_add_flag(VISIBILITY_HIDDEN -fvisibility=hidden)

if(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
set(_M_ARM 1)
set(_M_ARM64 1)
add_definitions(-D_M_ARM=1)
add_definitions(-D_M_ARM64=1)
# CRC instruction set is used in the CRC32 hash function
check_and_add_flag(HAVE_ARCH_ARMV8 -march=armv8-a+crc)
endif()

include(CheckSymbolExists)
function(detect_architecture symbol arch)
if (NOT DEFINED ARCHITECTURE)
Expand Down Expand Up @@ -209,11 +222,7 @@ if (ENABLE_FFMPEG)
endif()
endif()

if (ENABLE_FFMPEG_VIDEO_DUMPER)
find_package(FFmpeg REQUIRED COMPONENTS avcodec avformat avutil swscale swresample)
else()
find_package(FFmpeg REQUIRED COMPONENTS avcodec)
endif()
find_package(FFmpeg REQUIRED COMPONENTS avcodec avformat avutil swscale swresample)
if ("${FFmpeg_avcodec_VERSION}" VERSION_LESS "57.48.101")
message(FATAL_ERROR "Found version for libavcodec is too low. The required version is at least 57.48.101 (included in FFmpeg 3.1 and later).")
endif()
Expand Down Expand Up @@ -331,10 +340,12 @@ git_describe(GIT_DESC --always --long --dirty)
git_branch_name(GIT_BRANCH)
get_timestamp(BUILD_DATE)

enable_testing()
if(NOT ANDROID)
enable_testing()
add_subdirectory(dist/installer)
endif()
add_subdirectory(externals)
add_subdirectory(src)
add_subdirectory(dist/installer)


# Set citra-qt project or citra project as default StartUp Project in Visual Studio depending on whether QT is enabled or not
Expand Down
49 changes: 49 additions & 0 deletions CMakeModules/CheckAndAddFlag.cmake
@@ -0,0 +1,49 @@
include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)

# check_add_add_flag(<variable> <flag> [DEBUG_ONLY | RELEASE_ONLY])
#
# Add a C or C++ compilation flag to the current scope
#
# Can optionally add the flag to Debug or Release configurations only, use this when
# targeting multi-configuration generators like Visual Studio or Xcode.
# Release configurations means NOT Debug, so it will work for RelWithDebInfo or MinSizeRel too.
#
# If the flag is added successfully, the variables FLAG_C_<variable> and FLAG_CXX_<variable>
# may be set to ON.
#
# Examples:
# check_and_add_flag(FOO -foo)
# check_and_add_flag(ONLYDEBUG -onlydebug DEBUG_ONLY)
# check_and_add_flag(OPTMAX -O9001 RELEASE_ONLY)

function(check_and_add_flag var flag)
set(genexp_config_test "1")
if(ARGV2 STREQUAL "DEBUG_ONLY")
set(genexp_config_test "$<CONFIG:Debug>")
elseif(ARGV2 STREQUAL "RELEASE_ONLY")
set(genexp_config_test "$<NOT:$<CONFIG:Debug>>")
elseif(ARGV2)
message(FATAL_ERROR "check_and_add_flag called with incorrect arguments: ${ARGN}")
endif()

set(is_c "$<COMPILE_LANGUAGE:C>")
set(is_cxx "$<COMPILE_LANGUAGE:CXX>")

# The Visual Studio generators don't support COMPILE_LANGUAGE
# So we fail all the C flags and only actually test CXX ones
if(CMAKE_GENERATOR MATCHES "Visual Studio")
set(is_c "0")
set(is_cxx "1")
endif()

check_c_compiler_flag(${flag} FLAG_C_${var})
if(FLAG_C_${var})
add_compile_options("$<$<AND:${is_c},${genexp_config_test}>:${flag}>")
endif()

check_cxx_compiler_flag(${flag} FLAG_CXX_${var})
if(FLAG_CXX_${var})
add_compile_options("$<$<AND:${is_cxx},${genexp_config_test}>:${flag}>")
endif()
endfunction()
19 changes: 11 additions & 8 deletions externals/CMakeLists.txt
Expand Up @@ -12,9 +12,11 @@ target_include_directories(catch-single-include INTERFACE catch/single_include)
add_subdirectory(cryptopp)

# Dynarmic
if (ARCHITECTURE_x86_64)
# Dynarmic will skip defining xbyak if it's already defined, we then define it below
add_library(xbyak INTERFACE)
if (ARCHITECTURE_x86_64 OR ARCHITECTURE_ARM64)
if (ARCHITECTURE_x86_64)
# Dynarmic will skip defining xbyak if it's already defined, we then define it below
add_library(xbyak INTERFACE)
endif()
option(DYNARMIC_TESTS OFF)
set(DYNARMIC_NO_BUNDLED_FMT ON)
add_subdirectory(dynarmic)
Expand All @@ -32,8 +34,12 @@ endif()
# Glad
add_subdirectory(glad)

# inih
add_subdirectory(inih)
if (ANDROID)
add_subdirectory(oboe)
else()
# inih
add_subdirectory(inih)
endif()

# MicroProfile
add_library(microprofile INTERFACE)
Expand Down Expand Up @@ -100,6 +106,3 @@ if (ENABLE_WEB_SERVICE)
add_library(cpp-jwt INTERFACE)
target_include_directories(cpp-jwt INTERFACE ./cpp-jwt/include)
endif()

# lodepng
add_subdirectory(lodepng)
3 changes: 3 additions & 0 deletions externals/cryptopp/CMakeLists.txt
Expand Up @@ -64,6 +64,9 @@ endif()
if(CRYPTOPP_DISABLE_AESNI)
add_definitions(-DCRYPTOPP_DISABLE_AESNI)
endif()
if(ARCHITECTURE_ARM64)
add_definitions(-DCRYPTOPP_ARM_NEON_HEADER)
endif()

# We need the output 'uname -s' for Unix and Linux system detection
if (NOT CRYPTOPP_CROSS_COMPILE)
Expand Down
7 changes: 5 additions & 2 deletions src/CMakeLists.txt
Expand Up @@ -88,7 +88,10 @@ add_subdirectory(video_core)
add_subdirectory(audio_core)
add_subdirectory(network)
add_subdirectory(input_common)
add_subdirectory(tests)

if(NOT ANDROID)
add_subdirectory(tests)
endif()

if (ENABLE_SDL2)
add_subdirectory(citra)
Expand All @@ -98,7 +101,7 @@ if (ENABLE_QT)
add_subdirectory(citra_qt)
endif()
if (ANDROID)
add_subdirectory(android/app/src/main/cpp)
add_subdirectory(android/jni)
else()
add_subdirectory(dedicated_room)
endif()
Expand Down
2 changes: 2 additions & 0 deletions src/android/.gitignore
Expand Up @@ -8,3 +8,5 @@
/build
/captures
.externalNativeBuild
app/release
app/.cxx
61 changes: 17 additions & 44 deletions src/android/app/build.gradle
@@ -1,8 +1,7 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 26
buildToolsVersion '28.0.3'
compileSdkVersion 28

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand All @@ -16,23 +15,19 @@ android {
}

defaultConfig {
applicationId "org.citra_emu"
minSdkVersion 21
targetSdkVersion 26

applicationId "org.citra.emu"
minSdkVersion 24
targetSdkVersion 28
versionCode(getBuildVersionCode())

versionName "${getVersion()}"
}

signingConfigs {
release {
if (project.hasProperty('keystore')) {
storeFile file(project.property('keystore'))
storePassword project.property('storepass')
keyAlias project.property('keyalias')
keyPassword project.property('keypass')
}
keyAlias 'dolphin-release-key'
keyPassword 'zhangwei'
storeFile file('D:/Android/android-sign-key/dolphin-release-key.jks')
storePassword 'zhangwei'
}
}

Expand All @@ -41,6 +36,9 @@ android {
// Signed by release key, allowing for upload to Play Store.
release {
signingConfig signingConfigs.release
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}

// Signed by debug key disallowing distribution on Play Store.
Expand All @@ -55,8 +53,8 @@ android {

externalNativeBuild {
cmake {
version getCmakeVersion()
path "../../../CMakeLists.txt"
version "3.10.2"
}
}

Expand All @@ -65,35 +63,26 @@ android {
cmake {
arguments "-DENABLE_QT=0", // Don't use QT
"-DENABLE_SDL2=0", // Don't use SDL
"-DENABLE_WEB_SERVICE=0", // Don't use web services
"-DANDROID_ARM_NEON=true", // cryptopp requires Neon to work
"-DENABLE_CUBEB=0",
"-DANDROID_STL=c++_shared"

"-DENABLE_CUBEB=1",
"-DANDROID_STL=c++_static",
"-DCMAKE_CXX_FLAGS_RELEASE=-Ofast"
abiFilters "arm64-v8a"

targets "citra-android"
}
}
}
}

ext {
androidSupportVersion = '26.1.0'
androidSupportVersion = '27.1.0'
}

dependencies {
implementation "com.android.support:support-v13:$androidSupportVersion"
implementation "com.android.support:cardview-v7:$androidSupportVersion"
implementation "com.android.support:recyclerview-v7:$androidSupportVersion"
implementation "com.android.support:design:$androidSupportVersion"

// Android TV UI libraries.
implementation "com.android.support:leanback-v17:$androidSupportVersion"

implementation 'com.android.support.constraint:constraint-layout:1.1.0'

testImplementation "com.android.support.test:runner:1.0.2"
androidTestImplementation "com.android.support.test:runner:1.0.1"
}

def getVersion() {
Expand Down Expand Up @@ -122,19 +111,3 @@ def getBuildVersionCode() {

return 0
}

def getCmakeVersion() {
try {
// Tokenized form of the output will be - ["cmake", "version", "M.m.p-rcx"], the version number
// will be at index 2
def version_string = 'cmake -version'.execute([], project.rootDir).text
.trim().tokenize()[2]

return version_string
}
catch(Exception e) {
logger.error('Cannot find Cmake, using default Cmake')
}

return null
}
3 changes: 3 additions & 0 deletions src/android/app/proguard-rules.pro
Expand Up @@ -19,3 +19,6 @@
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

-keep class org.citra.emu.NativeLibrary { *; }
-keep class android.support.v7.app.** { *; }

This file was deleted.

0 comments on commit 3ec17dd

Please sign in to comment.