Skip to content

Commit

Permalink
Fix xxd in github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
timower committed Oct 15, 2023
1 parent e10fad5 commit 394ff34
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- uses: actions/checkout@v3

- name: Install Deps
run: sudo apt-get install -y ninja-build libsdl2-dev
run: sudo apt-get install -y ninja-build libsdl2-dev xxd

- name: Configure CMake
run: cmake --preset dev-host
Expand All @@ -19,7 +19,7 @@ jobs:
run: cmake --build build/host

- name: Test
run: ctest --test-dir build/host
run: ctest --test-dir build/host --output-on-failure

build:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion libs/rMlib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ endif()
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_17)

if (EMULATE)
target_link_libraries(${PROJECT_NAME} PRIVATE NotoFont)
target_link_libraries(${PROJECT_NAME} PRIVATE NotoFont::font)

find_package(SDL2 REQUIRED)
if (TARGET SDL2::SDL2)
Expand Down
7 changes: 5 additions & 2 deletions libs/rMlib/Canvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,13 @@ getFont() {
}
const auto* data = fontBuffer.data();
#else
const auto* data = noto_sans_mono_font;
const auto* data = NotoSansMono_Regular_ttf;
#endif

stbtt_InitFont(&font, data, 0);
if (!stbtt_InitFont(&font, data, 0)) {
std::cerr << "Error initializing font!\n";
std::exit(EXIT_FAILURE);
}

#ifndef EMULATE
fclose(fp); // NOLINT
Expand Down
15 changes: 11 additions & 4 deletions vendor/noto/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
find_program(XXD xxd REQUIRED)
find_program(XXD xxd)

if ("${XXD}" STREQUAL "XXD-NOTFOUND")
message(WARNING "XXD not found, skipping font include")
return()
endif()

set(BUILD_INCLUDE_DIR "${CMAKE_BINARY_DIR}/include")
set(FONT_HEADER "${BUILD_INCLUDE_DIR}/noto-sans-mono.h")
add_custom_command(
OUTPUT "${FONT_HEADER}"
COMMAND "${CMAKE_COMMAND}" -E make_directory "${BUILD_INCLUDE_DIR}"
COMMAND
${XXD} -n "noto_sans_mono_font"
-i "${CMAKE_CURRENT_SOURCE_DIR}/NotoSansMono-Regular.ttf"
"${FONT_HEADER}")
${XXD} -i "NotoSansMono-Regular.ttf"
"${FONT_HEADER}"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")

add_library(NotoFont INTERFACE "${FONT_HEADER}")
target_include_directories(NotoFont INTERFACE "${BUILD_INCLUDE_DIR}")

add_library(NotoFont::font ALIAS NotoFont)

0 comments on commit 394ff34

Please sign in to comment.