diff --git a/.github/workflows/cmake.yaml b/.github/workflows/cmake.yaml index 4223b0e..ff1af42 100644 --- a/.github/workflows/cmake.yaml +++ b/.github/workflows/cmake.yaml @@ -2,50 +2,52 @@ name: CMake on: push: - branches: [ "master" ] + branches: ["master", "conan2"] pull_request: - branches: [ "master" ] - -env: - BUILD_TYPE: Release + branches: ["master"] jobs: build: - runs-on: ${{matrix.os}} + runs-on: ${{ matrix.os }} strategy: matrix: - os: [ ubuntu-latest, windows-latest, macos-latest ] + os: [ubuntu-latest, windows-latest] + build_type: [Release, Debug] steps: - - uses: actions/checkout@v3 - - - name: Setup ccache - uses: Chocobo1/setup-ccache-action@v1 - with: - windows_compile_environment: msvc + - uses: actions/checkout@v4 - - name: Cache CMake build directory - uses: actions/cache@v3 - env: - cache-name: cache-cmake-build - with: - path: ${{github.workspace}}/build - key: ${{matrix.os}}-${{env.BUILD_TYPE}}-build2 + - name: Get conan + uses: turtlebrowser/get-conan@v1.0 - - name: Configure CMake (Windows) - # Builind with shared libs fails on Windows ATM - if: runner.os == 'Windows' - run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_SHARED_LIBS=OFF + - name: Get conan home + id: conan-home + run: echo "CONAN_HOME=$(conan config home)" >> $GITHUB_OUTPUT - - name: Configure CMake - if: runner.os != 'Windows' - run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} + - name: Cache conan packages + uses: actions/cache@v4 + with: + path: ${{ steps.conan-home.outputs.CONAN_HOME/p}} + key: ${{ matrix.os }}-${{ matrix.build_type }}-packages + + - name: Create default profile + run: conan profile detect --force + + - name: Install dependencies + run: | + conan install . \ + --settings build_type=${{ matrix.build_type }} \ + --build=missing \ + --conf tools.system.package_manager:mode=install \ + --conf tools.system.package_manager:sudo=True + if: ${{ matrix.os == 'ubuntu-latest' }} + + - name: Install dependencies + run: | + conan install . \ + --settings build_type=${{ matrix.build_type }} \ + --build=missing + if: ${{ matrix.os == 'windows-latest' }} - name: Build - # According to this link, github runners should have at least two CPUs - # https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources - run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --parallel 2 - - - name: Test - working-directory: ${{github.workspace}}/build - run: ctest -C ${{env.BUILD_TYPE}} + run: conan build . diff --git a/CMakeLists.txt b/CMakeLists.txt index 0cfd02c..0296cc0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,10 @@ find_package(doctest REQUIRED) find_package(cxxopts REQUIRED) find_package(yaml-cpp REQUIRED) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) + include(cmake/compiler_flags.cmake) include(cmake/copy_dll.cmake) enable_testing() # needed to create the target lib/test diff --git a/chip-8-disassembler/disas.cpp b/chip-8-disassembler/disas.cpp index 2405f24..38fcd88 100644 --- a/chip-8-disassembler/disas.cpp +++ b/chip-8-disassembler/disas.cpp @@ -22,7 +22,7 @@ int main(int argc, char** argv) for (std::size_t i = 0; i < program.size() && i + 1 < program.size(); i += 2) { uint16_t raw_opcode = program[i] << 8 | program[i + 1]; - opcode decoded_opcode = opcode::decode(raw_opcode); + Opcode decoded_opcode = Opcode::decode(raw_opcode); std::cout << fmt::format("{:#06x} {}\n", addr, decoded_opcode.string_repr()); addr += 2; } diff --git a/chip-8-sdl/app.cpp b/chip-8-sdl/app.cpp index 6d83aba..840db2d 100644 --- a/chip-8-sdl/app.cpp +++ b/chip-8-sdl/app.cpp @@ -15,13 +15,13 @@ static constexpr int font_point_size = 12; static constexpr int SCALE_FACTOR = 10; -static constexpr int PANEL_WIDTH = chip8::SCREEN_WIDTH * SCALE_FACTOR; -static constexpr int PANEL_HEIGHT = (chip8::SCREEN_HEIGHT / 8) * SCALE_FACTOR; -static constexpr int RENDERER_WIDTH = chip8::SCREEN_WIDTH * SCALE_FACTOR; -static constexpr int RENDERER_HEIGHT = chip8::SCREEN_HEIGHT * SCALE_FACTOR + PANEL_HEIGHT; +static constexpr int PANEL_WIDTH = Chip8::SCREEN_WIDTH * SCALE_FACTOR; +static constexpr int PANEL_HEIGHT = (Chip8::SCREEN_HEIGHT / 8) * SCALE_FACTOR; +static constexpr int RENDERER_WIDTH = Chip8::SCREEN_WIDTH * SCALE_FACTOR; +static constexpr int RENDERER_HEIGHT = Chip8::SCREEN_HEIGHT * SCALE_FACTOR + PANEL_HEIGHT; static constexpr int CHIP8SCREEN_Y = PANEL_HEIGHT; -app::app(config& conf, std::string const& rom_path, std::vector const& program) +App::App(Config& conf, std::string const& rom_path, std::vector const& program) : m_emulator(program), m_rom_path(rom_path), m_conf(conf), @@ -71,17 +71,17 @@ app::app(config& conf, std::string const& rom_path, std::vector const& sdl_nullcheck(m_font.get(), fmt::format("Failed to open font file: {}", font_strpath).c_str()); } - panel_ptr p1 = std::make_unique(m_renderer, 0, 0, PANEL_WIDTH, PANEL_HEIGHT, m_conf.fg_color, m_conf.bg_color, Layout::Horizontal); - p1->add_child(std::make_unique