diff --git a/.gitignore b/.gitignore index c5227e8..09638ba 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,4 @@ build .externalNativeBuild libwebp .DS_Store - +wolfssl-git diff --git a/app/build.gradle b/app/build.gradle index 34b28db..a08ac5e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -18,9 +18,10 @@ android { } // set these default settings externalNativeBuild { - 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' + //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' } } diff --git a/build.gradle b/build.gradle index 84526bd..edf51cc 100644 --- a/build.gradle +++ b/build.gradle @@ -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" diff --git a/docs/CMakeLists_example.txt b/docs/CMakeLists_example.txt new file mode 100644 index 0000000..23270c7 --- /dev/null +++ b/docs/CMakeLists_example.txt @@ -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/) + + + diff --git a/docs/nc-wc-ndk_dev b/docs/nc-wc-ndk_dev index 78434b1..ea3eda4 100644 --- a/docs/nc-wc-ndk_dev +++ b/docs/nc-wc-ndk_dev @@ -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 diff --git a/docs/nc-wc-ndk_logs b/docs/nc-wc-ndk_logs new file mode 100644 index 0000000..b880cb5 --- /dev/null +++ b/docs/nc-wc-ndk_logs @@ -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 + + diff --git a/settings.gradle b/settings.gradle index 9d495b3..2ea1c1c 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1,2 @@ -include ':app' \ No newline at end of file +//include ':app' +include ':wolfssl' \ No newline at end of file diff --git a/wolfssl/CMakeLists.txt b/wolfssl/CMakeLists.txt new file mode 100644 index 0000000..ea312a2 --- /dev/null +++ b/wolfssl/CMakeLists.txt @@ -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) diff --git a/wolfssl/build.gradle b/wolfssl/build.gradle index 32eea06..c5f79ed 100644 --- a/wolfssl/build.gradle +++ b/wolfssl/build.gradle @@ -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']) } diff --git a/wolfssl/src/main/cpp/Android.mk b/wolfssl/docs/Android.mk similarity index 100% rename from wolfssl/src/main/cpp/Android.mk rename to wolfssl/docs/Android.mk diff --git a/wolfssl/src/main/cpp/Application.mk b/wolfssl/docs/Application.mk similarity index 100% rename from wolfssl/src/main/cpp/Application.mk rename to wolfssl/docs/Application.mk diff --git a/wolfssl/get_wolfssl_src.sh b/wolfssl/get_wolfssl_src.sh old mode 100644 new mode 100755 index 6197fc0..711b963 --- a/wolfssl/get_wolfssl_src.sh +++ b/wolfssl/get_wolfssl_src.sh @@ -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 diff --git a/wolfssl/src/main/cpp/CMakeLists.txt b/wolfssl/src/main/cpp/CMakeLists.txt index 7d6028f..afa2fd2 100644 --- a/wolfssl/src/main/cpp/CMakeLists.txt +++ b/wolfssl/src/main/cpp/CMakeLists.txt @@ -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) diff --git a/wolfssl/src/main/cpp/wolfssl-oem/CMakeLists.txt b/wolfssl/src/main/cpp/wolfssl-oem/CMakeLists.txt new file mode 100644 index 0000000..9e56950 --- /dev/null +++ b/wolfssl/src/main/cpp/wolfssl-oem/CMakeLists.txt @@ -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}")