Skip to content

Commit

Permalink
Android build 1.0; Unity build
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanHenson committed May 6, 2016
1 parent 098116a commit 5bd66f8
Show file tree
Hide file tree
Showing 2,033 changed files with 24,692 additions and 9,170 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ external
openssl
zlib
credentials
toolchains/android/

#maven
# codegen
code-generation/generator/target/

#config output
aws-cpp-sdk-core/include/aws/core/SDKConfig.h
1,459 changes: 577 additions & 882 deletions CMakeLists.txt

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@ cmake <path-to-root-of-this-source-code> -G "Visual Studio 12 Win64"
msbuild INSTALL.vcxproj /p:Configuration=Release
```

####Building for Android
To build for Android, add -DTARGET_ARCH=ANDROID to your cmake command line. We've included a cmake toolchain file that should cover what's needed, assuming you have the appropriate environment variables (ANDROID_NDK) set.

#####Android on Windows
Building for Android on Windows requires some additional setup. In particular, you will need to run cmake from a Visual Studio developer command prompt (2013 or higher). Additionally, you will need 'git' and 'patch' in your path. If you have git installed on a Windows system, then patch is likely found in a sibling directory (.../Git/usr/bin/). Once you've verified these requirements, your cmake command line will change slightly to use nmake:

cmake -G "NMake Makefiles" -DTARGET_ARCH=ANDROID <other options> ..

Nmake builds targets in a serial fashion. To make things quicker, we recommend installing JOM as an alternative to nmake and then changing the cmake invocation to:

cmake -G "NMake Makefiles JOM" -DTARGET_ARCH=ANDROID <other options> ..

####CMake Variables

#####BUILD_ONLY
Expand Down
50 changes: 28 additions & 22 deletions android-build/build_and_test_android.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ def ParseArguments():
argMap[ "useExistingEmulator" ] = args[ "emu" ]
argMap[ "noBuild" ] = args[ "nobuild" ]
argMap[ "noInstall" ] = args[ "noinstall" ]
argMap[ "credentialsFile" ] = args[ "credentials" ] or "android-build/credentials"
argMap[ "buildType" ] = args[ "build" ] or "Debug"
argMap[ "credentialsFile" ] = args[ "credentials" ] or "~/.aws/credentials"
argMap[ "buildType" ] = args[ "build" ] or "Release"
argMap[ "runTest" ] = args[ "runtest" ]
argMap[ "so" ] = args[ "so" ]

Expand Down Expand Up @@ -117,7 +117,7 @@ def IsValidAVD(avd, abi, avdABIs):

def GetTestList(buildSharedObjects):
if buildSharedObjects:
return [ 'core', 's3', 'dynamodb', 'cloudfront', 'cognitoidentity', 'identity', 'lambda', 'logging', 'redshifts', 'sqs', 'transfer' ]
return [ 'core', 's3', 'dynamodb', 'cloudfront', 'cognitoidentity', 'identity', 'lambda', 'logging', 'redshift', 'sqs', 'transfer' ]
else:
return [ 'unified' ]

Expand Down Expand Up @@ -161,7 +161,7 @@ def SetupJniDirectory(abi, clean):
shutil.rmtree(path)

if os.path.exists( path ) == False:
os.mkdir( path )
os.makedirs( path )

return path

Expand All @@ -172,11 +172,6 @@ def CopyNativeLibraries(buildSharedObjects, jniDir, buildDir, abi):

shutil.copy(os.path.join(platformLibDir, "liblog.so"), jniDir)

shutil.copy(os.path.join(buildDir, "ZLIB-prefix", "src", "ZLIB-build", "libz.so"), jniDir)
shutil.copy(os.path.join(buildDir, "OPENSSL-prefix", "src", "OPENSSL-build", "crypto", "libcrypto.so"), jniDir)
shutil.copy(os.path.join(buildDir, "OPENSSL-prefix", "src", "OPENSSL-build", "ssl", "libssl.so"), jniDir)
shutil.copy(os.path.join(buildDir, "CURL-prefix", "src", "CURL-build", "lib", "libcurl.so"), jniDir)

stdLibDir = os.path.join(os.environ['ANDROID_NDK'], "sources", "cxx-stl", "gnu-libstdc++", "4.9", "libs", abi)
shutil.copy(os.path.join(stdLibDir, "libgnustl_shared.so"), jniDir)

Expand Down Expand Up @@ -205,32 +200,34 @@ def BuildNative(abi, clean, buildDir, jniDir, installDir, buildType, buildShared
for externalProjectDir in [ "openssl", "zlib", "curl" ]:
RemoveTree(externalProjectDir)

os.mkdir( jniDir )
os.mkdir( buildDir )
os.makedirs( jniDir )
os.makedirs( buildDir )
os.chdir( buildDir )

if buildSharedObjects:
link_type_line = "-DSTATIC_LINKING=0"
stl_line = "-DANDROID_STL=gnustl_shared"
if not buildSharedObjects:
link_type_line = "-DBUILD_SHARED_LIBS=OFF"
crt_line = "-DFORCE_SHARED_CRT=OFF"
else:
link_type_line = "-DSTATIC_LINKING=1"
stl_line = "-DANDROID_STL=gnustl_static"
link_type_line = "-DBUILD_SHARED_LIBS=ON"
crt_line = "-DFORCE_SHARED_CRT=ON"

subprocess.check_call( [ "cmake",
link_type_line,
crt_line,
"-DCUSTOM_MEMORY_MANAGEMENT=1",
stl_line,
"-DANDROID_STL_FORCE_FEATURES=OFF",
"-DTARGET_ARCH=ANDROID",
"-DANDROID_ABI=" + abi,
"-DANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-4.9",
"-DCMAKE_BUILD_TYPE=" + buildType,
'-DTEST_CERT_PATH="/data/data/aws.coretests/certs"',
'-DBUILD_ONLY=dynamodb;sqs;s3;lambda;kinesis;cognito-identity;transfer;iam;identity-management;access-management',
".."] )
else:
os.chdir( buildDir )

subprocess.check_call( [ "make", "-j12" ] )
if buildSharedObjects:
subprocess.check_call( [ "make", "-j12" ] )
else:
subprocess.check_call( [ "make", "-j12", "android-unified-tests" ] )

os.chdir( ".." )
CopyNativeLibraries(buildSharedObjects, jniDir, buildDir, abi)
Expand Down Expand Up @@ -304,7 +301,7 @@ def BuildAndInstallCertSet(pemSourceDir, buildDir):

# assume that if the directory exists, then the cert set is valid and we just need to upload
if not os.path.exists( certDir ):
os.mkdir( certDir )
os.makedirs( certDir )

# extract all the certs in curl's master cacert.pem file out into individual .pem files
subprocess.check_call( "cat " + pemSourceFile + " | awk '{print > \"" + certDir + "/cert\" (1+n) \".pem\"} /-----END CERTIFICATE-----/ {n++}'", shell = True )
Expand All @@ -328,6 +325,12 @@ def BuildAndInstallCertSet(pemSourceDir, buildDir):
certFileName = os.path.join(rootDir, fileName)
subprocess.check_call( [ "adb", "push", certFileName, "/data/data/aws.coretests/certs" ] )

def UploadTestResources(resourcesDir):
for rootDir, dirNames, fileNames in os.walk( resourcesDir ):
for fileName in fileNames:
resourceFileName = os.path.join( rootDir, fileName )
subprocess.check_call( [ "adb", "push", resourceFileName, os.path.join( "/data/data/aws.coretests/resources", fileName ) ] )


def InstallTests(credentialsFile):
subprocess.check_call( [ "adb", "install", "-r", "android-tests/app/build/outputs/apk/app-debug.apk" ] )
Expand Down Expand Up @@ -411,6 +414,9 @@ def Main():
print("Installing certs...")
BuildAndInstallCertSet("android-build", buildDir)

print("Uploading test resources")
UploadTestResources("aws-cpp-sdk-lambda-integration-tests/resources")

print("Running tests...")
RunTest( runTest )

Expand Down
8 changes: 1 addition & 7 deletions android-build/cmakefiles/openssl-cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,12 @@ endif()

install( FILES e_os2.h DESTINATION include/openssl )

install( FILES tools/c_hash tools/c_info tools/c_issuer tools/c_name tools/c_rehash
FAQ LICENSE PROBLEMS README README.ASN1 README.ENGINE
DESTINATION share/openssl )

install( DIRECTORY doc DESTINATION ./ )

# Generate the package target
set( CPACK_GENERATOR ZIP TGZ )
set( CPACK_PACKAGE_NAME "openssl-cmake" )
set( CPACK_PACKAGE_VERSION_MAJOR 1 )
set( CPACK_PACKAGE_VERSION_MINOR 0 )
set( CPACK_PACKAGE_VERSION_PATCH 2a )
set( CPACK_PACKAGE_VERSION_PATCH 2g )

include( CPack )

1 change: 0 additions & 1 deletion android-build/cmakefiles/openssl-cmake/apps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,3 @@ target_link_libraries ( openssl z crypto ssl )

install( TARGETS openssl RUNTIME DESTINATION bin/${SDK_INSTALL_BINARY_PREFIX}/${CMAKE_BUILD_TYPE} )

install( FILES CA.sh CA.pl tsget DESTINATION share/openssl )
9 changes: 5 additions & 4 deletions android-build/configure_openssl_cmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ def BuildIncludeFileList():
"../../crypto/objects/obj_mac.h",
"../../crypto/objects/objects.h",
"../../crypto/ocsp/ocsp.h",
"../../crypto/opensslconf.h",
"../../crypto/opensslv.h",
"../../crypto/ossl_typ.h",
"../../crypto/pem/pem.h",
Expand Down Expand Up @@ -128,7 +127,7 @@ def BuildIncludeFileList():
def CopyIncludeDirectory():
path = os.path.join( "openssl", "include", "openssl" )
if os.path.exists( path ) == False:
os.mkdir( path )
os.makedirs( path )

os.chdir( path )
for includeFile in BuildIncludeFileList():
Expand All @@ -138,12 +137,14 @@ def CopyIncludeDirectory():


def Main():
print ("Copying CMakeLists.txt files")
if not CopyCMakeFiles(os.path.join("openssl")):
print( "Failed to copy required CMake files" )
return 1

if platform.system() == "Windows": # symbolic links aren't extracted properly by cmake in windows, so copy the include file set manually
CopyIncludeDirectory()
print("Making unified include directory")
# normally these would be symlinks created by configure, but since we're not running configure, copy them manually
CopyIncludeDirectory()

return 0

Expand Down
8 changes: 4 additions & 4 deletions android-tests/android-tests.iml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id="android-tests" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="java-gradle" name="Java-Gradle">
<configuration>
<option name="BUILD_FOLDER_PATH" value="$MODULE_DIR$/build" />
<option name="BUILDABLE" value="false" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="true">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
</module>

15 changes: 6 additions & 9 deletions android-tests/app/app.iml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id=":app" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="android-tests" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="android-tests" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android-gradle" name="Android-Gradle">
<configuration>
Expand All @@ -13,11 +13,8 @@
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugAndroidTest" />
<option name="COMPILE_JAVA_TEST_TASK_NAME" value="compileDebugAndroidTestSources" />
<afterSyncTasks>
<task>generateDebugAndroidTestSources</task>
<task>generateDebugSources</task>
</afterSyncTasks>
<option name="SOURCE_GEN_TASK_NAME" value="generateDebugSources" />
<option name="TEST_SOURCE_GEN_TASK_NAME" value="generateDebugAndroidTestSources" />
<option name="ALLOW_USER_CONFIGURATION" value="false" />
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
Expand All @@ -26,7 +23,7 @@
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false">
<component name="NewModuleRootManager" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/androidTest/debug" />
<exclude-output />
Expand Down Expand Up @@ -84,12 +81,12 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<orderEntry type="jdk" jdkName="Android API 22 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="appcompat-v7-22.0.0" level="project" />
<orderEntry type="library" exported="" name="support-v4-22.0.0" level="project" />
<orderEntry type="library" exported="" name="support-annotations-22.0.0" level="project" />
</component>
</module>
</module>

11 changes: 4 additions & 7 deletions android-tests/app/src/main/java/aws/coretests/TestActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

package aws.coretests;

import android.content.Context;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
Expand Down Expand Up @@ -129,10 +130,6 @@ protected Boolean doInBackground(String... testNames)

//System.loadLibrary("c");
System.loadLibrary("gnustl_shared");
System.loadLibrary("z");
System.loadLibrary("crypto");
System.loadLibrary("ssl");
System.loadLibrary("curl");
System.loadLibrary("log");
System.loadLibrary("aws-cpp-sdk-core");
System.loadLibrary("testing-resources");
Expand All @@ -154,7 +151,7 @@ protected Boolean doInBackground(String... testNames)

Log.i("AwsNativeSDK", "Starting tests");

boolean success = runTests() == 0;
boolean success = runTests((Context)m_source) == 0;
if(success) {
Log.i("AwsNativeSDK", "Tests Succeeded!");
} else {
Expand All @@ -171,7 +168,7 @@ protected void onPostExecute(Boolean testsSucceeded)
}
}

public native int runTests();
static public native int runTests(Context context);

@Override
public void onDestroy()
Expand All @@ -187,7 +184,7 @@ protected void onCreate(Bundle savedInstanceState) {

String testName = getIntent().getStringExtra("test");
if(testName == null) {
testName = "dynamodb";
testName = "unified";
}
new TestTask(this).execute(testName);
}
Expand Down
Empty file modified android-tests/gradlew
100644 → 100755
Empty file.
Loading

0 comments on commit 5bd66f8

Please sign in to comment.