mirror of https://github.com/FWGS/xash3d-fwgs
waifulib: nswitch: add new tool to faciliate NRO file generation. Add precompiled NACP file, icon and all needed changes in wscripts
This commit is contained in:
parent
2536b7ea2a
commit
905878bec0
Binary file not shown.
After Width: | Height: | Size: 7.7 KiB |
Binary file not shown.
|
@ -145,7 +145,7 @@ def build(bld):
|
|||
source += bld.path.ant_glob(['platform/stub/s_stub.c'])
|
||||
|
||||
if bld.env.DEST_OS == 'haiku':
|
||||
libs.append('HAIKU')
|
||||
libs += ['HAIKU']
|
||||
|
||||
if bld.get_define('XASH_CUSTOM_SWAP'):
|
||||
source += bld.path.ant_glob(['platform/misc/kmalloc.c', 'platform/misc/sbrk.c'])
|
||||
|
@ -155,11 +155,11 @@ def build(bld):
|
|||
is_cxx_link = True
|
||||
|
||||
if bld.env.HAVE_SDL2:
|
||||
libs.append('SDL2')
|
||||
libs += ['SDL2']
|
||||
source += bld.path.ant_glob(['platform/sdl/*.c'])
|
||||
|
||||
if bld.env.MAGX:
|
||||
libs.append('MAGX')
|
||||
libs += ['MAGX']
|
||||
source += bld.path.ant_glob(['platform/magx/*.cpp'])
|
||||
is_cxx_link = True
|
||||
|
||||
|
@ -170,7 +170,6 @@ def build(bld):
|
|||
if bld.env.DEST_OS == 'nswitch':
|
||||
libs += ['SOLDER']
|
||||
source += bld.path.ant_glob(['platform/nswitch/*.c'])
|
||||
is_cxx_link = True # switch-mesa requires libstdc++
|
||||
|
||||
# add client files
|
||||
if not bld.env.DEDICATED:
|
||||
|
@ -181,6 +180,20 @@ def build(bld):
|
|||
|
||||
includes = ['common', 'server', 'client', 'client/vgui', 'tests', '.', '../public', '../common', '../pm_shared' ]
|
||||
|
||||
# Switch has custom parameters
|
||||
if bld.env.DEST_OS == 'nswitch':
|
||||
bld(source = source,
|
||||
target = 'xash',
|
||||
features = 'c cxxprogram',
|
||||
includes = includes,
|
||||
use = libs,
|
||||
install_path = None,
|
||||
nro_install_path = bld.env.BINDIR,
|
||||
nacp = 'platform/nswitch/xash3d-fwgs.nacp',
|
||||
icon = 'platform/nswitch/icon.jpg')
|
||||
else:
|
||||
install_path = None
|
||||
|
||||
if bld.env.SINGLE_BINARY:
|
||||
install_path = bld.env.BINDIR
|
||||
program = 'cxxprogram' if is_cxx_link else 'cprogram'
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
# encoding: utf-8
|
||||
# nswitch.py -- switch NRO task
|
||||
# Copyright (C) 2018 a1batross
|
||||
# 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.
|
||||
|
||||
from waflib.Tools import ccroot
|
||||
from waflib import *
|
||||
|
||||
def configure(conf):
|
||||
conf.find_program('elf2nro')
|
||||
|
||||
v = conf.env
|
||||
|
||||
v.ELF2NRO_NACP_F = ['--nacp=']
|
||||
v.ELF2NRO_ICON_F = ['--icon=']
|
||||
|
||||
class elf2nro(Task.Task):
|
||||
color = 'RED'
|
||||
run_str = '${ELF2NRO} ${ELFFILE} ${TGT} ${ELF2NRO_NACP_F?NACP}${NACP} ${ELF2NRO_ICON_F?ICON}${ICON}'
|
||||
|
||||
def keyword(self):
|
||||
if Logs.colors_lst['USE']: # red/blue switch colors :)
|
||||
return '%sConverting to NRO' % Logs.colors_lst['CYAN']
|
||||
return 'Converting to NRO'
|
||||
|
||||
@TaskGen.feature('cxxprogram')
|
||||
@TaskGen.after_method('apply_link')
|
||||
def apply_nro(self):
|
||||
elffile = self.link_task.outputs[0]
|
||||
|
||||
nodes = [elffile]
|
||||
|
||||
def add_source_file(ctx, nodes, f):
|
||||
if f:
|
||||
if isinstance(f, str):
|
||||
node = ctx.path.make_node(f)
|
||||
elif isinstance(f, Node.Node):
|
||||
node = f
|
||||
|
||||
nodes += [node]
|
||||
return node
|
||||
return None
|
||||
|
||||
nacpfile = add_source_file(self, nodes, getattr(self, 'nacp', None))
|
||||
iconfile = add_source_file(self, nodes, getattr(self, 'icon', None))
|
||||
self.env.ELFFILE = str(elffile)
|
||||
if nacpfile: self.env.NACP = str(nacpfile)
|
||||
if iconfile: self.env.ICON = str(iconfile)
|
||||
|
||||
tsk = self.nro_task = self.create_task('elf2nro', nodes)
|
||||
self.nro_task.set_outputs(nodes[0].change_ext('.nro'))
|
||||
|
||||
inst_to = getattr(self, 'nro_install_path', None)
|
||||
if inst_to:
|
||||
self.add_install_files(install_to=inst_to,
|
||||
install_from=tsk.outputs[:], chmod=Utils.O755, task=tsk)
|
|
@ -500,7 +500,6 @@ def configure(conf):
|
|||
conf.env.LDFLAGS += nswitch.ldflags()
|
||||
conf.env.HAVE_M = True
|
||||
conf.env.LIB_M = ['m']
|
||||
conf.env.PREFIX = ''
|
||||
conf.env.DEST_OS = 'nswitch'
|
||||
|
||||
conf.env.MAGX = conf.options.MAGX
|
||||
|
|
5
wscript
5
wscript
|
@ -130,6 +130,9 @@ def configure(conf):
|
|||
# Load compilers early
|
||||
conf.load('xshlib xcompile compiler_c compiler_cxx')
|
||||
|
||||
if conf.options.NSWITCH:
|
||||
conf.load('nswitch')
|
||||
|
||||
# HACKHACK: override msvc DEST_CPU value by something that we understand
|
||||
if conf.env.DEST_CPU == 'amd64':
|
||||
conf.env.DEST_CPU = 'x86_64'
|
||||
|
@ -339,7 +342,7 @@ def configure(conf):
|
|||
conf.env.LIBDIR = conf.env.BINDIR = '${PREFIX}/lib/xash3d'
|
||||
conf.env.SHAREDIR = '${PREFIX}/share/xash3d'
|
||||
else:
|
||||
if sys.platform != 'win32' and conf.env.DEST_OS not in ['android', 'nswitch']:
|
||||
if sys.platform != 'win32' and conf.env.DEST_OS not in ['android']:
|
||||
conf.env.PREFIX = '/'
|
||||
|
||||
conf.env.SHAREDIR = conf.env.LIBDIR = conf.env.BINDIR = conf.env.PREFIX
|
||||
|
|
Loading…
Reference in New Issue