Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: try to make haskell_genrule. #48

Draft
wants to merge 2 commits into
base: wavewave/virtual_modules
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions decls/haskell_rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
load("@prelude//linking:types.bzl", "Linkage")
load(":common.bzl", "LinkableDepType", "buck", "prelude_rule")
load(":haskell_common.bzl", "haskell_common")
load(":genrule_common.bzl", "genrule_common")
load(":native_common.bzl", "native_common")

haskell_binary = prelude_rule(
Expand Down Expand Up @@ -270,6 +271,49 @@ haskell_prebuilt_library = prelude_rule(
),
)

haskell_genrule = prelude_rule(
name = "haskell_genrule",
docs = """
A `haskell_genrule()` enables you to run shell commands as part
of the Buck build process. A `haskell_genrule()` exposes - through
a set of string parameter macros and variables - information about the
tools and configuration options used by the
Buck environment, specifically those related to the Haskell toolchain.
""",
examples = None,
further = None,
attrs = (
# @unsorted-dict-items
genrule_common.srcs_arg() |
{
"cmd": attrs.option(attrs.arg(), default = None, doc = """
Haskell genrule.

"""),
} |
genrule_common.bash_arg() |
genrule_common.cmd_exe_arg() |
genrule_common.type_arg() |
genrule_common.weight_arg() |
genrule_common.out_arg() |
genrule_common.environment_expansion_separator() |
{
#"enable_sandbox": attrs.option(attrs.bool(), default = None, doc = """
# Whether this target should be executed in a sandbox or not.
#"""),
"cacheable": attrs.option(attrs.bool(), default = None),
#"contacts": attrs.list(attrs.string(), default = []),
#"default_host_platform": attrs.option(attrs.configuration_label(), default = None),
#"default_outs": attrs.option(attrs.set(attrs.string(), sorted = False), default = None),
"labels": attrs.list(attrs.string(), default = []),
#"licenses": attrs.list(attrs.source(), default = []),
#"need_android_tools": attrs.bool(default = False),
"outs": attrs.option(attrs.dict(key = attrs.string(), value = attrs.set(attrs.string(), sorted = False), sorted = False), default = None),
#"remote": attrs.option(attrs.bool(), default = None),
}
),
)

haskell_rules = struct(
haskell_binary = haskell_binary,
haskell_ghci = haskell_ghci,
Expand All @@ -278,4 +322,5 @@ haskell_rules = struct(
haskell_library = haskell_library,
haskell_prebuilt_library = haskell_prebuilt_library,
haskell_toolchain_library = haskell_toolchain_library,
haskell_genrule = haskell_genrule,
)
6 changes: 6 additions & 0 deletions rules_impl.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ load("@prelude//haskell:haskell_ghci.bzl", "haskell_ghci_impl")
load("@prelude//haskell:haskell_haddock.bzl", "haskell_haddock_impl")
load("@prelude//haskell:haskell_ide.bzl", "haskell_ide_impl")
load("@prelude//haskell:library_info.bzl", "HaskellLibraryProvider")
load("@prelude//haskell:toolchain.bzl", "HaskellToolchainInfo")
load("@prelude//http_archive:http_archive.bzl", "http_archive_impl")
load("@prelude//java:java.bzl", _java_extra_attributes = "extra_attributes", _java_implemented_rules = "implemented_rules")
load("@prelude//js:js.bzl", _js_extra_attributes = "extra_attributes", _js_implemented_rules = "implemented_rules")
Expand Down Expand Up @@ -189,6 +190,7 @@ extra_implemented_rules = struct(
haskell_ide = haskell_ide_impl,
haskell_prebuilt_library = haskell_prebuilt_library_impl,
haskell_toolchain_library = haskell_toolchain_library_impl,
haskell_genrule = genrule_impl,

#lua
cxx_lua_extension = cxx_lua_extension_impl,
Expand Down Expand Up @@ -535,6 +537,10 @@ inlined_extra_attributes = {
"_cxx_toolchain": toolchains_common.cxx(),
"_haskell_toolchain": toolchains_common.haskell(),
},
"haskell_genrule": genrule_attributes() | {
"_cxx_toolchain": toolchains_common.cxx(),
"_haskell_toolchain": toolchains_common.haskell(),
},
"haskell_ghci": {
"template_deps": attrs.list(attrs.exec_dep(providers = [HaskellLibraryProvider]), default = []),
"_cxx_toolchain": toolchains_common.cxx(),
Expand Down