Python Automation build Tools SCons Use introductory notes _python

Source: Internet
Author: User
Tags glob

This period of time used to SCons, summed up here, but also convenient for me to consult later.

I. Installation of SCons
Linux Environment (take CentOS as an example)

1, yum Installation

Yum Install SCons
2, the source code installation

Download Scons:http://http://jaist.dl.sourceforge.net/project/scons/scons/2.3.0/scons-2.3.0.zip

Install Scons:python setup.py Install

Second, scons Common command

Scons-c: You can clear the generated temporary and destination files, which is equivalent to making clean.

SCONS-Q: Less output information will be generated.

Three, SCons use example

1. Compiling executable files

Use the program function to compile an executable file.

1.1 Single File Mode

1.1.1 Write program code

Establish the document TEST.C, which reads as follows:

Copy Code code as follows:

#include <stdio.h>
int main ()
{
printf ("Just a test!\n");
return 0;
}

1.1.2 Write Sconstruct Code

The contents are as follows:

Copy Code code as follows:

Program ("test1.c")

1.1.3 Compile Program

Execute the scons command to compile with the following effect:

1.2 Multiple file modes

1.2.1 Write program code

Test1.h file:

Copy Code code as follows:

#include <stdio.h>
void Fun11 ();

test1.c file:
Copy Code code as follows:

#include "Test1.h"
void Fun11 ()
{
printf ("fun11\n");
}

TEST2.C file:
Copy Code code as follows:

#include "Test1.h"
int main ()
{
Fun11 ();
return 0;
}

1.2.2 Write sconstruct Code

The contents are as follows:

Copy Code code as follows:

Program (' Test ', [' test1.c ', ' test2.c '])

Or:
Copy Code code as follows:

Program (' Test ', Glob (' *.c '))

1.2.3 Compile Program

Executes the scons command to compile.

1.3 Dependence

1.3.1 Link Library

The syntax example is as follows:

Copy Code code as follows:

Program (' Test ', [' test1.cpp '],libs=[' boost_system ', ' boost_thread-mt '], libpath= '/usr/lib64 ')

1.3.2 contains libraries

The syntax example is as follows:

Copy Code code as follows:

Program (' Program ', Glob (' *.c '), cpppath= '/home/admin/inc ')

2. Compile the static library

The syntax example is as follows:

Copy Code code as follows:

Library (' Libtest1 ', [' test1.c '])

3. Compile Dynamic Library

The syntax example is as follows:

Copy Code code as follows:

Sharedlibrary (' Libtest1 ', [' test1.c '])

Third, other

Resources

(1) scons homepage: http://www.scons.org/

(2) SCons document: http://www.scons.org/documentation.php

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.