-
Notifications
You must be signed in to change notification settings - Fork 30
/
sparkle.bzl
67 lines (60 loc) · 1.92 KB
/
sparkle.bzl
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
"""Helpers for sparkle packaging."""
load("@io_tweag_clodl//clodl:clodl.bzl", "library_closure")
load("@rules_haskell//haskell:defs.bzl", "haskell_library")
def _mangle_dir(name):
"""Creates a unique directory name from the repo name and package
name of the package being evaluated, and a given name.
"""
components = [native.repository_name(), native.package_name(), name]
components = [c.replace("@", "") for c in components]
components = [c for c in components if c]
return "/".join(components).replace("_", "_U").replace("/", "_S")
def sparkle_package(name, src, resource_jars=[], **kwargs):
libclosure = "libclosure-%s" % name
libclosure_hs_wrapper = libclosure + "-hs-wrapper"
haskell_library(
name = libclosure_hs_wrapper,
srcs = ["@io_tweag_sparkle//:hs-wrapper/FFIWrapper.hs"],
deps = [src, "@io_tweag_sparkle//:base"],
compiler_flags = ["-threaded", "-flink-rts"],
)
library_closure(
name = libclosure,
srcs = [libclosure_hs_wrapper],
excludes = [
"^/System/",
"^/usr/lib/",
"ld\\.so.*",
"ld-linux\\.so.*",
"ld-linux-x86-64\\.so.*",
"libgcc_s\\.so.*",
"libc\\.so.*",
"libcrypt\\.so.*",
"libdl\\.so.*",
"libjava\\.so.*",
"libjli\\.so.*",
"libjvm\\.so.*",
"libm\\.so.*",
"libpthread\\.so.*",
"librt\\.so.*",
"libresolv\\.so.*",
"libstdc++\\.so.*",
"libutil\\.so.*",
"libz\\.so.*",
],
**kwargs
)
libclosure_renamed = libclosure + "-renamed"
native.genrule(
name = libclosure_renamed,
srcs = [libclosure],
outs = [_mangle_dir(libclosure) + "/sparkle-app.zip"],
cmd = "cp $< $@",
)
native.java_binary(
name = name,
create_executable = False,
classpath_resources = [libclosure_renamed],
resource_jars = ["@io_tweag_sparkle//:sparkle-jar"] + resource_jars,
deploy_manifest_lines = ["Main-Class: io.tweag.sparkle.SparkMain"]
)