diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e78ce653..ab5298f1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -69,12 +69,7 @@ jobs: fi - name: Configure and build - run: | - cmake --version - bun install - bun run codegen - bun run meson-setup.clang-release - meson compile -C build/ vs:executable + run: scripts/build-default.sh - name: Archive production artifacts uses: actions/upload-artifact@v4 with: @@ -107,14 +102,7 @@ jobs: echo "PATH=$PATH" >> $GITHUB_ENV - name: Configure and build - run: | - cmake --version - bun install - bun run codegen - meson setup -Dforce_x11_backend=true --reconfigure build/ --buildtype=release --native-file toolchains/flatpak.ini - # Unclear fix to be investigated - rm subprojects/libtcc/VERSION - meson compile -C build/ vs:executable + run: scripts/build-default.sh - name: Archive production artifacts uses: actions/upload-artifact@v4 with: diff --git a/.github/workflows/docker-test.yml b/.github/workflows/docker-test.yml index c5f32939..a0ab1982 100644 --- a/.github/workflows/docker-test.yml +++ b/.github/workflows/docker-test.yml @@ -66,7 +66,16 @@ jobs: - name: Run commands in Docker container run: | export HOSTUID=$(id -u) HOSTGID=$(id -g) - docker compose -f docker/docker-compose.yml run --rm dev + docker compose -f docker/docker-compose.yml up -d dev + docker exec --user builder vs-fltk-env \ + bash -l -c '\ + set -e + export -p + cd $WORKSPACE + . ~/.profile + scripts/build-default.sh + ' + docker stop vs-fltk-env + docker rm vs-fltk-env env: - ENTRYPOINT: /entry-build.sh - WORKSPACE: ${{ github.workspace }}/vs-workspace + WORKSPACE: /vs-workspace diff --git a/docker/README.md b/docker/README.md index 59b0a2e9..7624358c 100644 --- a/docker/README.md +++ b/docker/README.md @@ -18,28 +18,21 @@ Replace the values for `HOSTUID` and `HOSTGID` with your system `uid` and `gid`. Then, from the source root, to enter the build environment: ```sh -docker-compose -f docker/docker-compose.yml run --rm dev +docker compose -f docker/docker-compose.yml run --rm dev ``` From there, you can run the commands to build the app. You can use your regular IDE to make changes, and then test them by building within the -container. - -To start the container and build the app non-interactively: +container. A convenience script is available: ```sh -export ENTRYPOINT=/entry-build.sh +scripts/build-default ``` -And use the same command as shown above. - -Remember to unset `ENTRYPOINT` when you wish to start the container with only -a prompt. - -All of the above methods will mount your current directory as _/vs-workspace_ -inside the container. Your username will be _builder_. By default, you will -not have root privileges (which are not necessary to build and test). However, -you can use `sudo` if you need to run `apt` or any other commands that require +When starting the container, your current directory will be mounted at +_/vs-workspace_. Your username will be _builder_. By default, you will not +have root privileges (which are not necessary to build and test). However, you +can use `sudo` if you need to run `apt` or any other commands that require root access. ## Notes @@ -112,7 +105,7 @@ necessary devices. Here's a general guide: 3. **Run the container with access to the display:** When starting the container, pass the display environment variable (`$DISPLAY`) and mount the X11 socket. Instead of *dev" for the last - argument of `docker-compose` (see above), use *xgui\*, which essentially + argument of `docker-compose` (see above), use *x11-dev\*, which essentially adds these three arguments (through the compose configuration): ```sh diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index fabb3d28..8ae93b6e 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -2,7 +2,7 @@ services: dev: image: "${IMAGE:-ghcr.io/karurochori/vs-fltk:build-env}" container_name: "${VS_NAME:-vs-fltk-env}" - entrypoint: "${ENTRYPOINT:-/entry-default.sh}" + entrypoint: "${ENTRYPOINT:-/entrypoint.sh}" # Only variables used within the container should be here environment: @@ -14,9 +14,8 @@ services: volumes: - ${PWD}:${WORKSPACE} - # Mount the entrypoint scripts inside the container - - ${PWD}/docker/entry-build.sh:/entry-build.sh - - ${PWD}/docker/entry-default.sh:/entry-default.sh + # Mount the script inside the container + - ${PWD}/docker/entrypoint.sh:/entrypoint.sh working_dir: ${WORKSPACE} stdin_open: true # Allows interactive mode tty: true # Allocate a pseudo-TTY diff --git a/docker/entry-build.sh b/docker/entry-build.sh deleted file mode 100755 index 2963ddf3..00000000 --- a/docker/entry-build.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -set -e -$WORKSPACE/docker/entry-common.sh - -su builder -c bash -l << EOF - set -e - cd $WORKSPACE - bun install - bun run codegen - bun run meson-setup.clang-release - meson compile -C build/ vs:executable -EOF diff --git a/docker/entry-default.sh b/docker/entry-default.sh deleted file mode 100755 index dbac4d7f..00000000 --- a/docker/entry-default.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -set -e -$WORKSPACE/docker/entry-common.sh - -# If -l, --login is used here, the variables defined in -# docker-compose.yml do not get exported -su builder diff --git a/docker/entry-common.sh b/docker/entrypoint.sh similarity index 63% rename from docker/entry-common.sh rename to docker/entrypoint.sh index 9b075dde..2c34f2ff 100755 --- a/docker/entry-common.sh +++ b/docker/entrypoint.sh @@ -1,5 +1,5 @@ #!/bin/bash -# entry-common.sh +# entrypoint.sh set -e @@ -15,3 +15,7 @@ fi usermod -u $HOSTUID builder groupmod -g $HOSTGID builder + +# If -l, --login is used here, the variables defined in +# docker-compose.yml do not get exported +su builder diff --git a/scripts/build-default.sh b/scripts/build-default.sh new file mode 100755 index 00000000..afb0c7dd --- /dev/null +++ b/scripts/build-default.sh @@ -0,0 +1,25 @@ +#!/bin/sh +# This file is part of vs-fltk +# License: https://github.com/KaruroChori/vs-fltk/blob/master/LICENCE.md + +set -e + +if [ ! -f "src/app/main.cpp" ]; then + echo "This script must be run from the source root." + exit 1 +fi + +set -v + +bun install +bun run codegen + +if [ "$(uname)" != "Darwin" ]; then + bun run meson-setup.clang-release +else + meson setup -Dforce_x11_backend=true --reconfigure build --buildtype=release --native-file toolchains/flatpak.ini + # Unclear fix to be investigated + rm subprojects/libtcc/VERSION +fi + +meson compile -C build vs:executable