Skip to content
Snippets Groups Projects
Commit f31e3ba4 authored by nicolas's avatar nicolas
Browse files

Move sections around to allow porting to windows

We will need to use the environment's CC variable to make decisions
that apply to windows compiling and linking. Therefore we move some
existing sections below the set up of env["CC"] and env["CXX"]
parent 45eea0d9
No related branches found
No related tags found
No related merge requests found
...@@ -4,7 +4,6 @@ import os.path ...@@ -4,7 +4,6 @@ import os.path
import platform import platform
import sys import sys
vars = Variables(None, ARGUMENTS) vars = Variables(None, ARGUMENTS)
vars.Add(PathVariable('DESTDIR', "Root directory to install in (useful for packaging scripts)", None, PathVariable.PathIsDirCreate)) 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", "/usr/local", PathVariable.PathAccept))
...@@ -49,15 +48,6 @@ env['backendsincpath'] = calcInstallPath("$prefix", "include", "hammer", "backen ...@@ -49,15 +48,6 @@ env['backendsincpath'] = calcInstallPath("$prefix", "include", "hammer", "backen
env['pkgconfigpath'] = calcInstallPath("$prefix", "lib", "pkgconfig") env['pkgconfigpath'] = calcInstallPath("$prefix", "lib", "pkgconfig")
env.ScanReplace('libhammer.pc.in') env.ScanReplace('libhammer.pc.in')
env.MergeFlags("-std=gnu99 -Wall -Wextra -Werror -Wno-unused-parameter -Wno-attributes -Wno-unused-variable")
if env['PLATFORM'] == 'darwin':
env.Append(SHLINKFLAGS = '-install_name ' + env["libpath"] + '/${TARGET.file}')
elif os.uname()[0] == "OpenBSD":
pass
else:
env.MergeFlags("-lrt")
AddOption("--variant", AddOption("--variant",
dest="variant", dest="variant",
nargs=1, type="choice", nargs=1, type="choice",
...@@ -78,20 +68,23 @@ AddOption("--in-place", ...@@ -78,20 +68,23 @@ AddOption("--in-place",
action="store_true", action="store_true",
help="Build in-place, rather than in the build/<variant> tree") help="Build in-place, rather than in the build/<variant> tree")
env["CC"] = os.getenv("CC") or env["CC"]
env["CXX"] = os.getenv("CXX") or env["CXX"]
dbg = env.Clone(VARIANT='debug') if os.getenv("CC") == "clang" or env['PLATFORM'] == 'darwin':
dbg.Append(CCFLAGS=['-g']) env.Replace(CC="clang",
CXX="clang++")
opt = env.Clone(VARIANT='opt') # Language standard and warnings
opt.Append(CCFLAGS=["-O3"]) env.MergeFlags("-std=gnu99 -Wall -Wextra -Werror -Wno-unused-parameter -Wno-attributes -Wno-unused-variable")
if GetOption("variant") == 'debug': # Linker options
env = dbg if env['PLATFORM'] == 'darwin':
env.Append(SHLINKFLAGS = '-install_name ' + env["libpath"] + '/${TARGET.file}')
elif platform.system() == "OpenBSD":
pass
else: else:
env = opt env.MergeFlags("-lrt")
env["CC"] = os.getenv("CC") or env["CC"]
env["CXX"] = os.getenv("CXX") or env["CXX"]
if GetOption("coverage"): if GetOption("coverage"):
env.Append(CFLAGS=["--coverage"], env.Append(CFLAGS=["--coverage"],
...@@ -102,9 +95,16 @@ if GetOption("coverage"): ...@@ -102,9 +95,16 @@ if GetOption("coverage"):
else: else:
env.ParseConfig('llvm-config --ldflags') env.ParseConfig('llvm-config --ldflags')
if os.getenv("CC") == "clang" or env['PLATFORM'] == 'darwin': dbg = env.Clone(VARIANT='debug')
env.Replace(CC="clang", dbg.Append(CCFLAGS=['-g'])
CXX="clang++")
opt = env.Clone(VARIANT='opt')
opt.Append(CCFLAGS=["-O3"])
if GetOption("variant") == 'debug':
env = dbg
else:
env = opt
env["ENV"].update(x for x in os.environ.items() if x[0].startswith("CCC_")) env["ENV"].update(x for x in os.environ.items() if x[0].startswith("CCC_"))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment