aboutsummaryrefslogtreecommitdiff
path: root/cobol/internal/rules.bzl
diff options
context:
space:
mode:
authorFuwn <[email protected]>2022-05-22 04:21:33 -0700
committerFuwn <[email protected]>2022-05-22 04:21:33 -0700
commit16cb282ad266674de090cc5c6439944e242074c5 (patch)
treee067967f45c880053fe3063642f0167689c32ddf /cobol/internal/rules.bzl
downloadrules_cobol-main.tar.xz
rules_cobol-main.zip
feat(0.1.0): initial releaseHEAD0.1.0main
Diffstat (limited to 'cobol/internal/rules.bzl')
-rw-r--r--cobol/internal/rules.bzl30
1 files changed, 30 insertions, 0 deletions
diff --git a/cobol/internal/rules.bzl b/cobol/internal/rules.bzl
new file mode 100644
index 0000000..8dac747
--- /dev/null
+++ b/cobol/internal/rules.bzl
@@ -0,0 +1,30 @@
+"Rules for building COBOL programs"
+
+load(":actions.bzl", "cobol_compile_executable")
+
+def _cobol_binary_impl(ctx):
+ prefix = ctx.label.name + "%/"
+ executable = ctx.actions.declare_file(prefix + ctx.label.name)
+
+ cobol_compile_executable(
+ ctx,
+ srcs = ctx.files.srcs,
+ out = executable,
+ )
+
+ return [DefaultInfo(
+ files = depset([executable]),
+ executable = executable,
+ )]
+
+cobol_binary = rule(
+ _cobol_binary_impl,
+ attrs = {
+ "srcs": attr.label_list(
+ allow_files = True,
+ doc = "The COBOL source files to compile for this binary",
+ ),
+ },
+ doc = "Builds an executable program from COBOL source code",
+ executable = True,
+)