annotate src/portaudio_20140130/build/scons/SConscript_opts @ 39:7ddb4fc30dac

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