From d5845873276f142f785cab0d3489209b3a4980ab Mon Sep 17 00:00:00 2001 From: Martin Nowack Date: Mon, 14 Sep 2020 12:10:14 +0100 Subject: Replace travis container build script with python-based version --- scripts/build/build-travis-container.py | 64 ++++++++++++++++++++++++++++++++ scripts/build/build-travis-containers.sh | 64 -------------------------------- 2 files changed, 64 insertions(+), 64 deletions(-) create mode 100755 scripts/build/build-travis-container.py delete mode 100755 scripts/build/build-travis-containers.sh (limited to 'scripts/build') diff --git a/scripts/build/build-travis-container.py b/scripts/build/build-travis-container.py new file mode 100755 index 00000000..d2baf4a9 --- /dev/null +++ b/scripts/build/build-travis-container.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python3 + +import yaml +import subprocess +import os + +(abs_path, _) = os.path.split(os.path.abspath(__file__)) + +with open(os.path.join(abs_path,"../../.travis.yml"), 'r') as stream: + try: + travis_config = yaml.safe_load(stream) + global_env = travis_config['env']['global'] + for job in travis_config['jobs']['include']: + if job['name'] in ["Docker", "macOS"]: + print("Skip: {}".format(job['name'])) + continue + print("Building: {}".format(job['name'])) + + + # Copy current environment + build_env = os.environ.copy() + + build_vars = {} + # Setup global build variables + for e in global_env: + (k,v) = e.split("=") + build_vars[k] = v + + # Override with job specific values + for e in job['env'].strip("").split(" "): + (k,v) = e.split("=") + build_vars[k] = v + + for k,v in build_vars.items(): + build_env[k] = v + + cmd = [os.path.join(abs_path, 'build.sh'), + 'klee', # build KLEE and all its dependencies + '--docker', # using docker containers + '--push-docker-deps', # push containers if possible + '--debug', # print debug output + '--create-final-image', # assume KLEE is the final image + ] + + env_str = [k+"="+v for (k,v) in build_vars.items()] + print("{} {}".format(" ".join(env_str)," ".join(cmd)) ) + + process = subprocess.Popen(cmd, # Assume KLEE is the final image + stdout=subprocess.PIPE, + universal_newlines=True, + env = build_env) + + while True: + output = process.stdout.readline() + print(output.strip()) + return_code = process.poll() + if return_code is not None: + print('Building image failed: {}'.format(return_code)) + for output in process.stdout.readlines(): + print(output.strip()) + break + + except yaml.YAMLError as exc: + print(exc) \ No newline at end of file diff --git a/scripts/build/build-travis-containers.sh b/scripts/build/build-travis-containers.sh deleted file mode 100755 index fe80e29f..00000000 --- a/scripts/build/build-travis-containers.sh +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/bash -# Build all the docker containers utilized, that would be -# also build by TravisCI. -# -# Every line starting with " - LLVM_VERSION=" is a single setup - -set -e -#set -x -DIR="$(cd "$(dirname "$0")" && pwd)" - -trim() { - local var="$*" - # remove leading whitespace characters - var="${var#"${var%%[![:space:]]*}"}" - # remove trailing whitespace characters - var="${var%"${var##*[![:space:]]}"}" - echo -n "$var" -} - -# Build dependencies only -isGlobal=0 -isEnv=0 -commons=() -experiments=() -while read -r line -do - [[ "${line}" == "env:"* ]] && isEnv=1 && continue - [[ "${line}" == "#stop"* ]] && isEnv=0 && break - - - [[ "${isEnv}" -eq 0 ]] && continue - - line="$(trim "${line}")" - - # Ignore empty lines - [[ -z "${line}" ]] && continue - [[ "${line}" == "#"* ]] && continue - - [[ "${line}" == "global:"* ]] && isGlobal=1 && continue - [[ "${line}" == "matrix:"* ]] && isGlobal=0 && continue - - - - if [[ "${isGlobal}" -eq 1 ]]; then - tmp="${line#*-}" - IFS=: read -r key value <<< "${tmp}" - key=$(trim "${key}") - [[ "${key}" == "secure" ]] && continue - [[ -z "${key}" ]] && continue - commons+=("${key}=$(trim "${value}")") - continue - fi - - experiment=$(echo "$line"| grep "\- " | xargs -L 1 | cut -d "-" -f 2) - if [[ "x$experiment" == "x" ]]; then - continue - fi - experiments+=("${experiment}") -done < "${DIR}/../../.travis.yml" - -for experiment in "${experiments[@]}"; do - [[ -z "${experiment}" ]] && continue - /bin/bash -c "${commons[*]} ${experiment} ${DIR}/build.sh klee --docker --push-docker-deps --debug --create-final-image" -done \ No newline at end of file -- cgit 1.4.1