2008-03-31 13:28:15 +00:00
# vi: syntax=python:et:ts=4
2008-01-25 03:27:44 +00:00
#
# SCons build description for the Wesnoth project
#
2008-03-29 11:28:18 +00:00
# Prerequisites are:
2013-03-26 14:44:47 +00:00
# 1. autorevision for getting the repository revision level.
2011-02-12 16:52:50 +00:00
# 2. msgfmt(1) for making builds with i18n support.
# 3. graph-includes for making the project dependency graph.
2008-03-29 12:16:27 +00:00
2009-03-20 12:04:48 +00:00
EnsureSConsVersion ( 0 , 98 , 3 )
Add CMake and SCons options to use system Lua 5.4 C++
scons/lua.py makes use of the vestigial luadir option from commit
e94dcecf171.
Like FindLua.cmake, scons/lua.py searches for the Lua headers and
library, instead of using pkg-config like the old scons/lua.py (removed
in commit 9929d3ca1cf) did, because even though distributions typically
provide .pc files for Lua, upstream Lua doesn't. It's likely that all
distributions that compile Lua as a C++ library will also provide .pc
files, but this check doesn't rely on that (just as the CMake module
doesn't).
Unfortunately, SCons.Conftest.CheckLib() prints up to eight messages
like "Checking for C++ library lua54-c++... no" until a working library
name is found.
Also conditionally include system Lua headers in src/lua/*.h and update
documentation in src/modules/lua_README.md, src/wesnoth_lua_config.h,
and src/wesnoth_lua_config.md. The two lines about "The primary commit,
after replacing the sources," in src/wesnoth_lua_config.md don't make
sense since the instructions were updated for submodule Lua in commit
d32cfb88c4f and make even less sense now with preceding commits for
updating CMake modules.
2024-01-06 23:54:56 +00:00
lua_ver = " 5.4 "
2017-09-20 13:22:21 +00:00
import os , sys , shutil , re , subprocess
2008-03-30 21:06:25 +00:00
from glob import glob
2018-02-28 02:03:40 +00:00
from subprocess import Popen , PIPE , call , check_output
2008-04-06 13:55:17 +00:00
from os import access , F_OK
2008-01-25 22:34:36 +00:00
2008-04-01 15:49:22 +00:00
# Warn user of current set of build options.
2013-06-11 11:31:53 +00:00
AddOption ( ' --option-cache ' , dest = ' option_cache ' , nargs = 1 , type = ' string ' , action = ' store ' , metavar = ' FILE ' , help = ' file with cached construction variables ' , default = ' .scons-option-cache ' )
2017-11-04 07:20:09 +00:00
if GetOption ( " option_cache " ) != " " and os . path . exists ( GetOption ( " option_cache " ) ) :
2017-10-11 13:36:20 +00:00
optfile = open ( GetOption ( " option_cache " ) )
2017-09-21 09:45:00 +00:00
print ( " Saved options: {} " . format ( optfile . read ( ) . replace ( " \n " , " , " ) [ : - 2 ] ) )
2008-04-01 15:49:22 +00:00
optfile . close ( )
2010-01-26 03:12:25 +00:00
#
# Get the Wesnoth version number
#
config_h_re = re . compile ( r " ^.*#define \ s*( \ S*) \ s* \" ( \ S*) \" .*$ " , re . MULTILINE )
2017-10-11 13:36:20 +00:00
build_config = dict ( config_h_re . findall ( File ( " src/wesconfig.h " ) . get_contents ( ) . decode ( " utf-8 " ) ) )
2010-01-26 03:12:25 +00:00
try :
version = build_config [ " VERSION " ]
2017-09-20 13:04:50 +00:00
print ( " Building Wesnoth version %s " % version )
2010-01-26 03:12:25 +00:00
except KeyError :
2017-09-20 13:04:50 +00:00
print ( " Couldn ' t determine the Wesnoth version number, bailing out! " )
2010-01-26 03:12:25 +00:00
sys . exit ( 1 )
2008-01-25 03:27:44 +00:00
#
# Build-control options
#
2013-06-11 11:31:53 +00:00
opts = Variables ( GetOption ( " option_cache " ) )
2008-01-25 17:28:44 +00:00
2008-06-24 20:43:09 +00:00
def OptionalPath ( key , val , env ) :
if val :
2009-03-20 12:04:53 +00:00
PathVariable . PathIsDir ( key , val , env )
2008-06-24 20:43:09 +00:00
2009-03-20 12:04:53 +00:00
opts . AddVariables (
ListVariable ( ' default_targets ' , ' Targets that will be built if no target is specified in command line. ' ,
2017-11-02 02:26:37 +00:00
" wesnoth,wesnothd " , Split ( " wesnoth wesnothd campaignd boost_unit_tests " ) ) ,
2021-06-08 21:12:03 +00:00
EnumVariable ( ' build ' , ' Build variant: release, debug, or profile ' , " release " , [ " release " , " debug " ] ) ,
2009-06-27 19:13:15 +00:00
PathVariable ( ' build_dir ' , ' Build all intermediate files(objects, test programs, etc) under this dir ' , " build " , PathVariable . PathAccept ) ,
2016-06-17 10:22:54 +00:00
( ' extra_flags_config ' , " Extra compiler and linker flags to use for configuration and all builds. Whether they ' re compiler or linker is determined by env.ParseFlags. Unknown flags are compile flags by default. This applies to all extra_flags_* variables " , " " ) ,
2008-05-10 14:43:25 +00:00
( ' extra_flags_release ' , ' Extra compiler and linker flags to use for release builds ' , " " ) ,
( ' extra_flags_debug ' , ' Extra compiler and linker flags to use for debug builds ' , " " ) ,
2008-05-13 12:48:04 +00:00
( ' extra_flags_profile ' , ' Extra compiler and linker flags to use for profile builds ' , " " ) ,
2018-02-12 06:11:50 +00:00
BoolVariable ( ' enable_lto ' , ' Whether to enable Link Time Optimization for build=release ' , False ) ,
2017-09-30 18:32:41 +00:00
( ' arch ' , ' What -march option to use for build=release, will default to pentiumpro on Windows ' , " " ) ,
2018-04-20 17:29:07 +00:00
( ' opt ' , ' override for the build \' s optimization level ' , " " ) ,
2018-06-15 06:31:31 +00:00
BoolVariable ( ' harden ' , ' Whether to enable options to harden the executables ' , True ) ,
2023-02-25 10:44:06 +00:00
BoolVariable ( ' glibcxx_assertions ' , ' Whether to define _GLIBCXX_ASSERTIONS for build=debug ' , False ) ,
BoolVariable ( ' glibcxx_debug ' , " Whether to define _GLIBCXX_DEBUG and _GLIBCXX_DEBUG_PEDANTIC for build=debug. Requires a version of Boost ' s program_options that ' s compiled with __GLIBCXX_DEBUG too. " , False ) ,
2021-06-08 21:12:03 +00:00
EnumVariable ( ' profiler ' , ' profiler to be used ' , " " , [ " " , " gprof " , " gcov " , " gperftools " , " perf " ] ) ,
2017-10-25 13:02:30 +00:00
EnumVariable ( ' pgo_data ' , ' whether to generate profiling data for PGO, or use existing profiling data ' , " " , [ " " , " generate " , " use " ] ) ,
2017-10-27 22:51:06 +00:00
BoolVariable ( ' use_srcdir ' , ' Whether to place object files in src/ or not ' , False ) ,
2009-03-20 12:04:53 +00:00
PathVariable ( ' bindir ' , ' Where to install binaries ' , " bin " , PathVariable . PathAccept ) ,
2008-05-01 16:41:06 +00:00
( ' cachedir ' , ' Directory that contains a cache of derived files. ' , ' ' ) ,
2009-03-20 12:04:53 +00:00
PathVariable ( ' datadir ' , ' read-only architecture-independent game data ' , " $datarootdir/$datadirname " , PathVariable . PathAccept ) ,
PathVariable ( ' fifodir ' , ' directory for the wesnothd fifo socket file ' , " /var/run/wesnothd " , PathVariable . PathAccept ) ,
BoolVariable ( ' desktop_entry ' , ' Clear to disable desktop-entry ' , True ) ,
2017-11-03 13:10:55 +00:00
BoolVariable ( ' appdata_file ' , ' Clear to not install appdata file ' , True ) ,
2021-04-24 22:47:15 +00:00
BoolVariable ( ' systemd ' , ' Install systemd unit file for wesnothd ' , bool ( WhereIs ( " systemctl " ) ) ) ,
2009-03-20 12:04:53 +00:00
PathVariable ( ' datarootdir ' , ' sets the root of data directories to a non-default location ' , " share " , PathVariable . PathAccept ) ,
PathVariable ( ' datadirname ' , ' sets the name of data directory ' , " wesnoth$version_suffix " , PathVariable . PathAccept ) ,
PathVariable ( ' desktopdir ' , ' sets the desktop entry directory to a non-default location ' , " $datarootdir/applications " , PathVariable . PathAccept ) ,
PathVariable ( ' icondir ' , ' sets the icons directory to a non-default location ' , " $datarootdir/icons " , PathVariable . PathAccept ) ,
2017-11-03 13:10:55 +00:00
PathVariable ( ' appdatadir ' , ' sets the appdata directory to a non-default location ' , " $datarootdir/metainfo " , PathVariable . PathAccept ) ,
2009-03-20 12:04:53 +00:00
BoolVariable ( ' internal_data ' , ' Set to put data in Mac OS X application fork ' , False ) ,
PathVariable ( ' localedirname ' , ' sets the locale data directory to a non-default location ' , " translations " , PathVariable . PathAccept ) ,
PathVariable ( ' mandir ' , ' sets the man pages directory to a non-default location ' , " $datarootdir/man " , PathVariable . PathAccept ) ,
PathVariable ( ' docdir ' , ' sets the doc directory to a non-default location ' , " $datarootdir/doc/wesnoth " , PathVariable . PathAccept ) ,
PathVariable ( ' python_site_packages_dir ' , ' sets the directory where python modules are installed ' , " lib/python/site-packages/wesnoth " , PathVariable . PathAccept ) ,
2009-08-10 09:47:58 +00:00
BoolVariable ( ' notifications ' , ' Enable support for desktop notifications ' , True ) ,
2009-03-20 12:04:53 +00:00
BoolVariable ( ' nls ' , ' enable compile/install of gettext message catalogs ' , True ) ,
PathVariable ( ' prefix ' , ' autotools-style installation prefix ' , " /usr/local " , PathVariable . PathAccept ) ,
2010-10-15 01:24:24 +00:00
PathVariable ( ' prefsdir ' , ' user preferences directory ' , " " , PathVariable . PathAccept ) ,
2012-03-05 22:36:26 +00:00
PathVariable ( ' default_prefs_file ' , ' default preferences file name ' , " " , PathVariable . PathAccept ) ,
2009-03-20 12:04:53 +00:00
PathVariable ( ' destdir ' , ' prefix to add to all installation paths. ' , " / " , PathVariable . PathAccept ) ,
BoolVariable ( ' prereqs ' , ' abort if prerequisites cannot be detected ' , True ) ,
2008-06-13 08:42:18 +00:00
( ' program_suffix ' , ' suffix to append to names of installed programs ' , " $version_suffix " ) ,
( ' version_suffix ' , ' suffix that will be added to default values of prefsdir, program_suffix and datadirname ' , " " ) ,
2021-03-09 05:16:58 +00:00
BoolVariable ( ' forum_user_handler ' , ' Enable forum user handler in wesnothd and campaignd ' , False ) ,
2008-05-01 16:41:06 +00:00
( ' server_gid ' , ' group id of the user who runs wesnothd ' , " " ) ,
( ' server_uid ' , ' user id of the user who runs wesnothd ' , " " ) ,
2009-03-20 12:04:53 +00:00
BoolVariable ( ' strict ' , ' Set to strict compilation ' , False ) ,
2017-12-04 14:11:04 +00:00
BoolVariable ( ' pedantic ' , ' Set to pedantic compilation ' , False ) ,
2009-03-20 12:04:53 +00:00
BoolVariable ( ' static_test ' , ' Staticaly build against boost test (Not supported yet) ' , False ) ,
BoolVariable ( ' verbose ' , ' Emit progress messages during data installation. ' , False ) ,
PathVariable ( ' sdldir ' , ' Directory of SDL installation. ' , " " , OptionalPath ) ,
PathVariable ( ' boostdir ' , ' Directory of boost installation. ' , " " , OptionalPath ) ,
PathVariable ( ' boostlibdir ' , ' Directory where boost libraries are installed. ' , " " , OptionalPath ) ,
2008-05-01 16:41:06 +00:00
( ' boost_suffix ' , ' Suffix of boost libraries. ' ) ,
2018-03-09 00:35:31 +00:00
PathVariable ( ' gettextdir ' , ' Root directory of Gettext \' s installation. ' , " " , OptionalPath ) ,
2009-03-20 12:04:53 +00:00
PathVariable ( ' gtkdir ' , ' Directory where GTK SDK is installed. ' , " " , OptionalPath ) ,
Add CMake and SCons options to use system Lua 5.4 C++
scons/lua.py makes use of the vestigial luadir option from commit
e94dcecf171.
Like FindLua.cmake, scons/lua.py searches for the Lua headers and
library, instead of using pkg-config like the old scons/lua.py (removed
in commit 9929d3ca1cf) did, because even though distributions typically
provide .pc files for Lua, upstream Lua doesn't. It's likely that all
distributions that compile Lua as a C++ library will also provide .pc
files, but this check doesn't rely on that (just as the CMake module
doesn't).
Unfortunately, SCons.Conftest.CheckLib() prints up to eight messages
like "Checking for C++ library lua54-c++... no" until a working library
name is found.
Also conditionally include system Lua headers in src/lua/*.h and update
documentation in src/modules/lua_README.md, src/wesnoth_lua_config.h,
and src/wesnoth_lua_config.md. The two lines about "The primary commit,
after replacing the sources," in src/wesnoth_lua_config.md don't make
sense since the instructions were updated for submodule Lua in commit
d32cfb88c4f and make even less sense now with preceding commits for
updating CMake modules.
2024-01-06 23:54:56 +00:00
BoolVariable ( ' system_lua ' , ' Enable use of system Lua ' + lua_ver + ' (compiled as C++, only for non-Windows systems). ' , False ) ,
2009-03-23 01:26:52 +00:00
PathVariable ( ' luadir ' , ' Directory where Lua binary package is unpacked. ' , " " , OptionalPath ) ,
2008-06-23 19:52:02 +00:00
( ' host ' , ' Cross-compile host. ' , ' ' ) ,
2015-12-02 13:20:55 +00:00
EnumVariable ( ' multilib_arch ' , ' Address model for multilib compiler: 32-bit or 64-bit ' , " " , [ " " , " 32 " , " 64 " ] ) ,
2008-10-31 21:00:34 +00:00
( ' jobs ' , ' Set the number of parallel compilations ' , " 1 " , lambda key , value , env : int ( value ) , int ) ,
2009-03-20 12:04:53 +00:00
BoolVariable ( ' distcc ' , ' Use distcc ' , False ) ,
BoolVariable ( ' ccache ' , " Use ccache " , False ) ,
2015-12-02 13:02:53 +00:00
( ' ctool ' , ' Set c compiler command if not using standard compiler. ' ) ,
2008-06-24 20:43:09 +00:00
( ' cxxtool ' , ' Set c++ compiler command if not using standard compiler. ' ) ,
2021-01-16 22:18:30 +00:00
EnumVariable ( ' cxx_std ' , ' Target c++ std version ' , ' 17 ' , [ ' 17 ' , ' 20 ' ] ) ,
2016-06-17 09:51:46 +00:00
( ' sanitize ' , ' Enable clang and GCC sanitizer functionality. A comma separated list of sanitize suboptions must be passed as value. ' , ' ' ) ,
2009-10-10 11:00:12 +00:00
BoolVariable ( " fast " , " Make scons faster at cost of less precise dependency tracking. " , False ) ,
2018-12-27 11:39:31 +00:00
BoolVariable ( " autorevision " , ' Use autorevision tool to fetch current git revision that will be embedded in version string ' , True ) ,
2014-03-08 20:24:37 +00:00
BoolVariable ( " lockfile " , " Create a lockfile to prevent multiple instances of scons from being run at the same time on this working copy. " , False ) ,
2014-11-02 03:13:23 +00:00
BoolVariable ( " OS_ENV " , " Forward the entire OS environment to scons " , False ) ,
2022-06-08 10:44:33 +00:00
BoolVariable ( " history " , " Clear to disable GNU history support in lua console " , True ) ,
BoolVariable ( ' force_color ' , ' Always produce ANSI-colored output (GNU/Clang only). ' , False ) ,
2008-05-01 16:41:06 +00:00
)
2008-03-24 15:04:08 +00:00
2008-01-25 22:34:36 +00:00
#
2008-01-26 00:18:31 +00:00
# Setup
2008-01-25 03:27:44 +00:00
#
2008-01-26 00:18:31 +00:00
2014-05-02 13:24:35 +00:00
toolpath = [ " scons " ]
for repo in Dir ( " . " ) . repositories :
# SCons repositories are additional dirs to look for source and lib files.
# It is possible to make out of tree builds by running SCons outside of this
# source code root and supplying this path with -Y option.
toolpath . append ( repo . abspath + " /scons " )
2014-03-22 13:44:25 +00:00
sys . path = toolpath + sys . path
2020-12-14 12:58:39 +00:00
env = Environment ( tools = [ " tar " , " gettext_tool " , " install " , " scanreplace " ] , options = opts , toolpath = toolpath )
2008-06-23 12:44:24 +00:00
2009-10-10 11:00:12 +00:00
if env [ " lockfile " ] :
2017-09-20 13:04:50 +00:00
print ( " Creating lockfile " )
2009-10-10 11:00:12 +00:00
lockfile = os . path . abspath ( " scons.lock " )
2020-02-22 23:32:50 +00:00
if sys . version_info . major > = 3 :
create = " x "
else :
create = " wx "
open ( lockfile , create ) . write ( str ( os . getpid ( ) ) )
2009-10-10 11:00:12 +00:00
import atexit
atexit . register ( os . remove , lockfile )
2017-11-04 07:20:09 +00:00
if GetOption ( " option_cache " ) != " " :
opts . Save ( GetOption ( " option_cache " ) , env )
2009-06-27 19:13:15 +00:00
env . SConsignFile ( " $build_dir/sconsign.dblite " )
2008-06-23 19:52:02 +00:00
2014-11-02 03:13:23 +00:00
# If OS_ENV was enabled, copy the entire OS environment.
if env [ ' OS_ENV ' ] :
env [ ' ENV ' ] = os . environ
2008-09-04 19:44:06 +00:00
# Make sure the user's environment is always available
2013-12-10 02:29:11 +00:00
env [ ' ENV ' ] [ ' PATH ' ] = os . environ . get ( " PATH " )
2014-11-02 05:06:39 +00:00
term = os . environ . get ( ' TERM ' )
if term is not None :
env [ ' ENV ' ] [ ' TERM ' ] = term
2008-05-02 11:41:03 +00:00
if env [ " PLATFORM " ] == " win32 " :
env . Tool ( " mingw " )
else :
2008-06-23 19:52:02 +00:00
from cross_compile import *
setup_cross_compile ( env )
2008-03-21 15:28:19 +00:00
2022-10-22 20:54:31 +00:00
if sys . platform != ' win32 ' :
env . Tool ( " system_include " )
2016-01-04 15:44:02 +00:00
2015-12-02 13:02:53 +00:00
if ' HOME ' in os . environ :
env [ ' ENV ' ] [ ' HOME ' ] = os . environ [ ' HOME ' ]
if env . get ( ' ctool ' , " " ) :
env [ ' CC ' ] = env [ ' ctool ' ]
env [ ' CXX ' ] = env [ ' ctool ' ] . rstrip ( " cc " ) + " ++ "
2008-06-23 13:01:26 +00:00
if env . get ( ' cxxtool ' , " " ) :
2008-08-12 20:01:52 +00:00
env [ ' CXX ' ] = env [ ' cxxtool ' ]
2008-06-23 12:44:24 +00:00
2008-10-31 21:00:34 +00:00
if env [ ' jobs ' ] > 1 :
SetOption ( " num_jobs " , env [ ' jobs ' ] )
2017-09-30 18:32:41 +00:00
else :
env [ ' jobs ' ] = 1
2008-10-31 21:00:34 +00:00
2018-03-09 00:35:31 +00:00
if env [ ' distcc ' ] :
2008-08-22 16:53:42 +00:00
env . Tool ( ' distcc ' )
2008-10-31 21:00:34 +00:00
2008-06-27 11:52:19 +00:00
if env [ ' ccache ' ] : env . Tool ( ' ccache ' )
2024-09-08 15:25:45 +00:00
boost_version = " 1.67 "
2008-06-27 11:52:19 +00:00
2018-03-27 06:52:23 +00:00
def SortHelpText ( a , b ) :
return ( a > b ) - ( a < b )
2008-08-05 11:53:30 +00:00
Help ( """ Arguments may be a mixture of switches and targets in any order.
Switches apply to the entire build regardless of where they are in the order .
2008-03-28 15:18:17 +00:00
Important switches include :
2008-03-23 05:13:12 +00:00
2008-03-28 15:18:17 +00:00
prefix = / usr probably what you want for production tools
2017-10-27 22:51:06 +00:00
use_srcdir = yes build directly in the distribution root ;
2017-10-08 18:03:49 +00:00
you ' ll need this if you ' re trying to use Emacs compile mode .
2008-08-21 22:04:27 +00:00
build = release build the release build variant with appropriate flags
2008-06-03 12:59:33 +00:00
in build / release and copy resulting binaries
into distribution / working copy root .
2017-10-09 13:08:39 +00:00
build = debug same for debug build variant
2017-10-11 08:11:31 +00:00
build = profile build with instrumentation for a supported profiler
2008-03-28 15:18:17 +00:00
2008-04-06 13:55:17 +00:00
With no arguments , the recipe builds wesnoth and wesnothd . Available
build targets include the individual binaries :
2008-03-28 15:18:17 +00:00
2017-11-02 02:26:37 +00:00
wesnoth wesnothd campaignd boost_unit_tests
2008-03-28 15:18:17 +00:00
2008-04-06 13:55:17 +00:00
You can make the following special build targets :
2008-03-28 15:18:17 +00:00
2017-11-02 02:26:37 +00:00
all = wesnoth wesnothd campaignd boost_unit_tests ( * ) .
2017-10-08 18:03:49 +00:00
TAGS = build tags for Emacs ( * ) .
2008-04-01 18:53:03 +00:00
wesnoth - deps . png = project dependency graph
2008-04-08 11:55:40 +00:00
install = install all executables that currently exist , and any data needed
2008-03-28 15:18:17 +00:00
install - wesnothd = install the Wesnoth multiplayer server .
install - campaignd = install the Wesnoth campaign server .
2008-04-06 13:55:17 +00:00
install - pytools = install all Python tools and modules
uninstall = uninstall all executables , tools , modules , and servers .
2008-04-01 20:13:37 +00:00
pot - update = generate gettext message catalog templates and merge them with localized message catalogs
update - po = merge message catalog templates with localized message catalogs for particular lingua
2008-04-11 20:21:51 +00:00
update - po4a = update translations of manual and manpages
2008-04-01 20:13:37 +00:00
af bg ca . . . = linguas for update - po
2024-07-28 15:59:28 +00:00
translations = build all translations
2008-03-29 16:44:38 +00:00
dist = make distribution tarball as wesnoth . tar . bz2 ( * ) .
data - dist = make data tarball as wesnoth - data . tar . bz2 ( * ) .
2008-03-30 21:06:25 +00:00
binary - dist = make data tarball as wesnoth - binaries . tar . bz2 ( * ) .
2008-03-29 16:13:33 +00:00
wesnoth - bundle = make Mac OS application bundle from game ( * )
2016-03-01 14:16:36 +00:00
windows - installer = create Windows distribution with NSIS ( * )
2008-03-28 15:18:17 +00:00
sanity - check = run a pre - release sanity check on the distribution .
2008-04-11 20:21:51 +00:00
manual = regenerate English - language manual and , possibly , localized manuals if appropriate xmls exist .
2008-01-25 17:28:44 +00:00
2008-08-05 11:53:30 +00:00
Files made by targets marked with ' (*) ' are cleaned by ' scons -c all '
2008-03-29 16:13:33 +00:00
2008-03-28 18:57:47 +00:00
Options are cached in a file named . scons - option - cache and persist to later
2013-06-11 11:31:53 +00:00
invocations . The file is editable . Delete it to start fresh . You can also use a different file by
specifying - - option - cache = FILE command line argument . Current option values can be listed with ' scons -h ' .
2008-03-28 18:57:47 +00:00
2008-03-30 21:06:25 +00:00
If you set CXXFLAGS and / or LDFLAGS in the environment , the values will
2008-06-03 12:59:33 +00:00
be appended to the appropriate variables within scons .
2018-03-27 06:52:23 +00:00
""" + opts.GenerateHelpText(env, sort=SortHelpText))
2008-03-28 10:08:37 +00:00
2009-03-31 12:34:50 +00:00
if GetOption ( " help " ) :
Return ( )
2008-06-27 11:52:19 +00:00
if env [ " cachedir " ] and not env [ ' ccache ' ] :
2008-04-01 10:32:19 +00:00
CacheDir ( env [ " cachedir " ] )
2008-06-23 09:20:53 +00:00
if env [ " fast " ] :
env . Decider ( ' MD5-timestamp ' )
SetOption ( ' max_drift ' , 1 )
SetOption ( ' implicit_cache ' , 1 )
2008-11-01 21:52:28 +00:00
if not os . path . isabs ( env [ " prefix " ] ) :
2017-09-20 13:04:50 +00:00
print ( " Warning: prefix is set to relative dir. destdir setting will be ignored. " )
2008-11-01 21:52:28 +00:00
env [ " destdir " ] = " "
2009-09-24 16:46:12 +00:00
#
# work around long command line problem on windows
# see http://www.scons.org/wiki/LongCmdLinesOnWin32
#
2009-09-25 13:23:37 +00:00
if sys . platform == ' win32 ' :
2009-09-24 16:46:12 +00:00
try :
import win32file
import win32event
import win32process
import win32security
import string
def my_spawn ( sh , escape , cmd , args , spawnenv ) :
for var in spawnenv :
spawnenv [ var ] = spawnenv [ var ] . encode ( ' ascii ' , ' replace ' )
sAttrs = win32security . SECURITY_ATTRIBUTES ( )
StartupInfo = win32process . STARTUPINFO ( )
2017-09-20 14:51:33 +00:00
newargs = ' ' . join ( map ( escape , args [ 1 : ] ) )
2009-09-24 16:46:12 +00:00
cmdline = cmd + " " + newargs
# check for any special operating system commands
if cmd == ' del ' :
for arg in args [ 1 : ] :
win32file . DeleteFile ( arg )
exit_code = 0
else :
# otherwise execute the command.
hProcess , hThread , dwPid , dwTid = win32process . CreateProcess ( None , cmdline , None , None , 1 , 0 , spawnenv , None , StartupInfo )
win32event . WaitForSingleObject ( hProcess , win32event . INFINITE )
exit_code = win32process . GetExitCodeProcess ( hProcess )
2016-11-03 05:04:21 +00:00
win32file . CloseHandle ( hProcess )
win32file . CloseHandle ( hThread )
2009-09-24 16:46:12 +00:00
return exit_code
env [ ' SPAWN ' ] = my_spawn
except ImportError :
2009-09-25 13:13:24 +00:00
def subprocess_spawn ( sh , escape , cmd , args , env ) :
return call ( ' ' . join ( args ) )
env [ ' SPAWN ' ] = subprocess_spawn
2009-09-24 16:46:12 +00:00
2008-03-29 14:01:55 +00:00
#
# Check some preconditions
#
2017-09-20 13:04:50 +00:00
print ( " ---[checking prerequisites]--- " )
2008-03-29 14:01:55 +00:00
2014-08-06 18:58:07 +00:00
def Info ( message ) :
2017-09-20 13:04:50 +00:00
print ( " INFO: " + message )
2014-08-06 18:58:07 +00:00
return True
2008-03-29 14:01:55 +00:00
def Warning ( message ) :
2017-09-20 13:04:50 +00:00
print ( " WARNING: " + message )
2008-03-29 14:57:16 +00:00
return False
2008-03-29 14:01:55 +00:00
2008-05-06 12:43:02 +00:00
from metasconf import init_metasconf
2014-05-02 00:54:03 +00:00
configure_args = dict (
Add CMake and SCons options to use system Lua 5.4 C++
scons/lua.py makes use of the vestigial luadir option from commit
e94dcecf171.
Like FindLua.cmake, scons/lua.py searches for the Lua headers and
library, instead of using pkg-config like the old scons/lua.py (removed
in commit 9929d3ca1cf) did, because even though distributions typically
provide .pc files for Lua, upstream Lua doesn't. It's likely that all
distributions that compile Lua as a C++ library will also provide .pc
files, but this check doesn't rely on that (just as the CMake module
doesn't).
Unfortunately, SCons.Conftest.CheckLib() prints up to eight messages
like "Checking for C++ library lua54-c++... no" until a working library
name is found.
Also conditionally include system Lua headers in src/lua/*.h and update
documentation in src/modules/lua_README.md, src/wesnoth_lua_config.h,
and src/wesnoth_lua_config.md. The two lines about "The primary commit,
after replacing the sources," in src/wesnoth_lua_config.md don't make
sense since the instructions were updated for submodule Lua in commit
d32cfb88c4f and make even less sense now with preceding commits for
updating CMake modules.
2024-01-06 23:54:56 +00:00
custom_tests = init_metasconf ( env , [ " cplusplus " , " sdl " , " boost " , " cairo " , " pango " , " pkgconfig " , " gettext_tool " , " lua " ] ) ,
2014-05-02 00:54:03 +00:00
config_h = " $build_dir/config.h " ,
2009-06-27 19:13:15 +00:00
log_file = " $build_dir/config.log " , conf_dir = " $build_dir/sconf_temp " )
2008-03-28 10:08:37 +00:00
2009-01-12 15:16:30 +00:00
env . MergeFlags ( env [ " extra_flags_config " ] )
2012-11-27 16:19:20 +00:00
2015-12-02 13:20:55 +00:00
if env [ " multilib_arch " ] :
multilib_flag = " -m " + env [ " multilib_arch " ]
env . AppendUnique ( CCFLAGS = [ multilib_flag ] , LINKFLAGS = [ multilib_flag ] )
2012-11-27 16:19:20 +00:00
# Some tests need to load parts of boost
2014-12-27 18:57:51 +00:00
env . PrependENVPath ( ' LD_LIBRARY_PATH ' , env [ " boostlibdir " ] )
2016-12-22 22:26:01 +00:00
# Some tests require at least C++11
2016-12-24 04:22:51 +00:00
if " gcc " in env [ " TOOLS " ] :
2020-01-10 01:34:31 +00:00
env . AppendUnique ( CCFLAGS = Split ( " -Wall -Wextra " ) )
env . AppendUnique ( CXXFLAGS = Split ( " -Werror=non-virtual-dtor -std=c++ " + env [ " cxx_std " ] ) )
2016-12-22 22:26:01 +00:00
Use -Wno-dangling-reference when building with GCC-13
Version 13 of GCC added the -Wdangling-reference option, however
due to false positives it had to be moved from -Wall to -Wextra.
Discussion about its status in GCC-14 is in
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110075
The warning is for C++ only and the flag will generate a warning
when compiling C files if the flag is set in Scon's CCFLAGS.
The docs don't explain exactly what triggers the warning, but here's the
explanation from https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106393#c1
> The warning works by checking if a reference is initialized with a function
> that returns a reference, and at least one parameter of the function is a
> reference that is bound to a temporary. It assumes that such a function
> actually returns one of its arguments! ... suppress the warning when we've
> seen the definition of the function and we can say that it can return a
> variable with static storage duration.
Consistent with that, we're getting warnings on functions of the form
find(container, const std::string&). All of the things triggering it
seem to be false positives:
* Calls to find_widget<...>.
* Calls to theme::get_theme_config.
* Calls to race::gender_value.
* In src/actions/attack.cpp, any `attacker->attacks()[i]`.
Although there's an iterator in there, the eventual reference
is to a member of the array, not the iterator.
* In src/gui/dialogs/unit_advance.cpp, `cfg.child_range("...").back()`
That returns an object indirectly owned by cfg.
We'd like the other warnings of -Wextra, so turn off -Wdangling-reference.
2024-02-04 13:20:53 +00:00
# GCC-13 added this new warning, and included it in -Wextra,
# however in GCC-13 it has a lot of false positives.
#
# It's likely to generate false postives with GCC-14 too, but
# I'm using a narrow version check as GCC-14 is still in dev.
# See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110075
if " CXXVERSION " in env and env [ " CXXVERSION " ] . startswith ( " 13. " ) :
env . AppendUnique ( CXXFLAGS = " -Wno-dangling-reference " )
2008-03-28 18:13:41 +00:00
if env [ " prereqs " ] :
2008-11-01 21:52:28 +00:00
conf = env . Configure ( * * configure_args )
2009-08-08 23:49:38 +00:00
if env [ " PLATFORM " ] == " posix " :
if conf . CheckCHeader ( " sys/sendfile.h " , " <> " ) :
conf . CheckFunc ( " sendfile " )
2013-08-18 14:34:05 +00:00
def CheckAsio ( conf ) :
2011-06-18 23:10:55 +00:00
if env [ " PLATFORM " ] == ' win32 ' :
conf . env . Append ( LIBS = [ " libws2_32 " ] )
2013-08-18 14:34:05 +00:00
have_libpthread = True
else :
have_libpthread = conf . CheckLib ( " pthread " )
2014-08-05 18:50:27 +00:00
return have_libpthread & \
conf . CheckBoost ( " system " ) & \
2020-12-30 16:08:34 +00:00
conf . CheckBoost ( " asio " , header_only = True ) & \
conf . CheckBoost ( " context " ) & \
conf . CheckBoost ( " coroutine " )
2013-05-23 15:25:57 +00:00
2016-03-12 21:27:17 +00:00
def have_sdl_other ( ) :
return \
2024-04-11 17:58:56 +00:00
conf . CheckSDL2 ( ' 2.0.18 ' ) & \
2022-04-29 23:59:19 +00:00
conf . CheckSDL2Mixer ( ) & \
conf . CheckSDL2Image ( )
2014-08-06 15:57:54 +00:00
2018-06-01 19:45:45 +00:00
if sys . platform == " msys " :
env [ " PKG_CONFIG_FLAGS " ] = " --dont-define-prefix "
2014-08-06 18:58:07 +00:00
have_server_prereqs = ( \
2024-02-21 16:31:23 +00:00
conf . CheckCPlusPlus ( gcc_version = " 8 " ) & \
2016-11-03 04:57:01 +00:00
conf . CheckBoost ( " iostreams " , require_version = boost_version ) & \
2014-08-05 18:50:27 +00:00
conf . CheckBoostIostreamsGZip ( ) & \
conf . CheckBoostIostreamsBZip2 ( ) & \
2020-10-23 04:11:51 +00:00
conf . CheckBoost ( " program_options " , require_version = boost_version ) & \
2016-11-03 04:57:01 +00:00
conf . CheckBoost ( " random " , require_version = boost_version ) & \
2014-10-17 14:40:45 +00:00
conf . CheckBoost ( " smart_ptr " , header_only = True ) & \
2018-04-18 12:36:32 +00:00
CheckAsio ( conf ) & \
2019-10-25 14:38:11 +00:00
conf . CheckBoost ( " thread " ) & \
2018-03-13 18:02:40 +00:00
conf . CheckBoost ( " locale " ) & \
conf . CheckBoost ( " filesystem " ) \
2016-11-03 05:01:08 +00:00
and Info ( " Base prerequisites are met " ) ) \
or Warning ( " Base prerequisites are not met " )
2018-03-13 15:22:49 +00:00
if ( have_server_prereqs and not env [ " host " ] ) :
conf . CheckBoostLocaleBackends ( [ " icu " , " winapi " ] ) \
or Warning ( " Only icu and winapi backends of Boost Locale are supported. Bugs/crashes are very likely with other backends " )
2008-03-29 14:01:55 +00:00
2018-07-27 12:13:59 +00:00
if env [ ' harden ' ] :
env [ " have_fortify " ] = conf . CheckFortifySource ( )
2017-05-31 04:37:29 +00:00
if ( env [ " PLATFORM " ] != ' darwin ' ) :
# Otherwise, use Security.framework
2020-12-22 12:11:13 +00:00
have_server_prereqs = have_server_prereqs & conf . CheckLib ( " libcrypto " ) & conf . CheckLib ( " ssl " )
2017-05-31 04:37:29 +00:00
2009-04-27 11:00:14 +00:00
env = conf . Finish ( )
2015-11-15 14:14:11 +00:00
2016-06-08 14:20:59 +00:00
client_env = env . Clone ( )
2009-04-27 11:00:14 +00:00
conf = client_env . Configure ( * * configure_args )
2018-12-31 19:17:37 +00:00
have_client_prereqs = have_server_prereqs & have_sdl_other ( )
2019-01-23 00:34:21 +00:00
have_client_prereqs = have_client_prereqs & conf . CheckLib ( " vorbisfile " ) & conf . CheckOgg ( )
2018-12-31 19:17:37 +00:00
have_client_prereqs = have_client_prereqs & conf . CheckPNG ( )
have_client_prereqs = have_client_prereqs & conf . CheckJPG ( )
2021-12-15 05:15:11 +00:00
have_client_prereqs = have_client_prereqs & conf . CheckWebP ( )
2018-12-31 19:17:37 +00:00
have_client_prereqs = have_client_prereqs & conf . CheckCairo ( min_version = " 1.10 " )
2022-09-09 15:28:15 +00:00
have_client_prereqs = have_client_prereqs & conf . CheckPango ( " cairo " , require_version = " 1.44.0 " )
2018-12-31 19:17:37 +00:00
have_client_prereqs = have_client_prereqs & conf . CheckPKG ( " fontconfig " )
have_client_prereqs = have_client_prereqs & conf . CheckBoost ( " regex " )
2023-03-08 03:48:58 +00:00
have_client_prereqs = have_client_prereqs & conf . CheckLib ( " curl " )
2023-12-20 02:20:09 +00:00
have_client_prereqs = have_client_prereqs & conf . CheckBoost ( " graph " )
2022-03-09 18:07:11 +00:00
Add CMake and SCons options to use system Lua 5.4 C++
scons/lua.py makes use of the vestigial luadir option from commit
e94dcecf171.
Like FindLua.cmake, scons/lua.py searches for the Lua headers and
library, instead of using pkg-config like the old scons/lua.py (removed
in commit 9929d3ca1cf) did, because even though distributions typically
provide .pc files for Lua, upstream Lua doesn't. It's likely that all
distributions that compile Lua as a C++ library will also provide .pc
files, but this check doesn't rely on that (just as the CMake module
doesn't).
Unfortunately, SCons.Conftest.CheckLib() prints up to eight messages
like "Checking for C++ library lua54-c++... no" until a working library
name is found.
Also conditionally include system Lua headers in src/lua/*.h and update
documentation in src/modules/lua_README.md, src/wesnoth_lua_config.h,
and src/wesnoth_lua_config.md. The two lines about "The primary commit,
after replacing the sources," in src/wesnoth_lua_config.md don't make
sense since the instructions were updated for submodule Lua in commit
d32cfb88c4f and make even less sense now with preceding commits for
updating CMake modules.
2024-01-06 23:54:56 +00:00
if env [ " system_lua " ] :
if env [ " PLATFORM " ] == ' win32 ' :
Warning ( " System Lua cannot be used on Windows. " )
if not conf . CheckLua ( lua_ver ) :
have_client_prereqs = False
2022-03-09 18:07:11 +00:00
else :
Add CMake and SCons options to use system Lua 5.4 C++
scons/lua.py makes use of the vestigial luadir option from commit
e94dcecf171.
Like FindLua.cmake, scons/lua.py searches for the Lua headers and
library, instead of using pkg-config like the old scons/lua.py (removed
in commit 9929d3ca1cf) did, because even though distributions typically
provide .pc files for Lua, upstream Lua doesn't. It's likely that all
distributions that compile Lua as a C++ library will also provide .pc
files, but this check doesn't rely on that (just as the CMake module
doesn't).
Unfortunately, SCons.Conftest.CheckLib() prints up to eight messages
like "Checking for C++ library lua54-c++... no" until a working library
name is found.
Also conditionally include system Lua headers in src/lua/*.h and update
documentation in src/modules/lua_README.md, src/wesnoth_lua_config.h,
and src/wesnoth_lua_config.md. The two lines about "The primary commit,
after replacing the sources," in src/wesnoth_lua_config.md don't make
sense since the instructions were updated for submodule Lua in commit
d32cfb88c4f and make even less sense now with preceding commits for
updating CMake modules.
2024-01-06 23:54:56 +00:00
if not File ( " #/src/modules/lua/.git " ) . rfile ( ) . exists ( ) :
have_client_prereqs = False
Warning ( " Lua submodule does not exist. You must run ' git submodule update --init --recursive ' to initialize it. " )
else :
print ( " Lua submodule found. " )
2022-03-09 18:07:11 +00:00
2018-12-31 19:17:37 +00:00
if not have_client_prereqs :
Warning ( " Client prerequisites are not met. wesnoth cannot be built. " )
2008-01-25 17:56:04 +00:00
2008-06-05 20:41:16 +00:00
have_X = False
2009-08-08 23:49:38 +00:00
if have_client_prereqs :
if env [ " PLATFORM " ] != " win32 " :
have_X = conf . CheckLib ( ' X11 ' )
2009-08-10 09:47:58 +00:00
env [ " notifications " ] = env [ " notifications " ] and conf . CheckPKG ( " dbus-1 " )
2014-11-23 01:49:17 +00:00
env [ " history " ] = env [ " history " ] and ( conf . CheckLib ( " history " ) or Warning ( " Can ' t find GNU history, disabling history support. " ) )
2020-02-09 11:55:10 +00:00
client_env = conf . Finish ( )
# We set those outside of Configure() section because SCons doesn't merge CPPPATH var properly in conf.Finish()
if env [ " notifications " ] :
client_env . Append ( CPPDEFINES = [ " HAVE_LIBDBUS " ] )
if env [ " history " ] :
client_env . Append ( CPPDEFINES = [ " HAVE_HISTORY " ] )
2014-11-22 02:08:47 +00:00
2020-12-30 16:08:34 +00:00
env . Append ( CPPDEFINES = [ " BOOST_COROUTINES_NO_DEPRECATION_WARNING " ] )
2008-09-12 20:03:48 +00:00
if env [ " forum_user_handler " ] :
2019-01-15 11:23:47 +00:00
found_connector = False
for sql_config in [ " mariadb_config " , " mysql_config " ] :
try :
2019-10-13 16:53:45 +00:00
mysql_config = check_output ( [ sql_config , " --libs " , " --cflags " ] ) . decode ( " utf-8 " ) . replace ( " \n " , " " ) . replace ( " -DNDEBUG " , " " )
2020-08-01 08:50:52 +00:00
mysql_flags = env . ParseFlags ( mysql_config + " -I " + Dir ( " #/src/modules/mariadbpp/include/ " ) . rdir ( ) . abspath )
2019-01-15 11:23:47 +00:00
env . Append ( CPPDEFINES = [ " HAVE_MYSQLPP " ] )
env . MergeFlags ( mysql_flags )
found_connector = True
break
except OSError :
print ( " Failed to run script ' %s ' " % sql_config )
if not found_connector :
Exit ( " Failed to find sql connector library but forum user handler support is requested. " )
have_server_prereqs = False
2008-09-12 20:03:48 +00:00
2009-04-27 11:00:14 +00:00
test_env = client_env . Clone ( )
2008-11-01 21:52:28 +00:00
conf = test_env . Configure ( * * configure_args )
2016-06-15 19:14:29 +00:00
have_test_prereqs = have_client_prereqs and conf . CheckBoost ( ' unit_test_framework ' ) \
2016-11-03 05:01:08 +00:00
or Warning ( " Unit tests are disabled because their prerequisites are not met " )
2008-11-01 21:52:28 +00:00
test_env = conf . Finish ( )
2017-11-02 02:26:37 +00:00
if not have_test_prereqs and " boost_unit_tests " in env [ " default_targets " ] :
env [ " default_targets " ] . remove ( " boost_unit_tests " )
2008-07-01 21:57:09 +00:00
2017-09-20 13:04:50 +00:00
print ( " " + env . subst ( " If any config checks fail, look in $build_dir/config.log for details " ) )
print ( " If a check fails spuriously due to caching, use --config=force to force its rerun " )
2009-03-03 10:14:01 +00:00
2008-03-29 14:01:55 +00:00
else :
have_client_prereqs = True
2008-07-12 09:32:27 +00:00
have_X = False
if env [ " PLATFORM " ] != " win32 " :
have_X = True
2008-03-29 14:01:55 +00:00
have_server_prereqs = True
2008-07-01 21:57:09 +00:00
have_test_prereqs = True
2008-11-01 21:52:28 +00:00
test_env = env . Clone ( )
2009-04-27 11:00:14 +00:00
client_env = env . Clone ( )
2008-03-28 02:22:11 +00:00
2011-12-17 16:37:19 +00:00
2018-02-28 02:03:40 +00:00
if not env [ " MSGFMT " ] :
2008-03-30 22:43:10 +00:00
env [ " nls " ] = False
2017-09-20 13:04:50 +00:00
print ( " NLS tools are not present... " )
2008-03-30 22:43:10 +00:00
if not env [ ' nls ' ] :
2017-09-20 13:04:50 +00:00
print ( " NLS catalogue installation is disabled. " )
2008-03-30 22:43:10 +00:00
2008-03-24 12:17:46 +00:00
#
# Implement configuration switches
#
2017-09-20 13:04:50 +00:00
print ( " ---[applying configuration]--- " )
2008-03-24 12:17:46 +00:00
2016-06-15 19:14:29 +00:00
for env in [ test_env , client_env , env ] :
2014-03-21 02:38:44 +00:00
build_root = " #/ "
if os . path . isabs ( env [ " build_dir " ] ) :
build_root = " "
env . Prepend ( CPPPATH = [ build_root + " $build_dir " , " #/src " ] )
Add CMake and SCons options to use system Lua 5.4 C++
scons/lua.py makes use of the vestigial luadir option from commit
e94dcecf171.
Like FindLua.cmake, scons/lua.py searches for the Lua headers and
library, instead of using pkg-config like the old scons/lua.py (removed
in commit 9929d3ca1cf) did, because even though distributions typically
provide .pc files for Lua, upstream Lua doesn't. It's likely that all
distributions that compile Lua as a C++ library will also provide .pc
files, but this check doesn't rely on that (just as the CMake module
doesn't).
Unfortunately, SCons.Conftest.CheckLib() prints up to eight messages
like "Checking for C++ library lua54-c++... no" until a working library
name is found.
Also conditionally include system Lua headers in src/lua/*.h and update
documentation in src/modules/lua_README.md, src/wesnoth_lua_config.h,
and src/wesnoth_lua_config.md. The two lines about "The primary commit,
after replacing the sources," in src/wesnoth_lua_config.md don't make
sense since the instructions were updated for submodule Lua in commit
d32cfb88c4f and make even less sense now with preceding commits for
updating CMake modules.
2024-01-06 23:54:56 +00:00
if env [ " system_lua " ] :
env . Append ( CPPDEFINES = [ " HAVE_SYSTEM_LUA " ] )
2008-11-01 21:52:28 +00:00
env . Append ( CPPDEFINES = [ " HAVE_CONFIG_H " ] )
2008-03-27 08:37:20 +00:00
2017-11-22 19:39:35 +00:00
if " clang " in env [ " CXX " ] :
# Silence warnings about unused -I options and unknown warning switches.
2019-05-22 17:18:09 +00:00
env . AppendUnique ( CCFLAGS = Split ( " -Qunused-arguments -Wno-unknown-warning-option -Wmismatched-tags -Wno-conditional-uninitialized -Wno-unused-lambda-capture " ) )
2018-03-09 00:35:31 +00:00
2017-12-04 14:11:04 +00:00
if env [ ' pedantic ' ] :
env . AppendUnique ( CXXFLAGS = Split ( " -Wdocumentation -Wno-documentation-deprecated-sync " ) )
2022-06-08 10:44:33 +00:00
if env [ ' force_color ' ] :
env . AppendUnique ( CCFLAGS = [ " -fcolor-diagnostics " ] )
2017-11-22 19:39:35 +00:00
2008-11-01 21:52:28 +00:00
if " gcc " in env [ " TOOLS " ] :
2018-05-06 08:04:59 +00:00
env . AppendUnique ( CCFLAGS = Split ( " -Wno-unused-local-typedefs -Wno-maybe-uninitialized -Wtrampolines " ) )
2017-12-04 14:11:04 +00:00
env . AppendUnique ( CXXFLAGS = Split ( " -Wold-style-cast " ) )
2018-03-09 00:35:31 +00:00
2008-11-01 21:52:28 +00:00
if env [ ' strict ' ] :
2017-12-02 20:54:40 +00:00
env . AppendUnique ( CCFLAGS = Split ( " -Werror " ) )
2017-12-04 14:11:04 +00:00
if env [ ' pedantic ' ] :
env . AppendUnique ( CCFLAGS = Split ( " -Wlogical-op -Wmissing-declarations -Wredundant-decls -Wdouble-promotion " ) )
env . AppendUnique ( CXXFLAGS = Split ( " -Wctor-dtor-privacy -Wuseless-cast -Wnoexcept " ) )
2016-06-17 09:51:46 +00:00
if env [ ' sanitize ' ] :
env . AppendUnique ( CCFLAGS = [ " -fsanitize= " + env [ " sanitize " ] ] , LINKFLAGS = [ " -fsanitize= " + env [ " sanitize " ] ] )
2018-04-22 11:04:19 +00:00
env . AppendUnique ( CCFLAGS = Split ( " -fno-omit-frame-pointer -fno-optimize-sibling-calls " ) )
2022-06-08 10:44:33 +00:00
if env [ ' force_color ' ] :
env . AppendUnique ( CCFLAGS = [ " -fdiagnostics-color=always " ] )
2018-04-22 11:04:19 +00:00
2018-04-20 17:29:07 +00:00
# #
# Determine optimization level
# #
2018-04-20 17:35:45 +00:00
2018-04-20 17:29:07 +00:00
if not env [ " opt " ] :
if env [ " build " ] == " release " :
env [ " opt " ] = " -O3 "
2021-06-08 21:12:03 +00:00
elif env [ " profiler " ] == " perf " :
2018-04-20 17:29:07 +00:00
env [ " opt " ] = " -Og "
else :
env [ " opt " ] = " -O0 "
else :
2018-04-22 11:04:19 +00:00
env [ " opt " ] = env [ " opt " ] + " "
2018-04-20 17:35:45 +00:00
2018-05-04 00:07:57 +00:00
# #
# Add options to provide more hardened executables
2018-06-15 07:18:32 +00:00
# osx doesn't seem to support RELRO
2018-06-22 13:46:34 +00:00
# windows' tdm-gcc doesn't seem to provide good support for the hardening options in general
2018-05-04 00:07:57 +00:00
# #
2018-06-22 13:46:34 +00:00
if env [ ' harden ' ] and env [ " PLATFORM " ] != ' win32 ' :
2018-05-04 00:07:57 +00:00
env . AppendUnique ( CCFLAGS = [ " -fPIE " , " -fstack-protector-strong " ] )
2019-09-02 09:53:48 +00:00
if not env . get ( " have_fortify " ) and " -O0 " not in env [ " opt " ] :
2018-09-07 17:36:11 +00:00
env . AppendUnique ( CPPDEFINES = [ " _FORTIFY_SOURCE=2 " ] )
2018-05-04 00:07:57 +00:00
2018-06-11 01:23:27 +00:00
if env [ " enable_lto " ] == True :
env . AppendUnique ( LINKFLAGS = [ " -fstack-protector-strong " ] )
2018-07-27 12:13:59 +00:00
2018-06-15 07:18:32 +00:00
if env [ " PLATFORM " ] == ' darwin ' :
env . AppendUnique ( LINKFLAGS = [ " -fPIE " , " -Wl,-pie " ] )
else :
env . AppendUnique ( LINKFLAGS = [ " -fPIE " , " -pie " , " -Wl,-z,relro,-z,now " ] )
2018-06-11 01:23:27 +00:00
2017-10-08 18:03:49 +00:00
# #
# Start determining options for debug build
# #
2018-03-09 00:35:31 +00:00
2018-04-20 17:29:07 +00:00
debug_flags = env [ " opt " ] + " -DDEBUG -ggdb3 "
2020-11-19 16:44:31 +00:00
if " mingw " in env [ " TOOLS " ] :
debug_flags + = " -Wa,-mbig-obj "
debug_flags = Split ( debug_flags )
debug_flags . append ( " $ { ' -O3 ' if TARGET.name == ' gettext.o ' else ' ' } " ) # workaround for "File too big" errors
2018-03-09 00:35:31 +00:00
2023-02-25 10:44:06 +00:00
glibcxx_debug_flags = " "
if env [ " glibcxx_assertions " ] == True :
glibcxx_debug_flags = " " . join ( [ glibcxx_debug_flags , " _GLIBCXX_ASSERTIONS " ] )
2017-10-08 18:03:49 +00:00
if env [ " glibcxx_debug " ] == True :
2023-02-25 10:44:06 +00:00
glibcxx_debug_flags = " " . join ( [ glibcxx_debug_flags , " _GLIBCXX_DEBUG " , " _GLIBCXX_DEBUG_PEDANTIC " ] )
2018-03-09 00:35:31 +00:00
2017-10-08 18:03:49 +00:00
# #
# End determining options for debug build
# Start setting options for release build
# #
2018-03-09 00:35:31 +00:00
2017-10-25 13:02:30 +00:00
# default compiler flags
2018-04-20 17:29:07 +00:00
rel_comp_flags = env [ " opt " ]
2017-10-27 22:51:06 +00:00
rel_link_flags = " "
2018-03-09 00:35:31 +00:00
2021-06-08 21:12:03 +00:00
# #
# Add flags if using profiling
# #
if env [ " profiler " ] == " gprof " :
rel_comp_flags + = " -pg "
rel_link_flags + = " -pg "
if env [ " profiler " ] == " gcov " :
2021-06-09 07:51:17 +00:00
rel_comp_flags + = " --coverage "
rel_link_flags + = " --coverage "
2021-06-08 21:12:03 +00:00
if env [ " profiler " ] == " gperftools " :
rel_comp_flags + = " "
rel_link_flags + = " -Wl,--no-as-needed,-lprofiler "
if env [ " profiler " ] == " perf " :
2021-06-09 03:37:57 +00:00
rel_comp_flags + = " -ggdb -fno-omit-frame-pointer "
2021-06-08 21:12:03 +00:00
rel_link_flags + = " "
2017-10-25 13:02:30 +00:00
# use the arch if provided, or if on Windows and no arch was passed in then default to pentiumpro
# without setting to pentiumpro, compiling on Windows with 64-bit tdm-gcc and -O3 currently fails
2017-09-30 18:32:41 +00:00
if env [ " arch " ] :
env [ " arch " ] = " -march= " + env [ " arch " ]
2018-03-09 00:35:31 +00:00
2017-09-30 18:32:41 +00:00
if env [ " PLATFORM " ] == " win32 " and not env [ " arch " ] :
env [ " arch " ] = " -march=pentiumpro "
2018-03-09 00:35:31 +00:00
2021-06-08 21:12:03 +00:00
rel_comp_flags + = env [ " arch " ]
2018-03-09 00:35:31 +00:00
2017-10-25 13:02:30 +00:00
# PGO and LTO setup
2018-02-11 04:09:58 +00:00
if " gcc " in env [ " CC " ] :
2017-10-25 13:02:30 +00:00
if env [ " pgo_data " ] == " generate " :
2021-06-08 21:12:03 +00:00
rel_comp_flags + = " -fprofile-generate=pgo_data/ "
rel_link_flags + = " -fprofile-generate=pgo_data/ "
2018-03-09 00:35:31 +00:00
2017-10-25 13:02:30 +00:00
if env [ " pgo_data " ] == " use " :
2021-06-08 21:12:03 +00:00
rel_comp_flags + = " -fprofile-correction -fprofile-use=pgo_data/ "
rel_link_flags + = " -fprofile-correction -fprofile-use=pgo_data/ "
2017-10-25 13:02:30 +00:00
if env [ " enable_lto " ] == True :
2021-06-08 21:12:03 +00:00
rel_comp_flags + = " -flto= " + str ( env [ " jobs " ] )
rel_link_flags + = rel_comp_flags + " -fuse-ld=gold -Wno-stringop-overflow "
2017-10-25 13:02:30 +00:00
elif " clang " in env [ " CXX " ] :
if env [ " pgo_data " ] == " generate " :
2021-06-08 21:12:03 +00:00
rel_comp_flags + = " -fprofile-instr-generate=pgo_data/wesnoth- % p.profraw "
rel_link_flags + = " -fprofile-instr-generate=pgo_data/wesnoth- % p.profraw "
2018-03-09 00:35:31 +00:00
2017-10-25 13:02:30 +00:00
if env [ " pgo_data " ] == " use " :
2021-06-08 21:12:03 +00:00
rel_comp_flags + = " -fprofile-instr-use=pgo_data/wesnoth.profdata "
rel_link_flags + = " -fprofile-instr-use=pgo_data/wesnoth.profdata "
2017-10-25 13:02:30 +00:00
if env [ " enable_lto " ] == True :
2021-06-08 21:12:03 +00:00
rel_comp_flags + = " -flto=thin "
rel_link_flags + = rel_comp_flags + " -fuse-ld=lld "
2008-03-24 12:17:46 +00:00
2018-05-31 00:33:10 +00:00
# Enable ASLR and NX bit support on mingw
if " mingw " in env [ " TOOLS " ] :
2021-06-08 21:12:03 +00:00
rel_link_flags + = " -Wl,--dynamicbase -Wl,--nxcompat "
2018-05-31 00:33:10 +00:00
2017-10-08 18:03:49 +00:00
# #
# End setting options for release build
# #
2008-11-01 21:52:28 +00:00
if env [ ' internal_data ' ] :
env . Append ( CPPDEFINES = " USE_INTERNAL_DATA " )
2008-10-04 14:19:57 +00:00
2008-11-01 21:52:28 +00:00
if have_X :
env . Append ( CPPDEFINES = " _X11 " )
2008-06-05 20:41:16 +00:00
2008-03-29 14:35:30 +00:00
# Simulate autools-like behavior of prefix on various paths
2017-11-03 13:10:55 +00:00
installdirs = Split ( " bindir datadir fifodir icondir desktopdir appdatadir mandir docdir python_site_packages_dir " )
2008-11-01 21:52:28 +00:00
for d in installdirs :
env [ d ] = os . path . join ( env [ " prefix " ] , env [ d ] )
2008-03-27 15:22:56 +00:00
2008-11-01 21:52:28 +00:00
if env [ " PLATFORM " ] == ' win32 ' :
2021-05-21 22:06:10 +00:00
env . Append ( LIBS = [ " wsock32 " , " crypt32 " , " iconv " , " z " , " shlwapi " , " winmm " , " ole32 " , " uuid " ] , CCFLAGS = [ " -mthreads " ] , LINKFLAGS = [ " -mthreads " ] , CPPDEFINES = [ " _WIN32_WINNT=0x0601 " ] )
2014-12-27 18:57:51 +00:00
2008-11-01 21:52:28 +00:00
if env [ " PLATFORM " ] == ' darwin ' : # Mac OS X
2016-11-03 17:23:04 +00:00
env . Append ( FRAMEWORKS = " Cocoa " ) # Cocoa GUI
2017-05-31 04:37:29 +00:00
env . Append ( FRAMEWORKS = " Security " ) # commonCrypto (after OpenSSL replacement on Mac)
2018-08-09 15:13:12 +00:00
env . Append ( FRAMEWORKS = " IOKit " ) # IOKit
2020-08-06 04:44:39 +00:00
env . Append ( FRAMEWORKS = " CoreGraphics " ) # CoreGraphics
2008-11-01 21:52:28 +00:00
2021-12-10 22:47:53 +00:00
if env [ " PLATFORM " ] == ' sunos ' :
env . Append ( LINKFLAGS = " -lsocket " )
2008-11-01 21:52:28 +00:00
if not env [ ' static_test ' ] :
test_env . Append ( CPPDEFINES = " BOOST_TEST_DYN_LINK " )
2008-03-28 09:15:19 +00:00
2018-12-27 11:39:31 +00:00
if env [ ' autorevision ' ] :
try :
if call ( env . subst ( " utils/autorevision.sh -t h > $build_dir/revision.h " ) , shell = True ) == 0 :
env [ " have_autorevision " ] = True
if not call ( env . subst ( " cmp -s $build_dir/revision.h src/revision.h " ) , shell = True ) == 0 :
call ( env . subst ( " cp $build_dir/revision.h src/revision.h " ) , shell = True )
except :
pass
2008-03-24 12:17:46 +00:00
2016-06-15 19:14:29 +00:00
Export ( Split ( " env client_env test_env have_client_prereqs have_server_prereqs have_test_prereqs " ) )
2012-08-24 15:55:19 +00:00
SConscript ( dirs = Split ( " po doc packaging/windows packaging/systemd " ) )
2008-05-07 11:23:39 +00:00
2017-11-02 02:26:37 +00:00
binaries = Split ( " wesnoth wesnothd campaignd boost_unit_tests " )
2008-05-07 11:23:39 +00:00
builds = {
2017-10-27 22:51:06 +00:00
" release " : dict ( CCFLAGS = Split ( rel_comp_flags ) , LINKFLAGS = Split ( rel_link_flags ) ) ,
2021-06-08 21:12:03 +00:00
" debug " : dict ( CCFLAGS = Split ( debug_flags ) , CPPDEFINES = Split ( glibcxx_debug_flags ) )
2008-05-07 11:23:39 +00:00
}
2008-05-11 12:34:55 +00:00
build = env [ " build " ]
2008-06-02 21:58:36 +00:00
2016-06-15 19:14:29 +00:00
for env in [ test_env , client_env , env ] :
2008-11-01 21:52:28 +00:00
env . AppendUnique ( * * builds [ build ] )
2011-01-03 23:27:17 +00:00
env . Append ( CXXFLAGS = Split ( os . environ . get ( ' CXXFLAGS ' , [ ] ) ) , LINKFLAGS = Split ( os . environ . get ( ' LDFLAGS ' , [ ] ) ) )
2008-11-01 21:52:28 +00:00
env . MergeFlags ( env [ " extra_flags_ " + build ] )
2008-06-29 23:55:15 +00:00
2017-10-27 22:51:06 +00:00
if env [ " use_srcdir " ] == True :
2017-10-08 18:03:49 +00:00
build_dir = " "
else :
build_dir = os . path . join ( " $build_dir " , build )
2008-08-21 22:04:27 +00:00
2009-06-27 19:13:15 +00:00
env . SConscript ( " src/SConscript " , variant_dir = build_dir , duplicate = False )
2017-10-08 18:03:49 +00:00
Import ( binaries + [ " sources " ] )
2017-09-20 14:51:33 +00:00
binary_nodes = [ eval ( binary ) for binary in binaries ]
all = env . Alias ( " all " , [ Alias ( binary ) for binary in binaries ] )
env . Default ( [ Alias ( target ) for target in env [ " default_targets " ] ] )
2008-06-29 23:55:15 +00:00
2009-08-08 23:49:44 +00:00
if have_client_prereqs and env [ " nls " ] :
env . Requires ( " wesnoth " , Dir ( " translations " ) )
2017-10-25 13:02:30 +00:00
#
# clean out any PGO-related files
#
env . Clean ( all , " pgo_data/ " )
2017-10-08 18:03:49 +00:00
#
# Utility productions (Unix-like systems only)
#
# Make a tags file for Emacs
# Exuberant Ctags doesn't understand the -l c++ flag so if the etags fails try the ctags version
env . Command ( " TAGS " , sources , ' etags -l c++ $SOURCES.srcpath || (ctags --tag-relative=yes -f src/tags $SOURCES.srcpath) ' )
env . Clean ( all , ' TAGS ' )
2008-03-24 15:04:08 +00:00
#
2008-03-30 10:54:33 +00:00
# Unix installation productions
#
# These will not be portable to Windows or Mac. They assume a Unix-like
2023-10-23 01:18:31 +00:00
# directory structure and FreeDesktop standard locations for icon, app,
2008-03-30 21:42:16 +00:00
# and doc files.
2008-03-24 15:04:08 +00:00
#
2008-03-25 01:14:25 +00:00
2008-06-24 16:02:23 +00:00
for d in installdirs :
2012-09-03 23:22:49 +00:00
locals ( ) [ d ] = os . path . join ( env [ " destdir " ] , env [ d ] . lstrip ( " / " ) )
2008-09-12 12:07:27 +00:00
installable_subs = Split ( ' data fonts images sounds ' )
2009-01-11 13:15:27 +00:00
if os . path . isabs ( env [ " localedirname " ] ) :
env [ " localedir " ] = env [ " localedirname " ]
else :
env [ " localedir " ] = " $datadir/$localedirname "
2018-03-09 00:35:31 +00:00
2008-04-14 14:25:07 +00:00
pythontools = Split ( " wmlscope wmllint wmlindent wesnoth_addon_manager " )
2020-08-05 19:56:12 +00:00
pythonmodules = Split ( " wmltools3.py wmlparser.py wmlparser3.py wmldata.py wmliterator3.py campaignserver_client.py __init__.py " )
2008-03-25 05:56:15 +00:00
2008-03-27 13:48:33 +00:00
def CopyFilter ( fn ) :
" Filter out data-tree things that shouldn ' t be installed. "
2013-03-26 14:44:47 +00:00
return not " .git " in str ( fn ) and not " Makefile " in str ( fn )
2008-03-27 13:48:33 +00:00
2008-05-22 13:51:51 +00:00
env [ " copy_filter " ] = CopyFilter
2019-03-30 12:33:27 +00:00
def MoFileFilter ( fn ) :
" Don ' t install .mo files for manual and manpages. They ' re built only to catch broken po files "
return not " wesnoth-manual.mo " in str ( fn ) and not " wesnoth-manpages.mo " in str ( fn )
2017-10-11 13:36:20 +00:00
linguas = Split ( File ( " po/LINGUAS " ) . get_contents ( ) . decode ( " utf-8 " ) )
2008-04-06 13:55:17 +00:00
2008-10-16 18:45:52 +00:00
def InstallManpages ( env , component ) :
env . InstallData ( " mandir " , component , os . path . join ( " doc " , " man " , component + " .6 " ) , " man6 " )
for lingua in linguas :
2021-04-25 00:11:56 +00:00
manpage = FindFile ( os . path . join ( lingua , component + " .6 " ) , " doc/man " )
if manpage :
env . InstallData ( " mandir " , component , manpage , os . path . join ( lingua , " man6 " ) )
2008-04-06 13:55:17 +00:00
# Now the actual installation productions
2009-05-03 10:32:00 +00:00
# The game and associated resources
env . InstallBinary ( wesnoth )
2017-09-20 14:51:33 +00:00
env . InstallData ( " datadir " , " wesnoth " , [ Dir ( sub ) for sub in installable_subs ] )
2009-04-27 11:52:53 +00:00
env . InstallData ( " docdir " , " wesnoth " , [ Glob ( " doc/manual/*.html " ) , Dir ( " doc/manual/styles " ) , Dir ( " doc/manual/images " ) ] )
2009-01-11 13:15:27 +00:00
if env [ " nls " ] :
2019-03-30 12:33:27 +00:00
env . InstallData ( " localedir " , " wesnoth " , Dir ( " translations " ) , copy_filter = MoFileFilter )
2008-10-16 18:45:52 +00:00
InstallManpages ( env , " wesnoth " )
2008-03-29 14:35:30 +00:00
if have_client_prereqs and have_X and env [ " desktop_entry " ] :
2017-10-21 22:23:43 +00:00
env . InstallData ( " icondir " , " wesnoth " , " packaging/icons " )
2019-03-27 19:08:17 +00:00
env . InstallData ( " desktopdir " , " wesnoth " , " packaging/org.wesnoth.Wesnoth.desktop " )
2017-11-03 13:10:55 +00:00
if have_client_prereqs and " linux " in sys . platform and env [ " appdata_file " ] :
2019-03-27 19:08:17 +00:00
env . InstallData ( " appdatadir " , " wesnoth " , " packaging/org.wesnoth.Wesnoth.appdata.xml " )
2008-04-06 13:55:17 +00:00
# Python tools
2017-09-20 13:04:50 +00:00
env . InstallData ( " bindir " , " pytools " , [ os . path . join ( " data " , " tools " , tool ) for tool in pythontools ] )
env . InstallData ( " python_site_packages_dir " , " pytools " , [ os . path . join ( " data " , " tools " , " wesnoth " , module ) for module in pythonmodules ] )
2008-04-06 13:55:17 +00:00
# Wesnoth MP server install
2008-11-02 18:10:48 +00:00
env . InstallBinary ( wesnothd )
2008-10-16 18:45:52 +00:00
InstallManpages ( env , " wesnothd " )
2008-03-27 16:36:33 +00:00
if not access ( fifodir , F_OK ) :
2008-11-02 18:10:48 +00:00
fifodir = env . Command ( fifodir , [ ] , [
2008-03-27 16:36:33 +00:00
Mkdir ( fifodir ) ,
2017-09-20 13:04:50 +00:00
Chmod ( fifodir , 0o700 ) ,
2008-03-27 17:01:08 +00:00
Action ( " chown %s : %s %s " %
( env [ " server_uid " ] , env [ " server_gid " ] , fifodir ) ) ,
2008-03-27 16:36:33 +00:00
] )
2008-11-02 18:10:48 +00:00
AlwaysBuild ( fifodir )
env . Alias ( " install-wesnothd " , fifodir )
2012-08-24 15:55:19 +00:00
if env [ " systemd " ] :
env . InstallData ( " prefix " , " wesnothd " , " #packaging/systemd/wesnothd.service " , " lib/systemd/system " )
2024-01-23 01:07:45 +00:00
env . InstallData ( " prefix " , " wesnothd " , " #packaging/systemd/wesnothd.tmpfiles.conf " , " lib/tmpfiles.d " )
env . InstallData ( " prefix " , " wesnothd " , " #packaging/systemd/wesnothd.sysusers.conf " , " lib/sysusers.d " )
2008-03-25 05:56:15 +00:00
2008-04-06 13:55:17 +00:00
# Wesnoth campaign server
2008-11-02 18:10:48 +00:00
env . InstallBinary ( campaignd )
2008-04-08 04:45:32 +00:00
# Compute things for default install based on which targets have been created.
2008-05-04 19:47:54 +00:00
install = env . Alias ( ' install ' , [ ] )
2008-10-04 11:03:29 +00:00
for installable in ( ' wesnoth ' ,
2016-12-17 11:24:36 +00:00
' wesnothd ' , ' campaignd ' ) :
2024-01-15 23:00:16 +00:00
if os . path . exists ( installable ) or installable in COMMAND_LINE_TARGETS or " all " in COMMAND_LINE_TARGETS :
2008-05-04 19:47:54 +00:00
env . Alias ( ' install ' , env . Alias ( ' install- ' + installable ) )
2008-03-26 23:40:51 +00:00
2008-03-25 05:56:15 +00:00
#
# Un-installation
#
2008-04-30 11:20:20 +00:00
def Uninstall ( nodes ) :
deletes = [ ]
for node in nodes :
if node . __class__ == install [ 0 ] . __class__ :
deletes . append ( Uninstall ( node . sources ) )
else :
deletes . append ( Delete ( str ( node ) ) )
return deletes
2009-01-25 11:05:11 +00:00
uninstall = env . Command ( ' uninstall ' , ' ' , Flatten ( Uninstall ( Alias ( " install " ) ) ) or " " )
2008-03-25 05:56:15 +00:00
env . AlwaysBuild ( uninstall )
env . Precious ( uninstall )
2008-03-27 20:03:25 +00:00
#
2008-03-29 15:28:01 +00:00
# Making a distribution tarball.
2008-03-27 20:03:25 +00:00
#
2009-02-02 17:37:51 +00:00
env [ " version " ] = build_config . get ( " VERSION " )
2008-08-12 20:01:52 +00:00
if ' dist ' in COMMAND_LINE_TARGETS : # Speedup, the manifest is expensive
2008-03-29 16:44:38 +00:00
def dist_manifest ( ) :
" Get an argument list suitable for passing to a distribution archiver. "
# Start by getting a list of all files under version control
2018-06-14 14:03:22 +00:00
lst = subprocess . check_output ( " git ls-files " , shell = True ) . splitlines ( )
2008-04-18 20:35:35 +00:00
lst = filter ( os . path . isfile , lst )
2008-03-29 16:44:38 +00:00
return lst
2008-05-17 09:15:26 +00:00
dist_tarball = env . Tar ( ' wesnoth-$ {version} .tar.bz2 ' , [ ] )
2018-06-14 14:00:20 +00:00
open ( " dist.manifest " , " w " ) . write ( " \n " . join ( dist_manifest ( ) + [ " src/revision.h " ] ) )
2008-05-17 09:15:26 +00:00
env . Append ( TARFLAGS = ' -j -T dist.manifest --transform " s,^,wesnoth-$version/, " ' ,
2008-03-29 16:44:38 +00:00
TARCOMSTR = " Making distribution tarball... " )
2008-05-17 09:15:26 +00:00
env . AlwaysBuild ( dist_tarball )
2008-03-29 16:44:38 +00:00
env . Clean ( all , ' wesnoth.tar.bz2 ' )
env . Alias ( ' dist ' , dist_tarball )
2008-03-27 20:03:25 +00:00
2008-04-01 22:02:40 +00:00
#
# Make binary distribution (from installed client side)
#
bin_tar_env = env . Clone ( )
bin_tarball = bin_tar_env . Tar ( ' wesnoth-binary.tar.bz2 ' ,
os . path . join ( bindir , " wesnoth " ) )
bin_tar_env . Append ( TARFLAGS = ' -j ' , TARCOMSTR = " Making binary tarball... " )
env . Clean ( all , ' wesnoth-binary.tar.bz2 ' )
env . Alias ( ' binary-dist ' , bin_tarball )
#
# Make data distribution (from installed client side)
#
data_tar_env = env . Clone ( )
data_tarball = data_tar_env . Tar ( ' wesnoth-data.tar.bz2 ' , datadir )
data_tar_env . Append ( TARFLAGS = ' -j ' , TARCOMSTR = " Making data tarball... " )
env . Clean ( all , ' wesnoth-data.tar.bz2 ' )
env . Alias ( ' data-dist ' , data_tarball )
2008-09-03 08:23:44 +00:00
#
# Windows installer
#
2009-02-09 18:43:45 +00:00
env . WindowsInstaller ( [
wesnoth , wesnothd ,
Dir ( installable_subs ) , env [ " nls " ] and Dir ( " translations " ) or [ ] ,
2015-08-08 01:37:57 +00:00
glob ( " *.dll " )
2009-02-09 18:43:45 +00:00
] )
2008-09-03 08:23:44 +00:00
2008-03-29 15:28:01 +00:00
#
# Making Mac OS X application bundles
#
2008-03-29 16:13:33 +00:00
env . Alias ( " wesnoth-bundle " ,
2016-11-13 05:43:06 +00:00
env . Command ( " Wesnoth.app " , " wesnoth " , [
2008-03-29 16:13:33 +00:00
Mkdir ( " $ {TARGET} /Contents " ) ,
Mkdir ( " $ {TARGET} /Contents/MacOS " ) ,
Mkdir ( " $ {TARGET} /Contents/Resources " ) ,
Action ( ' echo " APPL???? " > " $ {TARGET} /Contents/PkgInfo " ' ) ,
2016-11-13 05:43:06 +00:00
Copy ( " $ {TARGET} /Contents/MacOS/Wesnoth " , " wesnoth " ) ,
Copy ( " $ {TARGET} /Contents/MacOS/wesnothd " , " wesnothd " ) ,
Copy ( " $ {TARGET} /Contents/Info.plist " , " projectfiles/Xcode/Info.plist " ) ,
Action ( r """ sed -i ' ' ' s/ \ $[ { ].*[}]/Wesnoth/ ' " $ {TARGET} /Contents/Info.plist " """ ) ,
Copy ( " $ {TARGET} /Contents/Resources/data " , " data " ) ,
Copy ( " $ {TARGET} /Contents/Resources/English.lproj " , " projectfiles/Xcode/English.lproj " ) ,
Copy ( " $ {TARGET} /Contents/Resources/fonts " , " fonts " ) ,
Copy ( " $ {TARGET} /Contents/Resources/fonts.conf " , " projectfiles/Xcode/Resources/fonts.conf " ) ,
Copy ( " $ {TARGET} /Contents/Resources/icon.icns " , " projectfiles/Xcode/Resources/icon.icns " ) ,
Copy ( " $ {TARGET} /Contents/Resources/images " , " images " ) ,
Copy ( " $ {TARGET} /Contents/Resources/SDLMain.nib " , " projectfiles/Xcode/Resources/SDLMain.nib " ) ,
Copy ( " $ {TARGET} /Contents/Resources/sounds " , " sounds " ) ,
Copy ( " $ {TARGET} /Contents/Resources/translations " , " translations " ) ,
2008-03-29 16:13:33 +00:00
] ) )
2016-11-13 05:43:06 +00:00
env . Clean ( all , " Wesnoth.app " )
2008-03-29 16:13:33 +00:00
2008-03-27 21:51:30 +00:00
#
# Sanity checking
#
2008-03-28 15:18:17 +00:00
sanity_check = env . Command ( ' sanity-check ' , ' ' , [
2008-03-29 19:11:12 +00:00
Action ( " cd utils; ./sanity_check " ) ,
2008-03-27 21:51:30 +00:00
Action ( " cd data/tools; make sanity-check " ) ,
] )
env . AlwaysBuild ( sanity_check )
env . Precious ( sanity_check )
2008-04-01 18:53:03 +00:00
#
# Make the project dependency graph (requires graph-includes).
#
env . Command ( " wesnoth-deps.dot " , [ ] ,
" graph-includes -verbose --class wesnoth \
2008-08-12 20:01:52 +00:00
- sysI / usr / include / c + + / 4.0 - sysI / usr / include - sysI / usr / include / SDL \
- - prefixstrip src / - I src src > $ { TARGET } " )
2008-04-01 18:53:03 +00:00
env . Command ( " wesnoth-deps.png " , " wesnoth-deps.dot " ,
" dot -Tpng -o $ {TARGET} $ {SOURCE} " )
env . Clean ( all , [ " wesnoth-deps.dot " , " wesnoth-deps.png " ] )
2008-01-25 03:27:44 +00:00
# Local variables:
# mode: python
# end: