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 b6ee123
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 10 deletions.
13 changes: 10 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ jobs:

steps:
- uses: actions/checkout@v3
with:
lfs: 'true'

- 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,15 +21,20 @@ 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
container:
image: ghcr.io/toltec-dev/base:v2.3

steps:
- uses: actions/checkout@v2
- name: Install Deps
run: apt-get update && apt-get install -y git

- uses: actions/checkout@v3
with:
lfs: 'true'

- name: Configure CMake
run: cmake --preset release-toltec
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 b6ee123

Please sign in to comment.