tzupengwang | cd663c1 | 2016-08-26 16:28:55 +0800 | [diff] [blame] | 1 | # Copyright 2016 The Chromium OS Authors. All rights reserved. |
| 2 | # Distributed under the terms of the GNU General Public License v2 |
| 3 | |
| 4 | # @ECLASS: autotest-external-dep.eclass |
| 5 | # @MAINTAINER: |
| 6 | # ChromiumOS Build Team |
| 7 | # @AUTHOR: |
| 8 | # The Chromium OS Authors <chromium-os-dev@chromium.org> |
| 9 | # @BUGREPORTS: |
| 10 | # Please report bugs via http://crbug.com/new (with label Build) |
| 11 | # @VCSURL: https://chromium.googlesource.com/chromiumos/overlays/chromiumos-overlay/+/master/eclass/@ECLASS@ |
| 12 | # @BLURB: Eclass for handling minimal external autotest-dep packages |
| 13 | # @DESCRIPTION: |
| 14 | # Since all autotest dep package requires basic fake test during compile stage, |
| 15 | # each package needs a ${PACKAGE}.py for setup. However, we have many dep |
| 16 | # packages that simply fetches src from external packages and thus don't need |
| 17 | # additional setup. This eclass handles the common jobs that has to be done by |
| 18 | # these autotest-dep ebuilds. |
| 19 | |
| 20 | inherit autotest-deponly cros-constants |
| 21 | |
| 22 | # @ECLASS-VARIABLE: PACKAGE |
| 23 | # @DESCRIPTION: |
| 24 | # The name of the autotest-dep package being build. MUST be set by the |
| 25 | # inheriting ebuild. If empty, build fails. |
| 26 | |
| 27 | autotest-external-dep_src_prepare() { |
| 28 | # Check if PACKAGE is set, abort if not set. |
| 29 | [[ -z "${PACKAGE}" ]] && die "PACKAGE is not set" |
| 30 | # Use customized ${PACKAGE}.py if available, use default otherwise. |
| 31 | if [[ -e "${FILESDIR}/${PACKAGE}.py" ]]; then |
| 32 | cp "${FILESDIR}/${PACKAGE}.py" "${WORKDIR}/${PACKAGE}.py" || die |
| 33 | else |
| 34 | cat << EOF > "${WORKDIR}/${PACKAGE}.py" |
| 35 | import logging |
| 36 | import os |
| 37 | |
| 38 | # Setup autotest_lib path by importing common. |
| 39 | import common |
| 40 | from autotest_lib.client.bin import utils |
| 41 | |
| 42 | version = 1 |
| 43 | |
| 44 | def setup(setup_dir): |
| 45 | """ An empty setup function |
| 46 | @param setup_dir: the target directory |
| 47 | """ |
| 48 | logging.info('setup(%s)', setup_dir) |
| 49 | |
| 50 | pwd = os.getcwd() |
| 51 | utils.update_version(pwd, True, version, setup, pwd) |
| 52 | EOF |
| 53 | chmod a+x "${WORKDIR}/${PACKAGE}.py" |
| 54 | fi |
| 55 | } |
| 56 | |
| 57 | autotest-external-dep_src_compile() { |
| 58 | if [[ ! -e "${AUTOTEST_WORKDIR}/client/deps/${PACKAGE}" ]]; then |
| 59 | mkdir -p "${AUTOTEST_WORKDIR}/client/deps" |
| 60 | ln -s "${WORKDIR}" "${AUTOTEST_WORKDIR}/client/deps/${PACKAGE}" || die |
| 61 | fi |
| 62 | autotest_src_compile |
| 63 | if [[ -e "${ROOT}/${AUTOTEST_BASE}/client/deps/${PACKAGE}/.version" ]]; then |
| 64 | cp "${ROOT}/${AUTOTEST_BASE}/client/deps/${PACKAGE}/.version" "${WORKDIR}/" || die |
| 65 | fi |
| 66 | # Clean up autotest workdir which we don't need in final package. |
| 67 | rm -rf "${AUTOTEST_WORKDIR}" |
| 68 | } |
| 69 | |
| 70 | autotest-external-dep_src_install() { |
| 71 | insinto "${AUTOTEST_BASE}"/client/deps/${PACKAGE} |
| 72 | doins -r . |
| 73 | } |
| 74 | |
| 75 | EXPORT_FUNCTIONS src_prepare src_compile src_install |