Import Mbed OS hard-float snapshot
This commit is contained in:
6
tools/test/travis-ci/doxy-spellchecker/en.dat
Normal file
6
tools/test/travis-ci/doxy-spellchecker/en.dat
Normal file
@@ -0,0 +1,6 @@
|
||||
name en
|
||||
charset iso8859-1
|
||||
soundslike en
|
||||
affix en
|
||||
special ' -*- 0 *** 1 *** 2 *** 3 *** 4 *** 5 *** 6 *** 7 *** 8 *** 9 *** < *** > *** _ ***
|
||||
#repl-table en_affix.dat
|
||||
226
tools/test/travis-ci/doxy-spellchecker/en_affix.dat
Normal file
226
tools/test/travis-ci/doxy-spellchecker/en_affix.dat
Normal file
@@ -0,0 +1,226 @@
|
||||
#
|
||||
# This affix file is based on Ispell, which is under the following
|
||||
# copyright:
|
||||
#
|
||||
# Copyright 1992, 1993, 1999, 2000, 2001, Geoff Kuenning, Claremont, CA
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions, and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions, and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. All modifications to the source code must be clearly marked as
|
||||
# such. Binary redistributions based on modified source code
|
||||
# must be clearly marked as modified versions in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
# (Clause 4 removed with permission from Geoff Kuenning.)
|
||||
# 5. The name of Geoff Kuenning may not be used to endorse or promote
|
||||
# products derived from this software without specific prior
|
||||
# written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY GEOFF KUENNING AND CONTRIBUTORS 'AS IS' AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL GEOFF KUENNING OR CONTRIBUTORS BE LIABLE
|
||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
# SUCH DAMAGE.
|
||||
#
|
||||
|
||||
SET ISO8859-1
|
||||
TRY esianrtolcdugmphbyfvkwzESIANRTOLCDUGMPHBYFVKWZ'
|
||||
|
||||
PFX A Y 1
|
||||
PFX A 0 re .
|
||||
|
||||
PFX I Y 1
|
||||
PFX I 0 in .
|
||||
|
||||
PFX U Y 1
|
||||
PFX U 0 un .
|
||||
|
||||
PFX C Y 1
|
||||
PFX C 0 de .
|
||||
|
||||
PFX E Y 1
|
||||
PFX E 0 dis .
|
||||
|
||||
PFX F Y 1
|
||||
PFX F 0 con .
|
||||
|
||||
PFX K Y 1
|
||||
PFX K 0 pro .
|
||||
|
||||
SFX V N 2
|
||||
SFX V e ive e
|
||||
SFX V 0 ive [^e]
|
||||
|
||||
SFX N Y 3
|
||||
SFX N e ion e
|
||||
SFX N y ication y
|
||||
SFX N 0 en [^ey]
|
||||
|
||||
SFX X Y 3
|
||||
SFX X e ions e
|
||||
SFX X y ications y
|
||||
SFX X 0 ens [^ey]
|
||||
|
||||
SFX H N 2
|
||||
SFX H y ieth y
|
||||
SFX H 0 th [^y]
|
||||
|
||||
SFX Y Y 1
|
||||
SFX Y 0 ly .
|
||||
|
||||
SFX G Y 2
|
||||
SFX G e ing e
|
||||
SFX G 0 ing [^e]
|
||||
|
||||
SFX J Y 2
|
||||
SFX J e ings e
|
||||
SFX J 0 ings [^e]
|
||||
|
||||
SFX D Y 4
|
||||
SFX D 0 d e
|
||||
SFX D y ied [^aeiou]y
|
||||
SFX D 0 ed [^ey]
|
||||
SFX D 0 ed [aeiou]y
|
||||
|
||||
SFX T N 4
|
||||
SFX T 0 st e
|
||||
SFX T y iest [^aeiou]y
|
||||
SFX T 0 est [aeiou]y
|
||||
SFX T 0 est [^ey]
|
||||
|
||||
SFX R Y 4
|
||||
SFX R 0 r e
|
||||
SFX R y ier [^aeiou]y
|
||||
SFX R 0 er [aeiou]y
|
||||
SFX R 0 er [^ey]
|
||||
|
||||
SFX Z Y 4
|
||||
SFX Z 0 rs e
|
||||
SFX Z y iers [^aeiou]y
|
||||
SFX Z 0 ers [aeiou]y
|
||||
SFX Z 0 ers [^ey]
|
||||
|
||||
SFX S Y 4
|
||||
SFX S y ies [^aeiou]y
|
||||
SFX S 0 s [aeiou]y
|
||||
SFX S 0 es [sxzh]
|
||||
SFX S 0 s [^sxzhy]
|
||||
|
||||
SFX P Y 3
|
||||
SFX P y iness [^aeiou]y
|
||||
SFX P 0 ness [aeiou]y
|
||||
SFX P 0 ness [^y]
|
||||
|
||||
SFX M Y 1
|
||||
SFX M 0 's .
|
||||
|
||||
SFX B Y 3
|
||||
SFX B 0 able [^aeiou]
|
||||
SFX B 0 able ee
|
||||
SFX B e able [^aeiou]e
|
||||
|
||||
SFX L Y 1
|
||||
SFX L 0 ment .
|
||||
|
||||
REP 88
|
||||
REP a ei
|
||||
REP ei a
|
||||
REP a ey
|
||||
REP ey a
|
||||
REP ai ie
|
||||
REP ie ai
|
||||
REP are air
|
||||
REP are ear
|
||||
REP are eir
|
||||
REP air are
|
||||
REP air ere
|
||||
REP ere air
|
||||
REP ere ear
|
||||
REP ere eir
|
||||
REP ear are
|
||||
REP ear air
|
||||
REP ear ere
|
||||
REP eir are
|
||||
REP eir ere
|
||||
REP ch te
|
||||
REP te ch
|
||||
REP ch ti
|
||||
REP ti ch
|
||||
REP ch tu
|
||||
REP tu ch
|
||||
REP ch s
|
||||
REP s ch
|
||||
REP ch k
|
||||
REP k ch
|
||||
REP f ph
|
||||
REP ph f
|
||||
REP gh f
|
||||
REP f gh
|
||||
REP i igh
|
||||
REP igh i
|
||||
REP i uy
|
||||
REP uy i
|
||||
REP i ee
|
||||
REP ee i
|
||||
REP j di
|
||||
REP di j
|
||||
REP j gg
|
||||
REP gg j
|
||||
REP j ge
|
||||
REP ge j
|
||||
REP s ti
|
||||
REP ti s
|
||||
REP s ci
|
||||
REP ci s
|
||||
REP k cc
|
||||
REP cc k
|
||||
REP k qu
|
||||
REP qu k
|
||||
REP kw qu
|
||||
REP o eau
|
||||
REP eau o
|
||||
REP o ew
|
||||
REP ew o
|
||||
REP oo ew
|
||||
REP ew oo
|
||||
REP ew ui
|
||||
REP ui ew
|
||||
REP oo ui
|
||||
REP ui oo
|
||||
REP ew u
|
||||
REP u ew
|
||||
REP oo u
|
||||
REP u oo
|
||||
REP u oe
|
||||
REP oe u
|
||||
REP u ieu
|
||||
REP ieu u
|
||||
REP ue ew
|
||||
REP ew ue
|
||||
REP uff ough
|
||||
REP oo ieu
|
||||
REP ieu oo
|
||||
REP ier ear
|
||||
REP ear ier
|
||||
REP ear air
|
||||
REP air ear
|
||||
REP w qu
|
||||
REP qu w
|
||||
REP z ss
|
||||
REP ss z
|
||||
REP shun tion
|
||||
REP shun sion
|
||||
REP shun cion
|
||||
1
tools/test/travis-ci/doxy-spellchecker/en_phonet.dat
Normal file
1
tools/test/travis-ci/doxy-spellchecker/en_phonet.dat
Normal file
@@ -0,0 +1 @@
|
||||
version 1.1
|
||||
120
tools/test/travis-ci/doxy-spellchecker/ignore.en.pws
Normal file
120
tools/test/travis-ci/doxy-spellchecker/ignore.en.pws
Normal file
@@ -0,0 +1,120 @@
|
||||
personal_ws-1.1 en 1600 utf-8
|
||||
_code_
|
||||
unconfigured
|
||||
mbed
|
||||
rtos
|
||||
malloc
|
||||
mutex
|
||||
tx
|
||||
rx
|
||||
wi
|
||||
fi
|
||||
rr
|
||||
sd
|
||||
pc
|
||||
vtable
|
||||
nmemb
|
||||
relloc
|
||||
printf
|
||||
arg
|
||||
scanf
|
||||
fclose
|
||||
fputs
|
||||
usb
|
||||
or'd
|
||||
MMmmpp
|
||||
multithread
|
||||
multithreaded
|
||||
initializer
|
||||
lookup
|
||||
startup
|
||||
unreferenced
|
||||
singleshot
|
||||
multishot
|
||||
inlined
|
||||
allocator
|
||||
parameterized
|
||||
XORed
|
||||
unbuffered
|
||||
sizeof
|
||||
stringification
|
||||
interoperability
|
||||
memcpy
|
||||
nack
|
||||
mbit
|
||||
retval
|
||||
dequeue
|
||||
assertation
|
||||
destructor
|
||||
destructors
|
||||
constructor
|
||||
constructors
|
||||
ctor
|
||||
dtor
|
||||
dereference
|
||||
ptr
|
||||
templated
|
||||
templatize
|
||||
accessor
|
||||
init
|
||||
deleters
|
||||
decrement
|
||||
increment
|
||||
deinitialize
|
||||
deinitializes
|
||||
atomicity
|
||||
pointee
|
||||
entrancy
|
||||
Systick
|
||||
noop
|
||||
deassert
|
||||
deasserts
|
||||
deasserted
|
||||
getter
|
||||
setter
|
||||
preallocated
|
||||
excludable
|
||||
ascii
|
||||
IPv
|
||||
param
|
||||
struct
|
||||
typedef
|
||||
typedefs
|
||||
onboard
|
||||
enum
|
||||
endian
|
||||
emac
|
||||
emacs
|
||||
json
|
||||
noncopyable
|
||||
sendto
|
||||
gethostbyname
|
||||
multicast
|
||||
multicasts
|
||||
singleshot
|
||||
multishot
|
||||
sa
|
||||
tparam
|
||||
retarget
|
||||
TCPSocket
|
||||
UDPSocket
|
||||
Socket
|
||||
unregister
|
||||
deinit
|
||||
auth
|
||||
pppapi
|
||||
pbuf
|
||||
nak
|
||||
reqs
|
||||
xmit
|
||||
pppd
|
||||
pppdebug
|
||||
ppp
|
||||
api
|
||||
uart
|
||||
chrono
|
||||
Hinnant
|
||||
Vin
|
||||
Vref
|
||||
ssid
|
||||
_doxy_
|
||||
126
tools/test/travis-ci/doxy-spellchecker/spell.sh
Normal file
126
tools/test/travis-ci/doxy-spellchecker/spell.sh
Normal file
@@ -0,0 +1,126 @@
|
||||
#!/bin/bash -eu
|
||||
# mbed Microcontroller Library
|
||||
# Copyright (c) 2018 ARM Limited
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
set -o pipefail
|
||||
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
|
||||
ERRORS=0
|
||||
|
||||
# Loops use here strings to allow them to run in the main shell and modify the correct version of
|
||||
# the error counter global variable
|
||||
while read file; do
|
||||
echo "${file}"
|
||||
res=$(awk '/\/\*\*/,/\*\//' "${file}" | cut -d '/' -f2 | sed 's/0x[^ ]*//' | sed 's/[0-9]*//g')
|
||||
|
||||
# Select a token to begin on, then a formating option such as strip all text between the start
|
||||
# and end token, strip an entire line containing the start token, or strip a portion of a line
|
||||
# containing the start token. Select an appropiate end token. The tokens and formats are index
|
||||
# matched.
|
||||
start_tokens=( "/@code"
|
||||
"/addtogroup"
|
||||
"ingroup"
|
||||
"defgroup"
|
||||
"<"
|
||||
"()"
|
||||
)
|
||||
|
||||
formats=( 'strip_between'
|
||||
'strip_between'
|
||||
'strip_line'
|
||||
'strip_line'
|
||||
'strip_between_sameline'
|
||||
'strip_token'
|
||||
)
|
||||
|
||||
end_tokens=( "/@endcode"
|
||||
"/\*"
|
||||
""
|
||||
""
|
||||
">"
|
||||
""
|
||||
)
|
||||
|
||||
# Stripping strings between tokens P1-P2 and P3-P4 inclusively ran into issues depending
|
||||
# on if the tokens were on the same line or not.
|
||||
#_________________________________________
|
||||
# Don't remove this P1 remove me P2
|
||||
# Keep me
|
||||
# P3
|
||||
# Remove me too please
|
||||
# P4
|
||||
# Keep me too
|
||||
# Still here P1 But this shouldn't be P2
|
||||
#_________________________________________
|
||||
#
|
||||
# Opted for having two separate formats. In particular this formatting issue came up when
|
||||
# trying to strip the code segments and template type arguments between '<, >' as the multiline
|
||||
# sed command would strip the entire line, causing the removal string to span across the entire file
|
||||
# when trying to match the next end token (above format when stripping everything between P1 and P2
|
||||
# would end up with just "Don't remove this" and the rest of the file stripped).
|
||||
|
||||
for ((i=0;i<${#start_tokens[@]};++i)); do
|
||||
filter=""
|
||||
if [[ "${formats[i]}" == 'strip_between' ]]; then
|
||||
filter=$(<<< "${res}" sed "${start_tokens[i]}/,${end_tokens[i]}/d")
|
||||
elif [[ "${formats[i]}" == 'strip_between_sameline' ]]; then
|
||||
filter=$(<<< "${res}" sed -e "s/"${start_tokens[i]}".*"${end_tokens[i]}"//")
|
||||
elif [[ "${formats[i]}" == 'strip_line' ]]; then
|
||||
filter=$(<<< "${res}" sed "/"${start_tokens[i]}"/ d")
|
||||
elif [[ "${formats[i]}" == 'strip_token' ]]; then
|
||||
filter=$(<<< "${res}" sed "s/"${start_tokens[i]}"//g")
|
||||
fi
|
||||
|
||||
if [ "${filter}" != "" ]; then
|
||||
res=${filter}
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "${2:-}" == "-vv" ]; then
|
||||
echo "${res}"
|
||||
fi
|
||||
|
||||
prev_err=("")
|
||||
while read err; do
|
||||
if [ $(echo "${res}" | grep "${err}" | wc -l) -eq $(grep "${err}" "${file}" | wc -l) ]; then
|
||||
# Do not count all caps words as errors (RTOS, WTI, etc) or plural versions (APNs/MTD's)
|
||||
if ! [[ ${err} =~ ^[A-Z]+$ || ${err} =~ ^[A-Z]+s$ || ${err} =~ ^[A-Z]+\'s$ ]]; then
|
||||
|
||||
# Disregard camelcase/underscored words. Hex was stripped at the beginning
|
||||
if ! echo "${err}" | grep --quiet -E '[a-z]{1,}[A-Z]|_'; then
|
||||
|
||||
# The grep command to fetch the line numbers will report all instances, do not
|
||||
# list repeated error words found from aspell in each file
|
||||
if ! [[ ${prev_err[*]} =~ "${err}" ]]; then
|
||||
prev_err+=("${err}")
|
||||
|
||||
if [ ${#prev_err[@]} -eq 2 ]; then
|
||||
echo "================================="
|
||||
echo "Errors: "
|
||||
fi
|
||||
|
||||
while read ln; do
|
||||
echo "${ln} ${err}"
|
||||
ERRORS=$((ERRORS + 1))
|
||||
done <<< "$(grep -n "${err}" "${file}" | cut -d ' ' -f1)"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done <<< "$(echo "${res}" | aspell list -C --ignore-case -p "${DIR}"/ignore.en.pws --local-data-dir "${DIR}")"
|
||||
|
||||
if [ ${#prev_err[@]} -ne 1 ]; then
|
||||
echo "_________________________________"
|
||||
fi
|
||||
|
||||
done < <(find "${1}" -type d -iname "*target*" -prune -o -name '*.h' -print)
|
||||
|
||||
echo "----------------------------------------------------------------------------------"
|
||||
echo "Total Errors Found: ${ERRORS}"
|
||||
|
||||
if [ ${ERRORS} -ne 0 ]; then
|
||||
echo "If any of the failed words should be considered valid please add them to the ignore.en.pws file"\
|
||||
"found in tools/test/travis-ci/doxy-spellchecker between the _code_ and _doxy_ tags."
|
||||
exit 1
|
||||
fi
|
||||
196
tools/test/travis-ci/functions.sh
Normal file
196
tools/test/travis-ci/functions.sh
Normal file
@@ -0,0 +1,196 @@
|
||||
#!/bin/bash -euf
|
||||
#
|
||||
# Copyright (c) 2013-2018 Arm Limited. All rights reserved.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
# not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
set -o pipefail
|
||||
|
||||
|
||||
#
|
||||
# Helper functions for printing status information.
|
||||
# Uses 'echo' instead of 'printf' due to Travis CI stdout sync issues.
|
||||
#
|
||||
info() { echo -e "I: ${1}"; }
|
||||
die() { echo -e "E: ${1}" 1>&2; exit "${2:-1}"; }
|
||||
|
||||
|
||||
#
|
||||
# Sets the GitHub job status for a given commit.
|
||||
#
|
||||
set_status()
|
||||
{
|
||||
local job_name="${NAME}"
|
||||
local payload=""
|
||||
|
||||
payload=$(<<< "
|
||||
{
|
||||
'state': '${1}',
|
||||
'description': '${2}',
|
||||
'context': 'travis-ci/${job_name}',
|
||||
'target_url': 'https://travis-ci.org/${TRAVIS_REPO_SLUG}/jobs/${TRAVIS_JOB_ID}'
|
||||
}" tr "'" '"')
|
||||
|
||||
curl --silent --output /dev/null --user "${MBED_BOT}" --request POST \
|
||||
"https://api.github.com/repos/${TRAVIS_REPO_SLUG}/statuses/${TRAVIS_PULL_REQUEST_SHA:-${TRAVIS_COMMIT}}" \
|
||||
--data @- <<< "${payload}"
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# Sources a pre-compiled GCC installation from AWS, installing the archive by
|
||||
# extracting and prepending the executable directory to PATH.
|
||||
#
|
||||
# Note: Expects 'deps_url' and 'deps_dir' to already be defined.
|
||||
#
|
||||
_install_gcc()
|
||||
{
|
||||
# Ignore shellcheck warnings: Variables defined in .travis.yml
|
||||
# shellcheck disable=SC2154
|
||||
local url="${deps_url}/gcc6-linux.tar.bz2"
|
||||
|
||||
# shellcheck disable=SC2154
|
||||
local gcc_path="${deps_dir}/gcc/gcc-arm-none-eabi-6-2017-q2-update/"
|
||||
|
||||
local archive="gcc.tar.bz2"
|
||||
|
||||
info "URL: ${url}"
|
||||
|
||||
if [ ! -d "${deps_dir}/gcc" ]; then
|
||||
|
||||
info "Downloading archive"
|
||||
curl --location "${url}" --output "${deps_dir}/${archive}"
|
||||
ls -al "${deps_dir}"
|
||||
|
||||
info "Extracting 'gcc'"
|
||||
mkdir -p "${deps_dir}/gcc"
|
||||
tar -xf "${deps_dir}/${archive}" -C "${deps_dir}/gcc"
|
||||
rm "${deps_dir}/${archive}"
|
||||
|
||||
fi
|
||||
|
||||
info "Installing 'gcc'"
|
||||
export "PATH=${gcc_path}/bin:${PATH}"
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# Downloads a list of packages from AWS, really fast.
|
||||
#
|
||||
_fetch_deps()
|
||||
{
|
||||
local pkg="${1}"
|
||||
local dep_list="${2}"
|
||||
local pid_list=""
|
||||
|
||||
local PID;
|
||||
|
||||
info "Fetching '${pkg}' archives"
|
||||
|
||||
while read -r dep; do
|
||||
|
||||
curl --location "${deps_url}/${dep}.deb" \
|
||||
--output "${deps_dir}/${dep}.deb" \
|
||||
|| die "Download failed ('${dep}')" \
|
||||
&& info "Fetched ${deps_url}/${dep}.deb" &
|
||||
|
||||
PID=$!
|
||||
pid_list="${pid_list} ${PID}"
|
||||
|
||||
done <<< "${dep_list}"
|
||||
|
||||
# Ignoring shellcheck warning, since we need to allow parameter expansion to
|
||||
# turn the list string into parametesr.
|
||||
# shellcheck disable=SC2086
|
||||
wait ${pid_list}
|
||||
|
||||
info "Fetch completed."
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# Installs a list of Debian packages, fetching them if not locally found.
|
||||
#
|
||||
_install_deps()
|
||||
{
|
||||
local pkg="${1}"
|
||||
local dep_list="${2}"
|
||||
local first_dep=""
|
||||
|
||||
# Assume that if the first package isn't cached, none are.
|
||||
first_dep=$(<<< "${dep_list}" head -n1)
|
||||
[ ! -f "${deps_dir}/${first_dep}.deb" ] && _fetch_deps "${pkg}" "${dep_list}"
|
||||
|
||||
# Install dependencies
|
||||
info "Installing '${pkg}' packages"
|
||||
|
||||
# Ignore shellcheck warnings: Word splitting is specifically used to build
|
||||
# command in one go, and expression non-expansion
|
||||
# is intentional.
|
||||
# shellcheck disable=SC2046 disable=SC2016
|
||||
sudo dpkg -i $(<<< "${dep_list}" sed -e 's_^ *__' -e 's_^\(.*\)$_'"${deps_dir}"'/\1.deb_' | tr $'\n' ' ')
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# Wrapper for installing a given package.
|
||||
#
|
||||
source_pkg()
|
||||
{
|
||||
# Debian dependencies needed for a single package.
|
||||
local aspell_deps="aspell
|
||||
aspell-en
|
||||
dictionaries-common
|
||||
libaspell15"
|
||||
|
||||
local libfuse_deps="libfuse-dev
|
||||
libpcre3-dev
|
||||
libpcre32-3
|
||||
libpcrecpp0v5
|
||||
libselinux1-dev
|
||||
libsepol1-dev
|
||||
libc-bin"
|
||||
|
||||
local pkg="${1}"
|
||||
|
||||
case "${pkg}" in
|
||||
|
||||
"fuse" )
|
||||
# 'fuse' does not require an 'apt-get update' to install in Travis CI, so
|
||||
# there's no reason to upload it or its dependencies into AWS.
|
||||
sudo apt-get -o=dir::cache="${deps_dir}/apt-get" install fuse \
|
||||
|| die "Installation failed"
|
||||
;;
|
||||
|
||||
"aspell" )
|
||||
_install_deps aspell "${aspell_deps}" \
|
||||
|| die "Installation failed"
|
||||
;;
|
||||
"libfuse-dev" )
|
||||
_install_deps libfuse-dev "${libfuse_deps}" \
|
||||
|| die "Installation failed"
|
||||
;;
|
||||
|
||||
"gcc" )
|
||||
_install_gcc \
|
||||
|| die "Installation failed"
|
||||
;;
|
||||
|
||||
* )
|
||||
die "Package not supported: '${pkg}'"
|
||||
;;
|
||||
|
||||
esac
|
||||
}
|
||||
133
tools/test/travis-ci/scancode-evaluate.py
Normal file
133
tools/test/travis-ci/scancode-evaluate.py
Normal file
@@ -0,0 +1,133 @@
|
||||
"""
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
Copyright (c) 2020 Arm Limited. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations
|
||||
"""
|
||||
|
||||
# Asumptions for this script:
|
||||
# 1. directory_name is scanned directory.
|
||||
# Files are copied to this directory with full tree. As result, if we find
|
||||
# license offender, we can have full path (just scrape directory_name). We do this
|
||||
# magic because scancode allows to scan directories/one file.
|
||||
# 2. SPDX and license text is a must for all code files
|
||||
|
||||
import json
|
||||
import argparse
|
||||
import sys
|
||||
import os.path
|
||||
import logging
|
||||
import re
|
||||
|
||||
userlog = logging.getLogger("scancode-evaluate")
|
||||
userlog.setLevel(logging.INFO)
|
||||
logfile = os.path.join(os.getcwd(), 'scancode-evaluate.log')
|
||||
log_file_handler = logging.FileHandler(logfile, mode='w')
|
||||
userlog.addHandler(log_file_handler)
|
||||
|
||||
MISSING_LICENSE_TEXT = "Missing license header"
|
||||
MISSING_PERMISIVE_LICENSE_TEXT = "Non-permissive license"
|
||||
MISSING_SPDX_TEXT = "Missing SPDX license identifier"
|
||||
|
||||
def license_check(directory_name, file):
|
||||
""" Check licenses in the scancode json file for specified directory
|
||||
|
||||
This function does not verify if file exists, should be done prior the call.
|
||||
|
||||
Args:
|
||||
directory_name - where scancode was run, used to scrape this from paths
|
||||
file - scancode json output file (output from scancode --license --json-pp)
|
||||
|
||||
Returns:
|
||||
0 if nothing found
|
||||
>0 - count how many license isses found
|
||||
-1 if any error in file licenses found
|
||||
"""
|
||||
|
||||
offenders = []
|
||||
try:
|
||||
# find all licenses in the files, must be licensed and permissive
|
||||
with open(file, 'r') as scancode_output:
|
||||
results = json.load(scancode_output)
|
||||
except ValueError:
|
||||
userlog.warning("JSON could not be decoded")
|
||||
return -1
|
||||
|
||||
try:
|
||||
for file in results['files']:
|
||||
license_offender = {}
|
||||
license_offender['file'] = file
|
||||
# ignore directory, not relevant here
|
||||
if license_offender['file']['type'] == 'directory':
|
||||
continue
|
||||
if not license_offender['file']['licenses']:
|
||||
license_offender['reason'] = MISSING_LICENSE_TEXT
|
||||
offenders.append(license_offender)
|
||||
continue
|
||||
|
||||
found_spdx = False
|
||||
for i in range(len(license_offender['file']['licenses'])):
|
||||
if license_offender['file']['licenses'][i]['category'] != 'Permissive':
|
||||
license_offender['reason'] = MISSING_PERMISIVE_LICENSE_TEXT
|
||||
offenders.append(license_offender)
|
||||
# find SPDX, it shall be one of licenses found
|
||||
if license_offender['file']['licenses'][i]['matched_rule']['identifier'].find("spdx") != -1:
|
||||
found_spdx = True
|
||||
|
||||
if not found_spdx:
|
||||
try:
|
||||
# Issue reported here https://github.com/nexB/scancode-toolkit/issues/1913
|
||||
# We verify here if SPDX is not really there as SDPX is part of the license text
|
||||
# scancode has some problems detecting it properly
|
||||
with open(os.path.join(os.path.abspath(license_offender['file']['path'])), 'r') as spdx_file_check:
|
||||
filetext = spdx_file_check.read()
|
||||
matches = re.findall("SPDX-License-Identifier:?", filetext)
|
||||
if matches:
|
||||
continue
|
||||
license_offender['reason'] = MISSING_SPDX_TEXT
|
||||
offenders.append(license_offender)
|
||||
except UnicodeDecodeError:
|
||||
# not valid file for license check
|
||||
continue
|
||||
except KeyError:
|
||||
userlog.warning("Invalid scancode json file")
|
||||
return -1
|
||||
|
||||
if offenders:
|
||||
userlog.warning("Found files with missing license details, please review and fix")
|
||||
for offender in offenders:
|
||||
userlog.warning("File: " + offender['file']['path'][len(directory_name):] + " " + "reason: " + offender['reason'])
|
||||
return len(offenders)
|
||||
|
||||
def parse_args():
|
||||
parser = argparse.ArgumentParser(
|
||||
description="License check.")
|
||||
parser.add_argument('-f', '--file',
|
||||
help="scancode-toolkit output json file")
|
||||
parser.add_argument('-d', '--directory_name', default="SCANCODE",
|
||||
help='Directory name where are files being checked')
|
||||
return parser.parse_args()
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
args = parse_args()
|
||||
if args.file and os.path.isfile(args.file):
|
||||
count = license_check(args.directory_name, args.file)
|
||||
if count == 0:
|
||||
sys.exit(0)
|
||||
else:
|
||||
sys.exit(-1)
|
||||
else:
|
||||
userlog.warning("Could not find the scancode json file")
|
||||
sys.exit(-1)
|
||||
Reference in New Issue
Block a user