Commit 229c84a4 authored by ahoms's avatar ahoms

* Split lima library into core and independent camera modules


git-svn-id: https://scm.blissgarden.org/svn/lima/trunk@257 45c4679d-1946-429d-baad-37912b19538b
parent 5c2555a8
lima-objs := ../common/src/Common.o \
../hardware/src/Hw.o \
../control/src/Ct.o \
../camera/simulator/src/Simu.o
include ../config.inc
ifneq ($(COMPILE_ESPIA),0)
lima-objs += ../camera/common/espia/src/Espia.o
############################
# LIMA - CORE
############################
CORE_LDFLAGS = -fPIC -L../third-party/Processlib/build
CORE_LDLIBS = -lprocesslib
ifneq ($(COMPILE_CORE),0)
core-objs := ../common/src/Common.o \
../hardware/src/Hw.o \
../control/src/Ct.o
liblimacore.so: $(core-objs)
$(CXX) -shared -o $@ $(CORE_LDFLAGS) $+ $(CORE_LDLIBS)
build_targets += liblimacore.so
endif
LDFLAGS = $(CORE_LDFLAGS) -L.
LDLIBS = $(CORE_LDLIBS) -llimacore
############################
# LIMA - SIMULATOR
############################
ifneq ($(COMPILE_SIMULATOR),0)
simu-objs = ../camera/simulator/src/Simu.o
liblimasimulator.so: $(simu-objs)
$(CXX) -shared -o $@ $(LDFLAGS) $+ $(LDLIBS)
build_targets += liblimasimulator.so
endif
############################
# LIMA - ESPIA
############################
include ../camera/common/espia/include/espia.inc
LDLIBS += -lespia
LDFLAGS += -L$(ESPIA_DRV_LIB)
ESPIA_LDFLAGS = $(LDFLAGS) -L$(ESPIA_DRV_LIB)
ESPIA_LDLIBS = $(LDLIBS) -lespia
ifneq ($(COMPILE_ESPIA),0)
espia-objs = ../camera/common/espia/src/Espia.o
liblimaespia.so: $(espia-objs)
$(CXX) -shared -o $@ $(ESPIA_LDFLAGS) $+ $(ESPIA_LDLIBS)
build_targets += liblimaespia.so
endif
############################
# LIMA - FRELON
############################
ifneq ($(COMPILE_FRELON),0)
lima-objs += ../camera/frelon/src/Frelon.o
frelon-objs = ../camera/frelon/src/Frelon.o
FRELON_LDFLAGS = $(ESPIA_LDFLAGS) -L.
FRELON_LDLIBS = $(ESPIA_LDLIBS) -llimaespia
liblimafrelon.so: $(frelon-objs)
$(CXX) -shared -o $@ $(FRELON_LDFLAGS) $+ $(FRELON_LDLIBS)
build_targets += liblimafrelon.so
endif
############################
# LIMA - MAXIPIX
############################
ifneq ($(COMPILE_MAXIPIX),0)
lima-objs += ../camera/maxipix/src/Maxipix.o
endif
LDFLAGS += -L../third-party/Processlib/build
LDLIBS += -lprocesslib
maxipix-objs += ../camera/maxipix/src/Maxipix.o
MAXIPIX_LDFLAGS = $(ESPIA_LDFLAGS) -L.
MAXIPIX_LDLIBS = $(ESPIA_LDLIBS) -llimaespia
src: liblima.so
liblimamaxipix.so: $(maxipix-objs)
$(CXX) -shared -o $@ $(MAXIPIX_LDFLAGS) $+ $(MAXIPIX_LDLIBS)
build_targets += liblimamaxipix.so
endif
src: $(build_targets)
test:
@true
liblima.so: $(lima-objs)
$(CXX) -shared -o $@ -fPIC $+ $(LDFLAGS) $(LDLIBS)
clean:
rm -f *.o liblima.so
rm -f *.o liblima*.so
COMPILE_CORE=1
COMPILE_SIMULATOR=1
COMPILE_ESPIA=0
COMPILE_FRELON=0
COMPILE_MAXIPIX=0
export COMPILE_CORE COMPILE_ESPIA COMPILE_FRELON COMPILE_MAXIPIX
export COMPILE_CORE COMPILE_SIMULATOR \
COMPILE_ESPIA COMPILE_FRELON COMPILE_MAXIPIX
include ../config.inc
ifneq ($(COMPILE_CORE), 0)
sip-modules += core
endif
ifneq ($(COMPILE_SIMULATOR), 0)
sip-modules += simulator
endif
ifneq ($(COMPILE_ESPIA), 0)
sip-modules += espia
endif
ifneq ($(COMPILE_FRELON), 0)
sip-modules += frelon
endif
ifneq ($(COMPILE_MAXIPIX), 0)
sip-modules += maxipix
endif
src:
for d in $(sip-modules); do \
$(MAKE) -C $$d || break; \
done
clean:
for d in $(sip-modules); do \
$(MAKE) -C $$d clean || break; \
done
mrproper:
python mrproper.py
test:
@true
......@@ -4,117 +4,184 @@ import sipconfig
import shutil
import numpy
shutil.copyfile("lima.sip","lima_tmp.sip")
modules = [('core', ['common', 'hardware', 'control']),
('simulator', ['camera/simulator']),
('espia', ['camera/common/espia']),
('frelon', ['camera/frelon']),
('maxipix', ['camera/maxipix'])]
confFile = file('../config.inc')
excludeDirs = set()
espiaModules = ['espia', 'frelon', 'maxipix']
rootDir = '..'
def rootName(fn):
return '%s/%s' % (rootDir, fn)
def findIncludes(baseDir):
inclDirs = []
for root, dirs, files in os.walk(baseDir):
for dirname in dirs:
if dirname == 'include':
inclDirs.append(os.path.join(root,dirname))
return inclDirs
def findModuleIncludes(name):
for modName, modDirs in modules:
if modName == name:
modInclDirs = []
for subDir in modDirs:
modInclDirs += findIncludes(rootName(subDir))
return modInclDirs
return None
excludeMods = set()
confFile = open(rootName('config.inc'))
for line in confFile:
line = line.strip('\n ')
if line.startswith('COMPILE_') :
var,value = line.split('=')
if line.startswith('COMPILE_'):
var, value = line.split('=')
try:
value = int(value)
except ValueError:
continue
if not value:
excludeDirs.add(var.split('_')[-1].lower())
excludeMods.add(var.split('_')[-1].lower())
for modName, modDirs in modules:
if modName in excludeMods:
continue
if os.path.exists(modName):
if not os.path.isdir(modName):
raise 'Error: %s exists and is not a directory' % modName
else:
os.mkdir(modName)
os.chdir('%s' % modName)
rootDir = '../' + rootDir
sipFileNameSrc = "lima%s.sip" % modName
if modName != 'core':
sipFileNameIn = "../limamodules.sip.in"
cmd = 'sed "s/%%NAME/%s/g" %s > %s' % (modName, sipFileNameIn,
sipFileNameSrc)
os.system(cmd)
sipFileName = "lima%s_tmp.sip" % modName
shutil.copyfile(sipFileNameSrc, sipFileName)
sip_processlib = '../third-party/Processlib/sip'
extra_includes = ['.',sip_processlib,numpy.get_include()]
initNumpy = 'lima_init_numpy.cpp'
shutil.copyfile('../' + initNumpy, initNumpy)
if 'espia' not in excludeDirs:
espia_base = '/segfs/bliss/source/driver/linux-2.6/espia'
espia_incl = espia_base + '/src'
extra_includes += [espia_incl]
dirProcesslib = rootName('third-party/Processlib')
sipProcesslib = dirProcesslib + '/sip'
extraIncludes = ['.', '../core', sipProcesslib, numpy.get_include()]
extraIncludes += findIncludes(dirProcesslib)
sipFile = file("lima_tmp.sip","a")
sipFile.write('\n')
sipFile.write('%Import ../third-party/Processlib/sip/processlib_tmp.sip\n')
for root,dirs,files in os.walk('..') :
dir2rmove = excludeDirs.intersection(dirs)
for dname in dir2rmove:
dirs.remove(dname)
for dirname in dirs:
if dirname == 'include':
extra_includes.append(os.path.join(root,dirname))
if root.find('third-party') > -1: continue
for filename in files:
if filename == 'lima.sip' or filename == 'lima_tmp.sip' : continue
base,ext = os.path.splitext(filename)
if ext != '.sip': continue
sipFile.write('%%Include %s\n' % os.path.join(root,filename))
sipFile.close()
# The name of the SIP build file generated by SIP and used by the build
# system.
build_file = "lima.sbf"
config = sipconfig.Configuration()
# Run SIP to generate the code.
# module's specification files using the -I flag.
cmd = " ".join([config.sip_bin,"-g", "-e","-c", '.',
"-b", build_file,"lima_tmp.sip"])
print cmd
os.system(cmd)
#little HACK for adding source
bfile = file(build_file)
whole_line = ''
for line in bfile :
if 'sources' in line :
begin,end = line.split('=')
line = '%s = lima_init_numpy.cpp %s' % (begin,end)
whole_line += line
bfile.close()
bfile = file(build_file,'w')
bfile.write(whole_line)
bfile.close()
# We are going to install the SIP specification file for this module and
# its configuration module.
installs = []
installs.append(["lima.sip", os.path.join(config.default_sip_dir, "lima")])
installs.append(["limaconfig.py", config.default_mod_dir])
# Create the Makefile. The QtModuleMakefile class provided by the
# pyqtconfig module takes care of all the extra preprocessor, compiler and
# linker flags needed by the Qt library.
makefile = sipconfig.ModuleMakefile(
configuration=config,
build_file=build_file,
installs=installs,
export_all = True
)
makefile.extra_include_dirs = extra_includes
makefile.extra_libs = ['pthread','lima']
makefile.extra_lib_dirs = ['../build']
makefile.extra_cxxflags = ['-pthread', '-g']
makefile.extra_cxxflags.extend(['-I' + x for x in extra_includes])
# Add the library we are wrapping. The name doesn't include any platform
# specific prefixes or extensions (e.g. the "lib" prefix on UNIX, or the
# ".dll" extension on Windows).
# None (for me)
# Generate the Makefile itself.
makefile.generate()
# Now we create the configuration module. This is done by merging a Python
# dictionary (whose values are normally determined dynamically) with a
# (static) template.
content = {
# Publish where the SIP specifications for this module will be
# installed.
"lima_sip_dir": config.default_sip_dir
}
# This creates the pixmaptoolsconfig.py module from the pixmaptoolsconfig.py.in
# template and the dictionary.
sipconfig.create_config_module("limaconfig.py", "limaconfig.py.in", content)
coreDirs = modules[0][1]
extraIncludes += findModuleIncludes('core')
if (modName in espiaModules) and ('espia' not in excludeMods):
espia_base = '/segfs/bliss/source/driver/linux-2.6/espia'
espia_incl = espia_base + '/src'
extraIncludes += [espia_incl]
extraIncludes += findModuleIncludes(modName)
sipFile = open(sipFileName,"a")
sipFile.write('\n')
sipFile.write('%%Import %s/processlib_tmp.sip\n' % sipProcesslib)
if modName != 'core':
sipFile.write('%Import ../core/limacore_tmp.sip\n');
if (modName in espiaModules) and (modName != 'espia'):
sipFile.write('%Import ../espia/limaespia_tmp.sip\n');
extraIncludes += findModuleIncludes('espia')
for sdir in modDirs:
srcDir = rootName(sdir)
for root,dirs,files in os.walk(srcDir) :
dir2rmove = excludeMods.intersection(dirs)
for dname in dir2rmove:
dirs.remove(dname)
for filename in files:
base,ext = os.path.splitext(filename)
if ext != '.sip':
continue
sipFile.write('%%Include %s\n' % os.path.join(root,filename))
sipFile.close()
# The name of the SIP build file generated by SIP and used by the build
# system.
build_file = "lima%s.sbf" % modName
config = sipconfig.Configuration()
# Run SIP to generate the code.
# module's specification files using the -I flag.
cmd = " ".join([config.sip_bin,"-g", "-e","-c", '.',
"-b", build_file,sipFileName])
print cmd
os.system(cmd)
#little HACK for adding source
bfile = open(build_file)
whole_line = ''
for line in bfile :
if 'sources' in line :
begin,end = line.split('=')
line = '%s = lima_init_numpy.cpp %s' % (begin,end)
whole_line += line
bfile.close()
bfile = open(build_file,'w')
bfile.write(whole_line)
bfile.close()
# We are going to install the SIP specification file for this module and
# its configuration module.
installs = []
installs.append([sipFileNameSrc, os.path.join(config.default_sip_dir, "lima")])
installs.append(["limaconfig.py", config.default_mod_dir])
# Create the Makefile. The QtModuleMakefile class provided by the
# pyqtconfig module takes care of all the extra preprocessor, compiler and
# linker flags needed by the Qt library.
makefile = sipconfig.ModuleMakefile(configuration=config,
build_file=build_file,
installs=installs,
export_all = True)
makefile.extra_include_dirs = extraIncludes
makefile.extra_libs = ['pthread','lima%s' % modName]
makefile.extra_lib_dirs = [rootName('build')]
makefile.extra_cxxflags = ['-pthread', '-g']
makefile.extra_cxxflags.extend(['-I' + x for x in extraIncludes])
# Add the library we are wrapping. The name doesn't include any platform
# specific prefixes or extensions (e.g. the "lib" prefix on UNIX, or the
# ".dll" extension on Windows).
# None (for me)
# Generate the Makefile itself.
makefile.generate()
# Now we create the configuration module. This is done by merging a Python
# dictionary (whose values are normally determined dynamically) with a
# (static) template.
content = {
# Publish where the SIP specifications for this module will be
# installed.
"lima_sip_dir": config.default_sip_dir
}
# This creates the lima<mod>config.py module from the limaconfig.py.in
# template and the dictionary.
sipconfig.create_config_module("lima%sconfig.py" % modName,
"../limaconfig.py.in", content)
os.chdir('..')
rootDir = rootDir[3:]
%Module lima 0
%Module limacore 0
%ModuleHeaderCode
#include <SoftOpId.h>
......
%Module lima%NAME 0
%ModuleHeaderCode
extern "C" { void lima_import_array();}
%End
%PostInitialisationCode
lima_import_array();
%End
......@@ -3,20 +3,37 @@
import os
import os.path
import glob
import shutil
modules = ['core', 'simulator', 'espia', 'frelon', 'maxipix']
p = os.popen('svn propget svn:ignore . 2> /dev/null')
patterns = p.readlines()
if not p.close():
for pat in patterns:
for f in glob.glob(pat.strip()):
if os.path.isdir(f):
print "execture: rmtree", f
#shutil.rmtree(f)
else:
print "execute: rm ", f
#os.remove(f)
for mod in modules:
os.chdir(mod)
try:
os.chdir(mod)
except OSError:
continue
if os.access('./Makefile',os.R_OK) :
os.system('make clean')
# dont_rm_files = ['lima.sip','limaconfig.py.in','configure.py','clean.py',
# 'LimaConvertor.h','lima_init_numpy.cpp', 'Makefile']
p = os.popen('svn propget svn:ignore .')
p = os.popen('svn propget svn:ignore . 2> /dev/null')
patterns = p.readlines()
if p.close() == 0:
if not p.close():
for pat in patterns:
for f in glob.glob(pat.strip()):
print "execute: rm ", f
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment