Provide helpful errors when bucklets are missing

Based on experience, most users clone without --recursive, and don't
know to look for submodules when something fails. This causes the
first "buck build" to fail with a cryptic error:

  [+] PARSING BUILD FILES...0.0s
  Traceback (most recent call last):
    File ".../buck-out/tmp/buck_run.TJfecZrGH8/buck3109317914122554851.py", line 1205, in <module>
      main()
    File ".../buck-out/tmp/buck_run.TJfecZrGH8/buck3109317914122554851.py", line 588, in main
      buildFileProcessor.process(build_file.rstrip())
    File ".../buck-out/tmp/buck_run.TJfecZrGH8/buck3109317914122554851.py", line 487, in process
      build_env['BUILD_FILE_SYMBOL_TABLE'])
    File "..././BUCK", line 2, in <module>
      include_defs('//bucklets/maven_package.bucklet')
    File ".../buck-out/tmp/buck_run.TJfecZrGH8/buck3109317914122554851.py", line 85, in invoke
      return self.func(*args, **updated_kwargs)
    File ".../buck-out/tmp/buck_run.TJfecZrGH8/buck3109317914122554851.py", line 403, in include_defs
      execfile(include_file, build_env['BUILD_FILE_SYMBOL_TABLE'])
  IOError: [Errno 2] No such file or directory: '.../bucklets/maven_package.bucklet'
BUILD FAILED: Parse error for BUCK file ./BUCK: End of input at line 1 column 1

Instead, provide a wrapper around include_defs specifically for
bucklets, which checks that the bucklets directory exists and is
non-empty. If it is empty, buck fails with a more useful error:

  [+] PARSING BUILD FILES...0.2s
  Bucklets directory is empty: .../gitiles/bucklets
  Run `git submodule init`
  BUILD FAILED: Parse error for BUCK file ./BUCK: End of input at line 1 column 1

The unfortunate chicken-and-egg problem with this approach is this
common functionality cannot live in the bucklets repo itself.

Change-Id: I767f582f8978075355203af126d253dfc28ea8cd
diff --git a/bucklets.defs b/bucklets.defs
new file mode 100644
index 0000000..56c0a96
--- /dev/null
+++ b/bucklets.defs
@@ -0,0 +1,20 @@
+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)
+
+  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)
+
+  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)