annotate src/portaudio_20161030/build/scons/SConscript_opts @ 55:284acf908dcd

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