mirror of
https://github.com/motioneye-project/motioneyeos.git
synced 2025-07-27 05:06:39 +00:00
genrandconfig: calculate configfile only once
The path to the .config file is calculated in several places - replace it with a single calculation, and pass configfile as an argument to is_toolchain_usable and fixup_config. These functions also don't need outputdir any more. This makes it easier to fix the case when configfile is not in outputdir. Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
This commit is contained in:
parent
b8288a5f43
commit
5638b10c22
@ -164,10 +164,10 @@ def get_toolchain_configs(toolchains_url):
|
|||||||
return configs
|
return configs
|
||||||
|
|
||||||
|
|
||||||
def is_toolchain_usable(outputdir, config):
|
def is_toolchain_usable(configfile, config):
|
||||||
"""Check if the toolchain is actually usable."""
|
"""Check if the toolchain is actually usable."""
|
||||||
|
|
||||||
with open(os.path.join(outputdir, ".config")) as configf:
|
with open(configfile) as configf:
|
||||||
configlines = configf.readlines()
|
configlines = configf.readlines()
|
||||||
|
|
||||||
# Check that the toolchain configuration is still present
|
# Check that the toolchain configuration is still present
|
||||||
@ -192,7 +192,7 @@ def is_toolchain_usable(outputdir, config):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def fixup_config(outputdir):
|
def fixup_config(configfile):
|
||||||
"""Finalize the configuration and reject any problematic combinations
|
"""Finalize the configuration and reject any problematic combinations
|
||||||
|
|
||||||
This function returns 'True' when the configuration has been
|
This function returns 'True' when the configuration has been
|
||||||
@ -202,7 +202,7 @@ def fixup_config(outputdir):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
sysinfo = SystemInfo()
|
sysinfo = SystemInfo()
|
||||||
with open(os.path.join(outputdir, ".config")) as configf:
|
with open(configfile) as configf:
|
||||||
configlines = configf.readlines()
|
configlines = configf.readlines()
|
||||||
|
|
||||||
if "BR2_NEEDS_HOST_JAVA=y\n" in configlines and not sysinfo.has("java"):
|
if "BR2_NEEDS_HOST_JAVA=y\n" in configlines and not sysinfo.has("java"):
|
||||||
@ -314,7 +314,7 @@ def fixup_config(outputdir):
|
|||||||
'BR2_PACKAGE_QT_GUI_MODULE=y\n' in configlines:
|
'BR2_PACKAGE_QT_GUI_MODULE=y\n' in configlines:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
with open(os.path.join(outputdir, ".config"), "w+") as configf:
|
with open(configfile, "w+") as configf:
|
||||||
configf.writelines(configlines)
|
configf.writelines(configlines)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
@ -354,13 +354,14 @@ def gen_config(args):
|
|||||||
# Write out the configuration file
|
# Write out the configuration file
|
||||||
if not os.path.exists(args.outputdir):
|
if not os.path.exists(args.outputdir):
|
||||||
os.makedirs(args.outputdir)
|
os.makedirs(args.outputdir)
|
||||||
with open(os.path.join(args.outputdir, ".config"), "w+") as configf:
|
configfile = os.path.join(args.outputdir, ".config")
|
||||||
|
with open(configfile, "w+") as configf:
|
||||||
configf.writelines(configlines)
|
configf.writelines(configlines)
|
||||||
|
|
||||||
subprocess.check_call(["make", "O=%s" % args.outputdir, "-C", args.buildrootdir,
|
subprocess.check_call(["make", "O=%s" % args.outputdir, "-C", args.buildrootdir,
|
||||||
"olddefconfig"])
|
"olddefconfig"])
|
||||||
|
|
||||||
if not is_toolchain_usable(args.outputdir, config):
|
if not is_toolchain_usable(configfile, config):
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
# Now, generate the random selection of packages, and fixup
|
# Now, generate the random selection of packages, and fixup
|
||||||
@ -378,7 +379,7 @@ def gen_config(args):
|
|||||||
"KCONFIG_PROBABILITY=%d" % randint(1, 30),
|
"KCONFIG_PROBABILITY=%d" % randint(1, 30),
|
||||||
"randpackageconfig"])
|
"randpackageconfig"])
|
||||||
|
|
||||||
if fixup_config(args.outputdir):
|
if fixup_config(configfile):
|
||||||
break
|
break
|
||||||
|
|
||||||
subprocess.check_call(["make", "O=%s" % args.outputdir, "-C", args.buildrootdir,
|
subprocess.check_call(["make", "O=%s" % args.outputdir, "-C", args.buildrootdir,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user