Skip to content

Commit

Permalink
Add a default build script
Browse files Browse the repository at this point in the history
  • Loading branch information
andy5995 committed Dec 10, 2024
1 parent 3e619e2 commit 1c46c7d
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 58 deletions.
16 changes: 2 additions & 14 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
14 changes: 11 additions & 3 deletions .github/workflows/docker-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,15 @@ 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 vs-fltk-env \
bash -l -c '\
export -p && \
cd $WORKSPACE && \
. /home/builder/.profile && \
scripts/build-default.sh
'
docker container stop vs-fltk-env
docker container rm vs-fltk-env
env:
ENTRYPOINT: /entry-build.sh
WORKSPACE: ${{ github.workspace }}/vs-workspace
WORKSPACE: /vs-workspace
23 changes: 8 additions & 15 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
13 changes: 0 additions & 13 deletions docker/entry-build.sh

This file was deleted.

8 changes: 0 additions & 8 deletions docker/entry-default.sh

This file was deleted.

6 changes: 5 additions & 1 deletion docker/entry-common.sh → docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# entry-common.sh
# entrypoint.sh

set -e

Expand All @@ -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
25 changes: 25 additions & 0 deletions scripts/build-default.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 1c46c7d

Please sign in to comment.