Skip to content

Commit

Permalink
Merge pull request #4 from RISE-Maritime/feature/compile_windows
Browse files Browse the repository at this point in the history
Feature/compile windows
  • Loading branch information
luisheres authored Nov 7, 2024
2 parents 85c7376 + 9f1e5a6 commit d505cf3
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 28 deletions.
25 changes: 13 additions & 12 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# Use the official Ubuntu 22.04 LTS image
FROM ubuntu:22.04

# Set environment variables
ENV DEBIAN_FRONTEND=noninteractive
ENV ZENOH_VERSION=1.0.0
ENV PROTOBUF_VERSION=3.20.1
ENV LIBZIP_VERSION=1.10.1

# Install required packages
RUN apt-get update && apt-get install -y \
Expand Down Expand Up @@ -31,25 +35,21 @@ ENV PATH="/root/.cargo/bin:$PATH"
# Verify Rust and Cargo installation
RUN rustup --version && cargo --version

# Set working directory
WORKDIR /workspaces

# Build and install Zenoh-c
RUN git clone https://github.com/eclipse-zenoh/zenoh-c.git /workspaces/zenoh-c
RUN git clone --depth 1 --branch ${ZENOH_VERSION} https://github.com/eclipse-zenoh/zenoh-c.git /workspaces/zenoh-c
WORKDIR /workspaces/zenoh-c/build
RUN cmake ../ -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_SHARED_LIBS=FALSE && \
cmake --build . --target install


# Build and install Zenoh-cpp
RUN git clone https://github.com/eclipse-zenoh/zenoh-cpp.git /workspaces/zenoh-cpp
RUN git clone --depth 1 --branch ${ZENOH_VERSION} https://github.com/eclipse-zenoh/zenoh-cpp.git /workspaces/zenoh-cpp
WORKDIR /workspaces/zenoh-cpp/build
RUN cmake ../ -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_SHARED_LIBS=FALSE && \
cmake --build . --target install


