mirror of https://git.sr.ht/~kikoodx/momento
CMakeLists.txt: add script and dependency to automate level listing
This commit is contained in:
parent
4b1b4abbea
commit
2c983c18bf
|
@ -1,6 +1,7 @@
|
|||
# Build files
|
||||
/build-cg
|
||||
/*.g3a
|
||||
/generated/
|
||||
|
||||
# Python bytecode
|
||||
__pycache__/
|
||||
|
|
|
@ -10,7 +10,19 @@ include(Fxconv)
|
|||
find_package(Gint 2.3 REQUIRED)
|
||||
find_package(LibImg 2.2 REQUIRED)
|
||||
|
||||
include_directories(include)
|
||||
add_custom_target(filepaths
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
DEPENDS generated/filepaths.h
|
||||
COMMENT "generated/filepaths.h target")
|
||||
|
||||
add_custom_command(OUTPUT "${CMAKE_CURRENT_LIST_DIR}/generated/filepaths.h"
|
||||
COMMENT "Generate genereated/filepaths.h."
|
||||
COMMAND mkdir -p generated &&
|
||||
./make_filepaths.sh > generated/filepaths.h
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
|
||||
DEPENDS make_filepaths.sh)
|
||||
|
||||
include_directories(include generated)
|
||||
|
||||
set(SOURCES
|
||||
src/main.c
|
||||
|
@ -37,6 +49,7 @@ set(FLAGS
|
|||
fxconv_declare_assets(${ASSETS} WITH_METADATA)
|
||||
|
||||
add_executable(${PROJECT_NAME} ${SOURCES} ${ASSETS})
|
||||
add_dependencies(${PROJECT_NAME} filepaths)
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE ${FLAGS})
|
||||
target_link_libraries(${PROJECT_NAME} Gint::Gint)
|
||||
target_link_libraries(${PROJECT_NAME} LibImg::LibImg)
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
#!/bin/sh
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
printf '/* SPDX-License-Identifier: GPL-3.0-or-later */\n'
|
||||
printf '#pragma once\n'
|
||||
printf '#include <stdint.h>\n\n'
|
||||
printf 'static const uint16_t filepaths[][64] = {\n'
|
||||
|
||||
cd assets/levels
|
||||
for PACK in *; do
|
||||
PACK_NAME="$(basename $PACK)"
|
||||
cd "$PACK"
|
||||
for LEVEL in *; do
|
||||
LEVEL_NAME="$(basename $LEVEL | cut -c2- |
|
||||
awk -F '.' '{print $1}')"
|
||||
[ -z "$LEVEL_NAMES" ] &&
|
||||
LEVEL_NAMES="
|
||||
\"$LEVEL_NAME\"" ||
|
||||
LEVEL_NAMES="$LEVEL_NAMES,
|
||||
\"$LEVEL_NAME\""
|
||||
printf 'u"\\\\\\\\fls0\\\\mtem\\\\%s\\\\' "$PACK_NAME"
|
||||
printf '%s",\n' "$LEVEL"
|
||||
done
|
||||
cd ..
|
||||
done
|
||||
printf '};\n'
|
||||
|
||||
printf 'static const char level_names[][32] = { %s\n};\n' "$LEVEL_NAMES"
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include "level.h"
|
||||
#include "tiles.h"
|
||||
#include "filepaths.h"
|
||||
#include <gint/bfile.h>
|
||||
#include <gint/std/stdlib.h>
|
||||
#include <stdint.h>
|
||||
|
@ -13,10 +14,6 @@
|
|||
fatal_error_msg = error_msg; \
|
||||
return; \
|
||||
}
|
||||
#define PATH_PREFIX u"\\\\fls0\\mtem\\"
|
||||
|
||||
static const uint16_t filepaths[][32] = {
|
||||
PATH_PREFIX "pillars.kble", PATH_PREFIX "human.kble", {0}};
|
||||
|
||||
/* globals are needed when using gint_switch() */
|
||||
struct Level level;
|
||||
|
|
Loading…
Reference in New Issue