Skip to content

Commit

Permalink
Merge branch 'fed_id_patch' of github.com:lf-lang/reactor-c into fed_…
Browse files Browse the repository at this point in the history
…id_patch
  • Loading branch information
Jakio815 committed Dec 20, 2024
2 parents 02d4749 + 4f4da80 commit c1c1500
Show file tree
Hide file tree
Showing 52 changed files with 855 additions and 339 deletions.
20 changes: 18 additions & 2 deletions .github/workflows/build-rti.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,32 @@ on:
workflow_call:

jobs:
run:
native-build:
strategy:
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.platform }}

steps:
- name: Check out reactor-c repository
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Build the RTI with AUTH=OFF
run: .github/scripts/build-rti.sh -DAUTH=OFF
- name: Build the RTI with AUTH=ON
run: .github/scripts/build-rti.sh -DAUTH=ON

docker-build:
runs-on: ubuntu-latest
steps:
- name: Check out reactor-c repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Docker image
uses: docker/build-push-action@v6
with:
file: ./core/federated/RTI/rti.Dockerfile
context: .
platforms: linux/amd64, linux/arm64, linux/arm/v7, linux/riscv64
push: false
tags: lflang/rti:latest
16 changes: 8 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:

concurrency:
group: ci-${{ github.ref }}-${{ github.event_path }}
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

jobs:
check-labels:
Expand Down Expand Up @@ -56,12 +56,12 @@ jobs:
if: ${{ !github.event.pull_request.draft ||contains( github.event.pull_request.labels.*.name, 'zephyr') }}

lf-default-flexpret:
needs: [fetch-lf]
uses: lf-lang/lingua-franca/.github/workflows/c-flexpret-tests.yml@master
with:
runtime-ref: ${{ github.ref }}
compiler-ref: ${{ needs.fetch-lf.outputs.ref }}
if: ${{ !github.event.pull_request.draft ||contains( github.event.pull_request.labels.*.name, 'flexpret') }}
needs: [fetch-lf]
uses: lf-lang/lingua-franca/.github/workflows/c-flexpret-tests.yml@master
with:
runtime-ref: ${{ github.ref }}
compiler-ref: ${{ needs.fetch-lf.outputs.ref }}
if: ${{ !github.event.pull_request.draft ||contains( github.event.pull_request.labels.*.name, 'flexpret') }}

lf-default:
needs: [fetch-lf]
Expand Down Expand Up @@ -97,4 +97,4 @@ jobs:
compiler-ref: ${{ needs.fetch-lf.outputs.ref }}
scheduler: ADAPTIVE
all-platforms: ${{ !github.event.pull_request.draft || contains( github.event.pull_request.labels.*.name, 'mac') || contains( github.event.pull_request.labels.*.name, 'windows') }}
if: ${{ !github.event.pull_request.draft || contains( github.event.pull_request.labels.*.name, 'schedulers') }}
if: ${{ !github.event.pull_request.draft || contains( github.event.pull_request.labels.*.name, 'schedulers') }}
7 changes: 5 additions & 2 deletions .github/workflows/clang-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ on: [pull_request]

jobs:
clang-format:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v2
- name: Install clang-tidy
- name: Install clang-tidy and clang-format
run: |
sudo apt-get update
sudo apt-get install -y clang-tidy
sudo apt-get install -y pipx
pipx install clang-format
clang-format --version
- name: Analyze
run: make format-check
26 changes: 14 additions & 12 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ include(${LF_ROOT}/core/lf_utils.cmake)
list(APPEND GENERAL_SOURCES tag.c clock.c port.c mixed_radix.c reactor_common.c lf_token.c environment.c)

# Add tracing support if requested
if (DEFINED LF_TRACE)
if(DEFINED LF_TRACE)
message(STATUS "Including sources specific to tracing.")
list(APPEND GENERAL_SOURCES tracepoint.c)
endif()
Expand All @@ -16,7 +16,7 @@ endif()
list(APPEND REACTORC_SOURCES ${GENERAL_SOURCES})

# Add sources for either threaded or single-threaded runtime
if (DEFINED FEDERATED)
if(DEFINED FEDERATED)
include(federated/CMakeLists.txt)
include(federated/network/CMakeLists.txt)
endif()
Expand All @@ -35,14 +35,14 @@ endif()

# Add sources for the local RTI if we are using scheduling enclaves
if(DEFINED LF_ENCLAVES)
include(federated/RTI/local_rti.cmake)
include(federated/RTI/local_rti.cmake)
endif()

# Include sources from subdirectories
include(utils/CMakeLists.txt)

if (DEFINED MODAL_REACTORS)
include(modal_models/CMakeLists.txt)
if(DEFINED MODAL_REACTORS)
include(modal_models/CMakeLists.txt)
endif()

