diff --git a/configure.ac b/configure.ac index e24f69887d8..145231749ce 100644 --- a/configure.ac +++ b/configure.ac @@ -106,6 +106,7 @@ CFLAGS_COMMON+=" -Wvariadic-macros" CFLAGS_COMMON+=" -Wno-switch-default" CFLAGS_COMMON+=" -Wno-long-long" CFLAGS_COMMON+=" -Wno-redundant-decls" +CFLAGS_COMMON+=" -Wno-error=missing-field-initializers" # Code testing coverage with gcov AC_MSG_CHECKING(whether to build with gcov testing) diff --git a/dev/Dockerfile.yml b/dev/Dockerfile.yml new file mode 100644 index 00000000000..acb0d9054b2 --- /dev/null +++ b/dev/Dockerfile.yml @@ -0,0 +1,92 @@ +ARG DEBIAN_VERSION="bookworm" +FROM sonicdev-microsoft.azurecr.io:443/sonic-slave-${DEBIAN_VERSION}:latest + +ARG UID=1000 +ARG GID=1000 + +RUN groupadd -g ${GID} sonicdev && \ + useradd -u ${UID} -g ${GID} -ms /bin/bash sonicdev + +RUN mkdir -p /workspace && \ + mkdir -p /workspace/debs && \ + mkdir -p /workspace/tools && \ + chown -R sonicdev:sonicdev /workspace + +ENV PATH="${PATH}:/workspace/tools" + +RUN apt-get update && \ + sudo apt-get install -y \ + libhiredis-dev \ + libzmq3-dev \ + swig4.0 \ + libdbus-1-dev \ + libteam-dev \ + protobuf-compiler \ + libprotobuf-dev && \ + sudo pip3 install lcov_cobertura + +COPY dev/download_artifact.sh /workspace/tools/download_artifact.sh + +WORKDIR /workspace/debs + +ARG BRANCH_NAME="master" +ARG PLATFORM="amd64" +ARG DEBIAN_VERSION + +# SWSS COMMON + +ARG SWSS_COMMON_PROJECT_NAME="Azure.sonic-swss-common" +ARG SWSS_COMMON_ARTIFACT_NAME="sonic-swss-common" +ARG SWSS_COMMON_FILE_PATHS="/libswsscommon_1.0.0_${PLATFORM}.deb /libswsscommon-dev_1.0.0_${PLATFORM}.deb" + +RUN download_artifact.sh "${SWSS_COMMON_PROJECT_NAME}" "${BRANCH_NAME}" "${SWSS_COMMON_ARTIFACT_NAME}" "${SWSS_COMMON_FILE_PATHS}" + +# SAIREDIS + +ARG SAIREDIS_PROJECT_NAME="Azure.sonic-sairedis" +ARG SAIREDIS_ARTIFACT_NAME="sonic-sairedis" +ARG SAIREDIS_FILE_PATHS="\ + /libsaivs_1.0.0_${PLATFORM}.deb \ + /libsaivs-dev_1.0.0_${PLATFORM}.deb \ + /libsairedis_1.0.0_${PLATFORM}.deb \ + /libsairedis-dev_1.0.0_${PLATFORM}.deb \ + /libsaimetadata_1.0.0_${PLATFORM}.deb \ + /libsaimetadata-dev_1.0.0_${PLATFORM}.deb \ + /syncd-vs_1.0.0_${PLATFORM}.deb \ + " + +RUN download_artifact.sh "${SAIREDIS_PROJECT_NAME}" "${BRANCH_NAME}" "${SAIREDIS_ARTIFACT_NAME}" "${SAIREDIS_FILE_PATHS}" + +# COMMON LIB + +ARG COMMON_LIB_PROJECT_NAME="Azure.sonic-buildimage.common_libs" +ARG COMMON_LIB_ARTIFACT_NAME="common-lib" +ARG COMMON_LIB_FILE_PATHS="\ + /target/debs/${DEBIAN_VERSION}/libnl-3-200_3.7.0-0.2%2Bb1sonic1_${PLATFORM}.deb \ + /target/debs/${DEBIAN_VERSION}/libnl-3-dev_3.7.0-0.2%2Bb1sonic1_${PLATFORM}.deb \ + /target/debs/${DEBIAN_VERSION}/libnl-genl-3-200_3.7.0-0.2%2Bb1sonic1_${PLATFORM}.deb \ + /target/debs/${DEBIAN_VERSION}/libnl-genl-3-dev_3.7.0-0.2%2Bb1sonic1_${PLATFORM}.deb \ + /target/debs/${DEBIAN_VERSION}/libnl-route-3-200_3.7.0-0.2%2Bb1sonic1_${PLATFORM}.deb \ + /target/debs/${DEBIAN_VERSION}/libnl-route-3-dev_3.7.0-0.2%2Bb1sonic1_${PLATFORM}.deb \ + /target/debs/${DEBIAN_VERSION}/libnl-nf-3-200_3.7.0-0.2%2Bb1sonic1_${PLATFORM}.deb \ + /target/debs/${DEBIAN_VERSION}/libnl-nf-3-dev_3.7.0-0.2%2Bb1sonic1_${PLATFORM}.deb \ + /target/debs/${DEBIAN_VERSION}/libyang_1.0.73_${PLATFORM}.deb \ + " + +RUN download_artifact.sh "${COMMON_LIB_PROJECT_NAME}" "${BRANCH_NAME}" "${COMMON_LIB_ARTIFACT_NAME}" "${COMMON_LIB_FILE_PATHS}" + +# DASH API + +ARG DASH_API_PROJECT_NAME="sonic-net.sonic-dash-api" +ARG DASH_API_ARTIFACT_NAME="sonic-dash-api" +ARG DASH_API_FILE_PATHS="/libdashapi_1.0.0_${PLATFORM}.deb" + +RUN download_artifact.sh "${DASH_API_PROJECT_NAME}" "${BRANCH_NAME}" "${DASH_API_ARTIFACT_NAME}" "${DASH_API_FILE_PATHS}" + +RUN dpkg -i *.deb + +WORKDIR /workspace + +USER sonicdev + +ENTRYPOINT [ "bash" ] diff --git a/dev/docker-compose.yml b/dev/docker-compose.yml new file mode 100644 index 00000000000..ce51eb6781a --- /dev/null +++ b/dev/docker-compose.yml @@ -0,0 +1,18 @@ +services: + sonicdev: + container_name: sonicdev + build: + context: .. + dockerfile: dev/Dockerfile.yml + args: + - DEBIAN_VERSION + - UID + - GID + - BRANCH_NAME + - PLATFORM + volumes: + - ..:/workspace/sonic-swss + init: true + privileged: true + working_dir: /workspace/sonic-swss + diff --git a/dev/download_artifact.sh b/dev/download_artifact.sh new file mode 100755 index 00000000000..282ca504753 --- /dev/null +++ b/dev/download_artifact.sh @@ -0,0 +1,46 @@ +#!/bin/bash + +# download_artifact.sh +# +# targetPaths: space separated list of target paths to download from the artifact +# e.g. +# ./download_artifact.sh "Azure.sonic-swss-common" "master" "sonic-swss-common" "/libswsscommon-dev_1.0.0_amd64.deb /libswsscommon_1.0.0_amd64.deb" + +set -x -e + +pipelineName=${1} +branchName=${2} +artifactName=${3} +targetPaths=${4} + +queryPipelinesUrl="https://dev.azure.com/mssonic/build/_apis/pipelines" + +definitions=$(curl -s "${queryPipelinesUrl}" | jq -r ".value[] | select (.name == \"${pipelineName}\").id") + +queryBuildsUrl="https://dev.azure.com/mssonic/build/_apis/build/builds?definitions=${definitions}&branchName=refs/heads/${branchName}&resultFilter=succeeded&statusFilter=completed&api-version=6.0" + +buildId=$(curl -s ${queryBuildsUrl} | jq -r '.value[0].id') + +queryArtifactUrl="https://dev.azure.com/mssonic/build/_apis/build/builds/${buildId}/artifacts?artifactName=${artifactName}&api-version=6.0" + +function download_artifact { + + target_path=${1} + output_file=$(sed 's/.*\///' <<< ${target_path}) + + download_artifact_url=$(curl -s ${queryArtifactUrl} | jq -r '.resource.downloadUrl') + download_artifact_url=$(sed 's/zip$/file/' <<< ${download_artifact_url}) + download_artifact_url="$download_artifact_url&subPath=${target_path}" + + wget -O ${output_file} ${download_artifact_url} +} + +function download_artifacts { + target_paths_array=(${targetPaths}) + for target_path in "${target_paths_array[@]}" + do + download_artifact ${target_path} + done +} + +download_artifacts