Skip to content

Instantly share code, notes, and snippets.

@josephlr
Created June 20, 2019 09:34
Show Gist options
  • Save josephlr/ec1d64fd17d631da7dd9d7ef3fb245c4 to your computer and use it in GitHub Desktop.
Save josephlr/ec1d64fd17d631da7dd9d7ef3fb245c4 to your computer and use it in GitHub Desktop.
Bazel file to support OpenSSl-style perl -> asm generation
load("@bazel_skylib//lib:paths.bzl", "paths")
def perlasm(src, perlasm_utils, name=None):
""" Creates a genrule to process the src. Returns rule name."""
(filename, ext) = paths.split_extension(paths.basename(src))
if ext != ".pl":
fail("Provided perlasm file {} must be a Perl file".format(src))
if name == None:
name = filename
native.genrule(
name = name,
srcs = [src] + perlasm_utils,
outs = [name + ".S"],
cmd = "perl $(rootpath {}) elf $@".format(src),
)
return name
def perlasm_cc_library(perlasm_srcs, perlasm_utils, srcs=[], **kwargs):
"""Identical to cc_library, except allows for perlasm_srcs."""
native.cc_library(
srcs = srcs + [":" + perlasm(src, perlasm_utils) for src in perlasm_srcs],
**kwargs
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment