提交 bc6c12d5 编写于 作者: C Cleber Rosa

avocado/utils/build.py: add a configure utility function

The most common workflow when building software from source is to
configure the source, and then build it.  Avocado provides a utility
"make" function, but when users need to run "configure" or similar
scripts, there's no shortcut.

This introduces a configure script, which when used with no explicit
configure script name, will attempt to find a couple of suitable
scripts, but will forgive the source tree if one doesn't exist.

This allows test writers to use the following pattern:

   from avocado.utils import build
   build.configure("/path/to/src")
   build.make("/path/to/src")

And have successful results in most source code repositories.
Signed-off-by: NCleber Rosa <crosa@redhat.com>
上级 cc2bccc9
......@@ -18,6 +18,36 @@ import os
from . import process
def configure(path, configure=None):
"""
Configures the source tree for a subsequent build
Most source directories coming from official released tarballs
will have a "configure" script, but source code snapshots may have
"autogen.sh" instead (which usually creates and runs a "configure"
script itself). This function will attempt to run the first one
found (if a configure script name not given explicitly).
:param configure: the name of the configure script (None for trying to
find one automatically)
:type configure: str or None
:returns: the configure script exit status, or None if no script was
found and executed
"""
cwd = os.getcwd()
try:
os.chdir(path)
if configure is not None:
return process.run(os.path.join(path, configure)).exit_status
candidates = ['autogen.sh', 'configure']
for configure in candidates:
if os.access(configure, os.R_OK | os.X_OK):
return process.run(os.path.join(path, configure)).exit_status
finally:
os.chdir(cwd)
def run_make(path, make='make', extra_args='', process_kwargs=None):
"""
Run make, adding MAKEOPTS to the list of options.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册