annotate src/portaudio_20161030_catalina_patch/build/scons/SConscript_opts @ 169:223a55898ab9 tip default

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