Code Monkey home page Code Monkey logo

bazel_rules_install's Introduction

Install rules for Bazel

This is not an officially supported Google product.

Overview

This project aims at making it easy to install Bazel projects on local workstations.

Features

  • installer rule:
    • Installs given file(s) in a directory.
    • Installs a directory tree.
    • Prevents accidental installation of debug builds.
    • Renames installed files.
    • Selects a sensible default install prefix.
    • When needed asks for write access (sudo).
  • OS support:
    • Linux
    • macOS
    • Windows

Rules

Setup

  1. In the WORKSPACE file of your Bazel project add the following:

    load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
    
    http_archive(
        name = "com_github_google_rules_install",
        urls = ["https://github.com/google/bazel_rules_install/releases/download/0.3/bazel_rules_install-0.3.tar.gz"],
        sha256 = "ea2a9f94fed090859589ac851af3a1c6034c5f333804f044f8f094257c33bdb3",
        strip_prefix = "bazel_rules_install-0.3",
    )
    
    load("@com_github_google_rules_install//:deps.bzl", "install_rules_dependencies")
    
    install_rules_dependencies()
    
    load("@com_github_google_rules_install//:setup.bzl", "install_rules_setup")
    
    install_rules_setup()
  2. In the BUILD file of the package where you want to add an installer add the following:

    # In file src/path/to/pkg/BUILD:
    
    load("@com_github_google_rules_install//installer:def.bzl", "installer")
    
    installer(
        name = "install_foo",
        data = [":foo"],
    )

Usage

Run the installer using bazel run. The following example installs foo in ~/bin:

bazel run //src/path/to/pkg:install_foo -- ~/bin

sudo

If you need to use sudo to install a file in a system directory:

  • Do not run sudo bazel.
  • Instead pass flag -s to the installer.
bazel run //src/path/to/pkg:install_foo -- -s /usr/local/bin

Debug builds

By default installer uses targets built with -c opt. To disable this override of a command line flag use compilation_mode = "" attribute:

installer(
    name = "install_foo",
    compilation_mode = "",
    data = [":foo"],
)

Alternatively you can force a debug build:

installer(
    name = "install_foo_dbg",
    compilation_mode = "dbg",
    data = [":foo"],
)

See also

bazel_rules_install's People

Contributors

bttk avatar blackliner 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.