[935f5c]: trunk / src / gx_head / wscript Maximize Restore History

Download this file

wscript    170 lines (159 with data), 6.5 kB

#! /usr/bin/env python
# encoding: utf-8

import sys, wscript_helper
import Task, Utils, Options, Logs, os, shutil
from TaskGen import extension

def set_options(opt):
    guitarix_prog = opt.add_option_group("Guitarix Program Options")
    guitarix_prog.add_option(
        '--no-avahi', action='store_const', default=False, const=True,
        help=('Do not build with avahi support for automatic discovery of'
              ' / connection to Guitarix server instances  [Default: no]'))

def configure(conf):
    if not Options.options.no_avahi:
        conf.check_cfg(package='avahi-gobject', args='--cflags --libs', uselib_store='AVAHI_GOBJECT', mandatory=1)
        conf.check_cfg(package='avahi-glib', args='--cflags --libs', uselib_store='AVAHI_GLIB', mandatory=1)
        conf.check_cfg(package='avahi-client', args='--cflags --libs', uselib_store='AVAHI_CLIENT', mandatory=1)
        conf.define("HAVE_AVAHI", 1)
    conf.check_cfg(package='bluez', args='--cflags --libs', uselib_store='BLUEZ', mandatory=0)

def gperf2cc(task):
    out_c = task.outputs[0].bldpath(task.env)
    out_h = task.outputs[1].bldpath(task.env)
    basename = os.path.splitext(
        os.path.basename(task.inputs[0].srcpath(task.env)))[0]
    srcdir = task.inputs[0].parent.srcpath(task.env)
    if task.env["HAVE_GPERF"]:
        cmd = [task.proc,
               task.inputs[0].srcpath(task.env),
               out_c,
               out_h,
               ]
        Logs.debug("runner: system command -> %s" % cmd)
        ret = Utils.exec_command(cmd, shell=False)
        shutil.copy2(out_c, os.path.join(srcdir, basename+"-generated.cc"))
        shutil.copy2(out_h, os.path.join(srcdir, basename+"-generated.h"))
        return ret
    else:
        shutil.copy2(os.path.join(srcdir, basename+"-generated.cc"), out_c)
        shutil.copy2(os.path.join(srcdir, basename+"-generated.h"), out_h)
        return 0

Task.task_type_from_func(
    'gperf',
    gperf2cc,
    color='BLUE',
    before='cc cxx',
    )

@extension('.gperf_tmpl')
def process_gperf_tmpl(self, node):
    cc_node = node.change_ext('.cc')
    h_node = node.change_ext('.h')
    task = self.create_task('gperf', [node], [cc_node, h_node])
    task.proc = "../tools/make_jsonrpc_methods"
    self.bld.add_manual_dependency(node,self.bld.bldnode.find_resource(task.proc))

