diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mock/CMakeLists.txt | 35 | ||||
-rw-r--r-- | src/mock/libcurl.c | 4 | ||||
-rw-r--r-- | src/mock/wine/CMakeLists.txt | 1 |
3 files changed, 26 insertions, 14 deletions
diff --git a/src/mock/CMakeLists.txt b/src/mock/CMakeLists.txt index 80f2eac..1b23c63 100644 --- a/src/mock/CMakeLists.txt +++ b/src/mock/CMakeLists.txt @@ -1,18 +1,23 @@ -add_subdirectory(wine) - +list(APPEND + MOCK_SOURCES + ${CMAKE_CURRENT_SOURCE_DIR}/libcurl.c +) -set(WINE_JSON_INFILE "${CMAKE_CURRENT_SOURCE_DIR}/runners/wine.json") -set(WINE_JSON_OUTFILE "${CMAKE_CURRENT_BINARY_DIR}/wine_json") +if (ENABLE_WINE) +add_subdirectory(wine) +include_directories(${WINE_MOCK_ARCHIVE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) +set(WINE_MOCK_JSON_INFILE "${CMAKE_CURRENT_SOURCE_DIR}/runners/wine.json") +set(WINE_MOCK_JSON_OUTFILE "${CMAKE_CURRENT_BINARY_DIR}/wine_json") add_custom_command( - OUTPUT ${WINE_JSON_OUTFILE}.c ${WINE_JSON_OUTFILE}.h + OUTPUT ${WINE_MOCK_JSON_OUTFILE}.c ${WINE_MOCK_JSON_OUTFILE}.h COMMAND ${CMAKE_COMMAND} - "-Dbin_in=${WINE_JSON_INFILE}" + "-Dbin_in=${WINE_MOCK_JSON_INFILE}" -P ${CMAKE_SOURCE_DIR}/cmake/FileEmbed.cmake ) -add_custom_target(wine_json ALL DEPENDS ${WINE_JSON_OUTFILE}.c ${WINE_JSON_OUTFILE}.h) +add_custom_target(wine_mock_json ALL DEPENDS ${WINE_MOCK_JSON_OUTFILE}.c ${WINE_MOCK_JSON_OUTFILE}.h) set(WINE_MOCK ${WINE_MOCK_ARCHIVE_OUT}.c @@ -21,18 +26,22 @@ set(WINE_MOCK file(TOUCH ${WINE_MOCK}) -SET(MOCK_SOURCES - ${CMAKE_CURRENT_SOURCE_DIR}/libcurl.c +list(APPEND + MOCK_SOURCES ${WINE_MOCK} - ${WINE_JSON_OUTFILE}.c - ${WINE_JSON_OUTFILE}.h + ${WINE_MOCK_JSON_OUTFILE}.c + ${WINE_MOCK_JSON_OUTFILE}.h ) +endif() + add_library(mock STATIC ${MOCK_SOURCES}) target_compile_options(mock PUBLIC ${CFLAGS}) target_include_directories(mock PUBLIC ${LIBCURL_INCLUDE_DIRS}) -add_dependencies(mock wine_mock_archive wine_json) -target_include_directories(mock PRIVATE ${WINE_MOCK_ARCHIVE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) + +if (ENABLE_WINE) +add_dependencies(mock wine_mock_archive wine_mock_json) +endif() set(NAME ${CMAKE_PROJECT_NAME}_mock) add_executable(${NAME} ${SOURCES}) diff --git a/src/mock/libcurl.c b/src/mock/libcurl.c index 359b15c..308e5e1 100644 --- a/src/mock/libcurl.c +++ b/src/mock/libcurl.c @@ -5,8 +5,10 @@ #include "../defines.h" +#ifdef WINE_ENABLED #include "wine_mock_tar_xz.h" #include "wine_json.h" +#endif typedef size_t (*callback_t)(const void*, size_t, size_t, void*); typedef int (*xfercallback_t)(void*, curl_off_t, curl_off_t, curl_off_t, curl_off_t); @@ -89,6 +91,7 @@ CURLcode curl_easy_perform(UNUSED CURL *easy_handle) size_t output_size = 0; debug_printf("[MOCK] %s(...)\n", __func__); +#ifdef WINE_ENABLED if (!strcmp(url, WINE_API)) { output = wine_json; @@ -99,6 +102,7 @@ CURLcode curl_easy_perform(UNUSED CURL *easy_handle) output = wine_mock_tar_xz; output_size = wine_mock_tar_xz_size; } +#endif if (output && data && callbackfunc) { diff --git a/src/mock/wine/CMakeLists.txt b/src/mock/wine/CMakeLists.txt index 3418089..dab4d77 100644 --- a/src/mock/wine/CMakeLists.txt +++ b/src/mock/wine/CMakeLists.txt @@ -12,7 +12,6 @@ add_executable(wine_mock ${WINE_SOURCES}) set_target_properties(wine_mock PROPERTIES OUTPUT_NAME "wine") target_compile_options(wine_mock PUBLIC ${CFLAGS}) - set(WINE_MOCK_ARCHIVE_FILE_NAME "wine-mock.tar.xz") set(WINE_MOCK_ARCHIVE_FILE "${WINE_MOCK_ARCHIVE_DIR}/${WINE_MOCK_ARCHIVE_FILE_NAME}") string(REGEX REPLACE "\\.| |-" "_" WINE_MOCK_ARCHIVE_FILE_NAME ${WINE_MOCK_ARCHIVE_FILE_NAME}) |