# Download and build Protobuf from source
ARG PROTOBUF_VERSION=3.20.1
RUN curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOBUF_VERSION}/protobuf-cpp-${PROTOBUF_VERSION}.tar.gz && \
tar -xzf protobuf-cpp-${PROTOBUF_VERSION}.tar.gz && \
cd protobuf-${PROTOBUF_VERSION} && \
Expand All @@ -58,9 +58,7 @@ RUN curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v${PR
make install && \
ldconfig


# Download and build libzip from source
ENV LIBZIP_VERSION=1.11.1
RUN wget https://libzip.org/download/libzip-${LIBZIP_VERSION}.tar.gz && \
tar -xvf libzip-${LIBZIP_VERSION}.tar.gz && \
cd libzip-${LIBZIP_VERSION} && \
Expand All @@ -81,10 +79,13 @@ RUN rm -rf /libzip-${LIBZIP_VERSION} /libzip-${LIBZIP_VERSION}.tar.gz
# Python and FMPy
RUN python3 -m pip install fmpy[complete]==0.3.20

# Set working directory back to /workspaces
WORKDIR /workspaces
# Create a non-root user
ENV USERNAME=developer
RUN useradd -m $USERNAME

USER ${USERNAME}

# Copy your project files into the container
# Copy the workspace files to the container
COPY . /workspaces

CMD ["bash"]
CMD ["/bin/bash"]
3 changes: 1 addition & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
"build": {
"dockerfile": "Dockerfile"
},
"remoteUser": "root",
"mounts": ["source=${localEnv:HOME}/.ssh,target=/home/vscode/.ssh,type=bind"],
"remoteUser": "developer",
"customizations": {
"vscode": {
"extensions": ["ms-vscode.cmake-tools", "ms-vscode.cpptools"]
Expand Down
13 changes: 7 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
name: Release

on:
release:
types:
- created
push:
branches:
- main
tags:
- v*
- "v*.*.*"

jobs:
build_linux:
Expand All @@ -25,7 +26,7 @@ jobs:
- name: Run DevContainer and build project
run: |
docker run --rm -v ${{ github.workspace }}:/workspace -w /workspace linux-container-image \
docker run --rm -v ${{ github.workspace }}:/workspace -w /workspace -u root linux-container-image \
bash -c "mkdir -p build && cd build && cmake .. && make"
- name: Debug Build Output (Linux)
Expand Down Expand Up @@ -70,15 +71,15 @@ jobs:
- name: Build and install Zenoh-c
run: |
git clone https://github.com/eclipse-zenoh/zenoh-c.git
git clone --depth 1 --branch 1.0.0 https://github.com/eclipse-zenoh/zenoh-c.git
mkdir zenoh-c/build
cd zenoh-c/build
cmake ../ -DBUILD_SHARED_LIBS=FALSE
cmake --build . --config Release --target install
- name: Build and install Zenoh-cpp
run: |
git clone https://github.com/eclipse-zenoh/zenoh-cpp.git
git clone --depth 1 --branch 1.0.0 https://github.com/eclipse-zenoh/zenoh-cpp.git
mkdir zenoh-cpp/build
cd zenoh-cpp/build
cmake ../ -DBUILD_SHARED_LIBS=FALSE
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ Build all the targets and `cd` to the `build` folder.

``./liaison --make-fmu ../tests/BouncingBall.fmu fmus/bouncingball``

### Step 2: Run the "Liaison Server"
### Step 2: Serve the FMU

``./liaison --server ../tests/BouncingBall.fmu fmus/bouncingball``
``./liaison --serve ../tests/BouncingBall.fmu fmus/bouncingball``

### Step 3: Simulat the "Liaison FMU"

Expand Down
16 changes: 10 additions & 6 deletions src/liaison.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -805,17 +805,21 @@ void generateFmu(const std::string& fmuPath, const std::string& responderId) {
}

// Add the renamed DLL files to the FMU inside the binaries/platform directory
size_t nDynamicLibraryErrors = 0;
std::string originalLinuxDynamicLibraryPath ="./binaries/x86_64-linux/libliaisonfmu.so";
std::string renamedLinuxDynamicLibraryPath = "binaries/x86_64-linux/" + modelName + ".so";
if (!addFileToZip(fmu, originalLinuxDynamicLibraryPath, renamedLinuxDynamicLibraryPath)) {
std::cerr << "Error adding Liaison Linux dynamic library file to FMU." << std::endl;
zip_discard(fmu);
return;
std::cerr << "Warning: failed adding Liaison Linux dynamic library file to FMU." << std::endl;
nDynamicLibraryErrors++;
}
std::string originalWindowsDynamicLibraryPath ="./binaries/x86_64-windows/liaisonfmu.dll";
std::string renamedWindowsDynamicLibraryPath = "binaries/x86_64-windows/" + modelName + ".dll";
if (!addFileToZip(fmu, originalWindowsDynamicLibraryPath, renamedWindowsDynamicLibraryPath)) {
std::cerr << "Error adding Liaison Windows dynamic library file to FMU." << std::endl;
std::cerr << "Warning: failed adding Liaison Windows dynamic library file to FMU." << std::endl;
nDynamicLibraryErrors++;
}
if (nDynamicLibraryErrors == 2) {
std::cerr << "Fatal Error: Failed to add a single Liaison dynamic library file to the Liaison FMU." << std::endl;
zip_discard(fmu);
return;
}
Expand Down Expand Up @@ -848,7 +852,7 @@ void generateFmu(const std::string& fmuPath, const std::string& responderId) {

void printUsage() {
std::cout << "Usage:\n";
std::cout << " liaison --server <Path to FMU> <Responder Id>\n";
std::cout << " liaison --serve <Path to FMU> <Responder Id>\n";
std::cout << " liaison --make-fmu <Path to FMU> <Responder Id>\n";
}

Expand All @@ -864,7 +868,7 @@ int main(int argc, char* argv[]) {
std::string responderId = argv[3];

try {
if (option == "--server") {
if (option == "--serve") {
startServer(fmuPath, responderId);
} else if (option == "--make-fmu") {
generateFmu(fmuPath, responderId);
Expand Down

0 comments on commit d505cf3

Please sign in to comment.