aboutsummaryrefslogtreecommitdiffstats
path: root/lv2/lv2plug.in/ns/lv2core/wscript
blob: 3e8025984c8083385e49cd3af61b6012e39616dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/usr/bin/env python
import os

from waflib.extras import autowaf as autowaf
import waflib.Options as Options
import waflib.Context as Context
import waflib.Scripting as Scripting
import glob

# Version of this package (even if built as a child)
LV2CORE_VERSION = '6.7'

# Variables for 'waf dist'
APPNAME = 'lv2core'
VERSION = LV2CORE_VERSION

# Mandatory variables
top = '.'
out = 'build'

def options(opt):
    opt.load('compiler_c')
    autowaf.set_options(opt)
    opt.add_option('--bundle-only', action='store_true', default=False,
                   dest='bundle_only',
                   help="Only install bundle (not header or pkg-config file)")
    opt.add_option('--copy-headers', action='store_true', default=False,
                   dest='copy_headers',
                   help='Copy headers instead of linking to bundle')

def configure(conf):
    if not hasattr(os.path, 'relpath') and not Options.options.copy_headers:
        conf.fatal(
            'os.path.relpath missing, get Python 2.6 or use --copy-headers')

    conf.load('compiler_c')
    autowaf.configure(conf)

    autowaf.display_msg(conf, "LV2 bundle directory", conf.env['LV2DIR'])
    print('')

def news(ctx):
    path = ctx.path.abspath()
    autowaf.write_news(APPNAME,
                       glob.glob(os.path.join(path, '*.ttl')),
                       os.path.join(path, 'NEWS'))

def build(bld):
    # Header "library"
    obj = bld(export_includes = ['.'],
              name            = 'liblv2core',
              target          = 'lv2core')

    # Bundle (data)
    bld.install_files('${LV2DIR}/lv2core.lv2', bld.path.ant_glob('*.ttl'))

    if not Options.options.bundle_only:
        # Header
        bld.install_files('${INCLUDEDIR}', 'lv2.h')
        bld.install_files('${LV2DIR}/lv2core.lv2', 'lv2.h')

        # Pkgconfig file
        autowaf.build_pc(bld, 'LV2CORE', LV2CORE_VERSION, '', [])

        # URI-like header include
        include_dir = os.path.join(bld.env['INCLUDEDIR'], 'lv2/lv2plug.in/ns')
        bundle_dir  = os.path.join(bld.env['LV2DIR'], 'lv2core.lv2')
        if bld.env['COPY_HEADERS']:
            bld.install_files(os.path.join(include_dir, 'lv2core'),
                              bld.path.ant_glob('*.h'))
        else:
            bld.symlink_as(os.path.join(include_dir, 'lv2core'),
                           os.path.relpath(bundle_dir, include_dir))

class Dist(Scripting.Dist):
    def execute(self):
        "Execute but do not call archive() since dist() has already done so."
        self.recurse([os.path.dirname(Context.g_module.root_path)])

    def get_tar_path(self, node):
        "Resolve symbolic links to avoid broken links in tarball."
        return os.path.realpath(node.abspath())

class DistCheck(Dist, Scripting.DistCheck):
    def execute(self):
        Dist.execute(self)
        self.check()
    
    def archive(self):
        Dist.archive(self)

def pre_dist(ctx):
    # Write NEWS file in source directory
    news(ctx)

def dist(ctx):
    pre_dist(ctx)
    ctx.archive()
    post_dist(ctx)

def distcheck(ctx):
    dist(ctx)

def post_dist(ctx):
    # Delete generated NEWS file
    try:
        os.remove(os.path.join(ctx.path.abspath(), 'NEWS'))
    except:
        pass