From 65523fcb6eb7c5916560056f960c7aa2289035fa Mon Sep 17 00:00:00 2001 From: David Benepe Date: Sun, 28 Jun 2020 13:52:22 -0500 Subject: [PATCH] Added error messages for tools to make sure the user has properly run setup before make. --- Makefile | 8 +++++++- extract.sh | 8 ++++++-- setup.sh | 25 ++++++++++++++++--------- tools/dkr_extractor.cpp | 10 +++++++++- 4 files changed, 38 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index a70453a7..cd1c38b5 100755 --- a/Makefile +++ b/Makefile @@ -4,6 +4,12 @@ SHELL := /bin/bash +######################### Setup Check ######################## + +ifeq ($(wildcard ./assets/.*),) + $(error Error, /assets/ folder was not found. Did you run the ./setup.sh script?) +endif + ################ Target Executable and Sources ############### # BUILD_DIR is location where all build artifacts are placed @@ -166,7 +172,7 @@ all: $(BUILD_DIR)/$(TARGET).z64 clean: rm -r $(BUILD_DIR) - + $(BUILD_DIR): mkdir $(BUILD_DIR) $(addprefix $(BUILD_DIR)/,$(ASM_DIRS) $(SRC_DIRS) $(ASSETS_DIRS)) diff --git a/extract.sh b/extract.sh index 79ef789a..b291b1e8 100755 --- a/extract.sh +++ b/extract.sh @@ -1,5 +1,9 @@ echo 'Extracting Assets...' -./tools/dkr_extractor ./extract-ver ./baseroms . +if ! ./tools/dkr_extractor ./extract-ver ./baseroms .; then + exit 1 +fi # Generate the linker file (dkr.ld) -python3 ./tools/python/generate_ld.py \ No newline at end of file +python3 ./tools/python/generate_ld.py + +exit 0 \ No newline at end of file diff --git a/setup.sh b/setup.sh index 132cf8a4..e6f6d95c 100755 --- a/setup.sh +++ b/setup.sh @@ -1,5 +1,12 @@ #!/bin/bash +# Check if the baseroms directory exists. +BASEROMS_DIR="./baseroms/" +if [ ! -d "$BASEROMS_DIR" ]; then + echo "/baseroms/ directory was not found. Was it deleted?" + exit 1 +fi + # If the assets directory already exists, then the repo is already setup # TODO: add a `--force` option ASSETS_DIR="./assets/" @@ -51,13 +58,13 @@ echo 'Tools built!' cd .. # Extract assets into the /assets/ directory -./extract.sh +if ./extract.sh; then + echo 'Setup complete!' -echo 'Setup complete!' - -echo '---------------------------------------' -echo ' Hello there! ' -echo ' I am the genie of the decomp. ' -echo ' I am here to help you. ' -echo ' Good luck! ' -echo '---------------------------------------' + echo '---------------------------------------' + echo ' Hello there! ' + echo ' I am the genie of the decomp. ' + echo ' I am here to help you. ' + echo ' Good luck! ' + echo '---------------------------------------' +fi diff --git a/tools/dkr_extractor.cpp b/tools/dkr_extractor.cpp index 8843c301..1878fdc5 100755 --- a/tools/dkr_extractor.cpp +++ b/tools/dkr_extractor.cpp @@ -548,6 +548,8 @@ int main(int argc, char* argv[]) { } } + bool completedAnExtraction = false; + for(auto& config : configs) { if(config.is_supported()) { for(auto& rom : roms) { @@ -555,13 +557,19 @@ int main(int argc, char* argv[]) { std::cout << "Found ROM file for config \"" << config.get_name() << "\"" << std::endl; extract_assets_from_rom(config, rom); std::cout << "Finished extracting " << numberOfFilesExtracted << " files." << std::endl; + completedAnExtraction = true; break; } } } else { - std::cout << "This version of the game is currently not supported." << std::endl; + std::cout << "The config for \"" << config.get_name() << "\" is currently not supported." << std::endl; } } + if(!completedAnExtraction) { + std::cout << "No compatible ROMs were found within the /baseroms/ directory" << std::endl; + return 1; + } + return 0; }