Add libpl submodule (#753)

* Add libpl submodule

* Clone libpl submodule automatically while building (if enabled)
This commit is contained in:
Gregory Heskett
2024-02-02 22:08:34 -05:00
committed by GitHub
parent 5064fcfb69
commit b9ba17a4d6
7 changed files with 54 additions and 1 deletions

3
.gitmodules vendored Normal file
View File

@@ -0,0 +1,3 @@
[submodule "lib/libpl"]
path = lib/libpl
url = https://gitlab.com/parallel-launcher/libpl.git

View File

@@ -27,6 +27,7 @@
"F3DEX_GBI_2=1",
"F3DZEX_NON_GBI_2=1",
"F3DEX_GBI_SHARED=1"
"LIBPL=1",
],
"compilerPath": "/usr/bin/mips-linux-gnu-gcc",
"cStandard": "gnu17",

View File

@@ -253,6 +253,18 @@ ifeq ($(HVQM),1)
SRC_DIRS += src/hvqm
endif
# LIBPL - whether to include libpl library for interfacing with Parallel Launcher
# (library will be pulled into repo after building with this enabled for the first time)
# 1 - includes code in ROM
# 0 - does not
LIBPL ?= 0
LIBPL_DIR := lib/libpl
$(eval $(call validate-option,LIBPL,0 1))
ifeq ($(LIBPL),1)
DEFINES += LIBPL=1
SRC_DIRS += $(LIBPL_DIR)
endif
BUILD_DIR_BASE := build
# BUILD_DIR is the location where all build artifacts are placed
BUILD_DIR := $(BUILD_DIR_BASE)/$(VERSION)_$(CONSOLE)
@@ -335,6 +347,18 @@ ifeq ($(filter clean distclean print-%,$(MAKECMDGOALS)),)
ifeq ($(DUMMY),FAIL)
$(error Failed to build tools)
endif
# Clone any needed submodules
ifeq ($(LIBPL),1)
ifeq ($(wildcard $(LIBPL_DIR)),)
$(info Cloning libpl submodule...)
DUMMY != git submodule update --init $(LIBPL_DIR) > /dev/null || echo FAIL
ifeq ($(DUMMY),FAIL)
$(error Failed to clone libpl submodule)
endif
endif
endif
$(info Building ROM...)
endif

1
lib/libpl Submodule

Submodule lib/libpl added at d6b3a90d09

12
sm64.ld
View File

@@ -171,6 +171,9 @@ SECTIONS
BUILD_DIR/src/audio*.o(.text*);
#ifdef S2DEX_TEXT_ENGINE
BUILD_DIR/src/s2d_engine*.o(.text*);
#endif
#ifdef LIBPL
BUILD_DIR/lib/libpl*.o(.text*);
#endif
*/ULTRALIB.a:*.o(.text*);
*/libnustd.a:*.o(.text*);
@@ -191,6 +194,9 @@ SECTIONS
BUILD_DIR/src/audio*.o(.*data*);
#ifdef S2DEX_TEXT_ENGINE
BUILD_DIR/src/s2d_engine*.o(.*data*);
#endif
#ifdef LIBPL
BUILD_DIR/lib/libpl*.o(.*data*);
#endif
*/ULTRALIB.a:*.o(.data*);
*/libhvqm2.a:*.o(.data*);
@@ -207,6 +213,9 @@ SECTIONS
BUILD_DIR/src/audio*.o(.rodata*);
#ifdef S2DEX_TEXT_ENGINE
BUILD_DIR/src/s2d_engine*.o(.rodata*);
#endif
#ifdef LIBPL
BUILD_DIR/lib/libpl*.o(.rodata*);
#endif
*/ULTRALIB.a:*.o(.rodata*);
*/libgcc.a:*.o(.rodata*);
@@ -224,6 +233,9 @@ SECTIONS
BUILD_DIR/src/audio*.o(.*bss*);
#ifdef S2DEX_TEXT_ENGINE
BUILD_DIR/src/s2d_engine*.o(.*bss*);
#endif
#ifdef LIBPL
BUILD_DIR/lib/libpl*.o(.*bss*);
#endif
*/ULTRALIB.a:*.o(COMMON);
*/ULTRALIB.a:*.o(.scommon);

View File

@@ -9,7 +9,10 @@
#include <string.h>
#include "emutest_vc.h"
#include "float.h"
#include "types.h"
#ifdef LIBPL
#include "lib/libpl/libpl-emu.h"
#endif
extern OSMesgQueue gSIEventMesgQueue;
extern u8 __osContPifRam[];
@@ -20,6 +23,7 @@ extern void __osPiGetAccess(void);
extern void __osPiRelAccess(void);
enum Emulator gEmulator = EMU_CONSOLE;
u8 gSupportsLibpl = FALSE;
u32 pj64_get_count_factor_asm(void); // defined in asm/pj64_get_count_factor_asm.s
u32 emux_detect(void); // defined in asm/emux.s
@@ -140,6 +144,9 @@ void detect_emulator() {
if (magic == 0x00500000u) {
// libpl is supported. Must be ParallelN64
gEmulator = EMU_PARALLELN64;
#ifdef LIBPL
gSupportsLibpl = libpl_is_supported(LPL_ABI_VERSION_CURRENT);
#endif
return;
}

View File

@@ -1,6 +1,8 @@
#ifndef EMUTEST_H
#define EMUTEST_H
#include "types.h"
enum Emulator {
EMU_WIIVC = 0x0001,
EMU_PROJECT64_ANY = 0x001E,
@@ -37,6 +39,9 @@ extern void detect_emulator();
*/
extern enum Emulator gEmulator;
// determines whether libpl is safe to use
extern u8 gSupportsLibpl;
// Included for backwards compatibility when upgrading from HackerSM64 2.0
#define gIsConsole ((gEmulator & EMU_CONSOLE) != 0)