mirror of
https://github.com/FWGS/xash3d-fwgs.git
synced 2026-08-10 06:02:10 +08:00
PSP Port initial
This commit is contained in:
@@ -28,6 +28,8 @@ ANDROID_NDK_SYSROOT_FLAG_MAX = 19 # latest NDK that need --sysroot flag
|
||||
ANDROID_NDK_API_MIN = { 10: 3, 19: 16, 20: 16 } # minimal API level ndk revision supports
|
||||
ANDROID_64BIT_API_MIN = 21 # minimal API level that supports 64-bit targets
|
||||
|
||||
PSP_SDK_ENVVARS = ['PSPDEV', 'PSPSDK', 'PSPTOOLCHAIN']
|
||||
|
||||
# This class does support ONLY r10e and r19c/r20 NDK
|
||||
class Android:
|
||||
ctx = None # waf context
|
||||
@@ -320,11 +322,80 @@ class Android:
|
||||
ldflags += ['-march=armv5te']
|
||||
return ldflags
|
||||
|
||||
|
||||
|
||||
class PSP:
|
||||
ctx = None # waf context
|
||||
sdk_home = None
|
||||
psptoolchain_path = None
|
||||
pspsdk_path = None
|
||||
binutils_path = None
|
||||
module_type = None
|
||||
fw_version = None
|
||||
render_type = None
|
||||
|
||||
def __init__(self, ctx, moduletype, fwversion, rendertype):
|
||||
self.ctx = ctx
|
||||
self.module_type = moduletype
|
||||
self.fw_version = fwversion
|
||||
self.render_type = rendertype
|
||||
|
||||
for i in PSP_SDK_ENVVARS:
|
||||
self.sdk_home = os.getenv(i)
|
||||
if self.sdk_home != None:
|
||||
break
|
||||
else:
|
||||
ctx.fatal('Set %s environment variable pointing to the root of PSP SDK!' %
|
||||
' or '.join(PSP_SDK_ENVVARS))
|
||||
|
||||
self.psptoolchain_path = os.path.join(self.sdk_home, 'psp')
|
||||
self.pspsdk_path = os.path.join(self.psptoolchain_path, 'sdk')
|
||||
self.binutils_path = os.path.join(self.sdk_home, 'bin')
|
||||
|
||||
def cflags(self, cxx = False):
|
||||
cflags = []
|
||||
cflags += ['-I%s' % (os.path.join(self.pspsdk_path, 'include'))]
|
||||
# cflags += ['-I%s' % (os.path.join(self.psptoolchain_path, 'include'))]
|
||||
cflags += ['-I.']
|
||||
cflags += ['-D_PSP_FW_VERSION=%s' % self.fw_version, '-G0']
|
||||
return cflags
|
||||
# they go before object list
|
||||
def linkflags(self):
|
||||
linkflags = []
|
||||
# if self.module_type == 'prx':
|
||||
# linkflags += ['-specs=%s' % os.path.join(self.pspsdk_path, 'lib/prxspecs')]
|
||||
# linkflags += ['-Wl,-q,-T%s' % os.path.join(self.pspsdk_path, 'lib/linkfile.prx')]
|
||||
# linkflags += ['-Wl,--hash-style=sysv', '-Wl,--no-undefined', '-no-canonical-prefixes']
|
||||
return linkflags
|
||||
|
||||
def ldflags(self):
|
||||
ldflags = []
|
||||
if self.module_type == 'prx':
|
||||
ldflags += ['-specs=%s' % os.path.join(self.pspsdk_path, 'lib/prxspecs')]
|
||||
ldflags += ['-Wl,-q,-T%s' % os.path.join(self.pspsdk_path, 'lib/linkfile.prx')]
|
||||
ldflags += ['-L%s' % os.path.join(self.pspsdk_path, 'lib')]
|
||||
# ldflags += ['-L%s' % os.path.join(self.psptoolchain_path, 'lib')]
|
||||
ldflags += ['-L.']
|
||||
# ldflags += ['-lgcc', '-no-canonical-prefixes']
|
||||
return ldflags
|
||||
|
||||
def stdlibs(self):
|
||||
stdlibs = []
|
||||
stdlibs += ['-lpspdisplay', '-lpspgum_vfpu', '-lpspgu','-lpspge', '-lpspvfpu']
|
||||
stdlibs += ['-lpspaudiolib', '-lpspaudio']
|
||||
stdlibs += ['-lstdc++', '-lc', '-lm', '-lpspdebug', '-lpspctrl', '-lpspsdk', '-lpsprtc']
|
||||
stdlibs += ['-lpspnet', '-lpspnet_inet', '-lpspnet_apctl', '-lpspnet_resolver', '-lpsputility', '-lpspuser', '-lpspkernel', '-lpsppower']
|
||||
return stdlibs
|
||||
|
||||
def options(opt):
|
||||
android = opt.add_option_group('Android options')
|
||||
android.add_option('--android', action='store', dest='ANDROID_OPTS', default=None,
|
||||
help='enable building for android, format: --android=<arch>,<toolchain>,<api>, example: --android=armeabi-v7a-hard,4.9,9')
|
||||
|
||||
psp = opt.add_option_group('Sony PSP options')
|
||||
psp.add_option('--psp', action='store', dest='PSP_OPTS', default=None,
|
||||
help='enable building for Sony PSP, format: --psp=<module type>,<fw version>,<render type> example: --psp=prx,660,HW')
|
||||
|
||||
def configure(conf):
|
||||
if conf.options.ANDROID_OPTS:
|
||||
values = conf.options.ANDROID_OPTS.split(',')
|
||||
@@ -361,11 +432,98 @@ def configure(conf):
|
||||
# conf.env.ANDROID_OPTS = android
|
||||
conf.env.DEST_OS2 = 'android'
|
||||
|
||||
MACRO_TO_DESTOS = OrderedDict({ '__ANDROID__' : 'android' })
|
||||
if conf.options.PSP_OPTS:
|
||||
values = conf.options.PSP_OPTS.split(',')
|
||||
if len(values) != 3:
|
||||
conf.fatal('Invalid --psp paramater value!')
|
||||
|
||||
valid_module_type = ['elf', 'prx']
|
||||
valid_render_type = ['SW', 'HW', 'ALL']
|
||||
|
||||
if values[0] not in valid_module_type:
|
||||
conf.fatal('Unknown module type: %s. Supported: %r' % (values[0], ', '.join(valid_module_type)))
|
||||
if values[2] not in valid_render_type:
|
||||
conf.fatal('Unknown render type: %s. Supported: %r' % (values[2], ', '.join(valid_render_type)))
|
||||
|
||||
conf.psp = psp = PSP(conf, values[0], values[1], values[2])
|
||||
conf.environ['CC'] = os.path.join(psp.binutils_path, 'psp-gcc')
|
||||
conf.environ['CXX'] = os.path.join(psp.binutils_path, 'psp-gcc')
|
||||
conf.environ['AS'] = os.path.join(psp.binutils_path, 'psp-gcc')
|
||||
conf.environ['STRIP'] = os.path.join(psp.binutils_path, 'psp-strip')
|
||||
conf.environ['LD'] = os.path.join(psp.binutils_path, 'psp-gcc')
|
||||
conf.environ['AR'] = os.path.join(psp.binutils_path, 'psp-ar')
|
||||
conf.environ['RANLIB'] = os.path.join(psp.binutils_path, 'psp-ranlib')
|
||||
conf.environ['OBJCOPY'] = os.path.join(psp.binutils_path, 'psp-objcopy')
|
||||
|
||||
# conf.environ['PRXGEN'] = os.path.join(psp.binutils_path, 'prxgen')
|
||||
# conf.environ['MKSFO'] = os.path.join(psp.binutils_path, 'mksfoex')
|
||||
# conf.environ['PACK_PBP'] = os.path.join(psp.binutils_path, 'pack-pbp')
|
||||
# conf.environ['FIXUP'] = os.path.join(psp.binutils_path, 'psp-fixup-imports')
|
||||
|
||||
conf.env.PRXGEN = conf.find_program('psp-prxgen', path_list = psp.binutils_path)
|
||||
conf.env.MKSFO = conf.find_program('mksfoex', path_list = psp.binutils_path)
|
||||
conf.env.PACK_PBP = conf.find_program('pack-pbp', path_list = psp.binutils_path)
|
||||
conf.env.FIXUP = conf.find_program('psp-fixup-imports', path_list = psp.binutils_path)
|
||||
|
||||
conf.env.CFLAGS += psp.cflags()
|
||||
conf.env.CXXFLAGS += psp.cflags()
|
||||
conf.env.LINKFLAGS += psp.linkflags()
|
||||
conf.env.LDFLAGS += psp.ldflags()
|
||||
|
||||
conf.env.PREFIX = '/lib'
|
||||
|
||||
conf.msg('Selected PSPSDK', '%s' % (psp.sdk_home))
|
||||
# no need to print C/C++ compiler, as it would be printed by compiler_c/cxx
|
||||
conf.msg('... C/C++ flags', ' '.join(psp.cflags()).replace(psp.sdk_home, '$PSPSDK'))
|
||||
conf.msg('... link flags', ' '.join(psp.linkflags()).replace(psp.sdk_home, '$PSPSDK'))
|
||||
conf.msg('... ld flags', ' '.join(psp.ldflags()).replace(psp.sdk_home, '$PSPSDK'))
|
||||
|
||||
if conf.options.PROFILING:
|
||||
conf.env.LDFLAGS += ['-lpspprof']
|
||||
conf.env.CFLAGS += ['-pg']
|
||||
conf.env.LDFLAGS += psp.stdlibs()
|
||||
|
||||
conf.env.DEST_OS2 = 'psp'
|
||||
conf.env.PSP_RENDER_TYPE = psp.render_type
|
||||
conf.env.PSP_PATTERN_program = '%s'
|
||||
conf.env.PSP_PATTERN_stlib = 'lib%s.a'
|
||||
conf.env.PSP_PATTERN_shlib = '%s.elf'
|
||||
|
||||
if psp.module_type == 'prx':
|
||||
conf.env.PSP_BUILD_PRX = True
|
||||
|
||||
MACRO_TO_DESTOS = OrderedDict({ '__ANDROID__' : 'android', '__psp__' : 'psp'})
|
||||
for k in c_config.MACRO_TO_DESTOS:
|
||||
MACRO_TO_DESTOS[k] = c_config.MACRO_TO_DESTOS[k] # ordering is important
|
||||
c_config.MACRO_TO_DESTOS = MACRO_TO_DESTOS
|
||||
|
||||
def build(bld):
|
||||
if bld.env.DEST_OS == 'psp':
|
||||
bld(rule='${FIXUP} -o ${TGT} ${SRC}', source='engine/xash', target='xash.elf')
|
||||
if bld.env.PSP_BUILD_PRX:
|
||||
bld(rule='${PRXGEN} ${SRC} ${TGT}', source='xash.elf', target='xash.prx')
|
||||
bld(rule='${MKSFO} -d MEMSIZE=1 Xash3D ${TGT}', source='xash.prx', target='PARAM.SFO')
|
||||
bld(rule='${PACK_PBP} ${TGT} ${SRC[1]} ${PSP_EBOOT_ICON} ${PSP_EBOOT_ICON1} ${PSP_EBOOT_UNKPNG} ${PSP_EBOOT_PIC1} ${PSP_EBOOT_SND0} ${SRC[0]} ${PSP_EBOOT_PSAR}', source='xash.prx PARAM.SFO', target='EBOOT.PBP')
|
||||
else:
|
||||
bld(rule='${STRIP} -o ${TGT} ${SRC}', source='xash.elf', target='xash_strip.elf')
|
||||
bld(rule='${MKSFO} -d MEMSIZE=1 Xash3D ${TGT}', source='xash_strip.elf', target='PARAM.SFO')
|
||||
bld(rule='${PACK_PBP} ${TGT} ${SRC[1]} ${PSP_EBOOT_ICON} ${PSP_EBOOT_ICON1} ${PSP_EBOOT_UNKPNG} ${PSP_EBOOT_PIC1} ${PSP_EBOOT_SND0} ${SRC[0]} ${PSP_EBOOT_PSAR}', source='xash_strip.elf PARAM.SFO', target='EBOOT.PBP')
|
||||
# source_target = os.path.join('engine', bld.env.PSP_BUILD_TARGET)
|
||||
# Logs.info(source_target)
|
||||
# Logs.info(bld.env.PSP_BUILD_TARGET)
|
||||
# bld(rule='${FIXUP} -o ${PSP_BUILD_TARGET}.elf ${SRC}', source=source_target, always=True)
|
||||
# if bld.env.PSP_BUILD_PRX:
|
||||
# bld(rule='${PRXGEN} ${PSP_BUILD_TARGET}.elf ${PSP_BUILD_TARGET}.prx', always=True)
|
||||
# if bld.env.PSP_BUILD_EBOOT:
|
||||
# bld(rule='${MKSFO} -d MEMSIZE=1 ${PSP_EBOOT_TITLE} ${PSP_EBOOT_SFO}', always=True)
|
||||
# bld(rule='${PACK_PBP} ${PSP_EBOOT} ${PSP_EBOOT_SFO} ${PSP_EBOOT_ICON} ${PSP_EBOOT_ICON1} ${PSP_EBOOT_UNKPNG} ${PSP_EBOOT_PIC1} ${PSP_EBOOT_SND0} ${PSP_BUILD_TARGET}.prx ${PSP_EBOOT_PSAR}', always=True)
|
||||
# else:
|
||||
# if bld.env.PSP_BUILD_EBOOT:
|
||||
# bld(rule='${STRIP} -o ${PSP_BUILD_TARGET}.elf ${PSP_BUILD_TARGET}_strip.elf', always=True)
|
||||
# bld(rule='${MKSFO} -d MEMSIZE=1 ${PSP_EBOOT_TITLE} ${PSP_EBOOT_SFO}', always=True)
|
||||
# bld(rule='${PACK_PBP} ${PSP_EBOOT} ${PSP_EBOOT_SFO} ${PSP_EBOOT_ICON} ${PSP_EBOOT_ICON1} ${PSP_EBOOT_UNKPNG} ${PSP_EBOOT_PIC1} ${PSP_EBOOT_SND0} ${PSP_BUILD_TARGET}_strip.elf ${PSP_EBOOT_PSAR}', always=True)
|
||||
# bld(rule='rm -f ${PSP_BUILD_TARGET}_strip.elf', always=True)
|
||||
|
||||
def post_compiler_cxx_configure(conf):
|
||||
conf.msg('Target OS', conf.env.DEST_OS)
|
||||
conf.msg('Target CPU', conf.env.DEST_CPU)
|
||||
|
||||
Reference in New Issue
Block a user