forked from digital-asset/daml
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBUILD.bazel
416 lines (370 loc) · 13.2 KB
/
BUILD.bazel
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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
# Copyright (c) 2019 The DAML Authors. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary")
load("@os_info//:os_info.bzl", "is_linux", "is_windows")
load("//rules_daml:daml.bzl", "daml_test")
load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar")
nodejs_binary(
name = "grunt",
data = [
"@npm//grunt-cli",
"@npm//matchdep",
],
entry_point = "@npm//:node_modules/grunt-cli/bin/grunt",
)
genrule(
name = "theme",
srcs = glob(
["theme/**"],
exclude = [
"theme/bower_components/**",
"theme/node_modules/**",
"theme/da_theme/**",
],
) + [
"@npm//browserify",
"@npm//grunt-banner",
"@npm//grunt-browserify",
"@npm//grunt-contrib-clean",
"@npm//grunt-contrib-connect",
"@npm//grunt-contrib-copy",
"@npm//grunt-contrib-sass",
"@npm//grunt-contrib-uglify",
"@npm//grunt-contrib-watch",
"@npm//grunt-exec",
"@npm//grunt-open",
"@npm//matchdep",
],
outs = ["da_theme.tar.gz"],
cmd = """
cp -rL docs/theme theme
cd theme
# Make the node_modules available
ln -s ../external/npm/node_modules .
# Run sass and grunt
../$(location @sass_nix//:bin/sass) \
-I bower_components_static/bourbon/dist \
-I bower_components_static/neat/app/assets/stylesheets \
-I bower_components_static/font-awesome/scss \
-I bower_components_static/wyrm/sass \
--style compressed \
--sourcemap=none \
--update \
sass:da_theme/static/css
../$(location :grunt) build
tar \
--owner=1000 \
--group=1000 \
--mtime=1337 \
--no-acls \
--no-xattrs \
--no-selinux \
--sort=name \
-czf ../$(location da_theme.tar.gz) \
da_theme
""",
tools = [
":grunt",
"@sass_nix//:bin/sass",
],
) if not is_windows else None
genrule(
name = "sources",
srcs = glob(["source/**"]) + [
"//compiler/damlc:daml-base-rst-docs",
"//triggers/daml:daml-trigger-rst-docs",
"//ledger-api/grpc-definitions:docs",
"//:LICENSE",
"//:NOTICES",
],
outs = ["source.tar.gz"],
cmd = """
cp -rL docs/source source
# Copy in Stdlib
cp -rL $(location //compiler/damlc:daml-base-rst-docs) source/daml/reference/base.rst
# Copy in daml-trigger documentation
cp -rL $(location //triggers/daml:daml-trigger-rst-docs) source/triggers/trigger-docs.rst
# Copy in Protobufs
cp -rL $(location //ledger-api/grpc-definitions:docs) source/app-dev/grpc/proto-docs.rst
# Copy in License and Notices
cp -L $(location //:LICENSE) source/LICENSE
cp -L $(location //:NOTICES) source/NOTICES
tar -zcf $(location source.tar.gz) source
""",
)
genrule(
name = "pdf-docs",
srcs = glob([
"configs/pdf/**",
"configs/static/pygments_daml_lexer.py",
]) + [
":sources",
],
outs = ["DigitalAssetSDK.pdf"],
cmd = ("""
export LOCALE_ARCHIVE="$$PWD/$(location @glibc_locales//:locale-archive)"
""" if is_linux else "") + """
set -euo pipefail
# Set up tools
export PATH="$$( cd "$$(dirname "$(location @imagemagick_nix//:bin/convert)")" ; pwd -P )":$$PATH
# Copy files into the right structure and remove symlinks
tar -zxf $(location sources) -C .
cp -L docs/configs/pdf/index.rst source/
cp -L docs/configs/pdf/conf.py source/
cp -L docs/configs/pdf/logo.png source/
cp -rL docs/configs/static ./
# Build with Sphinx
DATE=$$(date +"%Y-%m-%d")
sed -i "s,__VERSION__,"$$DATE"," source/conf.py
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
$(location @sphinx_nix//:bin/sphinx-build) -b latex source out
# Copy in fonts and build with lualatex
cp -L docs/configs/pdf/fonts/* out/
cd out
# run twice to generate all references properly (this is a latex thing...)
../$(location @texlive_nix//:bin/lualatex) -halt-on-error -interaction=batchmode --shell-escape *.tex
../$(location @texlive_nix//:bin/lualatex) -halt-on-error -interaction=batchmode --shell-escape *.tex
# Move output to target
mv DigitalAssetSDK.pdf ../$(location DigitalAssetSDK.pdf)""",
tools =
[
"@texlive_nix//:bin/lualatex",
"@sphinx_nix//:bin/sphinx-build",
"@imagemagick_nix//:bin/convert",
] + (["@glibc_locales//:locale-archive"] if is_linux else []),
) if not is_windows else None
genrule(
name = "docs-no-pdf",
srcs = glob([
"configs/html/**",
"configs/static/pygments_daml_lexer.py",
]) + [
":sources",
":theme",
"//compiler/damlc:daml-base-rst-docs",
"//compiler/damlc:daml-base-hoogle-docs",
"//language-support/java:javadoc",
],
outs = ["html-only.tar.gz"],
cmd = ("""
export LOCALE_ARCHIVE="$$PWD/$(location @glibc_locales//:locale-archive)"
""" if is_linux else "") + """
# Copy files into the right structure and remove symlinks
mkdir build
cp -rL docs build
tar -zxf $(location sources) -C build/docs
# Copy in theme
mkdir -p build/docs/theme
tar -zxf $(location :theme) -C build/docs/theme
# Build with Sphinx
cd build
DATE=$$(date +"%Y-%m-%d")
sed -i "s,__VERSION__,"$$DATE"," docs/configs/html/conf.py
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
WARNINGS=$$(../$(location @sphinx_nix//:bin/sphinx-build) -c docs/configs/html docs/source html 2>&1 | \
grep -Ei "warning:" || true)
if [ "$$WARNINGS" != "" ]; then
echo "$$WARNINGS"
exit 1
fi
# Copy Javadoc using unzip to avoid having to know the path to the 'jar' binary. Note flag to overwrite
unzip -o ../$(locations //language-support/java:javadoc) -d html/app-dev/bindings-java/javadocs
# Copy in hoogle DB
mkdir -p html/hoogle_db
cp -rL ../$(location //compiler/damlc:daml-base-hoogle-docs) html/hoogle_db/base.txt
tar -zcf ../$(location html-only.tar.gz) html
""",
tools =
["@sphinx_nix//:bin/sphinx-build"] +
(["@glibc_locales//:locale-archive"] if is_linux else []),
) if not is_windows else None
genrule(
name = "redirects",
srcs = [
"redirects.map",
"redirect_template.html",
],
outs = ["redirects.tar.gz"],
cmd = """
mkdir redirects
while read l; do
from=$$(awk -F' -> ' '{print $$1}' <<<$$l)
to=$$(awk -F' -> ' '{print $$2}' <<<"$$l")
if [ $$to ]
then
mkdir -p redirects/$$(dirname $$from)
cp -L docs/redirect_template.html redirects/$$from
sed -i -e "s,__URL__,$${to}," redirects/$$from
fi
done <docs/redirects.map
tar -zcf $(location redirects.tar.gz) redirects
""",
)
genrule(
name = "docs",
srcs = [
":docs-no-pdf",
":pdf-docs",
":redirects",
"error.html",
],
outs = ["html.tar.gz"],
cmd = """
tar -zxf $(location :redirects)
tar -zxf $(location :docs-no-pdf)
cp -rn redirects/* html
cp -L docs/error.html html
cd html
find . -name '*.html' | sed -e 's,^\\./,https://docs.daml.com/,' > sitemap
SMHEAD=\"{}\"
SMITEM=\"{}\"
SMFOOT=\"{}\"
DATE=$$(date +"%Y-%m-%d")
echo $$SMHEAD > sitemap.xml
while read item; do
echo $$SMITEM | sed -e "s,%DATE%,$${{DATE}}," | sed -e "s,%LOC%,$${{item}}," >> sitemap.xml
done < sitemap
echo $$SMFOOT >> sitemap.xml
echo {{ \\"$$DATE\\" : \\"$$DATE\\" }} > versions.json
cd ..
cp -L $(location :pdf-docs) html/_downloads
tar -zcf $(location html.tar.gz) html
""".format(
"""<?xml version='1.0' encoding='UTF-8'?><urlset xmlns='http://www.sitemaps.org/schemas/sitemap/0.9' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd'>""",
"""<url><loc>%LOC%</loc><lastmod>%DATE%</lastmod><changefreq>daily</changefreq><priority>0.8</priority></url>""",
"""</urlset>""",
),
) if not is_windows else None
filegroup(
name = "daml-assistant-iou-setup",
srcs = glob(
["source/getting-started/quickstart/template-root/*"],
# excluding quickstart-java stuff and da-skeleton.yaml (which should be removed once DA Assistant is gone)
exclude = [
"source/getting-started/quickstart/template-root/src",
"source/getting-started/quickstart/template-root/pom.xml",
"source/getting-started/quickstart/template-root/da-skeleton.yaml",
],
exclude_directories = 0,
),
visibility = ["//visibility:public"],
)
genrule(
name = "quickstart-java",
srcs = ["//:component-version"] + glob(["source/getting-started/quickstart/template-root/**"]),
outs = ["quickstart-java.tar.gz"],
cmd = """
mkdir -p quickstart-java
cp -rL docs/source/getting-started/quickstart/template-root/* quickstart-java/
VERSION=$$(cat $(location //:component-version))
sed -i "s/__VERSION__/$$VERSION/" quickstart-java/pom.xml
tar zcf $@ quickstart-java
""",
visibility = ["//visibility:public"],
)
load("//rules_daml:daml.bzl", "daml_compile")
load("//language-support/java/codegen:codegen.bzl", "dar_to_java")
daml_compile(
name = "quickstart-model",
srcs = glob(["source/getting-started/quickstart/template-root/**/*.daml"]),
main_src = "source/getting-started/quickstart/template-root/daml/Main.daml",
visibility = [
"//language-support/scala/examples:__subpackages__",
"//ledger-service:__subpackages__",
],
)
dar_to_java(
name = "quickstart-model",
src = "quickstart-model.dar",
package_prefix = "com.digitalasset.quickstart.model",
)
java_binary(
name = "quickstart-java-lib",
srcs = glob(["source/getting-started/quickstart/template-root/src/main/java/**/*.java"]) + [":quickstart-model-srcjar"],
main_class = "com.digitalasset.quickstart.iou.IouMain",
deps = [
"//daml-lf/archive:daml_lf_dev_archive_java_proto",
"//language-support/java/bindings:bindings-java",
"//language-support/java/bindings-rxjava",
"@maven//:ch_qos_logback_logback_classic",
"@maven//:com_google_code_gson_gson",
"@maven//:com_google_guava_guava",
"@maven//:com_google_protobuf_protobuf_java",
"@maven//:com_sparkjava_spark_core",
"@maven//:io_reactivex_rxjava2_rxjava",
"@maven//:org_slf4j_slf4j_api",
],
)
daml_test(
name = "ledger-api-daml-test",
srcs = glob(["source/app-dev/code-snippets/**/*.daml"]),
)
daml_test(
name = "bindings-java-daml-test",
srcs = glob(["source/app-dev/bindings-java/code-snippets/**/*.daml"]),
)
daml_test(
name = "patterns-daml-test",
srcs = glob(["source/daml/patterns/daml/**/*.daml"]),
)
daml_test(
name = "daml-studio-daml-test",
srcs = glob(["source/daml/daml-studio/daml/**/*.daml"]),
)
daml_test(
name = "daml-ref-daml-test",
timeout = "long",
srcs = glob(["source/daml/code-snippets/**/*.daml"]),
)
daml_test(
name = "introduction-daml-test",
srcs = glob(["source/getting-started/introduction/code/**/*.daml"]),
)
daml_test(
name = "quickstart-daml-test",
srcs = glob(["source/getting-started/quickstart/template-root/daml/**/*.daml"]),
)
daml_test(
name = "ledger-model-daml-test",
srcs = glob(["source/concepts/ledger-model/daml/**/*.daml"]),
)
daml_test(
name = "java-bindings-docs-daml-test",
srcs = glob(["source/app-dev/bindings-java/daml/**/*.daml"]),
)
daml_test(
name = "daml-intro-daml-test",
srcs = glob(["source/daml/intro/daml/**/*.daml"]),
)
filegroup(
name = "daml-intro-1",
srcs = glob(
["source/daml/intro/daml/1_Token/**/*"],
# excluding quickstart-java stuff and da-skeleton.yaml (which should be removed once DA Assistant is gone)
exclude = [
"source/getting-started/quickstart/template-root/src",
"source/getting-started/quickstart/template-root/pom.xml",
"source/getting-started/quickstart/template-root/da-skeleton.yaml",
],
exclude_directories = 0,
),
visibility = ["//visibility:public"],
)
pkg_tar(
name = "daml-intro-templates",
srcs = glob(["source/daml/intro/daml/**"]),
strip_prefix = "source/daml/intro/daml",
visibility = ["//visibility:public"],
)
pkg_tar(
name = "copy-trigger-template",
srcs = glob(
["source/triggers/template-root/**"],
exclude = ["**/*~"],
),
strip_prefix = "source/triggers/template-root",
visibility = ["//visibility:public"],
)
exports_files(["source/triggers/template-root/src/CopyTrigger.daml"])