Ejemplo n.º 1
0
def create_makefiles(macros):
    """Create the Makefiles.

    macros is the dictionary of platform specific build macros.
    """
    # Bootstrap.  Make sure we get the right one.
    sys.path.insert(0, os.path.curdir)
    invalidate_caches()
    import sipconfig

    cfg = sipconfig.Configuration()

    cfg.set_build_macros(macros)

    sipconfig.inform("Creating top level Makefile...")

    sipconfig.ParentMakefile(
        configuration=cfg,
        subdirs=["sipgen", "siplib"],
        installs=(["sipconfig.py", os.path.join(src_dir, "sipdistutils.py")],
                cfg.sip_mod_dir)
    ).generate()

    sipconfig.inform("Creating sip code generator Makefile...")

    sipconfig.ProgramMakefile(
        configuration=cfg,
        build_file=os.path.join(src_dir, "sipgen", "sipgen.sbf"),
        dir="sipgen",
        install_dir=os.path.dirname(cfg.sip_bin),
        console=1,
        warnings=0,
        universal=opts.universal,
        arch=opts.arch,
        deployment_target=opts.deployment_target
    ).generate()

    sipconfig.inform("Creating sip module Makefile...")

    makefile = sipconfig.ModuleMakefile(
        configuration=cfg,
        build_file=os.path.join(src_dir, "siplib", "siplib.sbf"),
        dir="siplib",
        install_dir=cfg.sip_mod_dir,
        installs=([os.path.join(src_dir, "siplib", "sip.h")], cfg.sip_inc_dir),
        console=1,
        warnings=0,
        static=opts.static,
        debug=opts.debug,
        universal=opts.universal,
        arch=opts.arch,
        deployment_target=opts.deployment_target
    )

    makefile.generate()
Ejemplo n.º 2
0
def create_makefiles(macros):
    """Create the Makefiles.

    macros is the dictionary of platform specific build macros.
    """
    # Bootstrap.
    import sipconfig

    cfg = sipconfig.Configuration()

    cfg.set_build_macros(macros)

    sipconfig.inform("Creating top level Makefile...")

    sipconfig.ParentMakefile(
        configuration=cfg,
        subdirs=["sipgen", "siplib"],
        installs=(["sipconfig.py", "sipdistutils.py"], cfg.sip_mod_dir)
    ).generate()

    sipconfig.inform("Creating sip code generator Makefile...")

    sipconfig.ProgramMakefile(
        configuration=cfg,
        build_file="sipgen.sbf",
        dir="sipgen",
        install_dir=os.path.dirname(cfg.sip_bin),
        console=1,
        warnings=0,
        universal=opts.universal
    ).generate()

    sipconfig.inform("Creating sip module Makefile...")

    makefile = sipconfig.ModuleMakefile(
        configuration=cfg,
        build_file="siplib.sbf",
        dir="siplib",
        install_dir=cfg.sip_mod_dir,
        installs=(["sip.h"], cfg.sip_inc_dir),
        console=1,
        warnings=0,
        static=opts.static,
        debug=opts.debug,
        universal=opts.universal
    )

    makefile.generate()
Ejemplo n.º 3
0
def create_makefiles(macros):
    """Create the Makefiles.

    macros is the dictionary of platform specific build macros.
    """
    # Bootstrap.  Make sure we get the right one.
    sys.path.insert(0, os.path.curdir)
    invalidate_caches()
    import sipconfig

    cfg = sipconfig.Configuration()

    cfg.set_build_macros(macros)

    if opts.no_tools:
        subdirs = ["siplib"]
        installs = None
    else:
        subdirs = ["sipgen", "siplib"]
        installs = (["sipconfig.py",
                     os.path.join(src_dir,
                                  "sipdistutils.py")], cfg.sip_mod_dir)

    if opts.use_qmake:
        sipconfig.inform("Creating top level .pro file...")

        pro = open("sip.pro", "w")

        pro.write("TEMPLATE = subdirs\n")
        pro.write("SUBDIRS = %s\n" % " ".join(subdirs))

        if installs is not None:
            files, path = installs
            pro.write("\n")
            pro.write("build_system.files = %s\n" % " ".join(files))
            pro.write("build_system.path = %s\n" % quote(path))
            pro.write("INSTALLS += build_system\n")

        pro.close()
    else:
        sipconfig.inform("Creating top level Makefile...")

        sipconfig.ParentMakefile(configuration=cfg,
                                 subdirs=subdirs,
                                 installs=installs).generate()

    if opts.use_qmake:
        sipconfig.inform("Creating sip code generator .pro file...")

        pro = open(os.path.join("sipgen", "sipgen.pro"), "w")

        pro.write("TEMPLATE = app\n")
        pro.write("TARGET = sip\n")
        pro.write("CONFIG -= qt app_bundle\n")
        pro.write("CONFIG += warn_off exceptions_off console %s\n" %
                  (("debug" if opts.debug else "release")))

        pro.write("\n")
        pro.write("# Work around QTBUG-39300.\n")
        pro.write("CONFIG -= android_install\n")

        pro.write("\n")
        pro.write("target.path = %s\n" % os.path.dirname(cfg.sip_bin))
        pro.write("INSTALLS += target\n")

        c_sources = get_sources("sipgen", "*.c")
        pro.write("\n")
        pro.write("SOURCES = %s\n" % " ".join(c_sources))

        headers = get_sources("sipgen", "*.h")
        pro.write("\n")
        pro.write("HEADERS = %s\n" % " ".join(headers))

        pro.close()
    else:
        sipconfig.inform("Creating sip code generator Makefile...")

        sipconfig.ProgramMakefile(
            configuration=cfg,
            build_file=os.path.join(src_dir, "sipgen", "sipgen.sbf"),
            dir="sipgen",
            install_dir=os.path.dirname(cfg.sip_bin),
            console=1,
            warnings=0,
            universal=opts.universal,
            arch=opts.arch,
            deployment_target=opts.deployment_target).generate()

    if opts.use_qmake:
        sipconfig.inform("Creating sip module .pro file...")

        pro = open(os.path.join("siplib", "siplib.pro"), "w")

        pro.write("TEMPLATE = lib\n")
        pro.write("TARGET = %s\n" % sip_module_base)
        pro.write("CONFIG -= qt\n")
        pro.write("CONFIG += warn_on exceptions_off %s %s\n" %
                  (("staticlib" if opts.static else "plugin"),
                   ("debug" if opts.debug else "release")))

        pro.write("\n")
        pro.write("# Work around QTBUG-39300.\n")
        pro.write("CONFIG -= android_install\n")

        pro.write("\n")
        pro.write("INCLUDEPATH += %s\n" % cfg.py_inc_dir)
        if cfg.py_conf_inc_dir != cfg.py_inc_dir:
            pro.write("INCLUDEPATH += %s\n" % cfg.py_conf_inc_dir)

        if not opts.static:
            # These only need to be correct for Windows.
            debug_suffix = "_d" if opts.debug else ""
            link_lib_dir = quote("-L" + cfg.py_lib_dir)

            pro.write("""
win32 {
    PY_MODULE = %s%s.pyd
    target.files = %s%s.pyd
    LIBS += %s -lpython%d.%d
    QMAKE_POST_LINK = $(COPY_FILE) $(DESTDIR_TARGET) $$PY_MODULE
} else {
    PY_MODULE = %s.so
    target.files = %s.so
    QMAKE_POST_LINK = $(COPY_FILE) $(TARGET) $$PY_MODULE
}

macx {
    QMAKE_LFLAGS += "-undefined dynamic_lookup"
    QMAKE_LFLAGS += "-install_name $$absolute_path($$PY_MODULE, $$target.path)"
}
""" % (sip_module_base, debug_suffix, sip_module_base, debug_suffix,
            link_lib_dir, (py_version >> 16),
            ((py_version >> 8) & 0xff), sip_module_base, sip_module_base))

        pro.write("\n")
        pro.write("target.CONFIG = no_check_exist\n")
        pro.write("target.path = %s\n" % cfg.sip_mod_dir)
        pro.write("INSTALLS += target\n")

        pro.write("\n")
        pro.write("sip_h.files = sip.h\n")
        pro.write("sip_h.path = %s\n" % cfg.sip_inc_dir)
        pro.write("INSTALLS += sip_h\n")

        c_sources = get_sources("siplib", "*.c")
        cpp_sources = get_sources("siplib", "*.cpp")
        pro.write("\n")
        pro.write("SOURCES = %s\n" % " ".join(c_sources + cpp_sources))

        headers = get_sources("siplib", "*.h")
        pro.write("\n")
        pro.write("HEADERS = %s\n" % " ".join(headers))

        pro.close()
    else:
        sipconfig.inform("Creating sip module Makefile...")

        sipconfig.ModuleMakefile(
            configuration=cfg,
            build_file=os.path.join(src_dir, "siplib", "siplib.sbf"),
            dir="siplib",
            install_dir=cfg.sip_mod_dir,
            installs=([os.path.join(src_dir, "siplib",
                                    "sip.h")], cfg.sip_inc_dir),
            console=1,
            warnings=0,
            static=opts.static,
            debug=opts.debug,
            universal=opts.universal,
            arch=opts.arch,
            deployment_target=opts.deployment_target).generate()
