Finished cmake_morpheus_build_utils_docs

This commit is contained in:
Bobby Youstra 2021-07-25 12:34:02 -07:00
parent 8da6751871
commit b3afcfc2ae
No known key found for this signature in database
GPG Key ID: 46665F9BA88E45C5
10 changed files with 223 additions and 56 deletions

Binary file not shown.

View File

@ -90,7 +90,7 @@ def main() -> None:
else: else:
image_mode = "RGB" image_mode = "RGB"
if len(sys.argv) > 7: if len(sys.argv) > 9:
background_color = (int(sys.argv[7]), int(sys.argv[8]), int(sys.argv[9])) background_color = (int(sys.argv[7]), int(sys.argv[8]), int(sys.argv[9]))
else: else:
background_color = (0, 0, 0) background_color = (0, 0, 0)

View File

@ -36,7 +36,9 @@ def main():
os.makedirs(os.path.join(project_dir, "buildtools"), exist_ok=False) os.makedirs(os.path.join(project_dir, "buildtools"), exist_ok=False)
os.makedirs(os.path.join(project_dir, "cmake"), exist_ok=False) os.makedirs(os.path.join(project_dir, "cmake"), exist_ok=False)
os.makedirs(os.path.join(project_dir, "src"), exist_ok=False) os.makedirs(os.path.join(project_dir, "src"), exist_ok=False)
except OSError: except OSError as e:
raise e
print(f"Found existing Morpheus directory structure under {project_dir}!\n" print(f"Found existing Morpheus directory structure under {project_dir}!\n"
f"Not overwriting files and aborting...", file=sys.stderr) f"Not overwriting files and aborting...", file=sys.stderr)

View File

