]> granicus.if.org Git - python/commitdiff
bpo-30492: Allow make clinic to work out of tree. (#1836)
authorGregory P. Smith <greg@krypto.org>
Sat, 27 May 2017 23:40:45 +0000 (16:40 -0700)
committerGitHub <noreply@github.com>
Sat, 27 May 2017 23:40:45 +0000 (16:40 -0700)
* bpo-30492: Allow make clinic to work out of tree.

* Use os.curdir instead of "." as the default value.

Makefile.pre.in
Tools/clinic/clinic.py

index 0aefcf2a307cfad284f80112e9b018d46a301b47..ee1cd4a0280ed4b2f5247c70daae585e9fe87a20 100644 (file)
@@ -528,7 +528,7 @@ coverage-report: regen-grammar regen-importlib
 # (depends on python having already been built)
 .PHONY=clinic
 clinic: $(BUILDPYTHON) $(srcdir)/Modules/_blake2/blake2s_impl.c
-       $(RUNSHARED) $(PYTHON_FOR_BUILD) ./Tools/clinic/clinic.py --make
+       $(RUNSHARED) $(PYTHON_FOR_BUILD) $(srcdir)/Tools/clinic/clinic.py --make --srcdir $(srcdir)
 
 # Build the interpreter
 $(BUILDPYTHON):        Programs/python.o $(LIBRARY) $(LDLIBRARY) $(PY3LIBRARY)
index 6be0ab2b3d1527ffda2ac8c3c903b3fc59d57037..0845a8e9b190858a52f3287c6d4d89ce344c7acb 100755 (executable)
@@ -4335,7 +4335,10 @@ def main(argv):
     cmdline.add_argument("-o", "--output", type=str)
     cmdline.add_argument("-v", "--verbose", action='store_true')
     cmdline.add_argument("--converters", action='store_true')
-    cmdline.add_argument("--make", action='store_true')
+    cmdline.add_argument("--make", action='store_true',
+                         help="Walk --srcdir to run over all relevant files.")
+    cmdline.add_argument("--srcdir", type=str, default=os.curdir,
+                         help="The directory tree to walk in --make mode.")
     cmdline.add_argument("filename", type=str, nargs="*")
     ns = cmdline.parse_args(argv)
 
@@ -4406,7 +4409,12 @@ def main(argv):
             print()
             cmdline.print_usage()
             sys.exit(-1)
-        for root, dirs, files in os.walk('.'):
+        if not ns.srcdir:
+            print("Usage error: --srcdir must not be empty with --make.")
+            print()
+            cmdline.print_usage()
+            sys.exit(-1)
+        for root, dirs, files in os.walk(ns.srcdir):
             for rcs_dir in ('.svn', '.git', '.hg', 'build', 'externals'):
                 if rcs_dir in dirs:
                     dirs.remove(rcs_dir)