Last active
February 16, 2024 20:14
-
-
Save kassane/5e2499dfe5b532597ff7770eabfa30b1 to your computer and use it in GitHub Desktop.
zig build to PSVita target
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// replacing https://github.com/vitasdk/samples/blob/master/hello_world/src/main.c | |
const c = @cImport({ | |
@cInclude("psp2/kernel/processmgr.h"); | |
@cInclude("psp2/kernel/threadmgr.h"); | |
@cInclude("stdio.h"); | |
@cInclude("debugScreen.h"); | |
@cDefine("printf", "psvDebugScreenPrintf"); | |
}); | |
pub export fn main() c_int { | |
_ = c.psvDebugScreenInit(); | |
_ = c.printf("[Zig] Hello, world!\n"); | |
_ = c.sceKernelDelayThread(3 * 1000000); // Wait for 3 seconds | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
VITASDK=$HOME/Downloads/vita3k-emu/vitasdk | |
PATH=$VITASDK/bin:$PATH | |
PROJECT_TITLEID=VSDK00007 | |
# remove old build | |
rm -fr build | |
mkdir -p build | |
zig build-obj -fstrip -fcompiler-rt -lc \ | |
-cflags -fshort-enums -- src/main.zig ../common/debugScreen.c \ | |
-femit-bin=build/hello_world.o -fno-sanitize-c \ | |
-target arm-freestanding-eabihf -mcpu=cortex_a9 \ | |
-isystem $HOME/Downloads/vita3k-emu/vitasdk/include \ | |
-isystem $HOME/Downloads/vita3k-emu/vitasdk/arm-vita-eabi/include \ | |
-I../common | |
# add .vitalink section on binary | |
arm-vita-eabi-gcc -Wl,-q -Wall -O3 -DNDEBUG -Wl,-z,nocopyreloc \ | |
$PWD/build/hello_world.o -o $PWD/build/hello_world \ | |
-lSceLibKernel_stub -lSceDisplay_stub | |
rm $PWD/build/hello_world.o | |
vita-elf-create $PWD/build/hello_world $PWD/build/hello_world.velf | |
vita-make-fself -c -s $PWD/build/hello_world.velf $PWD/build/hello_world.self | |
vita-mksfoex -d PARENTAL_LEVEL=1 -s APP_VER=01.00 -s \ | |
TITLE_ID=$PROJECT_TITLEID "Hello World" \ | |
$PWD/build/hello_world.vpk_param.sfo | |
vita-pack-vpk -a $PWD/sce_sys/icon0.png=sce_sys/icon0.png \ | |
-a $PWD/sce_sys/livearea/contents/bg.png=sce_sys/livearea/contents/bg.png \ | |
-a $PWD/sce_sys/livearea/contents/startup.png=sce_sys/livearea/contents/startup.png \ | |
-a $PWD/sce_sys/livearea/contents/template.xml=sce_sys/livearea/contents/template.xml \ | |
-s $PWD/build/hello_world.vpk_param.sfo \ | |
-b $PWD/build/hello_world.self \ | |
$PWD/build/hello_world.vpk | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment