Commit 35366b83 authored by Fabian Müller's avatar Fabian Müller
Browse files

Port remaining build jobs

parent 6262626c
Loading
Loading
Loading
Loading
Loading
+39 −1
Original line number Diff line number Diff line
@@ -119,6 +119,13 @@ stages:
    echo "Commit time was $CI_COMMIT_TIMESTAMP"
    date | xargs echo "System time is"

.print-common-info-windows: &print-common-info-windows
  - |
    echo "Printing common information for build job."
    echo "Current job is run on commit $CI_COMMIT_SHA"
    echo "Commit time was $CI_COMMIT_TIMESTAMP"
    ("echo 'System time is'", "Get-Date -Format 'dddd dd/MM/yyyy HH:mm K'") | Invoke-Expression

.disable-debugging-macro: &disable-debugging-macro
  # automatically disable #DEBUGGING macro in options.h using /**/-comment
  - sed -i.bak -e "s/^[[:space:]]*\(#define[[:space:]]*DEBUGGING\)/\/\*\1\*\//g" lib_com/options.h
@@ -216,6 +223,10 @@ stages:
.activate-Werror-linux: &activate-Werror-linux
  - sed -i.bak "s/^# \(CFLAGS += -Werror\)/\1/" Makefile

.activate-WX-windows: &activate-WX-windows
  - (Get-Content -Path "CMakeLists.txt") -replace '# \(add_compile_options\("\/WX"\)\)', '$1' | Set-Content -Path "CMakeLists.txt"
  - Get-ChildItem -Path "Workspace_msvc" -Filter "*.vcxproj" | ForEach-Object { (Get-Content -Path $_.FullName) -replace '<TreatWarningAsError>false', '<TreatWarningAsError>true' | Set-Content -Path $_.FullName }

.rules-pytest-to-ref-short:
  rules:
    - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "pytest-compare"
@@ -326,6 +337,14 @@ stages:
  tags:
    - ivas-basop-linux

.build-job-windows:
  stage: build
  needs: []
  timeout: "4 minutes"
  tags:
    # TODO: set up ivas-basop-windows runners
    - ivas-windows

# template for test jobs on linux that need the TESTV_DIR
.test-job-linux-needs-testv-dir:
  extends: .test-job-linux
@@ -775,7 +794,7 @@ build-codec-linux-instrumented-make:
  rules:
    - if: $CI_PIPELINE_SOURCE == 'web'
    - if: $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main" # only have MR pipelines for MRs to main
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
    - if: $CI_PIPELINE_SOURCE == 'schedule'
    - if: $CI_PIPELINE_SOURCE == 'push'
      when: never
@@ -788,6 +807,25 @@ build-codec-linux-instrumented-make:
    - bash scripts/prepare_instrumentation.sh -m MEM_ONLY -p BASOP
    - make -j -C $INSTR_DIR

# make sure that the codec builds with msan, asan and usan
build-codec-sanitizers-linux:
  extends:
    - .build-job-linux
    - .rules-basis
  script:
    - *print-common-info
    - *activate-Werror-linux
    - bash ci/build_codec_sanitizers_linux.sh

build-codec-windows-msbuild:
  extends:
    - .build-job-windows
    - .rules-basis
  script:
    - *print-common-info-windows
    - *activate-WX-windows
    - MSBuild.exe -maxcpucount .\Workspace_msvc\Workspace_msvc.sln /property:Configuration=Debug

# ---------------------------------------------------------------
# Short test jobs that run in merge request pipelines
# ---------------------------------------------------------------
+43 −0
Original line number Diff line number Diff line
#! /usr/bin/bash

# (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
# Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
# Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
# Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
# contributors to this repository. All Rights Reserved.

# This software is protected by copyright law and by international treaties.
# The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
# Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
# Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
# Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
# contributors to this repository retain full ownership rights in their respective contributions in
# the software. This notice grants no license of any kind, including but not limited to patent
# license, nor is any license granted by implication, estoppel or otherwise.

# Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
# contributions.

# This software is provided "AS IS", without any express or implied warranties. The software is in the
# development stage. It is intended exclusively for experts who have experience with such software and
# solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
# and fitness for a particular purpose are hereby disclaimed and excluded.

# Any dispute, controversy or claim arising under or in relation to providing this software shall be
# submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
# accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
# the United Nations Convention on Contracts on the International Sales of Goods.

if [ ! -d "lib_com" ]; then
    echo "not in root directory! - please run in IVAS root"
    exit 1
fi

# CI linux container would do this, can stay commented if clang (v13) is in your path
#PATH=$PATH:/usr/lib/llvm-13/bin
make clean
make CLANG=1 -j
make clean
make CLANG=2 -j
make clean
make CLANG=3 -j
+207 −0
Original line number Diff line number Diff line
#!/bin/bash

#
#   (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
#   Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
#   Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
#   Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
#   contributors to this repository. All Rights Reserved.
#
#   This software is protected by copyright law and by international treaties.
#   The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
#   Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
#   Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
#   Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
#   contributors to this repository retain full ownership rights in their respective contributions in
#   the software. This notice grants no license of any kind, including but not limited to patent
#   license, nor is any license granted by implication, estoppel or otherwise.
#
#   Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
#   contributions.
#
#   This software is provided "AS IS", without any express or implied warranties. The software is in the
#   development stage. It is intended exclusively for experts who have experience with such software and
#   solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
#   and fitness for a particular purpose are hereby disclaimed and excluded.
#
#   Any dispute, controversy or claim arising under or in relation to providing this software shall be
#   submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
#   accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
#   the United Nations Convention on Contracts on the International Sales of Goods.
#

function usage {
    echo
    echo "Usage:"
    echo "      $(basename $0) [OPTIONS]"
    echo 
    echo "      -m MODE    one of [FULL|MEM_ONLY]"
    echo "      -p PROJECT one of [FLOAT|BASOP]"
    exit
}


# default values
MODE="FULL"
PROJECT="FLOAT"

while getopts "m:p:h" OPTIONS; do
    case ${OPTIONS} in
    m)
        MODE=${OPTARG^^}
        if [ "$MODE" != "FULL" -a "$MODE" != "MEM_ONLY" ]; then
            usage
        fi
        ;;
    p)
        PROJECT=${OPTARG^^}
        if [ "$PROJECT" != "FLOAT" -a "$PROJECT" != "BASOP" ]; then
            usage
        fi
        ;;
    h | *)
        usage
        ;;
    esac
done
shift $((OPTIND-1))


wmc_opt=""
if [ "$MODE" = "MEM_ONLY" ]; then
    wmc_opt="-s"
fi


system=`uname -s`
if [[ ($system = "Linux") && (`uname -a` =~ (microsoft|Microsoft|wsl|WSL) ) ]]; then
    system="Linux"
fi

coan_exists () {
  type coan &> /dev/null ;
}

cppp_exists () {
  type cppp/cppp.pl &> /dev/null ;
}

if ! (coan_exists || cppp_exists); then
    echo "Neither coan (recommended) nor cppp could be found. Requires either coan or cppp to operate properly. Exiting."
    echo "Coan is available from http://coan2.sourceforge.net/; please make it available in your path"
    echo "cppp is available from https://homes.cs.washington.edu/~mernst/software/#cppp; please copy to directory scripts/cppp"
    exit -1
fi

targetdir=c-code_instrument

currdir=`pwd`
scriptdir=`dirname $0`
ifdef_list=ifdef_instrument.list
sourcedir=$scriptdir/..
cd $scriptdir

rm -Rf $targetdir
mkdir $targetdir

# copy files from source-dir
cp -R ../lib_* $targetdir
cp -R ../apps $targetdir
cp -R ../Makefile $targetdir
if [ "$PROJECT" = "FLOAT" ]; then
    cp -R ../CMakeLists.txt $targetdir
fi
cp -R ../Workspace_msvc $targetdir

# back up #ifdef-list
rm -f $ifdef_list
touch $ifdef_list

# LC3plus-related stuff -> only in float code
if [ "$PROJECT" = "FLOAT" ]; then
    # Add LC3plus feature defines to options.h so that they are stripped correctly
    # Generate list of active defines in LC3plus defines.h
    lc3plus_defines=$(
        gcc -E -dM $targetdir/lib_lc3plus/defines.h -I $targetdir/lib_com -I $targetdir/lib_debug |
            sed '/^#define [[:alnum:]][[:alnum:]_]\+[[:space:]]*$/! d' |
            sed '/#define DEFINES_H/ d'
    )

    # Filter defines that come from outside of the header lib_lc3plus/defines.h
    lc3plus_defines_filtered=""
    while IFS=' \n' read -r line;
    do
       line=`echo $line | tr -d '\n'`
       if grep -wqF "$line" "$targetdir/lib_lc3plus/defines.h"; then
           lc3plus_defines_filtered+=$line$'\n'
       fi
    done <<< $lc3plus_defines

    # Append LC3plus defines to options.h
    echo "
    /* LC3plus switches */
    #ifndef OPTIONS_H_LC3_DEFINES
    #define OPTIONS_H_LC3_DEFINES
    $lc3plus_defines_filtered
    #endif /* OPTIONS_H_LC3_DEFINES */
    " >>$targetdir/lib_com/options.h
fi

