A summary of software building tools scons in large-scale projects

Source: Internet
Author: User


A unified software building environment for the team was recently built to provide a unified compilation framework and commands for more than 10 software modules with SCons, supporting the generation of release/debug different versions of executables while supporting different levels of debugging.


1. Overall structure and implementation process


A. Agree on the relative position of different modules in a unified code base

Because the software module may exist between library dependencies, header file dependencies and other relationships, fixed relative path can make the module contains other module header files or library script statements fixed down;


B. Write sconscript scripts for each new add-on module, using scons, Python statements to build, deploy and purge software;


C. If the submodule, a similar Rpcgen tool supported by scons automatically generates generated code, define the corresponding environment variables in the corresponding sconscript, such as Rpcgen corresponding $rpcgen, $RPCGENCLIENTFLAGS, $ Rpcgenflags, $RPCGENHEADERFLAGS, $RPCGENSERVICEFLAGS, $RPCGENXDRFLAGS;


C. If the sub-module, there is scons unsupported similar thrift tool automatically generated generated code, in the corresponding sconscript can be Pythonos.system ()/os.popen () /commands.getoutputstatus () Call "Thrift" command implementation;


D. At the top level of the code base, the definition of ccflags, Ccpdefines, LIBS, Cpppath and Libpath is realized according to the agreed parameter definition;


E. At the top level of the code base, implement the Sconstruct script, which uses relative paths to refer to the Sconscript script of each submodule;


2. Build frameworks and scripts with existing submodule software

If the submodule already has a ready-made sconstruct, there are two ways of handling it for different situations:

A. If the Sconsript script of a submodule can be called from a submodule or from the topmost layer of the code base, then the sconscript of the submodule can be referenced directly from the topmost layer.

B. If the submodule's sconsript script can only be called from a submodule, then the Pythonos.system ()/os.popen () function can be passed from the top-level through the ' Cdsubdir && scons ' To refer to the sconstruct of the submodule.


3. Ensure consistent compilation options and configurations can be passed to each sub-module

In order to ensure that the submodule can inherit the environment variable setting of the topmost module, the environment settings such as Ccflags/cpppath/ccpdefines/libpath defined by the topmost module must be export, and the import () is required in the submodule.


If the top-level script can only refer to the sconstruct of a submodule using functions such as Pythonos.system ()/os.popen (), such as ' Cdsubdir &&scons ', then it is also necessary to ensure that the top-level parameters are passed to the child module. and the sub-module is the same as the top level of the parameter processing.


4. Precautions

In the process of compiling multiple modules, it is important to clarify the dependencies between the modules, to figure out which modules must be compiled before which module, and then to ensure this dependency in the SCons script. There are two ways to achieve this:

1. Use Sconspreaction/requires and other functions to limit the order of compilation;

2. Compile the module of the sconstruct script that needs to jump to the subdirectory and then call the subdirectory, and make sure that the library that the module depends on is already generated. In this case, it is important to note, however: if the Sconstruct script contains Python statements other than scons, the SCons interpreter will take precedence over all non-scons python statements. Finally, the SCons statement is executed to refer to the sconscript of the submodule.






This article is from the "Store Chef" blog, so be sure to keep this source http://xiamachao.blog.51cto.com/10580956/1867453

A summary of software building tools scons in large-scale projects

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.