Start with scons » History » Version 1
jun chen, 03/10/2025 12:30 AM
1 | 1 | jun chen | # Start with scons |
---|---|---|---|
2 | |||
3 | ## where is scons |
||
4 | |||
5 | scons is in `/home/hqtan/local/bin/scons`, you should add this path to `$PATH`: or set alias to it. |
||
6 | recommend to add `alias scons to "bsub -I -q centl /home/hqtan/local/bin/scons"` |
||
7 | |||
8 | ## useful command |
||
9 | 1. compile |
||
10 | ``` |
||
11 | scons |
||
12 | ``` |
||
13 | 2. clean |
||
14 | ``` |
||
15 | scons -c |
||
16 | ``` |
||
17 | or |
||
18 | ``` |
||
19 | git clean -xdf ../ |
||
20 | ``` |
||
21 | 3. create release |
||
22 | ``` |
||
23 | scons --cut |
||
24 | ``` |
||
25 | 4. test create release, save time w/o copy ext and compress |
||
26 | ``` |
||
27 | scons --cut --test |
||
28 | ``` |
||
29 | 5. debug mode |
||
30 | ``` |
||
31 | scons VFRBOSF=l |
||
32 | ``` |
||
33 | |||
34 | ## Code Structure |
||
35 |  |
||
36 | |||
37 | ## how does the scons work? |
||
38 | |||
39 | scons works like make, but the main depend file name is SConstruct instead of makefile, |
||
40 | |||
41 | **firstly** it will search `SConscruct` file in current directly, will complain error if not found, for a hierarchy code, |
||
42 | **secondly** it will try to find `SConscript` in each sub-directory. |
||
43 | In the `SConstruct` , we need call `env.SConscript` to compile each sub-directory. |
||
44 | |||
45 | More details refer to attachment:"scons-man.pdf" attachment:"scons-user.pdf" |
||
46 | |||
47 | how to add a sub module? |
||
48 | |||
49 | scons --init=module—name |
||
50 | |||
51 | ## Example of SConscript |
||
52 |  |
||
53 | |||
54 | 1. generally the env comes from the top level SConstruct which defined some variable and functions, if we will change somethings in it, we should do Clone before use it. |
||
55 | 2. DEPENDS include the dependency of current module, it will be used as Link directory(-L) when link the binary. |
||
56 | 3. LIBS include the linked library name, it will be used as -lklibname> when link the binary |
||
57 | 4. LINKFLAGS include extra link flags, it will be used when link the binary |
||
58 | 5. cpp_files include all source files which should be compiled, **alway remember add your source file into this list when you add a new cc file** |
||
59 | 6. build_vesper_target accept above arguments and do compile and link |
||
60 | 7. the argument exectuable was specified means we want to build a binary, else if we should specify shared_library to build a shared library instead. |
||
61 | 8. in Vesper we expect each module is a shared library instead of a static library to reduce the size of the total package. |