From e279a23f779568f940f0ce90a6d3a2fc2b445dc1 Mon Sep 17 00:00:00 2001 From: David Benepe Date: Wed, 5 Aug 2020 08:19:20 -0500 Subject: [PATCH] Updated repo setup to no longer need setup.sh --- .gitignore | 3 ++ Makefile | 82 +++++++++++++++++++++++++++++++++++++++++++++--------- README.md | 40 ++++++++------------------ setup.sh | 70 ---------------------------------------------- 4 files changed, 84 insertions(+), 111 deletions(-) delete mode 100755 setup.sh diff --git a/.gitignore b/.gitignore index 627faee0..4f4351de 100755 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,6 @@ dkr.ld # Misc stuff that should be ignored. .*/ + +# Ignore .deb packages +*.deb diff --git a/Makefile b/Makefile index 0b6fe67b..37f91e54 100755 --- a/Makefile +++ b/Makefile @@ -4,15 +4,79 @@ SHELL := /bin/bash -######################### Setup Check ######################## +############################ Setup ########################### -ifeq ($(wildcard ./assets/.*),) - $(error Error, /assets/ folder was not found. Did you run the ./setup.sh script?) +# Don't do setup checks if cleaning. +ifneq ($(MAKECMDGOALS),clean) +ifneq ($(MAKECMDGOALS),clean_lib) +ifneq ($(MAKECMDGOALS),clean_src) + +########## QEMU_IRIX ########### + +ifndef QEMU_IRIX + QEMU_IRIX := $(shell which qemu-irix 2>/dev/null) + ifndef QEMU_IRIX + # Use /etc/os-release to get the distro's ID_LIKE string + DISTRO_TYPE := $(shell grep ^ID_LIKE= /etc/os-release | cut -c9-) + # If the current distro is Ubuntu/Debian, then automatically download & install qemu-irix + ifneq ($(filter $(DISTRO_TYPE),debian),) + QEMU_IRIX_REPO = https://github.com/n64decomp/qemu-irix + QEMU_IRIX_RELEASE = $(QEMU_IRIX_REPO)/releases/download/v2.11-deb + QEMU_IRIX_FILENAME = qemu-irix-2.11.0-2169-g32ab296eef_amd64.deb + QEMU_IRIX_URL = $(QEMU_IRIX_RELEASE)/$(QEMU_IRIX_FILENAME) + # Download qemu-irix using wget + DUMMY != wget --no-check-certificate --content-disposition $(QEMU_IRIX_URL) >&2 || echo FAIL + ifeq ($(DUMMY),FAIL) + $(error Failed to get QEMU_IRIX) + else + # Install qemu-irix using dpkg + DUMMY != sudo dpkg -i $(QEMU_IRIX_FILENAME) >&2 || echo FAIL + ifeq ($(DUMMY),FAIL) + $(error Failed to install QEMU_IRIX) + else + # Removed the downloaded .deb package, since it is no longer needed. + DUMMY != rm -f $(QEMU_IRIX_FILENAME) >&2 || echo FAIL + ifeq ($(DUMMY),FAIL) + $(warning Failed to remove $(QEMU_IRIX_FILENAME)) + endif + $(info QEMU_IRIX has been installed sucessfully!) + QEMU_IRIX := $(shell which qemu-irix 2>/dev/null) + endif + endif + else + $(error Please install qemu-irix package or set QEMU_IRIX env var to the full qemu-irix binary path) + endif + endif endif -#################### Generate linker file #################### +########## Make tools ########## -GENERATE_LD := $(shell ./generate_ld.sh) +DUMMY != make -s -C tools >&2 || echo FAIL +ifeq ($(DUMMY),FAIL) + $(error Failed to build tools) +endif + +######## Extract Assets ######## + +ifeq ($(wildcard ./assets/.*),) + DUMMY != ./extract.sh >&2 || echo FAIL + ifeq ($(DUMMY),FAIL) + $(error Failed to extract assets) + endif +endif + +##### Generate linker file ##### + +DUMMY != ./generate_ld.sh >&2 || echo FAIL +ifeq ($(DUMMY),FAIL) + $(error Failed to generate the linker file) +endif + +################################ + +endif +endif +endif ################ Target Executable and Sources ############### @@ -32,14 +96,6 @@ else CROSS := mips64-elf- endif -# check that either QEMU_IRIX is set or qemu-irix package installed -ifndef QEMU_IRIX - QEMU_IRIX := $(shell which qemu-irix 2>/dev/null) - ifeq (, $(QEMU_IRIX)) - $(error Please install qemu-irix package or set QEMU_IRIX env var to the full qemu-irix binary path) - endif -endif - AS = $(CROSS)as CC := $(QEMU_IRIX) -silent -L $(IRIX_ROOT) $(IRIX_ROOT)/usr/bin/cc CPP := cpp -P -Wno-trigraphs diff --git a/README.md b/README.md index a4c83db4..21b9bd2a 100755 --- a/README.md +++ b/README.md @@ -16,30 +16,16 @@ Currently, only the US 1.0 version of the game is supported. US 1.1, EU 1.0, EU ### Debian / Ubuntu -`sudo apt install build-essential pkg-config git binutils-mips-linux-gnu python3 libssl-dev` +`sudo apt install build-essential pkg-config git binutils-mips-linux-gnu python3 libssl-dev wget` -#### qemu-irix - -Download qemu-irix `.deb` package here: https://github.com/n64decomp/qemu-irix/releases - -Then install it by running `sudo dpkg -i qemu-irix-2.11.0-2169-g32ab296eef_amd64.deb` - -## Setup +## Setup / Building 1. Place the ROM file within the `baseroms` directory. **a.** Any DKR ROM should work as long as it is US 1.0. **b.** The name of the ROM file does not matter. It will be detected automatically from an md5 checksum. **c.** If you use a byte-swapped or little-endian ROM, then it will automatically be converted to a big-endian (.z64) ROM file. -2. Run `./setup.sh` in the main directory. - **a.** All of the tools within `/tools/` will be built. - **b.** Assets from the original DKR rom will be extracted into the generated `/assets/` folder. - **c.** Lastly, the linker file `dkr.ld` will be generated - -If you see the message `Setup complete!`, then you are ready to build. - -## Build - -To build the ROM, you just simply type in `make` in the main directory. You should see an `OK` at the end of the build if it worked correctly. The generated ROM file should appear in the `/build/` folder. - +2. Run `make` in the main directory. + **a.** Use the `-jN` argument to use `N` number of threads to speed up building. For example, if you have a system with 4 cores / 4 threads, you should do `make -j4`. + ## Assets See the [ASSETS_README.md](ASSETS_README.md) file for more information on the assets within this decompilation. @@ -50,18 +36,11 @@ There are some useful scripts that should be kept in mind when working on this r --- -#### `./generate_ld.sh` - -This script will generate the linker file `dkr.ld`, which is used for building. You will need to call this when you add or remove files from the `/asm/` or `/src/` directories. - ---- - #### `./extract.sh` This script will extract all the assets from the DKR ROM and place them into `/assets/` folder according to the extract-config file within the `/extract-ver/` folder. You will need to run this every time you update one of the `.extract-config` files. -Note 1: You do not need to call `./generate_ld.sh`, since that is done automatically from this script. -Note 2: The `/assets/` folder will get deleted if it already exists, so don't put anything important in there! +Note: The `/assets/` folder will get deleted if it already exists, so don't put anything important in there! --- @@ -73,6 +52,12 @@ Example: `./rename_sym.sh D_A4001000 SP_IMEM` --- +#### `./score.sh` + +Prints out the current completion percentage of the decomp. You do need to have an `OK` build for this to work properly. + +--- + #### `./get_symbol.sh ` Will return the symbol associated with the RAM address within `undefined_syms.txt`. The RAM address must be in base 16. The `0x` prefix is not required. @@ -94,7 +79,6 @@ TODO: Add more things to the TODO list. What should be focused on. * Decompiling the asm files into matching c files. -* Split the asm files into smaller ones. This has been partially done, but nowhere near complete. ### Minor diff --git a/setup.sh b/setup.sh deleted file mode 100755 index e6f6d95c..00000000 --- a/setup.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/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/" -if [ -d "$ASSETS_DIR" ]; then - echo "Decomp is already setup, delete the /assets/ folder if you wish to continue" - exit 1 -fi - -# Check if gcc is installed -# TODO: Automatically install gcc -if ! command -v gcc > /dev/null; then - echo 'gcc is not installed!' - exit 2 -fi - -# Check if make is installed -# TODO: Automatically install make -if ! command -v make > /dev/null; then - echo 'make is not installed!' - exit 3 -fi - -# Check if python3 is installed -# TODO: Automatically install python3 -if ! command -v python3 > /dev/null; then - echo 'python3 is not installed!' - exit 4 -fi - -# Check if binutils is installed -# TODO: Automatically install binutils -if ! command -v mips-linux-gnu-ld > /dev/null; then - if ! command -v mips64-linux-gnu-ld > /dev/null; then - if ! command -v mips64-elf-ld > /dev/null; then - echo 'binutils is not installed!' - echo 'Arch users should install: `mips64-elf-binutils`' - echo 'Ubuntu/Debian should install: `binutils-mips-linux-gnu`' - echo 'RHEL/CentOS/Fedora should install: `gcc-mips64-linux-gnu`' - exit 5 - fi - fi -fi - -# build all the tools in the /tools/ directory -echo 'Building tools...' -cd tools -make -echo 'Tools built!' -cd .. - -# Extract assets into the /assets/ directory -if ./extract.sh; then - 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 '---------------------------------------' -fi