Skip to content

Commit

Permalink
[Refactor] Build scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
melianmiko committed Feb 8, 2025
1 parent cf53295 commit b32b177
Show file tree
Hide file tree
Showing 23 changed files with 193 additions and 199 deletions.
16 changes: 9 additions & 7 deletions .github/workflows/on_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ name: Build & Test
on: push

jobs:
BuildExe:
build_exe:
name: Windows portable build
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: pdm-project/setup-pdm@v4
with:
python-version: 3.13
cache: true
python-version: 3.12.8
- name: Install Just
run: choco install just
run: choco install -y just
- uses: actions/checkout@v4
- run: just prepare
- run: just --evaluate
- run: just bump_version_git build win32_portable
Expand All @@ -22,7 +22,8 @@ jobs:
path: .\dist\*
if-no-files-found: error

TestAndBuildDebian:
build_deb:
name: Run PyTest and build Debian package
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
Expand All @@ -32,7 +33,8 @@ jobs:
cache: true
- name: Install Just
run: curl -s https://just.systems/install.sh | sudo bash -s -- --to /usr/local/bin
- run: just deps_debian prepare
- name: Install project dependencies
run: just deps_debian prepare
- run: just --evaluate
- run: just test
- run: just bump_version_git build debian
Expand Down
101 changes: 45 additions & 56 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,82 +54,71 @@ May also work with newer/older devices in same series. If you want to get better
Download & install
-----------------

Common installation options:

