diff options
Diffstat (limited to 'infra/nncc/command')
-rw-r--r-- | infra/nncc/command/build | 11 | ||||
-rw-r--r-- | infra/nncc/command/check-copyright | 62 | ||||
-rw-r--r-- | infra/nncc/command/configure | 10 | ||||
-rw-r--r-- | infra/nncc/command/docker-nncc | 10 | ||||
-rw-r--r-- | infra/nncc/command/docker-run | 10 | ||||
-rw-r--r-- | infra/nncc/command/docker-shell | 11 | ||||
-rw-r--r-- | infra/nncc/command/test | 13 |
7 files changed, 127 insertions, 0 deletions
diff --git a/infra/nncc/command/build b/infra/nncc/command/build new file mode 100644 index 000000000..86082c188 --- /dev/null +++ b/infra/nncc/command/build @@ -0,0 +1,11 @@ +#!/bin/bash + +import "build.configuration" + +BUILD_WORKSPACE_PATH="${NNCC_PROJECT_PATH}/${BUILD_WORKSPACE_RPATH}" + +if [[ ! -d "${BUILD_WORKSPACE_PATH}" ]]; then + echo "'${BUILD_WORKSPACE_RPATH}' does not exist. Please run 'configure' first" + exit 255 +fi +cd "${BUILD_WORKSPACE_PATH}" && cmake --build . -- "$@" diff --git a/infra/nncc/command/check-copyright b/infra/nncc/command/check-copyright new file mode 100644 index 000000000..b70785971 --- /dev/null +++ b/infra/nncc/command/check-copyright @@ -0,0 +1,62 @@ +#!/bin/bash + +# HOW TO USE +# +# Create .COPYRIGHT file at the root of your project (compiler/[PROJECT]/.COPYRIGHT) +# with the copyright pattern required for your project. +# +# echo "Copyright (c) [0-9]\+ Samsung Electronics Co., Ltd. All Rights Reserved" > compiler/[PROJECT]/.COPYRIGHT +# +# DISCLAIMER +# +# This check works only when your copyright notice is of the following form: +# +# /** +# * [Copyright notice] +# ... +# */ +# +# NOTE +# +# The current implementation does not validate YEAR in the copyright notice. +# +# TODO Validate YEAR without FALSE POSTIVIES +# +# It already turns out that checking the initial commit year introduces +# FALSE POSITIVES if there are relocated files. +INVALID_FILES=() + +for COPYRIGHT_PATH in $(ls ${NNCC_PROJECT_PATH}/compiler/*/.COPYRIGHT); do + PROJECT_PATH="$(dirname ${COPYRIGHT_PATH})" + PROJECT_NAME="$(basename ${PROJECT_PATH})" + + CANDIDATE_FILES=$(find "${PROJECT_PATH}" -iname '*.h' -o -iname '*.hpp' -o -iname '*.cpp' -o -iname '*.c') + + # Skip copyright check if there is no candidate files + # + # NOTE "git ls-files" with no argument will enumerate all the files in the repo + if [[ -z ${CANDIDATE_FILES} ]]; then + continue + fi + + for TRACKED_FILE in $(git ls-files $CANDIDATE_FILES); do + MATCHED=$(cat "${NNCC_PROJECT_PATH}/${TRACKED_FILE}" | head -n2 | tail -n1 | sed 's/^ \* //g' | grep -f "${COPYRIGHT_PATH}" | wc -l) + + if [[ ${MATCHED} -ne 1 ]]; then + INVALID_FILES+=(${TRACKED_FILE}) + fi + done +done + +if [[ ${#INVALID_FILES[@]} -ne 0 ]]; then + echo ">> FAILED <<" + echo + echo "PLEASE CHECK THE FOLLOWING FILES" + for INVALID_FILE in "${INVALID_FILES[@]}"; do + echo "- ${INVALID_FILE}" + done + exit 255 +fi + +echo ">> PASSED <<" +exit 0 diff --git a/infra/nncc/command/configure b/infra/nncc/command/configure new file mode 100644 index 000000000..2648cb893 --- /dev/null +++ b/infra/nncc/command/configure @@ -0,0 +1,10 @@ +#!/bin/bash + +import "build.configuration" + +BUILD_WORKSPACE_PATH="${NNCC_PROJECT_PATH}/${BUILD_WORKSPACE_RPATH}" + +mkdir -p "${BUILD_WORKSPACE_PATH}" + +cd "${BUILD_WORKSPACE_PATH}" +cmake "${NNCC_PROJECT_PATH}/infra/nncc" "$@" diff --git a/infra/nncc/command/docker-nncc b/infra/nncc/command/docker-nncc new file mode 100644 index 000000000..0eea016c6 --- /dev/null +++ b/infra/nncc/command/docker-nncc @@ -0,0 +1,10 @@ +#!/bin/bash + +import "docker.configuration" + +docker run $DOCKER_RUN_OPTS $DOCKER_ENV_VARS $DOCKER_VOLUMES $DOCKER_IMAGE_NAME ./nncc "$@" +EXITCODE=$? + +docker_cleanup + +exit $EXITCODE diff --git a/infra/nncc/command/docker-run b/infra/nncc/command/docker-run new file mode 100644 index 000000000..863b2b8f1 --- /dev/null +++ b/infra/nncc/command/docker-run @@ -0,0 +1,10 @@ +#!/bin/bash + +import "docker.configuration" + +docker run $DOCKER_RUN_OPTS $DOCKER_ENV_VARS $DOCKER_VOLUMES $DOCKER_IMAGE_NAME "$@" +EXITCODE=$? + +docker_cleanup + +exit $EXITCODE diff --git a/infra/nncc/command/docker-shell b/infra/nncc/command/docker-shell new file mode 100644 index 000000000..7f8449855 --- /dev/null +++ b/infra/nncc/command/docker-shell @@ -0,0 +1,11 @@ +#!/bin/bash + +import "docker.configuration" + +DOCKER_RUN_OPTS+=" -it" +docker run $DOCKER_RUN_OPTS $DOCKER_ENV_VARS $DOCKER_VOLUMES $DOCKER_IMAGE_NAME /bin/bash +EXITCODE=$? + +docker_cleanup + +exit $EXITCODE diff --git a/infra/nncc/command/test b/infra/nncc/command/test new file mode 100644 index 000000000..96ddd7a17 --- /dev/null +++ b/infra/nncc/command/test @@ -0,0 +1,13 @@ +#!/bin/bash + +import "build.configuration" + +BUILD_WORKSPACE_PATH="${NNCC_PROJECT_PATH}/${BUILD_WORKSPACE_RPATH}" + +if [[ ! -d "${BUILD_WORKSPACE_PATH}" ]]; then + echo "'${BUILD_WORKSPACE_RPATH}' does not exist. Please run 'configure' first" + exit 255 +fi + +export CTEST_OUTPUT_ON_FAILURE=1 +cd "${BUILD_WORKSPACE_PATH}" && ctest "$@" |