Permalink
Browse files

Another template format (#2)

* Another template structure

* Added some infos and more gitignores

* Removed unused files and fixed indentation
  • Loading branch information...
1 parent c323344 commit 05f0eee5c5b74caae83699c7f7fe1effe18f61a4 @Eiyeron Eiyeron committed with xyzz Jul 31, 2016
View
@@ -1,3 +1,6 @@
*.o
*.elf
-*.velf
+*.velf
+*.bin
+*.vpk
+*.sfo
View
@@ -9,6 +9,10 @@ Always use the `*_debug.bat` (e.g. `run_homebrew_unity_debug.bat`) launcher to g
* `hello_world`: A minimal Makefile-based C project
* `hello_cpp_world`: A minimal Makefile-based C++ project
+## Notes
+- icon0.png, startup.png and bg.png must be using indexed palettes.
+- For some reasons, some PNG files created by GIMP makes the .vpk installation crash.
+
## License
All code and build scripts in this repo is licensed under the terms of [CC0 1.0 Universal](https://creativecommons.org/publicdomain/zero/1.0/).
View
0 build.sh 100644 → 100755
No changes.
View
0 clean.sh 100644 → 100755
No changes.
@@ -1,12 +1,40 @@
+PHONY := all package clean
+rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d))
+
CC := arm-vita-eabi-gcc
CXX := arm-vita-eabi-g++
STRIP := arm-vita-eabi-strip
+PROJECT_TITLE := HelloWorld
+PROJECT_TITLEID := FFFF00001
+
PROJECT := hello_cpp_world
CXXFLAGS += -std=c++11
-OBJS := main.o
-all: $(PROJECT).velf
+SRC_C :=$(call rwildcard, src/, *.c)
+SRC_CPP :=$(call rwildcard, src/, *.cpp)
+
+OBJ_DIRS := $(addprefix out/, $(dir $(SRC_C:src/%.c=%.o))) $(addprefix out/, $(dir $(SRC_CPP:src/%.cpp=%.o)))
+OBJS := $(addprefix out/, $(SRC_C:src/%.c=%.o)) $(addprefix out/, $(SRC_CPP:src/%.cpp=%.o))
+
+
+all: package
+
+package: $(PROJECT).vpk
+
+$(PROJECT).vpk: eboot.bin param.sfo
+ vita-pack-vpk -s param.sfo -b eboot.bin \
+ --add sce_sys/icon0.png=sce_sys/icon0.png \
+ --add sce_sys/livearea/contents/bg.png=sce_sys/livearea/contents/bg.png \
+ --add sce_sys/livearea/contents/startup.png=sce_sys/livearea/contents/startup.png \
+ --add sce_sys/livearea/contents/template.xml=sce_sys/livearea/contents/template.xml \
+ $(PROJECT).vpk
+
+eboot.bin: $(PROJECT).velf
+ vita-make-fself $(PROJECT).velf eboot.bin
+
+param.sfo:
+ vita-mksfoex -s TITLE_ID="$(PROJECT_TITLEID)" "$(PROJECT_TITLE)" param.sfo
$(PROJECT).velf: $(PROJECT).elf
$(STRIP) -g $<
@@ -15,5 +43,15 @@ $(PROJECT).velf: $(PROJECT).elf
$(PROJECT).elf: $(OBJS)
$(CXX) -Wl,-q -o $@ $^
+$(OBJ_DIRS):
+ mkdir -p $@
+
+out/%.o : src/%.cpp | $(OBJ_DIRS)
+ arm-vita-eabi-g++ -c $(CXXFLAGS) -o $@ $<
+
+out/%.o : src/%.c | $(OBJ_DIRS)
+ arm-vita-eabi-g++ -c -o $@ $<
+
clean:
- -rm -f $(PROJECT).velf $(PROJECT).elf $(OBJS)
+ rm -f $(PROJECT).velf $(PROJECT).elf $(PROJECT).vpk param.sfo eboot.bin $(OBJS)
+ rm -r $(abspath $(OBJ_DIRS))
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<livearea style="a1" format-ver="01.00" content-rev="1">
+ <livearea-background>
+ <image>bg.png</image>
+ </livearea-background>
+
+ <gate>
+ <startup-image>startup.png</startup-image>
+ </gate>
+</livearea>
@@ -1,3 +1,4 @@
+#include <psp2/kernel/processmgr.h>
#include <sstream>
#include <vector>
@@ -15,4 +16,6 @@ int main(int argc, char *argv[]) {
}
output << std::endl;
printf("%s\n", output.str().c_str());
+ sceKernelExitProcess(0);
+ return 0;
}
View
@@ -1,17 +1,57 @@
+PHONY := all package clean
+rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d))
+
CC := arm-vita-eabi-gcc
+CXX := arm-vita-eabi-g++
STRIP := arm-vita-eabi-strip
-PROJECT := hello_world
-OBJS := main.o
+PROJECT_TITLE := HelloWorld
+PROJECT_TITLEID := FFFF00001
+
+PROJECT := hello_cpp_world
+CXXFLAGS += -std=c++11
+
+SRC_C :=$(call rwildcard, src/, *.c)
+SRC_CPP :=$(call rwildcard, src/, *.cpp)
+
+OBJ_DIRS := $(addprefix out/, $(dir $(SRC_C:src/%.c=%.o))) $(addprefix out/, $(dir $(SRC_CPP:src/%.cpp=%.o)))
+OBJS := $(addprefix out/, $(SRC_C:src/%.c=%.o)) $(addprefix out/, $(SRC_CPP:src/%.cpp=%.o))
+
+
+all: package
-all: $(PROJECT).velf
+package: $(PROJECT).vpk
+
+$(PROJECT).vpk: eboot.bin param.sfo
+ vita-pack-vpk -s param.sfo -b eboot.bin \
+ --add sce_sys/icon0.png=sce_sys/icon0.png \
+ --add sce_sys/livearea/contents/bg.png=sce_sys/livearea/contents/bg.png \
+ --add sce_sys/livearea/contents/startup.png=sce_sys/livearea/contents/startup.png \
+ --add sce_sys/livearea/contents/template.xml=sce_sys/livearea/contents/template.xml \
+ $(PROJECT).vpk
+
+eboot.bin: $(PROJECT).velf
+ vita-make-fself $(PROJECT).velf eboot.bin
+
+param.sfo:
+ vita-mksfoex -s TITLE_ID="$(PROJECT_TITLEID)" "$(PROJECT_TITLE)" param.sfo
$(PROJECT).velf: $(PROJECT).elf
$(STRIP) -g $<
vita-elf-create $< $@
$(PROJECT).elf: $(OBJS)
- $(CC) -Wl,-q -o $@ $^
+ $(CXX) -Wl,-q -o $@ $^
+
+$(OBJ_DIRS):
+ mkdir -p $@
+
+out/%.o : src/%.cpp | $(OBJ_DIRS)
+ arm-vita-eabi-g++ -c $(CXXFLAGS) -o $@ $<
+
+out/%.o : src/%.c | $(OBJ_DIRS)
+ arm-vita-eabi-g++ -c -o $@ $<
clean:
- -rm -f $(PROJECT).velf $(PROJECT).elf $(OBJS)
+ rm -f $(PROJECT).velf $(PROJECT).elf $(PROJECT).vpk param.sfo eboot.bin $(OBJS)
+ rm -r $(abspath $(OBJ_DIRS))
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<livearea style="a1" format-ver="01.00" content-rev="1">
+ <livearea-background>
+ <image>bg.png</image>
+ </livearea-background>
+
+ <gate>
+ <startup-image>startup.png</startup-image>
+ </gate>
+</livearea>
@@ -1,6 +1,8 @@
+#include <psp2/kernel/processmgr.h>
#include <stdio.h>
int main(int argc, char *argv[]) {
printf("Hello, world!\n");
+ sceKernelExitProcess(0);
return 0;
}

0 comments on commit 05f0eee

Please sign in to comment.