Buck: Import all bucklets in bucklet.defs
This means all bucklets used by Gitiles are loaded on every buck
invocation.
Arguably it's a performance hit if you try to build a target that
doesn't require the bucklets, but for a small project like Gitiles where
every rule requires loading at least one bucklet, the cost should be
minimal.
Inspired-by: Dave Borowitz <[email protected]>
Change-Id: Ic1c8048437876b5bfd7cd503b32bd97649e4402c
diff --git a/bucklets.defs b/bucklets.defs
index 56c0a96..1ba5e0c 100644
--- a/bucklets.defs
+++ b/bucklets.defs
@@ -1,20 +1,27 @@
import os
import sys
-def include_bucklets(names):
- d = os.getcwd()
- while not os.path.lexists(os.path.join(d, '.buckversion')):
- d = os.path.dirname(d)
+d = os.getcwd()
+while not os.path.lexists(os.path.join(d, '.buckversion')):
+ d = os.path.dirname(d)
- bd = os.path.join(d, 'bucklets')
- if not os.path.isdir(bd) or not os.listdir(bd):
- sys.stderr.write(('Bucklets directory is missing or empty: %s\n'
- 'Run `git submodule update --init`') % bd)
+bd = os.path.join(d, 'bucklets')
+if not os.path.isdir(bd) or not os.listdir(bd):
+ sys.stderr.write(('Bucklets directory is missing or empty: %s\n'
+ 'Run `git submodule update --init`') % bd)
+ sys.exit(1)
+
+bucklets = [
+ 'java_doc.bucklet',
+ 'java_sources.bucklet',
+ 'maven_jar.bucklet',
+ 'maven_package.bucklet',
+ 'war.bucklet',
+]
+
+for bucklet in bucklets:
+ path = os.path.join(bd, bucklet)
+ if not os.path.isfile(path):
+ sys.stderr.write('Missing bucklet: %s\n' % path)
sys.exit(1)
-
- for name in names:
- path = os.path.join(bd, name)
- if not os.path.isfile(path):
- sys.stderr.write('Missing bucklet: %s\n' % path)
- sys.exit(1)
- include_defs('//bucklets/%s' % name)
+ include_defs('//bucklets/%s' % bucklet)