summaryrefslogtreecommitdiffstats
path: root/src/fluent-bit/lib/librdkafka-2.1.0/packaging/nuget/staticpackage.py
blob: 38567bb609194d5f5669ed4371ff0cb9ae98176b (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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#!/usr/bin/env python3
#
# Create self-contained static-library tar-ball package
#

import os
import tempfile
import shutil
import subprocess
from packaging import Package, Mapping


class StaticPackage (Package):
    """ Create a tar-ball with self-contained static libraries.
        These are later imported into confluent-kafka-go. """

    # Make sure gssapi (cyrus-sasl) is not linked, since that is a
    # dynamic linkage, by specifying negative match '!extra': 'gssapi'.
    # Except for on OSX where cyrus-sasl is always available, and
    # Windows where it is never linked.
    #
    # Match statically linked artifacts (which are included in 'all' builds)
    mappings = [
        Mapping({'arch': 'x64',
                 'plat': 'linux',
                 'dist': 'centos6',
                 '!extra': 'gssapi'},
                'librdkafka.tgz',
                './usr/local/include/librdkafka/rdkafka.h',
                'rdkafka.h'),
        Mapping({'arch': 'x64',
                 'plat': 'linux',
                 'dist': 'centos6',
                 '!extra': 'gssapi'},
                'librdkafka.tgz',
                './usr/local/share/doc/librdkafka/LICENSES.txt',
                'LICENSES.txt'),

        # glibc linux static lib and pkg-config file
        Mapping({'arch': 'x64',
                 'plat': 'linux',
                 'dist': 'centos6',
                 'lnk': 'all',
                 '!extra': 'gssapi'},
                'librdkafka.tgz',
                './usr/local/lib/librdkafka-static.a',
                'librdkafka_glibc_linux_amd64.a'),
        Mapping({'arch': 'x64',
                 'plat': 'linux',
                 'dist': 'centos6',
                 'lnk': 'all',
                 '!extra': 'gssapi'},
                'librdkafka.tgz',
                './usr/local/lib/pkgconfig/rdkafka-static.pc',
                'librdkafka_glibc_linux_amd64.pc'),

        # glibc linux arm64 static lib and pkg-config file
        Mapping({'arch': 'arm64',
                 'plat': 'linux',
                 'dist': 'centos7',
                 'lnk': 'all',
                 '!extra': 'gssapi'},
                'librdkafka.tgz',
                './usr/local/lib/librdkafka-static.a',
                'librdkafka_glibc_linux_arm64.a'),
        Mapping({'arch': 'arm64',
                 'plat': 'linux',
                 'dist': 'centos7',
                 'lnk': 'all',
                 '!extra': 'gssapi'},
                'librdkafka.tgz',
                './usr/local/lib/pkgconfig/rdkafka-static.pc',
                'librdkafka_glibc_linux_arm64.pc'),

        # musl linux static lib and pkg-config file
        Mapping({'arch': 'x64',
                 'plat': 'linux',
                 'dist': 'alpine',
                 'lnk': 'all',
                 '!extra': 'gssapi'},
                'librdkafka.tgz',
                './usr/local/lib/librdkafka-static.a',
                'librdkafka_musl_linux_amd64.a'),
        Mapping({'arch': 'x64',
                 'plat': 'linux',
                 'dist': 'alpine',
                 'lnk': 'all',
                 '!extra': 'gssapi'},
                'librdkafka.tgz',
                './usr/local/lib/pkgconfig/rdkafka-static.pc',
                'librdkafka_musl_linux_amd64.pc'),

        # musl linux arm64 static lib and pkg-config file
        Mapping({'arch': 'arm64',
                 'plat': 'linux',
                 'dist': 'alpine',
                 'lnk': 'all',
                 '!extra': 'gssapi'},
                'librdkafka.tgz',
                './usr/local/lib/librdkafka-static.a',
                'librdkafka_musl_linux_arm64.a'),
        Mapping({'arch': 'arm64',
                 'plat': 'linux',
                 'dist': 'alpine',
                 'lnk': 'all',
                 '!extra': 'gssapi'},
                'librdkafka.tgz',
                './usr/local/lib/pkgconfig/rdkafka-static.pc',
                'librdkafka_musl_linux_arm64.pc'),

        # osx x64 static lib and pkg-config file
        Mapping({'arch': 'x64',
                 'plat': 'osx',
                 'lnk': 'all'},
                'librdkafka.tgz',
                './usr/local/lib/librdkafka-static.a',
                'librdkafka_darwin_amd64.a'),
        Mapping({'arch': 'x64',
                 'plat': 'osx',
                 'lnk': 'all'},
                'librdkafka.tgz',
                './usr/local/lib/pkgconfig/rdkafka-static.pc',
                'librdkafka_darwin_amd64.pc'),

        # osx arm64 static lib and pkg-config file
        Mapping({'arch': 'arm64',
                 'plat': 'osx',
                 'lnk': 'all'},
                'librdkafka.tgz',
                './usr/local/lib/librdkafka-static.a',
                'librdkafka_darwin_arm64.a'),
        Mapping({'arch': 'arm64',
                 'plat': 'osx',
                 'lnk': 'all'},
                'librdkafka.tgz',
                './usr/local/lib/pkgconfig/rdkafka-static.pc',
                'librdkafka_darwin_arm64.pc'),

        # win static lib and pkg-config file (mingw)
        Mapping({'arch': 'x64',
                 'plat': 'win',
                 'dist': 'mingw',
                 'lnk': 'static'},
                'librdkafka.tgz',
                './lib/librdkafka-static.a', 'librdkafka_windows.a'),
        Mapping({'arch': 'x64',
                 'plat': 'win',
                 'dist': 'mingw',
                 'lnk': 'static'},
                'librdkafka.tgz',
                './lib/pkgconfig/rdkafka-static.pc',
                'librdkafka_windows.pc'),
    ]

    def __init__(self, version, arts):
        super(StaticPackage, self).__init__(version, arts)

    def cleanup(self):
        if os.path.isdir(self.stpath):
            shutil.rmtree(self.stpath)

    def build(self, buildtype):
        """ Build single package for all artifacts. """

        self.stpath = tempfile.mkdtemp(prefix="out-", dir=".")

        self.apply_mappings()

        print('Tree extracted to %s' % self.stpath)

        # After creating a bare-bone layout, create a tarball.
        outname = "librdkafka-static-bundle-%s.tgz" % self.version
        print('Writing to %s in %s' % (outname, self.stpath))
        subprocess.check_call("(cd %s && tar cvzf ../%s .)" %
                              (self.stpath, outname),
                              shell=True)

        return outname