@ -8,7 +8,7 @@ include("cmake/morpheus_build_utils.cmake")
## Project-dependent variables ## Project-dependent variables
## --------------------------- ## ---------------------------
set(PROJECT_NAME "Project Template Name") set(PROJECT_NAME "TestProject")
set(MAIN_SRC_FILES src/main.cpp) set(MAIN_SRC_FILES src/main.cpp)
@ -39,16 +39,24 @@ set(NDS_SUBTITLE2 " ")
## Library setup-dependent variables ## Library setup-dependent variables
## --------------------------------- ## ---------------------------------
if(WIN32)
string(REPLACE "\\" "/" DEVKITPRO $ENV{DEVKITPRO})
string(REPLACE "\\" "/" DEVKITARM $ENV{DEVKITARM})
else()
set(DEVKITPRO $ENV{DEVKITPRO})
set(DEVKITARM $ENV{DEVKITARM})
endif()
set(MORPHEUS_DIR "") set(MORPHEUS_DIR "")
# ${CMAKE_CURRENT_BINARY_DIR} is included here for including generated files # ${CMAKE_CURRENT_BINARY_DIR} is included here for including generated files
set(COMMON_INCLUDE_DIRECTORIES ${MORPHEUS_DIR}/include ${CMAKE_CURRENT_BINARY_DIR}) set(COMMON_INCLUDE_DIRECTORIES ${MORPHEUS_DIR}/include ${CMAKE_CURRENT_BINARY_DIR})
set(GBA_INCLUDE_DIRECTORIES $ENV{DEVKITPRO}/libtonc/include $ENV{DEVKITPRO}/libgba/include) set(GBA_INCLUDE_DIRECTORIES ${DEVKITPRO}/libtonc/include ${DEVKITPRO}/libgba/include)
set(NDS_INCLUDE_DIRECTORIES $ENV{DEVKITPRO}/libnds/include) set(NDS_INCLUDE_DIRECTORIES ${DEVKITPRO}/libnds/include)
set(COMMON_LINK_DIRECTORIES ${MORPHEUS_DIR}/lib) set(COMMON_LINK_DIRECTORIES ${MORPHEUS_DIR}/lib)
set(GBA_LINK_DIRECTORIES $ENV{DEVKITPRO}/libtonc/lib $ENV{DEVKITPRO}/libgba/lib) set(GBA_LINK_DIRECTORIES ${DEVKITPRO}/libtonc/lib ${DEVKITPRO}/libgba/lib)
set(NDS_LINK_DIRECTORIES $ENV{DEVKITPRO}/libnds/lib) set(NDS_LINK_DIRECTORIES ${DEVKITPRO}/libnds/lib)
## ---------------------------- ## ----------------------------
## Cross-compiler configuration ## Cross-compiler configuration
@ -66,7 +74,7 @@ if(platform_lower STREQUAL "gba")
add_compile_definitions(_GBA) add_compile_definitions(_GBA)
if(NOT GBAFIX) if(NOT GBAFIX)
find_program(GBAFIX gbafix $ENV{DEVKITPRO}/tools/bin/) find_program(GBAFIX gbafix ${DEVKITPRO}/tools/bin/)
if(GBAFIX) if(GBAFIX)
message(STATUS "gbafix: ${GBAFIX} - found") message(STATUS "gbafix: ${GBAFIX} - found")
else() else()
@ -75,7 +83,7 @@ if(platform_lower STREQUAL "gba")
endif() endif()
if(NOT OBJCOPY) if(NOT OBJCOPY)
find_program(OBJCOPY arm-none-eabi-objcopy $ENV{DEVKITARM}/bin) find_program(OBJCOPY arm-none-eabi-objcopy ${DEVKITARM}/bin)
if(OBJCOPY) if(OBJCOPY)
message(STATUS "objcopy: ${OBJCOPY} - found") message(STATUS "objcopy: ${OBJCOPY} - found")
else() else()
@ -93,7 +101,7 @@ elseif(platform_lower STREQUAL "nds")
add_compile_definitions(_NDS) add_compile_definitions(_NDS)
if(NOT NDSTOOL) if(NOT NDSTOOL)
find_program(NDSTOOL ndstool $ENV{DEVKITPRO}/tools/bin) find_program(NDSTOOL ndstool ${DEVKITPRO}/tools/bin)
if(NDSTOOL) if(NDSTOOL)
message(STATUS "ndstool: ${NDSTOOL} - found") message(STATUS "ndstool: ${NDSTOOL} - found")
else() else()
@ -116,21 +124,23 @@ set(CMAKE_C_COMPILER_WORKS 1)
set(CMAKE_CXX_COMPILER_WORKS 1) set(CMAKE_CXX_COMPILER_WORKS 1)
if(WIN32) if(WIN32)
set(CMAKE_C_COMPILER "$ENV{DEVKITARM}/bin/arm-none-eabi-gcc.exe") message(STATUS "Running on Windows")
set(CMAKE_CXX_COMPILER "$ENV{DEVKITARM}/bin/arm-none-eabi-g++.exe")
set(CMAKE_LINKER "$ENV{DEVKITARM}/bin/arm-none-eabi-ld.exe") set(CMAKE_C_COMPILER "${DEVKITARM}/bin/arm-none-eabi-gcc.exe")
set(CMAKE_AR "$ENV{DEVKITARM}/bin/arm-none-eabi-gcc-ar.exe" CACHE STRING "") set(CMAKE_CXX_COMPILER "${DEVKITARM}/bin/arm-none-eabi-g++.exe")
set(CMAKE_AS "$ENV{DEVKITARM}/bin/arm-none-eabi-as.exe") set(CMAKE_LINKER "${DEVKITARM}/bin/arm-none-eabi-ld.exe")
set(CMAKE_NM "$ENV{DEVKITARM}/bin/arm-none-eabi-gcc-nm.exe" CACHE STRING "") set(CMAKE_AR "${DEVKITARM}/bin/arm-none-eabi-gcc-ar.exe")
set(CMAKE_RANLIB "$ENV{DEVKITARM}/bin/arm-none-eabi-gcc-ranlib.exe" CACHE STRING "") set(CMAKE_AS "${DEVKITARM}/bin/arm-none-eabi-as.exe")
set(CMAKE_NM "${DEVKITARM}/bin/arm-none-eabi-gcc-nm.exe")
set(CMAKE_RANLIB "${DEVKITARM}/bin/arm-none-eabi-gcc-ranlib.exe")
else() else()
set(CMAKE_C_COMPILER "$ENV{DEVKITARM}/bin/arm-none-eabi-gcc") set(CMAKE_C_COMPILER "${DEVKITARM}/bin/arm-none-eabi-gcc")
set(CMAKE_CXX_COMPILER "$ENV{DEVKITARM}/bin/arm-none-eabi-g++") set(CMAKE_CXX_COMPILER "${DEVKITARM}/bin/arm-none-eabi-g++")
set(CMAKE_LINKER "$ENV{DEVKITARM}/bin/arm-none-eabi-ld") set(CMAKE_LINKER "${DEVKITARM}/bin/arm-none-eabi-ld")
set(CMAKE_AR "$ENV{DEVKITARM}/bin/arm-none-eabi-gcc-ar" CACHE STRING "") set(CMAKE_AR "${DEVKITARM}/bin/arm-none-eabi-gcc-ar")
set(CMAKE_AS "$ENV{DEVKITARM}/bin/arm-none-eabi-as") set(CMAKE_AS "${DEVKITARM}/bin/arm-none-eabi-as")
set(CMAKE_NM "$ENV{DEVKITARM}/bin/arm-none-eabi-gcc-nm" CACHE STRING "") set(CMAKE_NM "${DEVKITARM}/bin/arm-none-eabi-gcc-nm")
set(CMAKE_RANLIB "$ENV{DEVKITARM}/bin/arm-none-eabi-gcc-ranlib" CACHE STRING "") set(CMAKE_RANLIB "${DEVKITARM}/bin/arm-none-eabi-gcc-ranlib")
endif() endif()
enable_language(ASM) enable_language(ASM)

