'''Specifies Target class with encapsulates the logic about how to build a target. Much of the data for a Targe instance comes by reading the "data.xml" file. This file should be changed when new hurdles in the build process are discovered (for a new platform). data.xml tags that are read by Target: target attributes: build_misc_dir Path (relative to build directory of this target) of files that are not libraries or executables, but are build products of this target. build_lib_dir Path (relative to build directory of this target) of libraries that are build products of this target. build_exe_dir Path (relative to build directory of this target) of executable that are build products of this target. ''' from target_base import * import logging _log = logging.getLogger('target_logic.py') class AceTarget(Target): def addEnvVarForSelf(self, environ, addedEnv, step): '''While building we need TAO_ORBSVCS (and ACE_ROOT and TAO_ROOT)''' effectiveStep = max(step, self.currentStep) if effectiveStep < StepEnum.stage: addEnv(environ, addedEnv, False, TAO_ORBSVCS = 'Naming CosEvent') self.addEnvVarForOthers(environ, addedEnv, step) def _addEnvVarForOthers(self, environ, addedEnv, step): '''If somebody is building or staging, they may need ACE_ROOT and TAO_ROOT''' if step < StepEnum.stage: addEnv(environ, addedEnv, ACE_ROOT = self.getAbsPath(StepEnum.build)) addEnv(environ, addedEnv, TAO_ROOT = os.path.join('$ACE_ROOT', 'TAO')) def _configure(self): if isDarwin: versTuple = my_sw_vers() if len(versTuple) < 2 or versTuple[1] < 4: sysConfigFilePath = 'mac_ACE_config.h' sysGnuPlatFilePath = 'mac_ACE_GNU_Platform' else: sys.exit('Sorry, ACE does not want to build on Tiger. You need to use omniORB-only configuration of CIPRES') sysConfigFilePath = 'tiger_ACE_config.h' sysGnuPlatFilePath = 'tiger_ACE_GNU_Platform' else: sysConfigFilePath = 'linux_ACE_config.h' sysGnuPlatFilePath = 'linux_ACE_GNU_Platform' configFilePath = expandPath(os.path.join('$ACE_ROOT', 'ace', 'config.h')) gnuPlatFilePath = expandPath(os.path.join('$ACE_ROOT', 'include', 'makeinclude', 'platform_macros.GNU')) shutil.copyfile(sysConfigFilePath, configFilePath) shutil.copyfile(sysGnuPlatFilePath, gnuPlatFilePath) def _build(self): make(['$ACE_ROOT/ace', '$ACE_ROOT/apps/gperf', '$ACE_ROOT/Kokyu', '$TAO_ROOT/tao', '$TAO_ROOT/TAO_IDL', '$TAO_ROOT/orbsvcs/orbsvcs'], os.environ) def moveOmniPyProducts(target): '''both omni and omnipy produce targets in python2.# directories we are trying out moving them to just python''' origLocation = os.path.join(Target.absPathToTop.getTopDir(StepEnum.stage), 'lib', pyVersionDir, 'site-packages') newParentDir = os.path.join(Target.absPathToTop.getTopDir(StepEnum.stage), 'lib', 'python', 'site-packages') if not os.path.exists(newParentDir): os.makedirs(newParentDir) assert(os.path.exists(origLocation)) if False: # we should probably do something like this: # this will fail if we start adding stage directories attributes in the xml for omniORBpy for p in target.products: n = p.getNativeFileName(StepEnum.stage) if n: copyTreeIfNewer(os.path.join(origLocation, n), os.path.join(newParentDir, n)) else: # instead we'll take the easy way out for name in os.listdir(origLocation): copyTreeIfNewer(os.path.join(origLocation, name), os.path.join(newParentDir, name)) class OmniTarget(Target): def addEnvVarForSelf(self, environ, addedEnv, step): self._addEnvVarForOthers(environ, addedEnv, step) def _addEnvVarForOthers(self, environ, addedEnv, step): '''If we are staging and omniORB is staged, then we set OMNIORB_TOP and OMNIORB_INCLUDE_DIR ''' buildDir = self.getAbsPath(StepEnum.build) addEnv(environ, addedEnv, OMNIORB_TOP = buildDir) if step <= StepEnum.stage: # if we are still build or stage dependencies we need the include files for omniORB if self.currentStep >= StepEnum.stage: pd = isWindows and buildDir or self.getAbsPath(self.currentStep) addEnv(environ, addedEnv, OMNIORB_LIB_PARENT = pd) addEnv(environ, addedEnv, OMNIORB_INCLUDE_DIR = os.path.join(pd, 'include')) addEnv(environ, addedEnv, OMNIORB_SHARE_DIR = os.path.join(self.getAbsPath(self.currentStep), 'share')) if isDarwin: addEnv(environ, addedEnv, False, DYLD_BIND_AT_LAUNCH = '1') def _configure(self): if isWindows: return # we are getting the prebuilt version for windows self.cdToPath(StepEnum.configure) if not os.path.exists('build'): os.mkdir('build') os.chdir('build') commandOS('../configure', ['--prefix=%s' % Target.absPathToTop.getTopDir(StepEnum.stage), '--disable-static'], os.environ) def _build(self): assert('OMNIORB_TOP' in os.environ) if isWindows: shareDir = os.path.join(os.environ['OMNIORB_TOP'], 'share', 'idl') if not os.path.exists(shareDir): os.makedirs(shareDir) idlDir = os.path.join(os.environ['OMNIORB_TOP'], 'idl') copyTreeIfNewer(idlDir, shareDir) else: make([expandPath(os.path.join('$OMNIORB_TOP', 'build'))], os.environ) def stage(self, addedEnv): '''Make install moves everything, so we don't use the base class stage.''' postCallback = isWindows and self._stageProducts or None self._standardStep(StepEnum.stage, addedEnv, self._stage, postCallback) def _stage(self): assert('OMNIORB_TOP' in os.environ) if isWindows: sharedir = os.path.join(os.environ['OMNIORB_TOP'], 'share', 'idl') stageDir = os.path.join(Target.absPathToTop.getTopDir(StepEnum.stage), 'share', 'idl', 'omniORB') copyTreeIfNewer(sharedir, stageDir) else: os.chdir(expandPath(os.path.join('$OMNIORB_TOP', 'build'))) commandOS('make', ['install'], os.environ) moveOmniPyProducts(self) class OmniPyTarget(Target): def addEnvVarForSelf(self, environ, addedEnv, step): '''If we are staging or earlier, we need OMNIORB_PY_TOP''' effectiveStep = max(step, self.currentStep) if effectiveStep <= StepEnum.stage: addEnv(environ, addedEnv, OMNIORB_PY_TOP = self.getAbsPath(StepEnum.build)) def _addEnvVarForOthers(self, environ, addedEnv, step): if isDarwin: addEnv(environ, addedEnv, False, DYLD_BIND_AT_LAUNCH = '1') if isWindows: toadd = os.path.join(self.getAbsPath(StepEnum.build), 'bin', 'x86_win32') appendEnv(environ, addedEnv, PATH = toadd) appendEnv(environ, addedEnv, PATH = os.path.join(os.environ['OMNIORB_TOP'], 'bin', 'x86_win32') ) if step >= StepEnum.stage: pysiteP = os.path.join(Target.absPathToTop.getTopDir(StepEnum.stage), 'lib', 'python', 'site-packages') currPyPath = os.environ.get('PYTHONPATH', '') if not pysiteP in currPyPath: appendEnv(environ, addedEnv, PYTHONPATH = pysiteP) def _configure(self): if isWindows: return self.cdToPath(StepEnum.configure) if not os.path.exists('build'): os.mkdir('build') os.chdir('build') # omniORB stage dir is the parent of OMNIORB_INCLUDE_DIR assert('OMNIORB_INCLUDE_DIR' in os.environ) stagedOmniORB = os.path.split(expandPath('$OMNIORB_INCLUDE_DIR'))[0] commandOS('../configure', ['--prefix=%s' % Target.absPathToTop.getTopDir(StepEnum.stage), '--with-omniorb=%s' % stagedOmniORB ], os.environ) def _build(self): assert('OMNIORB_PY_TOP' in os.environ) if isWindows: return os.chdir(expandPath(os.path.join('$OMNIORB_PY_TOP', 'build'))) commandOS('make', [], os.environ) def stage(self, addedEnv): '''Make install moves everything, so we don't use the base class stage.''' self._standardStep(StepEnum.stage, addedEnv, self._stage, None) def _stage(self): assert('OMNIORB_PY_TOP' in os.environ) if isWindows: pysiteP = os.path.join(Target.absPathToTop.getTopDir(StepEnum.stage), 'lib', 'python', 'site-packages') source = os.path.join(os.environ['OMNIORB_PY_TOP'], 'lib', 'python') copyTreeIfNewer(source, pysiteP) source = os.path.join(os.environ['OMNIORB_PY_TOP'], 'lib', 'x86_win32') copyTreeIfNewer(source, pysiteP) else: os.chdir(expandPath(os.path.join('$OMNIORB_PY_TOP', 'build'))) commandOS('make', ['install'], os.environ) moveOmniPyProducts(self) class JacorbTarget(Target): def addEnvVarForSelf(self, environ, addedEnv, step): '''While building we need JACORB_ROOT''' effectiveStep = max(step, self.currentStep) if effectiveStep < StepEnum.stage: addEnv(environ, addedEnv, JACORB_ROOT = self.getAbsPath(effectiveStep)) toadd = os.path.join(self.getAbsPath(effectiveStep), 'bin') appendEnv(environ, addedEnv, PATH = toadd) def _addEnvVarForOthers(self, environ, addedEnv, step): '''CIPRES needs JACORB_TOP to find IDL files that are part of the jacorb dist. ''' if step <= StepEnum.stage: addEnv(environ, addedEnv, JACORB_TOP = self.getAbsPath(StepEnum.build)) toadd = os.path.join(self.getAbsPath(StepEnum.build), 'bin') appendEnv(environ, addedEnv, PATH = toadd) def _configure(self): assert('JACORB_ROOT' in os.environ) if isWindows: return os.chdir(expandPath('$JACORB_ROOT')) # following 3 lines are Terri's fixascii script used to put the correct line ending chars in the bin directory commandOS('zip', ['-qr', 'foo.zip', 'bin'], os.environ) commandOS('unzip', ['-aqo', 'foo.zip'], os.environ) os.remove('foo.zip') def _build(self): assert('JACORB_ROOT' in os.environ) os.chdir(os.environ['JACORB_ROOT']) commandOS('ant', ['jaco'], os.environ) commandOS('ant', ['idlcmd'], os.environ) class CipresLibTarget(Target): def addEnvVarForSelf(self, environ, addedEnv, step): effectiveStep = max(step, self.currentStep) if effectiveStep < StepEnum.stage: self._addEnvVarForOthers(environ, addedEnv, step) def _addEnvVarForOthers(self, environ, addedEnv, step): '''define CIPRES_CVS_ROOT, CIPRES_LIB_ROOT, and CIPRES_IDL_DIR if we are building/configuring something''' if step <= StepEnum.stage: # if we change this 'cipres' directory on the end of the path, change it in build_cipres.py too p = os.path.join(self.getAbsPath(StepEnum.build), 'cipres') addEnv(environ, addedEnv, CIPRES_CVS_ROOT = p) addEnv(environ, addedEnv, CIPRES_LIB_ROOT = os.path.join(p, 'framework')) addEnv(environ, addedEnv, CIPRES_IDL_DIR = os.path.join(p,'framework', 'IDL')) def _configure(self): if isWindows: return assert('CIPRES_LIB_ROOT' in os.environ) os.chdir(expandPath('$CIPRES_LIB_ROOT/C++')) commandOS('sh', ['createCommlibMakefileAM.sh'], os.environ) commandOS('autoreconf', [], os.environ) configArgs = self.__dict__.get('x_useACE') and [] or ['--enable-omni-orb'] commandOS('./configure', configArgs + Target.configureArgs, os.environ) def _build(self): assert('CIPRES_CVS_ROOT' in os.environ) os.chdir(expandPath(os.environ['CIPRES_CVS_ROOT'])) if isWindows: versionSpecificName = 'VC%s' % Target.devenvMainVersion libroot = os.environ['CIPRES_LIB_ROOT'] os.chdir(os.path.join(libroot, 'C++', 'build', versionSpecificName)) pathToSln = versionSpecificName + '.sln' for cfg in ['Debug', 'Release']: commandOS('devenv', [pathToSln, '/build', cfg, '/project', 'libcipres'], os.environ) else: make([os.path.join('framework', 'C++')], os.environ) # now build java code using ant os.chdir(expandPath(os.environ['CIPRES_CVS_ROOT'])) for antFile in ['build.xml', 'build-macros.xml', 'build-scripts.xml']: copyTreeIfNewer(os.path.join('cipres_dist', antFile), os.path.join(os.curdir, antFile)) commandOS('ant', ['build'], os.environ) def _stage(self): '''run ant configure from where we stage (need to make sure that we are staging everything the user will ''' os.chdir(self.getAbsPath(StepEnum.stage)) commandOS('ant', ['configure'], os.environ) class PipresTarget(Target): def addEnvVarForSelf(self, environ, addedEnv, step): self._addEnvVarForOthers(environ, addedEnv, step) def _addEnvVarForOthers(self, environ, addedEnv, step): addEnv(environ, addedEnv, PIPRES_ROOT = self.getAbsPath(max(self.currentStep, StepEnum.build))) appendEnv(environ, addedEnv, PYTHONPATH = environ['PIPRES_ROOT']) def _configure(self): assert('PIPRES_ROOT' in os.environ) os.chdir(expandPath(os.environ['PIPRES_ROOT'])) commandOS('python', ['setup.py', '--fidlcompile'], os.environ) class DcmTarget(Target): def _configure(self): if isWindows: return assert('CIPRES_CVS_ROOT' in os.environ) os.chdir(expandPath(os.path.join('$CIPRES_CVS_ROOT', 'phyloservices', 'dcm3'))) commandOS('autoreconf', [], os.environ) optConfigArgs = self.__dict__.get('x_randTieBreaking') and ['--enable-random-tie-breaking'] or [] commandOS('./configure', ['--prefix=%s' % Target.absPathToTop.getTopDir(StepEnum.stage), ] + optConfigArgs + Target.configureArgs, os.environ) def _build(self): assert('CIPRES_CVS_ROOT' in os.environ) if isWindows: versionSpecificName = 'VC%s' % Target.devenvMainVersion os.chdir(os.path.join(os.environ['CIPRES_CVS_ROOT'], 'phyloservices', 'dcm3', 'build', versionSpecificName)) pathToSln = 'dcm.sln' for cfg in ['Debug', 'Release']: commandOS('devenv', [pathToSln, '/build', cfg, '/project', 'dcm'], os.environ) else: #make([expandPath(os.path.join('$CIPRES_CVS_ROOT', 'phyloservices', 'dcm3'))], os.environ) os.chdir(expandPath(os.path.join('$CIPRES_CVS_ROOT', 'phyloservices', 'dcm3'))) commandOS('make', ['install'], os.environ) class PhycasTarget(Target): def addEnvVarForSelf(self, environ, addedEnv, step): effectiveStep = max(step, self.currentStep) if effectiveStep < StepEnum.stage: addEnv(environ, addedEnv, PHYCAS_ROOT = self.getAbsPath(StepEnum.build)) addEnv(environ, addedEnv, NCL_ROOT = '$PHYCAS_ROOT') def _configure(self): if isWindows: return assert('PHYCAS_ROOT' in os.environ) os.chdir(expandPath(os.path.join('$PHYCAS_ROOT','cipres_services'))) commandOS('autoreconf', [], os.environ) commandOS('./configure', ['--prefix=%s' % Target.absPathToTop.getTopDir(StepEnum.stage)] + Target.configureArgs, os.environ) def _build(self): assert('PHYCAS_ROOT' in os.environ) if isWindows: versionSpecificName = 'VC%s' % Target.devenvMainVersion os.chdir(os.path.join(os.environ['PHYCAS_ROOT'], 'cipres_services', versionSpecificName)) pathToSln = versionSpecificName + '.sln' for cfg in ['Debug', 'Release']: for proj in ['read_nexus', 'tree_merge']: commandOS('devenv', [pathToSln, '/build', cfg, '/project', proj], os.environ) else: make([expandPath(os.path.join('$PHYCAS_ROOT','cipres_services'))], os.environ) class PaupTarget(Target): buildDirFromPaupDir = 'cipres-paup' fileToSouce = os.path.join('$CIPRES_LIB_ROOT', 'C++', 'config', 'CommlibShEnv') def addEnvVarForSelf(self, environ, addedEnv, step): effectiveStep = max(step, self.currentStep) if effectiveStep < StepEnum.stage: addEnv(environ, addedEnv, PAUP_BUILD_DIR = os.path.join(self.getAbsPath(StepEnum.build), 'cipres-paup')) addEnv(environ, addedEnv, PAUP_ROOT = os.path.join(self.getAbsPath(StepEnum.clean), self.expanded_name, 'paup-cvs')) #print 'PAUP_ROOT =', expandPath('$PAUP_ROOT') #print 'PAUP_BUILD_DIR = ', expandPath('$PAUP_BUILD_DIR') def _configure(self): assert('PAUP_BUILD_DIR' in os.environ) # run autoconf paupCVSDir = expandPath(os.path.join('$PAUP_ROOT')) print paupCVSDir assert(os.path.exists(paupCVSDir)) os.chdir(paupCVSDir) print paupCVSDir commandOS('autoconf', [], os.environ) # run configure from buildDirFromPaupDir buildDir = expandPath('$PAUP_BUILD_DIR') if not os.path.exists(buildDir): os.makedirs = (buildDir) os.chdir(buildDir) expandedFileToSource = expandPath(PaupTarget.fileToSouce) pathToConfigure = expandPath(os.path.join('$PAUP_ROOT', 'configure')) cmd = 'source ' + expandedFileToSource + '; ' + pathToConfigure + ' --enable-cipres-corba --enable-future-code' + ' '.join(Target.configureArgs) _log.info('Using os.system to launch the command:\n\t' + cmd + '\n from directory ' + os.path.abspath(os.curdir)) os.system(cmd) def _makeAndReturnPathToExecutable(self, arg = ''): assert('PAUP_BUILD_DIR' in os.environ) buildDir = expandPath('$PAUP_BUILD_DIR') os.chdir(buildDir) expandedFileToSource = expandPath(PaupTarget.fileToSouce) pathToBuiltPaup = os.path.join(buildDir, 'paup') try: os.remove(pathToBuiltPaup) except OSError: pass cmd = 'source ' + expandedFileToSource + ' ; make ' + arg if self.__dict__.get('x_compilePaup'): _log.info('Using os.system to launch the command:\n\t' + cmd + '\n from directory ' + os.path.abspath(os.curdir)) os.system(cmd) return pathToBuiltPaup def _build(self): pathToBuiltPaup = self._makeAndReturnPathToExecutable() if self.__dict__.get('x_compilePaup') and not os.path.exists(pathToBuiltPaup): raise AssertionError, 'BuildFailed' def touch(self): Target.touch(self) self.addEnvVarForSelf(os.environ, {}, StepEnum.build) pathToBuiltPaup = self._makeAndReturnPathToExecutable('clean') class BoostTarget(Target): def _addEnvVarForOthers(self, environ, addedEnv, step): if step < StepEnum.stage: addEnv(environ, addedEnv, BOOST_ROOT = self.getAbsPath(step))