You've already forked hackerlibultra
mirror of
https://github.com/HackerN64/hackerlibultra.git
synced 2026-01-21 10:37:53 -08:00
Add support for multiple versions, match current archives under 2.0K (#52)
* Initial pass at multi-version support, matched 2.0K * Fixed CI and made it build K, changed default version back to L * Fixed VERSION_DEFINE not being used after rebase * Update checkbox matrix for 2.0K * Update readme instructions, fix ido CI * Fix NON_MATCHING and document it in the readme * Change default version to L, fix clean removing all builds, made distclean remove all builds, allow running clean and distclean without setup * Made build and extracted paths match the base path format, remove unnecessary file compilation flag setting
This commit is contained in:
4
.github/workflows/ci_gcc.yml
vendored
4
.github/workflows/ci_gcc.yml
vendored
@@ -13,7 +13,7 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
version: [L] # [H, I, I_patch, J, K, L]
|
||||
version: [K, L] # [H, I, I_patch, J, K, L]
|
||||
suffix: [~, _d, _rom]
|
||||
|
||||
steps:
|
||||
@@ -32,7 +32,7 @@ jobs:
|
||||
token: ${{ secrets.SECRETTOKEN }}
|
||||
path: deps_repo
|
||||
- name: Get the dependency
|
||||
run: cp deps_repo/libultra/${{ matrix.version }}/* .
|
||||
run: cp deps_repo/libultra/${{ matrix.version }}/* base/${{ matrix.version }}
|
||||
|
||||
- name: Setup
|
||||
run: make setup -j $(nproc) TARGET=libgultra${{ matrix.suffix }} VERSION=${{ matrix.version }}
|
||||
|
||||
4
.github/workflows/ci_ido.yml
vendored
4
.github/workflows/ci_ido.yml
vendored
@@ -13,7 +13,7 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
version: [L] # [E, F, G, H, I, I_patch, J, K, L]
|
||||
version: [K, L] # [E, F, G, H, I, I_patch, J, K, L]
|
||||
suffix: [~, _rom] # [~, _d, _rom]
|
||||
|
||||
steps:
|
||||
@@ -32,7 +32,7 @@ jobs:
|
||||
token: ${{ secrets.SECRETTOKEN }}
|
||||
path: deps_repo
|
||||
- name: Get the dependency
|
||||
run: cp deps_repo/libultra/${{ matrix.version }}/* .
|
||||
run: cp deps_repo/libultra/${{ matrix.version }}/* base/${{ matrix.version }}
|
||||
|
||||
- name: Setup
|
||||
run: make setup -j $(nproc) TARGET=libultra${{ matrix.suffix }} VERSION=${{ matrix.version }}
|
||||
|
||||
43
Makefile
43
Makefile
@@ -4,12 +4,13 @@ NON_MATCHING ?= 0
|
||||
# libgultra_rom, libgultra_d, libgultra
|
||||
# libultra_rom, libultra_d, libultra
|
||||
TARGET ?= libgultra_rom
|
||||
VERSION ?= L
|
||||
CROSS ?= mips-linux-gnu-
|
||||
|
||||
BASE_DIR := base_$(TARGET)
|
||||
BASE_AR := $(TARGET).a
|
||||
BASE_DIR := extracted/$(VERSION)/$(TARGET)
|
||||
BASE_AR := base/$(VERSION)/$(TARGET).a
|
||||
BUILD_ROOT := build
|
||||
BUILD_DIR := $(BUILD_ROOT)/$(TARGET)
|
||||
BUILD_DIR := $(BUILD_ROOT)/$(VERSION)/$(TARGET)
|
||||
BUILD_AR := $(BUILD_DIR)/$(TARGET).a
|
||||
|
||||
WORKING_DIR := $(shell pwd)
|
||||
@@ -17,6 +18,18 @@ WORKING_DIR := $(shell pwd)
|
||||
CPP := cpp -P
|
||||
AR := ar
|
||||
|
||||
VERSION_D := 1
|
||||
VERSION_E := 2
|
||||
VERSION_F := 3
|
||||
VERSION_G := 4
|
||||
VERSION_H := 5
|
||||
VERSION_I := 6
|
||||
VERSION_J := 7
|
||||
VERSION_K := 8
|
||||
VERSION_L := 9
|
||||
|
||||
VERSION_DEFINE := -DBUILD_VERSION=$(VERSION_$(VERSION)) -DBUILD_VERSION_STRING=\"2.0$(VERSION)\"
|
||||
|
||||
ifeq ($(findstring libgultra,$(TARGET)),libgultra)
|
||||
-include Makefile.gcc
|
||||
else ifeq ($(findstring libultra,$(TARGET)),libultra)
|
||||
@@ -40,8 +53,7 @@ ASM_DIRS := $(shell find asm -type d -not -path "asm/non_matchings*")
|
||||
C_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.c))
|
||||
S_FILES := $(foreach dir,$(SRC_DIRS) $(ASM_DIRS),$(wildcard $(dir)/*.s))
|
||||
O_FILES := $(foreach f,$(S_FILES:.s=.o),$(BUILD_DIR)/$f) \
|
||||
$(foreach f,$(C_FILES:.c=.o),$(BUILD_DIR)/$f) \
|
||||
$(foreach f,$(wildcard $(BASE_DIR)/*),$(BUILD_DIR)/$f)
|
||||
$(foreach f,$(C_FILES:.c=.o),$(BUILD_DIR)/$f)
|
||||
# Because we patch the object file timestamps, we can't use them as the targets since they'll always be older than the C file
|
||||
# Therefore instead we use marker files that have actual timestamps as the dependencies for the archive
|
||||
MARKER_FILES := $(O_FILES:.o=.marker)
|
||||
@@ -61,6 +73,17 @@ AR_OLD := $(AR)
|
||||
endif
|
||||
|
||||
BASE_OBJS := $(wildcard $(BASE_DIR)/*.o)
|
||||
|
||||
# Check to make sure the current version has been set up
|
||||
ifneq ($(NON_MATCHING),1)
|
||||
ifeq ($(BASE_OBJS),)
|
||||
# Ignore this check if the user is currently running setup, clean or distclean
|
||||
ifeq ($(filter $(MAKECMDGOALS),setup clean distclean),)
|
||||
$(error Current version ($(TARGET) 2.0$(VERSION)) has not been setup!)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
# Try to find a file corresponding to an archive file in any of src/ asm/ or the base directory, prioritizing src then asm then the original file
|
||||
AR_ORDER = $(foreach f,$(shell $(AR) t $(BASE_AR)),$(shell find $(BUILD_DIR)/src $(BUILD_DIR)/asm $(BUILD_DIR)/$(BASE_DIR) -iname $f -type f -print -quit))
|
||||
MATCHED_OBJS = $(filter-out $(BUILD_DIR)/$(BASE_DIR)/%,$(AR_ORDER))
|
||||
@@ -69,7 +92,7 @@ NUM_OBJS = $(words $(AR_ORDER))
|
||||
NUM_OBJS_MATCHED = $(words $(MATCHED_OBJS))
|
||||
NUM_OBJS_UNMATCHED = $(words $(UNMATCHED_OBJS))
|
||||
|
||||
$(shell mkdir -p asm $(BASE_DIR) src $(BUILD_DIR)/$(BASE_DIR) $(foreach dir,$(ASM_DIRS) $(SRC_DIRS),$(BUILD_DIR)/$(dir)))
|
||||
$(shell mkdir -p asm $(BASE_DIR) src $(foreach dir,$(ASM_DIRS) $(SRC_DIRS),$(BUILD_DIR)/$(dir)))
|
||||
|
||||
.PHONY: all clean distclean setup
|
||||
all: $(BUILD_AR)
|
||||
@@ -85,15 +108,15 @@ ifneq ($(NON_MATCHING),1)
|
||||
endif
|
||||
|
||||
clean:
|
||||
$(RM) -rf $(BUILD_ROOT)
|
||||
$(RM) -rf $(BUILD_DIR)
|
||||
|
||||
distclean: clean
|
||||
distclean:
|
||||
$(MAKE) -C tools distclean
|
||||
$(RM) -rf $(BASE_DIR)
|
||||
$(RM) -rf extracted/ $(BUILD_ROOT)
|
||||
|
||||
setup:
|
||||
$(MAKE) -C tools
|
||||
cd $(BASE_DIR) && $(AR) xo ../$(BASE_AR)
|
||||
cd $(BASE_DIR) && $(AR) xo $(WORKING_DIR)/$(BASE_AR)
|
||||
chmod -R +rw $(BASE_DIR)
|
||||
ifeq ($(COMPILER),ido)
|
||||
export CROSS=$(CROSS) && ./tools/strip_debug.sh $(BASE_DIR)
|
||||
|
||||
@@ -9,7 +9,7 @@ export COMPILER_PATH := $(WORKING_DIR)/tools/gcc
|
||||
|
||||
CFLAGS := -w -nostdinc -c -G 0 -mgp32 -mfp32 -D_LANGUAGE_C
|
||||
ASFLAGS := -w -nostdinc -c -G 0 -mgp32 -mfp32 -DMIPSEB -D_LANGUAGE_ASSEMBLY -D_MIPS_SIM=1 -D_ULTRA64 -x assembler-with-cpp
|
||||
CPPFLAGS = -D_MIPS_SZLONG=32 -D__USE_ISOC99 $(GBIDEFINE)
|
||||
CPPFLAGS = -D_MIPS_SZLONG=32 -D__USE_ISOC99 $(GBIDEFINE) $(VERSION_DEFINE)
|
||||
IINC = -I . -I $(WORKING_DIR)/include -I $(WORKING_DIR)/include/gcc -I $(WORKING_DIR)/include/PR
|
||||
MIPS_VERSION := -mips3
|
||||
ASOPTFLAGS :=
|
||||
|
||||
@@ -9,7 +9,7 @@ export COMPILER_PATH := $(WORKING_DIR)/tools/ido
|
||||
|
||||
CFLAGS := -c -Wab,-r4300_mul -G 0 -nostdinc -Xcpluscomm -fullwarn -woff 516,649,838,712
|
||||
ASFLAGS := -c -Wab,-r4300_mul -G 0 -nostdinc -woff 516,649,838,712
|
||||
CPPFLAGS = -D_MIPS_SZLONG=32 $(GBIDEFINE) $(PICFLAGS)
|
||||
CPPFLAGS = -D_MIPS_SZLONG=32 $(GBIDEFINE) $(VERSION_DEFINE) $(PICFLAGS)
|
||||
IINC = -I $(WORKING_DIR)/include -I $(WORKING_DIR)/include/ido -I $(WORKING_DIR)/include/PR
|
||||
MIPS_VERSION := -mips2 -o32
|
||||
PICFLAGS := -non_shared
|
||||
|
||||
17
README.md
17
README.md
@@ -15,13 +15,15 @@ Currently this repo supports building the following versions:
|
||||
| 2.0I | :x: / :x: | :x: / :x: | :x: / :x: |
|
||||
| 2.0I_patch | :x: / :x: | :x: / :x: | :x: / :x: |
|
||||
| 2.0J | :x: / :x: | :x: / :x: | :x: / :x: |
|
||||
| 2.0K | :x: / :x: | :x: / :x: | :x: / :x: |
|
||||
| 2.0K | :heavy_check_mark: / :heavy_check_mark: | :x: / :heavy_check_mark: | :heavy_check_mark: / :heavy_check_mark: |
|
||||
| 2.0L | :heavy_check_mark: / :heavy_check_mark: | :x: / :heavy_check_mark: | :heavy_check_mark: / :heavy_check_mark: |
|
||||
| ique_v1.5 | :x: | :x: | :x: |
|
||||
|
||||
## Preparation
|
||||
|
||||
After cloning the repo, put a copy of the target archive on the root of this directory.
|
||||
After cloning the repo, put a copy of the target archive(s) in their correct version folder in `base/`.
|
||||
For example, if your target archive is libgultra_rom.a 2.0L then you'd place it in `base/L/`.
|
||||
If you will be building without a target archive by setting `NON_MATCHING` then you can skip this step.
|
||||
|
||||
## Build dependencies
|
||||
|
||||
@@ -46,5 +48,12 @@ sudo apt install binutils-mips-linux-gnu
|
||||
|
||||
## Building
|
||||
|
||||
- `make setup`
|
||||
- `make`
|
||||
Run make setup with the proper flags set followed by make with optional jobs.
|
||||
For example, if building the 2.0L PC archive you'd do the following:
|
||||
|
||||
- `make VERSION=L TARGET=libgultra_rom setup`
|
||||
- `make VERSION=L TARGET=libgultra_rom`
|
||||
|
||||
Every target flag combination requires separate a setup command.
|
||||
|
||||
If building without a target archive using `NON_MATCHING` then you can skip the setup command.
|
||||
|
||||
0
base/J/.gitkeep
Normal file
0
base/J/.gitkeep
Normal file
0
base/K/.gitkeep
Normal file
0
base/K/.gitkeep
Normal file
0
base/L/.gitkeep
Normal file
0
base/L/.gitkeep
Normal file
@@ -10,7 +10,17 @@
|
||||
#ifndef _OS_VERSION_H_
|
||||
#define _OS_VERSION_H_
|
||||
|
||||
#define OS_MAJOR_VERSION "2.0K" /* major version */
|
||||
#define OS_MINOR_VERSION 0 /* patch level */
|
||||
#define VERSION_D 1
|
||||
#define VERSION_E 2
|
||||
#define VERSION_F 3
|
||||
#define VERSION_G 4
|
||||
#define VERSION_H 5
|
||||
#define VERSION_I 6
|
||||
#define VERSION_J 7
|
||||
#define VERSION_K 8
|
||||
#define VERSION_L 9
|
||||
|
||||
#define OS_MAJOR_VERSION BUILD_VERSION_STRING /* major version */
|
||||
#define OS_MINOR_VERSION 0 /* patch level */
|
||||
|
||||
#endif /* !_OS_VERSION_H_ */
|
||||
|
||||
@@ -10,8 +10,13 @@ void osThreadProfileStop(void) {
|
||||
|
||||
#ifndef NDEBUG
|
||||
if (__osThprofFlag == 0) {
|
||||
#if BUILD_VERSION >= VERSION_L
|
||||
__osRestoreInt(saveMask);
|
||||
__osError(138, 0);
|
||||
#else
|
||||
__osError(138, 0);
|
||||
__osRestoreInt(saveMask);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
@@ -23,9 +28,13 @@ void osThreadProfileStop(void) {
|
||||
thprof[id].time += now_time - __osThprofLastTimer;
|
||||
} else {
|
||||
#ifndef NDEBUG
|
||||
#if BUILD_VERSION >= VERSION_L
|
||||
__osRestoreInt(saveMask);
|
||||
#endif
|
||||
__osError(147, 1, id);
|
||||
#if BUILD_VERSION >= VERSION_L
|
||||
saveMask = __osDisableInt();
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,9 @@ s32 osEepromProbe(OSMesgQueue* mq) {
|
||||
}
|
||||
}
|
||||
|
||||
#if BUILD_VERSION >= VERSION_L
|
||||
__osEepromRead16K = 0;
|
||||
#endif
|
||||
__osSiRelAccess();
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,9 @@
|
||||
#include "siint.h"
|
||||
|
||||
OSPifRam __osEepPifRam ALIGNED(16);
|
||||
#if BUILD_VERSION >= VERSION_L
|
||||
s32 __osEepromRead16K;
|
||||
#endif
|
||||
static void __osPackEepReadData(u8 address);
|
||||
|
||||
s32 osEepromRead(OSMesgQueue* mq, u8 address, u8* buffer) {
|
||||
@@ -31,9 +33,12 @@ s32 osEepromRead(OSMesgQueue* mq, u8 address, u8* buffer) {
|
||||
if (address >= EEP16K_MAXBLOCKS) {
|
||||
// not technically possible
|
||||
ret = CONT_RANGE_ERROR;
|
||||
} else {
|
||||
}
|
||||
#if BUILD_VERSION >= VERSION_L
|
||||
else {
|
||||
__osEepromRead16K = 1;
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
ret = CONT_NO_RESPONSE_ERROR;
|
||||
|
||||
@@ -10,7 +10,9 @@ s32 osEepromWrite(OSMesgQueue* mq, u8 address, u8* buffer) {
|
||||
u8* ptr = (u8*)&__osEepPifRam.ramarray;
|
||||
__OSContEepromFormat eepromformat;
|
||||
OSContStatus sdata;
|
||||
#if BUILD_VERSION > VERSION_K
|
||||
u8 temp[8];
|
||||
#endif
|
||||
|
||||
__osSiGetAccess();
|
||||
ret = __osEepStatus(mq, &sdata);
|
||||
@@ -28,12 +30,15 @@ s32 osEepromWrite(OSMesgQueue* mq, u8 address, u8* buffer) {
|
||||
if (address >= EEP16K_MAXBLOCKS) {
|
||||
// not technically possible
|
||||
ret = CONT_RANGE_ERROR;
|
||||
} else if (__osEepromRead16K) {
|
||||
}
|
||||
#if BUILD_VERSION >= VERSION_L
|
||||
else if (__osEepromRead16K) {
|
||||
__osEepromRead16K = 0;
|
||||
__osSiRelAccess();
|
||||
osEepromRead(mq, (address ^ 1), temp);
|
||||
__osSiGetAccess();
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
ret = CONT_NO_RESPONSE_ERROR;
|
||||
|
||||
Reference in New Issue
Block a user