View File

@ -152,28 +152,6 @@ function(execute_grit_tilemap png_file is_4bpp palette_bank_num is_affine)
VERBATIM) VERBATIM)
endfunction() endfunction()
# TODO(Bobby): Update this function to match the working function below this function (convert_tilemap_bin_png_file)
function(convert_tilemap_bin_files build_dir palette_bank_num bin_files target_name_var)
if(WIN32)
find_program(PYTHON3 python)
else()
find_program(PYTHON3 python3)
endif()
if(NOT PYTHON3)
message(FATAL_ERROR "python3 - not found")
endif()
foreach(bin_file IN ${${bin_files}})
add_custom_command(OUTPUT ${bin_file}.c
COMMAND ${PYTHON3} buildtools/bintileconvert/bintileconvert.py ${bin_file} ${build_dir}
${palette_bank_num}
VERBATIM)
endforeach()
execute_grit_tilemaps(palette_bank_num)
endfunction()
function(convert_tilemap_bin_image_file bin_file build_dir width height palette_bank_num image_file is_8bpp is_affine) function(convert_tilemap_bin_image_file bin_file build_dir width height palette_bank_num image_file is_8bpp is_affine)
if(WIN32) if(WIN32)
find_program(PYTHON3 python) find_program(PYTHON3 python)

View File

@ -21,3 +21,4 @@ Welcome to Morpheus's documentation!
:maxdepth: 1 :maxdepth: 1
classes/class_index.rst classes/class_index.rst
misc/cmake_morpheus_build_utils_docs.rst

View File

