Skip to content

Commit

Permalink
Merge pull request #9346 from RomanLut/submit-docker-scripts-sitl
Browse files Browse the repository at this point in the history
update docker build scripts
  • Loading branch information
DzikuVx committed Oct 20, 2023
2 parents baa59e5 + 79e1474 commit b6fb884
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 8 deletions.
8 changes: 4 additions & 4 deletions Dockerfile
Expand Up @@ -4,15 +4,15 @@ ARG USER_ID
ARG GROUP_ID
ENV DEBIAN_FRONTEND noninteractive

RUN apt-get update && apt-get install -y git cmake make ruby gcc python3 python3-pip gcc-arm-none-eabi
RUN apt-get update && apt-get install -y git cmake make ruby gcc python3 python3-pip gcc-arm-none-eabi ninja-build gdb

RUN pip install pyyaml

# if either of these are already set the same as the user's machine, leave them be and ignore the error
RUN addgroup --gid $GROUP_ID inav; exit 0;
RUN adduser --disabled-password --gecos '' --uid $USER_ID --gid $GROUP_ID inav; exit 0;
RUN if [ -n "$USER_ID" ]; then RUN addgroup --gid $GROUP_ID inav; exit 0; fi
RUN if [ -n "$USER_ID" ]; then RUN adduser --disabled-password --gecos '' --uid $USER_ID --gid $GROUP_ID inav; exit 0; fi

USER inav
RUN if [ -n "$USER_ID" ]; then USER inav; fi
RUN git config --global --add safe.directory /src

VOLUME /src
Expand Down
4 changes: 2 additions & 2 deletions cmake/docker.sh
Expand Up @@ -6,7 +6,7 @@ CURR_REV="$(git rev-parse HEAD)"

initialize_cmake() {
echo -e "*** CMake was not initialized yet, doing it now.\n"
cmake ..
cmake -GNinja ..
echo "$CURR_REV" > "$LAST_CMAKE_AT_REV_FILE"
}

Expand All @@ -26,4 +26,4 @@ else
fi

# Let Make handle the arguments coming from the build script
make "$@"
ninja "$@"
7 changes: 7 additions & 0 deletions cmake/docker_build_sitl.sh
@@ -0,0 +1,7 @@
#!/bin/bash
rm -r build_SITL
mkdir -p build_SITL
#cmake -DSITL=ON -DWARNINGS_AS_ERRORS=ON -GNinja -B build_SITL ..
cmake -DSITL=ON -DDEBUG=ON -DWARNINGS_AS_ERRORS=ON -GNinja -B build_SITL ..
cd build_SITL
ninja
8 changes: 8 additions & 0 deletions cmake/docker_run_sitl.sh
@@ -0,0 +1,8 @@
#!/bin/bash
cd build_SITL

#Lauch SITL - configurator only mode
./inav_7.0.0_SITL

#Launch SITL - connect to X-Plane. IP address should be host IP address, not 127.0.0.1. Can be found in X-Plane "Network" tab.
#./inav_7.0.0_SITL --sim=xp --simip=192.168.2.105 --simport=49000
5 changes: 5 additions & 0 deletions cmake/sitl.cmake
Expand Up @@ -53,6 +53,11 @@ set(SITL_COMPILE_OPTIONS
-funsigned-char
)

if(DEBUG)
message(STATUS "Debug mode enabled. Adding -g to SITL_COMPILE_OPTIONS.")
list(APPEND SITL_COMPILE_OPTIONS -g)
endif()

if(NOT MACOSX)
set(SITL_COMPILE_OPTIONS ${SITL_COMPILE_OPTIONS}
-Wno-return-local-addr
Expand Down
15 changes: 13 additions & 2 deletions docs/development/Building in Docker.md
Expand Up @@ -37,8 +37,19 @@ You'll have to manually execute the same steps that the build script does:
+ This step is only needed the first time.
2. `docker run --rm -it -u root -v <PATH_TO_REPO>:/src inav-build <TARGET>`
+ Where `<PATH_TO_REPO>` must be replaced with the absolute path of where you cloned this repo (see above), and `<TARGET>` with the name of the target that you want to build.
+ Note that on Windows/WSL 2 mounted /src folder is writeable for root user only. You have to run build under root user. You can achieve this by using `-u root` option in the command line above, or by removing "USER inav" line from the .\DockerFile before building image.
+ Note that on Windows/WSL 2 mounted /src folder is writeable for root user only. You have to run build under root user. You can achieve this by using `-u root` option in the command line above.

3. If you need to update `Settings.md`, run `docker run --entrypoint /src/cmake/docker_docs.sh --rm -it -u root -v <PATH_TO_REPO>:/src inav-build`
3. If you need to update `Settings.md`, run:

`docker run --entrypoint /src/cmake/docker_docs.sh --rm -it -u root -v <PATH_TO_REPO>:/src inav-build`

4. Building SITL:

`docker run --rm --entrypoint /src/cmake/docker_build_sitl.sh -it -u root -v <PATH_TO_REPO>:/src inav-build`

5. Running SITL:

`docker run -p 5760:5760 -p 5761:5761 -p 5762:5762 -p 5763:5763 -p 5764:5764 -p 5765:5765 -p 5766:5766 -p 5767:5767 --entrypoint /src/cmake/docker_run_sitl.sh --rm -it -u root -v <PATH_TO_REPO>:/src inav-build`.
+ SITL command line parameters can be adjusted in `cmake/docker_run_sitl.sh`.

Refer to the [Linux](#Linux) instructions or the [build script](/build.sh) for more details.

0 comments on commit b6fb884

Please sign in to comment.