-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit c009331
Showing
26 changed files
with
1,700 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild | ||
.cxx | ||
local.properties |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "curl/src/main/native/curl"] | ||
path = curl/src/main/native/curl | ||
url = https://github.com/curl/curl.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# curl Android | ||
|
||
curl static library prefab for android | ||
|
||
## Integration | ||
|
||
Gradle: | ||
|
||
```gradle | ||
implementation 'io.github.vvb2060.ndk:curl:7.72.0' | ||
``` | ||
|
||
This library is [Prefab](https://google.github.io/prefab/), so you will need to enable it in your project (Android Gradle Plugin 4.1+): | ||
|
||
```gradle | ||
android { | ||
... | ||
buildFeatures { | ||
... | ||
prefab true | ||
} | ||
} | ||
``` | ||
|
||
## Usage | ||
|
||
### ndk-build | ||
|
||
you can use `curl_static` in your `Android.mk`. | ||
For example, if your application defines `libapp.so` and it uses `curl_static`, your `Android.mk` file should include the following: | ||
|
||
```makefile | ||
include $(CLEAR_VARS) | ||
LOCAL_MODULE := app | ||
LOCAL_SRC_FILES := app.cpp | ||
LOCAL_STATIC_LIBRARIES := curl_static | ||
include $(BUILD_SHARED_LIBRARY) | ||
|
||
# If you don't need your project to build with NDKs older than r21, you can omit | ||
# this block. | ||
ifneq ($(call ndk-major-at-least,21),true) | ||
$(call import-add-path,$(NDK_GRADLE_INJECTED_IMPORT_PATH)) | ||
endif | ||
|
||
$(call import-module,prefab/curl) | ||
``` | ||
|
||
### CMake | ||
|
||
you can use `curl_static` in your `CMakeLists.txt`. | ||
For example, if your application defines `libapp.so` and it uses `curl_static`, your `CMakeLists.txt` file should include the following: | ||
|
||
```cmake | ||
add_library(app SHARED app.cpp) | ||
# Add these two lines. | ||
find_package(curl REQUIRED CONFIG) | ||
target_link_libraries(app curl::curl_static) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
buildscript { | ||
repositories { | ||
google() | ||
jcenter() | ||
} | ||
dependencies { | ||
classpath "com.android.tools.build:gradle:4.2.0-alpha13" | ||
} | ||
} | ||
|
||
allprojects { | ||
repositories { | ||
google() | ||
jcenter() | ||
} | ||
} | ||
|
||
task clean(type: Delete) { | ||
delete rootProject.buildDir | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
plugins { | ||
id 'com.android.library' | ||
} | ||
|
||
android { | ||
compileSdkVersion 30 | ||
buildToolsVersion "30.0.2" | ||
|
||
defaultConfig { | ||
minSdkVersion 16 | ||
targetSdkVersion 30 | ||
versionCode 1 | ||
versionName '7.72.0' | ||
ndkVersion '21.3.6528147' | ||
externalNativeBuild { | ||
ndkBuild { | ||
arguments "-j${Runtime.runtime.availableProcessors()}" | ||
} | ||
} | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled true | ||
} | ||
} | ||
|
||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
|
||
buildFeatures { | ||
buildConfig false | ||
prefabPublishing true | ||
} | ||
|
||
externalNativeBuild { | ||
ndkBuild.path 'src/main/native/Android.mk' | ||
} | ||
|
||
prefab { | ||
curl_static { | ||
headers "src/main/native/curl/include" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="io.github.vvb2060.ndk.curl"> | ||
|
||
<uses-permission android:name="android.permission.INTERNET" /> | ||
|
||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
LOCAL_PATH:= $(call my-dir) | ||
|
||
include $(CLEAR_VARS) | ||
include $(LOCAL_PATH)/curl/lib/Makefile.inc | ||
LOCAL_MODULE := curl_static | ||
LOCAL_SRC_FILES := $(addprefix curl/lib/,$(CSOURCES)) | ||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/curl/include $(LOCAL_PATH)/curl/lib $(LOCAL_PATH)/include | ||
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/curl/include | ||
LOCAL_CFLAGS := -DHAVE_CONFIG_H -DBUILDING_LIBCURL | ||
# https://gist.github.com/vvb2060/56d5b8fda2553f36938b2b72b1390114 | ||
STATIC_LIBRARY_STRIP := true | ||
include $(BUILD_STATIC_LIBRARY) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
APP_CFLAGS := -Wall -Werror -fvisibility=hidden | ||
APP_CFLAGS += -Wno-builtin-macro-redefined -D__FILE__=__FILE_NAME__ | ||
APP_CONLYFLAGS := -std=c99 | ||
APP_STL := c++_static |
Oops, something went wrong.