Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3345880
D4433.id14195.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
16 KB
Referenced Files
None
Subscribers
None
D4433.id14195.diff
View Options
diff --git a/flake.nix b/flake.nix
--- a/flake.nix
+++ b/flake.nix
@@ -20,6 +20,7 @@
# package set
pkgsForSystem = system: import nixpkgs {
inherit overlays system;
+ config.android_sdk.accept_license = true;
};
# utils.lib.eachSystem helps create a result set of expected flake outputs
diff --git a/native/android/app/CMakeLists.txt b/native/android/app/CMakeLists.txt
--- a/native/android/app/CMakeLists.txt
+++ b/native/android/app/CMakeLists.txt
@@ -15,7 +15,23 @@
set(PACKAGE_NAME "comm_jni_module")
-find_package(fbjni REQUIRED CONFIG)
+find_package(fbjni
+ NAMES fbjni fbjniLibrary
+ REQUIRED CONFIG
+)
+
+# Allow for CMake build to run without invoking through gradle
+file(STRINGS ${CMAKE_SOURCE_DIR}/../gradle.properties ConfigContents)
+foreach(NameAndValue ${ConfigContents})
+ # Strip leading spaces
+ string(REGEX REPLACE "^[ ]+" "" NameAndValue ${NameAndValue})
+ # Find variable name
+ string(REGEX MATCH "^[^=]+" Name ${NameAndValue})
+ # Find the value
+ string(REPLACE "${Name}=" "" Value ${NameAndValue})
+ # Set the variable
+ set(${Name} "${Value}")
+endforeach()
set(BUILD_TESTING OFF)
set(HAVE_SYMBOLIZE OFF)
@@ -37,10 +53,16 @@
set(OPENSSL_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/build/third-party-ndk/openssl/openssl-${OPENSSL_VERSION}/build/${CMAKE_ANDROID_ARCH_ABI}")
list(APPEND CMAKE_FIND_ROOT_PATH "${OPENSSL_ROOT_DIR}")
-add_subdirectory(./build/third-party-ndk/grpc/grpc-${GRPC_VERSION}/ ${CMAKE_CURRENT_BINARY_DIR}/grpc/ EXCLUDE_FROM_ALL)
-add_subdirectory(./build/third-party-ndk/glog/glog-${GLOG_VERSION}/)
+add_subdirectory(${CMAKE_SOURCE_DIR}/build/third-party-ndk/grpc/grpc-${GRPC_VERSION}/ ${CMAKE_CURRENT_BINARY_DIR}/grpc/ EXCLUDE_FROM_ALL)
+add_subdirectory(${CMAKE_SOURCE_DIR}/build/third-party-ndk/glog/glog-${GLOG_VERSION}/)
add_subdirectory(../../node_modules/olm ./build)
+# Common Comm Cpp projects
+add_subdirectory(
+ ${CMAKE_CURRENT_SOURCE_DIR}/../../../native/cpp
+ ${CMAKE_CURRENT_BINARY_DIR}/cpp
+)
+
include_directories(
../../node_modules/react-native/React
../../node_modules/react-native/React/Base
@@ -55,9 +77,6 @@
# SQLCipher amalgamation
../../node_modules/@commapp/sqlcipher-amalgamation/src
- # SQLite ORM
- ../../cpp/lib/sqlite_orm
-
# symlinked React Native headers
../headers
@@ -69,25 +88,14 @@
# comm android specific code
./src/cpp
- # comm native mutual code
- ../../cpp/CommonCpp/NativeModules
- ../../cpp/CommonCpp/NativeModules/InternalModules
- ../../cpp/CommonCpp/NativeModules/PersistentStorageUtilities
- ../../cpp/CommonCpp/NativeModules/PersistentStorageUtilities/ThreadOperationsUtilities
- ../../cpp/CommonCpp/NativeModules/PersistentStorageUtilities/MessageOperationsUtilities
- ../../cpp/CommonCpp/NativeModules/PersistentStorageUtilities/MessageOperationsUtilities/MessageSpecs
- ../../cpp/CommonCpp/DatabaseManagers
- ../../cpp/CommonCpp/Tools
- ../../cpp/CommonCpp/grpc/_generated
- ../../cpp/CommonCpp/grpc
+ # Android ndk headers
+ ${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/
)
# search for all cpp files in this directory
file(GLOB SQLCIPHER "../../node_modules/@commapp/sqlcipher-amalgamation/src/*.c")
-file(GLOB_RECURSE COMMON_NATIVE_CODE "../../cpp/CommonCpp/**/*.cpp")
file(GLOB ANDROID_NATIVE_CODE "./src/cpp/*.cpp")
file(GLOB DOUBLE_CONVERSION_SOURCES "./build/third-party-ndk/double-conversion/double-conversion/*.cc")
-file(GLOB GRPC_CODE "../../cpp/CommonCpp/grpc/_generated/*.cc")
add_library(
# Sets the name of the library.
@@ -102,7 +110,7 @@
../../node_modules/react-native/ReactCommon/react/nativemodule/core/ReactCommon/TurboModule.cpp
../../node_modules/react-native/ReactCommon/react/nativemodule/core/ReactCommon/LongLivedObject.cpp
../../node_modules/react-native/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleUtils.cpp
-
+
# SQLCipher
${SQLCIPHER}
@@ -132,11 +140,8 @@
# double-conversion
${DOUBLE_CONVERSION_SOURCES}
- ${GRPC_CODE}
-
# comm code
${ANDROID_NATIVE_CODE}
- ${COMMON_NATIVE_CODE}
)
add_definitions(
@@ -144,7 +149,6 @@
-DFOLLY_NO_CONFIG=1
-DFOLLY_HAVE_CLOCK_GETTIME=1
-DFOLLY_HAVE_MEMRCHR=1
- -DFOLLY_USE_LIBCPP=1
-DFOLLY_MOBILE=1
## SQLCipher
@@ -156,6 +160,14 @@
find_library(log-lib log)
+if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
+ # Clang and GCC differ on how they expose the std namespace
+ # Only define this, if using clang
+ add_definitions(
+ -DFOLLY_USE_LIBCPP=1
+ )
+endif()
+
add_library(
# OpenSSL Crypto lib
openssl-crypto
@@ -190,6 +202,16 @@
openssl-ssl
grpc++
libprotobuf
+
+ # Comm
+ comm-modules-native
+ comm-databasemanagers
+ comm-tools
+ comm-grpc
+ comm-backup
+ comm-blob
+ comm-tunnelbroker
+ comm-sqlite-orm
)
# add a dummy library which is required by CallInvokerHolderImpl.java
diff --git a/native/android/app/build.gradle b/native/android/app/build.gradle
--- a/native/android/app/build.gradle
+++ b/native/android/app/build.gradle
@@ -371,7 +371,7 @@
// Release keystore via macOS Keychain Access
def getPassword(String keyLabel) {
if (System.getenv('ANDROID_SIGNING_PASSWORD')) {
- return System.getenv('ANDROID_SIGNING_PASSWORD')
+ return System.getenv('ANDROID_SIGNING_PASSWORD')
}
def stdout = new ByteArrayOutputStream()
exec {
@@ -389,7 +389,7 @@
// or only from 'adb devices' if running debug release.
def getBuildTypeABIs(nativeArchitectures) {
if (System.getenv("BUILDKITE") == "true") {
- return ["arm64-v8a"]
+ return ["arm64-v8a"]
}
def isBundleRelease = gradle.startParameter.taskRequests.any {
!it.args.isEmpty() && it.args.first().contains("bundleRelease")
@@ -499,6 +499,7 @@
arguments "-DANDROID_STL=c++_shared",
"-DGLOG_VERSION=" + GLOG_VERSION,
"-DOPENSSL_VERSION=" + OPENSSL_VERSION,
+ "-DANDROID_NDK_HOME=" + android.ndkDirectory.absolutePath,
"-DGRPC_VERSION=" + GRPC_VERSION
targets "comm_jni_module", "turbomodulejsijni"
}
diff --git a/native/android/app/src/cpp/CommSecureStore.cpp b/native/android/app/src/cpp/CommSecureStore.cpp
--- a/native/android/app/src/cpp/CommSecureStore.cpp
+++ b/native/android/app/src/cpp/CommSecureStore.cpp
@@ -1,4 +1,4 @@
-#include "CommSecureStore.h"
+#include <Tools/CommSecureStore.h>
#include <fbjni/fbjni.h>
using namespace facebook::jni;
diff --git a/native/android/app/src/cpp/GlobalNetworkSingletonJNIHelper.cpp b/native/android/app/src/cpp/GlobalNetworkSingletonJNIHelper.cpp
--- a/native/android/app/src/cpp/GlobalNetworkSingletonJNIHelper.cpp
+++ b/native/android/app/src/cpp/GlobalNetworkSingletonJNIHelper.cpp
@@ -1,5 +1,5 @@
-#include "GlobalNetworkSingletonJNIHelper.h"
-#include "GlobalNetworkSingleton.h"
+#include <Internal/GlobalNetworkSingleton.h>
+#include <Internal/GlobalNetworkSingletonJNIHelper.h>
namespace comm {
void GlobalNetworkSingletonJNIHelper::sendPong(
diff --git a/native/android/app/src/cpp/Logger.cpp b/native/android/app/src/cpp/Logger.cpp
--- a/native/android/app/src/cpp/Logger.cpp
+++ b/native/android/app/src/cpp/Logger.cpp
@@ -1,4 +1,4 @@
-#include "Logger.h"
+#include <Tools/Logger.h>
#include <android/log.h>
diff --git a/native/android/app/src/cpp/PlatformSpecificTools.cpp b/native/android/app/src/cpp/PlatformSpecificTools.cpp
--- a/native/android/app/src/cpp/PlatformSpecificTools.cpp
+++ b/native/android/app/src/cpp/PlatformSpecificTools.cpp
@@ -1,5 +1,5 @@
-#include "PlatformSpecificTools.h"
-#include "Logger.h"
+#include <Tools/Logger.h>
+#include <Tools/PlatformSpecificTools.h>
#include <fbjni/fbjni.h>
using namespace facebook::jni;
diff --git a/native/android/app/src/cpp/ThreadOperationsJNIHelper.cpp b/native/android/app/src/cpp/ThreadOperationsJNIHelper.cpp
--- a/native/android/app/src/cpp/ThreadOperationsJNIHelper.cpp
+++ b/native/android/app/src/cpp/ThreadOperationsJNIHelper.cpp
@@ -1,6 +1,6 @@
-#include "ThreadOperationsJNIHelper.h"
-#include "SQLiteQueryExecutor.h"
-#include "ThreadOperations.h"
+#include <DatabaseManagers/SQLiteQueryExecutor.h>
+#include <Internal/ThreadOperationsJNIHelper.h>
+#include <Native/ThreadOperations.h>
namespace comm {
void ThreadOperationsJNIHelper::updateSQLiteUnreadStatus(
diff --git a/native/android/app/src/cpp/jsiInstaller.cpp b/native/android/app/src/cpp/jsiInstaller.cpp
--- a/native/android/app/src/cpp/jsiInstaller.cpp
+++ b/native/android/app/src/cpp/jsiInstaller.cpp
@@ -1,12 +1,13 @@
-#include "CommCoreModule.h"
-#include "GlobalNetworkSingletonJNIHelper.h"
-#include "SQLiteQueryExecutor.h"
-#include "ThreadOperationsJNIHelper.h"
#include "jniHelpers.h"
#include <CallInvokerHolder.h>
#include <fbjni/fbjni.h>
#include <jsi/jsi.h>
+#include <DatabaseManagers/SQLiteQueryExecutor.h>
+#include <Internal/GlobalNetworkSingletonJNIHelper.h>
+#include <Internal/ThreadOperationsJNIHelper.h>
+#include <Native/CommCoreModule.h>
+
namespace jni = facebook::jni;
namespace jsi = facebook::jsi;
namespace react = facebook::react;
diff --git a/native/cpp/CMakeLists.txt b/native/cpp/CMakeLists.txt
--- a/native/cpp/CMakeLists.txt
+++ b/native/cpp/CMakeLists.txt
@@ -1,7 +1,11 @@
project(comm-cpp)
-# 3.13+ required for CMP0079 to be set
-cmake_minimum_required(VERSION 3.13)
+cmake_minimum_required(VERSION 3.10)
+
+# cmake 3.13+ defaults this to new, for android
+# build which uses 3.10, this needs to be set
+# explicitly
+# cmake_policy(SET CMP0079 NEW)
add_subdirectory(CommonCpp)
add_subdirectory(lib/sqlite_orm)
diff --git a/native/cpp/CommonCpp/CMakeLists.txt b/native/cpp/CommonCpp/CMakeLists.txt
--- a/native/cpp/CommonCpp/CMakeLists.txt
+++ b/native/cpp/CommonCpp/CMakeLists.txt
@@ -1,8 +1,5 @@
project(comm-common-cpp)
-# 3.13+ required for CMP0079 to be set
-cmake_minimum_required(VERSION 3.13)
-
include(GNUInstallDirs)
add_subdirectory(Tools)
diff --git a/native/cpp/CommonCpp/CryptoTools/CMakeLists.txt b/native/cpp/CommonCpp/CryptoTools/CMakeLists.txt
--- a/native/cpp/CommonCpp/CryptoTools/CMakeLists.txt
+++ b/native/cpp/CommonCpp/CryptoTools/CMakeLists.txt
@@ -17,6 +17,7 @@
)
add_library(comm-cryptotools
+ STATIC
${CRYPTO_HDRS}
${CRYPTO_SRCS}
)
@@ -24,7 +25,7 @@
find_package(Olm)
target_link_libraries(comm-cryptotools
- Olm
+ Olm::Olm
)
# reference local directory when building, use installation path when installing
diff --git a/native/cpp/CommonCpp/DatabaseManagers/CMakeLists.txt b/native/cpp/CommonCpp/DatabaseManagers/CMakeLists.txt
--- a/native/cpp/CommonCpp/DatabaseManagers/CMakeLists.txt
+++ b/native/cpp/CommonCpp/DatabaseManagers/CMakeLists.txt
@@ -21,6 +21,7 @@
)
add_library(comm-databasemanagers
+ STATIC
${DBM_HDRS}
${DBM_SRCS}
)
diff --git a/native/cpp/CommonCpp/NativeModules/CMakeLists.txt b/native/cpp/CommonCpp/NativeModules/CMakeLists.txt
--- a/native/cpp/CommonCpp/NativeModules/CMakeLists.txt
+++ b/native/cpp/CommonCpp/NativeModules/CMakeLists.txt
@@ -16,6 +16,7 @@
)
add_library(comm-modules-internal
+ STATIC
${INTERNAL_HDRS}
${INTERNAL_SRCS}
)
@@ -35,6 +36,7 @@
)
add_library(comm-modules-native
+ STATIC
${NATIVE_HDRS}
${NATIVE_SRCS}
)
diff --git a/native/cpp/CommonCpp/Tools/CMakeLists.txt b/native/cpp/CommonCpp/Tools/CMakeLists.txt
--- a/native/cpp/CommonCpp/Tools/CMakeLists.txt
+++ b/native/cpp/CommonCpp/Tools/CMakeLists.txt
@@ -3,7 +3,7 @@
include(GNUInstallDirs)
-find_package(Folly REQUIRED)
+find_package(Folly)
set(TOOLS_HDRS
"CommSecureStore.h"
@@ -17,6 +17,7 @@
)
add_library(comm-tools
+ STATIC
${TOOLS_HDRS}
${TOOLS_SRCS}
)
diff --git a/native/cpp/CommonCpp/grpc/CMakeLists.txt b/native/cpp/CommonCpp/grpc/CMakeLists.txt
--- a/native/cpp/CommonCpp/grpc/CMakeLists.txt
+++ b/native/cpp/CommonCpp/grpc/CMakeLists.txt
@@ -2,8 +2,8 @@
cmake_minimum_required(VERSION 3.4)
include(GNUInstallDirs)
-find_package(protobuf REQUIRED)
-find_package(gRPC REQUIRED)
+find_package(protobuf)
+find_package(gRPC)
set(_components backup blob tunnelbroker)
# Iterate through each protobuf file, create headers, sources, and export as component library
@@ -57,6 +57,7 @@
)
add_library(comm-client
+ STATIC
${CLIENT_HDRS}
${CLIENT_SRCS}
)
diff --git a/nix/android-dev-env.nix b/nix/android-dev-env.nix
new file mode 100644
--- /dev/null
+++ b/nix/android-dev-env.nix
@@ -0,0 +1,33 @@
+{ androidenv }:
+
+androidenv.composeAndroidPackages {
+ toolsVersion = "26.1.1";
+ platformToolsVersion = "33.0.1";
+ buildToolsVersions = [ "31.0.0" ];
+ includeEmulator = false;
+ emulatorVersion = "30.9.0";
+ platformVersions = [ "30" ];
+ includeSources = false;
+ includeSystemImages = false;
+ systemImageTypes = [ "google_apis_playstore" ];
+ abiVersions = [ "armeabi-v7a" "arm64-v8a" ];
+ cmakeVersions = [ "3.10.2" ];
+ includeNDK = true;
+ ndkVersions = ["22.0.7026061"];
+ useGoogleAPIs = false;
+ useGoogleTVAddOns = false;
+ includeExtras = [
+ "extras;google;gcm"
+ ];
+
+ extraLicenses = [
+ "android-googletv-license"
+ "android-sdk-preview-license"
+ "android-sdk-arm-dbt-license"
+ "android-sdk-preview-license"
+ "google-gdk-license"
+ "intel-android-extra-license"
+ "intel-android-sysimage-license"
+ "mips-android-sysimage-license"
+ ];
+}
diff --git a/nix/dev-shell.nix b/nix/dev-shell.nix
--- a/nix/dev-shell.nix
+++ b/nix/dev-shell.nix
@@ -1,9 +1,11 @@
{ mkShell
, stdenv
, lib
+, androidDevEnv
, amqp-cpp
, arcanist
, boost
+, c-ares-cmake
, cargo
, cmake
, cryptopp
@@ -11,11 +13,13 @@
, fbjni
, folly
, fmt
+, glog
, grpc
, libiconv
, libuv
, nodejs-16_x
, olm
+, openjdk8
, openssl
, pkg-config
, protobuf_3_15_cmake
@@ -25,6 +29,8 @@
, watchman
, rustfmt
, yarn
+, zlib
+, pkgsCross
}:
mkShell {
@@ -60,7 +66,7 @@
# include any libraries buildInputs
buildInputs = [
- fbjni # android builds
+ c-ares-cmake # android
protobuf_3_15_cmake # exposes both a library and a command, thus should appear in both inputs
folly # cpp tools
fmt # needed for folly
@@ -68,6 +74,10 @@
olm # needed for CryptoTools
sqlite # needed for sqlite_orm
openssl # needed for grpc
+ ] ++ lib.optionals stdenv.isx86_64 [
+ # aarch64-darwin tarballs are not available
+ androidDevEnv.androidsdk
+ glog # android
] ++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [
CoreFoundation
CoreServices
@@ -75,10 +85,19 @@
libiconv # identity service
]);
+ # Used by gradle
+ JAVA_HOME = openjdk8.passthru.home;
+
# shell commands to be ran upon entering shell
shellHook = ''
if [[ "$OSTYPE" == 'linux'* ]]; then
export MYSQL_UNIX_PORT=''${XDG_RUNTIME_DIR:-/run/user/$UID}/mysql-socket/mysql.sock
+ export ANDROID_SDK_ROOT=''${ANDROID_SDK_ROOT:-$HOME/Android/Sdk}
+ fi
+
+ if [ -f /etc/NIXOS ]; then
+ # allow for impurely downloaded android ndk tools to be used on NixOS
+ export LD_LIBRARY_PATH=${lib.makeLibraryPath [ stdenv.cc.cc.lib zlib ]}
fi
echo "Welcome to Comm dev environment! :)"
diff --git a/nix/overlay.nix b/nix/overlay.nix
--- a/nix/overlay.nix
+++ b/nix/overlay.nix
@@ -13,8 +13,18 @@
# add packages meant for just this repository
amqp-cpp = prev.callPackage ./amqp-cpp.nix { };
+ androidDevEnv = prev.callPackage ./android-dev-env.nix { };
+
protobuf_3_15_cmake = prev.callPackage ./protobuf_3_15.nix { };
+ # The original c-ares just uses a Makefile build
+ # so it doesn't export any cmake information.
+ # This is likely to be not be changed upstreamed because
+ # it's used to bootstrap curl, which is required to make cmake.
+ c-ares-cmake = (prev.c-ares.overrideAttrs(_: {
+ nativeBuildInputs = [ prev.cmake ];
+ }));
+
comm-grpc = final.callPackage ./comm-grpc.nix { };
devShell = final.callPackage ./dev-shell.nix { };
@@ -40,4 +50,11 @@
});
fbjni = prev.callPackage ./fbjni.nix { };
+
+ # Android ecosystem expects to be to available at `$out/lib`
+ openjdk8 = prev.openjdk8.overrideAttrs(_: {
+ preFixup = ''
+ ln -s $out/lib/openjdk/lib/* $out/lib
+ '';
+ });
}
diff --git a/nix/tunnelbroker.nix b/nix/tunnelbroker.nix
new file mode 100644
--- /dev/null
+++ b/nix/tunnelbroker.nix
@@ -0,0 +1,54 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, amqp-cpp
+, aws-sdk-cpp
+, cmake
+, folly
+, fmt
+, pkg-config
+, libuv
+, cryptopp
+, protobuf_3_15_cmake
+, grpc
+, glog
+, boost17x
+}:
+
+stdenv.mkDerivation rec {
+ pname = "tunnelbroker";
+ version = "0.0.1";
+
+ # needs access to native/cpp/CommonCpp/grpc
+ # so we have to capture the top-level directory
+ src = ../.;
+
+ prePatch = ''
+ cd services/tunnelbroker
+ '';
+
+ nativeBuildInputs = [
+ cmake
+ pkg-config
+ ];
+
+ buildInputs = [
+ amqp-cpp
+ aws-sdk-cpp
+ boost17x
+ libuv
+ cryptopp
+ protobuf_3_15_cmake
+ folly
+ fmt
+ grpc
+ glog
+ ];
+
+ # TODO: fix aws sdk installation assumptions, make assumption that include shares same prefix as lib
+ cmakeFlags = [
+ "-DAWSSDK_DEFAULT_ROOT_DIR="
+ "-DAWSSDK_INSTALL_INCLUDEDIR=${lib.getDev aws-sdk-cpp}/include"
+ "-DAWSSDK_CORE_HEADER_FILE=${lib.getDev aws-sdk-cpp}/include/aws/core/Aws.h"
+ ];
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 23, 7:21 AM (18 h, 40 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2567147
Default Alt Text
D4433.id14195.diff (16 KB)
Attached To
Mode
D4433: [android] Fix android CI + build with CMake changes
Attached
Detach File
Event Timeline
Log In to Comment