Skip to content

Commit

Permalink
Fix Windows build
Browse files Browse the repository at this point in the history
  • Loading branch information
sjanel committed Feb 27, 2024
1 parent f1a90a2 commit d6a0e57
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 53 deletions.
14 changes: 0 additions & 14 deletions .dockerignore

This file was deleted.

3 changes: 2 additions & 1 deletion .github/workflows/ubuntu-clang-tidy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ jobs:

- name: Install dependencies
run: |
sudo apt update && sudo apt install libcurl4-gnutls-dev ninja-build
sudo apt update
sudo apt install libcurl4-gnutls-dev ninja-build
- name: Install clang (with clang-tidy)
run: |
Expand Down
16 changes: 12 additions & 4 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,32 @@ jobs:
buildmode: [Debug, Release]
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Install dependencies
uses: crazy-max/ghaction-chocolatey@v1
uses: crazy-max/ghaction-chocolatey@v3
with:
args: install curl openssl
args: install openssl curl -y --no-progress

- name: Add cURL directory in the path
run: |
$curlPath = Get-ChildItem -Path C:\ProgramData\chocolatey\lib\curl\tools\curl* -Name
echo "C:\ProgramData\chocolatey\lib\curl\tools\${curlPath}\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
echo "C:\ProgramData\chocolatey\lib\curl\tools\${curlPath}\lib" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
dir "C:\ProgramData\chocolatey\lib\curl\tools\${curlPath}\include"
$Env:CURL_LIBRARY = "C:\ProgramData\chocolatey\lib\curl\tools\${curlPath}\bin\libcurl-x64.dll"
$Env:CURL_INCLUDE_DIR = "C:\ProgramData\chocolatey\lib\curl\tools\${curlPath}\include"
- name: Create Build Environment
run: cmake -E make_directory ${{github.workspace}}/build

- name: Configure CMake
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=${{matrix.buildmode}}
run: |
echo "CURL_LIBRARY = $CURL_LIBRARY"
echo "CURL_INCLUDE_DIR = $CURL_INCLUDE_DIR"
cmake -S . -B build -DCMAKE_BUILD_TYPE=${{matrix.buildmode}} -DCURL_LIBRARY="C:\ProgramData\chocolatey\lib\curl\tools\curl-8.6.0_1-win64-mingw\bin\libcurl-x64.dll" -DCURL_INCLUDE_DIR="C:\ProgramData\chocolatey\lib\curl\tools\curl-8.6.0_1-win64-mingw\bin\libcurl-x64.dll"
- name: Build
working-directory: ${{github.workspace}}/build
Expand Down
30 changes: 18 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ set(CMAKE_CXX_STANDARD 20)
include(FetchContent)

find_package(amc CONFIG)

if(amc_FOUND)
set(LINK_AMC FALSE)
else()
Expand Down Expand Up @@ -83,7 +82,7 @@ if(CCT_ENABLE_TESTS)
enable_testing()
endif()

