mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-11-23 04:59:16 +01:00
Structure Code and Link libunicorn
This commit is contained in:
parent
2e5d107f5d
commit
875fe194f6
@ -1,54 +1,8 @@
|
|||||||
# For more information about using CMake with Android Studio, read the
|
cmake_minimum_required (VERSION 3.2)
|
||||||
# documentation: https://d.android.com/studio/projects/add-native-code.html
|
project(LightSwitch VERSION 1 LANGUAGES CXX)
|
||||||
|
set_property(GLOBAL PROPERTY CMAKE_CXX_STANDARD 17 PROPERTY CMAKE_CXX_STANDARD_REQUIRED TRUE)
|
||||||
|
|
||||||
# Sets the minimum version of CMake required to build the native library.
|
set(source_DIR ${CMAKE_SOURCE_DIR}/src/main/cpp/)
|
||||||
|
include_directories(${source_DIR}include/)
|
||||||
cmake_minimum_required(VERSION 3.4.1)
|
add_library(lightswitch SHARED ${source_DIR}lightswitch.cpp)
|
||||||
|
target_link_libraries(lightswitch ${source_DIR}/lib/${ANDROID_ABI}/libunicorn.a)
|
||||||
set(unicorn_DIR ${CMAKE_SOURCE_DIR}/src/main/cpp/unicorn)
|
|
||||||
|
|
||||||
include_directories(${unicorn_DIR}/lib/${ANDROID_ABI}/include)
|
|
||||||
|
|
||||||
add_library(unicorn SHARED IMPORTED)
|
|
||||||
set_target_properties(unicorn PROPERTIES IMPORTED_LOCATION
|
|
||||||
${unicorn_DIR}/lib/${ANDROID_ABI}/libunicorn.so)
|
|
||||||
|
|
||||||
# Creates and names a library, sets it as either STATIC
|
|
||||||
# or SHARED, and provides the relative paths to its source code.
|
|
||||||
# You can define multiple libraries, and CMake builds them for you.
|
|
||||||
# Gradle automatically packages shared libraries with your APK.
|
|
||||||
|
|
||||||
add_library( # Sets the name of the library.
|
|
||||||
native-lib
|
|
||||||
|
|
||||||
# Sets the library as a shared library.
|
|
||||||
SHARED
|
|
||||||
|
|
||||||
# Provides a relative path to your source file(s).
|
|
||||||
src/main/cpp/native-lib.cpp)
|
|
||||||
|
|
||||||
# Searches for a specified prebuilt library and stores the path as a
|
|
||||||
# variable. Because CMake includes system libraries in the search path by
|
|
||||||
# default, you only need to specify the name of the public NDK library
|
|
||||||
# you want to add. CMake verifies that the library exists before
|
|
||||||
# completing its build.
|
|
||||||
|
|
||||||
find_library( # Sets the name of the path variable.
|
|
||||||
log-lib
|
|
||||||
|
|
||||||
# Specifies the name of the NDK library that
|
|
||||||
# you want CMake to locate.
|
|
||||||
log)
|
|
||||||
|
|
||||||
# Specifies libraries CMake should link to your target library. You
|
|
||||||
# can link multiple libraries, such as libraries you define in this
|
|
||||||
# build script, prebuilt third-party libraries, or system libraries.
|
|
||||||
|
|
||||||
target_link_libraries( # Specifies the target library.
|
|
||||||
native-lib
|
|
||||||
|
|
||||||
unicorn
|
|
||||||
|
|
||||||
# Links the target library to the log library
|
|
||||||
# included in the NDK.
|
|
||||||
${log-lib})
|
|
@ -9,7 +9,6 @@ android {
|
|||||||
targetSdkVersion 29
|
targetSdkVersion 29
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "1.0"
|
versionName "1.0"
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
||||||
externalNativeBuild {
|
externalNativeBuild {
|
||||||
cmake {
|
cmake {
|
||||||
cppFlags ""
|
cppFlags ""
|
||||||
@ -28,7 +27,6 @@ android {
|
|||||||
externalNativeBuild {
|
externalNativeBuild {
|
||||||
cmake {
|
cmake {
|
||||||
path "CMakeLists.txt"
|
path "CMakeLists.txt"
|
||||||
version "3.10.2"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sourceSets {
|
sourceSets {
|
||||||
@ -42,7 +40,4 @@ dependencies {
|
|||||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
implementation 'androidx.appcompat:appcompat:1.0.2'
|
implementation 'androidx.appcompat:appcompat:1.0.2'
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||||||
testImplementation 'junit:junit:4.12'
|
|
||||||
androidTestImplementation 'androidx.test:runner:1.2.0'
|
|
||||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
|
|
||||||
}
|
}
|
||||||
|
@ -1,27 +0,0 @@
|
|||||||
package gq.cyuubi.lightswitch;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
|
|
||||||
import androidx.test.InstrumentationRegistry;
|
|
||||||
import androidx.test.runner.AndroidJUnit4;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Instrumented test, which will execute on an Android device.
|
|
||||||
*
|
|
||||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
|
||||||
*/
|
|
||||||
@RunWith(AndroidJUnit4.class)
|
|
||||||
public class ExampleInstrumentedTest {
|
|
||||||
@Test
|
|
||||||
public void useAppContext() {
|
|
||||||
// Context of the app under test.
|
|
||||||
Context appContext = InstrumentationRegistry.getTargetContext();
|
|
||||||
|
|
||||||
assertEquals("gq.cyuubi.lightswitch", appContext.getPackageName());
|
|
||||||
}
|
|
||||||
}
|
|
BIN
app/src/main/cpp/lib/arm64-v8a/libunicorn.a
Normal file
BIN
app/src/main/cpp/lib/arm64-v8a/libunicorn.a
Normal file
Binary file not shown.
Binary file not shown.
@ -1,15 +1,14 @@
|
|||||||
package gq.cyuubi.lightswitch;
|
package gq.cyuubi.lightswitch;
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
// Used to load the 'native-lib' library on application startup.
|
|
||||||
static {
|
static {
|
||||||
System.loadLibrary("native-lib");
|
System.loadLibrary("lightswitch");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -22,9 +21,5 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
tv.setText(stringFromJNI());
|
tv.setText(stringFromJNI());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* A native method that is implemented by the 'native-lib' native library,
|
|
||||||
* which is packaged with this application.
|
|
||||||
*/
|
|
||||||
public native String stringFromJNI();
|
public native String stringFromJNI();
|
||||||
}
|
}
|
||||||
|
@ -1,17 +0,0 @@
|
|||||||
package gq.cyuubi.lightswitch;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Example local unit test, which will execute on the development machine (host).
|
|
||||||
*
|
|
||||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
|
||||||
*/
|
|
||||||
public class ExampleUnitTest {
|
|
||||||
@Test
|
|
||||||
public void addition_isCorrect() {
|
|
||||||
assertEquals(4, 2 + 2);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user