summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: ec28c22595b7b8278816c90c7a843f0d51ec8e87 (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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
# Maintainer: Rod Kay <rodakay5 at gmail dot com>

## Note:
#   This package will not build correctly if it is already installed.
#   Remove it first with:
#
#       sudo pacman -Rc langkit
#

pkgname=langkit
pkgdesc='Compiler for syntactic and semantic language analysis libraries'
pkgver=27.0w
pkgrel=1
epoch=1

url='https://github.com/AdaCore/langkit'
arch=(i686 x86_64)
license=(Apache-2.0)


depends=(
    adasat
    gnatcoll-gmp
    gnatcoll-iconv
    ocaml-ctypes
    ocaml-zarith
    prettier-ada
    python
)

makedepends=(
    dune
    gprbuild
    python-pip
    python-coverage
    python-docutils
    python-e3-core
#    python-e3-testsuite
    python-funcy
    python-mako
    python-pexpect
    python-pycodestyle
    python-pygments
    python-ptyprocess
    python-railroad-diagrams
    python-sphinx
    texlive-bin
)


_langkit_src="${pkgname}-${pkgver}-20260324-164EA-src"
_adasat_src="adasat-${pkgver}-20260324-1629D-src"


source=(
    'https://github.com/charlie5/archlinux-gnatstudio-support/raw/refs/heads/main/gnatstudio-sources-2026/langkit-src.tar.gz'
    'https://github.com/charlie5/archlinux-gnatstudio-support/raw/refs/heads/main/gnatstudio-sources-2026/adasat-src.tar.gz'
)

sha256sums=(
    '1d9fd350c1aa3fa61cfa17bade0e6e0fbee7a7ad737676ba8ad5f0b6d759bc65'
    'f9576c214c980680dc4ef13375b464679679e0de5e3d9770b8e0c2f32d84576f'
)


prepare()
{
    cd "$srcdir/$_langkit_src"


    ## Use the AdaSAT source tree from the second tarball.
    #
    ln -sfn "$srcdir/$_adasat_src" langkit/adasat
}


build()
{
    cd "$srcdir/$_langkit_src"


    ## Strip GCC warning flags that GNAT does not understand.
    #
    local ada_flags="$CFLAGS"
    ada_flags="${ada_flags//-Wformat/}"
    ada_flags="${ada_flags//-Werror=format-security/}"


    ## Build the Langkit_Support library used by all generated libraries.
    #
    python manage.py build-langkit-support \
        --library-types=static,static-pic,relocatable \
        --build-mode=prod \
        --gargs="-R -cargs $ada_flags -largs $LDFLAGS -gargs"


    ## Build Langkit itself.
    #
    python manage.py make \
        --no-mypy \
        --library-types=static,static-pic,relocatable


    ## Build the OCaml bindings.
    #
    dune build --root=lkt/build/ocaml


    ## Build the documentation.
    #
    make -C doc html
}


package()
{
    cd "$srcdir/$_langkit_src"


    local python_site
    python_site=$(python -c 'import site; print(site.getsitepackages()[0])')


    ## Install Langkit_Support.
    #
    python manage.py install-langkit-support \
        --library-types=static,static-pic,relocatable \
        --build-mode=prod \
        "$pkgdir/usr"


    ## Install liblktlang.
    #
    python -m langkit.scripts.lkm install \
           -c lkt/langkit.yaml \
           "$pkgdir/usr" \
           --library-types=static,static-pic,relocatable \
           --disable-all-mains


    ## Move Python modules into site-packages.
    #
    install -d "$pkgdir$python_site"
    mv "$pkgdir/usr/python/liblktlang" "$pkgdir$python_site/"
    rm -rf "$pkgdir/usr/python"


    ## Install the langkit Python package itself.
    #
    pip install              \
        --root="$pkgdir"     \
        --prefix=/usr        \
        --no-deps            \
        --no-build-isolation \
        --ignore-installed   \
        .
    
    
    ## Install Java bindings source and JNI support files.
    #
    install -Dm644 \
        "$pkgdir/usr/java/src/main/java/com/adacore/liblktlang/Liblktlang.java" \
        "$pkgdir/usr/share/langkit/java/com/adacore/liblktlang/Liblktlang.java"

    install -Dm644 \
        "$pkgdir/usr/java/pom.xml" \
        "$pkgdir/usr/share/langkit/java/pom.xml"

    install -Dm644 \
        "$pkgdir/usr/java/jni/jni_impl.c" \
        "$pkgdir/usr/share/langkit/java/jni/jni_impl.c"

    rm -rf "$pkgdir/usr/java"


    ## Install the OCaml bindings.
    #
    dune install \
        --root=lkt/build/ocaml \
        --prefix="$pkgdir/usr" \
        --libdir="$pkgdir/usr/lib/ocaml"

    rm -rf "$pkgdir/usr/ocaml"


    ## Remove the empty Windows-specific directory, if present.
    #
    rmdir --ignore-fail-on-non-empty "$pkgdir/usr/lib/windows"


    ## Install the license.
    #
    install -Dm644 \
        LICENSE.txt \
        "$pkgdir/usr/share/licenses/$pkgname/LICENSE.txt"


    ## Install the generated HTML documentation.
    #
    find doc/_build/html -type f | while read -r file; do
        install -Dm644 "$file" "$pkgdir/usr/share/doc/$pkgname/${file#doc/_build/html/}"
    done
}