From 11e4aece26cdfc21751fb401e14d8f07fd0cb308 Mon Sep 17 00:00:00 2001 From: Chris Johnson Date: Mon, 12 Aug 2019 13:40:00 -0500 Subject: [PATCH 1/6] chore: Update build to be out of source Updated build to be out of source to clean up the workspace and added build scripts to enforce this. Re-enabled cmake_example builds in CI. Removed cmake_example .gitmodules file. This historically caused git to do funny things having a nested .gitmodules in the source tree. Commented out the submodule clone in the CMakeList.txt and setup the build script to mimic the submodule clone by copying the cpp-crypto source into the correct directory. --- .circleci/script_desktop.sh | 13 ++++++---- .gitignore | 24 +------------------ build.cmd | 6 +++++ build.sh | 7 ++++++ examples/cmake_example/.gitmodules | 3 --- examples/cmake_example/CMakeLists.txt | 12 +++++----- examples/cmake_example/build.cmd | 12 ++++++++++ examples/cmake_example/build.sh | 14 +++++++++++ ...-here => submodule-cpp-client-folder-here} | 0 examples/cmake_example/main.cpp | 6 +++-- run_tests.cmd | 2 ++ run_tests.sh | 5 ++++ 12 files changed, 65 insertions(+), 39 deletions(-) create mode 100644 build.cmd create mode 100755 build.sh delete mode 100644 examples/cmake_example/.gitmodules create mode 100644 examples/cmake_example/build.cmd create mode 100755 examples/cmake_example/build.sh rename examples/cmake_example/lib/{put-cpp-client-folder-here => submodule-cpp-client-folder-here} (100%) create mode 100644 run_tests.cmd create mode 100755 run_tests.sh diff --git a/.circleci/script_desktop.sh b/.circleci/script_desktop.sh index e506b7fc..9d53caa7 100644 --- a/.circleci/script_desktop.sh +++ b/.circleci/script_desktop.sh @@ -1,12 +1,15 @@ # run desktop builds -cmake . -DCMAKE_BUILD_TYPE=Coverage -DBUILD_TESTING=OFF +mkdir build +cd build +cmake .. -DCMAKE_BUILD_TYPE=Coverage -DBUILD_TESTING=OFF cmake --build . -# disable build examples until breaking changes are committed so the example can pull them in # build examples -#cd ./examples/cmake_example -#cmake . -#cmake --build . +cd ../examples/cmake_example +mkdir build +cd build +cmake .. +cmake --build . # run Gtest # cd ../../ diff --git a/.gitignore b/.gitignore index 7c7eb12d..b1af3e60 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ /.vs /.vscode /bin +build /lib /_Base /CMakeFiles @@ -23,15 +24,11 @@ /test/.vscode /test/lib/readme.txt .DS_Store -/src/Ark-Cpp-Client-lib.dir -/src/CMakeFiles -/src/cmake_install.cmake /src/Ark-Cpp-Client-lib.vcxproj.filters /src/Ark-Cpp-Client-lib.vcxproj /src/Ark-Cpp-Client-lib.sln /src/ALL_BUILD.vcxproj.filters /src/ALL_BUILD.vcxproj -/test/Ark-Cpp-Client-tests.dir /Win32 /test/NightlyMemoryCheck.vcxproj.filters /test/NightlyMemoryCheck.vcxproj @@ -39,14 +36,8 @@ /test/Nightly.vcxproj /test/Experimental.vcxproj.filters /test/Experimental.vcxproj -/test/DartConfiguration.tcl -/test/CTestTestfile.cmake /test/Continuous.vcxproj.filters /test/Continuous.vcxproj -/test/cmake_install.cmake -/test/CMakeFiles/generate.stamp.depend -/test/CMakeFiles/generate.stamp -/test/CMakeFiles /test/Ark-Cpp-Client-tests.vcxproj.filters /test/Ark-Cpp-Client-tests.vcxproj /test/Ark-Cpp-Client-tests.sln @@ -55,30 +46,17 @@ /_3rdParty /ZERO_CHECK.vcxproj.filters /ZERO_CHECK.vcxproj -/cmake_install.cmake -/CMakeCache.txt /Ark-Cpp-Client.sln /ALL_BUILD.vcxproj.filters /ALL_BUILD.vcxproj /src/Win32 -/test/Debug -/src/Debug -/test/Release -/src/Release -/examples/cmake_example/CMakeFiles -/examples/cmake_example/CMakeCache.txt -/examples/cmake_example/Win32/ /examples/cmake_example/_3rdParty -/examples/cmake_example/lib/Debug /examples/cmake_example/bin -/examples/cmake_example/Cpp-Client-Example.dir /examples/cmake_example/ZERO_CHECK.vcxproj.filters /examples/cmake_example/ZERO_CHECK.vcxproj /examples/cmake_example/Cpp-Client-Example.vcxproj.filters /examples/cmake_example/Cpp-Client-Example.vcxproj /examples/cmake_example/Cpp-Client-Example.sln -/examples/cmake_example/cmake_install.cmake /examples/cmake_example/ALL_BUILD.vcxproj.filters /examples/cmake_example/ALL_BUILD.vcxproj /examples/cmake_example/Win32 -/examples/cmake_example/Debug diff --git a/build.cmd b/build.cmd new file mode 100644 index 00000000..c11f29f2 --- /dev/null +++ b/build.cmd @@ -0,0 +1,6 @@ +rmdir /S /Q build +mkdir build +cd build +cmake .. +cmake --build . +cd .. diff --git a/build.sh b/build.sh new file mode 100755 index 00000000..a29521ca --- /dev/null +++ b/build.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +rm -dfr build +mkdir build +cd build +cmake .. +cmake --build . diff --git a/examples/cmake_example/.gitmodules b/examples/cmake_example/.gitmodules deleted file mode 100644 index 458f10ec..00000000 --- a/examples/cmake_example/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "lib/cpp-client"] - path = lib/cpp-client - url = https://github.com/ArkEcosystem/cpp-client.git diff --git a/examples/cmake_example/CMakeLists.txt b/examples/cmake_example/CMakeLists.txt index b549ccc2..0fc2d9c6 100644 --- a/examples/cmake_example/CMakeLists.txt +++ b/examples/cmake_example/CMakeLists.txt @@ -1,12 +1,12 @@ cmake_minimum_required(VERSION 3.2) -# clone submodules -execute_process( - COMMAND git submodule update --init --recursive - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} -) +# clone submodules - Uncomment when used outside of the Ark cpp-crypto source tree +#execute_process( +# COMMAND git submodule update --init --recursive +# WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} +#) -add_subdirectory(lib/cpp-client) +add_subdirectory(lib/cpp-client/src) project(Cpp-Client-Example) diff --git a/examples/cmake_example/build.cmd b/examples/cmake_example/build.cmd new file mode 100644 index 00000000..1224556a --- /dev/null +++ b/examples/cmake_example/build.cmd @@ -0,0 +1,12 @@ +rmdir /S /Q build +mkdir build +cd build + +REM Mimic submodule process by copying cpp-client src into the expected directory +REM git doesn't like nested .gitmodule files +rmdir /S /Q ..\lib\cpp-client\ +mkdir ..\lib\cpp-client\ +xcopy /E /Y /H /R ..\..\..\src ..\lib\cpp-client\ + +cmake .. +cmake --build . diff --git a/examples/cmake_example/build.sh b/examples/cmake_example/build.sh new file mode 100755 index 00000000..5af1675c --- /dev/null +++ b/examples/cmake_example/build.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +rm -dfr build +mkdir build +cd build + +# Mimic submodule process by copying cpp-client src into the expected directory +# git doesn't like nested .gitmodule files +rm -dfr ../lib/cpp-client/ +mkdir ../lib/cpp-client/ +cp -R ../../../src ../lib/cpp-client/ + +cmake .. +cmake --build . diff --git a/examples/cmake_example/lib/put-cpp-client-folder-here b/examples/cmake_example/lib/submodule-cpp-client-folder-here similarity index 100% rename from examples/cmake_example/lib/put-cpp-client-folder-here rename to examples/cmake_example/lib/submodule-cpp-client-folder-here diff --git a/examples/cmake_example/main.cpp b/examples/cmake_example/main.cpp index c9879500..0470200f 100644 --- a/examples/cmake_example/main.cpp +++ b/examples/cmake_example/main.cpp @@ -37,8 +37,10 @@ int main(int argc, char* argv[]) { // NOLINT std::cout << "Response for votes 'a3b890d25824eba36dfc2a5956590c68101378211dab216ae92c123ab1ba4b67':\n"; std::cout << vote << "\n\n"; - const auto walletsSearch = connection.api.wallets.search( - {"username", "genesis_1"}); + const std::map body_parameters = { + {"username", "genesis_1"} + }; + const auto walletsSearch = connection.api.wallets.search(body_parameters); std::cout << "Response for wallet search 'username=genesis_1':\n"; std::cout << walletsSearch << std::endl; diff --git a/run_tests.cmd b/run_tests.cmd new file mode 100644 index 00000000..3d388d7c --- /dev/null +++ b/run_tests.cmd @@ -0,0 +1,2 @@ +call build.cmd +.\build\test\Debug\Ark-Cpp-Client-tests diff --git a/run_tests.sh b/run_tests.sh new file mode 100755 index 00000000..3a07c1c9 --- /dev/null +++ b/run_tests.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +./build.sh +chmod +x ./build/test/Ark-Cpp-Client-tests +./build/test/Ark-Cpp-Client-tests From 089242d46250e88499feec337a7013f92989f5c3 Mon Sep 17 00:00:00 2001 From: Chris Johnson Date: Mon, 12 Aug 2019 21:28:28 -0500 Subject: [PATCH 2/6] doc: Update build steps for desktop OS Updated build and run tests steps for Linux, Mac, and Windows. --- docs/INSTALL_OS.md | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/docs/INSTALL_OS.md b/docs/INSTALL_OS.md index 73ba248c..56f2a2bd 100644 --- a/docs/INSTALL_OS.md +++ b/docs/INSTALL_OS.md @@ -17,9 +17,15 @@ or using # ### make and build -**`cd` into `.../cpp-client/`** -then run the following command combo: -`cmake . && cmake --build .` +**For Linux/Mac** +> `./build.sh` + +**For Windows** +> `./build.cmd` ### run tests -`./bin/Ark-Cpp-Client-tests` +**For Linux/Mac** +> `./run_tests.sh` + +**For Windows** +> `./run_tests.cmd` From a9b2bfba4dd78d764c3660fd0b5a4a107682bc46 Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 12 Aug 2019 22:03:11 -0500 Subject: [PATCH 3/6] fix: Correct CI examples build --- .circleci/script_desktop.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.circleci/script_desktop.sh b/.circleci/script_desktop.sh index 9d53caa7..84edd4be 100644 --- a/.circleci/script_desktop.sh +++ b/.circleci/script_desktop.sh @@ -6,10 +6,7 @@ cmake --build . # build examples cd ../examples/cmake_example -mkdir build -cd build -cmake .. -cmake --build . +./build.sh # run Gtest # cd ../../ From dc739a671486f37ff68a4e8cf54f2e9811fa6d04 Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 12 Aug 2019 22:10:39 -0500 Subject: [PATCH 4/6] fix: Correct subdirectory ordering --- examples/cmake_example/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/cmake_example/CMakeLists.txt b/examples/cmake_example/CMakeLists.txt index 0fc2d9c6..d9fafffd 100644 --- a/examples/cmake_example/CMakeLists.txt +++ b/examples/cmake_example/CMakeLists.txt @@ -6,8 +6,6 @@ cmake_minimum_required(VERSION 3.2) # WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} #) -add_subdirectory(lib/cpp-client/src) - project(Cpp-Client-Example) set(CMAKE_CXX_STANDARD 11) @@ -25,6 +23,8 @@ if (MSVC) #set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd") endif() +add_subdirectory(lib/cpp-client/src) + set(SOURCE_FILES main.cpp) add_executable(${PROJECT_NAME} ${SOURCE_FILES}) From 2346c31a0a4c4310550a66ca62736cd44adb69da Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 12 Aug 2019 22:18:58 -0500 Subject: [PATCH 5/6] fix: Correct tests path in CI build script --- .circleci/script_desktop.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/script_desktop.sh b/.circleci/script_desktop.sh index 84edd4be..5eafed9c 100644 --- a/.circleci/script_desktop.sh +++ b/.circleci/script_desktop.sh @@ -9,5 +9,5 @@ cd ../examples/cmake_example ./build.sh # run Gtest -# cd ../../ +cd ../../../build ./test/Ark-Cpp-Client-tests From ae7fd4fc3950585addc6cf3e0f99eb9cad2fa6ad Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 12 Aug 2019 22:27:50 -0500 Subject: [PATCH 6/6] fix: Correct CI build script paths --- .circleci/script_desktop.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/script_desktop.sh b/.circleci/script_desktop.sh index 5eafed9c..7165d67a 100644 --- a/.circleci/script_desktop.sh +++ b/.circleci/script_desktop.sh @@ -9,5 +9,5 @@ cd ../examples/cmake_example ./build.sh # run Gtest -cd ../../../build +cd ../../build ./test/Ark-Cpp-Client-tests