Project

General

Profile

Start with scons » History » Revision 2

Revision 1 (jun chen, 03/10/2025 12:30 AM) → Revision 2/3 (jun chen, 03/10/2025 12:50 AM)

# Start with scons 

 ## where is scons 

 scons is in `/home/hqtan/local/bin/scons`, you should add this path to `$PATH`: or set alias to it.  
 recommend to add `alias scons to "bsub -I -q centl /home/hqtan/local/bin/scons"` 

 ## useful command 
 1. compile 
 ``` 
 scons 
 ``` 
 2. clean 
 ``` 
 scons -c 
 ``` 
 or 
 ``` 
 git clean -xdf ../ 
 ``` 
 3. create release 
 ``` 
 scons --cut 
 ``` 
 4. test create release, save time w/o copy ext and compress 
 ``` 
 scons --cut --test 
 ``` 
 5. debug mode 
 ``` 
 scons VFRBOSF=l 
 ``` 

 ## Code Structure 
 ![](clipboard-202503100027-hcobg.png) 

 

 ## how does the scons work? 

 scons works like make, but the main depend file name is SConstruct instead of makefile,  

 **firstly**    it will search `SConscruct` file in current directly, will complain error if not found, for a hierarchy code,  
 **secondly**    it will try to find `SConscript`    in each sub-directory.  
 In the `SConstruct` , we need call `env.SConscript` to compile each sub-directory.  

 ## More details refer to  
 attachment:"scons-man.pdf"   
    attachment:"scons-user.pdf"  
 attachment:"Compile_and_linke_using_Scons.pdf" 

 how to add a sub module? 

	 scons --init=module—name 

 

 ## Example of SConscript 
 ![](clipboard-202503100029-z2brs.png) 

 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. 
 2. DEPENDS include the dependency of current module, it will be used as Link directory(-L) when link the binary. 
 3. LIBS include the linked library name, it will be used as -lklibname> when link the binary 
 4. LINKFLAGS include extra link flags, it will be used when link the binary 
 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** 
 6. build_vesper_target accept above arguments and do compile and link 
 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. 
 8. in Vesper we expect each module is a shared library instead of a static library to reduce the size of the total package.