Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transitive workspace dependencies not working #2757

Closed
sergiocampama opened this issue Mar 30, 2017 · 4 comments
Closed

Transitive workspace dependencies not working #2757

sergiocampama opened this issue Mar 30, 2017 · 4 comments
Labels
P2 We'll consider working on this in future. (Assignee optional) stale Issues or PRs that are stale (no activity for 30 days) team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: feature request

Comments

@sergiocampama
Copy link
Contributor

sergiocampama commented Mar 30, 2017

Description of the problem / feature request / question:

I have a github repo/workspace where I define some new rules in https://github.com/sergiocampama/bazel-msp430. This github repo has 2 dependencies on external binaries using the new_http_archive repository rules, which can be seen in https://github.com/sergiocampama/bazel-msp430/blob/master/WORKSPACE.

I am trying to create a development WORKSPACE where I import the bazel-msp430 rules using the git_repository repository rule in https://github.com/sergiocampama/bazel_issue_repro/blob/master/WORKSPACE. I then load the Skylark extensions using load("@msp430_rules//tools/msp430:build_defs/msp430.bzl", "msp430_library") in https://github.com/sergiocampama/bazel_issue_repro/blob/master/BUILD

When I run bazel build :test, the build fails with the error:

ERROR: /Users/kaipi/Development/Bazel/BUILD:3:1: every rule of type msp430_library implicitly depends upon the target '@msp430_toolchain//:compiler_support', but this target could not be found because of: no such package '@msp430_toolchain//': error loading package 'external': The repository named 'msp430_toolchain' could not be resolved.

If possible, provide a minimal example to reproduce the problem:

The easiest way to repro is to git clone git@github.com:sergiocampama/bazel_issue_repro.git && cd bazel_issue_repro && bazel build :test

Environment info

  • Operating System: macOS 10.12.4 Beta

  • Bazel version (output of bazel info release): release 0.4.5-homebrew

Have you found anything relevant by searching the web?

I tried using the steps in https://bazel.build/versions/master/docs/external.html, but the following command generates empty WORKSPACE and BUILD files.

# Run from within a bazel repo checkout and MSP430 is a checkout of 
# https://github.com/sergiocampama/bazel-msp430
bazel run //src/tools/generate_workspace -- --bazel_project ../MSP430
@sergiocampama
Copy link
Contributor Author

I can manually add the following to make the bazel_issue_repro/WORKSPACE file and it works, but I'm wondering if there's a better way to accomplish what I want without having users of the msp430 rules configure this in their WORKSPACE:

(notice the build_file attributes)

new_http_archive(
    name = "msp430_toolchain",
    build_file = "@msp430_rules//:BUILD.msp430_toolchain",
    sha256 = "7e6b9fb94885e566777312bfcd0c1d1d583e37898a080210a4adebced1116f86",
    strip_prefix = "msp430-gcc-6.2.1.16_osx",
    urls = [
        "http://software-dl.ti.com/msp430/msp430_public_sw/mcu/msp430/MSPGCC/latest/exports/msp430-gcc-6.2.1.16_osx.tar.bz2",
    ],
)

new_http_archive(
    name = "msp430_include",
    build_file = "@msp430_rules//:BUILD.msp430_include",
    sha256 = "8d411d61eebf794d4f786f77c901223c931146ba2dfe2ae0798433c7ddb15137",
    strip_prefix = "msp430-gcc-support-files",
    urls = [
        "http://software-dl.ti.com/msp430/msp430_public_sw/mcu/msp430/MSPGCC/latest/exports/msp430-gcc-support-files-1.198.zip",
    ],
)

@kchodorow
Copy link
Contributor

Unfortunately, heirarchical workspace files are not supported, yet (which is what you're trying to accomplish). See #1943 for the relevant bug. For now, you do have to specify all repositories. One thing you can do to make your users lives a little easier (possibly) is define a skylark function in msp430_rules like msp430_repositories() that looks like:

def msp430_repositories():
  native.new_http_archive(
    name = "msp430_toolchain",
    build_file = "//:BUILD.msp430_toolchain",
    sha256 = "7e6b9fb94885e566777312bfcd0c1d1d583e37898a080210a4adebced1116f86",
    strip_prefix = "msp430-gcc-6.2.1.16_osx",
    urls = [
        "http://software-dl.ti.com/msp430/msp430_public_sw/mcu/msp430/MSPGCC/latest/exports/msp430-gcc-6.2.1.16_osx.tar.bz2",
    ],
  )

  native.new_http_archive(
    name = "msp430_include",
    build_file = "//:BUILD.msp430_include",
    sha256 = "8d411d61eebf794d4f786f77c901223c931146ba2dfe2ae0798433c7ddb15137",
    strip_prefix = "msp430-gcc-support-files",
    urls = [
        "http://software-dl.ti.com/msp430/msp430_public_sw/mcu/msp430/MSPGCC/latest/exports/msp430-gcc-support-files-1.198.zip",
    ],
  )

Then the user can load() and execute that function in their WORKSPACE file.

@EricCousineau-TRI
Copy link
Contributor

(As reference for others)
At present, you cannot use load(...) within macros / functions, per #1550, where you load macros / targets from one package, and then need to be load(...)d from other packages. Example from the issue:

def io_bazel_rules_closure():
  native.local_repository(
      name = "io_bazel_rules_closure",
      path = ".../jart/code/rules_closure",
  )
  load("@io_bazel_rules_closure//closure:defs.bzl", "closure_repositories")
  # Not going to work
  closure_repositories(...)

This is accounted for feature request #1943, as @kchodorow mentioned.

@dslomov dslomov added team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. and removed category: extensibility > external repositories labels Mar 5, 2019
@philwo philwo added the team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website label Jun 15, 2020
@philwo philwo removed the team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website label Nov 29, 2021
@sgowroji sgowroji added the stale Issues or PRs that are stale (no activity for 30 days) label Feb 17, 2023
@sgowroji
Copy link
Member

Hi there! We're doing a clean up of old issues and will be closing this one. Please reopen (or ping me to reopen) if you’d like to discuss anything further. We’ll respond as soon as we have the bandwidth/resources to do so.

@sgowroji sgowroji closed this as not planned Won't fix, can't repro, duplicate, stale Feb 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 We'll consider working on this in future. (Assignee optional) stale Issues or PRs that are stale (no activity for 30 days) team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: feature request
Projects
None yet
Development

No branches or pull requests

7 participants