aboutsummaryrefslogtreecommitdiffstats
path: root/build/plugins/lj_archive.py
blob: 9f071f3d87f2613d5c5305e8a3c4467b477d8604 (plain) (blame)
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
def onlj_archive(unit, *args):
    """
    @usage: LJ_ARCHIVE(NAME Name LuaFiles...)
    Precompile .lua files using LuaJIT and archive both sources and results using sources names as keys
    """

    def iter_luas(l):
        for a in l:
            if a.endswith('.lua'):
                yield a

    def iter_objs(l):
        for a in l:
            s = a[:-3] + 'raw'
            unit.on_luajit_objdump(['OUT', s, a])
            yield s

    luas = list(iter_luas(args))
    objs = list(iter_objs(luas))

    unit.onarchive_by_keys(['DONTCOMPRESS', 'NAME', 'LuaScripts.inc', 'KEYS', ':'.join(luas)] + objs)
    unit.onarchive_by_keys(['DONTCOMPRESS', 'NAME', 'LuaSources.inc', 'KEYS', ':'.join(luas)] + luas)


def onlj_21_archive(unit, *args):
    """
    @usage: LJ_21_ARCHIVE(NAME Name LuaFiles...) # deprecated
    Precompile .lua files using LuaJIT 2.1 and archive both sources and results using sources names as keys
    """

    def iter_luas(l):
        for a in l:
            if a.endswith('.lua'):
                yield a

    def iter_objs(l):
        for a in l:
            s = a[:-3] + 'raw'
            unit.on_luajit_21_objdump(['OUT', s, a])
            yield s

    luas = list(iter_luas(args))
    objs = list(iter_objs(luas))

    unit.onarchive_by_keys(['DONTCOMPRESS', 'NAME', 'LuaScripts.inc', 'KEYS', ':'.join(luas)] + objs)
    unit.onarchive_by_keys(['DONTCOMPRESS', 'NAME', 'LuaSources.inc', 'KEYS', ':'.join(luas)] + luas)