genrandconfig: pass outputdir and buildrootdir as arguments
The --instance argument is just an artifact of genrandconfig's history as part of autobuild-run. It is much more logical to pass the output directory and the buildroot directory as arguments, with sane defaults. This also allows us to remove the hack of creating a symlink in the instance directory if it doesn't exist yet. Note that the default outputdir 'output' doesn't work yet, because in that case Buildroot will put the config file in the buildroot directory instead of the output directory. This will be fixed in a follow-up patch. After this change, the script should be called from autobuild-run as: subprocess.call([os.path.join(srcdir, "utils/genrandconfig"), "-o", outputdir, "-b", srcdir, "--toolchains-url", kwargs['toolchains_url']], stdout=devnull, stderr=log) 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
9633b6ddd2
commit
b8288a5f43
@ -352,6 +352,8 @@ def gen_config(args):
|
|||||||
configlines.append("BR2_PACKAGE_PYTHON_PY_ONLY=y\n")
|
configlines.append("BR2_PACKAGE_PYTHON_PY_ONLY=y\n")
|
||||||
|
|
||||||
# Write out the configuration file
|
# Write out the configuration file
|
||||||
|
if not os.path.exists(args.outputdir):
|
||||||
|
os.makedirs(args.outputdir)
|
||||||
with open(os.path.join(args.outputdir, ".config"), "w+") as configf:
|
with open(os.path.join(args.outputdir, ".config"), "w+") as configf:
|
||||||
configf.writelines(configlines)
|
configf.writelines(configlines)
|
||||||
|
|
||||||
@ -391,29 +393,22 @@ def gen_config(args):
|
|||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
import argparse
|
import argparse
|
||||||
parser = argparse.ArgumentParser(description="Generate a random configuration")
|
parser = argparse.ArgumentParser(description="Generate a random configuration")
|
||||||
parser.add_argument("--instance", "-i",
|
parser.add_argument("--outputdir", "-o",
|
||||||
help="Instance number for creating unique directories",
|
help="Output directory (relative to current directory)",
|
||||||
type=int, default=0)
|
type=str, default='output')
|
||||||
|
parser.add_argument("--buildrootdir", "-b",
|
||||||
|
help="Buildroot directory (relative to current directory)",
|
||||||
|
type=str, default='.')
|
||||||
parser.add_argument("--toolchains-url",
|
parser.add_argument("--toolchains-url",
|
||||||
help="URL of toolchain configuration file",
|
help="URL of toolchain configuration file",
|
||||||
type=str,
|
type=str,
|
||||||
default="http://autobuild.buildroot.org/toolchains/configs/toolchain-configs.csv")
|
default="http://autobuild.buildroot.org/toolchains/configs/toolchain-configs.csv")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
# Output directory is already created by autobuild-run so emulate it here
|
|
||||||
idir = "instance-%d" % args.instance
|
|
||||||
# We need the absolute path to use with O=, because the relative
|
# We need the absolute path to use with O=, because the relative
|
||||||
# path to the output directory here is not relative to the
|
# path to the output directory here is not relative to the
|
||||||
# Buildroot sources, but to the location of the autobuilder
|
# Buildroot sources, but to the current directory.
|
||||||
# script.
|
args.outputdir = os.path.abspath(args.outputdir)
|
||||||
args.outputdir = os.path.abspath(os.path.join(idir, "output"))
|
|
||||||
args.buildrootdir = os.path.join(idir, "buildroot")
|
|
||||||
|
|
||||||
if not os.path.exists(idir):
|
|
||||||
os.mkdir(idir)
|
|
||||||
os.mkdir(args.outputdir)
|
|
||||||
# gen_config expects "buildroot" directory under idir
|
|
||||||
os.symlink("..", args.buildrootdir)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
ret = gen_config(args)
|
ret = gen_config(args)
|
||||||
|
Loading…
Reference in New Issue
Block a user