2012-04-27 64 views
1

現在我正在研究一種名爲pabalos的開源流體仿真。我在構建自己的與圖書館鏈接的程序時遇到了一些問題。Python scons building

該庫是使用scons從源生成的。

該項目的目錄是:

[[email protected] palabos-v1.1r0]$ls 
codeblocks/ examples/   jlabos/ pythonic/ SConstruct utility/ 
COPYING  externalLibraries/ lib/  scons/  src/ 

我將把這個作爲項目的根目錄!

該項目的正式建設的文件說:

庫Palabos利用按需編譯過程。 代碼首次被最終用戶應用程序 使用,然後在將來自動重新使用,直到由於代碼或編譯選項的修改而需要新的編譯爲 時編譯。

在實例目錄中,有一些示例代碼目錄,如:

[[email protected] palabos-v1.1r0]$ls examples/showCases/rectangularChannel3d/* 
examples/showCases/rectangularChannel3d/Makefile 
examples/showCases/rectangularChannel3d/rectangularChannel3D.cpp 

的例子中的Makefile文件是:

[[email protected] rectangularChannel3d]$cat Makefile 
########################################################################## 
## Makefile for the Palabos example program rectangularChannel3D. 
## 
## The present Makefile is a pure configuration file, in which 
## you can select compilation options. Compilation dependencies 
## are managed automatically through the Python library SConstruct. 
## 
## If you don't have Python, or if compilation doesn't work for other 
## reasons, consult the Palabos user's guide for instructions on manual 
## compilation. 
########################################################################## 

# USE: multiple arguments are separated by spaces. 
# For example: projectFiles = file1.cpp file2.cpp 
#    optimFlags = -O -finline-functions 

# Leading directory of the Palabos source code 
palabosRoot = ../../.. 
# Name of source files in current directory to compile and link with Palabos 
projectFiles = rectangularChannel3D.cpp 

# Set optimization flags on/off 
optimize  = true 
# Set debug mode and debug flags on/off 
debug  = false 
# Set profiling flags on/off 
profile  = false 
# Set MPI-parallel mode on/off (parallelism in cluster-like environment) 
MPIparallel = true 
# Set SMP-parallel mode on/off (shared-memory parallelism) 
SMPparallel = false 
# Decide whether to include calls to the POSIX API. On non-POSIX systems, 
# including Windows, this flag must be false, unless a POSIX environment is 
# emulated (such as with Cygwin). 
usePOSIX  = true 

# Path to external libraries (other than Palabos) 
libraryPaths = 
# Path to inlude directories (other than Palabos) 
includePaths = 
# Dynamic and static libraries (other than Palabos) 
libraries = 

# Compiler to use without MPI parallelism 
serialCXX = g++ 
# Compiler to use with MPI parallelism 
parallelCXX = mpicxx 
# General compiler flags (e.g. -Wall to turn on all warnings on g++) 
compileFlags = -Wall -Wnon-virtual-dtor 
# General linker flags (don't put library includes into this flag) 
linkFlags = 
# Compiler flags to use when optimization mode is on 
optimFlags = -O3 
# Compiler flags to use when debug mode is on 
debugFlags = -g 
# Compiler flags to use when profile mode is on 
profileFlags = -pg 


########################################################################## 
# All code below this line is just about forwarding the options 
# to SConstruct. It is recommended not to modify anything there. 
########################################################################## 

SCons  = $(palabosRoot)/scons/scons.py -j 2 -f $(palabosRoot)/SConstruct 

SConsArgs = palabosRoot=$(palabosRoot) \ 
      projectFiles="$(projectFiles)" \ 
      optimize=$(optimize) \ 
      debug=$(debug) \ 
      profile=$(profile) \ 
      MPIparallel=$(MPIparallel) \ 
      SMPparallel=$(SMPparallel) \ 
      usePOSIX=$(usePOSIX) \ 
      serialCXX=$(serialCXX) \ 
      parallelCXX=$(parallelCXX) \ 
      compileFlags="$(compileFlags)" \ 
      linkFlags="$(linkFlags)" \ 
      optimFlags="$(optimFlags)" \ 
      debugFlags="$(debugFlags)" \ 
     profileFlags="$(profileFlags)" \ 
     libraryPaths="$(libraryPaths)" \ 
     includePaths="$(includePaths)" \ 
     libraries="$(libraries)" 

compile: 
    python $(SCons) $(SConsArgs) 

clean: 
    python $(SCons) -c $(SConsArgs) 
    /bin/rm -vf `find $(palabosRoot) -name '*~'` 

我知道這個Makefile會調用scons的,並且SConstruct文件位於項目根目錄中,如我所示。

的SContstruct文件是:

[[email protected] palabos-v1.1r0]$cat SConstruct 
########################################################### 
# Configuration file for the compilation of Palabos code, 
# using the SConstruct library. 
# IT IS NOT RECOMMENDED TO MODIFY THIS FILE. 
# Compilation should be personalized by adjusting the 
# Makefile in the directory of the main source files. 
# See Palabos examples for sample Makefiles. 
########################################################### 

import os 
import sys 
import glob 

argdict = dict(ARGLIST) 

# Read input parameters 
palabosRoot = argdict['palabosRoot'] 
projectFiles = Split(argdict['projectFiles']) 
optimize  = argdict['optimize'].lower() == 'true' 
debug   = argdict['debug'].lower() == 'true' 
profile  = argdict['profile'].lower() == 'true' 
MPIparallel = argdict['MPIparallel'].lower() == 'true' 
SMPparallel = argdict['SMPparallel'].lower() == 'true' 
usePOSIX  = argdict['usePOSIX'].lower() == 'true' 
serialCXX  = argdict['serialCXX'] 
parallelCXX = argdict['parallelCXX'] 
compileFlags = Split(argdict['compileFlags']) 
linkFlags  = Split(argdict['linkFlags']) 
optimFlags = Split(argdict['optimFlags']) 
debugFlags = Split(argdict['debugFlags']) 
profileFlags = Split(argdict['profileFlags']) 
libraryPaths = Split(argdict['libraryPaths']) 
includePaths = Split(argdict['includePaths']) 
libraries  = Split(argdict['libraries']) 

# Read the optional input parameters 
try: 
    dynamicLibrary = argdict['dynamicLibrary'].lower() == 'true' 
except: 
    dynamicLibrary = False 

try: 
    srcPaths = Split(argdict['srcPaths']) 
except: 
    srcPaths = [] 

flags = compileFlags 
allPaths = [palabosRoot+'/src'] + [palabosRoot+'/externalLibraries'] + includePaths 

if optimize: 
    flags.append(optimFlags) 

if debug: 
    flags.append(debugFlags) 
    flags.append('-DPLB_DEBUG') 

if profile: 
    flags.append(profileFlags) 
    linkFlags.append(profileFlags) 

if MPIparallel: 
    compiler = parallelCXX 
    flags.append('-DPLB_MPI_PARALLEL') 
else: 
    compiler = serialCXX 

if SMPparallel: 
    flags.append('-DPLB_SMP_PARALLEL') 

if usePOSIX: 
    flags.append('-DPLB_USE_POSIX') 

env = Environment (ENV  = os.environ, 
        CXX  = compiler, 
        CXXFLAGS = flags, 
        LINKFLAGS = linkFlags, 
        CPPPATH = allPaths 
       ) 

if dynamicLibrary: 
    LibraryGen = env.SharedLibrary 
else: 
    LibraryGen = env.Library 


sourceFiles = [] 
for srcDir in glob.glob(palabosRoot+'/src/*'): 
    sourceFiles.extend(glob.glob(srcDir+'/*.cpp')) 

for srcDir in srcPaths: 
    sourceFiles.extend(glob.glob(srcDir+'/*.cpp')) 

sourceFiles.extend(glob.glob(palabosRoot+'/externalLibraries/tinyxml/*.cpp')); 

if MPIparallel: 
    palabos_library = LibraryGen(target = palabosRoot+'/lib/plb_mpi', 
            source = sourceFiles) 
else: 
    palabos_library = LibraryGen(target = palabosRoot+'/lib/plb', 
            source = sourceFiles) 

local_objects = env.Object(source = projectFiles) 

all_objects = local_objects + palabos_library 

env.Program(all_objects, LIBS=libraries, LIBPATH=libraryPaths) 

我的問題是:

當我在例子目錄更改源文件rectangularChannel3D.cpp, 和運行make時,palabos圖書館不應該因爲我沒有更改 庫項目的源文件(在根目錄的'src'目錄中),所以我重建了它。但是 其實lib庫文件「libplb.a」已經重建了 !!所以爲什麼?

+0

除非這是第一次編譯,並且您還沒有修改Makefile和/或SConstruct,否則可以考慮聯繫項目的所有者。 – Brady 2012-04-27 16:19:44

回答

0

我同意布雷迪。嘗試聯繫您正在嘗試構建的項目。或者,如果你沒有得到他們的幫助,或者你真的想自己解決這個問題,SCons會有一個標誌--debug=explain,它會告訴你爲什麼要構建/重建任何對象。