@ -0,0 +1,154 @@
============================
Morpheus buildtool reference
============================
Note: all of the Python 3 buildtools (or scripts) listed here are
labeled with their folder's name within the buildtools directory.
------------------
General buildtools
------------------
General buildtools are frequently used tools both in
compiling Morpheus and developing Morpheus games. They are included
within the release/dev packages found on itch and can also be
accessed through the GitHub or GitLab code repositories.
^^^^^^^^^^^^^^
bintileconvert
^^^^^^^^^^^^^^
Bintileconvert is used for converting regular non-streaming
backgrounds raw .bin binary tile map files
(specifically tested with `Tilemap Studio <https://github.com/Rangi42/tilemap-studio>`_)
to .c and .h files usable with Morpheus. You can use this buildtool by calling CMake
Morpheus utils function convert_tilemap_bin_image_file().
Buildtool arguments:
* *tilemap_studio_bin_file_path*: The file path to the tilemap .bin file to convert
* *build_dir*: The current build directory to place the generate .c and .h files in
* *width*: The width of the tilemap (in 8X8 TILES, NOT PIXELS) (32 or 64)
* *height*: The height of the tilemap (in 8X8 TILES, NOT PIXELS) (32 or 64)
Optional buildtool arguments:
* *palette_bank*: The [0-16] palette bank number to use for the entire tilemap
* *image_file*: The image file of the tilemap file's tiles to be converted using grit
* *image_bpp*: The 4, 8, or 1 bpp of the image file. This argument becomes required if image_file is passed in.
* *is_affine*: Whether this tilemap should be affine or not.
^^^^^^^^^^^^
bintilesplit
^^^^^^^^^^^^
Bintilesplit is used for converting one large 128x128, 256x256, or 512x512 background
into several smaller 64x64 backgrounds usable with StreamingBackgroundBase,
with a tilemap using the same raw binary tilemap format as in bintileconvert uses. You can
use this buildtool by calling CMake Morpheus utils function generate_streaming_background().
Buildtool arguments:
* *single_bin_file_path*: The large raw .bin binary background tilemap file
* *asset_dir*: The directory to produce the split 64x64 bin files used
* *width*: The width of the entire background (in 8X8 TILES, NOT PIXELS) (128, 256, or 512)
* *height*: The height of the entire background (in 8X8 TILES, NOT PIXELS) (128, 256, or 512)
Optional buildtool arguments:
* *palette_bank*: The [0-16] palette bank number to use for the entire tilemap
* *image_file*: The image file of the tilemap file's tiles to be converted using grit
* *image_bpp*: The 4, 8, or 1 bpp of the image file. This argument becomes required if image_file is passed in.
* *build_dir*: The current build directory to place the generate .c and .h files in
^^^^^^^^^^^^^
gba_fat_patch
^^^^^^^^^^^^^
Gba_fat_patch is used for applying a one-line header file patch to libgba's bundled
libfat library to prevent conflicts with libtonc while still being able to use libfat. If you
use the project template's CMakeLists.txt file, the patch will be handled automatically upon
the first build (though it might require superuser priviledges if running on Linux/macOS). If
you are making your own custom CMakeLists.txt file, use this buildtool by calling
libgba_fat_patch() and adding the libgba_fat_patch_target target as a dependency to your project
by using CMake's add_dependencies().
No arguments for this buildtool.
^^^^^^^^^^^^^^
generate_fonts
^^^^^^^^^^^^^^
Generate_fonts is used for converting a .ttf file and a .txt file containing a list of characters
into a font image which is then converted to .c and .h files by grit usable with Morpheus's
Expression text API. You can use this buildtool by calling the CMake Morpheus utils function
generate_font().
Buildtool arguments:
* *ttf_font_file*: The path to .ttf font file containing the appropriate glyphs
* *font_character_list_file*: The path or filename under buildtools/generate_fonts/character_lists/ for the list of characters seperated by spaces to be included
* *font_bpp*: The 1, 4, or 8 bpp of the font image to generate
* *destination_file*: The path and filename of the font image's .c and .h files being generated
* *make_1d*: Whether to make the font image use 1d or 2d mapping (currently only 2d mapping is supported by
the expression API)
* *use_utf8*: Whether this font is a UTF8 font containing non-ASCII/non-english characters(True) or a pure ASCII font (False)
Optional buildtool arguments:
* *background_color_r*: The red color component of the generated font image's background color
* *background_color_g*: The green color component of the generated font image's background color (required if background_color_r is given)
* *background_color_b*: The blue color component of the generated font image's background color (required if background_color_g is given)
* *font_size*: The font size of the characters generated within the font image, defaults to 16
^^^^^^^^^^^^^^^^^
project_generator
^^^^^^^^^^^^^^^^^
Project_generator is used for generating a project based on a default project template to get
started, with all appropriate buildtools copied over as well as a starter CMakeLists.txt preset
and an example "Hello World" project.
Buildtool arguments:
* *morpheus_dir_path*: The path to the root Morpheus release/dev/source package directory
* *new_project_name*: The name of the new project to be created
Optional buildtool arguments:
* *new_project_dir_path*: The path to the directory where the new project's directory should be created.
-------------------
Internal buildtools
-------------------
Internal buildtools are frequently used tools in compiling Morpheus,
but don't serve much purpose when developing Morpheus games. Thus,
they are **NOT** included within the release/dev package found on
itch and can only be accessed through the GitHub or GitLab
code repositories.
^^^^^^^^^^^^^^^^^^^^
generate_breathe_rst
^^^^^^^^^^^^^^^^^^^^
Generates `Breathe <https://github.com/michaeljones/breathe>`_-style
RestructedText files for the doxygen-documented Morpheus C++ classes,
used in the Documentation target for generation of C++ documentation.
Buildtool arguments:
* *header_path*: The path to the root directory of the headers to be documented
* *root_namespace*: The name of the root namespace of the headers to be documented (morpheus)
* *breathe_path*: The path to the directory where the breathe documentation will be generated in
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
generate_cd_release (Shell script)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
A shell script that is part of this project's GitLab continuous deployment pipeline,
deploying a release/dev package to itch.io.
No arguments for this buildtool.

