Skip to content

Commit

Permalink
Merge branch 'main' into send-on-reconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
sameerzuberi authored Oct 30, 2024
2 parents 419a8d8 + 800f0f2 commit 2485112
Show file tree
Hide file tree
Showing 2 changed files with 142 additions and 3 deletions.
118 changes: 118 additions & 0 deletions .github/workflows/cmake-multi-platform.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
name: CMake on multiple platforms
on:
workflow_dispatch:
push:
pull_request:
jobs:
build:
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
build_type: [RelWithDebInfo, MinSizeRel]
architecture: [aarch64-linux-gnu, arm-linux-gnueabihf, ""]
steps:
- uses: actions/checkout@v4
- name: Install generic dependencies
run: |
sudo apt clean && sudo apt update
sudo apt-get -y install --no-install-recommends \
cmake \
curl \
libc6-dev-i386 \
git \
libcurl4-openssl-dev \
libevent-dev \
libssl-dev \
libsqlite3-dev \
libsystemd-dev \
liburiparser-dev \
libyaml-dev \
libzip-dev \
pkg-config \
uuid-dev
- name: Install x86-64 dependencies / settings
if: matrix.architecture == ''
run: |
sudo apt-get -y install \
build-essential
echo "cmake_settings=" >> "$GITHUB_OUTPUT"
- name: Install arm64 dependencies / settings
if: matrix.architecture == 'aarch64-linux-gnu'
run: |
sudo apt-get -y install --no-install-recommends \
qemu-user-static \
g++-aarch64-linux-gnu \
binutils-aarch64-linux-gnu \
gcc-aarch64-linux-gnu
cat << EOF | tee -a ${{ matrix.architecture }}.cmake
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR aarch64)
set(CMAKE_SYSTEM_VERSION 1)
set(CMAKE_C_COMPILER_TARGET ${{ matrix.architecture }})
set(CMAKE_CXX_COMPILER_TARGET ${{ matrix.architecture }})
set(CMAKE_CROSSCOMPILING TRUE)
set(CMAKE_CROSSCOMPILING_EMULATOR qemu-aarch64-static -L /usr/${{ matrix.architecture }}/)
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
find_program(C_COMPILER_FULL_PATH NAMES aarch64-linux-gnu-gcc)
set(CMAKE_C_COMPILER ${C_COMPILER_FULL_PATH})
find_program(CXX_COMPILER_FULL_PATH NAMES g++-${CMAKE_CXX_COMPILER_TARGET} ${CMAKE_CXX_COMPILER_TARGET}-g++)
if(CXX_COMPILER_FULL_PATH)
set(CMAKE_CXX_COMPILER ${CXX_COMPILER_FULL_PATH})
endif()
EOF
echo "CMAKE_SETTINGS=-DCMAKE_TOOLCHAIN_FILE=${{ matrix.architecture }}.cmake" >> "$GITHUB_ENV"
- name: Install arm32 dependencies / settings
if: matrix.architecture == 'arm-linux-gnueabihf'
run: |
sudo apt-get -y install --no-install-recommends \
qemu-user-static \
libc-dev-armel-cross \
gcc-arm-linux-gnueabihf \
g++-arm-linux-gnueabihf \
binutils-arm-linux-gnueabihf
cat << EOF | tee -a ${{ matrix.architecture }}.cmake
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(CMAKE_SYSTEM_VERSION 1)
set(CMAKE_C_COMPILER_TARGET "${{ matrix.architecture }}")
set(CMAKE_CXX_COMPILER_TARGET "${{ matrix.architecture }}")
set(CMAKE_CROSSCOMPILING TRUE)
set(CMAKE_CROSSCOMPILING_EMULATOR qemu-arm-static -L /usr/${{ matrix.architecture }}/)
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
find_program(C_COMPILER_FULL_PATH NAMES ${{ matrix.architecture }}-gcc)
set(CMAKE_C_COMPILER ${C_COMPILER_FULL_PATH})
find_program(CXX_COMPILER_FULL_PATH NAMES g++-${CMAKE_CXX_COMPILER_TARGET} ${CMAKE_CXX_COMPILER_TARGET}-g++)
if(CXX_COMPILER_FULL_PATH)
set(CMAKE_CXX_COMPILER ${CXX_COMPILER_FULL_PATH})
endif()
EOF
echo "CMAKE_SETTINGS=-DCMAKE_TOOLCHAIN_FILE=${{ matrix.architecture }}.cmake" >> "$GITHUB_ENV"
- name: Set reusable strings
id: strings
shell: bash
run: |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
- name:
Configure CMake ${{ matrix.build_type }} / ${{ matrix.architecture }}
run: >
cmake ${{ env.CMAKE_SETTINGS }} -B ${{
steps.strings.outputs.build-output-dir }}
-DCMAKE_INSTALL_PREFIX=/opt/aws-greengrass-lite -DGGL_LOG_LEVEL=DEBUG
-S ${{ github.workspace }}
- name: Build
run: |
make -C ${{ steps.strings.outputs.build-output-dir }} -j$(nproc)
- name: Package
working-directory: ${{ steps.strings.outputs.build-output-dir }}
run: cpack -G DEB
- name: Save package
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.architecture }}_${{ matrix.build_type }}.deb
path: ${{ steps.strings.outputs.build-output-dir }}/*.deb
retention-days: 1
27 changes: 24 additions & 3 deletions ggdeploymentd/src/deployment_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -1047,8 +1047,14 @@ static GglError parse_dataplane_response_and_save_recipe(
if (ret != GGL_ERR_OK) {
return ret;
}
assert(cloud_component_version->buf.len <= NAME_MAX);

*cloud_version = cloud_component_version->buf;
memcpy(
cloud_version->data,
cloud_component_version->buf.data,
cloud_component_version->buf.len
);
cloud_version->len = cloud_component_version->buf.len;

if (vendor_guidance != NULL) {
if (ggl_buffer_eq(vendor_guidance->buf, GGL_STR("DISCONTINUED"))) {
Expand Down Expand Up @@ -1568,7 +1574,7 @@ static GglError resolve_dependencies(
return ret;
}
if (existing_requirements) {
static uint8_t new_req_buf[PATH_MAX];
uint8_t new_req_buf[PATH_MAX];
GglByteVec new_req_vec = GGL_BYTE_VEC(new_req_buf);
ret = ggl_byte_vec_append(
&new_req_vec, existing_requirements->buf
Expand All @@ -1583,7 +1589,22 @@ static GglError resolve_dependencies(
return ret;
}

*existing_requirements = GGL_OBJ_BUF(new_req_vec.buf);
uint8_t *new_req = GGL_ALLOCN(
&version_requirements_balloc.alloc,
uint8_t,
new_req_vec.buf.len
);
if (new_req == NULL) {
GGL_LOGE("Ran out of memory while trying to create "
"new requirements");
return GGL_ERR_NOMEM;
}

memcpy(
new_req, new_req_vec.buf.data, new_req_vec.buf.len
);
*existing_requirements = GGL_OBJ_BUF((GglBuffer
) { .data = new_req, .len = new_req_vec.buf.len });
}

// If we haven't resolved it yet, and it doesn't have an
Expand Down

0 comments on commit 2485112

Please sign in to comment.