title: conditional new_local_library in Bazel WORKSPACE
body: <p>I've got some pre-built 3rd party libraries that I have to include in my Bazel build. So I have something like this in my <code>WORKSPACE</code>:</p>
  
  <pre><code>new_local_repository(
     name = "thirdparty",
     path = ".install/OSX/DEBUG",
     build_file = "bazel/BUILD.third_party",
  )
  </code></pre>
  
  <p>And the <code>BUILD.third_party</code> looks like:</p>
  
  <pre><code>cc_library(
      name = "glog",
      srcs = ["glog/0.3.5.r1/lib/libglog.a"],
      hdrs = glob([
         "glog/0.3.5.r1/include/**"
      ]),
     visibility = ["//visibility:public"],
     includes = [
        "glog/0.3.5.r1/include"
     ]
  )
  </code></pre>
  
  <p>The issue is that the <code>OSX/DEBUG</code> part of the <code>path</code> in the <code>new_local_repository</code> rule needs to depend on the current platform and the <code>compilation_mode</code> (e.g. I want to link in a release build of <code>glog</code> if the <code>compilation_mode == opt</code>). However, as I understanding the <code>new_local_repository</code> rule must be evaluated during the loading phase and the command line options and other configuration information isn't available at that point. Similarly <code>select</code> expressions aren't available in <code>WORKSPACE</code> files. Is there any way to do this?</p>
  
  <h1>Edit</h1>
  
  <p>I found a way that <strong>should</strong> work but there appears to be a bug in Bazel. Here's my bug report: <a href="https://github.com/bazelbuild/bazel/issues/10400" rel="nofollow noreferrer">https://github.com/bazelbuild/bazel/issues/10400</a></p>