Use psxcdgen_ex under WSL and improve wslpath and makefiles

This commit is contained in:
Jaby Blubb 2023-08-25 05:15:23 +02:00
parent 5f21d7ebe7
commit 2c37c2b412
14 changed files with 113 additions and 70 deletions

View File

@ -1,5 +1,23 @@
ARTIFACT = PoolBox
make_assets = $(MAKE) $(1) ARTIFACT=$(ARTIFACT) -C assets
make_application = $(MAKE) $(1) ARTIFACT=$(ARTIFACT) -C application
make_cd = $(MAKE) $(1) ARTIFACT=$(ARTIFACT) -f $(JABY_ENGINE_DIR)/lib/ISOTarget.mk -C iso
all clean rebuild: always all clean rebuild: always
$(MAKE) $(MAKECMDGOALS) -C assets $(call make_assets,$(MAKECMDGOALS))
$(MAKE) $(MAKECMDGOALS) -C application $(call make_application,$(MAKECMDGOALS))
$(call make_cd,$(MAKECMDGOALS))
all_%: always
$(call make_assets,$*)
$(call make_application,$*)
$(call make_cd,$*)
assets_%: always
$(call make_assets,$*)
application_%: always
$(call make_application,$*)
cd_%: always
$(call make_cd,$*)
always: ; always: ;

View File

