Use SCons to easily build your own program (1)

Source: Internet
Author: User

The make tool is usually used to build programs during software project development. The make tool can automatically detect dependencies between files through a configuration file called Makefile, which is very helpful for building complex projects, writing Makefile is not an easy task. SCons is a program written in Python similar to the make tool. Compared with the make tool, the SCons configuration file is simpler and clearer. In addition, it has many advantages. This article will briefly introduce how to use SCons in software development projects. Through this article, readers can learn how to use SCons to build their own program projects.

The make tool has been one of the favorites of UNIX-like programmers since it was developed in the Bell lab in the 1970s S. By checking the file modification time, the make tool can know the other files on which the target file is to be compiled. In a complex project, if only a few files have been modified, the make tool knows which files need to be re-compiled to ensure that the target program is properly compiled. The advantage of doing so is that in compilation, not only can save a lot of Repeated input, but also can ensure that the program can be properly linked and shorten the Compilation Time. However, it is not easy to compile building rules for the make tool. Its Complex Configuration Rules are daunting for experienced developers. Many alternatives to the make tool were born. SCons is one of them. SCons is a program written in Python similar to the make tool. Compared with the make tool, the SCons configuration file is simpler and clearer. In addition, it has many advantages.

SCons Introduction

SCons is an open-source, next-generation program building tool written in Python. Its initial name was ScCons, developed based on the Cons Software written in perl, which won the SC build competition held by Software Carpentry in August 2000. Now ScCons has been renamed as SCons, so that it is no longer associated with Software Carpentry. Of course, there is another purpose, that is, to facilitate input.

As the next generation of software building tools, SCons is designed to make it easier, more reliable, and faster for developers to build software. Compared with traditional make tools, SCons has the following advantages:

● Use the Python script as the configuration file

● For C, C ++, and Fortran, built-in support for reliable automatic dependency analysis. you do not need to execute "make depends" or "make clean" as the make tool does to obtain all dependencies.

● Built-in support for C, C ++, D, Java, Fortran, Yacc, Lex, Qt, SWIG, And Tex/Latex. You can also expand your own needs to get support for the required programming language.

● Support parallel build of the make-j style. Compared with make-j, SCons can run N jobs at the same time without worrying about the code hierarchy.

● Use the Autoconf style to search for header files, function libraries, functions, and type definitions.

● Excellent platforms. SCons can run on Linux, AIX, BSD, HP/UX, IRIX, Solaris, Windows, Mac OS x, and OS/2.

Install SCons

SCons supports a variety of operating system platforms and creates easy-to-install files for each system. Therefore, the installation methods on each system platform are different, on the SCons official website, you can check the specific installation methods for each platform. If SCons does not have an installation package for your system, you can download the source code of SCons and install it directly. First, download the latest SCons source code package (the latest version of SCons is 2.0.1) from the SCons website ). Next, extract the downloaded source code. There are different methods depending on the format of the downloaded source code package. on the Windows platform, you can decompress the package using winzip or other similar tools. On Linux, run the tar command to decompress the tar package, for example:

$ tar -zxf scons-2.0.1.tar.gz

Switch to the decompressed directory for installation, as shown in figure

$ cd scons-2.0.1$ sudo python setup.py install

If there is no error in command execution, scons will be installed on the system. For Linux, scons will be installed in the/usr/loca/bin directory by default, while on Windows, scons will be installed in C: \ Python25 \ Scripts.


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.