55
66cmake_minimum_required (VERSION 3.10 )
77
8+ option (PBOOT "Generates a PBOOT.PBP instead of EBOOT.PBP" OFF )
9+ option (PSPEMU "Does VITA PSPemu specific processes when needed" OFF )
810option (BUILD_PRX "Build a PRX for use with PSPLink" OFF )
911option (ENC_PRX "Encrypt the PRX to allow running on official firmware" OFF )
1012
@@ -23,11 +25,13 @@ macro(create_pbp_file)
2325 VERSION # optional, adds version information to PARAM.SFO
2426 OUTPUT_DIR # optional, set the output directory for the EBOOT.PBP
2527 MEMSIZE # optional, set to 1 by default for allowing access to all available memory. Can be set to 2 for better Vita compatibility, but limited memory access
26- )
28+ )
2729 set (options
30+ PBOOT # optional, generates a PBOOT.PBP instead of EBOOT.PBP
31+ PSPEMU # optional, does VITA PSPemu specific processes when needed
2832 BUILD_PRX # optional, generates and uses PRX file instead of ELF in EBOOT.PBP
2933 ENC_PRX # optional, replaces PRX file with encrypted version.
30- )
34+ )
3135 cmake_parse_arguments ("ARG" "${options} " "${oneValueArgs} " "${multiValueArgs} " ${ARGN} )
3236
3337 # set mksfoex parameter if VERSION was not defined
@@ -40,6 +44,12 @@ macro(create_pbp_file)
4044 set (ARG_SFO_PATH "" )
4145 endif ()
4246
47+ if (PBOOT)
48+ set (PBP_FILENAME "PBOOT.PBP" )
49+ else ()
50+ set (PBP_FILENAME "EBOOT.PBP" )
51+ endif ()
52+
4353 # set output directory to where the target is build if not set
4454 if (NOT DEFINED ARG_OUTPUT_DIR)
4555 set (ARG_OUTPUT_DIR $<TARGET_FILE_DIR :${ARG_TARGET} >)
@@ -91,27 +101,27 @@ macro(create_pbp_file)
91101 POST_BUILD COMMAND
92102 "${PSPDEV} /bin/psp-strip" "$<TARGET_FILE :${ARG_TARGET} >"
93103 COMMENT "Stripping binary for target ${ARG_TARGET} "
94- )
104+ )
95105 elseif (${ARG_BUILD_PRX} )
96106 add_custom_command (
97107 TARGET ${ARG_TARGET}
98108 POST_BUILD COMMAND
99109 ${CMAKE_COMMAND } -E cmake_echo_color --cyan "Not stripping binary for target ${ARG_TARGET} because building PRX."
100- )
110+ )
101111 else ()
102112 add_custom_command (
103113 TARGET ${ARG_TARGET}
104114 POST_BUILD COMMAND
105115 ${CMAKE_COMMAND } -E cmake_echo_color --cyan "Not stripping binary for target ${ARG_TARGET} , build type is ${CMAKE_BUILD_TYPE } ."
106- )
116+ )
107117 endif ()
108118
109119 add_custom_command (
110120 TARGET ${ARG_TARGET}
111121 POST_BUILD COMMAND
112122 "$ENV{PSPDEV} /bin/psp-fixup-imports" "$<TARGET_FILE :${ARG_TARGET} >"
113123 COMMENT "Calling psp-fixup-imports for target ${ARG_TARGET} "
114- )
124+ )
115125
116126 if (${ARG_BUILD_PRX} )
117127 add_custom_command (
@@ -120,22 +130,28 @@ macro(create_pbp_file)
120130 "${PSPDEV} /bin/psp-prxgen" "$<TARGET_FILE :${ARG_TARGET} >"
121131 "$<TARGET_FILE :${ARG_TARGET} >.prx"
122132 COMMENT "Calling prxgen for target ${ARG_TARGET} "
123- )
133+ )
134+
135+ if (ARG_ENC_PRX AND PBOOT AND PSPEMU)
136+ set (ENC_VITA_PBOOT_PARAM "--pspemu-pboot" )
137+ else ()
138+ set (ENC_VITA_PBOOT_PARAM "" )
139+ endif ()
124140
125141 if (${ARG_ENC_PRX} )
126142 add_custom_command (
127- TARGET ${ARG_TARGET}
128- POST_BUILD COMMAND
129- "${PSPDEV} /bin/PrxEncrypter" "$<TARGET_FILE_DIR :${ARG_TARGET} >/$<TARGET_FILE_NAME :${ARG_TARGET} >.prx"
130- "$<TARGET_FILE :${ARG_TARGET} >.prx"
131- COMMENT "Calling PrxEncrypter for target ${ARG_TARGET} "
132- )
143+ TARGET ${ARG_TARGET}
144+ POST_BUILD COMMAND
145+ "${PSPDEV} /bin/PrxEncrypter" " ${ENC_VITA_PBOOT_PARAM} " "$<TARGET_FILE_DIR :${ARG_TARGET} >/$<TARGET_FILE_NAME :${ARG_TARGET} >.prx"
146+ "$<TARGET_FILE :${ARG_TARGET} >.prx"
147+ COMMENT "Calling PrxEncrypter for target ${ARG_TARGET} "
148+ )
133149 else ()
134150 add_custom_command (
135- TARGET ${ARG_TARGET}
136- POST_BUILD COMMAND
137- ${CMAKE_COMMAND } -E cmake_echo_color --cyan "Not encrypting PRX for target ${ARG_TARGET} , use ENC_PRX flag if you need to."
138- )
151+ TARGET ${ARG_TARGET}
152+ POST_BUILD COMMAND
153+ ${CMAKE_COMMAND } -E cmake_echo_color --cyan "Not encrypting PRX for target ${ARG_TARGET} , use ENC_PRX flag if you need to."
154+ )
139155 endif ()
140156
141157 else ()
@@ -150,11 +166,17 @@ macro(create_pbp_file)
150166 set (ARG_MEMSIZE "1" )
151167 endif ()
152168
169+ if (PBOOT)
170+ set (MKSFO_PBOOT_ARG "-p" )
171+ else ()
172+ set (MKSFO_PBOOT_ARG "" )
173+ endif ()
174+
153175 if (NOT ARG_SFO_PATH)
154176 add_custom_command (
155177 TARGET ${ARG_TARGET}
156178 POST_BUILD COMMAND
157- "${PSPDEV} /bin/mksfoex" "-d" "MEMSIZE=${ARG_MEMSIZE} " "-s" "APP_VER=${ARG_VERSION} " "${ARG_TITLE} " "${ARG_OUTPUT_DIR} /PARAM.SFO"
179+ "${PSPDEV} /bin/mksfoex" "${MKSFO_PBOOT_ARG} " " -d" "MEMSIZE=${ARG_MEMSIZE} " "-s" "APP_VER=${ARG_VERSION} " "${ARG_TITLE} " "${ARG_OUTPUT_DIR} /PARAM.SFO"
158180 COMMENT "Calling mksfoex for target ${ARG_TARGET} "
159181 )
160182 set (SFO_PATH "${ARG_OUTPUT_DIR} /PARAM.SFO" )
@@ -166,15 +188,15 @@ macro(create_pbp_file)
166188 add_custom_command (
167189 TARGET ${ARG_TARGET}
168190 POST_BUILD COMMAND
169- "${PSPDEV} /bin/pack-pbp" "${ARG_OUTPUT_DIR} /EBOOT.PBP " "${SFO_PATH} " "${ARG_ICON_PATH} " "${ARG_ANIM_PATH} " "${ARG_PREVIEW_PATH} "
191+ "${PSPDEV} /bin/pack-pbp" "${ARG_OUTPUT_DIR} /${PBP_FILENAME} " "${SFO_PATH} " "${ARG_ICON_PATH} " "${ARG_ANIM_PATH} " "${ARG_PREVIEW_PATH} "
170192 "${ARG_BACKGROUND_PATH} " "${ARG_MUSIC_PATH} " "$<TARGET_FILE :${ARG_TARGET} >.prx" "${ARG_PSAR_PATH} "
171193 COMMENT "Calling pack-pbp with PRX file for target ${ARG_TARGET} "
172194 )
173195 else ()
174196 add_custom_command (
175197 TARGET ${ARG_TARGET}
176198 POST_BUILD COMMAND
177- "${PSPDEV} /bin/pack-pbp" "${ARG_OUTPUT_DIR} /EBOOT.PBP " "${SFO_PATH} " "${ARG_ICON_PATH} " "${ARG_ANIM_PATH} " "${ARG_PREVIEW_PATH} "
199+ "${PSPDEV} /bin/pack-pbp" "${ARG_OUTPUT_DIR} /${PBP_FILENAME} " "${SFO_PATH} " "${ARG_ICON_PATH} " "${ARG_ANIM_PATH} " "${ARG_PREVIEW_PATH} "
178200 "${ARG_BACKGROUND_PATH} " "${ARG_MUSIC_PATH} " "$<TARGET_FILE :${ARG_TARGET} >" "${ARG_PSAR_PATH} "
179201 COMMENT "Calling pack-pbp with ELF file for target ${ARG_TARGET} "
180202 )
@@ -192,7 +214,7 @@ macro(create_pbp_file)
192214 add_custom_command (
193215 TARGET ${ARG_TARGET}
194216 POST_BUILD COMMAND
195- ${CMAKE_COMMAND } -E cmake_echo_color --cyan "EBOOT.PBP file created for target ${ARG_TARGET} ."
217+ ${CMAKE_COMMAND } -E cmake_echo_color --cyan "${PBP_FILENAME} file created for target ${ARG_TARGET} ."
196218 )
197219
198220endmacro ()
0 commit comments