[![Download for Windows](./docs/img/windows.png)](https://mmk.pw/en/openfreebuds/download/)
[![Available in FlatHub](./docs/img/flathub.png)](https://flathub.org/apps/pw.mmk.OpenFreebuds)

#### Windows package managers

Winget (preinstalled):

```powershell
winget install MelianMiko.OpenFreebuds
```

[Scoop](https://scoop.sh/):

```powershell
scoop bucket add extras
scoop install openfreebuds
```

#### Debian/Ubuntu
All installation options:

```shell
curl -s https://deb.mmk.pw/setup | sudo bash -
sudo apt install openfreebuds
```
| Platform | Package manager | Command/Linux |
|---|---|---|
| ![](./docs/img/i_linux.png) Any linux | [Available at Flathub](https://flathub.org/apps/pw.mmk.OpenFreebuds) | <pre>flatpak install pw.mmk.OpenFreebuds</pre> |
| ![](./docs/img/i_debian.png) Debian/Ubuntu | APT | <pre>curl -s https://deb.mmk.pw/setup \| sudo bash -<br/>sudo apt install openfreebuds</pre> |
| ![](./docs/img/i_arch.png) ArchLinux | [Yay](https://github.com/Jguer/yay) for AUR | <pre>yay -S openfreebuds</pre> |
| ![](./docs/img/i_win32.png) Windows | Direct install | [Website](https://mmk.pw/en/openfreebuds/download) or [releases](./releases)|
| ![](./docs/img/i_win32.png) Windows | [Winget](https://learn.microsoft.com/en-us/windows/package-manager/winget/) (preinstalled) | <pre>winget install MelianMiko.OpenFreebuds</pre> |
| ![](./docs/img/i_win32.png) Windows | [Scoop](https://scoop.sh/) | <pre>scoop bucket add extras<br/>scoop install openfreebuds</pre> |

#### Arch Linux
Most recent `dev`-binaries can be found as [GitHub Actions](https://github.com/melianmiko/OpenFreebuds/actions/workflows/on_push.yml) build artifacts.

`openfreebuds` [available in AUR](https://aur.archlinux.org/packages/openfreebuds).

#### Test builds

Most recent `dev`-binaries can be found in [GitHub Actions](https://github.com/melianmiko/OpenFreebuds/actions/workflows/on_push.yml) build artifacts.

Build or start from sources
Build from sources
-------------

### Manual build

Requirements:

- Windows 10/11, or enough modern Linux;
- Qt 6.0+ development tools, at least Linguist's `lrelease`;
- [Python](https://www.python.org/downloads/) (3.11+), [Poetry](https://python-poetry.org/docs/#installation) (1.8+);
- Qt 6.0+ development tools, at least Linguist's `lrelease` (under Windows, will be used auto-obtained from `PySide6`;
- [Just](https://github.com/casey/just)
- [Python](https://www.python.org/downloads/) (3.11+), [PDM](https://pdm-project.org/en/latest/);
- (Windows, optional) [NSIS](https://nsis.sourceforge.io/Download), [UPX](https://upx.github.io/);
- (Linux, optional) Build essentials and some libraries.

Also, some dev-scripts may have their own requirements, like `python3-polib` for
`./scripts/sync_translations.sh`. Setup poetry env and dependencies before
continue:

```shell
poetry install
```
### Just launch without installation
- (Debian/Ubuntu, optional) For Debian packaging, some native libs (command: `just deps_debian`).

```shell
./scripts/make.py build_launch
```
<details>
<summary>Get all dependencies for Windows</summary>
<pre>
winget install -e --no-upgrade --id Casey.Just
winget install -e --no-upgrade --id NSIS.NSIS
winget install -e --no-upgrade --id UPX.UPX
winget install -e --no-upgrade --id Python.Python.3.12
powershell -ExecutionPolicy ByPass -c "irm https://pdm-project.org/install-pdm.py | python -"
# Only for Python 3.13+
# winget install -e --no-upgrade --id Microsoft.VisualStudio.2022.BuildTools --override "--passive --wait --add Microsoft.VisualStudio.Workload.VCTools;includeRecommended"
</pre>
</details>

### Windows
When dependencies listed above are resolved, parepare project environment and build Python
wheel by running: `just prepare build`.

If everything above is installed & added to `PATH`, just run:
Now, you can try launching OpenFreebuds by `just start` command or package it via:

```shell
.\scripts\build_win32\make.cmd
```
- `just win32` for Windows portable and installer;
- `just debian` for Debian `deb`-package;
- `just flatpak` for Flatpak bundle (will also automatically install application).

Output binaries will be located in `scripts\build_win32\dist`
### VM-based build (Vagrant)

### Debian/Ubuntu
> [!WARNING]
> This build method will require a machine with at least 16 GB of RAM and fast internet conneciton.
Install all packaging dependencies automated way:
`apt install build-essentials && ./scripts/install_dpkg_dependencies.sh`.
Install [Vagrant](https://developer.hashicorp.com/vagrant/install?product_intent=vagrant) and any
suitable hypervisor, I'm using VMware. Then just `vagrant up` in project root, it will automatically
deply Debian 12 & Windows 11 machines that will build OpenFreebuds in (mostly) all packages.

```shell
dpkg-buildpackage -b
```
Don't forgot to `vagrant halt` after finish, to free CPU/RAM usage.

Output file will be located in parent folder (`../*.deb`).
---

![Extra dialogs preview](docs/preview_2.png)
36 changes: 22 additions & 14 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Vagrant.configure("2") do |config|

debian.vm.provision "shell",
run: 'once',
name: "Prepare base dependencies (Flatpak, Just, Poetry)",
name: "Prepare base dependencies (Python, Just, PDM)",
privileged: true,
inline: <<-SHELL
apt update
Expand All @@ -24,7 +24,7 @@ Vagrant.configure("2") do |config|
curl -s https://just.systems/install.sh | bash -s -- --to /usr/local/bin
fi
# Install Poetry for user
# Install PDM for user
if [ ! -f /home/vagrant/.local/bin/pdm ]
then
curl -sSL https://pdm-project.org/install-pdm.py | sudo -u vagrant python3 -
Expand All @@ -33,39 +33,46 @@ Vagrant.configure("2") do |config|

debian.vm.provision "shell",
run: 'always',
name: "Install Flatpak requirements",
name: "Install project dependencies",
privileged: false,
inline: <<-SHELL
flatpak remote-add --if-not-exists --user flathub https://dl.flathub.org/repo/flathub.flatpakrepo
flatpak install -y --user org.flatpak.Builder
cd ~/openfreebuds
just deps_debian prepare
SHELL

debian.vm.provision "shell",
run: 'always',
name: "Install project dependencies",
name: "Build binaries",
privileged: false,
inline: <<-SHELL
export FLATPAKBUILDDIR=$HOME/flatpak
cd ~/openfreebuds
just deps_debian prepare
just --evaluate
just build debian
SHELL

debian.vm.provision "shell",
run: 'always',
name: "Build binaries",
debian.vm.provision "shell",
run: 'once',
name: "Install Flatpak requirements and build Flatpak bundle",
privileged: false,
inline: <<-SHELL
export FLATPAKBUILDDIR=$HOME/flatpak
flatpak remote-add --if-not-exists --user flathub https://dl.flathub.org/repo/flathub.flatpakrepo
flatpak install -y --user org.flatpak.Builder
cd ~/openfreebuds
just --evaluate
just build debian flatpak
just build flatpak
SHELL
end

config.vm.define "windows", primary: true do |win|
win.vm.box = "gusztavvargadr/windows-11-24h2-enterprise"
win.vm.synced_folder ".", "C:\\openfreebuds"
win.vm.provider "vmware_desktop" do |v|
v.vmx["numvcpus"] = "4"
v.vmx["memsize"] = "4096"
v.gui = true
end

Expand All @@ -86,8 +93,9 @@ Vagrant.configure("2") do |config|
winget install -e --accept-source-agreements --no-upgrade --id Casey.Just
winget install -e --no-upgrade --id NSIS.NSIS
winget install -e --no-upgrade --id UPX.UPX
winget install -e --no-upgrade --id Python.Python.3.13
winget install -e --no-upgrade --id Microsoft.VisualStudio.2022.BuildTools --override "--passive --wait --add Microsoft.VisualStudio.Workload.VCTools;includeRecommended"
winget install -e --no-upgrade --id Python.Python.3.12
# Only for Python 3.13+
# winget install -e --no-upgrade --id Microsoft.VisualStudio.2022.BuildTools --override "--passive --wait --add Microsoft.VisualStudio.Workload.VCTools;includeRecommended"
SHELL

win.vm.provision "shell",
Expand Down
5 changes: 0 additions & 5 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@ Priority: optional
Maintainer: MelianMiko <[email protected]>
Build-Depends: debhelper-compat (= 12),
build-essential,
python3-dev,
python3-pip,
libcairo2-dev,
gobject-introspection,
libgirepository1.0-dev,
qt6-l10n-tools,
fakeroot,
make,
git
Expand Down
Binary file added docs/img/i_arch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/i_debian.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/i_linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/i_win32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 23 additions & 8 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set windows-shell := ["powershell.exe", "-c"]
set script-interpreter := ["python"]

# Tools
pyside6_dir := `python -c "
pyside6_dir := `pdm run python -c "
import os
try:
import PySide6
Expand Down Expand Up @@ -65,6 +65,9 @@ test:
prepare:
pdm install

vg_all:
vagrant halt -f
vagrant up --parallel


# ------------------------------------------------
Expand Down Expand Up @@ -203,8 +206,20 @@ debian_full:
# Install build dependencies for Debian\Ubuntu
[linux]
deps_debian:
# TODO: Move inside Justfile
sudo bash ./scripts/install_dpkg_dependencies.sh
sudo apt install -y --no-install-recommends \
build-essential \
debhelper-compat \
python3-dbus-next \
python3-pyqt6 \
python3-pil \
python3-qasync \
python3-aiohttp \
python3-psutil \
python3-pip \
qt6-l10n-tools \
fakeroot \
make \
git



Expand All @@ -220,20 +235,20 @@ win32: win32_installer win32_portable
[windows]
win32_installer: win32_bundle
New-Item -ItemType Directory -Force -Path ./dist
cd ./scripts/build_win32; makensis openfreebuds.nsi
mv ./scripts/build_win32/dist/openfreebuds.install.exe ./dist/openfreebuds_{{version}}_win32.exe
cd ./scripts; & "C:\Program Files (x86)\NSIS\Bin\makensis.exe" openfreebuds.nsi
mv -Force ./scripts/dist/openfreebuds.install.exe ./dist/openfreebuds_{{version}}_win32.exe

# Make windows portable executable
[windows]
win32_portable:
New-Item -ItemType Directory -Force -Path ./dist
cd ./scripts/build_win32; & pdm run pyinstaller openfreebuds_portable.spec
mv ./scripts/build_win32/dist/openfreebuds_portable.exe ./dist/openfreebuds_{{version}}_win32_portable.exe
cd ./scripts; & pdm run pyinstaller -y openfreebuds_portable.spec
mv -Force ./scripts/dist/openfreebuds_portable.exe ./dist/openfreebuds_{{version}}_win32_portable.exe

# Prepare ./dist/ for win32 installer build
[windows,private]
win32_bundle:
cd ./scripts/build_win32; pdm run pyinstaller openfreebuds.spec
cd ./scripts; pdm run pyinstaller -y openfreebuds.spec



Expand Down
Loading

0 comments on commit b32b177

Please sign in to comment.