aboutsummaryrefslogtreecommitdiff
path: root/cobol/internal/actions.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/actions.bzl
downloadrules_cobol-main.tar.xz
rules_cobol-main.zip
feat(0.1.0): initial releaseHEAD0.1.0main
Diffstat (limited to 'cobol/internal/actions.bzl')
-rw-r--r--cobol/internal/actions.bzl23
1 files changed, 23 insertions, 0 deletions
diff --git a/cobol/internal/actions.bzl b/cobol/internal/actions.bzl
new file mode 100644
index 0000000..a57bd58
--- /dev/null
+++ b/cobol/internal/actions.bzl
@@ -0,0 +1,23 @@
+"""Common functions for creating actions to build COBOL programs"""
+
+load("@bazel_skylib//lib:shell.bzl", "shell")
+
+def cobol_compile_executable(ctx, srcs, out):
+ """Compiles a single COBOL program from sources
+
+ Args:
+ ctx: the build context
+ srcs: the source files to compile
+ out: the output file
+ """
+
+ ctx.actions.run_shell(
+ outputs = [out],
+ inputs = srcs,
+ command = "cobc -x -o {out} {srcs}".format(
+ out = shell.quote(out.path),
+ srcs = " ".join([shell.quote(src.path) for src in srcs]),
+ ),
+ mnemonic = "COBOLCompile",
+ use_default_shell_env = True,
+ )