Skip to content
This repository has been archived by the owner on Dec 21, 2023. It is now read-only.

Commit

Permalink
Do not use amalgamated header for developing
Browse files Browse the repository at this point in the history
  • Loading branch information
bassosimone committed Dec 5, 2019
1 parent ec2f1df commit b756443
Show file tree
Hide file tree
Showing 8 changed files with 111 additions and 69 deletions.
140 changes: 78 additions & 62 deletions CMakeLists.txt
Expand Up @@ -44,14 +44,17 @@ endif()
include(CheckFunctionExists)
include(CheckSymbolExists)
file(WRITE "libndt.hpp" "// AUTOGENERATED BY CMake! DON'T EDIT!\n\n")
file(READ "sys.hpp" MK_AMALGAMATE_1172_0)
file(READ "preamble.hpp" MK_AMALGAMATE_1172_0)
file(APPEND "libndt.hpp" "${MK_AMALGAMATE_1172_0}")
file(APPEND "libndt.hpp" "\n\n")
file(READ "api.hpp" MK_AMALGAMATE_1172_1)
file(READ "sys.hpp" MK_AMALGAMATE_1172_1)
file(APPEND "libndt.hpp" "${MK_AMALGAMATE_1172_1}")
file(APPEND "libndt.hpp" "\n\n")
file(READ "impl.hpp" MK_AMALGAMATE_1172_2)
file(READ "api.hpp" MK_AMALGAMATE_1172_2)
file(APPEND "libndt.hpp" "${MK_AMALGAMATE_1172_2}")
file(APPEND "libndt.hpp" "\n\n")
file(READ "impl.hpp" MK_AMALGAMATE_1172_3)
file(APPEND "libndt.hpp" "${MK_AMALGAMATE_1172_3}")
check_function_exists(strtonum LIBNDT_HAVE_STRTONUM)
if(${LIBNDT_HAVE_STRTONUM})
add_definitions(-DLIBNDT_HAVE_STRTONUM)
Expand All @@ -72,18 +75,18 @@ endif()
message(STATUS "mkdirAll: ${CMAKE_BINARY_DIR}/.mkbuild/include")
execute_process(COMMAND
${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/.mkbuild/include"
RESULT_VARIABLE FAILURE_2218)
if("${FAILURE_2218}")
message(FATAL_ERROR "${FAILURE_2218}")
RESULT_VARIABLE FAILURE_2350)
if("${FAILURE_2350}")
message(FATAL_ERROR "${FAILURE_2350}")
endif()
message(STATUS "download: https://raw.githubusercontent.com/adishavit/argh/v1.3.1/argh.h")
file(DOWNLOAD https://raw.githubusercontent.com/adishavit/argh/v1.3.1/argh.h
"${CMAKE_BINARY_DIR}/.mkbuild/include/argh.h"
EXPECTED_HASH SHA256=ddb7dfc18dcf90149735b76fb2cff101067453a1df1943a6911233cb7085980c
TLS_VERIFY ON)
LIST(APPEND CMAKE_REQUIRED_INCLUDES "${CMAKE_BINARY_DIR}/.mkbuild/include")
CHECK_INCLUDE_FILE_CXX("argh.h" MK_HAVE_HEADER_2718)
if(NOT ("${MK_HAVE_HEADER_2718}"))
CHECK_INCLUDE_FILE_CXX("argh.h" MK_HAVE_HEADER_2850)
if(NOT ("${MK_HAVE_HEADER_2850}"))
message(FATAL_ERROR "cannot find: argh.h")
endif()

