annotate src/portaudio_20140130/build/scons/SConscript_opts @ 124:e3d5853d5918

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