Skip to content

Commit ce63e85

Browse files
Merge pull request #4
Implement Huffman encoding
2 parents 4047847 + c31f0e6 commit ce63e85

24 files changed

+1867
-74
lines changed

app/build.gradle.kts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@ android {
1616
versionName = "1.0"
1717

1818
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
19+
externalNativeBuild {
20+
cmake {
21+
// CLI arguments for CMake
22+
arguments += "-DLLAMA_BUILD_COMMON=ON"
23+
arguments += "-DCMAKE_BUILD_TYPE=Release"
24+
25+
// CLI flags for C++ compiler called by CMake
26+
cppFlags += ""
27+
}
28+
}
1929
}
2030

2131
buildTypes {
@@ -37,6 +47,12 @@ android {
3747
buildFeatures {
3848
compose = true
3949
}
50+
externalNativeBuild {
51+
cmake {
52+
path = file("src/main/cpp/CMakeLists.txt")
53+
version = "3.22.1"
54+
}
55+
}
4056
}
4157

4258
dependencies {
@@ -51,6 +67,7 @@ dependencies {
5167
implementation(libs.androidx.material3)
5268
implementation(libs.androidx.navigation.compose)
5369
implementation(libs.androidx.material.icons.extended)
70+
implementation(libs.androidx.datastore.preferences)
5471
testImplementation(libs.junit)
5572
androidTestImplementation(libs.androidx.junit)
5673
androidTestImplementation(libs.androidx.espresso.core)

app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:tools="http://schemas.android.com/tools">
44

5+
<uses-permission android:name="android.permission.INTERNET" />
6+
57
<application
68
android:allowBackup="true"
79
android:dataExtractionRules="@xml/data_extraction_rules"

app/src/main/cpp/CMakeLists.txt

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
2+
# For more information about using CMake with Android Studio, read the
3+
# documentation: https://d.android.com/studio/projects/add-native-code.html.
4+
# For more examples on how to use CMake, see https://github.com/android/ndk-samples.
5+
6+
# Sets the minimum CMake version required for this project.
7+
cmake_minimum_required(VERSION 3.22.1)
8+
9+
# Declares the project name. The project name can be accessed via ${ PROJECT_NAME},
10+
# Since this is the top level CMakeLists.txt, the project name is also accessible
11+
# with ${CMAKE_PROJECT_NAME} (both CMake variables are in-sync within the top level
12+
# build script scope).
13+
project("hips")
14+
15+
# Include CMake's FetchContent module
16+
include(FetchContent)
17+
18+
# Declare Git repo to fetch llama.cpp library from (has to be called "llama")
19+
FetchContent_Declare(
20+
llama
21+
GIT_REPOSITORY https://github.com/ggerganov/llama.cpp
22+
GIT_TAG master
23+
)
24+
25+
# Fetch llama.cpp (also provides "common")
26+
FetchContent_MakeAvailable(llama)
27+
28+
# Creates and names a library, sets it as either STATIC
29+
# or SHARED, and provides the relative paths to its source code.
30+
# You can define multiple libraries, and CMake builds them for you.
31+
# Gradle automatically packages shared libraries with your APK.
32+
#
33+
# In this top level CMakeLists.txt, ${CMAKE_PROJECT_NAME} is used to define
34+
# the target library name; in the sub-module's CMakeLists.txt, ${PROJECT_NAME}
35+
# is preferred for the same purpose.
36+
#
37+
# In order to load a library into your app from Java/Kotlin, you must call
38+
# System.loadLibrary() and pass the name of the library defined here;
39+
# for GameActivity/NativeActivity derived applications, the same library name must be
40+
# used in the AndroidManifest.xml file.
41+
add_library(${CMAKE_PROJECT_NAME} SHARED
42+
# List C/C++ source files with relative paths to this CMakeLists.txt.
43+
hips.cpp)
44+
45+
# Specifies libraries CMake should link to your target library. You
46+
# can link libraries from various origins, such as libraries defined in this
47+
# build script, prebuilt third-party libraries, or Android system libraries.
48+
target_link_libraries(${CMAKE_PROJECT_NAME}
49+
# List libraries link to the target library
50+
android
51+
log
52+
llama
53+
common
54+
)

0 commit comments

Comments
 (0)