Giter VIP home page Giter VIP logo

rules_babashka's Introduction

Babashka rules for Bazel

Status: Alpha.

Features

  • babashka toolchains for multiple execution platforms

Setup

Add the following to your WORKSPACE:

RULES_BABASHKA_SHA = $CURRENT_SHA1
http_archive(
    name = "rules_babashka",
    strip_prefix = "rules_babashka-%s" % RULES_BABASHKA_SHA,
    url = "https://github.com/griffinbank/rules_babashka/archive/%s.zip" % RULES_BABASHKA_SHA
)

load("@rules_babashka//:repo.bzl", "babashka")

BABASHKA_VERSION="1.3.184"

babashka(
    name = "babashka-local",
    version = BABASHKA_VERSION,
)
register_toolchains("@babashka-local//:toolchain")

You can then use the bb binary within a genrule as a tool:

genrule(
    name = "bb-rule",
    srcs = ["bb.edn"],
    outs = ["output.edn"],
    tools = ["@babashka-local//:bin/bb"],
    cmd = """
        $(execpath @babashka-local//:bin/bb) task:bb
    """
)

If you need to use an alternate Babashka to the execution environment, to build into a deployment artifact, you can override the arch and os:

babashka(
    name = "babashka-linux-x86",
    arch = "amd64",
    os = "linux",
    version = BABASHKA_VERSION,
)

and then reference the bb binary from the alternate version.

Script dependencies

Use the babashka_deps_jar rule within a BUILD file to generate a jar of all the dependencies referenced in bb.edn:

load("@rules_babashka//deps:deps.bzl", "babashka_deps_jar")

babashka_deps_jar(
    name = "deps",
    bb_edn = "bb.edn",
)

The output will be called {name}.jar. If that's not suitable, it can be overridden with the output parameter:

load("@rules_babashka//deps:deps.bzl", "babashka_deps_jar")

babashka_deps_jar(
    name = "deps-jar",
    bb_edn = "bb.edn",
    output = "deps.jar",
)

rules_babashka's People

Contributors

dancmeyers avatar

Stargazers

Neil Hooey avatar  avatar Brandon Adams avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.