Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: 🪲 Test

on: [push, pull_request]
on: [push]

jobs:
run-tests:
Expand All @@ -11,3 +11,21 @@ jobs:
- uses: actions/checkout@v3
- run: |
make in-docker TARGET='test'

build-x86_64:
name: Run x86_64 build
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- run: |
make in-docker TARGET='dist' BUILD_TYPE='debug'

build-aarch64:
name: Run aarch64 build
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- run: |
make in-docker TARGET='dist' BUILD_TYPE='debug' TARGET_ARCH='aarch64-unknown-linux-gnu'
8 changes: 5 additions & 3 deletions .releaserc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ plugins:
# Execute commands to build the project
- - "@semantic-release/exec"
- shell: true
prepareCmd: "make in-docker TARGET='dist'"
prepareCmd: |
make in-docker TARGET='dist'
make in-docker TARGET='dist' TARGET_ARCH="aarch64-unknown-linux-gnu"

# Commit the following changes to git after other plugins have run
- - "@semantic-release/git"
Expand All @@ -46,5 +48,5 @@ plugins:
- assets:
- path: dist/powerstation-*.rpm
- path: dist/powerstation-*.rpm.sha256.txt
- path: dist/powerstation.tar.gz
- path: dist/powerstation.tar.gz.sha256.txt
- path: dist/powerstation-*.tar.gz
- path: dist/powerstation-*.tar.gz.sha256.txt
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ description = "Daemon for controlling TDP and performance over DBus"

[package.metadata.generate-rpm]
assets = [
{ source = "./target/release/powerstation", dest = "/usr/bin/powerstation", mode = "755" },
{ source = "target/release/powerstation", dest = "/usr/bin/powerstation", mode = "755" },
{ source = "./rootfs/usr/share/dbus-1/system.d/org.shadowblip.PowerStation.conf", dest = "/usr/share/dbus-1/system.d/org.shadowblip.PowerStation.conf", mode = "644" },
{ source = "./rootfs/usr/lib/systemd/system/powerstation.service", dest = "/usr/lib/systemd/system/powerstation.service", mode = "644" },
]
Expand Down
14 changes: 13 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
FROM rust:1.83
FROM rust:1.86

RUN dpkg --add-architecture arm64
RUN apt-get update && apt-get install -y \
cmake \
build-essential \
libpci-dev \
libclang-15-dev

RUN apt-get install -y \
g++-aarch64-linux-gnu \
libc6-dev-arm64-cross \
libpci-dev:arm64

RUN rustup target add aarch64-unknown-linux-gnu

ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc
ENV CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc
ENV CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++
35 changes: 19 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
NAME := $(shell grep 'name =' Cargo.toml | head -n 1 | cut -d'"' -f2)
VERSION := $(shell grep '^version =' Cargo.toml | cut -d'"' -f2)
ARCH := $(shell uname -m)
TARGET_ARCH ?= $(shell rustc -vV | sed -n 's/host: //p')
ARCH := $(shell echo "$(TARGET_ARCH)" | cut -d'-' -f1)
ALL_RS := $(shell find src -name '*.rs')
PREFIX ?= /usr
CACHE_DIR := .cache
Expand Down Expand Up @@ -28,7 +29,7 @@ help: ## Display this help.

.PHONY: install
install: build ## Install PowerStation to the given prefix (default: PREFIX=/usr)
install -D -m 755 target/release/powerstation \
install -D -m 755 target/$(TARGET_ARCH)/release/powerstation \
$(PREFIX)/bin/powerstation
install -D -m 644 rootfs/usr/share/dbus-1/system.d/org.shadowblip.PowerStation.conf \
$(PREFIX)/share/dbus-1/system.d/org.shadowblip.PowerStation.conf
Expand All @@ -47,21 +48,21 @@ uninstall: ## Uninstall PowerStation
##@ Development

