Add better support for proper installation after build (#2370)

- Add `--install` option to `tools/build.py`.
- Make use of `--install` in `tools/run-tests.py` by testing the
  installed the executables instead of those in the build tree.

Related changes:
- Collect unit test binaries in the `tests` subdir of the build
  tree instead of `bin`.
- The `ls`-based collection of the unit test binaries had some
  shortcomings hitherto unrevealed (it didn't filter for files so
  it could potentially "collect" dictionaries, too), which has now
  been replaced with a more stable `find`-based solution.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
This commit is contained in:
Akos Kiss
2018-06-04 03:55:29 +02:00
committed by yichoi
parent 2cabb6f8ea
commit 71471a0416
9 changed files with 41 additions and 26 deletions
+20 -5
View File
@@ -68,6 +68,8 @@ def get_arguments():
help='enable error messages (%(choices)s; default: %(default)s)')
parser.add_argument('--external-context', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper,
help='enable external context (%(choices)s; default: %(default)s)')
parser.add_argument('--install', metavar='DIR', nargs='?', default=None, const=False,
help='install after build (default: don\'t install; default directory if install: OS-specific)')
parser.add_argument('-j', '--jobs', metavar='N', action='store', type=int, default=multiprocessing.cpu_count() + 1,
help='Allowed N build jobs at once (default: %(default)s)')
parser.add_argument('--jerry-cmdline', metavar='X', choices=['ON', 'OFF'], default='ON', type=str.upper,
@@ -206,18 +208,27 @@ def configure_output_dir(arguments):
if not os.path.exists(arguments.builddir):
os.makedirs(arguments.builddir)
def configure_build(arguments):
def configure_jerry(arguments):
configure_output_dir(arguments)
build_options = generate_build_options(arguments)
cmake_cmd = ['cmake', '-B' + arguments.builddir, '-H' + settings.PROJECT_DIR]
if arguments.install:
cmake_cmd.append('-DCMAKE_INSTALL_PREFIX=%s' % arguments.install)
cmake_cmd.extend(build_options)
return subprocess.call(cmake_cmd)
def build_jerry(arguments):
return subprocess.call(['make', '--no-print-directory', '-j', str(arguments.jobs), '-C', arguments.builddir])
def make_jerry(arguments, target=None):
make_cmd = ['make', '--no-print-directory', '-j', str(arguments.jobs), '-C', arguments.builddir]
if target:
make_cmd.append(target)
return subprocess.call(make_cmd)
def print_result(ret):
print('=' * 30)
@@ -229,10 +240,14 @@ def print_result(ret):
def main():
arguments = get_arguments()
ret = configure_build(arguments)
ret = configure_jerry(arguments)
if not ret:
ret = build_jerry(arguments)
ret = make_jerry(arguments)
if not ret and arguments.install is not None:
ret = make_jerry(arguments, 'install')
print_result(ret)
sys.exit(ret)
+5 -2
View File
@@ -206,6 +206,9 @@ def create_binary(job, options):
build_dir_path = os.path.join(options.outdir, job.name)
build_cmd.append('--builddir=%s' % build_dir_path)
install_dir_path = os.path.join(build_dir_path, 'local')
build_cmd.append('--install=%s' % install_dir_path)
if options.toolchain:
build_cmd.append('--toolchain=%s' % options.toolchain)
@@ -227,7 +230,7 @@ def create_binary(job, options):
return ret, build_dir_path
def get_binary_path(build_dir_path):
return os.path.join(build_dir_path, 'bin', 'jerry')
return os.path.join(build_dir_path, 'local', 'bin', 'jerry')
def hash_binary(bin_path):
blocksize = 65536
@@ -388,7 +391,7 @@ def run_unittests(options):
ret_test |= run_check([
settings.UNITTEST_RUNNER_SCRIPT,
os.path.join(build_dir_path, 'bin'),
os.path.join(build_dir_path, 'tests'),
"-q" if options.quiet else "",
])
+2 -2
View File
@@ -29,8 +29,8 @@ UNITTEST_OK=$DIR/unittests.passed
rm -f $UNITTEST_ERROR $UNITTEST_OK
UNITTESTS=$(ls $DIR/unit-*)
total=$(ls $DIR/unit-* | wc -l)
UNITTESTS=$(find $DIR -maxdepth 1 -type f -name 'unit-*')
total=$(find $DIR -maxdepth 1 -type f -name 'unit-*' | wc -l)
if [ "$total" -eq 0 ]
then