# Print sources used for compilation
Expand All @@ -53,7 +53,7 @@ add_library(reactor-c)
target_sources(reactor-c PRIVATE ${REACTORC_SOURCES})
lf_enable_compiler_warnings(reactor-c)

if (DEFINED LF_TRACE)
if(DEFINED LF_TRACE)
include(${LF_ROOT}/trace/api/CMakeLists.txt)
target_link_libraries(reactor-c PUBLIC lf::trace-api)
# If the user specified an external trace plugin. Find it and link with it
Expand Down Expand Up @@ -106,18 +106,19 @@ target_include_directories(reactor-c PUBLIC ../include/core/threaded)
target_include_directories(reactor-c PUBLIC ../include/core/utils)
target_include_directories(reactor-c PUBLIC federated/RTI/)

if (APPLE)
SET(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> Scr <TARGET> <LINK_FLAGS> <OBJECTS>")
if(APPLE)
SET(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> Scr <TARGET> <LINK_FLAGS> <OBJECTS>")
SET(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> Scr <TARGET> <LINK_FLAGS> <OBJECTS>")
SET(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>")
SET(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>")
SET(CMAKE_CXX_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>")
endif()

# Link with OpenSSL library
if(DEFINED FEDERATED_AUTHENTICATED)
if (APPLE)
if(APPLE)
set(OPENSSL_ROOT_DIR /usr/local/opt/openssl)
endif()

find_package(OpenSSL REQUIRED)
target_link_libraries(reactor-c PUBLIC OpenSSL::SSL)
endif()
Expand All @@ -130,10 +131,11 @@ if(DEFINED FEDERATED)
endif()

# Unless specified otherwise initial event queue and reaction queue to size 10
if (NOT DEFINED INITIAL_EVENT_QUEUE_SIZE)
if(NOT DEFINED INITIAL_EVENT_QUEUE_SIZE)
set(INITIAL_EVENT_QUEUE_SIZE 10)
endif()
if (NOT DEFINED INITIAL_REACT_QUEUE_SIZE)

if(NOT DEFINED INITIAL_REACT_QUEUE_SIZE)
set(INITIAL_REACT_QUEUE_SIZE 10)
endif()

Expand Down
20 changes: 16 additions & 4 deletions core/environment.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,16 @@ int environment_init(environment_t* env, const char* name, int id, int num_worke
const char* trace_file_name) {
(void)trace_file_name; // Will be used with future enclave support.

env->name = malloc(strlen(name) + 1); // +1 for the null terminator
LF_ASSERT_NON_NULL(env->name);
strcpy(env->name, name);

// Space for the name string with the null terminator.
if (name != NULL) {
size_t name_size = strlen(name) + 1; // +1 for the null terminator
env->name = (char*)malloc(name_size);
LF_ASSERT_NON_NULL(env->name);
// Use strncpy rather than strcpy to avoid compiler warnings.
strncpy(env->name, name, name_size);
} else {
env->name = NULL;
}
env->id = id;
env->stop_tag = FOREVER_TAG;

Expand Down Expand Up @@ -284,3 +290,9 @@ int environment_init(environment_t* env, const char* name, int id, int num_worke
env->initialized = true;
return 0;
}

void environment_verify(environment_t* env) {
for (int i = 0; i < env->is_present_fields_size; i++) {
LF_ASSERT_NON_NULL(env->is_present_fields[i]);
}
}
3 changes: 3 additions & 0 deletions core/federated/RTI/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CMakeFiles
Makefile
cmake_install.cmake
17 changes: 13 additions & 4 deletions core/federated/RTI/rti.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Docker file for building the image of the rti
FROM alpine:latest
ARG BASEIMAGE=alpine:latest
FROM ${BASEIMAGE} AS builder
COPY . /lingua-franca
WORKDIR /lingua-franca/core/federated/RTI
RUN set -ex && apk add --no-cache gcc musl-dev cmake make && \
Expand All @@ -9,5 +9,14 @@ RUN set -ex && apk add --no-cache gcc musl-dev cmake make && \
make && \
make install

# Use ENTRYPOINT not CMD so that command-line arguments go through
ENTRYPOINT ["RTI"]
WORKDIR /lingua-franca

# application stage
FROM ${BASEIMAGE} AS app
LABEL maintainer="lf-lang"
LABEL source="https://github.com/lf-lang/reactor-c/tree/main/core/federated/RTI"
COPY --from=builder /usr/local/bin/RTI /usr/local/bin/RTI

WORKDIR /lingua-franca

ENTRYPOINT ["/usr/local/bin/RTI"]
Loading

0 comments on commit c1c1500

Please sign in to comment.