Git Product home page Git Product logo

Comments (6)

BenjaminLawson avatar BenjaminLawson commented on July 28, 2024

Maybe --import-dir should be set to external/repo-name instead of "." and " ".

from emboss.

BenjaminLawson avatar BenjaminLawson commented on July 28, 2024

src.path resolves to the right path (external/repo-name/.../src), but src.root resolves to the directory containing "external" and is used for --import-dir. It seems like we want to use "src.root + /external/repo-name" to resolve imports.

from emboss.

BenjaminLawson avatar BenjaminLawson commented on July 28, 2024

Yes, imports = ["--import-dir=" + root.path + "external/pigweed/" for root in dep_roots.to_list()] in _emboss_library_impl works. I'm not sure how to properly calculate "external/pigweed" though.

from emboss.

BenjaminLawson avatar BenjaminLawson commented on July 28, 2024

This seems to work:

    adjusted_src_root = src.root.path
    if src.path.startswith("external/"):
        segments = src.path.split("/")
        first_two_segments = "/".join(segments[:3])
        adjusted_src_root = paths.dirname(first_two_segments)

    dep_roots = depset(
        direct = [adjusted_src_root],
        transitive = [dep.transitive_roots for dep in deps],
    )
    imports = ["--import-dir=" + root for root in dep_roots.to_list()]

from emboss.

reventlov avatar reventlov commented on July 28, 2024

That's sort of horrible, but probably good enough for now.

It would probably be worth reaching out to the Bazel team to see if they have any suggestions -- I was basically trying to copy the aspect for Proto, but that aspect is allowlisted for a bunch of interfaces that I could not use directly.

from emboss.

BenjaminLawson avatar BenjaminLawson commented on July 28, 2024

Sounds like proto has the same problem. I found a similar solution on stackoverflow:
https://stackoverflow.com/questions/55796252/how-to-write-bazel-rules-that-work-with-external-repositories

from emboss.

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.