mirror of
https://github.com/FWGS/xash3d-fwgs.git
synced 2026-08-08 21:31:46 +08:00
Compare commits
4 Commits
continuous
...
continuous
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
119926805f | ||
|
|
f749b5cb4b | ||
|
|
c29ad6b598 | ||
|
|
4c5dfb963e |
2
3rdparty/mainui
vendored
2
3rdparty/mainui
vendored
Submodule 3rdparty/mainui updated: 46d05f9ff5...da084b47f6
2
3rdparty/nanogl
vendored
2
3rdparty/nanogl
vendored
Submodule 3rdparty/nanogl updated: 76393a8fde...f48735b730
@@ -251,6 +251,7 @@ void _Mem_Free( void *data, const char *filename, int fileline )
|
||||
void *_Mem_Realloc( poolhandle_t poolptr, void *data, size_t size, qboolean clear, const char *filename, int fileline )
|
||||
{
|
||||
memheader_t *mem;
|
||||
uintptr_t oldmem;
|
||||
mempool_t *pool;
|
||||
size_t oldsize;
|
||||
|
||||
@@ -288,17 +289,29 @@ void *_Mem_Realloc( poolhandle_t poolptr, void *data, size_t size, qboolean clea
|
||||
#else // XASH_CUSTOM_SWAP
|
||||
pool = Mem_FindPool( poolptr );
|
||||
|
||||
oldmem = (uintptr_t)mem;
|
||||
mem = realloc( mem, sizeof( memheader_t ) + size + sizeof( byte ));
|
||||
|
||||
if( mem == NULL )
|
||||
{
|
||||
Sys_Error( "Mem_Realloc: out of memory (alloc size %s at %s:%i)\n", Q_memprint( size ), filename, fileline );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Mem_PoolSubtract( pool, oldsize );
|
||||
Mem_PoolAdd( pool, size );
|
||||
// Con_Printf( S_NOTE "%s: mem %s oldmem, size before %zu now %zu (alloc at %s:%i)\n",
|
||||
// __func__, (uintptr_t)mem != oldmem ? "!=" : "==", oldsize, size, filename, fileline );
|
||||
|
||||
Mem_InitAlloc( mem, size, filename, fileline );
|
||||
|
||||
if( size > oldsize )
|
||||
{
|
||||
Mem_PoolAdd( pool, size - oldsize );
|
||||
|
||||
if( clear )
|
||||
memset((byte *)mem + sizeof( memheader_t ) + oldsize, 0, size - oldsize );
|
||||
}
|
||||
else Mem_PoolSubtract( pool, oldsize - size );
|
||||
|
||||
// if allocation was migrated from one pool to another
|
||||
// (this is possible with original Mem_Realloc func)
|
||||
if( unlikely( mem->pool != pool ))
|
||||
@@ -306,17 +319,13 @@ void *_Mem_Realloc( poolhandle_t poolptr, void *data, size_t size, qboolean clea
|
||||
Mem_PoolUnlinkAlloc( mem->pool, mem );
|
||||
Mem_PoolLinkAlloc( pool, mem );
|
||||
}
|
||||
else
|
||||
else if( oldmem != (uintptr_t)mem ) // just relink pointers
|
||||
{
|
||||
if( mem->next ) mem->next->prev = mem;
|
||||
if( mem->prev ) mem->prev->next = mem;
|
||||
else pool->chain = mem;
|
||||
}
|
||||
|
||||
// clear new memory
|
||||
if( clear && size > oldsize )
|
||||
memset((byte *)mem + sizeof( memheader_t ) + oldsize, 0, size - oldsize );
|
||||
|
||||
return (void *)((byte *)mem + sizeof( memheader_t ));
|
||||
#endif // XASH_CUSTOM_SWAP
|
||||
}
|
||||
|
||||
@@ -116,6 +116,22 @@ POLLY_CFLAGS = {
|
||||
# msvc sosat :(
|
||||
}
|
||||
|
||||
PROFILE_GENERATE_CFLAGS = {
|
||||
'gcc': ['-fprofile-generate=xash3d-prof'],
|
||||
}
|
||||
|
||||
PROFILE_GENERATE_LINKFLAGS = {
|
||||
'gcc': ['-fprofile-generate=xash3d-prof'],
|
||||
}
|
||||
|
||||
PROFILE_USE_CFLAGS = {
|
||||
'gcc': ['-fprofile-use=%s'],
|
||||
}
|
||||
|
||||
PROFILE_USE_LINKFLAGS = {
|
||||
'gcc': ['-fprofile-use=%s'],
|
||||
}
|
||||
|
||||
def options(opt):
|
||||
grp = opt.add_option_group('Compiler optimization options')
|
||||
|
||||
@@ -128,6 +144,12 @@ def options(opt):
|
||||
grp.add_option('--enable-poly-opt', action = 'store_true', dest = 'POLLY', default = False,
|
||||
help = 'enable polyhedral optimization if possible [default: %default]')
|
||||
|
||||
grp.add_option('--enable-profile', action = 'store_true', dest = 'PROFILE_GENERATE', default = False,
|
||||
help = 'enable profile generating build (stored in xash3d-prof directory) [default: %default]')
|
||||
|
||||
grp.add_option('--use-profile', action = 'store', dest = 'PROFILE_USE', default = None,
|
||||
help = 'use profile during build [default: %default]')
|
||||
|
||||
def configure(conf):
|
||||
conf.start_msg('Build type')
|
||||
|
||||
@@ -144,6 +166,8 @@ def configure(conf):
|
||||
|
||||
conf.msg('LTO build', 'yes' if conf.options.LTO else 'no')
|
||||
conf.msg('PolyOpt build', 'yes' if conf.options.POLLY else 'no')
|
||||
conf.msg('Generate profile', 'yes' if conf.options.PROFILE_GENERATE else 'no')
|
||||
conf.msg('Use profile', conf.options.PROFILE_USE if not conf.options.PROFILE_GENERATE else 'no')
|
||||
|
||||
# -march=native should not be used
|
||||
if conf.options.BUILD_TYPE.startswith('fast'):
|
||||
@@ -174,6 +198,13 @@ def get_optimization_flags(conf):
|
||||
if conf.options.POLLY:
|
||||
cflags += conf.get_flags_by_compiler(POLLY_CFLAGS, conf.env.COMPILER_CC)
|
||||
|
||||
if conf.options.PROFILE_GENERATE:
|
||||
linkflags+= conf.get_flags_by_compiler(PROFILE_GENERATE_LINKFLAGS, conf.env.COMPILER_CC)
|
||||
cflags += conf.get_flags_by_compiler(PROFILE_GENERATE_CFLAGS, conf.env.COMPILER_CC)
|
||||
elif conf.options.PROFILE_USE:
|
||||
linkflags+= [conf.get_flags_by_compiler(PROFILE_USE_LINKFLAGS, conf.env.COMPILER_CC)[0] % conf.options.PROFILE_USE]
|
||||
cflags += [conf.get_flags_by_compiler(PROFILE_USE_CFLAGS, conf.env.COMPILER_CC)[0] % conf.options.PROFILE_USE]
|
||||
|
||||
if conf.env.DEST_OS == 'nswitch' and conf.options.BUILD_TYPE == 'debug':
|
||||
# enable remote debugger
|
||||
cflags.append('-DNSWITCH_DEBUG')
|
||||
|
||||
82
scripts/waifulib/psp.py
Normal file
82
scripts/waifulib/psp.py
Normal file
@@ -0,0 +1,82 @@
|
||||
# encoding: utf-8
|
||||
# psp.py -- PSP EBOOT task
|
||||
# Copyright (C) 2023 Sergey Galushko
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
##################################
|
||||
# PSP Tools #
|
||||
##################################
|
||||
class psp_fixup(Task.Task):
|
||||
run_str = '${FIXUP} -o ${TGT} ${SRC}'
|
||||
color = 'BLUE'
|
||||
|
||||
class psp_prxgen(Task.Task):
|
||||
run_str = '${PRXGEN} ${SRC} ${TGT}'
|
||||
color = 'BLUE'
|
||||
|
||||
class psp_strip(Task.Task):
|
||||
run_str = '${STRIP} -o ${TGT} ${SRC}'
|
||||
color = 'BLUE'
|
||||
|
||||
class psp_mksfo(Task.Task):
|
||||
run_str = '${MKSFO} -d MEMSIZE=1 ${PSP_EBOOT_TITLE} ${TGT}'
|
||||
color = 'YELLOW'
|
||||
|
||||
class psp_packpbp(Task.Task):
|
||||
run_str = '${PACK_PBP} ${TGT} ${SRC[1].abspath()} ${PSP_EBOOT_ICON} ${PSP_EBOOT_ICON1} ${PSP_EBOOT_UNKPNG} ${PSP_EBOOT_PIC1} ${PSP_EBOOT_SND0} ${SRC[0].abspath()} ${PSP_EBOOT_PSAR}'
|
||||
color = 'GREEN'
|
||||
|
||||
|
||||
@TaskGen.feature('cshlib', 'cxxshlib')
|
||||
@TaskGen.after_method('apply_link')
|
||||
def build_module(self):
|
||||
link_output = self.link_task.outputs[0]
|
||||
for d in self.env.STATIC_LINKING:
|
||||
if link_output.name.startswith(d):
|
||||
return
|
||||
fixup_output = self.path.find_or_declare(link_output.name + '_fixup')
|
||||
prxgen_output = self.path.find_or_declare(link_output.change_ext('.prx').name)
|
||||
|
||||
task = self.create_task('psp_fixup', src=link_output, tgt=fixup_output)
|
||||
task = self.create_task('psp_prxgen', src=fixup_output, tgt=prxgen_output)
|
||||
|
||||
if getattr(self, 'install_path', None):
|
||||
if self.bld.is_install:
|
||||
for k in self.install_task.inputs:
|
||||
if k == self.path.find_or_declare(link_output.name):
|
||||
self.install_task.inputs.remove(k)
|
||||
self.add_install_files(install_to=self.install_path, install_from=prxgen_output)
|
||||
|
||||
@TaskGen.feature('cprogram', 'cxxprogram', 'cprogram_static', 'cxxprogram_static')
|
||||
@TaskGen.after_method('apply_link')
|
||||
def build_eboot(self):
|
||||
finalobj_ext = '.elf'
|
||||
finalobj_tool = 'psp_strip'
|
||||
if self.env.PSP_BUILD_PRX:
|
||||
finalobj_ext = '.prx'
|
||||
finalobj_tool = 'psp_prxgen'
|
||||
|
||||
link_output = self.link_task.outputs[0]
|
||||
fixup_output = self.path.find_or_declare(link_output.name + '_fixup')
|
||||
finalobj_output = self.path.find_or_declare(link_output.change_ext(finalobj_ext).name)
|
||||
|
||||
mksfo_output = self.path.find_or_declare('PARAM.SFO')
|
||||
packpbp_output = self.path.find_or_declare('EBOOT.PBP')
|
||||
|
||||
task = self.create_task('psp_fixup', src=link_output, tgt=fixup_output)
|
||||
task = self.create_task(finalobj_tool, src=fixup_output, tgt=finalobj_output)
|
||||
task = self.create_task('psp_mksfo', tgt=mksfo_output)
|
||||
task = self.create_task('psp_packpbp', src=[finalobj_output, mksfo_output], tgt=packpbp_output)
|
||||
|
||||
if getattr(self, 'install_path', None):
|
||||
if getattr(self, 'install_task', None):
|
||||
self.install_task.inputs = self.install_task.outputs = []
|
||||
self.add_install_files(install_to=self.install_path, install_from=[packpbp_output, finalobj_output])
|
||||
Reference in New Issue
Block a user