Skip to content

Commit

Permalink
Windows and Linux build workflows first pass (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
samkusin authored Nov 4, 2022
1 parent e92fd25 commit 5a9e0c6
Show file tree
Hide file tree
Showing 8 changed files with 117 additions and 8 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/build-linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: CMake

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release

jobs:
build:
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
# You can convert this to a matrix build if you need cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Prerequisites
# Needed for X11 extensions and audio builds
run: sudo apt-get install -y libxi-dev libxcursor-dev libasound2-dev mesa-common-dev

- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}

- name: Build
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}

# - name: Test
# working-directory: ${{github.workspace}}/build
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
# run: ctest -C ${{env.BUILD_TYPE}}
51 changes: 51 additions & 0 deletions .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: CMake

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release

jobs:
build:
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
# You can convert this to a matrix build if you need cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
runs-on: windows-latest

steps:
- uses: actions/checkout@v3

- name: Add msbuild to PATH
uses: microsoft/[email protected]

#- name: Prerequisites
# # Needed for X11 extensions and audio builds
# run: sudo apt-get install -y libxi-dev libxcursor-dev libasound2-dev mesa-common-dev

- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake -B ${{github.workspace}}/build -G "Visual Studio 17 2022" -A x64 -DBUILD_TESTING=OFF

- name: Build
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}

# - name: Archive production artifacts
# uses: actions/upload-artifact@v3
# with:
# name: dist
# path: ${{github.workspace}}/build-run/clemens_iigs/Release/*
# retention-days: 1


# - name: Test
# working-directory: ${{github.workspace}}/build
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
# run: ctest -C ${{env.BUILD_TYPE}}
6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ function(project_create_assets_target ARG_TARGET_NAME)
add_dependencies(app_assets_${ARG_TARGET_NAME} ${ARG_TARGET_NAME})
endfunction()

enable_testing()

set(PROJECT_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}-run")

set(EMULATOR_SOURCES
Expand Down Expand Up @@ -86,7 +84,11 @@ target_link_libraries(clemens_65816_render PUBLIC clemens_65816)
target_include_directories(clemens_65816_render
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)

if(BUILD_TESTING)
enable_testing()
add_subdirectory(tests)
endif()


add_executable(clemens_65816_emulator
"${CMAKE_CURRENT_SOURCE_DIR}/app.c")
Expand Down
2 changes: 1 addition & 1 deletion emulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ static void _opcode_print(ClemensMachine *clem,
snprintf(operand, sizeof(operand), "$%02X%04X", inst->bank, inst->value);
break;
case kClemensCPUAddrMode_PCLongIndirect:
snprintf(operand, sizeof(operand), "[$%04X]", inst->bank, inst->value);
snprintf(operand, sizeof(operand), "[$%04X]", inst->value);
break;
case kClemensCPUAddrMode_Operand:
snprintf(operand, sizeof(operand), "%02X", inst->value);
Expand Down
4 changes: 2 additions & 2 deletions host/clem_backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,15 @@ struct ClemensRunSampler {
// acutal_clocks = sampledClocksSpent
// (reference / actual) * 1.023mhz is the emulator speed
if (clocksBuffer.isFull()) {
decltype(clocksBuffer)::ValueType lruClocksSpent;
decltype(clocksBuffer)::ValueType lruClocksSpent = 0;
clocksBuffer.pop(lruClocksSpent);
sampledClocksSpent -= lruClocksSpent;
}
clocksBuffer.push(clocksSpent);
sampledClocksSpent += clocksSpent;

if (cyclesBuffer.isFull()) {
decltype(cyclesBuffer)::ValueType lruCycles;
decltype(cyclesBuffer)::ValueType lruCycles = 0;
cyclesBuffer.pop(lruCycles);
sampledCyclesSpent -= lruCycles;
}
Expand Down
1 change: 1 addition & 0 deletions host/clem_disk_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <algorithm>
#include <array>
#include <cstring>
#include <filesystem>
#include <fstream>

Expand Down
12 changes: 9 additions & 3 deletions host/clem_front.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1240,7 +1240,9 @@ static void doMachineDebugIORegister(uint8_t* ioregsold, uint8_t* ioregs, uint8_
bool changed = ioregsold[reg] != ioregs[reg];
bool tooltip = false;
ImGui::TableNextColumn();
ImGui::TextColored(changed ? getModifiedColor(true) : getDefaultColor(true), desc.readLabel);
ImGui::PushStyleColor(ImGuiCol_Text, (ImU32)(changed ? getModifiedColor(true) : getDefaultColor(true)));
ImGui::TextUnformatted(desc.readLabel);
ImGui::PopStyleColor();
tooltip = tooltip || ImGui::IsItemHovered();
ImGui::TableNextColumn();
ImGui::TextColored(changed ? getModifiedColor(true) : getDefaultColor(true),
Expand Down Expand Up @@ -2061,7 +2063,9 @@ void ClemensFrontend::doImportDiskSet(int width, int height) {
auto contentRegionAvail = ImGui::GetContentRegionAvail();
ImGui::Spacing();
ImGui::Spacing();
ImGui::TextWrapped(messageModalString_.c_str());
ImGui::PushTextWrapPos(0.0f);
ImGui::TextUnformatted(messageModalString_.c_str());
ImGui::PopTextWrapPos();
ImGui::Spacing();
ImGui::Spacing();
ImGui::SetCursorPos(ImVec2(
Expand All @@ -2082,7 +2086,9 @@ void ClemensFrontend::doImportDiskSet(int width, int height) {
auto contentRegionAvail = ImGui::GetContentRegionAvail();
ImGui::Spacing();
ImGui::Spacing();
ImGui::TextWrapped(messageModalString_.c_str());
ImGui::PushTextWrapPos(0.0f);
ImGui::TextUnformatted(messageModalString_.c_str());
ImGui::PopTextWrapPos();
ImGui::Spacing();
ImGui::SetCursorPos(ImVec2(
cursorPos.x, cursorPos.y + contentRegionAvail.y -
Expand Down
9 changes: 9 additions & 0 deletions tests/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
#include <stdio.h>
#include <string.h>

#if defined(__GNUC__)
// removes a lot of unused STB Truetype functions
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-result"
#endif


int clem_test_init_machine(
ClemensMachine* machine,
Expand Down Expand Up @@ -119,3 +125,6 @@ void test_check_mega2_bank(
&machine->mega2_bank_map[bank & 1][adr]);
}
}
#if defined(__GNUC__)
#pragma GCC diagnostic pop
#endif

0 comments on commit 5a9e0c6

Please sign in to comment.