| 1 |
import os.path, sys |
| 2 |
|
| 3 |
def _PackageOption(pkgName, default=1): |
| 4 |
""" Allow user to choose whether a package should be used if available. This results in a commandline option use<Pkgname>, |
| 5 |
where Pkgname is the name of the package with a capitalized first letter. |
| 6 |
@param pkgName: Name of package. |
| 7 |
@param default: The default value for this option ("yes"/"no"). |
| 8 |
""" |
| 9 |
return BoolOption("use%s" % pkgName[0].upper() + pkgName[1:], "use %s if available" % (pkgName), default) |
| 10 |
|
| 11 |
def _BoolOption(opt, explanation, default=1): |
| 12 |
""" Allow user to enable/disable a certain option. This results in a commandline option enable<Option>, where Option |
| 13 |
is the name of the option with a capitalized first letter. |
| 14 |
@param opt: Name of option. |
| 15 |
@param explanation: Explanation of option. |
| 16 |
@param default: The default value for this option (1/0). |
| 17 |
""" |
| 18 |
return BoolOption("enable%s" % opt[0].upper() + opt[1:], explanation, default) |
| 19 |
|
| 20 |
def _EnumOption(opt, explanation, allowedValues, default): |
| 21 |
""" Allow the user to choose among a set of values for an option. This results in a commandline option with<Option>, |
| 22 |
where Option is the name of the option with a capitalized first letter. |
| 23 |
@param opt: The name of the option. |
| 24 |
@param explanation: Explanation of option. |
| 25 |
@param allowedValues: The set of values to choose from. |
| 26 |
@param default: The default value. |
| 27 |
""" |
| 28 |
assert default in allowedValues |
| 29 |
return EnumOption("with%s" % opt[0].upper() + opt[1:], explanation, default, allowed_values=allowedValues) |
| 30 |
|
| 31 |
def _DirectoryOption(opt, explanation, default): |
| 32 |
""" Allow the user to configure the location for a certain directory, for instance the prefix. This results in a |
| 33 |
commandline option which is simply the name of this option. |
| 34 |
@param opt: The configurable directory, for instance "prefix". |
| 35 |
@param explanation: Explanation of option. |
| 36 |
@param default: The default value for this option. |
| 37 |
""" |
| 38 |
return PathOption(opt, explanation, default) |
| 39 |
# Incompatible with the latest stable SCons |
| 40 |
# return PathOption(path, help, default, PathOption.PathIsDir) |
| 41 |
|
| 42 |
import SCons.Errors |
| 43 |
try: |
| 44 |
Import("Platform", "Posix") |
| 45 |
except SCons.Errors.UserError: |
| 46 |
# The common objects must be exported first |
| 47 |
SConscript("SConscript_common") |
| 48 |
Import("Platform", "Posix") |
| 49 |
|
| 50 |
# Expose the options as a dictionary of sets of options |
| 51 |
opts = {} |
| 52 |
|
| 53 |
if Platform in Posix: |
| 54 |
opts["Installation Dirs"] = [_DirectoryOption("prefix", "installation prefix", "/usr/local")] |
| 55 |
elif Platform in Windows: |
| 56 |
if Platform == "cygwin": |
| 57 |
opts["Installation Dirs"] = [_DirectoryOption("prefix", "installation prefix", "/usr/local")] |
| 58 |
|
| 59 |
opts["Build Targets"] = [_BoolOption("shared", "create shared library"), _BoolOption("static", "create static library"), |
| 60 |
_BoolOption("tests", "build test programs")] |
| 61 |
|
| 62 |
apis = [] |
| 63 |
if Platform in Posix: |
| 64 |
apis.append(_PackageOption("OSS")) |
| 65 |
apis.append(_PackageOption("JACK")) |
| 66 |
apis.append(_PackageOption("ALSA", Platform == "linux")) |
| 67 |
apis.append(_PackageOption("ASIHPI", Platform == "linux")) |
| 68 |
apis.append(_PackageOption("COREAUDIO", Platform == "darwin")) |
| 69 |
elif Platform in Windows: |
| 70 |
if Platform == "cygwin": |
| 71 |
apis.append(_EnumOption("winAPI", "Windows API to use", ("wmme", "directx", "asio"), "wmme")) |
| 72 |
|
| 73 |
opts["Host APIs"] = apis |
| 74 |
|
| 75 |
opts["Build Parameters"] = [\ |
| 76 |
_BoolOption("debug", "compile with debug symbols"), |
| 77 |
_BoolOption("optimize", "compile with optimization", default=0), |
| 78 |
_BoolOption("asserts", "runtime assertions are helpful for debugging, but can be detrimental to performance", |
| 79 |
default=1), |
| 80 |
_BoolOption("debugOutput", "enable debug output", default=0), |
| 81 |
# _BoolOption("python", "create Python binding"), |
| 82 |
("customCFlags", "customize compilation of C code", ""), |
| 83 |
("customCxxFlags", "customize compilation of C++ code", ""), |
| 84 |
("customLinkFlags", "customize linking", ""), |
| 85 |
] |
| 86 |
|
| 87 |
opts["Bindings"] = [\ |
| 88 |
_BoolOption("cxx", "build Merlijn Blaauw's PA C++ wrapper", default=0) |
| 89 |
] |
| 90 |
|
| 91 |
Return("opts") |