Ejemplo n.º 4
0
def create_makefiles(macros):
    """Create the Makefiles.

    macros is the dictionary of platform specific build macros.
    """
    # Bootstrap.  Make sure we get the right one.
    sys.path.insert(0, os.path.curdir)
    invalidate_caches()
    import sipconfig

    cfg = sipconfig.Configuration()

    cfg.set_build_macros(macros)

    all_installs = []
    top_installs = []
    gen_installs = []
    subdirs = []

    if not opts.no_tools:
        subdirs.append('sipgen')
        top_installs.append(
            (["sipconfig.py",
              os.path.join(src_dir, "sipdistutils.py")], cfg.sip_root_dir))
        gen_installs.append((os.path.join(src_dir, "siplib",
                                          "sip.h"), cfg.sip_inc_dir))

    if not opts.no_module:
        subdirs.append('siplib')

    all_installs.extend(top_installs)
    all_installs.extend(gen_installs)

    # The command to run to generate the dist-info directory.
    mk_distinfo = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                               'mk_distinfo.py')
    distinfo_dir = os.path.join(
        cfg.sip_module_dir, '%s-%s.dist-info' %
        (sip_module_name.replace('.', '_'), sip_version_str))

    if opts.use_qmake:
        run_mk_distinfo = '%s %s \\\"$(INSTALL_ROOT)\\\" %s installed.txt' % (
            sys.executable, mk_distinfo, distinfo_dir)

        sipconfig.inform("Creating top level .pro file...")

        pro = open("sip.pro", "w")

        pro.write("TEMPLATE = subdirs\n")
        pro.write("SUBDIRS = %s\n" % " ".join(subdirs))

        if top_installs:
            # There will only be one element.
            files, path = top_installs[0]
            pro.write("\n")
            pro.write("build_system.files = %s\n" % " ".join(files))
            pro.write("build_system.path = %s\n" % quote(path))
            pro.write("INSTALLS += build_system\n")

        if opts.distinfo:
            pro.write("\n")
            pro.write("distinfo.extra = %s\n" % run_mk_distinfo)
            pro.write("distinfo.path = %s\n" % quote(cfg.sip_module_dir))
            pro.write("INSTALLS += distinfo\n")

        pro.close()
    else:
        run_mk_distinfo = '%s %s "$(DESTDIR)" %s installed.txt' % (
            sys.executable, mk_distinfo, distinfo_dir)

        sipconfig.inform("Creating top level Makefile...")

        # Note that mk_distinfo.py won't exist if we are building from the
        # repository.
        if opts.distinfo and os.path.isfile(mk_distinfo):
            top_installs.append((run_mk_distinfo, None))

        sipconfig.ParentMakefile(configuration=cfg,
                                 subdirs=subdirs,
                                 installs=top_installs).generate()

    if opts.use_qmake:
        sipconfig.inform("Creating sip code generator .pro file...")

        pro = open(os.path.join("sipgen", "sipgen.pro"), "w")

        pro.write("TEMPLATE = app\n")
        pro.write("TARGET = sip\n")
        pro.write("CONFIG -= qt app_bundle\n")
        pro.write("CONFIG += warn_on exceptions_off console %s\n" %
                  (("debug" if opts.debug else "release")))

        pro.write("\n")
        pro.write("# Work around QTBUG-39300.\n")
        pro.write("CONFIG -= android_install\n")

        pro.write("\n")
        pro.write("target.path = %s\n" % os.path.dirname(cfg.sip_bin))
        pro.write("INSTALLS += target\n")

        c_sources = get_sources("sipgen", "*.c")
        pro.write("\n")
        pro.write("SOURCES = %s\n" %
                  " ".join([qmake_quote(s) for s in c_sources]))

        headers = get_sources("sipgen", "*.h")
        pro.write("\n")
        pro.write("HEADERS = %s\n" %
                  " ".join([qmake_quote(h) for h in headers]))

        if gen_installs:
            # There will only be one element.
            files, path = gen_installs[0]
            pro.write("\n")
            pro.write("sip_h.files = %s\n" % " ".join(files))
            pro.write("sip_h.path = %s\n" % quote(path))
            pro.write("INSTALLS += sip_h\n")

        pro.close()
    else:
        sipconfig.inform("Creating sip code generator Makefile...")

        sipconfig.ProgramMakefile(
            configuration=cfg,
            build_file=os.path.join(src_dir, "sipgen", "sipgen.sbf"),
            dir="sipgen",
            install_dir=os.path.dirname(cfg.sip_bin),
            installs=gen_installs,
            console=1,
            warnings=1,
            universal=opts.universal,
            arch=opts.arch,
            deployment_target=opts.deployment_target).generate()

    # The implied code generator installs.
    if not opts.no_tools:
        sip_dir, sip_exe = os.path.split(cfg.sip_bin)
        if sys.platform == 'win32':
            sip_exe += '.exe'

        all_installs.append((sip_exe, sip_dir))

    # The module installs.
    module_installs = []

    if opts.pyi:
        module_installs.append((os.path.join(src_dir, 'sip.pyi'), pyi_dir))

    all_installs.extend(module_installs)

    if not opts.no_module:
        if sys.platform == 'win32':
            mod = 'sip.lib' if opts.static else 'sip.pyd'
        else:
            mod = 'libsip.a' if opts.static else 'sip.so'

        all_installs.append((mod, sip_module_dest_dir))

    if opts.use_qmake:
        sipconfig.inform("Creating sip module .pro file...")

        pro = open(os.path.join("siplib", "siplib.pro"), "w")

        pro.write("TEMPLATE = lib\n")
        pro.write("TARGET = sip\n")
        pro.write("CONFIG -= qt\n")
        pro.write("CONFIG += warn_on exceptions_off %s %s\n" %
                  (("staticlib" if opts.static else "plugin plugin_bundle"),
                   ("debug" if opts.debug else "release")))

        pro.write("\n")
        pro.write("# Work around QTBUG-39300.\n")
        pro.write("CONFIG -= android_install\n")

        pro.write("\n")
        pro.write("INCLUDEPATH += %s\n" % cfg.py_inc_dir)
        if cfg.py_conf_inc_dir != cfg.py_inc_dir:
            pro.write("INCLUDEPATH += %s\n" % cfg.py_conf_inc_dir)

        if sip_module_name != 'sip':
            pro.write("\n")
            pro.write('DEFINES += SIP_MODULE_NAME=%s\n' % sip_module_name)

            base_name = sip_module_name.split('.')[-1]
            if base_name != 'sip':
                pro.write('DEFINES += SIP_MODULE_BASENAME=%s\n' % base_name)

        if not opts.static:
            # These only need to be correct for Windows.
            debug_suffix = "_d" if opts.debug else ""
            link_lib_dir = quote("-L" + cfg.py_lib_dir)

            pro.write("""
win32 {
    PY_MODULE = sip%s.pyd
    PY_MODULE_SRC = $(DESTDIR_TARGET)

    LIBS += %s
} else {
    PY_MODULE = sip.so

    macx {
        PY_MODULE_SRC = $(TARGET).plugin/Contents/MacOS/$(TARGET)

        QMAKE_LFLAGS += "-undefined dynamic_lookup"
    } else {
        PY_MODULE_SRC = $(TARGET)
    }
}

QMAKE_POST_LINK = $(COPY_FILE) $$PY_MODULE_SRC $$PY_MODULE

target.CONFIG = no_check_exist
target.files = $$PY_MODULE
""" % (debug_suffix, link_lib_dir))

        pro.write("\n")
        pro.write("target.path = %s\n" % sip_module_dest_dir)
        pro.write("INSTALLS += target\n")

        if opts.pyi:
            pro.write("\n")
            pro.write("sip_pyi.files = sip.pyi\n")
            pro.write("sip_pyi.path = %s\n" % pyi_dir)
            pro.write("INSTALLS += sip_pyi\n")

        c_sources = get_sources("siplib", "*.c")
        cpp_sources = get_sources("siplib", "*.cpp")
        pro.write("\n")
        pro.write("SOURCES = %s\n" %
                  " ".join([qmake_quote(s) for s in c_sources + cpp_sources]))

        headers = get_sources("siplib", "*.h")
        pro.write("\n")
        pro.write("HEADERS = %s\n" %
                  " ".join([qmake_quote(h) for h in headers]))

        pro.close()
    else:
        sipconfig.inform("Creating sip module Makefile...")

        build_dir = os.getcwd()

        makefile = sipconfig.ModuleMakefile(
            configuration=cfg,
            build_file=os.path.join(src_dir, "siplib", "siplib.sbf"),
            dir="siplib",
            install_dir=sip_module_dest_dir,
            installs=module_installs,
            console=1,
            warnings=1,
            static=opts.static,
            debug=opts.debug,
            universal=opts.universal,
            arch=opts.arch,
            deployment_target=opts.deployment_target)

        if sip_module_name != 'sip':
            makefile.DEFINES.append('SIP_MODULE_NAME=%s' % sip_module_name)

            base_name = sip_module_name.split('.')[-1]
            if base_name != 'sip':
                makefile.DEFINES.append('SIP_MODULE_BASENAME=%s' % base_name)

        if src_dir != build_dir:
            src_siplib_dir = os.path.join(src_dir, "siplib")
            makefile.extra_include_dirs.append(src_siplib_dir)
            makefile.extra_source_dirs.append(src_siplib_dir)

        makefile.generate()

    # Create the file containing all installed files.
    if opts.distinfo:
        installed = open('installed.txt', 'w')

        for sources, dst in all_installs:
            if not isinstance(sources, (list, tuple)):
                sources = [sources]

            for src in sources:
                installed.write(
                    os.path.join(dst, os.path.basename(src)) + '\n')

        installed.close()
