mirror of
https://github.com/LostArtefacts/TRX.git
synced 2025-04-28 20:58:07 +03:00
build: switch to just
This commit is contained in:
parent
4a79f0efb6
commit
bc533f03db
5 changed files with 84 additions and 99 deletions
25
.github/workflows/lint.yml
vendored
25
.github/workflows/lint.yml
vendored
|
@ -37,25 +37,26 @@ jobs:
|
||||||
echo 'deb-src http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main' | sudo tee -a /etc/apt/sources.list
|
echo 'deb-src http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main' | sudo tee -a /etc/apt/sources.list
|
||||||
sudo apt update
|
sudo apt update
|
||||||
sudo apt-get install -y clang-format-17 iwyu
|
sudo apt-get install -y clang-format-17 iwyu
|
||||||
|
sudo snap install --edge --classic just
|
||||||
sudo ln -s /usr/bin/clang-format-17 /usr/local/bin/clang-format
|
sudo ln -s /usr/bin/clang-format-17 /usr/local/bin/clang-format
|
||||||
sudo apt-get install -y make python3-pip
|
sudo apt-get install -y python3-pip
|
||||||
sudo python3 -m pip install pyjson5
|
sudo python3 -m pip install pyjson5
|
||||||
|
|
||||||
|
- name: Check formatted code differences
|
||||||
|
run: |
|
||||||
|
just lint-format
|
||||||
|
git diff --exit-code || (
|
||||||
|
clang-format --version
|
||||||
|
echo 'Please run `just lint` and commit the changes.'
|
||||||
|
exit 1
|
||||||
|
)
|
||||||
|
|
||||||
- name: Check imports
|
- name: Check imports
|
||||||
run: |
|
run: |
|
||||||
git add -A
|
git add -A
|
||||||
make lint_imports
|
just lint-imports
|
||||||
git diff --exit-code || (
|
git diff --exit-code || (
|
||||||
include-what-you-use --version
|
include-what-you-use --version
|
||||||
echo 'Please run `make lint` and commit the changes.'
|
echo 'Please run `just lint` and commit the changes.'
|
||||||
exit 1
|
|
||||||
)
|
|
||||||
|
|
||||||
- name: Check formatted code differences
|
|
||||||
run: |
|
|
||||||
make lint_format
|
|
||||||
git diff --exit-code || (
|
|
||||||
clang-format --version
|
|
||||||
echo 'Please run `make lint` and commit the changes.'
|
|
||||||
exit 1
|
exit 1
|
||||||
)
|
)
|
||||||
|
|
18
.github/workflows/release.yml
vendored
18
.github/workflows/release.yml
vendored
|
@ -136,11 +136,13 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
echo "$GITHUB_CONTEXT"
|
echo "$GITHUB_CONTEXT"
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y make moby-engine moby-cli
|
sudo apt-get install -y moby-engine moby-cli
|
||||||
|
sudo snap install --edge --classic just
|
||||||
|
|
||||||
- name: Build the game
|
- name: Build the game
|
||||||
run: |
|
run: |
|
||||||
make clean release
|
just clean
|
||||||
|
just build-win release
|
||||||
mkdir out/
|
mkdir out/
|
||||||
cp build/win/*.exe out/
|
cp build/win/*.exe out/
|
||||||
cp -r bin/* out/
|
cp -r bin/* out/
|
||||||
|
@ -171,7 +173,8 @@ jobs:
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y make p7zip-full
|
sudo apt-get install -y p7zip-full
|
||||||
|
sudo snap install --edge --classic just
|
||||||
|
|
||||||
- name: Package the game
|
- name: Package the game
|
||||||
run: |
|
run: |
|
||||||
|
@ -199,11 +202,13 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
echo "$GITHUB_CONTEXT"
|
echo "$GITHUB_CONTEXT"
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y make moby-engine moby-cli
|
sudo apt-get install -y moby-engine moby-cli
|
||||||
|
sudo snap install --edge --classic just
|
||||||
|
|
||||||
- name: Build the game
|
- name: Build the game
|
||||||
run: |
|
run: |
|
||||||
make clean release-linux
|
just clean
|
||||||
|
just build-linux release
|
||||||
mkdir out/
|
mkdir out/
|
||||||
cp build/linux/TR1X out/
|
cp build/linux/TR1X out/
|
||||||
cp -r bin/* out/
|
cp -r bin/* out/
|
||||||
|
@ -228,7 +233,8 @@ jobs:
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y make p7zip-full
|
sudo apt-get install -y p7zip-full
|
||||||
|
sudo snap install --edge --classic just
|
||||||
|
|
||||||
- name: Package the game
|
- name: Package the game
|
||||||
run: |
|
run: |
|
||||||
|
|
|
@ -20,8 +20,9 @@ Subsequent builds:
|
||||||
|
|
||||||
- **With Docker**:
|
- **With Docker**:
|
||||||
|
|
||||||
Make sure to install Docker and make, then run `make debug`.
|
Make sure to install Docker and [just](https://github.com/casey/just), then
|
||||||
The binaries should appear in the `build/` directory.
|
run `just`. The binaries should appear in the `build/` directory.
|
||||||
|
To see list of possible build targets, run `just -l`.
|
||||||
|
|
||||||
- **Without Docker**:
|
- **Without Docker**:
|
||||||
|
|
||||||
|
@ -98,7 +99,7 @@ Other things:
|
||||||
|
|
||||||
This project uses `clang-format` to take care of automatic code formatting, and
|
This project uses `clang-format` to take care of automatic code formatting, and
|
||||||
`include-what-you-use` to remove unused `#include`s. To ensure your code
|
`include-what-you-use` to remove unused `#include`s. To ensure your code
|
||||||
conforms to the standard, please run `make lint` after each commit. If for some
|
conforms to the standard, please run `just lint` after each commit. If for some
|
||||||
reason you can't run it, don't worry, our CI pipeline will show what needs to
|
reason you can't run it, don't worry, our CI pipeline will show what needs to
|
||||||
be changed in case of mistakes.
|
be changed in case of mistakes.
|
||||||
|
|
||||||
|
|
78
Makefile
78
Makefile
|
@ -1,78 +0,0 @@
|
||||||
CWD = $(shell pwd)
|
|
||||||
HOST_USER_UID = $(shell id -u)
|
|
||||||
HOST_USER_GID = $(shell id -g)
|
|
||||||
|
|
||||||
define build
|
|
||||||
$(eval TARGET := $(1))
|
|
||||||
mkdir -p build
|
|
||||||
docker run --rm \
|
|
||||||
--user $(HOST_USER_UID):$(HOST_USER_GID) \
|
|
||||||
-e TARGET="$(TARGET)" \
|
|
||||||
-v $(CWD):/app/ \
|
|
||||||
rrdash/tr1x:latest
|
|
||||||
endef
|
|
||||||
|
|
||||||
define build-linux
|
|
||||||
$(eval TARGET := $(1))
|
|
||||||
mkdir -p build
|
|
||||||
docker run --rm \
|
|
||||||
--user $(HOST_USER_UID):$(HOST_USER_GID) \
|
|
||||||
-e TARGET="$(TARGET)" \
|
|
||||||
-v $(CWD):/app/ \
|
|
||||||
rrdash/tr1x-linux:latest
|
|
||||||
endef
|
|
||||||
|
|
||||||
debug:
|
|
||||||
$(call build,debug)
|
|
||||||
|
|
||||||
debugopt:
|
|
||||||
$(call build,debugoptimized)
|
|
||||||
|
|
||||||
release:
|
|
||||||
$(call build,release)
|
|
||||||
|
|
||||||
build-docker-image:
|
|
||||||
docker build --progress plain . -f docker/game-win/Dockerfile -t rrdash/tr1x
|
|
||||||
|
|
||||||
build-docker-image-linux:
|
|
||||||
docker build --progress plain . -f docker/game-linux/Dockerfile -t rrdash/tr1x-linux
|
|
||||||
|
|
||||||
debug-linux:
|
|
||||||
$(call build-linux,debug)
|
|
||||||
|
|
||||||
debugopt-linux:
|
|
||||||
$(call build-linux,debugoptimized)
|
|
||||||
|
|
||||||
release-linux:
|
|
||||||
$(call build-linux,release)
|
|
||||||
|
|
||||||
clean:
|
|
||||||
-find build/ -type f -delete
|
|
||||||
-find tools/ -type f \( -ipath '*/out/*' -or -ipath '*/bin/*' -or -ipath '*/obj/*' \) -delete
|
|
||||||
-find . -mindepth 1 -empty -type d -delete
|
|
||||||
|
|
||||||
lint_imports:
|
|
||||||
tools/sort_imports
|
|
||||||
|
|
||||||
lint_format:
|
|
||||||
bash -c 'shopt -s globstar; clang-format -i **/*.c **/*.h'
|
|
||||||
|
|
||||||
lint: lint_format lint_imports
|
|
||||||
|
|
||||||
installer:
|
|
||||||
docker build . -f docker/installer/Dockerfile -t rrdash/tr1x_installer
|
|
||||||
docker run --rm \
|
|
||||||
--user $(HOST_USER_UID):$(HOST_USER_GID) \
|
|
||||||
--network host \
|
|
||||||
-v $(CWD):/app/ \
|
|
||||||
rrdash/tr1x_installer
|
|
||||||
|
|
||||||
config:
|
|
||||||
docker build . -f docker/config/Dockerfile -t rrdash/tr1x_config
|
|
||||||
docker run --rm \
|
|
||||||
--user $(HOST_USER_UID):$(HOST_USER_GID) \
|
|
||||||
--network host \
|
|
||||||
-v $(CWD):/app/ \
|
|
||||||
rrdash/tr1x_config
|
|
||||||
|
|
||||||
.PHONY: debug debugopt release clean lint_imports lint_format lint installer config
|
|
55
justfile
Normal file
55
justfile
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
CWD := `pwd`
|
||||||
|
HOST_USER_UID := `id -u`
|
||||||
|
HOST_USER_GID := `id -g`
|
||||||
|
|
||||||
|
default: (build-win "debug")
|
||||||
|
|
||||||
|
_docker_build dockerfile tag force="0":
|
||||||
|
#!/usr/bin/env sh
|
||||||
|
docker images | grep {{tag}} >/dev/null
|
||||||
|
if [ $? -eq 0 ] && [ "{{force}}" = "0" ]; then
|
||||||
|
echo "Docker image {{dockerfile}} is already built"
|
||||||
|
else
|
||||||
|
echo "Building Docker image: {{dockerfile}} → {{tag}}"
|
||||||
|
docker build \
|
||||||
|
--progress plain \
|
||||||
|
. \
|
||||||
|
-f {{dockerfile}} \
|
||||||
|
-t {{tag}}
|
||||||
|
fi
|
||||||
|
|
||||||
|
_docker_run *args:
|
||||||
|
@echo "Running docker image: {{args}}"
|
||||||
|
docker run \
|
||||||
|
--rm \
|
||||||
|
--user \
|
||||||
|
{{HOST_USER_UID}}:{{HOST_USER_GID}} \
|
||||||
|
--network host \
|
||||||
|
-v {{CWD}}:/app/ \
|
||||||
|
{{args}}
|
||||||
|
|
||||||
|
|
||||||
|
image-win force="1": (_docker_build "docker/game-win/Dockerfile" "rrdash/tr1x" force)
|
||||||
|
image-linux force="1": (_docker_build "docker/game-linux/Dockerfile" "rrdash/tr1x-linux" force)
|
||||||
|
image-config force="1": (_docker_build "docker/config/Dockerfile" "rrdash/tr1x-config" force)
|
||||||
|
image-installer force="1": (_docker_build "docker/installer/Dockerfile" "rrdash/tr1x-installer" force)
|
||||||
|
|
||||||
|
build-win target='debug': (image-win "0") (_docker_run "-e" "TARGET="+target "rrdash/tr1x")
|
||||||
|
build-linux target='debug': (image-linux "0") (_docker_run "-e" "TARGET="+target "rrdash/tr1x-linux")
|
||||||
|
build-config: (image-config "0") (_docker_run "rrdash/tr1x-config")
|
||||||
|
build-installer: (image-installer "0") (_docker_run "rrdash/tr1x-installer")
|
||||||
|
|
||||||
|
clean:
|
||||||
|
-find build/ -type f -delete
|
||||||
|
-find tools/ -type f \( -ipath '*/out/*' -or -ipath '*/bin/*' -or -ipath '*/obj/*' \) -delete
|
||||||
|
-find . -mindepth 1 -empty -type d -delete
|
||||||
|
|
||||||
|
lint-imports:
|
||||||
|
tools/sort_imports
|
||||||
|
|
||||||
|
lint-format:
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
shopt -s globstar
|
||||||
|
clang-format -i **/*.{c,h}
|
||||||
|
|
||||||
|
lint: (lint-imports) (lint-format)
|
Loading…
Add table
Add a link
Reference in a new issue