.PHONY: debug
debug: target/debug/powerstation ## Build debug build
target/debug/powerstation: $(ALL_RS) Cargo.lock
cargo build
debug: target/$(TARGET_ARCH)/debug/powerstation ## Build debug build
target/$(TARGET_ARCH)/debug/powerstation: $(ALL_RS) Cargo.lock
cargo build --target $(TARGET_ARCH)

.PHONY: build
build: target/release/powerstation ## Build release build
target/release/powerstation: $(ALL_RS) Cargo.lock
cargo build --release
build: target/$(TARGET_ARCH)/release/powerstation ## Build release build
target/$(TARGET_ARCH)/release/powerstation: $(ALL_RS) Cargo.lock
cargo build --release --target $(TARGET_ARCH)

.PHONY: all
all: build debug ## Build release and debug builds

.PHONY: run
run: setup debug ## Build and run
sudo ./target/debug/powerstation
sudo ./target/$(TARGET_ARCH)/debug/powerstation

.PHONY: test
test: debug ## Build and run all tests
Expand All @@ -87,25 +88,25 @@ setup: /usr/share/dbus-1/system.d/org.shadowblip.PowerStation.conf ## Install db
##@ Distribution

.PHONY: dist
dist: dist/$(NAME).tar.gz dist/$(NAME)-$(VERSION)-1.$(ARCH).rpm ## Create all redistributable versions of the project
dist: dist/$(NAME)-$(ARCH).tar.gz dist/$(NAME)-$(VERSION)-1.$(ARCH).rpm ## Create all redistributable versions of the project

.PHONY: dist-archive
dist-archive: dist/powerstation.tar.gz ## Build a redistributable archive of the project
dist/powerstation.tar.gz: build
dist-archive: dist/powerstation-$(ARCH).tar.gz ## Build a redistributable archive of the project
dist/powerstation-$(ARCH).tar.gz: build
rm -rf $(CACHE_DIR)/powerstation
mkdir -p $(CACHE_DIR)/powerstation
$(MAKE) install PREFIX=$(CACHE_DIR)/powerstation/usr NO_RELOAD=true
mkdir -p dist
tar cvfz $@ -C $(CACHE_DIR) powerstation
cd dist && sha256sum powerstation.tar.gz > powerstation.tar.gz.sha256.txt
cd dist && sha256sum powerstation-$(ARCH).tar.gz > powerstation-$(ARCH).tar.gz.sha256.txt

.PHONY: dist-rpm
dist-rpm: dist/$(NAME)-$(VERSION)-1.$(ARCH).rpm ## Build a redistributable RPM package
dist/$(NAME)-$(VERSION)-1.$(ARCH).rpm: target/release/$(NAME)
dist/$(NAME)-$(VERSION)-1.$(ARCH).rpm: target/$(TARGET_ARCH)/release/$(NAME)
mkdir -p dist
cargo install cargo-generate-rpm
cargo generate-rpm
cp ./target/generate-rpm/$(NAME)-$(VERSION)-1.$(ARCH).rpm dist
cargo generate-rpm --target $(TARGET_ARCH)
cp ./target/$(TARGET_ARCH)/generate-rpm/$(NAME)-$(VERSION)-1.$(ARCH).rpm dist
cd dist && sha256sum $(NAME)-$(VERSION)-1.$(ARCH).rpm > $(NAME)-$(VERSION)-1.$(ARCH).rpm.sha256.txt

INTROSPECT_CARD ?= Card2
Expand Down Expand Up @@ -166,6 +167,8 @@ in-docker: docker-builder
-v $(PWD):/src \
--workdir /src \
-e HOME=/home/build \
-e TARGET_ARCH=$(TARGET_ARCH) \
-e PKG_CONFIG_SYSROOT_DIR="/usr/$(ARCH)-linux-gnu" \
--user $(shell id -u):$(shell id -g) \
$(IMAGE_NAME):$(IMAGE_TAG) \
make $(TARGET)
Expand Down