From dd0eb0294ac23ca70ab7b083ff25762ce4ee6ab3 Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Tue, 14 Apr 2020 13:43:24 -0600 Subject: Docs: update the Configure Context sections [ci skip] Apply new formatting styles. Tweak a lot of wordings. Make sure manpage consistently describes return types. Signed-off-by: Mats Wichmann --- doc/man/scons.xml | 565 +++++++++++++++++++++++++++-------------------------- doc/user/sconf.xml | 95 +++++---- 2 files changed, 343 insertions(+), 317 deletions(-) diff --git a/doc/man/scons.xml b/doc/man/scons.xml index c52a4b8..f7eed2d 100644 --- a/doc/man/scons.xml +++ b/doc/man/scons.xml @@ -3209,8 +3209,7 @@ env = Environment(CC="cc") or when copying a &consenv; using the -Clone -method: +&f-link-Clone; method: env2 = env.Clone(CC="cl.exe") @@ -3221,67 +3220,75 @@ env2 = env.Clone(CC="cl.exe") Configure Contexts -&scons; +&SCons; supports a -configure context, +&configure_context;, an integrated mechanism similar to the various AC_CHECK macros in GNU &Autoconf; -for testing for the existence of C header -files, libraries, etc. -In contrast to &Autoconf;, +for testing the existence of external items needed +for the build, such as C header files, libraries, etc. +The mechanism is portable across platforms. + + + &scons; -does not maintain an explicit cache of the tested values, +does not maintain an explicit cache of the tested values +(this is different than &Autoconf;), but uses its normal dependency tracking to keep the checked values up to date. However, users may override this behaviour with the command line option. -To create a configure context: - - Configure(env, [custom_tests, conf_dir, log_file, config_h, clean, help]) - env.Configure([custom_tests, conf_dir, log_file, config_h, clean, help]) + Configure(env, [custom_tests, conf_dir, log_file, config_h, clean, help]) + env.Configure([custom_tests, conf_dir, log_file, config_h, clean, help]) -Create a configure context, which tracks information -discovered while running tests. The context includes a -&consenv;, which is used when running the tests and -which is updated with the check results. -When the context is complete, the (possibly modified) -environment is returned). Only one context may be active +Create a &configure_context;, which tracks information +discovered while running tests. The context includes a local &consenv; +(available as context.env) +which is used when running the tests and +which can be updated with the check results. +Only one context may be active at a time (since 4.0, &scons; will raise an exception -if this rule is not followed), but a new context can be created -after the active one is completed. - -The required env argument -specifies the environment for building the tests. -custom_tests -is a dictionary containing custom tests +on an attempt to create a new context when there is +an active context), but a new context can be created +after the active one is completed. +For the global function form, the required env +describes the initial values for the context's local &consenv;; +for the &consenv; method form the instance provides the values. + +custom_tests +specifies a dictionary containing custom tests (see the section on custom tests below). -By default, no custom tests are added to the configure context. -conf_dir +The default value is None, +meaning no custom tests are added to the &configure_context;. + +conf_dir specifies a directory where the test cases are built. -Note that this directory is not used for building -normal targets. -The default value is the directory -#/.sconf_temp. -log_file +This directory is not used for building normal targets. +The default value is +#/.sconf_temp. + +log_file specifies a file which collects the output from commands that are executed to check for the existence of header files, libraries, etc. -The default is the file #/config.log. +The default is #/config.log. If you are using the &VariantDir; function, -you may want to specify a subdirectory under your variant directory. -config_h +you may want to specify a subdirectory under your variant directory. + +config_h specifies a C header file where the results of tests -will be written, e.g. +will be written. The results will consist of lines like #define HAVE_STDIO_H, #define HAVE_LIBM, etc. +Customarily, the name chosen is config.h. The default is to not write a -config.h +config_h file. You can specify the same -config.h +config_h file in multiple calls to &Configure;, in which case &SCons; will concatenate all results in the specified file. @@ -3289,19 +3296,17 @@ Note that &SCons; uses its normal dependency checking to decide if it's necessary to rebuild the specified -config_h +config_h file. This means that the file is not necessarily re-built each time scons is run, but is only rebuilt if its contents will have changed and some target that depends on the -config_h +config_h file is being built. - -The optional -clean +The clean and -help +help arguments can be used to suppress execution of the configuration tests when the / @@ -3309,15 +3314,15 @@ or // options are used, respectively. The default behavior is always to execute -configure context tests, +&configure_context; tests, since the results of the tests may affect the list of targets to be cleaned or the help text. If the configure tests do not affect these, then you may add the -clean=False + or -help=False + arguments (or both) to avoid unnecessary test execution. @@ -3325,19 +3330,19 @@ to avoid unnecessary test execution. - SConf.Finish(context) - context.Finish() + SConf.Finish(context) + context.Finish() This method must be called after configuration is done. Though required, this is not enforced except -if &Configure; is called when there still an active context, +if &Configure; is called again while there is still an active context, in which case an exception is raised. &Finish; returns the environment as modified during the course of running the configuration checks. After this method is called, no further checks can be performed with this configuration context. However, you can create a new -configure context to perform additional checks. +&configure_context; to perform additional checks. @@ -3357,19 +3362,27 @@ if conf.CheckLibWithHeader("qt", "qapp.h", "c++", "QApplication qapp(0,0);"): env = conf.Finish() -A configure context +A &configure_context; has the following predefined methods which -can be used to perform checks: +can be used to perform checks. Where +language is a required or +optional parameter, the choice can currently +be C or C++. The spellings accepted for +C are C or c; +for C++ the value can be +CXX, cxx, C++ +or c++. + - SConf.CheckHeader(context, header, [include_quotes, language]) - context.CheckHeader(header, [include_quotes, language]) + SConf.CheckHeader(context, header, [include_quotes, language]) + context.CheckHeader(header, [include_quotes, language]) Checks if -header +header is usable in the specified language. -header +header may be a list, in which case the last item in the list is the header file to be checked, @@ -3379,32 +3392,32 @@ header files whose lines should precede the header line being checked for. The optional argument -include_quotes +include_quotes must be a two character string, where the first character denotes the opening quote and the second character denotes the closing quote. -By default, both characters are " (double quote). +By default, both characters are " (double quote). The optional argument -language +language should be either C or C++ and selects the compiler to be used for the check. -Returns 1 on success and 0 on failure. +Returns a boolean indicating success or failure. - SConf.CheckCHeader(context, header, [include_quotes]) - context.CheckCHeader(header, [include_quotes]) + SConf.CheckCHeader(context, header, [include_quotes]) + context.CheckCHeader(header, [include_quotes]) This is a wrapper around -SConf.CheckHeader +SConf.CheckHeader which checks if -header +header is usable in the C language. -header +header may be a list, in which case the last item in the list is the header file to be checked, @@ -3414,25 +3427,25 @@ header files whose lines should precede the header line being checked for. The optional argument -include_quotes +include_quotes must be a two character string, where the first character denotes the opening -quote and the second character denotes the closing quote (both default -to \N'34'). -Returns 1 on success and 0 on failure. +quote and the second character denotes the closing quote. +By default, both characters are " (double quote). +Returns a boolean indicating success or failure. - SConf.CheckCXXHeader(context, header, [include_quotes]) - context.CheckCXXHeader(header, [include_quotes]) + SConf.CheckCXXHeader(context, header, [include_quotes]) + context.CheckCXXHeader(header, [include_quotes]) This is a wrapper around -SConf.CheckHeader +SConf.CheckHeader which checks if -header +header is usable in the C++ language. -header +header may be a list, in which case the last item in the list is the header file to be checked, @@ -3442,25 +3455,32 @@ header files whose lines should precede the header line being checked for. The optional argument -include_quotes +include_quotes must be a two character string, where the first character denotes the opening -quote and the second character denotes the closing quote (both default -to \N'34'). -Returns 1 on success and 0 on failure. +quote and the second character denotes the closing quote. +By default, both characters are " (double quote). +Returns a boolean indicating success or failure. - SConf.CheckFunc(context,, function_name, [header, language]) - context.CheckFunc(function_name, [header, language]) + SConf.CheckFunc(context, function_name, [header, language]) + context.CheckFunc(function_name, [header, language]) Checks if the specified -C or C++ function is available. -function_name +C or C++ library function is available based on the +context's local environment settings (that is, using +the values of CFLAGS, +CPPFLAGS, LIBS +or other relevant &consvars;). + + + +function_name is the name of the function to check for. The optional -header +header argument is a string that will be placed at the top @@ -3476,77 +3496,65 @@ extern "C" char function_name(); -The optional -language -argument should be -C -or -C++ -and selects the compiler to be used for the check; -the default is "C". + +Returns an empty string on success, a string containing +an error message on failure. + - SConf.CheckLib(context, [library, symbol, header, language, autoadd=1]) - context.CheckLib([library, symbol, header, language, autoadd=1]) + SConf.CheckLib(context, [library, symbol, header, language, autoadd=True]) + context.CheckLib([library, symbol, header, language, autoadd=True]) Checks if -library +library provides -symbol. -If the value of -autoadd -is 1 and the library provides the specified -symbol, -appends the library to the LIBS &consvar; -library -may also be None (the default), +symbol. +If +autoadd +is true (the default) and the library provides the specified +symbol, +appends the library to the LIBS &consvar; +library +may also be None (the default), in which case -symbol -is checked with the current LIBS variable, +symbol +is checked with the current LIBS variable, or a list of library names, in which case each library in the list will be checked for -symbol. +symbol. If -symbol +symbol is not set or is -None, +None, then -SConf.CheckLib() +SConf.CheckLib just checks if you can link against the specified -library. -The optional -language -argument should be -C -or -C++ -and selects the compiler to be used for the check; -the default is "C". -The default value for -autoadd -is 1. -This method returns 1 on success and 0 on error. +library. +Note though it is legal syntax, it would +not be very useful to call this method +with library +and symbol both +omitted or None. +Returns a boolean indicating success or failure. - SConf.CheckLibWithHeader(context, library, header, language, [call, autoadd]) - context.CheckLibWithHeader(library, header, language, [call, autoadd]) + SConf.CheckLibWithHeader(context, library, header, language, [call, autoadd=True]) + context.CheckLibWithHeader(library, header, language, [call, autoadd=True]) -In contrast to the -SConf.CheckLib -call, this call provides a more sophisticated way to check against libraries. -Again, -library +Provides a more sophisticated way to check against libraries then the +SConf.CheckLib call. +library specifies the library or a list of libraries to check. -header +header specifies a header to check for. -header +header may be a list, in which case the last item in the list is the header file to be checked, @@ -3555,91 +3563,95 @@ header files whose #include lines should precede the header line being checked for. -language -may be one of 'C','c','CXX','cxx','C++' and 'c++'. -call +call can be any valid expression (with a trailing ';'). If -call +call is not set, the default simply checks that you can link against the specified -library. -autoadd -specifies whether to add the library to the environment (only if the check -succeeds). This method returns 1 on success and 0 on error. +library. +autoadd (default true) +specifies whether to add the library to the environment if the check +succeeds. +Returns a boolean indicating success or failure. - SConf.CheckType(context, type_name, [includes, language]) - context.CheckType(type_name, [includes, language]) + SConf.CheckType(context, type_name, [includes, language]) + context.CheckType(type_name, [includes, language]) Checks for the existence of a type defined by -typedef. -type_name +typedef. +type_name specifies the typedef name to check for. -includes +includes is a string containing one or more #include lines that will be inserted into the program that will be run to test for the existence of the type. -The optional -language -argument should be -C -or -C++ -and selects the compiler to be used for the check; -the default is "C". Example: sconf.CheckType('foo_type', '#include "my_types.h"', 'C++') + +Returns an empty string on success, a string containing +an error message on failure. + + - SConf.CheckCC(self) - context.CheckCC(self) + SConf.CheckCC(context) + context.CheckCC() -Checks whether the C compiler (as defined by the CC &consvar;) works -by trying to compile a small source file. +Checks whether the C compiler (as defined by the +CC &consvar;) works +by trying to compile a small source file. +Returns a boolean indicating success or failure. By default, SCons only detects if there is a program with the correct name, not if it is a functioning compiler. -This uses the exact same command than the one used by the object builder for C -source file, so it can be used to detect if a particular compiler flag works or +This uses the exact same command as the one used by the object builder for C +source files, so it can be used to detect if a particular compiler flag works or not. - SConf.CheckCXX(self) - context.CheckCXX(self) + SConf.CheckCXX(context) + context.CheckCXX() -Checks whether the C++ compiler (as defined by the CXX &consvar;) -works by trying to compile a small source file. By default, SCons only detects -if there is a program with the correct name, not if it is a functioning compiler. +Checks whether the C++ compiler (as defined by the +CXX &consvar;) +works by trying to compile a small source file. By default, +SCons only detects if there is a program with the correct name, +not if it is a functioning compiler. +Returns a boolean indicating success or failure. -This uses the exact same command than the one used by the object builder for -CXX source files, so it can be used to detect if a particular compiler flag +This uses the exact same command as the one used by the object builder for +C++ source files, so it can be used to detect if a particular compiler flag works or not. - SConf.CheckSHCC(self) - context.CheckSHCC(self) + SConf.CheckSHCC(context) + context.CheckSHCC() -Checks whether the C compiler (as defined by the SHCC &consvar;) works -by trying to compile a small source file. By default, SCons only detects if -there is a program with the correct name, not if it is a functioning compiler. +Checks whether the shared-object C compiler (as defined by the +SHCC &consvar;) works +by trying to compile a small source file. By default, +SCons only detects if there is a program with the correct name, +not if it is a functioning compiler. +Returns a boolean indicating success or failure. -This uses the exact same command than the one used by the object builder for C +This uses the exact same command as the one used by the object builder for C source file, so it can be used to detect if a particular compiler flag works or not. This does not check whether the object code can be used to build a shared library, only that the compilation (not link) succeeds. @@ -3647,97 +3659,90 @@ library, only that the compilation (not link) succeeds. - SConf.CheckSHCXX(self) - context.CheckSHCXX(self) + SConf.CheckSHCXX(context) + context.CheckSHCXX() -Checks whether the C++ compiler (as defined by the SHCXX &consvar;) -works by trying to compile a small source file. By default, SCons only detects -if there is a program with the correct name, not if it is a functioning compiler. +Checks whether the shared-object C++ compiler (as defined by the +SHCXX &consvar;) +works by trying to compile a small source file. By default, +SCons only detects if there is a program with the correct name, +not if it is a functioning compiler. +Returns a boolean indicating success or failure. -This uses the exact same command than the one used by the object builder for -CXX source files, so it can be used to detect if a particular compiler flag +This uses the exact same command as the one used by the object builder for +C++ source files, so it can be used to detect if a particular compiler flag works or not. This does not check whether the object code can be used to build a shared library, only that the compilation (not link) succeeds. - SConf.CheckTypeSize(context, type_name, [header, language, expect]) - context.CheckTypeSize(type_name, [header, language, expect]) + SConf.CheckTypeSize(context, type_name, [header, language, expect]) + context.CheckTypeSize(type_name, [header, language, expect]) Checks for the size of a type defined by -typedef. -type_name +typedef. +type_name specifies the typedef name to check for. The optional -header +header argument is a string that will be placed at the top of the test file that will be compiled -to check if the function exists; +to check if the type exists; the default is empty. -The optional -language -argument should be -C -or -C++ -and selects the compiler to be used for the check; -the default is "C". -The optional -expect -argument should be an integer. -If this argument is used, -the function will only check whether the type -given in type_name has the expected size (in bytes). +If the optional +expect, +is supplied, it should be an integer size; +&CheckTypeSize; will fail unless +type_name is actually +that size. +Returns the size in bytes, or zero if the type was not found +(or if the size did not match expect). + + For example, CheckTypeSize('short', expect=2) -will return success only if short is two bytes. +will return the size 2 only if short is +actually two bytes. - SConf.CheckDeclaration(context, symbol, [includes, language]) - context.CheckDeclaration(symbol, [includes, language]) + SConf.CheckDeclaration(context, symbol, [includes, language]) + context.CheckDeclaration(symbol, [includes, language]) Checks if the specified -symbol +symbol is declared. -includes +includes is a string containing one or more -#include +#include lines that will be inserted into the program -that will be run to test for the existence of the type. -The optional -language -argument should be -C -or -C++ -and selects the compiler to be used for the check; -the default is "C". +that will be run to test for the existence of the symbol. +Returns a boolean indicating success or failure. - SConf.Define(context, symbol, [value, comment]) - context.Define(symbol, [value, comment]) + SConf.Define(context, symbol, [value, comment]) + context.Define(symbol, [value, comment]) This function does not check for anything, but defines a preprocessor symbol that will be added to the configuration header file. -It is the equivalent of AC_DEFINE, +It is the equivalent of AC_DEFINE, and defines the symbol -name +name with the optional -value +value and the optional comment -comment. +comment. Define Examples: @@ -3787,112 +3792,119 @@ conf.Define("A_SYMBOL", 1, "Set to 1 if you have a symbol") -You can define your own custom checks. +You can define your own custom checks in addition to the predefined checks. -These are passed in a dictionary to the Configure function. +You pass a dictionary of these +to the &Configure; function +as the custom_tests argument. This dictionary maps the names of the checks -to user defined Python callables -(either Python functions or class instances implementing the -__call__ +to the user defined Python callables +(either Python functions or class instances implementing a +__call__ method). -The first argument of the call is always a -CheckContext +Each custom check will be called with a first +argument of a CheckContext, instance followed by the arguments, which must be supplied by the user of the check. -These CheckContext instances define the following methods: +A CheckContext instance defines the following methods: - CheckContext.Message(self, text) + context.Message(text) -Usually called before the check is started. -text -will be displayed to the user, e.g. 'Checking for library X...' +Displays a message, as an indicator of progess. +text +will be displayed, e.g. +Checking for library X.... +Usually called before the check is started. + - CheckContext.Result(self, res) + context.Result(res) -Usually called after the check is done. -res -can be either an integer or a string. In the former case, 'yes' (res != 0) -or 'no' (res == 0) is displayed to the user, in the latter case the -given string is displayed. +Displays a result message, as an indicator of progress. + +res +can be either an integer or a string. If an integer, displays +yes +(if res evaluates True) +or no +(if res evaluates False). +If a string, it is displayed as-is. +Usually called after the check has completed. - CheckContext.TryCompile(self, text, extension) + context.TryCompile(text, extension='') Checks if a file with the specified -extension +extension (e.g. '.c') containing -text +text can be compiled using the environment's -Object -builder. Returns 1 on success and 0 on failure. +&Object; builder. +Returns a boolean indicating success or failure. - CheckContext.TryLink(self, text, extension) + context.TryLink(text, extension='') Checks, if a file with the specified -extension +extension (e.g. '.c') containing -text -can be compiled using the environment's -Program -builder. Returns 1 on success and 0 on failure. +text +can be compiled using the environment's &Program; builder. +Returns a boolean indicating success or failure. - CheckContext.TryRun(self, text, extension) + context.TryRun(text, extension='') -Checks, if a file with the specified -extension +Checks if a file with the specified +extension (e.g. '.c') containing -text +text can be compiled using the environment's -Program -builder. On success, the program is run. If the program +&Program; builder. On success, the program is run. If the program executes successfully (that is, its return status is 0), a tuple (1, outputStr) is returned, where -outputStr +outputStr is the standard output of the program. If the program fails execution (its return status is non-zero), -then (0, '') is returned. +then (0, '') is returned. - CheckContext.TryAction(self, action, [text, extension]) + context.TryAction(action, [text, extension='']) Checks if the specified -action +action with an optional source file (contents -text -, extension -extension -= '' -) can be executed. -action +text, +extension +extension) +can be executed. +action may be anything which can be converted to a &scons; Action. On success, (1, outputStr) is returned, where -outputStr +outputStr is the content of the target file. On failure (0, '') @@ -3901,23 +3913,24 @@ is returned. - CheckContext.TryBuild(self, builder, [text, extension]) + context.TryBuild(builder[, text, extension='']) Low level implementation for testing specific builds; the methods above are based on this method. Given the Builder instance -builder +builder and the optional -text +text of a source file with optional -extension, -this method returns 1 on success and 0 on failure. In addition, -self.lastTarget -is set to the build target node, if the build was successful. +extension, +returns a boolean indicating success or failure. +In addition, +context.lastTarget +is set to the build target node if the build was successful. -Example for implementing and using custom tests: +Example of implementing and using custom tests: def CheckQt(context, qtdir): @@ -3925,7 +3938,7 @@ def CheckQt(context, qtdir): lastLIBS = context.env['LIBS'] lastLIBPATH = context.env['LIBPATH'] lastCPPPATH= context.env['CPPPATH'] - context.env.Append(LIBS = 'qt', LIBPATH = qtdir + '/lib', CPPPATH = qtdir + '/include' ) + context.env.Append(LIBS='qt', LIBPATH=qtdir + '/lib', CPPPATH=qtdir + '/include') ret = context.TryLink(""" #include <qapp.h> int main(int argc, char **argv) { @@ -3934,12 +3947,12 @@ int main(int argc, char **argv) { } """) if not ret: - context.env.Replace(LIBS = lastLIBS, LIBPATH=lastLIBPATH, CPPPATH=lastCPPPATH) + context.env.Replace(LIBS=lastLIBS, LIBPATH=lastLIBPATH, CPPPATH=lastCPPPATH) context.Result( ret ) return ret env = Environment() -conf = Configure( env, custom_tests = { 'CheckQt' : CheckQt } ) +conf = Configure(env, custom_tests = {'CheckQt': CheckQt}) if not conf.CheckQt('/usr/lib/qt'): print('We really need qt!') Exit(1) diff --git a/doc/user/sconf.xml b/doc/user/sconf.xml index 109e468..8961606 100644 --- a/doc/user/sconf.xml +++ b/doc/user/sconf.xml @@ -46,35 +46,29 @@ - &SCons; has integrated support for multi-platform build configuration - similar to that offered by GNU &Autoconf;, - such as - figuring out what libraries or header files - are available on the local system. + &SCons; has integrated support for build configuration + similar in style to GNU &Autoconf;, but designed to be + transparently multi-platform. The configuration system + can help figure out if external build requirements such + as system libraries or header files + are available on the build system. This section describes how to use this &SCons; feature. + (See also the &SCons; man page for additional information). - - - This chapter is still under development, - so not everything is explained as well as it should be. - See the &SCons; man page for additional information. - - -
&Configure_Contexts; The basic framework for multi-platform build configuration - in &SCons; is to attach a &configure_context; to a - construction environment by calling the &Configure; function, - perform a number of checks for + in &SCons; is to create a &configure_context; inside a + &consenv; by calling the &Configure; function, + perform the desired checks for libraries, functions, header files, etc., - and to then call the configure context's &Finish; method + and then call the configure context's &Finish; method to finish off the configuration: @@ -88,7 +82,15 @@ env = conf.Finish() - &SCons; provides a number of basic checks, + The &Finish; call is required; if a new context is + created while a context is active, even in a different + &consenv;, &scons; will complain and exit. + + + + + + &SCons; provides a number of pre-defined basic checks, as well as a mechanism for adding your own custom checks. @@ -125,8 +127,11 @@ env = conf.Finish() Testing the existence of a header file requires knowing what language the header file is. - A configure context has a &CheckCHeader; method - that checks for the existence of a C header file: + This information is supplied in the language + keyword parameter to the &CheckHeader; method. + Since &scons; grew up in a world of C/C++ code, + a &configure_context; also has a &CheckCHeader; method + that specifically checks for the existence of a C header file: @@ -134,7 +139,7 @@ env = conf.Finish() env = Environment() conf = Configure(env) if not conf.CheckCHeader('math.h'): - print 'Math.h must be installed!' + print('Math.h must be installed!') Exit(1) if conf.CheckCHeader('foo.h'): conf.env.Append('-DHAS_FOO_H') @@ -143,10 +148,18 @@ env = conf.Finish() - Note that you can choose to terminate + As shown in the example, depending on the circumstances + you can choose to terminate the build if a given header file doesn't exist, or you can modify the construction environment - based on the existence of a header file. + based on the presence or absence of a header file + (the same applies to any other check). If there are a + many elements to check for, it may be friendlier for + the user if you do not terminate on the first failure, + but track the problems found until the end and report on + all of them, that way the user does not have to iterate + multiple times, each time finding one new dependency that + needs to be installed. @@ -162,7 +175,7 @@ env = conf.Finish() env = Environment() conf = Configure(env) if not conf.CheckCXXHeader('vector.h'): - print 'vector.h must be installed!' + print('vector.h must be installed!') Exit(1) env = conf.Finish() @@ -183,8 +196,8 @@ env = conf.Finish() env = Environment() conf = Configure(env) if not conf.CheckFunc('strcpy'): - print 'Did not find strcpy(), using local version' - conf.env.Append(CPPDEFINES = '-Dstrcpy=my_local_strcpy') + print('Did not find strcpy(), using local version') + conf.env.Append(CPPDEFINES='-Dstrcpy=my_local_strcpy') env = conf.Finish() @@ -197,7 +210,7 @@ env = conf.Finish() Check for the availability of a library using the &CheckLib; method. - You only specify the basename of the library, + You only specify the base part of the library name, you don't need to add a lib prefix or a .a or .lib suffix: @@ -207,7 +220,7 @@ env = conf.Finish() env = Environment() conf = Configure(env) if not conf.CheckLib('m'): - print 'Did not find libm.a or m.lib, exiting!' + print('Did not find libm.a or m.lib, exiting!') Exit(1) env = conf.Finish() @@ -227,8 +240,8 @@ env = conf.Finish() env = Environment() conf = Configure(env) -if not conf.CheckLibWithHeader('m', 'math.h', 'c'): - print 'Did not find libm.a or m.lib, exiting!' +if not conf.CheckLibWithHeader('m', 'math.h', language='c'): + print('Did not find libm.a or m.lib, exiting!') Exit(1) env = conf.Finish() @@ -257,8 +270,8 @@ env = conf.Finish() env = Environment() conf = Configure(env) if not conf.CheckType('off_t'): - print 'Did not find off_t typedef, assuming int' - conf.env.Append(CCFLAGS = '-Doff_t=int') + print('Did not find off_t typedef, assuming int') + conf.env.Append(CCFLAGS='-Doff_t=int') env = conf.Finish() @@ -276,8 +289,8 @@ env = conf.Finish() env = Environment() conf = Configure(env) if not conf.CheckType('off_t', '#include <sys/types.h>\n'): - print 'Did not find off_t typedef, assuming int' - conf.env.Append(CCFLAGS = '-Doff_t=int') + print('Did not find off_t typedef, assuming int') + conf.env.Append(CCFLAGS='-Doff_t=int') env = conf.Finish() @@ -292,7 +305,7 @@ env = conf.Finish() env = Environment() conf = Configure(env) int_size = conf.CheckTypeSize('unsigned int') -print 'sizeof unsigned int is', int_size +print('sizeof unsigned int is', int_size) env = conf.Finish() @@ -317,7 +330,7 @@ scons: `.' is up to date. env = Environment() conf = Configure(env) if not conf.CheckProg('foobar'): - print 'Unable to find the program foobar on the system' + print('Unable to find the program foobar on the system') Exit(1) env = conf.Finish() @@ -399,7 +412,7 @@ def CheckMyLibrary(context): env = Environment() -conf = Configure(env, custom_tests = {'CheckMyLibrary' : CheckMyLibrary}) +conf = Configure(env, custom_tests={'CheckMyLibrary': CheckMyLibrary}) @@ -436,9 +449,9 @@ def CheckMyLibrary(context): return result env = Environment() -conf = Configure(env, custom_tests = {'CheckMyLibrary' : CheckMyLibrary}) +conf = Configure(env, custom_tests={'CheckMyLibrary': CheckMyLibrary}) if not conf.CheckMyLibrary(): - print 'MyLibrary is not installed!' + print('MyLibrary is not installed!') Exit(1) env = conf.Finish() @@ -516,9 +529,9 @@ Removed foo env = Environment() if not env.GetOption('clean'): - conf = Configure(env, custom_tests = {'CheckMyLibrary' : CheckMyLibrary}) + conf = Configure(env, custom_tests={'CheckMyLibrary': CheckMyLibrary}) if not conf.CheckMyLibrary(): - print 'MyLibrary is not installed!' + print('MyLibrary is not installed!') Exit(1) env = conf.Finish() -- cgit v0.12