Commit 758fa4dd authored by Yann Voté's avatar Yann Voté Committed by Sebastien Petitdemange

Rewrite config parser function to include cameras

This is a combination of 2 commits.
Also use context manager to read file
[cmake] Use conf file to say what to compile

Instead of hardcoding `-D COMPILE_XXX=1` arguments to cmake, which adds
duplication with `config.inc` file.

Thus `config.inc` becomes the only trusted configuration source.

We then disable SPS_IMAGE by default on Windows since it does not
compile on this platform and enable BASLER.

Note that we keep hardcoded `-D COMPILE_SIP=1` because we always want to
compile Python modules.
parent b954f8cf
......@@ -29,12 +29,40 @@ IF(UNIX)
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined")
ENDIF(UNIX)
set(COMPILE_CORE ON CACHE BOOL "compile core?")
set(COMPILE_SIMULATOR ON CACHE BOOL "compile simulator?")
set(COMPILE_SPS_IMAGE ON CACHE BOOL "compile sps_image?")
set(COMPILE_BASLER ON CACHE BOOL "compile basler?")
set(COMPILE_SIP OFF CACHE BOOL "compile python modules?")
set(COMPILE_TIFF_SAVING OFF CACHE BOOL "compile tiff saving code?")
IF(DEFINED ENV{COMPILE_CORE})
set(COMPILE_CORE "$ENV{COMPILE_CORE}" CACHE BOOL "compile core?" FORCE)
ELSE()
set(COMPILE_CORE ON CACHE BOOL "compile core?")
ENDIF()
IF(DEFINED ENV{COMPILE_SIMULATOR})
set(COMPILE_SIMULATOR "$ENV{COMPILE_SIMULATOR}" CACHE BOOL "compile simulator?" FORCE)
ELSE()
set(COMPILE_SIMULATOR ON CACHE BOOL "compile simulator?")
ENDIF()
IF(DEFINED ENV{COMPILE_SPS_IMAGE})
set(COMPILE_SPS_IMAGE "$ENV{COMPILE_SPS_IMAGE}" CACHE BOOL "compile sps_image?" FORCE)
ELSE()
IF (WIN32)
set(COMPILE_SPS_IMAGE OFF CACHE BOOL "compile sps_image?")
ELSE()
set(COMPILE_SPS_IMAGE ON CACHE BOOL "compile sps_image?")
ENDIF()
ENDIF()
IF(DEFINED ENV{COMPILE_BASLER})
set(COMPILE_BASLER "$ENV{COMPILE_BASLER}" CACHE BOOL "compile basler?" FORCE)
ELSE()
set(COMPILE_BASLER ON CACHE BOOL "compile basler?")
ENDIF()
IF(DEFINED ENV{COMPILE_SIP})
set(COMPILE_SIP "$ENV{COMPILE_SIP}" CACHE BOOL "compile python modules?" FORCE)
ELSE()
set(COMPILE_SIP OFF CACHE BOOL "compile python modules?")
ENDIF()
IF(DEFINED ENV{COMPILE_TIFF_SAVING})
set(COMPILE_TIFF_SAVING "$ENV{COMPILE_TIFF_SAVING}" CACHE BOOL "compile tiff saving code?" FORCE)
ELSE()
set(COMPILE_TIFF_SAVING OFF CACHE BOOL "compile tiff saving code?")
ENDIF()
if(COMPILE_SIP)
IF(!${SIP_FOUND})
......
......@@ -22,12 +22,12 @@
COMPILE_CORE=1
COMPILE_SIMULATOR=1
COMPILE_SPS_IMAGE=1
COMPILE_SPS_IMAGE=0
COMPILE_ESPIA=0
COMPILE_FRELON=0
COMPILE_MAXIPIX=0
COMPILE_PILATUS=0
COMPILE_BASLER=0
COMPILE_BASLER=1
COMPILE_PROSILICA=0
COMPILE_ROPERSCIENTIFIC=0
COMPILE_MYTHEN=0
......
@echo off
setlocal enabledelayedexpansion
rem variables d'environnement pour CMake
call python set_win_cmake_env.py
rem repertoire courant du batch
if exist "_build" (
rmdir /S /Q _build
......@@ -10,7 +13,7 @@ cd _build
set CurrentPath=%cd%
rem execution de cmake pour créer les fichiers projets et solution
cmake -G "Visual Studio 9 2008" -D PYLON_ROOT="C:\Program Files\Basler\pylon 3.2\pylon" -D GSL_INCLUDE_DIR="C:\Program Files (x86)\GnuWin32\include" -D GSL_LIB_DIR="C:\Program Files (x86)\GnuWin32\lib" -D NUMPY_INCLUDE_DIR="C:\Anaconda2\Lib\site-packages\numpy\core\include" -D NUMPY_LIB_DIR="C:\Anaconda2\Lib\site-packages\numpy\core\lib" -D COMPILE_SIP=1 -D COMPILE_SPS_IMAGE=0 ..
cmake -G "Visual Studio 9 2008" -D PYLON_ROOT="C:\Program Files\Basler\pylon 3.2\pylon" -D GSL_INCLUDE_DIR="C:\Program Files (x86)\GnuWin32\include" -D GSL_LIB_DIR="C:\Program Files (x86)\GnuWin32\lib" -D NUMPY_INCLUDE_DIR="C:\Anaconda2\Lib\site-packages\numpy\core\include" -D NUMPY_LIB_DIR="C:\Anaconda2\Lib\site-packages\numpy\core\lib" -D COMPILE_SIP=1 ..
rem configuration des variables d'environnement visual c++ 2008 express edition
cd /D %VS90COMNTOOLS%..\..\VC
......
############################################################################
# This file is part of LImA, a Library for Image Acquisition
#
# Copyright (C) : 2009-2016
# European Synchrotron Radiation Facility
# BP 220, Grenoble 38043
# FRANCE
#
# This is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This software is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
############################################################################
import os
from windowsSipCompilation import getModuleConfig
def _main():
"""Set environment variables for CMake on Windows."""
for modname, to_compile in getModuleConfig().items():
if to_compile:
os.environ['COMPILE_{0}'.format(modname)] = '1'
if __name__ == '__main__':
_main()
......@@ -20,30 +20,33 @@
# along with this program; if not, see <http://www.gnu.org/licenses/>.
############################################################################
import os,sys
import os.path as path
from optparse import OptionParser
configFile = 'config.inc'
def getModuleConfig() :
def getModuleConfig():
availableModules = set()
for dir_ in ('camera', 'sip'):
availableModules.update(
set([subdir for subdir in os.listdir(dir_)
if os.path.isdir(path.join(dir_, subdir))])
)
config = {}
try:
f = file(configFile)
with open(configFile) as f:
for line in f:
if line.startswith('COMPILE'):
modName, active = line.split('=')
modName = '_'.join(modName.split('_')[1:])
modName = modName.lower()
if modName in availableModules:
config[modName] = bool(int(active))
return config
except IOError:
print 'You should Read the README_WINDOW First'
raise
else:
os.chdir('sip')
availableModule = set([x for x in os.listdir('.') if os.path.isdir(x)])
config = {}
for line in f:
if line.startswith('COMPILE') :
modName,active = line.split('=')
modName = '_'.join(modName.split('_')[1:])
modName = modName.lower()
if modName in availableModule:
config[modName] = bool(int(active))
os.chdir('..')
return config
def compileModule(config) :
os.chdir('sip')
......
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