summaryrefslogtreecommitdiffstats
path: root/support/scripts
diff options
context:
space:
mode:
authorJérôme Pouiller <jezz@sysmic.org>2016-12-20 14:46:22 +0100
committerThomas Petazzoni <thomas.petazzoni@free-electrons.com>2017-03-20 23:00:25 +0100
commit6e45c5500ba31890d7f91c1c4ad50d314715affc (patch)
treef269414532cc5fe93dad3a5293971bdb411c5ed9 /support/scripts
parent6a4131d101cf0d8bc35ce15672524f144c925fc3 (diff)
downloadbuildroot-6e45c5500ba31890d7f91c1c4ad50d314715affc.tar.gz
buildroot-6e45c5500ba31890d7f91c1c4ad50d314715affc.zip
pycompile: allow to force compilation
By default, compile_dir() relies on the modification time to know if a python file has to be built again. However in some circumstances (when doing reproducible builds), modification times are not reliable. Thus, this patch adds a way to force the rebuild of all python sources. Signed-off-by: Jérôme Pouiller <jezz@sysmic.org> Reviewed-by: Samuel Martin <s.martin49@gmail.com> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Diffstat (limited to 'support/scripts')
-rw-r--r--support/scripts/pycompile.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/support/scripts/pycompile.py b/support/scripts/pycompile.py
index 9f7eb9fd9f..8e164ab9d1 100644
--- a/support/scripts/pycompile.py
+++ b/support/scripts/pycompile.py
@@ -10,6 +10,7 @@ from __future__ import print_function
import sys
import py_compile
import compileall
+import argparse
def check_for_errors(comparison):
'''Wrap comparison operator with code checking for PyCompileError.
@@ -54,4 +55,12 @@ class ReportProblem(int):
def __ne__(self, other):
return not self == other
-compileall.compile_dir(sys.argv[1], quiet=ReportProblem())
+parser = argparse.ArgumentParser(description='Compile Python source files in a directory tree.')
+parser.add_argument("target", metavar='DIRECTORY',
+ help='Directory to scan')
+parser.add_argument("--force", action='store_true',
+ help="Force compilation even if alread compiled")
+
+args = parser.parse_args()
+
+compileall.compile_dir(args.target, force=args.force, quiet=ReportProblem())
OpenPOWER on IntegriCloud