@ -11,7 +11,7 @@
{ {
"label": "build", "label": "build",
"type": "shell", "type": "shell",
"command": "wsl make ${input:target} BUILD_PROFILE=${input:build profile} JABY_ENGINE_DIR=$(wslpath ${env:JABY_ENGINE_PATH})", "command": "wsl make ${input:project}_${input:target} BUILD_PROFILE=${input:build profile} PSX_LICENSE_PATH=$(wslpath ${env:PSX_LICENSE_PATH}) JABY_ENGINE_DIR=$(wslpath ${env:JABY_ENGINE_PATH})",
"group": { "group": {
"kind": "build", "kind": "build",
"isDefault": true "isDefault": true
@ -22,25 +22,6 @@
} }
} }
}, },
{
"label": "cdgen",
"type": "shell",
"command": "${env:JABY_ENGINE_PATH}/bin/psxcdgen_ex.exe --list iso/PoolBox.lba -o iso/PoolBox psx bin-cue iso/Config.xml",
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "build & generate cd",
"type": "shell",
"dependsOn": ["build", "cdgen"],
"dependsOrder": "sequence",
"group": {
"kind": "build",
"isDefault": true
}
}
], ],
"inputs": [ "inputs": [
{ {
@ -50,6 +31,13 @@
"default": "release", "default": "release",
"description": "The build profile for PoolBox" "description": "The build profile for PoolBox"
}, },
{
"id": "project",
"type": "pickString",
"options": ["all", "assets", "application", "cd"],
"default": "all",
"description": "Project to build"
},
{ {
"id": "target", "id": "target",
"type": "pickString", "type": "pickString",

View File

@ -1,4 +1,3 @@
ARTIFACT = PoolBox
BUILD_DIR = bin BUILD_DIR = bin
OVERLAY_CONFIG = Overlays.json OVERLAY_CONFIG = Overlays.json
@ -10,9 +9,4 @@ INCLUDES += -I$(JABY_ENGINE_DIR)/include
CCFLAGS += -save-temps=obj CCFLAGS += -save-temps=obj
include $(JABY_ENGINE_DIR)/lib/Makefile include $(JABY_ENGINE_DIR)/lib/Makefile
include $(JABY_ENGINE_DIR)/lib/PSEXETarget.mk include $(JABY_ENGINE_DIR)/lib/PSEXETarget.mk
clean:
rm -fr $(OUTPUT_DIR)
rm -fr ../iso/*.bin
rm -fr ../iso/*.cue

View File

@ -4,14 +4,14 @@
<License>%PSX_LICENSE_PATH%/LICENSEE.DAT</License> <License>%PSX_LICENSE_PATH%/LICENSEE.DAT</License>
</Description> </Description>
<Track> <Track>
<File name = "SYSTEM.CNF">iso/System.cnf</File> <File name = "SYSTEM.CNF">System.cnf</File>
<Main name = "XXXX_AAA.AA" lba_source = "application/src/main_assets.cpp">application/bin/PSX-release/PoolBox.psexe</Main> <Main name = "XXXX_AAA.AA" lba_source = "../application/src/main_assets.cpp">../application/bin/PSX-release/PoolBox.psexe</Main>
<Directory name="ASSETS" hidden = "true"> <Directory name="ASSETS" hidden = "true">
<Directory name = "MAIN"> <Directory name = "MAIN">
<File name = "FONT.BIN" lz4 = "already">assets/bin/YoshiFont.bin</File> <File name = "FONT.BIN" lz4 = "already">../assets/bin/YoshiFont.bin</File>
</Directory> </Directory>
<File name = "FONT.BIN" lz4 = "already">assets/bin/TexturePage.bin</File> <File name = "FONT.BIN" lz4 = "already">../assets/bin/TexturePage.bin</File>
<File name = "ICON.BIN" lz4 = "already">assets/bin/IconTexture.bin</File> <File name = "ICON.BIN" lz4 = "already">../assets/bin/IconTexture.bin</File>
</Directory> </Directory>
</Track> </Track>
</ISO_Project> </ISO_Project>

14
lib/ISOTarget.mk Normal file
View File

@ -0,0 +1,14 @@
include $(JABY_ENGINE_DIR)/lib/RebuildTarget.mk
CD_OUTPUT ?= $(ARTIFACT).bin
$(CD_OUTPUT): always
psxcdgen_ex --list $(ARTIFACT).lba -o $(ARTIFACT) psx bin-cue Config.xml
all: $(CD_OUTPUT)
clean:
rm -fr *.bin
rm -fr *.cue
rm -fr *.lba
always: ;

View File

@ -7,6 +7,8 @@ include $(AUTO_OVERLAY_DIR)/Overlays.mk
JABY_ENGINE_LIB_DIR = $(JABY_ENGINE_DIR)/lib/PSX-$(BUILD_PROFILE) JABY_ENGINE_LIB_DIR = $(JABY_ENGINE_DIR)/lib/PSX-$(BUILD_PROFILE)
JABY_ENGINE_LIB_NAME = JabyEngine_$(TV_FORMAT) JABY_ENGINE_LIB_NAME = JabyEngine_$(TV_FORMAT)
OVERLAY_TARGET = $(foreach ovl, $(OVERLAYSECTION), $(OUTPUT_DIR)/Overlay$(ovl))
#Linking rule #Linking rule
$(TARGET).elf: $(OBJS) $(JABY_ENGINE_LIB_DIR)/lib$(JABY_ENGINE_LIB_NAME).a $(AUTO_OVERLAY_DIR)/Overlays.ld $(TARGET).elf: $(OBJS) $(JABY_ENGINE_LIB_DIR)/lib$(JABY_ENGINE_LIB_NAME).a $(AUTO_OVERLAY_DIR)/Overlays.ld
$(LD) -o $(TARGET).elf $(LDFLAGS_all) $(LDFLAGS) $(OBJS) -L$(JABY_ENGINE_LIB_DIR) -l$(JABY_ENGINE_LIB_NAME) $(LIBS) $(LD) -o $(TARGET).elf $(LDFLAGS_all) $(LDFLAGS) $(OBJS) -L$(JABY_ENGINE_LIB_DIR) -l$(JABY_ENGINE_LIB_NAME) $(LIBS)
@ -16,7 +18,7 @@ $(TARGET).psexe: $(TARGET).elf
$(PREFIX)-objcopy $(addprefix -R , $(OVERLAYSECTION)) -O binary $< $@ $(PREFIX)-objcopy $(addprefix -R , $(OVERLAYSECTION)) -O binary $< $@
#Create overlays #Create overlays
$(foreach ovl, $(OVERLAYSECTION), $(OUTPUT_DIR)/Overlay$(ovl)): $(TARGET).elf $(OVERLAY_TARGET): $(TARGET).elf
$(PREFIX)-objcopy -j $(suffix $@) -O binary $< $@ $(PREFIX)-objcopy -j $(suffix $@) -O binary $< $@
#Create overlay makefile #Create overlay makefile
@ -25,4 +27,7 @@ $(AUTO_OVERLAY_DIR)/Overlays.mk: $(OVERLAY_CONFIG)
mkoverlay --mk-file $(AUTO_OVERLAY_DIR)/Overlays.mk --ld-script $(AUTO_OVERLAY_DIR)/Overlays.ld $< mkoverlay --mk-file $(AUTO_OVERLAY_DIR)/Overlays.mk --ld-script $(AUTO_OVERLAY_DIR)/Overlays.ld $<
#Rules section for default compilation and linking #Rules section for default compilation and linking
all: $(TARGET).psexe $(foreach ovl, $(OVERLAYSECTION), $(OUTPUT_DIR)/Overlay$(ovl)) all: $(TARGET).psexe $(OVERLAY_TARGET)
clean:
rm -fr $(OUTPUT_DIR)

View File

@ -1,4 +1,4 @@
set bin_projects=psxcdgen psxcdgen_ex psxcdread psxreadmap wslpath set bin_projects=psxcdgen psxcdgen_ex psxcdread psxreadmap wslpath
set bin_linux_projects=cpp_out jaby_engine_fconv mkoverlay set bin_linux_projects=cpp_out psxcdgen_ex jaby_engine_fconv mkoverlay wslpath
set clean_projects=cdtypes set clean_projects=cdtypes
set clean_projects_linux=tool_helper set clean_projects_linux=tool_helper

View File

@ -1,7 +1,7 @@
use clap::{Parser, ValueEnum}; use clap::{Parser, ValueEnum};
use psxcdgen_ex::{encoder::{EncodingFunctions, psx::{calculate_psx_lbas, calculate_psx_length_for, encode_psx_image}}, file_writer::{ImageType, write_image}, config_reader}; use psxcdgen_ex::{encoder::{EncodingFunctions, psx::{calculate_psx_lbas, calculate_psx_length_for, encode_psx_image}}, file_writer::{ImageType, write_image}, config_reader};
use std::{path::PathBuf}; use std::path::PathBuf;
use tool_helper::{Error, exit_with_error}; use tool_helper::{Error, exit_with_error, read_file_to_string};
#[derive(Parser)] #[derive(Parser)]
#[clap(about = "Creates an ISO image from a description file", long_about = None)] #[clap(about = "Creates an ISO image from a description file", long_about = None)]
@ -37,7 +37,7 @@ impl SystemType {
fn run_main(cmd_line: CommandLine) -> Result<(), Error> { fn run_main(cmd_line: CommandLine) -> Result<(), Error> {
let encoding_functions = cmd_line.system_type.get_encoding_functions(); let encoding_functions = cmd_line.system_type.get_encoding_functions();
let (desc, lba_embedded_files) = psxcdgen_ex::process(config_reader::parse_xml(std::fs::read_to_string(cmd_line.input_file)?)?, encoding_functions.lba_calculator)?; let (desc, lba_embedded_files) = psxcdgen_ex::process(config_reader::parse_xml(read_file_to_string(&cmd_line.input_file)?)?, encoding_functions.lba_calculator)?;
let file_map = desc.create_file_map(); let file_map = desc.create_file_map();
psxcdgen_ex::process_files(file_map, lba_embedded_files, encoding_functions.length_calculator)?; psxcdgen_ex::process_files(file_map, lba_embedded_files, encoding_functions.length_calculator)?;

View File

@ -6,6 +6,7 @@ fn convert_slashes(path: String) -> String {
path.replace('\\', "/") path.replace('\\', "/")
} }
#[cfg(target_os = "windows")]
fn replace_drive_letter(mut path: String) -> String { fn replace_drive_letter(mut path: String) -> String {
let has_drive_letter = { let has_drive_letter = {
let drive_letter = path.get(0..2); let drive_letter = path.get(0..2);
@ -35,5 +36,10 @@ fn replace_drive_letter(mut path: String) -> String {
path.insert_str(0, "/mnt/"); path.insert_str(0, "/mnt/");
} }
path
}
#[cfg(not(target_os = "windows"))]
fn replace_drive_letter(path: String) -> String {
path path
} }

View File

@ -11,37 +11,17 @@
{ {
"label": "build", "label": "build",
"type": "shell", "type": "shell",
"command": "wsl make ${input:target} BUILD_PROFILE=${input:build profile} JABY_ENGINE_DIR=$(wslpath ${env:JABY_ENGINE_PATH})", "command": "wsl make ${input:project}_${input:target} BUILD_PROFILE=${input:build profile} PSX_LICENSE_PATH=$(wslpath ${env:PSX_LICENSE_PATH}) JABY_ENGINE_DIR=$(wslpath ${env:JABY_ENGINE_PATH})",
"group": { "group": {
"kind": "build", "kind": "build",
"isDefault": true "isDefault": true
}, },
"options": { "options": {
"cwd": "application",
"env": { "env": {
"PATH": "${env:JABY_ENGINE_PATH}/bin;${env:PATH}" "PATH": "${env:JABY_ENGINE_PATH}/bin;${env:PATH}"
} }
} }
}, },
{
"label": "cdgen",
"type": "shell",
"command": "${env:JABY_ENGINE_PATH}/bin/psxcdgen_ex.exe --list iso/#{ProjectName}.lba -o iso/#{ProjectName} psx bin-cue iso/Config.xml",
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "build & generate cd",
"type": "shell",
"dependsOn": ["build", "cdgen"],
"dependsOrder": "sequence",
"group": {
"kind": "build",
"isDefault": true
}
}
], ],
"inputs": [ "inputs": [
{ {
@ -51,6 +31,13 @@
"default": "release", "default": "release",
"description": "The build profile for #{ProjectName}" "description": "The build profile for #{ProjectName}"
}, },
{
"id": "project",
"type": "pickString",
"options": ["all", "assets", "application", "cd"],
"default": "all",
"description": "Project to build"
},
{ {
"id": "target", "id": "target",
"type": "pickString", "type": "pickString",

View File

@ -0,0 +1,23 @@
ARTIFACT = #{ProjectName}
make_assets = $(MAKE) $(1) ARTIFACT=$(ARTIFACT) -C assets
make_application = $(MAKE) $(1) ARTIFACT=$(ARTIFACT) -C application
make_cd = $(MAKE) $(1) ARTIFACT=$(ARTIFACT) -f $(JABY_ENGINE_DIR)/lib/ISOTarget.mk -C iso
all clean rebuild: always
$(call make_assets,$(MAKECMDGOALS))
$(call make_application,$(MAKECMDGOALS))
$(call make_cd,$(MAKECMDGOALS))
all_%: always
$(call make_assets,$*)
$(call make_application,$*)
$(call make_cd,$*)
assets_%: always
$(call make_assets,$*)
application_%: always
$(call make_application,$*)
cd_%: always
$(call make_cd,$*)
always: ;

View File

@ -1,4 +1,3 @@
ARTIFACT = #{ProjectName}
BUILD_DIR = bin BUILD_DIR = bin
#OVERLAY_CONFIG = Overlays.json #OVERLAY_CONFIG = Overlays.json
@ -9,9 +8,4 @@ SRCS = $(call rwildcard, src, c cpp)
INCLUDES += -I$(JABY_ENGINE_DIR)/include INCLUDES += -I$(JABY_ENGINE_DIR)/include
include $(JABY_ENGINE_DIR)/lib/Makefile include $(JABY_ENGINE_DIR)/lib/Makefile
include $(JABY_ENGINE_DIR)/lib/PSEXETarget.mk include $(JABY_ENGINE_DIR)/lib/PSEXETarget.mk
clean:
rm -fr $(OUTPUT_DIR)
rm -fr ../iso/*.bin
rm -fr ../iso/*.cue

View File

@ -0,0 +1,14 @@
include $(JABY_ENGINE_DIR)/lib/ExportPath.mk
include $(JABY_ENGINE_DIR)/lib/RebuildTarget.mk
OUTPUT_DIR = bin
# Create build targets like
# $(OUTPUT_DIR)/TexturePage.bin: TexturePage.png
# @mkdir -p $(OUTPUT_DIR)
# jaby_engine_fconv --lz4 $< -o $@ simple-tim clut4
all: #$(OUTPUT_DIR)/TexturePage.bin
clean:
rm -fr $(OUTPUT_DIR)

View File

@ -4,7 +4,7 @@
<!--<License>%PSX_LICENSE_PATH%/LICENSEE.DAT</License>--> <!--<License>%PSX_LICENSE_PATH%/LICENSEE.DAT</License>-->
</Description> </Description>
<Track> <Track>
<File name="SYSTEM.CNF">iso/System.cnf</File> <File name="SYSTEM.CNF">System.cnf</File>
<Main name="XXXX_AAA.AA">application/bin/PSX-release/#{ProjectName}.psexe</Main> <Main name="XXXX_AAA.AA">../application/bin/PSX-release/#{ProjectName}.psexe</Main>
</Track> </Track>
</ISO_Project> </ISO_Project>