Skip to content

Commit

Permalink
Download libraries instead of using submodule (trustwallet#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
alejandro-isaza authored Feb 21, 2019
1 parent ba4fa31 commit 4f9c5b0
Show file tree
Hide file tree
Showing 15 changed files with 357 additions and 279 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ xcode/

# Dependencies
node_modules
lib/json
lib/protobuf

.idea/
6 changes: 0 additions & 6 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
[submodule "lib/protobuf"]
path = lib/protobuf
url = https://github.com/protocolbuffers/protobuf.git
[submodule "lib/googletest"]
path = lib/googletest
url = https://github.com/google/googletest.git
[submodule "lib/json"]
path = lib/json
url = https://github.com/nlohmann/json.git
16 changes: 8 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ macro(find_host_package)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
endmacro(find_host_package)

find_host_package(Boost)
find_host_package(Boost REQUIRED)

# Submodules
find_package(Git QUIET)
Expand All @@ -36,12 +36,10 @@ if(NOT EXISTS "${PROJECT_SOURCE_DIR}/lib/googletest/CMakeLists.txt")
message(FATAL_ERROR "The submodules were not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.")
endif()

# JSON
set(JSON_BuildTests OFF CACHE INTERNAL "")
add_subdirectory(lib/json)
include(ExternalProject)

# Protobuf
set(ROOT_DIR ${PROJECT_SOURCE_DIR})
# Dependencies
include(cmake/JSON.cmake)
include(cmake/Protobuf.cmake)

# Source files
Expand All @@ -51,14 +49,15 @@ if(${ANDROID})
add_library(TrustWalletCore SHARED ${sources} ${PROTO_SRCS} ${PROTO_HDRS})

find_library(log-lib log)
target_link_libraries(TrustWalletCore PRIVATE TrezorCrypto protobuf ${log-lib} Boost::boost nlohmann_json::nlohmann_json)
target_link_libraries(TrustWalletCore PRIVATE TrezorCrypto protobuf ${log-lib} Boost::boost)
else()
message("Configuring standalone")
file(GLOB_RECURSE sources src/*.c src/proto/*.cc src/*.cpp src/*.h)
add_library(TrustWalletCore ${sources} ${PROTO_SRCS} ${PROTO_HDRS})

target_link_libraries(TrustWalletCore PRIVATE TrezorCrypto protobuf Boost::boost nlohmann_json::nlohmann_json)
target_link_libraries(TrustWalletCore PRIVATE TrezorCrypto protobuf Boost::boost)
endif()
add_dependencies(TrustWalletCore nlohmann_json)

# Define headers for this library. PUBLIC headers are used for compiling the
# library, and will be added to consumers' build paths.
Expand All @@ -69,6 +68,7 @@ target_include_directories(TrustWalletCore
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src
${CMAKE_CURRENT_SOURCE_DIR}/jni/cpp
${json_INCLUDE_DIRS}
)

if(NOT ANDROID AND NOT IOS_PLATFORM)
Expand Down
217 changes: 109 additions & 108 deletions TrustWalletCore.podspec

Large diffs are not rendered by default.

55 changes: 55 additions & 0 deletions bitrise.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
format_version: '6'
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
project_type: other
trigger_map:
- push_branch: master
workflow: primary
- pull_request_source_branch: "*"
pull_request_target_branch: master
workflow: primary
workflows:
primary:
steps:
- [email protected]:
run_if: '{{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}'
- [email protected]: {}
- [email protected]: {}
- [email protected]:
title: Unlink Node
inputs:
- content: brew unlink node@8 || true
- [email protected]:
inputs:
- packages: autoconf automake cmake protobuf swift-protobuf boost node
- [email protected]:
title: Run Tests
inputs:
- content: |-
#!/usr/bin/env bash
set -e
set -x
tools/generate-files
cmake -H. -Bbuild -DCMAKE_BUILD_TYPE=Release
make -C build tests
build/tests/tests --gtest_output=xml
- [email protected]:
title: Run Ruby Tests
inputs:
- content: |
#!/usr/bin/env bash
set -e
set -x
cd codegen
rake
- [email protected]:
inputs:
- source_root_path: "$BITRISE_SOURCE_DIR/swift"
- [email protected]:
inputs:
- scheme: TrustWalletCore
- project_path: swift/TrustWalletCore.xcworkspace
- [email protected]: {}
- [email protected]: {}
5 changes: 1 addition & 4 deletions bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@ set -e
echo "#### Updating submodules... ####"
git submodule update --init

echo "#### Generating code... ####"
echo "#### Generating files... ####"
tools/generate-files
pushd codegen
bin/codegen
popd

echo "#### Building... ####"
cmake -H. -Bbuild -DCMAKE_BUILD_TYPE=Debug -DGIT_SUBMODULE=OFF
Expand Down
20 changes: 20 additions & 0 deletions cmake/JSON.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
set(json_PREFIX ${PROJECT_SOURCE_DIR}/lib/json)
file(MAKE_DIRECTORY ${json_PREFIX}/include/nlohmann)

ExternalProject_Add(
nlohmann_json

PREFIX "nlohmann"
INSTALL_DIR ${json_PREFIX}

URL https://github.com/nlohmann/json/releases/download/v3.5.0/include.zip
URL_HASH SHA256=3564da9c5b0cf2e032f97c69baedf10ddbc98030c337d0327a215ea72259ea21

CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_directory <SOURCE_DIR>/nlohmann <INSTALL_DIR>/include/nlohmann
)
ExternalProject_Get_Property(nlohmann_json source_dir)

set(json_SOURCE_DIR ${source_dir})
set(json_INCLUDE_DIRS ${json_SOURCE_DIR})
Loading

0 comments on commit 4f9c5b0

Please sign in to comment.