mirror of
https://github.com/javalsai/lidm.git
synced 2025-07-05 15:28:42 +02:00
Merge pull request #52 from grialion/feat-help-version-menu
feat: help, version menu
This commit is contained in:
commit
9fe938b96a
@ -6,3 +6,6 @@ AllowShortIfStatementsOnASingleLine: WithoutElse
|
||||
AlignAfterOpenBracket: Align
|
||||
BinPackParameters: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: true
|
||||
|
||||
IndentPPDirectives: BeforeHash
|
||||
IndentGotoLabels: true
|
||||
|
130
.github/workflows/build.yml
vendored
Normal file
130
.github/workflows/build.yml
vendored
Normal file
@ -0,0 +1,130 @@
|
||||
name: Build
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
|
||||
jobs:
|
||||
build-linux-amd64:
|
||||
name: amd64
|
||||
runs-on: ubuntu-24.04
|
||||
permissions: write-all
|
||||
steps:
|
||||
- uses: awalsh128/cache-apt-pkgs-action@latest
|
||||
with:
|
||||
packages: "git libpam0g-dev"
|
||||
version: 1.0
|
||||
- uses: actions/checkout@v4
|
||||
- id: build
|
||||
run: ARCH=amd64 assets/github_scripts/build.sh
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: build-amd64
|
||||
path: lidm-amd64
|
||||
retention-days: 1
|
||||
|
||||
build-linux-i386:
|
||||
name: i386
|
||||
runs-on: ubuntu-24.04
|
||||
permissions: write-all
|
||||
|
||||
steps:
|
||||
- uses: awalsh128/cache-apt-pkgs-action@latest
|
||||
with:
|
||||
packages: "git libpam0g-dev gcc-multilib"
|
||||
version: 1.0
|
||||
- uses: actions/checkout@v4
|
||||
- run: |
|
||||
sudo dpkg --add-architecture i386
|
||||
sudo apt-get update -y
|
||||
sudo apt-get install -y libpam0g-dev:i386
|
||||
|
||||
- id: build
|
||||
run: ARCH=i386 assets/github_scripts/build.sh CFLAGS="-O3 -Wall -m32"
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: build-i386
|
||||
path: lidm-i386
|
||||
retention-days: 1
|
||||
|
||||
build-linux-aarch64:
|
||||
name: aarch64
|
||||
runs-on: ubuntu-24.04
|
||||
permissions: write-all
|
||||
steps:
|
||||
- uses: awalsh128/cache-apt-pkgs-action@latest
|
||||
with:
|
||||
packages: "git"
|
||||
version: 1.0
|
||||
- uses: actions/checkout@v4
|
||||
- uses: uraimo/run-on-arch-action@v2
|
||||
with:
|
||||
arch: aarch64
|
||||
distro: ubuntu22.04
|
||||
githubToken: ${{ github.token }}
|
||||
install: |
|
||||
apt-get update && \
|
||||
apt-get install -y make gcc libpam0g-dev
|
||||
run: ARCH=aarch64 GITHUB_STEP_SUMMARY=gss.out GITHUB_OUTPUT=go.out assets/github_scripts/build.sh
|
||||
- run: set +e; cat gss.out >>"$GITHUB_STEP_SUMMARY"; cat go.out >>"$GITHUB_OUTPUT"
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: build-aarch64
|
||||
path: lidm-aarch64
|
||||
retention-days: 1
|
||||
|
||||
build-linux-armv7:
|
||||
name: armv7
|
||||
runs-on: ubuntu-24.04
|
||||
permissions: write-all
|
||||
steps:
|
||||
- uses: awalsh128/cache-apt-pkgs-action@latest
|
||||
with:
|
||||
packages: "git"
|
||||
version: 1.0
|
||||
- uses: actions/checkout@v4
|
||||
- uses: uraimo/run-on-arch-action@v2
|
||||
with:
|
||||
arch: armv7
|
||||
distro: ubuntu22.04
|
||||
githubToken: ${{ github.token }}
|
||||
install: |
|
||||
apt-get update && \
|
||||
apt-get install -y make gcc libpam0g-dev
|
||||
run: ARCH=armv7 GITHUB_STEP_SUMMARY=gss.out GITHUB_OUTPUT=go.out assets/github_scripts/build.sh
|
||||
- run: set +e; cat gss.out >>"$GITHUB_STEP_SUMMARY"; cat go.out >>"$GITHUB_OUTPUT"
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: build-armv7
|
||||
path: lidm-armv7
|
||||
retention-days: 1
|
||||
|
||||
build-linux-riscv64:
|
||||
name: riscv64
|
||||
runs-on: ubuntu-24.04
|
||||
permissions: write-all
|
||||
steps:
|
||||
- uses: awalsh128/cache-apt-pkgs-action@latest
|
||||
with:
|
||||
packages: "git"
|
||||
version: 1.0
|
||||
- uses: actions/checkout@v4
|
||||
- uses: uraimo/run-on-arch-action@v2
|
||||
with:
|
||||
arch: riscv64
|
||||
distro: ubuntu22.04
|
||||
githubToken: ${{ github.token }}
|
||||
install: |
|
||||
apt-get update && \
|
||||
apt-get install -y make gcc libpam0g-dev
|
||||
run: ARCH=riscv64 GITHUB_STEP_SUMMARY=gss.out GITHUB_OUTPUT=go.out assets/github_scripts/build.sh
|
||||
- run: set +e; cat gss.out >>"$GITHUB_STEP_SUMMARY"; cat go.out >>"$GITHUB_OUTPUT"
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: build-riscv64
|
||||
path: lidm-riscv64
|
||||
retention-days: 1
|
291
.github/workflows/check-and-build.yml
vendored
291
.github/workflows/check-and-build.yml
vendored
@ -1,291 +0,0 @@
|
||||
name: Check and Build
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
set-statuses:
|
||||
required: false
|
||||
default: true
|
||||
type: boolean
|
||||
|
||||
jobs:
|
||||
spellcheck:
|
||||
name: Check Grammar
|
||||
runs-on: ubuntu-24.04
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: awalsh128/cache-apt-pkgs-action@latest
|
||||
with:
|
||||
packages: "codespell"
|
||||
version: 1.0
|
||||
- run: codespell
|
||||
|
||||
shellcheck:
|
||||
name: Shell Check
|
||||
runs-on: ubuntu-24.04
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: awalsh128/cache-apt-pkgs-action@latest
|
||||
with:
|
||||
packages: "shellcheck"
|
||||
version: 1.0
|
||||
- run: find . -type f -name '*.sh' -not -path './assets/pkg/aur/*/src/*' | xargs shellcheck
|
||||
|
||||
clangcheck:
|
||||
name: Clang Check
|
||||
runs-on: ubuntu-24.04
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: awalsh128/cache-apt-pkgs-action@latest
|
||||
with:
|
||||
packages: "clang-format clang-tidy"
|
||||
version: 1.0
|
||||
- run: clang-format -ni src/*.c include/*.h
|
||||
# TODO: include when the errors/warnings are bearable
|
||||
#- run: clang-tidy src/*.c include/*.h
|
||||
|
||||
build-linux-amd64:
|
||||
name: Build for amd64
|
||||
runs-on: ubuntu-24.04
|
||||
permissions: write-all
|
||||
needs: [spellcheck, shellcheck, clangcheck]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: myrotvorets/set-commit-status-action@master
|
||||
if: inputs.set-statuses
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
status: pending
|
||||
description: ${{ steps.build.outputs.DESCR }}
|
||||
context: Build for amd64
|
||||
- uses: awalsh128/cache-apt-pkgs-action@latest
|
||||
with:
|
||||
packages: "libpam0g-dev"
|
||||
version: 1.0
|
||||
- id: build
|
||||
run: |
|
||||
make -j$(nproc) 2> /tmp/stderr || (ERR=$?; cat /tmp/stderr >&2; exit $ERR)
|
||||
cat /tmp/stderr >&2
|
||||
|
||||
HSIZE="$(stat --printf="%s" lidm | numfmt --to=iec-i)B"
|
||||
WARNS="$(cat /tmp/stderr | grep '^[^ ]*\.[ch]:' | wc -l)"
|
||||
mv lidm lidm-amd64
|
||||
|
||||
echo "DESCR='$HSIZE, $WARNS warnings'" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- uses: myrotvorets/set-commit-status-action@master
|
||||
if: inputs.set-statuses
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
status: ${{ job.status }}
|
||||
description: ${{ steps.build.outputs.DESCR }}
|
||||
context: Build for amd64
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: build-amd64
|
||||
path: lidm-amd64
|
||||
retention-days: 1
|
||||
|
||||
build-linux-i386:
|
||||
name: Build for i386
|
||||
runs-on: ubuntu-24.04
|
||||
permissions: write-all
|
||||
needs: [spellcheck, shellcheck, clangcheck]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: myrotvorets/set-commit-status-action@master
|
||||
if: inputs.set-statuses
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
status: pending
|
||||
description: ${{ steps.build.outputs.DESCR }}
|
||||
context: Build for i386
|
||||
- uses: awalsh128/cache-apt-pkgs-action@latest
|
||||
with:
|
||||
packages: "libpam0g-dev gcc-multilib"
|
||||
version: 1.0
|
||||
- run: |
|
||||
sudo dpkg --add-architecture i386
|
||||
sudo apt-get update -y
|
||||
sudo apt-get install -y libpam0g-dev:i386
|
||||
|
||||
- id: build
|
||||
run: |
|
||||
make -j$(nproc) CFLAGS="-O3 -Wall -m32" 2> /tmp/stderr || (ERR=$?; cat /tmp/stderr >&2; exit $ERR)
|
||||
cat /tmp/stderr >&2
|
||||
|
||||
HSIZE="$(stat --printf="%s" lidm | numfmt --to=iec-i)B"
|
||||
WARNS="$(cat /tmp/stderr | grep '^[^ ]*\.[ch]:' | wc -l)"
|
||||
mv lidm lidm-i386
|
||||
|
||||
echo "DESCR='$HSIZE, $WARNS warnings'" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- uses: myrotvorets/set-commit-status-action@master
|
||||
if: inputs.set-statuses
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
status: ${{ job.status }}
|
||||
description: ${{ steps.build.outputs.DESCR }}
|
||||
context: Build for i386
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: build-i386
|
||||
path: lidm-i386
|
||||
retention-days: 1
|
||||
|
||||
build-linux-aarch64:
|
||||
name: Build for aarch64
|
||||
runs-on: ubuntu-24.04
|
||||
permissions: write-all
|
||||
needs: [spellcheck, shellcheck, clangcheck]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: myrotvorets/set-commit-status-action@master
|
||||
if: inputs.set-statuses
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
status: pending
|
||||
description: ${{ steps.status.outputs.DESCR }}
|
||||
context: Build for aarch64
|
||||
- uses: uraimo/run-on-arch-action@v2
|
||||
with:
|
||||
arch: aarch64
|
||||
distro: ubuntu22.04
|
||||
githubToken: ${{ github.token }}
|
||||
install: |
|
||||
apt-get update && \
|
||||
apt-get install -y make gcc libpam0g-dev
|
||||
run: |
|
||||
make -j$(nproc) 2> /tmp/stderr || (ERR=$?; cat /tmp/stderr >&2; exit $ERR)
|
||||
|
||||
cat /tmp/stderr >&2
|
||||
mv lidm lidm-aarch64
|
||||
|
||||
- if: inputs.set-statuses
|
||||
id: status
|
||||
run: |
|
||||
HSIZE="$(stat --printf="%s" lidm-aarch64 | numfmt --to=iec-i)B"
|
||||
WARNS="$(cat /tmp/stderr | grep '^[^ ]*\.[ch]:' | wc -l)"
|
||||
|
||||
echo "DESCR='$HSIZE, $WARNS warnings'" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- uses: myrotvorets/set-commit-status-action@master
|
||||
if: inputs.set-statuses
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
status: ${{ job.status }}
|
||||
description: ${{ steps.status.outputs.DESCR }}
|
||||
context: Build for aarch64
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: build-aarch64
|
||||
path: lidm-aarch64
|
||||
retention-days: 1
|
||||
|
||||
build-linux-armv7:
|
||||
name: Build for armv7
|
||||
runs-on: ubuntu-24.04
|
||||
permissions: write-all
|
||||
needs: [spellcheck, shellcheck, clangcheck]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: myrotvorets/set-commit-status-action@master
|
||||
if: inputs.set-statuses
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
status: pending
|
||||
description: ${{ steps.status.outputs.DESCR }}
|
||||
context: Build for armv7
|
||||
- uses: uraimo/run-on-arch-action@v2
|
||||
with:
|
||||
arch: armv7
|
||||
distro: ubuntu22.04
|
||||
githubToken: ${{ github.token }}
|
||||
install: |
|
||||
apt-get update && \
|
||||
apt-get install -y make gcc libpam0g-dev
|
||||
run: |
|
||||
make -j$(nproc) 2> /tmp/stderr || (ERR=$?; cat /tmp/stderr >&2; exit $ERR)
|
||||
|
||||
cat /tmp/stderr >&2
|
||||
mv lidm lidm-armv7
|
||||
|
||||
- if: inputs.set-statuses
|
||||
id: status
|
||||
run: |
|
||||
HSIZE="$(stat --printf="%s" lidm-armv7 | numfmt --to=iec-i)B"
|
||||
WARNS="$(cat /tmp/stderr | grep '^[^ ]*\.[ch]:' | wc -l)"
|
||||
|
||||
echo "DESCR='$HSIZE, $WARNS warnings'" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- uses: myrotvorets/set-commit-status-action@master
|
||||
if: inputs.set-statuses
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
status: ${{ job.status }}
|
||||
description: ${{ steps.status.outputs.DESCR }}
|
||||
context: Build for armv7
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: build-armv7
|
||||
path: lidm-armv7
|
||||
retention-days: 1
|
||||
|
||||
build-linux-riscv64:
|
||||
name: Build for riscv64
|
||||
runs-on: ubuntu-24.04
|
||||
permissions: write-all
|
||||
needs: [spellcheck, shellcheck, clangcheck]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: myrotvorets/set-commit-status-action@master
|
||||
if: inputs.set-statuses
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
status: pending
|
||||
description: ${{ steps.status.outputs.DESCR }}
|
||||
context: Build for riscv64
|
||||
- uses: uraimo/run-on-arch-action@v2
|
||||
with:
|
||||
arch: riscv64
|
||||
distro: ubuntu22.04
|
||||
githubToken: ${{ github.token }}
|
||||
install: |
|
||||
apt-get update && \
|
||||
apt-get install -y make gcc libpam0g-dev
|
||||
run: |
|
||||
make -j$(nproc) 2> /tmp/stderr || (ERR=$?; cat /tmp/stderr >&2; exit $ERR)
|
||||
|
||||
cat /tmp/stderr >&2
|
||||
mv lidm lidm-riscv64
|
||||
|
||||
- if: inputs.set-statuses
|
||||
id: status
|
||||
run: |
|
||||
HSIZE="$(stat --printf="%s" lidm-riscv64 | numfmt --to=iec-i)B"
|
||||
WARNS="$(cat /tmp/stderr | grep '^[^ ]*\.[ch]:' | wc -l)"
|
||||
|
||||
echo "DESCR='$HSIZE, $WARNS warnings'" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- uses: myrotvorets/set-commit-status-action@master
|
||||
if: inputs.set-statuses
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
status: ${{ job.status }}
|
||||
description: ${{ steps.status.outputs.DESCR }}
|
||||
context: Build for riscv64
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: build-riscv64
|
||||
path: lidm-riscv64
|
||||
retention-days: 1
|
43
.github/workflows/check.yml
vendored
Normal file
43
.github/workflows/check.yml
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
name: Check
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
|
||||
jobs:
|
||||
spellcheck:
|
||||
name: Grammar
|
||||
runs-on: ubuntu-24.04
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: awalsh128/cache-apt-pkgs-action@latest
|
||||
with:
|
||||
packages: "codespell"
|
||||
version: 1.0
|
||||
- run: codespell
|
||||
|
||||
shellcheck:
|
||||
name: Shellcheck
|
||||
runs-on: ubuntu-24.04
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: awalsh128/cache-apt-pkgs-action@latest
|
||||
with:
|
||||
packages: "shellcheck"
|
||||
version: 1.0
|
||||
- run: find . -type f -name '*.sh' -not -path './assets/pkg/aur/*/src/*' | xargs shellcheck
|
||||
|
||||
clangcheck:
|
||||
name: Clang
|
||||
runs-on: ubuntu-24.04
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: awalsh128/cache-apt-pkgs-action@latest
|
||||
with:
|
||||
packages: "clang-format clang-tidy bear libpam0g-dev"
|
||||
version: 1.0
|
||||
- run: bear -- make
|
||||
- run: clang-format -ni src/*.c include/*.h
|
||||
- run: clang-tidy -p . src/*.c include/*.h
|
62
.github/workflows/make-release.yml
vendored
62
.github/workflows/make-release.yml
vendored
@ -2,25 +2,51 @@ name: Check and Build Release
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version:
|
||||
required: true
|
||||
default: ''
|
||||
type: string
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Check and Build
|
||||
uses: ./.github/workflows/check-and-build.yml
|
||||
permissions: write-all
|
||||
with:
|
||||
set-statuses: false
|
||||
|
||||
release:
|
||||
name: Make Release v${{ inputs.version }}
|
||||
release-checks:
|
||||
name: Release Checks
|
||||
runs-on: ubuntu-24.04
|
||||
permissions: write-all
|
||||
needs: build
|
||||
outputs:
|
||||
VERSION: ${{ steps.check-ver-changed.outputs.VERSION }}
|
||||
steps:
|
||||
- uses: awalsh128/cache-apt-pkgs-action@latest
|
||||
with:
|
||||
packages: "git"
|
||||
version: 1.0
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Check Version Changed
|
||||
id: check-ver-changed
|
||||
run: |
|
||||
GIT_TAG=$(git describe --no-long --abbrev=0 --tags --always)
|
||||
MAKE_TAG=$(make print-version)
|
||||
|
||||
if [[ "$GIT_TAG" == "v$MAKE_TAG" ]]; then
|
||||
echo "ERR: Git tag matches makefile, did you bump Makefile up?" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "VERSION=$MAKE_TAG" >> "$GITHUB_OUTPUT"
|
||||
|
||||
|
||||
check:
|
||||
name: Check
|
||||
needs: release-checks
|
||||
uses: ./.github/workflows/check.yml
|
||||
permissions: write-all
|
||||
|
||||
build:
|
||||
name: Build
|
||||
needs: release-checks
|
||||
uses: ./.github/workflows/build.yml
|
||||
permissions: write-all
|
||||
|
||||
release:
|
||||
name: Make Release v${{ needs.release-checks.outputs.VERSION }}
|
||||
runs-on: ubuntu-24.04
|
||||
permissions: write-all
|
||||
needs: [ release-checks, check, build ]
|
||||
steps:
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
@ -30,7 +56,7 @@ jobs:
|
||||
|
||||
- uses: ncipollo/release-action@v1
|
||||
with:
|
||||
tag: v${{ inputs.version }}
|
||||
tag: v${{ needs.release-checks.outputs.VERSION }}
|
||||
commit: ${{ github.sha }}
|
||||
artifacts: builds/lidm-*
|
||||
artifactErrorsFailBuild: true
|
||||
@ -41,7 +67,7 @@ jobs:
|
||||
runs-on: ubuntu-24.04
|
||||
container: archlinux:latest
|
||||
permissions: write-all
|
||||
needs: release
|
||||
needs: [ release-checks, release ]
|
||||
steps:
|
||||
- run: pacman -Sy --noconfirm git github-cli base-devel pacman-contrib
|
||||
|
||||
@ -53,7 +79,7 @@ jobs:
|
||||
|
||||
cd "assets/pkg/aur"
|
||||
chown nobody:nobody . -R
|
||||
su - -s /bin/bash nobody -c "$PWD/update-pkgs.sh ${{ inputs.version }}"
|
||||
su - -s /bin/bash nobody -c "$PWD/update-pkgs.sh ${{ needs.release-checks.outputs.VERSION }}"
|
||||
su - -s /bin/bash nobody -c "$PWD/test-makepkg.sh" # This will also update -git pkgver
|
||||
chown $UID:$(id -g) . -R
|
||||
|
||||
|
13
.github/workflows/push.yml
vendored
13
.github/workflows/push.yml
vendored
@ -1,5 +1,4 @@
|
||||
# Kinda based by https://github.com/myrotvorets/set-commit-status-action/actions/runs/12344741285/workflow
|
||||
name: Push Checks
|
||||
name: _
|
||||
|
||||
on:
|
||||
push:
|
||||
@ -9,7 +8,11 @@ on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
check-and-build:
|
||||
name: Check and Build
|
||||
uses: ./.github/workflows/check-and-build.yml
|
||||
check:
|
||||
name: Check
|
||||
uses: ./.github/workflows/check.yml
|
||||
permissions: write-all
|
||||
build:
|
||||
name: Build
|
||||
uses: ./.github/workflows/build.yml
|
||||
permissions: write-all
|
||||
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -8,3 +8,5 @@ valgrind-out.txt
|
||||
|
||||
# nix build result
|
||||
result
|
||||
|
||||
include/version.h
|
||||
|
32
Makefile
32
Makefile
@ -1,3 +1,6 @@
|
||||
VERSION = 1.2.0
|
||||
.DEFAULT_GOAL := lidm
|
||||
|
||||
CDIR=src
|
||||
LDIR=lib
|
||||
IDIR=include
|
||||
@ -7,17 +10,27 @@ PREFIX=/usr
|
||||
|
||||
CC?=gcc
|
||||
CFLAGS?=-O3 -Wall
|
||||
_CFLAGS=-I$(DIR)
|
||||
ALLFLAGS=$(CFLAGS) -I$(IDIR)
|
||||
|
||||
LIBS=-lpam
|
||||
|
||||
_DEPS = log.h util.h ui.h ui_state.h config.h desktop.h auth.h ofield.h efield.h keys.h users.h sessions.h chvt.h macros.h launch_state.h
|
||||
_DEPS = version.h log.h util.h ui.h ui_state.h config.h desktop.h auth.h ofield.h efield.h keys.h users.h sessions.h chvt.h macros.h launch_state.h
|
||||
DEPS = $(patsubst %,$(IDIR)/%,$(_DEPS))
|
||||
|
||||
_OBJ = main.o log.o util.o ui.o ui_state.o config.o desktop.o auth.o ofield.o efield.o users.o sessions.o chvt.o launch_state.o
|
||||
OBJ = $(patsubst %,$(ODIR)/%,$(_OBJ))
|
||||
|
||||
$(IDIR)/version.h: Makefile .git/HEAD
|
||||
@tmp=$$(mktemp); \
|
||||
printf '' > $$tmp; \
|
||||
echo '#define LIDM_VERSION "'$(VERSION)'"' >> $$tmp; \
|
||||
echo '#define LIDM_GIT_REV "'$$(git describe --long --tags --always)'"' >> $$tmp; \
|
||||
echo '#define LIDM_BUILD_TS '$$(date +%s) >> $$tmp; \
|
||||
if ! cmp -s $$tmp $@; then \
|
||||
mv $$tmp $@; \
|
||||
fi; \
|
||||
rm -f $$tmp;
|
||||
|
||||
$(ODIR)/%.o: $(CDIR)/%.c $(DEPS)
|
||||
@mkdir -p $(ODIR)
|
||||
$(CC) -c -o $@ $< $(ALLFLAGS)
|
||||
@ -25,7 +38,6 @@ $(ODIR)/%.o: $(CDIR)/%.c $(DEPS)
|
||||
lidm: $(OBJ)
|
||||
$(CC) -o $@ $^ $(ALLFLAGS) $(LIBS)
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -f $(ODIR)/*.o lidm
|
||||
|
||||
@ -78,3 +90,17 @@ pre-commit:
|
||||
find . -type f -name '*.sh' -not -path './assets/pkg/aur/*/src/*' | xargs shellcheck
|
||||
clang-format -i $$(git ls-files "*.c" "*.h")
|
||||
clang-tidy -p . $$(git ls-files "*.c" "*.h")
|
||||
|
||||
print-version:
|
||||
@echo $(VERSION)
|
||||
|
||||
.PHONY: clean \
|
||||
install uninstall \
|
||||
install-service \
|
||||
install-service-s6 \
|
||||
install-service-dinit \
|
||||
install-service-runit \
|
||||
install-service-openrc \
|
||||
install-service-systemd \
|
||||
pre-commit \
|
||||
print-version
|
||||
|
47
assets/github_scripts/build.sh
Executable file
47
assets/github_scripts/build.sh
Executable file
@ -0,0 +1,47 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
if [ -z "$ARCH" ]; then
|
||||
echo "\$ARCH not present" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ERR=0
|
||||
# shellcheck disable=SC2034
|
||||
make -j"$(nproc)" "$@" 2> /tmp/stderr || ERR=$?
|
||||
|
||||
BSIZE=$(stat --printf="%s" lidm)
|
||||
HSIZE=$(numfmt --to=iec-i<<<"$BSIZE")B
|
||||
WARNS=$(
|
||||
{ grep -E '^[^ ]+\.[ch]:[0-9]+:[0-9]+: [a-z]+:' /tmp/stderr || :; } \
|
||||
| sed -E 's/^([^ ]+\.[ch]):([0-9]+):([0-9]+): ([a-z]+): (.*)$/::\4 file=\1,line=\2,col=\3::\5/'
|
||||
)
|
||||
WARNS_NUM=$({ [[ "$WARNS" == "" ]] && echo 0; } || wc -l <<<"$WARNS")
|
||||
|
||||
echo "$WARNS"
|
||||
|
||||
{
|
||||
echo "# Build for $ARCH"
|
||||
echo ""
|
||||
if [ -s "/tmp/stderr" ]; then
|
||||
echo "<details><summary><code>stderr</code></summary>"
|
||||
echo ""
|
||||
echo "\`\`\`"
|
||||
cat "/tmp/stderr"
|
||||
echo "\`\`\`"
|
||||
echo ""
|
||||
echo "</details>"
|
||||
else
|
||||
echo "*no \`stderr\` to show*"
|
||||
fi
|
||||
echo ""
|
||||
echo "## Stats"
|
||||
echo "* **Filesize:** $HSIZE ($BSIZE B)"
|
||||
echo "* **Warnings & Errors:** $WARNS_NUM"
|
||||
} >> "$GITHUB_STEP_SUMMARY"
|
||||
|
||||
if [ "$ERR" -ne 0 ]; then exit "$ERR"; fi
|
||||
|
||||
mv lidm lidm-"$ARCH"
|
||||
|
||||
echo "DESCR='$HSIZE, $WARNS_NUM warnings'" >> "$GITHUB_OUTPUT"
|
@ -3,21 +3,31 @@
|
||||
|
||||
// Do we just replace the compiler with clang??
|
||||
#if defined(__clang__)
|
||||
#define NULLABLE _Nullable
|
||||
#define NULLABLE _Nullable
|
||||
#else
|
||||
#define NULLABLE
|
||||
#define NULLABLE
|
||||
#endif
|
||||
|
||||
#if defined(__clang__)
|
||||
#define NNULLABLE _Nonnull
|
||||
#define NNULLABLE _Nonnull
|
||||
#else
|
||||
#define NNULLABLE
|
||||
#define NNULLABLE
|
||||
#endif
|
||||
|
||||
#if defined(__clang__)
|
||||
#define UNULLABLE _Null_unspecified
|
||||
#define UNULLABLE _Null_unspecified
|
||||
#else
|
||||
#define UNULLABLE
|
||||
#define UNULLABLE
|
||||
#endif
|
||||
|
||||
#if defined(__clang__)
|
||||
#define COMPILER_VERSION __VERSION__
|
||||
#elif defined(__GNUC__)
|
||||
#define xstr(s) str(s)
|
||||
#define str(s) #s
|
||||
|
||||
#define COMPILER_VERSION \
|
||||
"GCC " xstr(__GNUC__) "." xstr(__GNUC_MINOR__) "." xstr(__GNUC_PATCHLEVEL__)
|
||||
#endif
|
||||
|
||||
#define LEN(X) (sizeof(X) / sizeof((X)[0]))
|
||||
|
46
src/main.c
46
src/main.c
@ -1,18 +1,23 @@
|
||||
#include <pwd.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/types.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "chvt.h"
|
||||
#include "config.h"
|
||||
#include "log.h"
|
||||
#include "macros.h"
|
||||
#include "sessions.h"
|
||||
#include "ui.h"
|
||||
#include "users.h"
|
||||
#include "util.h"
|
||||
#include "version.h"
|
||||
|
||||
#define DATESTR_MAXBUFSIZE 0x20
|
||||
int main(int argc, char* argv[]) {
|
||||
// Logger
|
||||
char* log_output = getenv("LIDM_LOG");
|
||||
@ -27,8 +32,45 @@ int main(int argc, char* argv[]) {
|
||||
log_init(log_fd);
|
||||
}
|
||||
|
||||
// Chvt
|
||||
if (argc == 2) chvt_str(argv[1]);
|
||||
if (argc == 2) {
|
||||
if (strcmp(argv[1], "-v") == 0 || strcmp(argv[1], "--version") == 0) {
|
||||
// NOLINTBEGIN(clang-analyzer-deadcode.DeadStores)
|
||||
char* version = "?";
|
||||
char* revision = "?";
|
||||
char* builddate = "?";
|
||||
char* compilever = "?";
|
||||
// NOLINTEND(clang-analyzer-deadcode.DeadStores)
|
||||
#ifdef LIDM_VERSION
|
||||
version = LIDM_VERSION;
|
||||
#endif
|
||||
#ifdef LIDM_GIT_REV
|
||||
revision = LIDM_GIT_REV;
|
||||
#endif
|
||||
#ifdef LIDM_BUILD_TS
|
||||
time_t ts = LIDM_BUILD_TS;
|
||||
char date_buf[DATESTR_MAXBUFSIZE];
|
||||
builddate = date_buf;
|
||||
if (strftime(date_buf, 0xff, "%Y-%m-%dT%H:%M:%SZ", localtime(&ts)) > 0)
|
||||
builddate = date_buf;
|
||||
#endif
|
||||
#ifdef COMPILER_VERSION
|
||||
compilever = COMPILER_VERSION;
|
||||
#endif
|
||||
printf("lidm version %s (git %s, build date %s, compiler %s)\n", version,
|
||||
revision, builddate, compilever);
|
||||
return 0;
|
||||
}
|
||||
if (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0) {
|
||||
printf(
|
||||
"Usage: lidm [vt number]\n"
|
||||
"Options:\n"
|
||||
" -h, --help Display help menu\n"
|
||||
" -v, --version Display version information\n");
|
||||
return 0;
|
||||
}
|
||||
// Chvt
|
||||
chvt_str(argv[1]);
|
||||
}
|
||||
|
||||
struct config config = DEFAULT_CONFIG;
|
||||
char* conf_override = getenv("LIDM_CONF");
|
||||
|
Loading…
x
Reference in New Issue
Block a user