Git Product home page Git Product logo

Comments (4)

cormacrelf avatar cormacrelf commented on May 15, 2024

You can make a macro.

def wrapped_cxx_library(srcs=[], **kwargs):
    srcs.append("file.hh")
    native.cxx_library(srcs = srcs, **kwargs)

You don't need to return anything, rules don't return anything when you call them anyway (only the impl functions do). You can call multiple rules, and connect up the outputs of one to the inputs of the other, by constructing

whatever = "{}-whatever".format(name)
native.cxx_library(name = whatever, ...)

native.cxx_library(..., deps = kwargs.pop("deps") + [":{}".format(whatever)], **kwargs)

from buck2.

zjturner avatar zjturner commented on May 15, 2024

I'm using macros for this purpose right now, and it generally works ok but sometimes I wish I had access to some of the things in a rule impl's context structure.

from buck2.

cjhopman avatar cjhopman commented on May 15, 2024

The inner() function is a function that declares a target (and does a bunch of other stuff). As the error message indicates, you cannot do that during analysis. You could, however, call the _inner_impl() function if you wanted.

from buck2.

zjturner avatar zjturner commented on May 15, 2024

Yea, unfortunately I can't do that unless I have access to the impl. So I can't do it, for example, if I want to forward to cxx_library. In any case, I can continue with just using macros, I can still solve the problem I was having, just not as nicely as if I had the full power of a rule.

from buck2.

Related Issues (20)

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.