# nlohmann_json - coincenter json library
# nlohmann_json - json library
find_package(nlohmann_json CONFIG)
if(NOT nlohmann_json_FOUND)
FetchContent_Declare(
Expand All @@ -95,18 +94,13 @@ if(NOT nlohmann_json_FOUND)
FetchContent_MakeAvailable(nlohmann_json)
endif()

# spdlog - coincenter logging library
find_package(spdlog CONFIG)
if(NOT spdlog_FOUND)
FetchContent_Declare(
spdlog
GIT_REPOSITORY https://github.com/gabime/spdlog.git
GIT_TAG v1.13.0
)
# openssl for requests
find_package(OpenSSL REQUIRED)

FetchContent_MakeAvailable(spdlog)
endif()
# curl - request library
include(FindCURL)

# prometheus for monitoring support
if(CCT_BUILD_PROMETHEUS_FROM_SRC)
# Disable Prometheus testing
set(ENABLE_TESTING OFF)
Expand Down Expand Up @@ -135,6 +129,18 @@ else()
endif()
endif()

# spdlog - logging library
find_package(spdlog CONFIG)
if(NOT spdlog_FOUND)
FetchContent_Declare(
spdlog
GIT_REPOSITORY https://github.com/gabime/spdlog.git
GIT_TAG v1.13.0
)

FetchContent_MakeAvailable(spdlog)
endif()

# Unit Tests

#[[ Create an executable
Expand Down
20 changes: 13 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,22 @@ FROM ubuntu:22.04 AS build
# Install base & build dependencies, needed certificates for curl to work with https
RUN apt update && \
apt upgrade -y && \
apt install build-essential curl libcurl4-gnutls-dev libssl-dev cmake git ca-certificates gzip -y && \
curl -L -o /usr/local/bin/ninja.gz https://github.com/ninja-build/ninja/releases/latest/download/ninja-linux.zip && \
gunzip /usr/local/bin/ninja.gz && \
chmod a+x /usr/local/bin/ninja
apt install build-essential ninja-build libcurl4-gnutls-dev libssl-dev cmake git ca-certificates gzip -y --no-install-recommends

# Copy source files
WORKDIR /app/src
COPY src .

# Set default directory for application
WORKDIR /app
COPY CMakeLists.txt *.md ./

# Copy only the test secrets
WORKDIR /app/data/secret
COPY data/secret/secret_test.json .

# Copy all files, excluding the ones in '.dockerignore'
COPY . .
# Copy mandatory static configuration files
WORKDIR /app/data/static
COPY data/static/currency_prefix_translator.json data/static/currencyacronymtranslator.json data/static/stablecoins.json data/static/withdrawfees.json ./

# Create and go to 'bin' directory
WORKDIR /app/bin
Expand Down
17 changes: 13 additions & 4 deletions alpine.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,22 @@
FROM alpine:3.19.1 AS build

# Install base & build dependencies, needed certificates for curl to work with https
RUN apk add --update --upgrade --no-cache g++ libc-dev curl-dev cmake ninja git ca-certificates
RUN apk add --update --upgrade --no-cache g++ libc-dev openssl-dev curl-dev cmake ninja git ca-certificates

# Copy source files
WORKDIR /app/src
COPY src .

# Set default directory for application
WORKDIR /app
COPY CMakeLists.txt *.md ./

# Copy only the test secrets
WORKDIR /app/data/secret
COPY data/secret/secret_test.json .

# Copy all files, excluding the ones in '.dockerignore'
COPY . .
# Copy mandatory static configuration files
WORKDIR /app/data/static
COPY data/static/currency_prefix_translator.json data/static/currencyacronymtranslator.json data/static/stablecoins.json data/static/withdrawfees.json ./

# Create and go to 'bin' directory
WORKDIR /app/bin
Expand Down
21 changes: 13 additions & 8 deletions src/engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,19 @@ add_unit_test(
coincenter_engine
)

add_unit_test(
commandlineoptionsparser_test
test/commandlineoptionsparser_test.cpp
DEFINITIONS
CCT_DISABLE_SPDLOG
LIBRARIES
coincenter_tech
)
# As of MSVC 19.38.33135.0, it fails to compile commandlineoptionsparser_test:
# commandlineoptionsparser_test.cpp(333,79): fatal error C1001: Internal compiler error

if(NOT MSVC)
add_unit_test(
commandlineoptionsparser_test
test/commandlineoptionsparser_test.cpp
DEFINITIONS
CCT_DISABLE_SPDLOG
LIBRARIES
coincenter_tech
)
endif()

add_unit_test(
exchangesorchestrator_private_test
Expand Down
3 changes: 0 additions & 3 deletions src/http-request/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ if (MSVC)
add_compile_definitions(CURL_STATICLIB)
endif()

include(FindCURL)

target_link_libraries(coincenter_http-request PRIVATE CURL::libcurl)
target_include_directories(coincenter_http-request PUBLIC include)

Expand All @@ -30,7 +28,6 @@ add_unit_test(
coincenter_http-request
)


add_unit_test(
permanentcurloptions_test
test/permanentcurloptions_test.cpp
Expand Down

0 comments on commit d6a0e57

Please sign in to comment.