def build(bld):
    sources_engine = [
        './engine/gx_logging.cpp',
        './engine/gx_pluginloader.cpp',
        './engine/ladspaplugin.cpp',
        './engine/ladspaback.cpp',
        './engine/tunerswitcher.cpp',
        './engine/jsonrpc.cpp',
        './engine/gx_jack.cpp',
        './engine/gx_preset.cpp',
        './engine/gx_json.cpp',
        './engine/gx_faust_plugins.cpp',
        './engine/gx_internal_plugins.cpp',
        './engine/gx_internal_ui_plugins.cpp',
        './engine/gx_midi_plugin.cpp',
        './engine/gx_engine_audio.cpp',
        './engine/gx_paramtable.cpp',
        './engine/gx_pitch_tracker.cpp',
        './engine/gx_convolver.cpp',
        './engine/gx_resampler.cpp',
        './engine/gx_system.cpp',
        './engine/gx_engine.cpp',
        './engine/gx_engine_midi.cpp',
        './engine/jsonrpc_methods.gperf_tmpl',
        ]

    sources_gui = [
        './gui/machine.cpp',
        './gui/ladspalist.cpp',
        './gui/gx_stackbox_builder.cpp',
        './gui/gx_main_window.cpp',
        './gui/liveplay.cpp',
        './gui/rack.cpp',
        './gui/gx_preset_window.cpp',
        './gui/gx_jack_options.cpp',
        './gui/gx_ui_builder.cpp',
        './gui/gx_gui_helpers.cpp',
        './gui/gx_child_process.cpp',
        './gui/gx_main_midi.cpp',
        './gui/gx_jconv_settings.cpp',
        './gui/gxw_mm_controllers.cpp',
        './gui/gx_main_boxes.cpp',
        './gui/gx_mono_rack_builder.cpp',
        './gui/gx_stereo_rack_builder.cpp',
        './gui/gx_cairo_callbacks.cpp',
        './gui/gx_portmap.cpp',
        './gui/gx_main.cpp',
        ]

    builder_files = [
        './builder/midi.glade',
        './builder/ports.glade',
        './builder/iredit.glade',
        './builder/iredit_mono.glade',
        './builder/jackstarter.glade',
        './builder/mainpanel.glade',
        './builder/ladspaliste.glade',
        './builder/crybaby_ui.glade',
        './builder/gx_distortion_ui.glade',
        './builder/amp.tonestack_ui.glade',
        './builder/tremolo_ui.glade',
        './builder/pluginpreset_inputwindow.glade',
        './builder/pluginpreset_listwindow.glade',
        './builder/selectinstance.glade',
        './builder/menudef.xml',
        './builder/accels_rc',
        ]

    if bld.env["HAVE_AVAHI"]:
        sources_gui.append("gui/avahi_discover.cpp")
        sources_engine.append("engine/avahi_register.cpp")
    sources = sources_engine + sources_gui
    incl = ['.','./engine','../..','..','../headers','../../libgxwmm','../../libgxw'] # need ".." for config.h
    libpath = []
    lib = []
    if sys.platform.startswith("linux"):
        lib.append('dl')
    uselib = ['JACK', 'SNDFILE', 'GTHREAD', 'GMODULE_EXPORT',
              'GTK2', 'GTKMM', 'GIOMM', 'FFTW3', 'LRDF', 'LILV', 'BOOST_SYSTEM']
    if bld.env["HAVE_AVAHI"]:
        uselib += ['AVAHI_GOBJECT', 'AVAHI_GLIB', 'AVAHI_CLIENT']
    uselib.append('BLUEZ')
    uselib_local = []
    wscript_helper.add_zita_convolver(bld, uselib, sources, incl)
    wscript_helper.add_zita_resampler(bld, uselib, sources, incl)
    if bld.env["HAVE_PLUGINLIB"]:
        uselib_local += ["plugins"]
    if bld.env["GX_LIB_SHARED"]:
        lib += ['gxwmm','gxw']
        libpath += [bld.path.find_dir("../../libgxw/gxw").bldpath(bld.env),
                    bld.path.find_dir("../../libgxwmm/gxwmm").bldpath(bld.env)]
    else:
        uselib_local += ['gxwmm','gxw']
    ldscript = bld.path.find_resource('guitarix.lds')
    mapfile = bld.path.find_or_declare("guitarix.map")
    task = bld(features = 'cxx cprogram',
        includes = incl,
        obj_ext  = '.o',
        source = sources,
        lib = lib,
        uselib = uselib,
        uselib_local = uselib_local,
        libpath = libpath,
        target = bld.env['BIN_NAME'],
        chmod = 0o755,
        install_path = bld.env['BINDIR'],
        ldflags = ['-Wl,%s,-Map=%s' % (ldscript.srcpath(),mapfile.bldpath(bld.env))],
        )
    bld.add_manual_dependency(bld.path.find_or_declare(task.target), ldscript)
    bld.install_files(bld.env['GX_BUILDER_DIR'], builder_files, chmod=0o644)