Skip to content

Commit

Permalink
Build workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Xtansia committed Apr 23, 2024
1 parent 49e04b9 commit cb0b35d
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
Checks: 'clang-diagnostic-*,clang-analyzer-*,cert-*,cppcoreguidelines-*,modernize-*,performance-*,readability-*'
WarningsAsErrors: ''
FormatStyle: file

42 changes: 42 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Build

on: [pull_request, push]

jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu
cc: gcc
cxx: g++

- os: ubuntu
cc: clang
cxx: clang++

- os: macos

- os: windows

runs-on: ${{matrix.os}}-latest

steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Configure CC & CXX
if: matrix.cc != '' && matrix.cxx != ''
run: echo "CC=${{matrix.cc}}" >> $GITHUB_ENV && echo "CXX=${{matrix.cxx}}" >> $GITHUB_ENV

- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=ON

- name: Build
run: cmake --build ${{github.workspace}}/build --config Release

- name: Run clang-tidy
if: matrix.os == 'ubuntu' && matrix.cc == 'clang'
run: clang-tidy --warnings-as-errors="*" -p ${{github.workspace}}/build src/**/*.*
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ build/
build-debug/
build-release/
build-relwithdebinfo/
cmake-build-*/

.idea/
12 changes: 6 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
cmake_minimum_required(VERSION 3.2)
cmake_minimum_required(VERSION 3.5)
project(bin2s)

if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra -Wpedantic -Werror")
set(CMAKE_CXX_FLAGS_DEBUG "-g")
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra -Wpedantic")
set(CMAKE_CXX_FLAGS_DEBUG "-g")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-g -O2 -DNDEBUG")

if (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
if (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
set(CMAKE_EXECUTABLE_LINKER_FLAGS "${CMAKE_EXECUTABLE_LINKER_FLAGS} -stdlib=libc++")
endif()
Expand All @@ -16,7 +16,7 @@ if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.7")
endif()
elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /WX /MP")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /MP")
set(CMAKE_CXX_FLAGS_DEBUG "/ZI")
set(CMAKE_CXX_FLAGS_RELEASE "/O2 /DNDEBUG")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/O2 /Zi /DNDEBUG")
Expand Down
2 changes: 1 addition & 1 deletion src/bin2s.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ result bin2s(const std::string &identifier, std::istream &input,

auto cur_pos = input.tellg();
input.seekg(0, std::ios::end);
auto size = input.tellg() - cur_pos;
std::streamsize size = input.tellg() - cur_pos;
input.seekg(cur_pos);

if (size == 0) return result::empty_stream;
Expand Down

0 comments on commit cb0b35d

Please sign in to comment.