1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247
|
# -*- coding: utf-8 -*-
# ####################################################################
# Copyright (C) 2005-2012 by the FIFE team
# http://www.fifengine.net
# This file is part of FIFE.
#
# FIFE is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library 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
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
# ####################################################################
import os,sys
import utils.scons.scons_utils as utils
from utils.util_scripts.path import path as upath
import utils.scons.scons_builders as builders
Import('env', 'opts')
_sep = os.path.sep
src_path = upath(opts['SRC'])
engine_path = opts['SRC']
core_path = os.path.join('engine', 'core')
extensionpath = upath(os.path.join(opts['SRC'], 'python', 'fife', 'extensions'))
#**************************************************************************
#Compile the list of source code to be used
#**************************************************************************
allfiles = list(src_path.walkfiles())
allfiles_base = list()
for f in allfiles:
allfiles_base.append(utils.relpath(f, opts['SRC']))
extpyfiles = list(extensionpath.walkfiles('*.py'))
extensionfiles = list()
relextensionfiles = list()
for f in extpyfiles:
extensionfiles.append(utils.relpath(f, opts['SRC']))
relextensionfiles.append(utils.relpath(f, os.path.join(opts['SRC'], 'python', 'fife')))
headerfiles = [f for f in allfiles_base if utils.is_headerfile(f)]
implfiles = [f for f in allfiles_base if utils.is_implfile(f)]
swigfiles = [f for f in allfiles_base if utils.is_swigfile(f)]
intfiles = utils.filter_by_dir(['swigwrappers'], swigfiles)
compilefiles = utils.filter_by_dir(['swigwrappers'], implfiles)
if sys.platform == 'win32':
dllpath = upath(opts['DLLPATH'])
dllfilelist = list(dllpath.walkfiles('*.dll'))
dllfiles = list()
for f in dllfilelist:
dllfiles.append(utils.relpath(f,opts['DLLPATH']))
#**************************************************************************
#define the FIFE revision number
#**************************************************************************
if opts['FIFE_REVISION'] is not "0":
env.AppendUnique(CPPDEFINES = ['FIFE_REVISION=' + opts['FIFE_REVISION']])
#**************************************************************************
#python
#**************************************************************************
#generate swig interface file
utils.gen_swig_interface(os.path.join(engine_path, 'swigwrappers', 'python', 'fife.i.templ'),
intfiles,
os.path.join(engine_path, 'swigwrappers', 'python'))
pyfiles = list(compilefiles)
pyfiles.append([os.path.join('swigwrappers', 'python' ,'fife_wrap.cc')])
#**************************************************************************
#definition of scons builders for project files
#**************************************************************************
msvc_project_builder = Builder(action = builders.generate_msvc_project, suffix = '.vcproj')
env.Append(BUILDERS = {'MSVCProject': msvc_project_builder})
msvc_project_builder9 = Builder(action = builders.generate_msvc_project9, suffix = '.vcproj')
env.Append(BUILDERS = {'MSVCProject9': msvc_project_builder9})
codeblocks_project_builder_win32 = Builder(action = builders.generate_codeblocks_project_win32, suffix = '.cbp')
env.Append(BUILDERS = {'CodeblocksProjectWin32': codeblocks_project_builder_win32})
codeblocks_project_builder_linux = Builder(action = builders.generate_codeblocks_project_linux, suffix = '.cbp')
env.Append(BUILDERS = {'CodeblocksProjectLinux': codeblocks_project_builder_linux})
python_extensions_builder = Builder(action = "$SWIG -o $TARGET ${_SWIGOUTDIR} ${_SWIGINCFLAGS} $SWIGFLAGS $SOURCES")
env.Append(BUILDERS = {'PythonExtensions': python_extensions_builder})
#**************************************************************************
#project files target
#**************************************************************************
projectfiles = compilefiles + headerfiles
#projectfiles.append('swigwrappers/python/fife_wrap.cc')
msvcproj = env.MSVCProject(os.path.join('..', '..','..', builders.msvcbuildpath, 'fife'), projectfiles)
msvcproj9 = env.MSVCProject9(os.path.join('..', '..','..', builders.msvcbuildpath9, 'fife'), projectfiles)
cbproj_win32 = env.CodeblocksProjectWin32(os.path.join('..', '..','..', builders.cbbuildpath_win32, 'fife'), projectfiles)
cbproj_linux = env.CodeblocksProjectLinux(os.path.join('..', '..','..', builders.cbbuildpath_linux, 'fife'), projectfiles)
if opts['DEBUG'] and sys.platform == 'win32':
fife_tgt = 'fife_d'
else:
fife_tgt = 'fife'
#**************************************************************************
#shared library target
#**************************************************************************
if sys.platform == 'win32':
env.AppendUnique(CPPDEFINES = ['FIFE_EXPORTING'])
sharedlib = env.SharedLibrary(target = fife_tgt,
source = compilefiles,
OBJPREFIX='shared_',
SHLIBEMITTER = '')
elif sys.platform == 'darwin':
sharedlib = env.SharedLibrary(target = fife_tgt,
source = compilefiles)
else:
# soname will be libfife.so.major
majorVersion = opts['FIFE_VERSION'].split('.')[0]
soname = env.subst('$SHLIBPREFIX') + fife_tgt + env.subst('$SHLIBSUFFIX') + '.' + majorVersion
sharedlib = env.SharedLibrary(target = fife_tgt,
source = compilefiles,
SHLIBSUFFIX = env.subst('$SHLIBSUFFIX') + '.' + opts['FIFE_VERSION'],
LINKFLAGS=['-Wl,-soname,' + str(soname)])
#**************************************************************************
#python library target
#**************************************************************************
if sys.platform == 'win32':
dest_suffix = '.pyd'
else:
dest_suffix = '.so'
pythonlib = env.SharedLibrary(target = fife_tgt,
source = pyfiles,
OBJPREFIX='py_',
SHLIBPREFIX='_',
SHLIBSUFFIX=dest_suffix,
SHLIBEMITTER = '')
pythonext = env.PythonExtensions(target = [os.path.join('swigwrappers', 'python' ,'fife_wrap.cc'),
os.path.join('swigwrappers', 'python' ,'fife_wrap.h'),
os.path.join('python', 'fife', 'fife.py')],
source = os.path.join('swigwrappers', 'python' ,'fife.i'),
SWIGFLAGS=['-python','-c++','-w511'],
SWIGPATH='core',
SWIGOUTDIR=Dir('#/engine/python/fife').srcnode().path)
if opts['DEBUG'] and sys.platform == 'win32':
copy_dest = os.path.join(opts['PYLIB_COPY_DEST'], '_fife_d' + dest_suffix)
else:
copy_dest = os.path.join(opts['PYLIB_COPY_DEST'], '_fife' + dest_suffix)
copy_cmd = env.Command(copy_dest, pythonlib, [Copy('$TARGET', '$SOURCE')])
copy_cmd2 = env.Command(os.path.join(opts['WRAP_COPY_DEST'], 'fife_wrap.h'),
os.path.join('swigwrappers','python','fife_wrap.h'),
[Copy('$TARGET', '$SOURCE')])
copy_cmd3 = env.Command(os.path.join(opts['WRAP_COPY_DEST'], 'fife_wrap.cc'),
os.path.join('swigwrappers','python','fife_wrap.cc'),
[Copy('$TARGET', '$SOURCE')])
#**************************************************************************
#static library target
#**************************************************************************
staticlib = env.StaticLibrary(target = fife_tgt,
source = compilefiles,
LINKFLAGS=['-Wl'])
#**************************************************************************
#Install targets
#**************************************************************************
#TODO: This is not complete. Because of the current linux rpath issue this
#will not work as expected.
install_static = env.Install(opts['LIBDIR'], staticlib)
install_shared = env.Install(opts['LIBDIR'], sharedlib)
headerdestlist = utils.gen_dest_files(os.path.join(opts['PREFIX'], 'include', 'fife'), headerfiles)
install_headers = env.InstallAs(headerdestlist, headerfiles)
pypath = os.path.join(opts['PYTHON_PREFIX'], 'fife')
extdestfilelist = utils.gen_dest_files(pypath, relextensionfiles)
install_python_lib = env.Install(pypath, pythonlib)
install_python_module = env.Install(pypath, ['#/engine/python/fife/fife.py','#/engine/python/fife/__init__.py'])
install_python_extensions = env.InstallAs(extdestfilelist, extensionfiles)
if sys.platform == 'win32':
dlldestfilelist = utils.gen_dest_files(pypath, dllfiles)
dlldestfilelist2 = utils.gen_dest_files(os.path.join(engine_path, 'python', 'fife'), dllfiles)
install_dlls = env.InstallAs(dlldestfilelist, dllfilelist)
install_dlls2 = env.InstallAs(dlldestfilelist2, dllfilelist)
#**************************************************************************
#alias definitions
#**************************************************************************
alias_msvc = Alias('msvc',msvcproj)
alias_msvc9 = Alias('msvc9',msvcproj9)
alias_cbwin32 = Alias('cbwin32',cbproj_win32)
alias_cblinux = Alias('cblinux',cbproj_linux)
Alias('projects',[alias_msvc, alias_msvc9, alias_cbwin32, alias_cblinux])
alias_shared = Alias('fife-shared', sharedlib)
alias_static = Alias('fife-static', staticlib)
alias_swig = Alias('fife-swig', [pythonext, copy_cmd2, copy_cmd3])
if sys.platform == 'win32':
alias_python = Alias('fife-python', [pythonlib, copy_cmd, alias_swig, install_dlls2])
else:
alias_python = Alias('fife-python', [pythonlib, copy_cmd, alias_swig])
Alias('fife', [alias_shared, alias_static, alias_python])
alias_install_shared = Alias('install-shared', install_shared)
alias_install_static = Alias('install-static', install_static)
if sys.platform == 'win32':
alias_install_python = Alias('install-python', [alias_python, install_python_lib, install_python_module, install_python_extensions, install_dlls])
else:
alias_install_python = Alias('install-python', [alias_python, install_python_lib, install_python_module, install_python_extensions])
alias_install_dev = Alias('install-dev', [alias_install_shared, alias_install_static, install_headers])
Alias('install-all', [alias_install_python, alias_install_dev])
# vim: set filetype=python:
|