Ejemplo n.º 5
0
def main():
    excludeMods = set()

    config = sipconfig.Configuration()

    fn = rootName('config.inc')
    confFile = open(rootName('config.inc'))
    for line in confFile:
        if line.startswith('export'): break
        line = line.strip('\n ')
        if line.startswith('COMPILE_'):
            var, value = line.split('=')
            try:
                value = int(value)
            except ValueError:
                continue
            if not value:
                excludeMods.add(var.split('_')[-1].lower())

    for modName, modDirs in modules:

        extra_cxxflags = []
        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)

        global rootDir
        orig_rootDir = rootDir
        rootDir = os.path.join('..', rootDir)

        sipFileNameSrc = "lima%s.sip" % modName
        if modName != 'core':
            sipFileNameIn = os.path.join("..", "limamodules.sip.in")
            f = file(sipFileNameIn)
            lines = f.read()
            f.close()
            newlines = lines.replace('%NAME', modName)
            d = file(sipFileNameSrc, 'w')
            d.write(newlines)
            d.close()

        sipFileName = "lima%s_tmp.sip" % modName
        shutil.copyfile(sipFileNameSrc, sipFileName)

        initNumpy = 'lima_init_numpy.cpp'
        shutil.copyfile(os.path.join('..', initNumpy), initNumpy)

        dirProcesslib = rootName(os.path.join('third-party', 'Processlib'))
        sipProcesslib = os.path.join(dirProcesslib, 'sip')
        extraIncludes = [
            '.',
            os.path.join('..', 'core'), sipProcesslib,
            numpy.get_include(), config.sip_inc_dir
        ]

        extraIncludes += findIncludes(dirProcesslib)
        if platform.system() == 'Windows':
            extraIncludes += [
                os.path.join(dirProcesslib, "core", "include",
                             "WindowSpecific")
            ]

        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 = os.path.join(espia_base, 'src')
            extraIncludes += [espia_incl]

        if (modName == 'basler'):
            extraIncludes += [
                '/opt/pylon/include', '/opt/pylon/include/genicam',
                '/opt/pylon/genicam/library/CPP/include'
            ]
            extra_cxxflags += ['-DUSE_GIGE']
        elif (modName == 'ueye') and platform.system() != 'Windows':
            extra_cxxflags += ['-D__LINUX__']
        elif (modName == 'andor'):
            extraIncludes += ['/usr/local/include']
        elif (modName == 'xpad'):
            extraIncludes += [
                '../../third-party/yat/include',
                '/home/xpix_user/PCI_VALIDATED/trunk/sw/xpci_lib'
            ]
        elif (modName == 'pco'):
            extraIncludes += [
                'R:/bliss/projects/LIMA/package/WIN32/PCO/sdkPco/include'
            ]
        elif (modName == 'marccd'):
            extraIncludes += ['../../../include/DiffractionImage']
            extraIncludes += ['../../third-party/yat/include']

        extraIncludes += findModuleIncludes(modName)

        sipFile = open(sipFileName, "a")
        sipFile.write('\n')

        sipProcesslib = sipProcesslib.replace(
            os.sep, '/')  # sip don't manage windows path
        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
                    incl = os.path.join(root, filename)
                    incl = incl.replace(os.sep,
                                        '/')  # sip don't manage windows path.
                    sipFile.write('%%Include %s\n' % incl)

        sipFile.close()

        # The name of the SIP build file generated by SIP and used by the build
        # system.
        build_file = "lima%s.sbf" % modName

        # Run SIP to generate the code.
        # module's specification files using the -I flag.
        if platform.system() == 'Windows':
            plat = 'WIN32_PLATFORM'
        else:
            plat = 'POSIX_PLATFORM'
        cmd = " ".join([
            config.sip_bin, "-g", "-e", "-c", '.', '-t', plat, "-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

        if platform.system() == 'Windows':
            makefile.extra_libs = ['liblima%s' % modName, 'libprocesslib']
            if modName != 'core':
                makefile.extra_libs += ['liblimacore']
            makefile.extra_cxxflags = ['/EHsc'] + extra_cxxflags
            #libpath = 'build\msvc\9.0\*\Debug'
            libpath = 'build\msvc\9.0\*\Release'
            #makefile.extra_lib_dirs = glob.glob(os.path.join(rootName('build'),'msvc','9.0','*','Release'))

            makefile.extra_lib_dirs += glob.glob(
                os.path.join(rootName(''), libpath))
            makefile.extra_lib_dirs += glob.glob(
                os.path.join(rootName('third-party\Processlib'), libpath))
            makefile.extra_lib_dirs += glob.glob(
                os.path.join(rootName('camera'), modName, libpath))

        else:
            makefile.extra_libs = ['pthread', 'lima%s' % modName]
            makefile.extra_cxxflags = ['-pthread', '-g', '-DWITH_SPS_IMAGE'
                                       ] + extra_cxxflags
            makefile.extra_lib_dirs = [rootName('build')]
        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,
                                       os.path.join("..", "limaconfig.py.in"),
                                       content)

        # Fix SIP Exception handling
        for cpp_file in glob.glob('siplima*.cpp'):
            modify = checksipexc(cpp_file)
            cpp_file_out = '%s.out' % cpp_file
            if not modify:
                os.remove(cpp_file_out)
            else:
                os.remove(cpp_file)
                shutil.move(cpp_file_out, cpp_file)

        os.chdir('..')
        rootDir = orig_rootDir
Ejemplo n.º 6
0
def main():
    excludeMods = set()

    config = sipconfig.Configuration()

    fn = rootName('config.inc')
    confFile = open(rootName('config.inc'))
    for line in confFile:
        if line.startswith('export'): break
        line = line.strip('\n ')
        if line.startswith('COMPILE_'):
            var, value = line.split('=')
            try:
                value = int(value)
            except ValueError:
                continue
            if not value:
                modname = '_'.join([x.lower() for x in var.split('_')[1:]])
                excludeMods.add(modname)

    for modName, modDirs in modules:

        extra_cxxflags = []
        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)

        global rootDir
        orig_rootDir = rootDir
        rootDir = os.path.join('..', rootDir)

        sipFileNameSrc = "lima%s.sip" % modName
        if modName != 'core':
            if major == 4 and minor < 12:
                sipFileNameIn = os.path.join("..",
                                             "limamodules_before_4_12.sip.in")
            else:
                sipFileNameIn = os.path.join("..", "limamodules.sip.in")
            f = open(sipFileNameIn)
            lines = f.read()
            f.close()
            newlines = lines.replace('%NAME', modName)
            d = open(sipFileNameSrc, 'w')
            d.write(newlines)
            d.close()
        elif major == 4 and minor < 12:
            sipFileNameSrc = "limacore_before_4_12.sip"

        sipFileName = "lima%s_tmp.sip" % modName
        shutil.copyfile(sipFileNameSrc, sipFileName)

        initNumpy = 'lima_init_numpy.cpp'
        shutil.copyfile(os.path.join('..', initNumpy), initNumpy)

        dirProcesslib = rootName(os.path.join('third-party', 'Processlib'))
        sipProcesslib = os.path.join(dirProcesslib, 'sip')
        extraIncludes = [
            '.',
            os.path.join('..', 'core'), sipProcesslib,
            numpy.get_include(), config.sip_inc_dir
        ]

        extraIncludes += findIncludes(dirProcesslib)
        if platform.system() == 'Windows':
            extraIncludes += [
                os.path.join(dirProcesslib, "core", "include",
                             "WindowSpecific")
            ]

        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 = os.path.join(espia_base, 'src')
            extraIncludes += [espia_incl]

        if (modName == 'basler'):
            if platform.system() != 'Windows':
                extraIncludes += ['%s/include' % os.environ['PYLON_ROOT']]
                extraIncludes += [
                    '%s/library/CPP/include' % os.environ['GENICAM_ROOT_V2_1']
                ]
                extra_cxxflags += ['-DUSE_GIGE']
            else:
                extraIncludes += [
                    '%s\library\cpp\include' % os.environ['PYLON_GENICAM_ROOT']
                ]
                extraIncludes += ['%s\include' % os.environ['PYLON_ROOT']]
                extra_cxxflags += ['-DUSE_GIGE']
        elif (modName == 'ueye') and platform.system() != 'Windows':
            extra_cxxflags += ['-D__LINUX__']
        elif (modName == 'andor'):
            extraIncludes += ['/usr/local/include']
        elif (modName == 'xpad'):
            extraIncludes += [
                '../../third-party/yat/include',
                '/home/xpix_user/PCI_VALIDATED/trunk/sw/xpci_lib'
            ]
        elif (modName == 'xspress3'):
            extraIncludes += ['../../third-party/hdf5/c++/src']
            extra_cxxflags += ['-DSIPCOMPILATION']
        elif (modName == 'pco'):
            extraIncludes += [
                'R:/bliss/projects/LIMA/package/WIN32/PCO/sdkPco/include'
            ]
        elif (modName == 'marccd'):
            extraIncludes += ['../../../include/DiffractionImage']
            extraIncludes += ['../../third-party/yat/include']
        elif (modName == 'pointgrey'):
            extraIncludes += ['/usr/include/flycapture']
        elif (modName == 'rayonixhs'):
            extraIncludes += [
                '/opt/rayonix/include/craydl', '/opt/rayonix/include',
                '/opt/rayonix/include/marccd'
            ]
            extra_cxxflags += ['-std=c++0x']
        elif (modName == 'aviex'):
            extra_cxxflags += ['-DOS_UNIX']
        elif (modName == 'maxipix'):
            extraIncludes += ['../../camera/maxipix/tools/src']
        elif (modName == 'pixirad'):
            extra_cxxflags += ['-std=c++11']
            extraIncludes += findModuleIncludes(modName)
        elif (modName == 'hexitec'):
            extraIncludes += [
                '../../camera/hexitec/sdk',
                '/opt/pleora/ebus_sdk/CentOS-RHEL-7-x86_64/include'
            ]
            extra_cxxflags += ['-std=c++11']
            extra_cxxflags += ['-DSIPCOMPILATION']
        elif (modName == 'slsdetector'):
            SLS_DETECTORS_DIR = os.environ['SLS_DETECTORS_DIR']
            SLS_DETECTORS_SW = os.path.join(SLS_DETECTORS_DIR,
                                            'slsDetectorSoftware')
            SLS_DETECTORS_RECV = os.path.join(SLS_DETECTORS_DIR,
                                              'slsReceiverSoftware')
            slsIncl = [
                os.path.join(SLS_DETECTORS_SW, 'include'),
                os.path.join(SLS_DETECTORS_SW, 'commonFiles'),
                os.path.join(SLS_DETECTORS_SW, 'slsDetector'),
                os.path.join(SLS_DETECTORS_SW, 'multiSlsDetector'),
                os.path.join(SLS_DETECTORS_SW, 'slsDetectorServer'),
                os.path.join(SLS_DETECTORS_SW, 'slsDetectorAnalysis'),
                os.path.join(SLS_DETECTORS_SW, 'slsReceiverInterface'),
                os.path.join(SLS_DETECTORS_RECV, 'include'),
            ]
            extraIncludes += slsIncl
        extraIncludes += findModuleIncludes(modName)
        if (modName == 'roperscientific'):
            extraIncludes.remove(
                '../../camera/roperscientific/sdk/msvc/include')

        sipFile = open(sipFileName, "a")
        sipFile.write('\n')

        sipProcesslib = sipProcesslib.replace(
            os.sep, '/')  # sip don't manage windows path
        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
                    if major == 4 and minor < 12:
                        if os.access(os.path.join(root, filename + "_4_12"),
                                     os.R_OK):
                            filename += "_4_12"

                    incl = os.path.join(root, filename)
                    incl = incl.replace(os.sep,
                                        '/')  # sip don't manage windows path.
                    sipFile.write('%%Include %s\n' % incl)

        sipFile.close()

        # The name of the SIP build file generated by SIP and used by the build
        # system.
        build_file = "lima%s.sbf" % modName

        # Run SIP to generate the code.
        # module's specification files using the -I flag.
        if platform.system() == 'Windows':
            if platform.machine() == 'AMD64':
                plat = 'WIN64_PLATFORM'
            else:
                plat = 'WIN32_PLATFORM'
        else:
            plat = 'POSIX_PLATFORM'
        cmdargs = [config.sip_bin, "-g", "-e", "-c", '.', '-t', plat]
        if 'config' in excludeMods:
            cmdargs.extend(['-x', 'WITH_CONFIG'])
        cmdargs.extend(["-b", build_file, sipFileName])
        cmd = " ".join(cmdargs)
        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

        if platform.system() == 'Windows':
            makefile.extra_libs = [
                'liblima%s' % modName, 'libprocesslib', 'libconfig++'
            ]
            if modName != 'core':
                makefile.extra_libs += ['liblimacore']
            makefile.extra_cxxflags = ['/EHsc', '/DWITH_CONFIG'
                                       ] + extra_cxxflags
            if platform.machine() == 'AMD64':
                libpath = 'build\msvc\9.0\*\\x64\Release'
                makefile.extra_cxxflags.append('/DWITHOUT_GSL')
            else:
                libpath = 'build\msvc\9.0\*\Release'

            makefile.extra_lib_dirs += glob.glob(
                os.path.join(rootName(''), libpath))
            makefile.extra_lib_dirs += glob.glob(
                os.path.join(rootName('third-party\Processlib'), libpath))
            makefile.extra_lib_dirs += glob.glob(
                os.path.join(rootName('camera'), modName, libpath))
            makefile.extra_lib_dirs += glob.glob(
                os.path.join(rootName('third-party\libconfig'), 'lib',
                             'libconfig++.Release'))
            makefile.extra_lib_dirs += glob.glob(
                os.path.join(rootName('third-party\libconfig'), 'lib', 'x64',
                             'Release'))

            if (modName == 'basler'):
                makefile.extra_lib_dirs += [
                    '%s\library\cpp\lib\win32_i86' %
                    os.environ['PYLON_GENICAM_ROOT']
                ]
                makefile.extra_lib_dirs += [
                    '%s\lib\Win32' % os.environ['PYLON_ROOT']
                ]
        else:
            makefile.extra_libs = ['pthread', 'lima%s' % modName]
            makefile.extra_cxxflags = ['-pthread', '-g', '-DWITH_SPS_IMAGE'
                                       ] + extra_cxxflags
            if 'config' not in excludeMods:
                makefile.extra_cxxflags.append('-DWITH_CONFIG')
            makefile.extra_lib_dirs = [rootName('build')]

            if modName == 'slsdetector':
                bad_flag = '-Werror=format-security'
                good_flag = '-Wno-error=format-security'
                for flags in [makefile.CFLAGS, makefile.CXXFLAGS]:
                    for fg in flags.as_list():
                        if bad_flag in fg:
                            flags.remove(fg)
                            fg = good_flag.join(fg.split(bad_flag))
                            flags.extend([fg])

        makefile.extra_cxxflags.extend(['-I"%s"' % 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,
                                       os.path.join("..", "limaconfig.py.in"),
                                       content)

        # Fix SIP Exception handling
        for cpp_file in glob.glob('siplima*.cpp'):
            modify = checksipexc(cpp_file)
            cpp_file_out = '%s.out' % cpp_file
            if not modify:
                os.remove(cpp_file_out)
            else:
                os.remove(cpp_file)
                shutil.move(cpp_file_out, cpp_file)

        os.chdir('..')
        rootDir = orig_rootDir
Ejemplo n.º 7
0
# We are going to install the SIP specification file for this module and
# its configuration module.
installs = []

installs.append(
    ['gldisplay.sip',
     os.path.join(config.default_sip_dir, 'gldisplay')])

installs.append(['gldisplayconfig.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,
)

LIMA = os.path.join('..', '..', '..')
PROCESSLIB = os.path.join(LIMA, 'third-party', 'Processlib')
QTDIR = os.environ.get('QTDIR')

makefile.extra_include_dirs = [
    os.path.join('..', 'include'),
    os.path.join(LIMA, 'common', 'include'),
    os.path.join(LIMA, 'hardware', 'include'),
    os.path.join(LIMA, 'control', 'include'),
    os.path.join(PROCESSLIB, 'core', 'include')
]
makefile.extra_cxxflags = ['-pthread', '-I' + numpy.get_include(), '-g']
Ejemplo n.º 8
0
def setup_qwt4_build(configuration, options, package):
    """Setup the qwt package build
    """
    if 'Qwt4' not in options.modules:
        return

    print 'Setup the qwt package build.'

    build_dir = options.qwt
    tmp_dir = 'tmp-%s' % options.qwt
    build_file = os.path.join(tmp_dir, '%s.sbf' % options.qwt)
    extra_sources = []
    extra_headers = []
    extra_moc_headers = []
    extra_py_files = glob.glob(
        os.path.join(os.pardir, 'qt3lib', 'Qwt4', '*.py'))

    # do we compile and link the sources of Qwt statically into PyQwt?
    if options.qwt_sources:
        extra_sources += glob.glob(
            os.path.join(options.qwt_sources, 'src', '*.cpp'))
        extra_headers += glob.glob(
            os.path.join(options.qwt_sources, 'include', '*.h'))
        extra_moc_headers = []
        for header in extra_headers:
            text = open(header).read()
            if re.compile(r'^\s*Q_OBJECT', re.M).search(text):
                extra_moc_headers.append(header)

    # add the interface to the numerical Python extensions
    extra_sources += glob.glob(os.path.join(os.pardir, 'support', '*.cpp'))
    extra_headers += glob.glob(os.path.join(os.pardir, 'support', '*.h'))

    # do we compile and link the sources of Qwt into PyQwt?
    if options.qwt_sources:
        # yes, zap all 'qwt'
        while options.extra_libs.count('qwt'):
            options.extra_libs.remove('qwt')
    elif 'qwt' not in options.extra_libs:
        # no, add 'qwt' if needed
        options.extra_libs.append('qwt')

    # zap the temporary directory
    try:
        shutil.rmtree(tmp_dir)
    except:
        pass
    # make a clean temporary directory
    try:
        os.mkdir(tmp_dir)
    except:
        raise Die, 'Failed to create the temporary build directory.'

    # copy the extra files
    copy_files(extra_sources, tmp_dir)
    copy_files(extra_headers, tmp_dir)
    copy_files(extra_moc_headers, tmp_dir)
    copy_files(extra_py_files, tmp_dir)

    try:  # Qt4
        pyqt_sip_flags = configuration.pyqt_sip_flags
    except AttributeError:  # Qt3
        pyqt_sip_flags = configuration.pyqt_qt_sip_flags

    # invoke SIP
    cmd = ' '.join([
        configuration.sip_bin,
        # SIP assumes POSIX style path separators
        '-I',
        configuration.pyqt_sip_dir.replace('\\', '/'),
        '-b',
        build_file,
        '-c',
        tmp_dir,
        options.jobs,
        options.trace,
        pyqt_sip_flags,
    ] + options.sip_include_dirs + options.excluded_features +
                   options.timelines
                   # SIP assumes POSIX style path separators
                   + [options.qwt_sipfile.replace('\\', '/')])

    print 'sip invokation:'
    pprint.pprint(cmd)
    if os.path.exists(build_file):
        os.remove(build_file)
    os.system(cmd)
    if not os.path.exists(build_file):
        raise Die, 'SIP failed to generate the C++ code.'

    # FIXME: sip-4.7 does not generate those include files anymore
    for name in [
            os.path.join(tmp_dir, name) for name in [
                'sipQwtQwtArrayDouble.h',
                'sipQwtQwtArrayInt.h',
                'sipQwtQwtArrayQwtDoublePoint.h',
            ]
    ]:
        if not os.path.exists(name):
            open(name, 'w')

    # fix the SIP build file
    fix_build_file(build_file, [os.path.basename(f) for f in extra_sources],
                   [os.path.basename(f) for f in extra_headers],
                   [os.path.basename(f) for f in extra_moc_headers])

    # copy lazily to the build directory to speed up recompilation
    if not os.path.exists(build_dir):
        try:
            os.mkdir(build_dir)
        except:
            raise Die, 'Failed to create the build directory.'

    lazy_copies = 0
    for pattern in ('*.c', '*.cpp', '*.h', '*.py', '*.sbf'):
        for source in glob.glob(os.path.join(tmp_dir, pattern)):
            target = os.path.join(build_dir, os.path.basename(source))
            if lazy_copy_file(source, target):
                print 'Copy %s -> %s.' % (source, target)
                lazy_copies += 1
    print '%s file(s) lazily copied.' % lazy_copies

    # byte-compile the Python files
    compileall.compile_dir(build_dir, 1, options.module_install_path)

    # files to be installed
    installs = []
    installs.append([[
        os.path.basename(f)
        for f in glob.glob(os.path.join(build_dir, '*.py*'))
    ], options.module_install_path])

    pattern = os.path.join(os.pardir, 'sip', options.qwt, '*.sip')
    installs.append([[os.path.join(os.pardir, f) for f in glob.glob(pattern)],
                     os.path.join(configuration.pyqt_sip_dir, 'Qwt4')])
    pattern = os.path.join(os.pardir, 'sip', options.qwt, 'common', '*.sip')
    installs.append([[os.path.join(os.pardir, f) for f in glob.glob(pattern)],
                     os.path.join(configuration.pyqt_sip_dir, 'Qwt4',
                                  'common')])

    # module makefile
    makefile = sipconfig.ModuleMakefile(
        configuration=configuration,
        build_file=os.path.basename(build_file),
        dir=build_dir,
        install_dir=options.module_install_path,
        installs=installs,
        qt=1,
        warnings=1,
        debug=options.debug,
    )

    makefile.extra_cflags.extend(options.extra_cflags)
    makefile.extra_cxxflags.extend(options.extra_cxxflags)
    makefile.extra_defines.extend(options.extra_defines)
    makefile.extra_include_dirs.extend(options.extra_include_dirs)
    makefile.extra_lflags.extend(options.extra_lflags)
    makefile.extra_libs.extend(options.extra_libs)
    makefile.extra_lib_dirs.extend(options.extra_lib_dirs)
    makefile.generate()
Ejemplo n.º 9
0
def setup_iqt_build(configuration, options, package):
    """Setup the iqt package build
    """
    if 'iqt' not in options.modules:
        return

    print 'Setup the iqt package build.'

    build_dir = options.iqt
    tmp_dir = 'tmp-' + build_dir
    build_file = os.path.join(tmp_dir, '%s.sbf' % options.iqt)

    # zap the temporary directory
    try:
        shutil.rmtree(tmp_dir)
    except:
        pass
    # make a clean temporary directory
    try:
        os.mkdir(tmp_dir)
    except:
        raise Die, 'Failed to create the temporary build directory.'

    # invoke SIP
    cmd = ' '.join([
        configuration.sip_bin,
        '-b',
        build_file,
        '-c',
        tmp_dir,
        options.jobs,
        options.trace,
    ] + options.excluded_features
                   # SIP assumes POSIX style path separators
                   + [options.iqt_sipfile.replace('\\', '/')])

    print 'sip invokation:'
    pprint.pprint(cmd)
    if os.path.exists(build_file):
        os.remove(build_file)
    os.system(cmd)
    if not os.path.exists(build_file):
        raise Die, 'SIP failed to generate the C++ code.'

    # copy lazily to the build directory to speed up recompilation
    if not os.path.exists(build_dir):
        try:
            os.mkdir(build_dir)
        except:
            raise Die, 'Failed to create the build directory.'

    lazy_copies = 0
    for pattern in ('*.c', '*.cpp', '*.h', '*.py', '*.sbf'):
        for source in glob.glob(os.path.join(tmp_dir, pattern)):
            target = os.path.join(build_dir, os.path.basename(source))
            if lazy_copy_file(source, target):
                print 'Copy %s -> %s.' % (source, target)
                lazy_copies += 1
    print '%s file(s) lazily copied.' % lazy_copies

    makefile = sipconfig.ModuleMakefile(
        configuration=configuration,
        build_file=os.path.basename(build_file),
        dir=build_dir,
        install_dir=options.module_install_path,
        qt=1,
        warnings=1,
        debug=options.debug)

    makefile._target = '_iqt'
    makefile.extra_cflags.extend(options.extra_cflags)
    makefile.extra_cxxflags.extend(options.extra_cxxflags)
    makefile.extra_defines.extend(options.extra_defines)
    makefile.extra_include_dirs.extend(options.extra_include_dirs)
    makefile.extra_lflags.extend(options.extra_lflags)
    makefile.extra_libs.extend(options.extra_libs)
    makefile.extra_lib_dirs.extend(options.extra_lib_dirs)
    makefile.generate()
Ejemplo n.º 10
0
    build_path = os.path.join(output_dir, build_file)
    sip_file = os.path.join("sip", "PyTestObject.sip")

    command = " ".join([
        config.sip_bin, "-c", output_dir, "-b", build_path,
        "-I" + config.sip_inc_dir, "-I" + inc_dir, "-I/usr/include", "-Isip",
        "-w", "-o", sip_file
    ])
    sys.stdout.write(command + "\n")
    sys.stdout.flush()

    if os.system(command) != 0:
        sys.exit(1)

    makefile = sipconfig.ModuleMakefile(config,
                                        build_file,
                                        dir=output_dir,
                                        install_dir=dest_pkg_dir)

    makefile.extra_include_dirs += [os.path.abspath(inc_dir)]
    makefile.extra_lib_dirs += [os.path.abspath(lib_dir)]
    makefile.extra_lflags += ["-Wl,-rpath=" + os.path.abspath("src")]
    makefile.extra_libs += ["testobject"]
    makefile.generate()

    sipconfig.ParentMakefile(
        configuration=config,
        subdirs=["src", output_dir],
    ).generate()

    os.chdir("src")
    os.system("qmake")
Ejemplo n.º 11
0
def setup_qwt_build(configuration, options):
    """Setup the qwt package build
    """
    if 'qwt' not in options.packages:
        return

    print 'Setup the qwt package build.'

    build_dir = 'qwt'
    tmp_dir = 'tmp-' + build_dir
    build_file = os.path.join(tmp_dir, 'qwt.sbf')
    install_dir = os.path.join(configuration.default_mod_dir, 'qwt')
    sip_dir = os.path.join(configuration.pyqt_sip_dir, 'qwt')
    extra_sources = []
    extra_headers = []
    extra_moc_headers = []
    extra_py_files = glob.glob(os.path.join(os.pardir, 'qwt', '*.py'))

    # do we compile and link the sources of Qwt statically into PyQwt?
    if options.qwt_sources:
        extra_sources += glob.glob(
            os.path.join(options.qwt_sources, 'src', '*.cpp'))
        extra_headers += glob.glob(
            os.path.join(options.qwt_sources, 'include', '*.h'))
        extra_moc_headers = []
        for header in extra_headers:
            text = open(header).read()
            if re.compile(r'^\s*Q_OBJECT', re.M).search(text):
                extra_moc_headers.append(header)

    # add the interface to the numerical Python extensions
    extra_sources += glob.glob(os.path.join(os.pardir, 'numpy', '*.cpp'))
    extra_headers += glob.glob(os.path.join(os.pardir, 'numpy', '*.h'))

    # do we compile and link the sources of Qwt into PyQwt?
    if options.qwt_sources:
        # yes, zap all 'qwt'
        while options.extra_libs.count('qwt'):
            options.extra_libs.remove('qwt')
    elif 'qwt' not in options.extra_libs:
        # no, add 'qwt' if needed
        options.extra_libs.append('qwt')

    # zap the temporary directory
    try:
        shutil.rmtree(tmp_dir)
    except:
        pass
    # make a clean temporary directory
    try:
        os.mkdir(tmp_dir)
    except:
        raise SystemExit, 'Failed to create the temporary build directory'

    # copy the extra files
    copy_files(extra_sources, tmp_dir)
    copy_files(extra_headers, tmp_dir)
    copy_files(extra_moc_headers, tmp_dir)
    copy_files(extra_py_files, tmp_dir)

    # invoke SIP
    cmd = ' '.join(
        [
            configuration.sip_bin,
            # SIP assumes POSIX style path separators
            '-I',
            configuration.pyqt_sip_dir.replace('\\', '/'),
            '-b',
            build_file,
            '-c',
            tmp_dir,
            options.jobs,
            options.tracing,
            configuration.pyqt_qt_sip_flags,
        ] + options.sip_include_dirs + options.excluded_features +
        options.timelines
        # SIP assumes POSIX style path separators
        + [os.path.join(os.pardir, 'sip', 'qwtmod.sip').replace('\\', '/')])

    print 'sip invokation:'
    pprint.pprint(cmd)

    if os.path.exists(build_file):
        os.remove(build_file)
    os.system(cmd)
    if not os.path.exists(build_file):
        raise SystemExit, 'SIP failed to generate the C++ code.'

    # fix the SIP build file
    fix_build_file(build_file, [os.path.basename(f) for f in extra_sources],
                   [os.path.basename(f) for f in extra_headers],
                   [os.path.basename(f) for f in extra_moc_headers])

    # copy lazily to the build directory to speed up recompilation
    if not os.path.exists(build_dir):
        try:
            os.mkdir(build_dir)
        except:
            raise SystemExit, 'Failed to create the build directory'

    lazy_copies = 0
    for pattern in ('*.c', '*.cpp', '*.h', '*.py', '*.sbf'):
        for source in glob.glob(os.path.join(tmp_dir, pattern)):
            target = os.path.join(build_dir, os.path.basename(source))
            if lazy_copy_file(source, target):
                print 'Copy %s -> %s.' % (source, target)
                lazy_copies += 1
    print '%s file(s) lazily copied.' % lazy_copies

    # byte-compile the Python files
    compileall.compile_dir(build_dir, 1, install_dir)

    # files to be installed
    installs = []
    installs.append([[
        os.path.basename(f)
        for f in glob.glob(os.path.join(build_dir, '*.py*'))
    ], install_dir])
    for option in options.sip_include_dirs:
        # split and undo the POSIX style path separator
        directory = option.split()[-1].replace('/', os.sep)
        if directory.startswith(os.pardir):
            installs.append([[
                os.path.join(os.pardir, f)
                for f in glob.glob(os.path.join(directory, "*.sip"))
            ], sip_dir])

    # module makefile
    makefile = sipconfig.ModuleMakefile(
        configuration=configuration,
        build_file=os.path.basename(build_file),
        dir=build_dir,
        install_dir=install_dir,
        installs=installs,
        qt=1,
        warnings=1,
        debug=options.debug,
    )
    makefile.extra_cflags.extend(options.extra_cflags)
    makefile.extra_cxxflags.extend(options.extra_cxxflags)
    makefile.extra_defines.extend(options.extra_defines)
    makefile.extra_include_dirs.extend(options.extra_include_dirs)
    makefile.extra_lflags.extend(options.extra_lflags)
    makefile.extra_libs.extend(options.extra_libs)
    makefile.extra_lib_dirs.extend(options.extra_lib_dirs)
    if configuration.sip_version < 0x040000:
        makefile.extra_libs.insert(0, makefile.module_as_lib('qt'))
    makefile.generate()
Ejemplo n.º 12
0
def setup_iqt_build(configuration, options):
    """Setup the iqt package build
    """
    if 'iqt' not in options.packages:
        return

    print 'Setup the iqt package build.'

    build_dir = 'iqt'
    tmp_dir = 'tmp-' + build_dir
    install_dir = os.path.join(configuration.default_mod_dir, 'iqt')

    sources = (glob.glob(os.path.join(os.pardir, 'iqt', '*.cpp')) +
               glob.glob(os.path.join(os.pardir, 'iqt', '*.py')) +
               glob.glob(os.path.join(os.pardir, 'iqt', '*.sbf')))

    # zap the temporary directory
    try:
        shutil.rmtree(tmp_dir)
    except:
        pass
    # make a clean temporary directory
    try:
        os.mkdir(tmp_dir)
    except:
        raise SystemExit, 'Failed to create the temporary build directory'

    # copy all source files
    copy_files(sources, tmp_dir)

    # copy lazily to the build directory to speed up recompilation
    if not os.path.exists(build_dir):
        try:
            os.mkdir(build_dir)
        except:
            raise SystemExit, 'Failed to create the build directory'

    lazy_copies = 0
    for pattern in ('*.c', '*.cpp', '*.h', '*.py', '*.sbf'):
        for source in glob.glob(os.path.join(tmp_dir, pattern)):
            target = os.path.join(build_dir, os.path.basename(source))
            if lazy_copy_file(source, target):
                print 'Copy %s -> %s.' % (source, target)
                lazy_copies += 1
    print '%s file(s) lazily copied.' % lazy_copies

    # byte-compile the Python files
    compileall.compile_dir(build_dir, 1, install_dir)

    makefile = sipconfig.ModuleMakefile(
        configuration=configuration,
        build_file='iqt.sbf',
        dir='iqt',
        install_dir=install_dir,
        installs=[[['__init__.py', '__init__.pyc'], install_dir]],
        qt=1,
        warnings=1,
        debug=options.debug)

    makefile._target = '_iqt'
    makefile.generate()