Expand All @@ -94,18 +97,18 @@ endif()
message(STATUS "mkdirAll: ${CMAKE_BINARY_DIR}/.mkbuild/include")
execute_process(COMMAND
${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/.mkbuild/include"
RESULT_VARIABLE FAILURE_3042)
if("${FAILURE_3042}")
message(FATAL_ERROR "${FAILURE_3042}")
RESULT_VARIABLE FAILURE_3174)
if("${FAILURE_3174}")
message(FATAL_ERROR "${FAILURE_3174}")
endif()
message(STATUS "download: https://github.com/catchorg/Catch2/releases/download/v2.8.0/catch.hpp")
file(DOWNLOAD https://github.com/catchorg/Catch2/releases/download/v2.8.0/catch.hpp
"${CMAKE_BINARY_DIR}/.mkbuild/include/catch.hpp"
EXPECTED_HASH SHA256=2791047e459b981a1035f4ee16a2ad031f5bfb4ba66487ad4d3fc816c8946f61
TLS_VERIFY ON)
LIST(APPEND CMAKE_REQUIRED_INCLUDES "${CMAKE_BINARY_DIR}/.mkbuild/include")
CHECK_INCLUDE_FILE_CXX("catch.hpp" MK_HAVE_HEADER_3559)
if(NOT ("${MK_HAVE_HEADER_3559}"))
CHECK_INCLUDE_FILE_CXX("catch.hpp" MK_HAVE_HEADER_3691)
if(NOT ("${MK_HAVE_HEADER_3691}"))
message(FATAL_ERROR "cannot find: catch.hpp")
endif()

