annotate src/portaudio_20161030/build/scons/SConscript_opts @ 140:59a8758c56b1

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