# get switches from options.h and append it to $ifdef_list
parse_options_opt=""
if coan_exists; then
    echo "-UDEBUGGING" >> $ifdef_list
    parse_options_opt="-c"
else
    echo "DEBUGGING" >> $ifdef_list
fi
./parse_options_h.sh $parse_options_opt $targetdir/lib_com/options.h >> $ifdef_list
if [ $? -ne 0 ]; then
    exit -1
fi

# strip switches, to remove the macros (turn on extended globing to allow !(pattern*) matching)
shopt -s extglob
if coan_exists; then
    # remove WMOPS and MEM_COUNT_DETAILS from the list to preserve the options in the instrumented code
    sed -i "/-DWMOPS/d" $ifdef_list
	sed -i "/-UMEM_COUNT_DETAILS/d" $ifdef_list

    coan source --replace --no-transients -E -K --file $ifdef_list $targetdir/apps/*.[hc]
    if [ "$PROJECT" = "FLOAT" ]; then
        coan source --replace --no-transients -E -K --file $ifdef_list $targetdir/lib_{com,dec,enc,isar,rend,util,debug}/!(wmc_auto*).[hc]
        coan source --replace --no-transients -E -K --file $ifdef_list $targetdir/lib_lc3plus/!(wmc_auto*).[hc]
        coan source --replace --no-transients -E -K --file $ifdef_list $targetdir/lib_lc3plus/fft/!(wmc_auto*).[hc]
    else
        # same as first call from if, but without "isar" and "debug" to avoid coan warning
        coan source --replace --no-transients -E -K --file $ifdef_list $targetdir/lib_{com,dec,enc,rend,util}/!(wmc_auto*).[hc]
    fi
else
    ./strip_defines_cppp.sh $targetdir $ifdef_list
fi
shopt -u extglob

# patch code before wmc_tool: replace hexadecimal unsigned long constants (0x...UL) by regular integer constant + cast to unsigned long
find $targetdir -name "*.[ch]" -exec sed -i.bak -e "s/\(0x[0-9a-fA-F]*\)UL/\(\(unsigned long\)\1\)/" \{\} \;

# run wmc_tool
"tools/$system/wmc_tool" $wmc_opt -m "$targetdir/apps/encoder.c" "$targetdir/lib_enc/*.c" "$targetdir/lib_com/*.c"  >> /dev/null
"tools/$system/wmc_tool" $wmc_opt -m "$targetdir/apps/decoder.c" "$targetdir/lib_dec/*.c" "$targetdir/lib_rend/*.c" >> /dev/null
# ISAR post-renderer and lc3plus sources only need to be instrumented in float code
if [ "$PROJECT" = "FLOAT" ]; then
    for bak_file in $targetdir/lib_rend/*.bak; do mv "$bak_file" "${bak_file%.*}"; done      # restore fresh .c files to avoid time-consuming des-instrumentation of files by the WMC tool
    "tools/$system/wmc_tool" $wmc_opt -m "$targetdir/apps/renderer.c" "$targetdir/lib_rend/*.c" "$targetdir/lib_lc3plus/*.c" "$targetdir/lib_lc3plus/fft/*.c" >> /dev/null
    for bak_file in $targetdir/lib_lc3plus/*.bak; do mv "$bak_file" "${bak_file%.*}"; done      # restore fresh .c files to avoid time-consuming des-instrumentation of files by the WMC tool
    for bak_file in $targetdir/lib_lc3plus/fft/*.bak; do mv "$bak_file" "${bak_file%.*}"; done      # restore fresh .c files to avoid time-consuming des-instrumentation of files by the WMC tool
    "tools/$system/wmc_tool" $wmc_opt -m "$targetdir/apps/isar_post_rend.c" "$targetdir/lib_isar/*.c" "$targetdir/lib_lc3plus/*.c" "$targetdir/lib_lc3plus/fft/*.c" >> /dev/null
else
    for bak_file in $targetdir/lib_rend/*.bak; do mv "$bak_file" "${bak_file%.*}"; done      # restore fresh .c files to avoid time-consuming des-instrumentation of files by the WMC tool
    "tools/$system/wmc_tool" $wmc_opt -m "$targetdir/apps/renderer.c" "$targetdir/lib_rend/*.c" >> /dev/null
fi

# automatically enable #define WMOPS in options.h
sed -i.bak -e "s/\/\*[[:space:]]*\(#define[[:space:]]*WMOPS\)[[:space:]]*\*\//\1/g" $targetdir/lib_com/options.h
sed -i.bak -e "s/\/\/[[:space:]]*\(#define[[:space:]]*WMOPS\)/\1/g"        $targetdir/lib_com/options.h

# return to start dir
cd "$currdir"