Giter Site home page Giter Site logo

Comments (5)

nickpalmer avatar nickpalmer commented on March 29, 2024

This is also an issue for generating BuildConfig.java files. I am currently using:

genrule(
  name = 'BuildConfig',
  out = 'BuildConfig.java',
  cmd = 'bash -c \'echo "package some.pacakge; public final class BuildConfig { public final static boolean DEBUG = false; }" > $OUT \' ',
)

But I cannot have BuildConfig-Debug and BuildConfig-Release that generate the same file in two different modes.

from buck.

spearce avatar spearce commented on March 29, 2024

I worked around this in my build by running git describe from Python instead of the genrule:

def git_describe():
  import subprocess
  cmd = ['git', 'describe', '--match', 'v[0-9].*', '--dirty']
  p = subprocess.Popen(cmd, stdout = subprocess.PIPE)
  v = p.communicate()[0].strip()
  r = p.returncode
  if r != 0:
    raise subprocess.CalledProcessError(r, ' '.join(cmd))
  return v

genrule(
  name = 'gen_version',
  cmd = ';'.join([
    'cd $TMP',
    'mkdir -p com/google/gerrit/common',
    'echo "%s" >com/google/gerrit/common/Version' % git_describe(),
    'zip -9Dqr $OUT .',
  ]),
  out = 'version.jar',
)

nickpalmer, maybe you can create two top level build targets that add in the BuildConfig.java at the last minute? Something like this:

java_application(name = 'release', deps = [':app', ':BuildConfig-release'])
java_application(name = 'debug', deps = [':app', ':BuildConfig-debug'])

from buck.

Coneko avatar Coneko commented on March 29, 2024

@spearce That might not work because buckd caches the build files in memory.

Has that not been a problem?

from buck.

bolinfest avatar bolinfest commented on March 29, 2024

@nickpalmer We fixed your specific case with a custom rule that does smart things: http://facebook.github.io/buck/rule/android_build_config.html

from buck.

sdwilsh avatar sdwilsh commented on March 29, 2024

We don't want genrule to be able to do this, but I filed an issue for the feature you need out of this.

from buck.

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.