Clean up skeletool CMake integration, and use consistent naming

Renamed all instances of skelatool -> skeletool. This is more consistent
than the mixed usage previously, which consequently makes adding the
external project in CMake easier.
This commit is contained in:
Matt Penny 2024-10-21 23:29:43 -04:00
parent b04e404b0b
commit 1a10e45682
160 changed files with 108 additions and 93 deletions

View File

@ -2,7 +2,4 @@ build
portal_pak_dir
portal_pak_modified
vpk
skelatool64/build
skelatool64/cimg
skelatool64/yaml-cpp
skelatool64/skeletool64
skeletool64/build

4
.gitignore vendored
View File

@ -5,8 +5,6 @@
*.z64
*.blend1
lua-5.4.4/
build/
debugger
gfxvalidator
@ -21,8 +19,6 @@ resource/closecaption_*
tools/skeletool64*
tools/vtf2png*
skelatool64/*.zip*
src/controls/controller-data.h

View File

@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.28)
project(portal64 C ASM)
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
include(AddExternalProjectExecutable)
# TODO: remove when makefile is no longer in use
add_compile_definitions(CMAKE)
@ -21,23 +22,7 @@ find_program(VPK_EXECUTABLE vpk REQUIRED)
find_program(VTF2PNG_EXECUTABLE vtf2png REQUIRED)
# Add skeletool as external project to isolate from toolchain
set(SKELETOOL_BUILD_DIR "${CMAKE_BINARY_DIR}/skeletool64")
ExternalProject_Add(skeletool64
SOURCE_DIR
"${PROJECT_SOURCE_DIR}/skelatool64"
PREFIX
"${CMAKE_BINARY_DIR}/skeletool64"
CMAKE_ARGS
"-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>"
BUILD_BYPRODUCTS
"<INSTALL_DIR>/bin/skeletool64"
BUILD_ALWAYS TRUE
)
add_executable(skeletool64::skeletool64 IMPORTED)
set_target_properties(skeletool64::skeletool64 PROPERTIES
IMPORTED_LOCATION "${SKELETOOL_BUILD_DIR}/bin/skeletool64"
)
add_dependencies(skeletool64::skeletool64 skeletool64)
add_external_project_executable(skeletool64)
# Directories
set(ASM_DIR "${PROJECT_SOURCE_DIR}/asm")

View File

@ -8,13 +8,13 @@
# --------------------------------------------------------------------
include $(N64_ROOT)/usr/include/n64/make/PRdefs
SKELATOOL64:=skelatool64/build/skeletool64
SKELETOOL64:=skeletool64/build/skeletool64
VTF2PNG:=vtf2png
SFZ2N64:=sfz2n64
$(SKELATOOL64):
cmake -S skelatool64 -B skelatool64/build
cmake --build skelatool64/build
$(SKELETOOL64):
cmake -S skeletool64 -B skeletool64/build
cmake --build skeletool64/build
# Use tag name if the current commit is tagged, otherwise use commit hash
# If not in a git repo, fall back to exported version
@ -88,12 +88,12 @@ LDFLAGS = $(N64LIB) -lc -lgcc
default: english_audio
english_audio: build/src/audio/subtitles.h portal_pak_dir $(SKELATOOL64)
@$(MAKE) $(SKELATOOL64)
english_audio: build/src/audio/subtitles.h portal_pak_dir $(SKELETOOL64)
@$(MAKE) $(SKELETOOL64)
@$(MAKE) buildgame
all_languages: build/src/audio/subtitles.h portal_pak_dir german_audio french_audio russian_audio spanish_audio $(SKELATOOL64)
@$(MAKE) $(SKELATOOL64)
all_languages: build/src/audio/subtitles.h portal_pak_dir german_audio french_audio russian_audio spanish_audio $(SKELETOOL64)
@$(MAKE) $(SKELETOOL64)
@$(MAKE) buildgame
german_audio: vpk/portal_sound_vo_german_dir.vpk vpk/portal_sound_vo_german_000.vpk portal_pak_dir
@ -268,21 +268,21 @@ portal_pak_modified/images/valve.png portal_pak_modified/images/valve-no-logo.pn
## Materials
####################
build/assets/materials/static.h build/assets/materials/static_mat.c: assets/materials/static.skm.yaml $(TEXTURE_IMAGES) $(SKELATOOL64)
build/assets/materials/static.h build/assets/materials/static_mat.c: assets/materials/static.skm.yaml $(TEXTURE_IMAGES) $(SKELETOOL64)
@mkdir -p $(@D)
$(SKELATOOL64) --name static -m $< --material-output -o build/assets/materials/static.h
$(SKELETOOL64) --name static -m $< --material-output -o build/assets/materials/static.h
build/assets/materials/ui.h build/assets/materials/ui_mat.c: assets/materials/ui.skm.yaml $(TEXTURE_IMAGES) $(SKELATOOL64)
build/assets/materials/ui.h build/assets/materials/ui_mat.c: assets/materials/ui.skm.yaml $(TEXTURE_IMAGES) $(SKELETOOL64)
@mkdir -p $(@D)
$(SKELATOOL64) --name ui --default-material default_ui -m $< --material-output -o build/assets/materials/ui.h
$(SKELETOOL64) --name ui --default-material default_ui -m $< --material-output -o build/assets/materials/ui.h
build/assets/materials/images.h build/assets/materials/images_mat.c: assets/materials/images.skm.yaml $(TEXTURE_IMAGES) $(SKELATOOL64) portal_pak_modified/images/valve.png
build/assets/materials/images.h build/assets/materials/images_mat.c: assets/materials/images.skm.yaml $(TEXTURE_IMAGES) $(SKELETOOL64) portal_pak_modified/images/valve.png
@mkdir -p $(@D)
$(SKELATOOL64) --name images --default-material default_ui -m $< --material-output -o build/assets/materials/images.h
$(SKELETOOL64) --name images --default-material default_ui -m $< --material-output -o build/assets/materials/images.h
build/assets/materials/hud.h build/assets/materials/hud_mat.c: assets/materials/hud.skm.yaml $(TEXTURE_IMAGES) $(SKELATOOL64)
build/assets/materials/hud.h build/assets/materials/hud_mat.c: assets/materials/hud.skm.yaml $(TEXTURE_IMAGES) $(SKELETOOL64)
@mkdir -p $(@D)
$(SKELATOOL64) --name hud -m $< --material-output -o build/assets/materials/hud.h
$(SKELETOOL64) --name hud -m $< --material-output -o build/assets/materials/hud.h
src/levels/level_def_gen.h: build/assets/materials/static.h
@ -366,8 +366,8 @@ DYNAMIC_MODEL_OBJECTS = $(DYNAMIC_MODEL_LIST:%.blend=build/%_geo.o)
DYNAMIC_ANIMATED_MODEL_HEADERS = $(DYNAMIC_ANIMATED_MODEL_LIST:%.blend=build/%.h)
DYNAMIC_ANIMATED_MODEL_OBJECTS = $(DYNAMIC_ANIMATED_MODEL_LIST:%.blend=build/%_geo.o)
build/assets/models/%.h build/assets/models/%_geo.c build/assets/models/%_anim.c: build/assets/models/%.fbx assets/models/%.flags assets/materials/elevator.skm.yaml assets/materials/objects.skm.yaml assets/materials/static.skm.yaml $(TEXTURE_IMAGES) $(SKELATOOL64)
$(SKELATOOL64) --fixed-point-scale ${SCENE_SCALE} --model-scale 0.01 --name $(<:build/assets/models/%.fbx=%) $(shell cat $(<:build/assets/models/%.fbx=assets/models/%.flags)) -o $(<:%.fbx=%.h) $<
build/assets/models/%.h build/assets/models/%_geo.c build/assets/models/%_anim.c: build/assets/models/%.fbx assets/models/%.flags assets/materials/elevator.skm.yaml assets/materials/objects.skm.yaml assets/materials/static.skm.yaml $(TEXTURE_IMAGES) $(SKELETOOL64)
$(SKELETOOL64) --fixed-point-scale ${SCENE_SCALE} --model-scale 0.01 --name $(<:build/assets/models/%.fbx=%) $(shell cat $(<:build/assets/models/%.fbx=assets/models/%.flags)) -o $(<:%.fbx=%.h) $<
build/assets/models/player/chell.h: assets/materials/chell.skm.yaml
build/assets/models/props/combine_ball_catcher.h: assets/materials/ball_catcher.skm.yaml
@ -459,8 +459,8 @@ build/%.fbx: %.blend
@mkdir -p $(@D)
$(BLENDER_3_6) $< --background --python tools/models/export_fbx.py -- $@
build/assets/test_chambers/%.h build/assets/test_chambers/%_geo.c build/assets/test_chambers/%_anim.c: build/assets/test_chambers/%.fbx assets/test_chambers/%.yaml build/assets/materials/static.h build/src/audio/subtitles.h $(SKELATOOL64) $(TEXTURE_IMAGES) $(LUA_FILES)
$(SKELATOOL64) --script tools/level_scripts/export_level.lua --fixed-point-scale ${SCENE_SCALE} --model-scale 0.01 --name $(<:build/assets/test_chambers/%.fbx=%) -m assets/materials/static.skm.yaml -o $(<:%.fbx=%.h) $<
build/assets/test_chambers/%.h build/assets/test_chambers/%_geo.c build/assets/test_chambers/%_anim.c: build/assets/test_chambers/%.fbx assets/test_chambers/%.yaml build/assets/materials/static.h build/src/audio/subtitles.h $(SKELETOOL64) $(TEXTURE_IMAGES) $(LUA_FILES)
$(SKELETOOL64) --script tools/level_scripts/export_level.lua --fixed-point-scale ${SCENE_SCALE} --model-scale 0.01 --name $(<:build/assets/test_chambers/%.fbx=%) -m assets/materials/static.skm.yaml -o $(<:%.fbx=%.h) $<
build/assets/test_chambers/%.o: build/assets/test_chambers/%.c build/assets/materials/static.h
@mkdir -p $(@D)
@ -641,7 +641,7 @@ clean:
rm -rf portal_pak_dir
rm -rf portal_pak_modified
rm -rf assets/locales
cmake --build skelatool64/build --target clean
cmake --build skeletool64/build --target clean
clean-src:
rm -rf build/src

View File

@ -15,7 +15,7 @@ clean:
sudo rm -rf portal_pak_dir
sudo rm -rf portal_pak_modified
sudo rm -rf assets/locales
sudo $(MAKE) -C skelatool64 clean
sudo $(MAKE) -C skeletool64 clean
english_audio:
docker run --rm -v $$PWD:/usr/src/app -e PORTAL64_WITH_DEBUGGER -e PORTAL64_WITH_GFX_VALIDATOR -it portal64 make english_audio

View File

@ -0,0 +1,37 @@
#####################################
## Add external project executable ##
#####################################
include(ExternalProject)
include(GNUInstallDirs)
# Adds a local external project and creates an imported executable target
# Assumes the project's directory and executable have the same name
function(add_external_project_executable PROJECT_NAME)
set(RELATIVE_EXE_PATH "${CMAKE_INSTALL_BINDIR}/${PROJECT_NAME}${CMAKE_EXECUTABLE_SUFFIX}")
ExternalProject_Add(${PROJECT_NAME}
SOURCE_DIR
"${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}"
PREFIX
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}"
CMAKE_ARGS
"-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>"
BUILD_BYPRODUCTS
# Needed for Ninja so we can depend on the executable before it exists
"<INSTALL_DIR>/${RELATIVE_EXE_PATH}"
BUILD_ALWAYS
# Make sure it gets rebuilt when changes are made
TRUE
)
ExternalProject_Get_Property(${PROJECT_NAME} INSTALL_DIR)
set(EXE_TARGET_NAME ${PROJECT_NAME}::${PROJECT_NAME})
add_executable(${EXE_TARGET_NAME} IMPORTED)
add_dependencies(${EXE_TARGET_NAME} ${PROJECT_NAME})
set_target_properties(${EXE_TARGET_NAME} PROPERTIES
IMPORTED_LOCATION "${INSTALL_DIR}/${RELATIVE_EXE_PATH}"
)
endfunction()

View File

@ -44,7 +44,7 @@ pipx install vpk
### Skeletool Dependencies
Setup and install dependencies for `skelatool64`:
Setup and install dependencies for `skeletool64`:
```sh
sudo apt install cimg-dev libassimp-dev liblua5.4-0 liblua5.4-dev libpng-dev libtiff-dev libyaml-cpp-dev lua5.4

View File

@ -145,7 +145,7 @@ std::string generateMesh(const aiScene* scene, CFileDefinition& fileDefinition,
if (fileDefinition.GetBoneHierarchy().HasData()) {
dlResult->AddTypeHeader("\"sk64/skelatool_defs.h\"");
dlResult->AddTypeHeader("\"sk64/skeletool_defs.h\"");
}
fileDefinition.AddDefinition(std::move(dlResult));

View File

@ -284,7 +284,7 @@ AnimationResults generateAnimationForScene(const aiScene* scene, CFileDefinition
aiVector3D(0, 0, 0)
);
fileDefinition.AddHeader("\"sk64/skelatool_clip.h\"");
fileDefinition.AddHeader("\"sk64/skeletool_clip.h\"");
std::unique_ptr<StructureDataChunk> boneParentDataChunk(new StructureDataChunk());

View File

@ -173,7 +173,7 @@ MeshDefinitionResults MeshDefinitionGenerator::GenerateDefinitionsWithResults(co
std::unique_ptr<StructureDataChunk> armatureDef(new StructureDataChunk());
fileDefinition.AddHeader("\"sk64/skelatool_armature.h\"");
fileDefinition.AddHeader("\"sk64/skeletool_armature.h\"");
armatureDef->AddPrimitive(result.modelName);
armatureDef->AddPrimitive(animationResults.initialPoseReference);

Some files were not shown because too many files have changed in this diff Show More