Port scons build files for Windows users
We disable: - the tests (which require glib) although they can be reactivated with the `--tests` command line flag - shared library (lack of export symbol declarations means that although it can be built, no symbol is exported and therefore it can't be used) The `install` target installs the library and headers under the `build` folder, because it's a traditional practice to move libraries to a central location on Windows, unless you are using cygwin. In which case pass `prefix` to the command line. We adapt tools\windows\build_examples.bat to take the library that is built using scons or using tools\windows\build.bat
This commit is contained in:
parent
f31e3ba4bd
commit
69d3e70211
4 changed files with 76 additions and 21 deletions
43
SConstruct
43
SConstruct
|
|
@ -4,9 +4,13 @@ import os.path
|
|||
import platform
|
||||
import sys
|
||||
|
||||
default_install_dir="/usr/local"
|
||||
if platform.system() == 'Windows':
|
||||
default_install_dir = "build" # no obvious place for installation on Windows
|
||||
|
||||
vars = Variables(None, ARGUMENTS)
|
||||
vars.Add(PathVariable('DESTDIR', "Root directory to install in (useful for packaging scripts)", None, PathVariable.PathIsDirCreate))
|
||||
vars.Add(PathVariable('prefix', "Where to install in the FHS", "/usr/local", PathVariable.PathAccept))
|
||||
vars.Add(PathVariable('prefix', "Where to install in the FHS", default_install_dir, PathVariable.PathAccept))
|
||||
vars.Add(ListVariable('bindings', 'Language bindings to build', 'none', ['cpp', 'dotnet', 'perl', 'php', 'python', 'ruby']))
|
||||
|
||||
tools = ['default', 'scanreplace']
|
||||
|
|
@ -16,6 +20,9 @@ if 'dotnet' in ARGUMENTS.get('bindings', []):
|
|||
envvars = {'PATH' : os.environ['PATH']}
|
||||
if 'PKG_CONFIG_PATH' in os.environ:
|
||||
envvars['PKG_CONFIG_PATH'] = os.environ['PKG_CONFIG_PATH']
|
||||
if platform.system() == 'Windows':
|
||||
# from the scons FAQ (keywords: LNK1104 TEMPFILE), needed by link.exe
|
||||
envvars['TMP'] = os.environ['TMP']
|
||||
|
||||
env = Environment(ENV = envvars,
|
||||
variables = vars,
|
||||
|
|
@ -68,6 +75,12 @@ AddOption("--in-place",
|
|||
action="store_true",
|
||||
help="Build in-place, rather than in the build/<variant> tree")
|
||||
|
||||
AddOption("--tests",
|
||||
dest="with_tests",
|
||||
default=env['PLATFORM'] != 'win32',
|
||||
action="store_true",
|
||||
help="Build tests")
|
||||
|
||||
env["CC"] = os.getenv("CC") or env["CC"]
|
||||
env["CXX"] = os.getenv("CXX") or env["CXX"]
|
||||
|
||||
|
|
@ -76,13 +89,29 @@ if os.getenv("CC") == "clang" or env['PLATFORM'] == 'darwin':
|
|||
CXX="clang++")
|
||||
|
||||
# Language standard and warnings
|
||||
env.MergeFlags("-std=gnu99 -Wall -Wextra -Werror -Wno-unused-parameter -Wno-attributes -Wno-unused-variable")
|
||||
if env["CC"] == "cl":
|
||||
env.MergeFlags("-W3 -WX")
|
||||
env.Append(
|
||||
CPPDEFINES=[
|
||||
"_CRT_SECURE_NO_WARNINGS" # allow uses of sprintf
|
||||
],
|
||||
CFLAGS=[
|
||||
"-wd4018", # 'expression' : signed/unsigned mismatch
|
||||
"-wd4244", # 'argument' : conversion from 'type1' to 'type2', possible loss of data
|
||||
"-wd4267", # 'var' : conversion from 'size_t' to 'type', possible loss of data
|
||||
]
|
||||
)
|
||||
else:
|
||||
env.MergeFlags("-std=gnu99 -Wall -Wextra -Werror -Wno-unused-parameter -Wno-attributes -Wno-unused-variable")
|
||||
|
||||
# Linker options
|
||||
if env['PLATFORM'] == 'darwin':
|
||||
env.Append(SHLINKFLAGS = '-install_name ' + env["libpath"] + '/${TARGET.file}')
|
||||
elif platform.system() == "OpenBSD":
|
||||
pass
|
||||
elif env['PLATFORM'] == 'win32':
|
||||
# no extra lib needed
|
||||
pass
|
||||
else:
|
||||
env.MergeFlags("-lrt")
|
||||
|
||||
|
|
@ -96,10 +125,16 @@ if GetOption("coverage"):
|
|||
env.ParseConfig('llvm-config --ldflags')
|
||||
|
||||
dbg = env.Clone(VARIANT='debug')
|
||||
dbg.Append(CCFLAGS=['-g'])
|
||||
if env["CC"] == "cl":
|
||||
dbg.Append(CCFLAGS=["/Z7"])
|
||||
else:
|
||||
dbg.Append(CCFLAGS=['-g'])
|
||||
|
||||
opt = env.Clone(VARIANT='opt')
|
||||
opt.Append(CCFLAGS=["-O3"])
|
||||
if env["CC"] == "cl":
|
||||
opt.Append(CCFLAGS=["/O2"])
|
||||
else:
|
||||
opt.Append(CCFLAGS=["-O3"])
|
||||
|
||||
if GetOption("variant") == 'debug':
|
||||
env = dbg
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue