NEW: debug build working, release build has liblibwolfssl.so error ... LOL!

This commit is contained in:
JohnE 2017-01-21 12:39:00 -08:00
parent e9dea379c8
commit 26da7acde7
14 changed files with 208 additions and 55 deletions

2
.gitignore vendored
View File

@ -7,4 +7,4 @@ build
.externalNativeBuild
libwebp
.DS_Store
wolfssl-git

View File

@ -18,6 +18,7 @@ android {
}
// set these default settings
externalNativeBuild {
//arguments "-DVAR_NAME=VALUE"
arguments '-DANDROID_TOOLCHAIN=clang'
//arguments '-DANDROID_TOOLCHAIN=clang', '-DANDROID_STL=gnustl_static', '-DANDROID_PLATFORM=android-21'
//arguments '-DANDROID_TOOLCHAIN=gcc', '-DANDROID_STL=c++_static', '-DANDROID_PLATFORM=android-22'

View File

@ -5,6 +5,7 @@ buildscript {
jcenter()
}
dependencies {
// gradle tools 2.2.2+ supports stable ndk
classpath 'com.android.tools.build:gradle:2.2.3'
//classpath "com.android.tools.build:gradle-experimental:0.7.0-alpha4"

View File

@ -0,0 +1,62 @@
# Sets the minimum version of CMake required to build your native library.
# This ensures that a certain set of CMake features is available to
# your build.
#
# liblibrary-name.so
# static {
# System.loadLibrary(“native-lib”);
# }
cmake_minimum_required(VERSION 3.4.1)
# Specifies a library name, specifies whether the library is STATIC or
# SHARED, and provides relative paths to the source code. You can
# define multiple libraries by adding multiple add.library() commands,
# and CMake builds them for you. When you build your app, Gradle
# automatically packages shared libraries with your APK.
add_library( # Specifies 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 )
# Locates libraries that are built into the Android OS to be linked
# but not packaged in the APK
find_library( # Defines the name of the path variable
log-lib
# Specifies the name of the NDK library that
# CMake needs to locate.
log )
# Links your native library against one or more other native libraries.
target_link_libraries( # Specifies the target library.
native-lib
# Links the log library to the target library.
${log-lib} )
set_target_properties( # Specifies the target library.
imported-lib
# Specifies the parameter you want to define.
PROPERTIES IMPORTED_LOCATION
# Provides the path to the library you want to import.
imported-lib/src/${ANDROID_ABI}/libimported-lib.so )
add_library( app-glue
STATIC
${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c )
# You need to link static libraries against your shared native library.
target_link_libraries( native-lib app-glue ${log-lib} )
target_link_libraries( native-lib imported-lib app-glue ${log-lib} )
# Specifies a path to native header files.
include_directories(src/main/cpp/include/)

View File

@ -7,6 +7,7 @@
# gradle ndk support
@ http://tools.android.com/tech-docs/new-build-system/gradle-experimental/migrate-to-stable
@ https://developer.android.com/studio/projects/add-native-code.html#download-ndk
[ CMake ]
@ -15,3 +16,6 @@
# cmake building examples
@ https://github.com/googlesamples/android-ndk/tree/master-cmake
# variables
# arguments "-DVAR_NAME=VALUE"
@ https://developer.android.com/ndk/guides/cmake.html#variables

26
docs/nc-wc-ndk_logs Normal file
View File

@ -0,0 +1,26 @@
[[[ NC WC NDK Gradle Build Log Files ]]]
[[ gradle build ]]
# targets 'wolfssl'
$ gradle build
...
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':wolfssl:externalNativeBuildRelease'.
> Unexpected native build target wolfssl. Valid values are: libwolfssl
# targets 'libwolfssl'
$ gradle build
...
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':wolfssl:externalNativeBuildDebug'.
> Unexpected native build target libwolfssl. Valid values are: wolfssl

View File

@ -1 +1,2 @@
include ':app'
//include ':app'
include ':wolfssl'

6
wolfssl/CMakeLists.txt Normal file
View File

@ -0,0 +1,6 @@
# this CMake file is the root, and is used to create the bin folder
cmake_minimum_required(VERSION 3.4.1)
set(CMAKE_VERBOSE_MAKEFILE on)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src/main/cpp/wolfssl-oem)

View File

@ -1,40 +1,48 @@
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
compileSdkVersion 25
buildToolsVersion '25.0.2'
defaultConfig {
minSdkVersion 13
targetSdkVersion 23
// applicationId 'xyz.nc.android.wc'
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0"
versionName '1.0'
externalNativeBuild {
cmake {
arguments '-DANDROID_PLATFORM=android-9',
arguments '-DANDROID_PLATFORM=android-19',
'-DANDROID_TOOLCHAIN=clang'
// Sets optional flags for the C compiler.
cFlags \
'-D_POSIX_THREADS', '-DNDEBUG',
'-DPERSIST_SESSION_CACHE', '-DPERSIST_CERT_CACHE', '-DATOMIC_USER',
'-DHAVE_PK_CALLBACKS', '-DNO_DSA',
'-DNO_MD4', '-DNO_HC128', '-DNO_RABBIT',
'-DHAVE_OCSP', '-DHAVE_CRL', '-DWOLFSSL_JNI', '-DHAVE_DH',
'-Wall'
// explicitly build libs
targets 'gmath', 'gperf'
//targets 'wolfssl'
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
// buildTypes {
// release {
// minifyEnabled false
// proguardFiles getDefaultProguardFile('proguard-android.txt'),
// 'proguard-rules.pro'
// }
// }
externalNativeBuild {
cmake {
path 'src/main/cpp/CMakeLists.txt'
path 'CMakeLists.txt'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.4.0'
//compile fileTree(dir: 'libs', include: ['*.jar'])
}

5
wolfssl/get_wolfssl_src.sh Normal file → Executable file
View File

@ -1,4 +1,7 @@
#!/bin/sh
git clone https://github.com/wolfSSL/wolfssl.git
# from src/main/cpp/
cd src/main/cpp
git clone https://github.com/wolfSSL/wolfssl.git wolfssl-git
cd wolfssl-git
git checkout v3.10.0-stable
git checkout -b building

View File

@ -1,32 +1,2 @@
#
# Copyright (C) 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.
#
# Generate one static lib and one shared lib, copy them into
# ${project_dir}/distribution for other indepdendent applications
# to use.
cmake_minimum_required(VERSION 3.4.1)
set(CMAKE_VERBOSE_MAKEFILE on)
set(lib_src_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(lib_build_DIR $ENV{HOME}/tmp)
file(MAKE_DIRECTORY ${lib_build_DIR})
add_subdirectory(${lib_src_DIR}/gmath ${lib_build_DIR}/gmath)
add_subdirectory(${lib_src_DIR}/gperf ${lib_build_DIR}/gperf)
# this CMake file is the root, and is used to create the bin folder
add_subdirectory(wolfssl-oem)

View File

@ -0,0 +1,71 @@
# create a build target of "wolfssl"
# library is a SHARED (not STATIC)
# add all the source code
add_library(wolfssl SHARED
wolfssl-git/src/crl.c
wolfssl-git/src/internal.c
wolfssl-git/src/io.c
wolfssl-git/src/keys.c
wolfssl-git/src/ocsp.c
wolfssl-git/src/sniffer.c
wolfssl-git/src/ssl.c
wolfssl-git/src/tls.c
wolfssl-git/wolfcrypt/src/aes.c
wolfssl-git/wolfcrypt/src/arc4.c
wolfssl-git/wolfcrypt/src/asm.c
wolfssl-git/wolfcrypt/src/asn.c
wolfssl-git/wolfcrypt/src/blake2b.c
wolfssl-git/wolfcrypt/src/camellia.c
wolfssl-git/wolfcrypt/src/chacha.c
wolfssl-git/wolfcrypt/src/chacha20_poly1305.c
wolfssl-git/wolfcrypt/src/coding.c
wolfssl-git/wolfcrypt/src/compress.c
wolfssl-git/wolfcrypt/src/curve25519.c
wolfssl-git/wolfcrypt/src/des3.c
wolfssl-git/wolfcrypt/src/dh.c
wolfssl-git/wolfcrypt/src/dsa.c
wolfssl-git/wolfcrypt/src/ecc.c
wolfssl-git/wolfcrypt/src/ecc_fp.c
wolfssl-git/wolfcrypt/src/ed25519.c
wolfssl-git/wolfcrypt/src/error.c
wolfssl-git/wolfcrypt/src/fe_low_mem.c
wolfssl-git/wolfcrypt/src/fe_operations.c
wolfssl-git/wolfcrypt/src/ge_low_mem.c
wolfssl-git/wolfcrypt/src/ge_operations.c
wolfssl-git/wolfcrypt/src/hash.c
wolfssl-git/wolfcrypt/src/hc128.c
wolfssl-git/wolfcrypt/src/hmac.c
wolfssl-git/wolfcrypt/src/idea.c
wolfssl-git/wolfcrypt/src/integer.c
wolfssl-git/wolfcrypt/src/logging.c
wolfssl-git/wolfcrypt/src/md2.c
wolfssl-git/wolfcrypt/src/md4.c
wolfssl-git/wolfcrypt/src/md5.c
wolfssl-git/wolfcrypt/src/memory.c
wolfssl-git/wolfcrypt/src/misc.c
wolfssl-git/wolfcrypt/src/pkcs7.c
wolfssl-git/wolfcrypt/src/pkcs12.c
wolfssl-git/wolfcrypt/src/poly1305.c
wolfssl-git/wolfcrypt/src/pwdbased.c
wolfssl-git/wolfcrypt/src/rabbit.c
wolfssl-git/wolfcrypt/src/random.c
wolfssl-git/wolfcrypt/src/ripemd.c
wolfssl-git/wolfcrypt/src/rsa.c
wolfssl-git/wolfcrypt/src/sha.c
wolfssl-git/wolfcrypt/src/sha256.c
wolfssl-git/wolfcrypt/src/sha512.c
wolfssl-git/wolfcrypt/src/srp.c
wolfssl-git/wolfcrypt/src/tfm.c
wolfssl-git/wolfcrypt/src/wc_encrypt.c
wolfssl-git/wolfcrypt/src/wc_port.c )
# .h files are located at wolfssl/wolfssl, wolfssl/wolfssl/wolfcrypt
# the source files are looking for wolfssl/wolfcrypt/settings.h
# wolfssl-git/wolfssl/wolfcrypt/settings.h
# therefore give the root of the search path to the find the files
include_directories( wolfssl-git )
# set_target_properties(wolfssl
# PROPERTIES
# ARCHIVE_OUTPUT_DIRECTORY
# "${CMAKE_SOURCE_DIR}/dist/lib/${ANDROID_ABI}")