Expand All @@ -118,9 +121,9 @@ if(("${WIN32}"))
message(STATUS "mkdirAll: ${CMAKE_BINARY_DIR}/.mkbuild/download")
execute_process(COMMAND
${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/.mkbuild/download"
RESULT_VARIABLE FAILURE_3940)
if("${FAILURE_3940}")
message(FATAL_ERROR "${FAILURE_3940}")
RESULT_VARIABLE FAILURE_4072)
if("${FAILURE_4072}")
message(FATAL_ERROR "${FAILURE_4072}")
endif()
message(STATUS "download: https://github.com/measurement-kit/prebuilt/releases/download//testing/windows-curl-7.61.1-1.tar.gz")
file(DOWNLOAD https://github.com/measurement-kit/prebuilt/releases/download//testing/windows-curl-7.61.1-1.tar.gz
Expand All @@ -131,28 +134,28 @@ if(("${WIN32}"))
execute_process(COMMAND
${CMAKE_COMMAND} -E tar xf "${CMAKE_BINARY_DIR}/.mkbuild/download/windows-curl-7.61.1-1.tar.gz"
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/.mkbuild/download"
RESULT_VARIABLE FAILURE_4763)
if("${FAILURE_4763}")
message(FATAL_ERROR "${FAILURE_4763}")
RESULT_VARIABLE FAILURE_4895)
if("${FAILURE_4895}")
message(FATAL_ERROR "${FAILURE_4895}")
endif()
LIST(APPEND CMAKE_REQUIRED_INCLUDES "${CMAKE_BINARY_DIR}/.mkbuild/download/MK_DIST/windows/curl/7.61.1-1/${MK_WIN32_ARCH}/include")
CHECK_INCLUDE_FILE_CXX("curl/curl.h" MK_HAVE_HEADER_5008)
if(NOT ("${MK_HAVE_HEADER_5008}"))
CHECK_INCLUDE_FILE_CXX("curl/curl.h" MK_HAVE_HEADER_5140)
if(NOT ("${MK_HAVE_HEADER_5140}"))
message(FATAL_ERROR "cannot find: curl/curl.h")
endif()
CHECK_LIBRARY_EXISTS("${CMAKE_BINARY_DIR}/.mkbuild/download/MK_DIST/windows/curl/7.61.1-1/${MK_WIN32_ARCH}/lib/libcurl.lib" "curl_easy_init" "" MK_HAVE_LIB_5167)
if(NOT ("${MK_HAVE_LIB_5167}"))
CHECK_LIBRARY_EXISTS("${CMAKE_BINARY_DIR}/.mkbuild/download/MK_DIST/windows/curl/7.61.1-1/${MK_WIN32_ARCH}/lib/libcurl.lib" "curl_easy_init" "" MK_HAVE_LIB_5299)
if(NOT ("${MK_HAVE_LIB_5299}"))
message(FATAL_ERROR "cannot find: ${CMAKE_BINARY_DIR}/.mkbuild/download/MK_DIST/windows/curl/7.61.1-1/${MK_WIN32_ARCH}/lib/libcurl.lib")
endif()
LIST(APPEND CMAKE_REQUIRED_LIBRARIES "${CMAKE_BINARY_DIR}/.mkbuild/download/MK_DIST/windows/curl/7.61.1-1/${MK_WIN32_ARCH}/lib/libcurl.lib")
LIST(APPEND CMAKE_REQUIRED_DEFINITIONS -DCURL_STATICLIB)
else()
CHECK_INCLUDE_FILE_CXX("curl/curl.h" MK_HAVE_HEADER_5725)
if(NOT ("${MK_HAVE_HEADER_5725}"))
CHECK_INCLUDE_FILE_CXX("curl/curl.h" MK_HAVE_HEADER_5857)
if(NOT ("${MK_HAVE_HEADER_5857}"))
message(FATAL_ERROR "cannot find: curl/curl.h")
endif()
CHECK_LIBRARY_EXISTS("curl" "curl_easy_init" "" MK_HAVE_LIB_5884)
if(NOT ("${MK_HAVE_LIB_5884}"))
CHECK_LIBRARY_EXISTS("curl" "curl_easy_init" "" MK_HAVE_LIB_6016)
if(NOT ("${MK_HAVE_LIB_6016}"))
message(FATAL_ERROR "cannot find: curl")
endif()
LIST(APPEND CMAKE_REQUIRED_LIBRARIES "curl")
Expand All @@ -165,9 +168,9 @@ endif()
message(STATUS "mkdirAll: ${CMAKE_BINARY_DIR}/.mkbuild/download")
execute_process(COMMAND
${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/.mkbuild/download"
RESULT_VARIABLE FAILURE_6308)
if("${FAILURE_6308}")
message(FATAL_ERROR "${FAILURE_6308}")
RESULT_VARIABLE FAILURE_6440)
if("${FAILURE_6440}")
message(FATAL_ERROR "${FAILURE_6440}")
endif()
message(STATUS "download: https://github.com/measurement-kit/generic-assets/releases/download/20190520205742/generic-assets-20190520205742.tar.gz")
file(DOWNLOAD https://github.com/measurement-kit/generic-assets/releases/download/20190520205742/generic-assets-20190520205742.tar.gz
Expand All @@ -178,9 +181,9 @@ message(STATUS "Extract: ${CMAKE_BINARY_DIR}/.mkbuild/download/generic-assets-20
execute_process(COMMAND
${CMAKE_COMMAND} -E tar xf "${CMAKE_BINARY_DIR}/.mkbuild/download/generic-assets-20190520205742.tar.gz"
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/.mkbuild/download"
RESULT_VARIABLE FAILURE_7169)
if("${FAILURE_7169}")
message(FATAL_ERROR "${FAILURE_7169}")
RESULT_VARIABLE FAILURE_7301)
if("${FAILURE_7301}")
message(FATAL_ERROR "${FAILURE_7301}")
endif()

#
Expand All @@ -190,18 +193,18 @@ endif()
message(STATUS "mkdirAll: ${CMAKE_BINARY_DIR}/.mkbuild/include")
execute_process(COMMAND
${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/.mkbuild/include"
RESULT_VARIABLE FAILURE_7454)
if("${FAILURE_7454}")
message(FATAL_ERROR "${FAILURE_7454}")
RESULT_VARIABLE FAILURE_7586)
if("${FAILURE_7586}")
message(FATAL_ERROR "${FAILURE_7586}")
endif()
message(STATUS "download: https://raw.githubusercontent.com/nlohmann/json/v3.6.1/single_include/nlohmann/json.hpp")
file(DOWNLOAD https://raw.githubusercontent.com/nlohmann/json/v3.6.1/single_include/nlohmann/json.hpp
"${CMAKE_BINARY_DIR}/.mkbuild/include/json.hpp"
EXPECTED_HASH SHA256=d2eeb25d2e95bffeb08ebb7704cdffd2e8fca7113eba9a0b38d60a5c391ea09a
TLS_VERIFY ON)
LIST(APPEND CMAKE_REQUIRED_INCLUDES "${CMAKE_BINARY_DIR}/.mkbuild/include")
CHECK_INCLUDE_FILE_CXX("json.hpp" MK_HAVE_HEADER_8006)
if(NOT ("${MK_HAVE_HEADER_8006}"))
CHECK_INCLUDE_FILE_CXX("json.hpp" MK_HAVE_HEADER_8138)
if(NOT ("${MK_HAVE_HEADER_8138}"))
message(FATAL_ERROR "cannot find: json.hpp")
endif()

Expand All @@ -214,9 +217,9 @@ if(("${WIN32}"))
message(STATUS "mkdirAll: ${CMAKE_BINARY_DIR}/.mkbuild/download")
execute_process(COMMAND
${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/.mkbuild/download"
RESULT_VARIABLE FAILURE_8388)
if("${FAILURE_8388}")
message(FATAL_ERROR "${FAILURE_8388}")
RESULT_VARIABLE FAILURE_8520)
if("${FAILURE_8520}")
message(FATAL_ERROR "${FAILURE_8520}")
endif()
message(STATUS "download: https://github.com/measurement-kit/prebuilt/releases/download//testing/windows-libressl-2.7.4-1.tar.gz")
file(DOWNLOAD https://github.com/measurement-kit/prebuilt/releases/download//testing/windows-libressl-2.7.4-1.tar.gz
Expand All @@ -227,22 +230,22 @@ if(("${WIN32}"))
execute_process(COMMAND
${CMAKE_COMMAND} -E tar xf "${CMAKE_BINARY_DIR}/.mkbuild/download/windows-libressl-2.7.4-1.tar.gz"
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/.mkbuild/download"
RESULT_VARIABLE FAILURE_9226)
if("${FAILURE_9226}")
message(FATAL_ERROR "${FAILURE_9226}")
RESULT_VARIABLE FAILURE_9358)
if("${FAILURE_9358}")
message(FATAL_ERROR "${FAILURE_9358}")
endif()
LIST(APPEND CMAKE_REQUIRED_INCLUDES "${CMAKE_BINARY_DIR}/.mkbuild/download/MK_DIST/windows/libressl/2.7.4-1/${MK_WIN32_ARCH}/include")
CHECK_INCLUDE_FILE_CXX("openssl/rsa.h" MK_HAVE_HEADER_9474)
if(NOT ("${MK_HAVE_HEADER_9474}"))
CHECK_INCLUDE_FILE_CXX("openssl/rsa.h" MK_HAVE_HEADER_9606)
if(NOT ("${MK_HAVE_HEADER_9606}"))
message(FATAL_ERROR "cannot find: openssl/rsa.h")
endif()
CHECK_LIBRARY_EXISTS("${CMAKE_BINARY_DIR}/.mkbuild/download/MK_DIST/windows/libressl/2.7.4-1/${MK_WIN32_ARCH}/lib/crypto.lib" "RSA_new" "" MK_HAVE_LIB_9637)
if(NOT ("${MK_HAVE_LIB_9637}"))
CHECK_LIBRARY_EXISTS("${CMAKE_BINARY_DIR}/.mkbuild/download/MK_DIST/windows/libressl/2.7.4-1/${MK_WIN32_ARCH}/lib/crypto.lib" "RSA_new" "" MK_HAVE_LIB_9769)
if(NOT ("${MK_HAVE_LIB_9769}"))
message(FATAL_ERROR "cannot find: ${CMAKE_BINARY_DIR}/.mkbuild/download/MK_DIST/windows/libressl/2.7.4-1/${MK_WIN32_ARCH}/lib/crypto.lib")
endif()
LIST(APPEND CMAKE_REQUIRED_LIBRARIES "${CMAKE_BINARY_DIR}/.mkbuild/download/MK_DIST/windows/libressl/2.7.4-1/${MK_WIN32_ARCH}/lib/crypto.lib")
CHECK_LIBRARY_EXISTS("${CMAKE_BINARY_DIR}/.mkbuild/download/MK_DIST/windows/libressl/2.7.4-1/${MK_WIN32_ARCH}/lib/ssl.lib" "SSL_new" "" MK_HAVE_LIB_10128)
if(NOT ("${MK_HAVE_LIB_10128}"))
CHECK_LIBRARY_EXISTS("${CMAKE_BINARY_DIR}/.mkbuild/download/MK_DIST/windows/libressl/2.7.4-1/${MK_WIN32_ARCH}/lib/ssl.lib" "SSL_new" "" MK_HAVE_LIB_10260)
if(NOT ("${MK_HAVE_LIB_10260}"))
message(FATAL_ERROR "cannot find: ${CMAKE_BINARY_DIR}/.mkbuild/download/MK_DIST/windows/libressl/2.7.4-1/${MK_WIN32_ARCH}/lib/ssl.lib")
endif()
LIST(APPEND CMAKE_REQUIRED_LIBRARIES "${CMAKE_BINARY_DIR}/.mkbuild/download/MK_DIST/windows/libressl/2.7.4-1/${MK_WIN32_ARCH}/lib/ssl.lib")
Expand All @@ -256,21 +259,21 @@ else()
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -L/usr/local/opt/openssl@1.1/lib")
endif()
endif()
CHECK_INCLUDE_FILE_CXX("openssl/rsa.h" MK_HAVE_HEADER_11075)
if(NOT ("${MK_HAVE_HEADER_11075}"))
CHECK_INCLUDE_FILE_CXX("openssl/rsa.h" MK_HAVE_HEADER_11207)
if(NOT ("${MK_HAVE_HEADER_11207}"))
message(FATAL_ERROR "cannot find: openssl/rsa.h")
endif()
CHECK_LIBRARY_EXISTS("crypto" "RSA_new" "" MK_HAVE_LIB_11240)
if(NOT ("${MK_HAVE_LIB_11240}"))
CHECK_LIBRARY_EXISTS("crypto" "RSA_new" "" MK_HAVE_LIB_11372)
if(NOT ("${MK_HAVE_LIB_11372}"))
message(FATAL_ERROR "cannot find: crypto")
endif()
LIST(APPEND CMAKE_REQUIRED_LIBRARIES "crypto")
CHECK_INCLUDE_FILE_CXX("openssl/ssl.h" MK_HAVE_HEADER_11445)
if(NOT ("${MK_HAVE_HEADER_11445}"))
CHECK_INCLUDE_FILE_CXX("openssl/ssl.h" MK_HAVE_HEADER_11577)
if(NOT ("${MK_HAVE_HEADER_11577}"))
message(FATAL_ERROR "cannot find: openssl/ssl.h")
endif()
CHECK_LIBRARY_EXISTS("ssl" "SSL_read" "" MK_HAVE_LIB_11610)
if(NOT ("${MK_HAVE_LIB_11610}"))
CHECK_LIBRARY_EXISTS("ssl" "SSL_read" "" MK_HAVE_LIB_11742)
if(NOT ("${MK_HAVE_LIB_11742}"))
message(FATAL_ERROR "cannot find: ssl")
endif()
LIST(APPEND CMAKE_REQUIRED_LIBRARIES "ssl")
Expand Down Expand Up @@ -351,20 +354,33 @@ include_directories(${CMAKE_REQUIRED_INCLUDES})

add_executable(
libndt-client
libndt-client.cpp
libndt-client.cpp api.hpp impl.hpp sys.hpp
)
target_link_libraries(
libndt-client
${CMAKE_REQUIRED_LIBRARIES}
)

#
# libndt-standalne-builds
#

add_executable(
libndt-standalne-builds
libndt-standalone-builds.cpp libndt.hpp
)
target_link_libraries(
libndt-standalne-builds
${CMAKE_REQUIRED_LIBRARIES}
)

#
# sys_test
#

add_executable(
sys_test
sys_test.cpp
sys_test.cpp api.hpp impl.hpp sys.hpp
)
target_link_libraries(
sys_test
Expand All @@ -377,7 +393,7 @@ target_link_libraries(

add_executable(
tests-curl
curlx_test.cpp
curlx_test.cpp api.hpp impl.hpp sys.hpp
)
target_link_libraries(
tests-curl
Expand All @@ -390,7 +406,7 @@ target_link_libraries(

add_executable(
tests-libndt
libndt_test.cpp
libndt_test.cpp api.hpp impl.hpp sys.hpp
)
target_link_libraries(
tests-libndt
Expand Down
11 changes: 7 additions & 4 deletions MKBuild.yaml
Expand Up @@ -5,6 +5,7 @@ docker_tc_disabled: true

amalgamate:
libndt.hpp:
- preamble.hpp
- sys.hpp
- api.hpp
- impl.hpp
Expand Down Expand Up @@ -32,13 +33,15 @@ dependencies:
targets:
executables:
libndt-client:
compile: [libndt-client.cpp]
compile: [libndt-client.cpp api.hpp impl.hpp sys.hpp]
libndt-standalne-builds:
compile: [libndt-standalone-builds.cpp libndt.hpp]
sys_test:
compile: [sys_test.cpp]
compile: [sys_test.cpp api.hpp impl.hpp sys.hpp]
tests-curl:
compile: [curlx_test.cpp]
compile: [curlx_test.cpp api.hpp impl.hpp sys.hpp]
tests-libndt:
compile: [libndt_test.cpp]
compile: [libndt_test.cpp api.hpp impl.hpp sys.hpp]

tests:
curl_unit_tests:
Expand Down
3 changes: 2 additions & 1 deletion curlx_test.cpp
Expand Up @@ -3,7 +3,8 @@
// and LICENSE for more information on the copying conditions.

#include "json.hpp"
#include "libndt.hpp"

#include "impl.hpp" // not standalone

#define CATCH_CONFIG_MAIN
#include "catch.hpp"
Expand Down
5 changes: 5 additions & 0 deletions impl.hpp
@@ -1,6 +1,11 @@
#ifndef MEASUREMENT_KIT_LIBNDT_IMPL_HPP
#define MEASUREMENT_KIT_LIBNDT_IMPL_HPP

#ifndef LIBNDT_STANDALONE
#include "sys.hpp"
#include "api.hpp"
#endif // !LIBNDT_STANDALONE

// Implementation section
// ``````````````````````
// This is a single header library. In some use cases you may want to split
Expand Down
3 changes: 2 additions & 1 deletion libndt-client.cpp
Expand Up @@ -3,7 +3,8 @@
// and LICENSE for more information on the copying conditions.

#include "json.hpp"
#include "libndt.hpp"

#include "impl.hpp" // not standalone

#include <stdlib.h>

Expand Down
12 changes: 12 additions & 0 deletions libndt-standalone-builds.cpp
@@ -0,0 +1,12 @@
// The purpose of this file is to make sure the standalone
// header is building. We're now using the individual headers
// elsewhere, and specifically "impl.hpp", such that it's
// significantly simpler to do development.
#include "json.hpp"
#include "libndt.hpp"
int main() {
measurement_kit::libndt::Client client{
measurement_kit::libndt::Settings{}
};
client.run();
}
3 changes: 2 additions & 1 deletion libndt_test.cpp
Expand Up @@ -3,7 +3,8 @@
// and LICENSE for more information on the copying conditions.

#include "json.hpp"
#include "libndt.hpp"

#include "impl.hpp" // not standalone

#ifndef _WIN32
#include <arpa/inet.h>
Expand Down
3 changes: 3 additions & 0 deletions preamble.hpp
@@ -0,0 +1,3 @@
#ifndef LIBNDT_STANDALONE
#define LIBNDT_STANDALONE 1
#endif

0 comments on commit b756443

Please sign in to comment.