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 29, 2024
1 parent f1a90a2 commit 68b5f7f
Show file tree
Hide file tree
Showing 22 changed files with 240 additions and 130 deletions.
14 changes: 0 additions & 14 deletions .dockerignore

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/clang-format-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
name: Formatting Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Run clang-format style check for C/C++ programs.
uses: jidicula/clang-format-action@v4.11.0
with:
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -53,7 +53,8 @@ jobs:

- name: Install dependencies
run: |
sudo apt update && sudo apt install libcurl4-gnutls-dev ninja-build ${{matrix.compiler}}
sudo apt update
sudo apt install libcurl4-gnutls-dev ninja-build ${{matrix.compiler}} --no-install-recommends
- name: Create Build Environment
run: cmake -E make_directory ${{github.workspace}}/build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:

steps:
- name: Checkout repository code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Docker build
working-directory: ${{github.workspace}}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: macos-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- uses: maxim-lobanov/setup-xcode@v1
with:
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/ubuntu-clang-tidy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ jobs:

steps:
- name: Checkout repository code
uses: actions/checkout@v2
uses: actions/checkout@v4

- 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
2 changes: 1 addition & 1 deletion .github/workflows/ubuntu-monitoring.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:

steps:
- name: Checkout repository code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Prerequisites
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:

steps:
- name: Checkout repository code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Install dependencies
run: |
Expand Down
57 changes: 57 additions & 0 deletions .github/workflows/windows-2019.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Windows

on:
push:
branches:
- main
pull_request:

jobs:
windows-2019:
name: Build on Windows 2019
runs-on: windows-2019
strategy:
matrix:
buildmode: [Debug]
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install openssl
uses: crazy-max/ghaction-chocolatey@v3
with:
args: install openssl --version 3.1.1 -y --no-progress

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

- name: Add dependencies in the path
run: |
$CURL_DIR_NAME = Get-ChildItem -Path C:\ProgramData\chocolatey\lib\curl\tools\curl* -Name
$CURL_PATH = "C:\ProgramData\chocolatey\lib\curl\tools\${CURL_DIR_NAME}"
echo "OPENSSL_ROOT_DIR=C:\Program Files\OpenSSL" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
echo "CURL_LIBRARY=${CURL_PATH}\lib\libcurl.dll.a" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
echo "CURL_INCLUDE_DIR=${CURL_PATH}\include" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Create Build Environment
run: cmake -E make_directory ${{github.workspace}}/build

- name: Configure CMake
run: |
cmake -A "x64" -DCURL_LIBRARY="$env:CURL_LIBRARY" -DCURL_INCLUDE_DIR="$env:CURL_INCLUDE_DIR" -DCMAKE_BUILD_TYPE=${{matrix.buildmode}} -S . -B build
- name: Build
working-directory: ${{github.workspace}}/build
run: cmake --build . --config ${{matrix.buildmode}} --parallel 2

- name: Local Tests
working-directory: ${{github.workspace}}/build
run: ctest -C ${{matrix.buildmode}} --output-on-failure --exclude-regex api_test

- name: Public API Tests # Tries several times to avoid random timeout errors not coming from coincenter
working-directory: ${{github.workspace}}/build
run: ctest -C ${{matrix.buildmode}} --output-on-failure --tests-regex api_test --repeat until-pass:10
57 changes: 57 additions & 0 deletions .github/workflows/windows-latest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Windows

on:
push:
branches:
- main
pull_request:

jobs:
windows-latest:
name: Build on Windows latest
runs-on: windows-latest
strategy:
matrix:
buildmode: [Debug]
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install openssl
uses: crazy-max/ghaction-chocolatey@v3
with:
args: install openssl --version 3.1.1 -y --no-progress

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

- name: Add dependencies in the path
run: |
$CURL_DIR_NAME = Get-ChildItem -Path C:\ProgramData\chocolatey\lib\curl\tools\curl* -Name
$CURL_PATH = "C:\ProgramData\chocolatey\lib\curl\tools\${CURL_DIR_NAME}"
echo "OPENSSL_ROOT_DIR=C:\Program Files\OpenSSL" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
echo "CURL_LIBRARY=${CURL_PATH}\lib\libcurl.dll.a" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
echo "CURL_INCLUDE_DIR=${CURL_PATH}\include" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Create Build Environment
run: cmake -E make_directory ${{github.workspace}}/build

- name: Configure CMake
run: |
cmake -A "x64" -DCURL_LIBRARY="$env:CURL_LIBRARY" -DCURL_INCLUDE_DIR="$env:CURL_INCLUDE_DIR" -DCMAKE_BUILD_TYPE=${{matrix.buildmode}} -S . -B build
- name: Build
working-directory: ${{github.workspace}}/build
run: cmake --build . --config ${{matrix.buildmode}} --parallel 2

- name: Local Tests
working-directory: ${{github.workspace}}/build
run: ctest -C ${{matrix.buildmode}} --output-on-failure --exclude-regex api_test

- name: Public API Tests # Tries several times to avoid random timeout errors not coming from coincenter
working-directory: ${{github.workspace}}/build
run: ctest -C ${{matrix.buildmode}} --output-on-failure --tests-regex api_test --repeat until-pass:10
47 changes: 0 additions & 47 deletions .github/workflows/windows.yml

This file was deleted.

42 changes: 27 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,21 @@ endif()

set(CMAKE_CXX_STANDARD 20)

# openssl for requests
find_package(OpenSSL REQUIRED)

# curl - request library
if (MSVC)
# I struggled to compile with dynamic linking on Windows, I had this issue:
# bin\libcurl-x64.dll : fatal error LNK1107: invalid or corrupt file: cannot read at 0x2C0
set(CURL_USE_STATIC_LIBS ON)
endif()
find_package(CURL REQUIRED)

# External dependencies (linked with FetchContent)
include(FetchContent)

find_package(amc CONFIG)

if(amc_FOUND)
set(LINK_AMC FALSE)
else()
Expand Down Expand Up @@ -83,7 +93,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 +105,7 @@ 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
)

FetchContent_MakeAvailable(spdlog)
endif()

# prometheus for monitoring support
if(CCT_BUILD_PROMETHEUS_FROM_SRC)
# Disable Prometheus testing
set(ENABLE_TESTING OFF)
Expand Down Expand Up @@ -135,6 +134,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 Expand Up @@ -217,10 +228,11 @@ function(add_unit_test name)
endfunction()

if(MSVC)
add_compile_options(/W4)
add_compile_options(/W3)

# https://stackoverflow.com/questions/5004858/why-is-stdmin-failing-when-windows-h-is-included
add_compile_definitions(NOMINMAX)
add_compile_definitions(_SILENCE_STDEXT_ARR_ITERS_DEPRECATION_WARNING)
else()
add_compile_options(-Wall -Wextra -pedantic)

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
Loading

0 comments on commit 68b5f7f

Please sign in to comment.