View File

@ -6,9 +6,32 @@ cmake_minimum_required(VERSION 3.16)
include(cmake/morpheus_build_utils.cmake) include(cmake/morpheus_build_utils.cmake)
string(TOLOWER "$ENV{PLATFORM}" platform_lower) string(TOLOWER "$ENV{PLATFORM}" platform_lower)
set(BASE_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../../morpheus set(BASE_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../../include
${CMAKE_CURRENT_SOURCE_DIR}/../../assets) ${CMAKE_CURRENT_SOURCE_DIR}/../../assets)
#set( CMAKE_VERBOSE_MAKEFILE on )
set(CMAKE_C_COMPILER_WORKS 1)
set(CMAKE_CXX_COMPILER_WORKS 1)
if(WIN32)
set(CMAKE_C_COMPILER "$ENV{DEVKITARM}/bin/arm-none-eabi-gcc.exe")
set(CMAKE_CXX_COMPILER "$ENV{DEVKITARM}/bin/arm-none-eabi-g++.exe")
set(CMAKE_LINKER "$ENV{DEVKITARM}/bin/arm-none-eabi-ld.exe")
set(CMAKE_AR "$ENV{DEVKITARM}/bin/arm-none-eabi-gcc-ar.exe" CACHE STRING "")
set(CMAKE_AS "$ENV{DEVKITARM}/bin/arm-none-eabi-as.exe")
set(CMAKE_NM "$ENV{DEVKITARM}/bin/arm-none-eabi-gcc-nm.exe" CACHE STRING "")
set(CMAKE_RANLIB "$ENV{DEVKITARM}/bin/arm-none-eabi-gcc-ranlib.exe" CACHE STRING "")
else()
set(CMAKE_C_COMPILER "$ENV{DEVKITARM}/bin/arm-none-eabi-gcc")
set(CMAKE_CXX_COMPILER "$ENV{DEVKITARM}/bin/arm-none-eabi-g++")
set(CMAKE_LINKER "$ENV{DEVKITARM}/bin/arm-none-eabi-ld")
set(CMAKE_AR "$ENV{DEVKITARM}/bin/arm-none-eabi-gcc-ar" CACHE STRING "")
set(CMAKE_AS "$ENV{DEVKITARM}/bin/arm-none-eabi-as")
set(CMAKE_NM "$ENV{DEVKITARM}/bin/arm-none-eabi-gcc-nm" CACHE STRING "")
set(CMAKE_RANLIB "$ENV{DEVKITARM}/bin/arm-none-eabi-gcc-ranlib" CACHE STRING "")
endif()
if(WIN32) if(WIN32)
set(CMAKE_AS "$ENV{DEVKITARM}/bin/arm-none-eabi-as.exe") set(CMAKE_AS "$ENV{DEVKITARM}/bin/arm-none-eabi-as.exe")
else() else()
@ -54,7 +77,6 @@ set(CMAKE_CXX_FLAGS "-g -Wall -Werror -O2 ${ARCH_FLAGS} -ffast-math -fno-strict-
project(puzzler) project(puzzler)
set(MAXMOD_SOUNDBANK_LIST "${CMAKE_CURRENT_SOURCE_DIR}/assets/sfx/gemcompleted.wav" set(MAXMOD_SOUNDBANK_LIST "${CMAKE_CURRENT_SOURCE_DIR}/assets/sfx/gemcompleted.wav"
"${CMAKE_CURRENT_SOURCE_DIR}/assets/sfx/gemplaced.wav" "${CMAKE_CURRENT_SOURCE_DIR}/assets/sfx/gemplaced.wav"
"${CMAKE_CURRENT_SOURCE_DIR}/assets/music/main_theme3.xm" "${CMAKE_CURRENT_SOURCE_DIR}/assets/music/main_theme3.xm"
@ -144,7 +166,7 @@ if(platform_lower STREQUAL "gba")
generate_maxmod_soundbank(true ${MAXMOD_SOUNDBANK_NAME} MAXMOD_SOUNDBANK_LIST) generate_maxmod_soundbank(true ${MAXMOD_SOUNDBANK_NAME} MAXMOD_SOUNDBANK_LIST)
link_directories(puzzler PRIVATE ../../cmake-build-debug-gba $ENV{DEVKITPRO}/libtonc/lib $ENV{DEVKITPRO}/libgba/lib) link_directories(puzzler PRIVATE ../../lib $ENV{DEVKITPRO}/libtonc/lib $ENV{DEVKITPRO}/libgba/lib)
add_executable(puzzler.elf ${SOURCE_FILES}) add_executable(puzzler.elf ${SOURCE_FILES})
add_gba_executable(puzzler.elf) add_gba_executable(puzzler.elf)
@ -170,7 +192,7 @@ elseif(platform_lower STREQUAL "nds")
endif() endif()
endif() endif()
link_directories(puzzler PRIVATE ../../cmake-build-debug-nds $ENV{DEVKITPRO}/libnds/lib) link_directories(puzzler PRIVATE ../../lib $ENV{DEVKITPRO}/libnds/lib)
convert_tilemap_bin_image_file("assets/backgrounds/subscorescreen.bin" ${CMAKE_CURRENT_BINARY_DIR} 32 32 0 convert_tilemap_bin_image_file("assets/backgrounds/subscorescreen.bin" ${CMAKE_CURRENT_BINARY_DIR} 32 32 0
"assets/backgrounds/subscorescreen.png" false "") "assets/backgrounds/subscorescreen.png" false "")

View File

@ -5,7 +5,7 @@
#ifndef PUZZLER_SCENE_HPP #ifndef PUZZLER_SCENE_HPP
#define PUZZLER_SCENE_HPP #define PUZZLER_SCENE_HPP
#include <core/control_reciever.hpp> #include <morpheus/core/control_reciever.hpp>
namespace puzzler { namespace puzzler {
class Scene : public morpheus::core::ControlReciever { class Scene : public morpheus::core::ControlReciever {

View File

@ -11,11 +11,11 @@ puzzler::SceneManager::SceneManager(morpheus::core::MainLoop *main_loop) {
m_main_loop->add_control_reciever(m_current_scene); m_main_loop->add_control_reciever(m_current_scene);
nocashMessage("setting up"); //nocashMessage("setting up");
m_current_scene->setup(); m_current_scene->setup();
nocashMessage("set up!"); //nocashMessage("set up!");
} }
void puzzler::SceneManager::update(unsigned char cycle_time) { void puzzler::SceneManager::update(unsigned char cycle_time) {