aboutsummaryrefslogtreecommitdiff
path: root/cobol/internal/actions.bzl
blob: a57bd580a5911406b43be61ac5795b3170e29c82 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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,
    )