mirror of
https://gitlab.com/buildroot.org/buildroot.git
synced 2026-10-01 06:21:56 -09:00
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>
This commit is contained in:
committed by
Thomas Petazzoni
parent
6a4131d101
commit
6e45c5500b
@@ -10,6 +10,7 @@ from __future__ import print_function
|
|||||||
import sys
|
import sys
|
||||||
import py_compile
|
import py_compile
|
||||||
import compileall
|
import compileall
|
||||||
|
import argparse
|
||||||
|
|
||||||
def check_for_errors(comparison):
|
def check_for_errors(comparison):
|
||||||
'''Wrap comparison operator with code checking for PyCompileError.
|
'''Wrap comparison operator with code checking for PyCompileError.
|
||||||
@@ -54,4 +55,12 @@ class ReportProblem(int):
|
|||||||
def __ne__(self, other):
|
def __ne__(self, other):
|
||||||
return not 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())
|
||||||
|
|||||||
Reference in New Issue
Block a user