Update Linux build scripts (#397)

* update linux build scripts

* update docs
This commit is contained in:
Cyano Hao 2024-04-27 10:22:53 +08:00 committed by GitHub
parent f51ca9009e
commit ad6873614b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
17 changed files with 356 additions and 427 deletions

View File

@ -189,11 +189,8 @@ jobs:
matrix:
arch: [amd64, i386]
version: ["11", "12"]
include:
- arch: amd64
platform: linux/amd64
- arch: i386
platform: linux/386
env:
IMAGE: docker.io/${{ matrix.arch }}/debian:${{ matrix.version }}
runs-on: ubuntu-latest
@ -202,13 +199,9 @@ jobs:
with:
fetch-depth: 0
- name: Fetch container image
run: |
podman pull --platform ${{ matrix.platform }} docker.io/${{ matrix.arch }}/debian:${{ matrix.version }}
- name: Build
run: |
podman run --rm -e SOURCE_DIR=/src -v $GITHUB_WORKSPACE:/src --platform linux/amd64 debian:${{ matrix.version }} /src/packages/debian/01-in-docker.sh
podman run --rm -v $PWD:/mnt -w /mnt $IMAGE ./packages/debian/01-in-docker.sh
- name: Upload
uses: actions/upload-artifact@v2
@ -221,7 +214,9 @@ jobs:
strategy:
fail-fast: false
matrix:
version: ["22.04", "23.10", "devel"]
version: ["22.04", "23.10", "24.04", "devel"]
env:
IMAGE: docker.io/amd64/ubuntu:${{ matrix.version }}
runs-on: ubuntu-latest
@ -230,13 +225,9 @@ jobs:
with:
fetch-depth: 0
- name: Fetch container image
run: |
podman pull --platform linux/amd64 docker.io/amd64/ubuntu:${{ matrix.version }}
- name: Build
run: |
podman run --rm -e SOURCE_DIR=/src -v $GITHUB_WORKSPACE:/src --platform linux/amd64 ubuntu:${{ matrix.version }} /src/packages/debian/01-in-docker.sh
podman run --rm -v $PWD:/mnt -w /mnt $IMAGE ./packages/debian/01-in-docker.sh
- name: Upload
uses: actions/upload-artifact@v2
@ -247,19 +238,17 @@ jobs:
archlinux:
name: Arch Linux
runs-on: ubuntu-latest
env:
IMAGE: docker.io/amd64/archlinux:latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Fetch container image
run: |
podman pull --platform linux/amd64 docker.io/amd64/archlinux:latest
- name: Build
run: |
podman run --security-opt seccomp=unconfined --rm -e SOURCE_DIR=/src -v $GITHUB_WORKSPACE:/src --platform linux/amd64 docker.io/amd64/archlinux:latest /src/packages/archlinux/01-in-docker.sh
podman run --security-opt seccomp=unconfined --rm -v $PWD:/mnt -w /mnt $IMAGE ./packages/archlinux/01-in-docker.sh
- name: Upload
uses: actions/upload-artifact@v2
@ -267,68 +256,70 @@ jobs:
name: Arch Linux
path: dist/*.pkg.tar.zst
rpm_fedora:
name: RPM on latest Fedora
fedora:
name: Fedora
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
version: ["latest", "rawhide"]
env:
IMAGE: docker.io/amd64/fedora:${{ matrix.version }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Fetch container image
run: |
podman pull --platform linux/amd64 docker.io/amd64/fedora:latest
- name: Build
run: |
podman run --security-opt seccomp=unconfined --rm -e SOURCE_DIR=/src -v $GITHUB_WORKSPACE:/src --platform linux/amd64 docker.io/amd64/fedora:latest /src/packages/fedora/01-in-docker.sh
podman run --security-opt seccomp=unconfined --rm -v $PWD:/mnt -w /mnt $IMAGE ./packages/fedora/01-in-docker.sh
- name: Upload
uses: actions/upload-artifact@v2
with:
name: RPM on latest Fedora
name: Fedora ${{ matrix.version }} x86_64
path: dist/*.rpm
# rpm_opensuse:
# name: RPM on openSUSE Tumbleweed
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# with:
# fetch-depth: 0
# - name: Fetch container image
# run: |
# podman pull --platform linux/amd64 docker.io/opensuse/tumbleweed:latest
# - name: Build
# run: |
# podman run --security-opt seccomp=unconfined --rm -e SOURCE_DIR=/src -v $GITHUB_WORKSPACE:/src --platform linux/amd64 docker.io/opensuse/tumbleweed:latest /src/packages/opensuse/01-in-docker.sh
# - name: Upload
# uses: actions/upload-artifact@v2
# with:
# name: RPM on openSUSE Tumbleweed
# path: dist/*.rpm
musl:
name: musl-based Linux (latest Alpine)
opensuse:
name: openSUSE
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
edition: ["leap", "tumbleweed"]
env:
IMAGE: docker.io/opensuse/${{ matrix.edition }}:latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Fetch container image
- name: Build
run: |
podman pull --platform linux/amd64 docker.io/amd64/alpine:latest
podman run --security-opt seccomp=unconfined --rm -v $PWD:/mnt -w /mnt $IMAGE ./packages/opensuse/01-in-docker.sh
- name: Upload
uses: actions/upload-artifact@v2
with:
name: openSUSE ${{ matrix.edition }} x86_64
path: dist/*.rpm
musl:
name: musl-based Linux (latest Alpine)
runs-on: ubuntu-latest
env:
IMAGE: docker.io/amd64/alpine:latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Build
run: |
podman run --rm -e SOURCE_DIR=/src -v $GITHUB_WORKSPACE:/src --platform linux/amd64 docker.io/amd64/alpine:latest /src/packages/alpine/01-in-docker.sh
podman run --rm -v $PWD:/mnt -w /mnt $IMAGE ./packages/alpine/01-in-docker.sh
- name: Upload
uses: actions/upload-artifact@v2
@ -339,19 +330,17 @@ jobs:
appimage:
name: Linux AppImage
runs-on: ubuntu-latest
env:
IMAGE: quay.io/redpanda-cpp/appimage-builder-x86_64:20240304.0
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Fetch container image
run: |
podman pull --platform linux/amd64 quay.io/redpanda-cpp/appimage-builder-x86_64:20240304.0
- name: Build
run: |
podman run --rm -v $PWD:/mnt -w /mnt -e CARCH=x86_64 quay.io/redpanda-cpp/appimage-builder-x86_64:20240304.0 packages/appimage/01-in-docker.sh
podman run --rm -v $PWD:/mnt -w /mnt $IMAGE ./packages/appimage/01-in-docker.sh
- name: Upload
uses: actions/upload-artifact@v2
@ -368,10 +357,6 @@ jobs:
with:
fetch-depth: 0
- name: Fetch container image
run: |
podman pull --platform linux/amd64 quay.io/redpanda-cpp/appimage-builder-x86_64:20240304.0
- name: Build
run: |
packages/debian-static/builddeb.sh

195
BUILD.md
View File

@ -230,184 +230,69 @@ To build with VS 2017 or later in Command Prompt:
"%JOM%" install
```
# Linux and Other freedesktop.org-conforming (XDG) Desktop Systems
# Linux
General steps:
See also [more build instructions for freedesktop.org-conforming (XDG) desktop systems](./docs/detailed-build-xdg.md).
- Install recent version of GCC (≥ 7) or Clang (≥ 6) that supports C++17.
- Install Qt 5.15 Base, SVG and Tools modules, including both libraries and development files.
- Optionally install fcitx5-qt for building with static Qt library.
## Alpine Linux, Arch Linux, Debian and Its Derivatives, Fedora, openSUSE
qmake-based build steps:
1. Configure:
```bash
qmake PREFIX=/usr/local /path/to/src/Red_Panda_CPP.pro
```
2. Build:
```bash
make -j$(nproc)
```
3. Install:
```bash
sudo make install
```
qmake variables:
- `PREFIX`: default to `/usr/local`. It should be set to `/usr` when packaging.
- `LIBEXECDIR`: directory for auxiliary executables, default to `$PREFIX/libexec`. Arch Linux uses `/usr/lib`.
- `LINUX_STATIC_IME_PLUGIN=ON` (make phase): link to static ime plugin. Recommended for building with static version of Qt; **DO NOT** set for dynamic version of Qt.
xmake-based build steps:
1. Configure:
```bash
xmake f -p linux -a x86_64 -m release --qt=/usr --prefix=/usr/local
```
2. Build:
```bash
xmake
```
3. Install:
```bash
sudo xmake install --root -o / # `-o ...` imitates `DESTDIR=...` in `make install`
```
Hint: `xmake f --help` for more options.
## Debian and Its Derivatives
### “deb” Package for Current OS
1. Install dependency:
```bash
sudo apt install \
build-essential debhelper \
libqt5svg5-dev qtbase5-dev qtbase5-dev-tools qttools5-dev-tools
```
2. Build the package:
```bash
./packages/debian/builddeb.sh
```
3. Install the package:
```bash
sudo apt install /tmp/redpanda-cpp_*.deb
```
4. Run Red Panda C++:
```bash
RedPandaIDE
```
### Build Packages for Multiple Architectures and Versions in Containers
Extra requirements for Windows host:
- Docker uses WSL 2 based engine, or enable file sharing on the project folder (Settings > Resources > File sharing);
- PowerShell (Core) or Windows PowerShell.
* Linux host:
```bash
DOCKER=docker # or podman
SOURCE_DIR=/build/RedPanda-CPP # source directory *in container*
JOBS=$(nproc) # reduce it for multiple builds at same time
MIRROR=mirrors.kernel.org # leave empty for default mirror
PLATFORM=linux/amd64 # or linux/386, linux/arm64/v8, linux/arm/v7, linux/riscv64
IMAGE=debian:12 # or Ubuntu (e.g. ubuntu:22.04)
$DOCKER run --rm -e MIRROR=$MIRROR -e SOURCE_DIR=$SOURCE_DIR -e JOBS=$JOBS -v $PWD:$SOURCE_DIR --platform $PLATFORM $IMAGE $SOURCE_DIR/packages/debian/01-in-docker.sh
```
* Windows host:
```ps1
$DOCKER = "docker" # or "podman"
$SOURCE_DIR = "/build/RedPanda-CPP" # source directory *in container*
$JOBS = $Env:NUMBER_OF_PROCESSORS # reduce it for multiple builds at same time
$MIRROR = "mirrors.kernel.org" # leave empty for default mirror
$PLATFORM = "linux/amd64" # or "linux/386", "linux/arm64/v8", "linux/arm/v7", "linux/riscv64"
$IMAGE = "debian:12" # or Ubuntu (e.g. "ubuntu:22.04")
& $DOCKER run --rm -e MIRROR=$MIRROR -e SOURCE_DIR=$SOURCE_DIR -e JOBS=$JOBS -v "$(Get-Location):$SOURCE_DIR" --platform $PLATFORM $IMAGE $SOURCE_DIR/packages/debian/01-in-docker.sh
```
### Manual Install
1. Install compiler
```bash
apt install gcc g++ make gdb gdbserver
```
2. Install Qt 5 and other dependencies
```bash
apt install qtbase5-dev qttools5-dev-tools libqt5svg5-dev git qterminal
```
3. Fetch source code
```bash
git clone https://github.com/royqh1979/RedPanda-CPP.git
```
4. Build
```bash
cd RedPanda-CPP/
qmake Red_Panda_CPP.pro
make -j$(nproc)
sudo make install
```
5. Run
```bash
RedPandaIDE
```
## Alpine Linux, Arch Linux, Fedora, openSUSE
1. Setup build environment (documentation for [Alpine](https://wiki.alpinelinux.org/wiki/Abuild_and_Helpers), [Arch](https://wiki.archlinux.org/title/Makepkg), [RPM](https://rpm-packaging-guide.github.io/#prerequisites)).
1. Setup build environment (documentation for [Alpine](https://wiki.alpinelinux.org/wiki/Abuild_and_Helpers), [Arch](https://wiki.archlinux.org/title/Makepkg), [Debians](https://wiki.debian.org/BuildingTutorial), [RPM](https://rpm-packaging-guide.github.io/#prerequisites)).
- For Debians:
```sh
sudo apt install --no-install-recommends build-essential debhelper devscripts equivs
```
2. Call build script:
- Alpine Linux: `./packages/alpine/buildapk.sh`
- Arch Linux: `./packages/archlinux/buildpkg.sh`
- Debians: `./packages/debian/builddeb.sh`
- Fedora: `./packages/fedora/buildrpm.sh`
- openSUSE: `./packages/opensuse/buildrpm.sh`
3. Install the package:
- Alpine Linux: `~/packages/unsupported/$(uname -m)/redpanda-cpp-git-*.apk`
- Arch Linux: `/tmp/redpanda-cpp-git/redpanda-cpp-git-*.pkg.tar.zst`
- Debians: `/tmp/redpanda-cpp_*.deb`
- Fedora, openSUSE: `~/rpmbuild/RPMS/$(uname -m)/redpanda-cpp-git-*.rpm`
4. Run Red Panda C++:
```bash
RedPandaIDE
```
Note that these build scripts check out HEAD of the repo, so any changes should be committed before building.
Note that some of these scripts check out HEAD of the repo, so any changes should be committed before building.
Alternatively, build in container (rootless Podman preferred; Docker may break file permissions):
```sh
podman run --rm -v $PWD:/mnt -w /mnt <image> ./packages/<distro>/01-in-docker.sh
# Arch Linux for example
podman run --rm -v $PWD:/mnt -w /mnt docker.io/archlinux:latest ./packages/archlinux/01-in-docker.sh
```
The package will be placed in `dist/`.
## Statically Linked Binary for Ubuntu 20.04 x86_64 (NOI Linux 2.0)
The package `redpanda-cpp-bin` is roughly “AppImage repack”. The binary is actually built in a container. Thus the build host is not necessarily Ubuntu 20.04; any Linux distribution with Podman and dpkg should work.
1. Install Podman, and dpkg if build host is not Debian or its derivatives:
```sh
sudo apt install podman
```
WARNING: DO NOT install packages with dpkg on non-Debians, or your system will be terminated.
2. Call build script:
```sh
./packages/debian-static/builddeb.sh
```
The package will be placed in `dist/`.
## Linux AppImage
Linux host:
```bash
ARCH=x86_64
podman run --rm -v $PWD:/mnt -w /mnt -e CARCH=$ARCH quay.io/redpanda-cpp/appimage-builder-$ARCH:20240304.0 packages/appimage/01-in-docker.sh
podman run --rm -v $PWD:/mnt -w /mnt quay.io/redpanda-cpp/appimage-builder-x86_64:20240304.0 ./packages/appimage/01-in-docker.sh
```
Windows host:
```ps1
$ARCH = "x86_64"
podman run --rm -v "$(Get-Location):/mnt" -w /mnt -e CARCH=$ARCH redpanda-builder-$ARCH packages/appimage/01-in-docker.sh
```
Dockerfiles are available in [redpanda-cpp/appimage-builder](https://github.com/redpanda-cpp/appimage-builder).
## Emulated Native Build for Foreign Architectures
It is possible to build Red Panda C++ for foreign architectures using targets native toolchains with QEMU user space emulation.
Note: Always run emulated native build **in containers or jails**. Mixing architectures may kill your system.
For Linux or BSD host, install statically linked QEMU user space emulator (package name is likely `qemu-user-static`) and make sure that binfmt support is enabled.
For Windows host, Docker and Podman should have QEMU user space emulation enabled. If not,
* For Docker:
```ps1
docker run --rm --privileged multiarch/qemu-user-static:register
```
* For Podman, whose virtual machine is based on Fedora WSL, simply enable binfmt support:
```ps1
wsl -d podman-machine-default sudo cp /usr/lib/binfmt.d/qemu-aarch64-static.conf /proc/sys/fs/binfmt_misc/register
wsl -d podman-machine-default sudo cp /usr/lib/binfmt.d/qemu-riscv64-static.conf /proc/sys/fs/binfmt_misc/register
```
Dockerfiles are available in [redpanda-cpp/appimage-builder](https://github.com/redpanda-cpp/appimage-builder). Available architectures: `x86_64`, `aarch64`, `riscv64`.
# macOS

View File

@ -230,142 +230,27 @@ qmake 变量:
"%JOM%" install
```
# Linux 和其他符合 freedesktop.orgXDG规范的桌面系统
# Linux
通用步骤:
另请参阅[详细构建指南——符合 freedesktop.orgXDG规范的桌面系统](./docs/detailed-build-xdg-cn.md)。
- 安装支持 C++17 的 GCC≥ 7或 Clang≥ 6
- 安装 Qt 5.15 Base、SVG、Tools 模块,包括库和开发文件。
- 如果使用静态版本的 Qt 编译,还要安装 fcitx5-qt。
## Alpine Linux、Arch Linux、Debian 及其衍生版本、Fedora、openSUSE
基于 qmake 构建:
1. 配置:
```bash
qmake PREFIX=/usr/local /path/to/src/Red_Panda_CPP.pro
```
2. 构建:
```bash
make -j$(nproc)
```
3. 安装:
```bash
sudo make install
```
qmake 变量:
- `PREFIX`:默认值是 `/usr/local`。打包时应该定义为 `/usr`
- `LIBEXECDIR`:辅助程序的路径,默认值是 `$PREFIX/libexec`。Arch Linux 使用 `/usr/lib`
- `LINUX_STATIC_IME_PLUGIN=ON`make 阶段):静态链接输入法插件。推荐在使用静态版本的 Qt 编译时启用;**不要**在使用动态版本的 Qt 编译时启用。
基于 xmake 构建:
1. 配置:
```bash
xmake f -p linux -a x86_64 -m release --qt=/usr --prefix=/usr/local
```
2. 构建:
```bash
xmake
```
3. 安装:
```bash
sudo xmake install --root -o / # -o ... 模拟了 make install 的 DESTDIR=...
```
提示:`xmake f --help` 可以查看更多选项。
## Debian 及其衍生版本
### 适用于当前系统的 deb 包
1. 安装依赖包:
```bash
sudo apt install \
build-essential debhelper \
libqt5svg5-dev qtbase5-dev qtbase5-dev-tools qttools5-dev-tools
```
2. 构建 deb 包:
```bash
./packages/debian/builddeb.sh
```
3. 安装 deb 包:
```bash
sudo apt install /tmp/redpanda-cpp_*.deb
```
4. 运行小熊猫C++
```bash
RedPandaIDE
```
### 在容器中构建适用于多架构/版本的包
Windows 宿主的额外要求:
- Docker 使用基于 WSL 2 的引擎或者对此项目文件夹启用文件共享Settings > Resources > File sharing
- PowerShell (Core) 或 Windows PowerShell。
* Linux 宿主:
```bash
DOCKER=docker # 或 podman
SOURCE_DIR=/build/RedPanda-CPP # *容器内*的源代码路径
JOBS=$(nproc) # 同时构建多个包时可降低并行数
MIRROR=mirrors.ustc.edu.cn # 留空以使用默认的镜像站
PLATFORM=linux/amd64 # 或 linux/386、linux/arm64/v8、linux/arm/v7、linux/riscv64
IMAGE=debian:12 # 或 Ubuntu如 ubuntu:22.04
$DOCKER run --rm -e MIRROR=$MIRROR -e SOURCE_DIR=$SOURCE_DIR -e JOBS=$JOBS -v $PWD:$SOURCE_DIR --platform $PLATFORM $IMAGE $SOURCE_DIR/packages/debian/01-in-docker.sh
```
* Windows 宿主:
```ps1
$DOCKER = "docker" # 或 "podman"
$SOURCE_DIR = "/build/RedPanda-CPP" # *容器内*的源代码路径
$JOBS = $Env:NUMBER_OF_PROCESSORS # 同时构建多个包时可降低并行数
$MIRROR = "mirrors.ustc.edu.cn" # 留空以使用默认的镜像站
$PLATFORM = "linux/amd64" # 或 "linux/386"、"linux/arm64/v8"、"linux/arm/v7"、"linux/riscv64"
$IMAGE = "debian:12" # 或 Ubuntu如 "ubuntu:22.04"
& $DOCKER run --rm -e MIRROR=$MIRROR -e SOURCE_DIR=$SOURCE_DIR -e JOBS=$JOBS -v "$(Get-Location):$SOURCE_DIR" --platform $PLATFORM $IMAGE $SOURCE_DIR/packages/debian/01-in-docker.sh
```
### 手动安装
1. 安装编译器
```bash
apt install gcc g++ make gdb gdbserver
```
2. 安装 Qt 5 和依赖包
```bash
apt install qtbase5-dev qttools5-dev-tools libqt5svg5-dev git qterminal
```
3. 下载源码
```bash
git clone https://gitee.com/royqh1979/RedPanda-CPP.git
```
4. 编译
```bash
cd RedPanda-CPP/
qmake Red_Panda_CPP.pro
make -j$(nproc)
sudo make install
```
5. 运行
```bash
RedPandaIDE
```
## Alpine Linux, Arch Linux, Fedora, openSUSE
1. 准备构建环境([Alpine](https://wiki.alpinelinux.org/wiki/Abuild_and_Helpers)、[Arch](https://wiki.archlinux.org/title/Makepkg)、[RPM](https://rpm-packaging-guide.github.io/#prerequisites) 文档)。
1. 准备构建环境([Alpine](https://wiki.alpinelinux.org/wiki/Abuild_and_Helpers)、[Arch](https://wiki.archlinuxcn.org/wiki/Makepkg)、[Debians](https://wiki.debian.org/BuildingTutorial)、[RPM](https://rpm-packaging-guide.github.io/#prerequisites) 文档)。
- 对于 Debian 系:
```sh
sudo apt install --no-install-recommends build-essential debhelper devscripts equivs
```
2. 调用构建脚本:
- Alpine Linux`./packages/alpine/buildapk.sh`
- Arch Linux`./packages/archlinux/buildpkg.sh`
- Debian 系:`./packages/debian/builddeb.sh`
- Fedora`./packages/fedora/buildrpm.sh`
- openSUSE`./packages/opensuse/buildrpm.sh`
3. 安装软件包:
- Alpine Linux`~/packages/unsupported/$(uname -m)/redpanda-cpp-git-*.apk`
- Arch Linux`/tmp/redpanda-cpp-git/redpanda-cpp-git-*.pkg.tar.zst`
- Debian 系:`/tmp/redpanda-cpp_*.deb`
- Fedora、openSUSE`~/rpmbuild/RPMS/$(uname -m)/redpanda-cpp-git-*.rpm`
4. 运行小熊猫C++
```bash
@ -374,40 +259,40 @@ Windows 宿主的额外要求:
注意:这些构建脚本签出此存储库的 HEAD因此构建之前务必提交所有变更。
此外,也可以在容器环境中构建(推荐使用 rootless PodmanDocker 可能搞乱文件权限):
```bash
podman run --rm -v $PWD:/mnt -w /mnt <image> ./packages/<distro>/01-in-docker.sh
# 以 Arch Linux 为例
podman run --rm -v $PWD:/mnt -w /mnt docker.io/archlinux:latest ./packages/archlinux/01-in-docker.sh
```
软件包位于 `dist/` 目录下。
## Ubuntu 20.04 x86_64NOI Linux 2.0)静态链接包
`redpanda-cpp-bin` 包大体上就是 “AppImage 重新打包”。真正的构建过程在容器中进行,因此构建主机不一定要 Ubuntu 20.04,任何 Linux 发行版只要有 Podman 和 dpkg 就行。
1. 安装 Podman如果不是 Debian 及其衍生版还要安装 dpkg。
```sh
sudo apt install podman
```
**警告****不要**在非 Debian 系上使用 dpkg 安装软件包,否则将会破坏系统。
2. 调用构建脚本:
```sh
./packages/debian-static/builddeb.sh
```
软件包位于 `dist/` 目录下。
## Linux AppImage
Linux 宿主:
```bash
ARCH=x86_64
podman run --rm -v $PWD:/mnt -w /mnt -e CARCH=$ARCH quay.io/redpanda-cpp/appimage-builder-$ARCH:20240304.0 packages/appimage/01-in-docker.sh
podman run --rm -v $PWD:/mnt -w /mnt quay.io/redpanda-cpp/appimage-builder-x86_64:20240304.0 ./packages/appimage/01-in-docker.sh
```
Windows 宿主:
```ps1
$ARCH = "x86_64"
podman run --rm -v "$(Get-Location):/mnt" -w /mnt -e CARCH=$ARCH redpanda-builder-$ARCH packages/appimage/01-in-docker.sh
```
Dockerfile 位于 [redpanda-cpp/appimage-builder](https://github.com/redpanda-cpp/appimage-builder)。
## 异架构的模拟本机构建emulated native build
可以借助 QEMU 用户空间模拟运行目标架构的本机工具链来构建小熊猫C++。
注意:始终**在容器或 jail 中**运行模拟本机构建,因为混用不同架构的程序和库可能会损坏系统。
对于 Linux 或 BSD 宿主,需要安装静态链接的 QEMU 用户空间模拟器(包名通常为 `qemu-user-static`)并确认已经启用 binfmt 支持。
对于 Windows 宿主Docker 和 Podman 应该已经启用了 QEMU 用户空间模拟。如果没有启用,
* Docker
```ps1
docker run --rm --privileged multiarch/qemu-user-static:register
```
* Podman其虚拟机基于 Fedora WSL只需要启用 binfmt 支持:
```ps1
wsl -d podman-machine-default sudo cp /usr/lib/binfmt.d/qemu-aarch64-static.conf /proc/sys/fs/binfmt_misc/register
wsl -d podman-machine-default sudo cp /usr/lib/binfmt.d/qemu-riscv64-static.conf /proc/sys/fs/binfmt_misc/register
```
Dockerfile 位于 [redpanda-cpp/appimage-builder](https://github.com/redpanda-cpp/appimage-builder)。可用架构:`x86_64`、`aarch64`、`riscv64`。
# macOS

View File

@ -0,0 +1,98 @@
# 详细构建指南——符合 freedesktop.orgXDG规范的桌面系统
## 传统 Unix 方式(`./configure``make``make install`
- 安装支持 C++17 的 GCC≥ 7或 Clang≥ 6
- 安装 Qt 5.15 Base、SVG、Tools 模块,包括库和开发文件。
- 如果使用静态版本的 Qt 编译,还要安装 fcitx5-qt。
- 安装 astyle 以便在小熊猫 C++ 中对代码进行重新排版。
### 基于 qmake 构建
1. 配置:
```bash
qmake PREFIX=/usr/local /path/to/src/Red_Panda_CPP.pro
```
2. 构建:
```bash
make -j$(nproc)
```
3. 安装:
```bash
sudo make install
```
qmake 变量:
- `PREFIX`:默认值是 `/usr/local`。打包时应该定义为 `/usr`
- `LIBEXECDIR`:辅助程序的路径,默认值是 `$PREFIX/libexec`。Arch Linux 使用 `/usr/lib`
- `LINUX_STATIC_IME_PLUGIN=ON`make 阶段):静态链接输入法插件。推荐在使用静态版本的 Qt 编译时启用;**不要**在使用动态版本的 Qt 编译时启用。
### 基于 xmake 构建
1. 配置:
```bash
xmake f -p linux -a x86_64 -m release --qt=/usr --prefix=/usr/local
```
2. 构建:
```bash
xmake
```
3. 安装:
```bash
sudo xmake install --root -o / # -o ... 模拟了 make install 的 DESTDIR=...
```
提示:`xmake f --help` 可以查看更多选项。
### Debian/Ubuntu 的傻瓜式指南
```bash
# 准备工作
apt install gcc g++ make git gdb gdbserver astyle qterminal # 安装构建工具和运行时工具
apt install qtbase5-dev qttools5-dev-tools libqt5svg5-dev # 安装开发头文件和库
git clone https://gitee.com/royqh1979/RedPanda-CPP.git # 获取源代码
# 构建
mkdir -p RedPanda-CPP/build && cd RedPanda-CPP/build # 创建构建目录
qmake ../Red_Panda_CPP.pro # 配置
make -j$(nproc) # 构建
sudo make install # 安装
# 运行
RedPandaIDE
```
## 适用于多架构/版本的 Debian 包
可以在容器环境中构建这些包。支持 Linux 宿主和 Windows 宿主。
```bash
podman run --rm -v $PWD:/mnt -w /mnt --platform linux/amd64 docker.io/debian:12 ./packages/debian/01-in-docker.sh
```
平台(`--platform` 参数)可以是 `linux/amd64`、`linux/386`、`linux/arm64/v8`、`linux/arm/v7`、`linux/riscv64` 等。
映像可以是 `docker.io/debian:12`、`docker.io/debian:11`、`docker.io/ubuntu:24.04`、`docker.io/ubuntu:23.10`、`docker.io/ubuntu:22.04` 等。
可选环境变量:
- `-e MIRROR=mirrors.kernel.org`APT 镜像站。
- `-e JOBS=4`make 的并行任务数。
## 异架构的模拟本机构建emulated native build
可以借助 QEMU 用户空间模拟运行目标架构的本机工具链来构建小熊猫C++。
注意:始终**在容器或 jail 中**运行模拟本机构建,因为混用不同架构的程序和库可能会损坏系统。
对于 Linux 或 BSD 宿主,需要安装静态链接的 QEMU 用户空间模拟器(包名通常为 `qemu-user-static`)并确认已经启用 binfmt 支持。
对于 Windows 宿主Docker 和 Podman 应该已经启用了 QEMU 用户空间模拟。如果没有启用,
* Docker
```ps1
docker run --rm --privileged multiarch/qemu-user-static:register
```
* Podman其虚拟机基于 Fedora WSL只需要启用 binfmt 支持:
```ps1
wsl -d podman-machine-default sudo cp /usr/lib/binfmt.d/qemu-aarch64-static.conf /proc/sys/fs/binfmt_misc/register
wsl -d podman-machine-default sudo cp /usr/lib/binfmt.d/qemu-riscv64-static.conf /proc/sys/fs/binfmt_misc/register
```

View File

@ -0,0 +1,98 @@
# More Build Instructions for freedesktop.org-conforming (XDG) Desktop Systems
## Traditional Unix Way (`./configure``make``make install`)
- Install recent version of GCC (≥ 7) or Clang (≥ 6) that supports C++17.
- Install Qt 5.15 Base, SVG and Tools modules, including both libraries and development files.
- Optionally install fcitx5-qt for building with static Qt library.
- Install astyle for code formatting in Red Panda C++.
### qmake-based Build Steps
1. Configure:
```bash
qmake PREFIX=/usr/local /path/to/src/Red_Panda_CPP.pro
```
2. Build:
```bash
make -j$(nproc)
```
3. Install:
```bash
sudo make install
```
qmake variables:
- `PREFIX`: default to `/usr/local`. It should be set to `/usr` when packaging.
- `LIBEXECDIR`: directory for auxiliary executables, default to `$PREFIX/libexec`. Arch Linux uses `/usr/lib`.
- `LINUX_STATIC_IME_PLUGIN=ON` (make phase): link to static ime plugin. Recommended for building with static version of Qt; **DO NOT** set for dynamic version of Qt.
### xmake-based Build Steps
1. Configure:
```bash
xmake f -p linux -a x86_64 -m release --qt=/usr --prefix=/usr/local
```
2. Build:
```bash
xmake
```
3. Install:
```bash
sudo xmake install --root -o / # `-o ...` imitates `DESTDIR=...` in `make install`
```
Hint: `xmake f --help` for more options.
### Copy n Paste Instructions for Debian/Ubuntu
```bash
# prepare
apt install gcc g++ make git gdb gdbserver astyle qterminal # install build tools and runtime tools
apt install qtbase5-dev qttools5-dev-tools libqt5svg5-dev # install development headers and libraries
git clone https://github.com/royqh1979/RedPanda-CPP.git # fetch source code
# build
mkdir -p RedPanda-CPP/build && cd RedPanda-CPP/build # create build directory
qmake ../Red_Panda_CPP.pro # configure
make -j$(nproc) # build
sudo make install # install
# run
RedPandaIDE
```
## Debian Packages for Multiple Architectures and Versions
These packages can be built in containers. Both Linux host and Windows host are supported.
```bash
podman run --rm -v $PWD:/mnt -w /mnt --platform linux/amd64 docker.io/debian:12 ./packages/debian/01-in-docker.sh
```
Platform can be `linux/amd64`, `linux/386`, `linux/arm64/v8`, `linux/arm/v7`, `linux/riscv64`, etc.
Image can be `docker.io/debian:12`, `docker.io/debian:11`, `docker.io/ubuntu:24.04`, `docker.io/ubuntu:23.10`, `docker.io/ubuntu:22.04`, etc.
Optional environment variables:
- `-e MIRROR=mirrors.kernel.org`: mirror for APT.
- `-e JOBS=4`: number of parallel jobs for make.
## Emulated Native Build for Foreign Architectures
It is possible to build Red Panda C++ for foreign architectures using targets native toolchains with QEMU user space emulation.
Note: Always run emulated native build **in containers or jails**. Mixing architectures may kill your system.
For Linux or BSD host, install statically linked QEMU user space emulator (package name is likely `qemu-user-static`) and make sure that binfmt support is enabled.
For Windows host, Docker and Podman should have QEMU user space emulation enabled. If not,
* For Docker:
```ps1
docker run --rm --privileged multiarch/qemu-user-static:register
```
* For Podman, whose virtual machine is based on Fedora WSL, simply enable binfmt support:
```ps1
wsl -d podman-machine-default sudo cp /usr/lib/binfmt.d/qemu-aarch64-static.conf /proc/sys/fs/binfmt_misc/register
wsl -d podman-machine-default sudo cp /usr/lib/binfmt.d/qemu-riscv64-static.conf /proc/sys/fs/binfmt_misc/register
```

View File

@ -9,8 +9,7 @@ fi
apk add alpine-sdk git
abuild-keygen -an
cd $SOURCE_DIR
./packages/alpine/buildapk.sh
mkdir -p $SOURCE_DIR/dist
cp ~/packages/unsupported/$(uname -m)/redpanda-cpp-git-*.apk $SOURCE_DIR/dist/
mkdir -p dist
cp ~/packages/unsupported/$(uname -m)/redpanda-cpp-git-*.apk dist/

View File

@ -6,7 +6,7 @@ pkgdesc='A fast, lightweight, open source, and cross platform C++ IDE (developme
arch='all'
url="https://github.com/royqh1979/$_pkgname"
license='GPL-3.0'
depends='qt5-qtbase qt5-qtsvg gcc g++ gdb'
depends='qt5-qtbase qt5-qtsvg gcc g++ gdb astyle'
makedepends='qt5-qtbase-dev qt5-qtsvg-dev qt5-qttools-dev'
provides='redpanda-cpp'
source="$_pkgname.tar.gz"

View File

@ -12,6 +12,7 @@ else
VERSION="$APP_VERSION.$TEST_VERSION"
fi
CARCH=$(gcc -dumpmachine | cut -d- -f1)
APPIMAGE_FILE=RedPandaIDE-$VERSION-$CARCH.AppImage
RUNTIME_FILE=/opt/appimage-runtime
RUNTIME_SIZE=$(wc -c <$RUNTIME_FILE)

View File

@ -13,9 +13,8 @@ useradd -m builduser
echo 'builduser ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/builduser
echo "MAKEFLAGS=-j$(($(nproc)+1))" >>/etc/makepkg.conf
cd $SOURCE_DIR
su builduser -c "git config --global --add safe.directory $SOURCE_DIR"
su builduser -c "git config --global --add safe.directory $PWD"
su builduser -c ./packages/archlinux/buildpkg.sh
mkdir -p $SOURCE_DIR/dist
cp /tmp/redpanda-cpp-git/redpanda-cpp-git-*.pkg.tar.zst $SOURCE_DIR/dist/
mkdir -p dist
cp /tmp/redpanda-cpp-git/redpanda-cpp-git-*.pkg.tar.zst dist/

View File

@ -6,7 +6,7 @@ pkgdesc='A fast, lightweight, open source, and cross platform C++ IDE (developme
arch=('i686' 'pentium4' 'x86_64' 'arm' 'armv6h' 'armv7h' 'aarch64' 'riscv64')
url="https://github.com/royqh1979/$_pkgname"
license=('GPL3')
depends=(qt5-base qt5-svg gcc gdb)
depends=(qt5-base qt5-svg gcc gdb astyle)
makedepends=(qt5-tools imagemagick librsvg)
optdepends=(
'clang: C/C++ compiler (alternative)'

View File

@ -6,7 +6,7 @@ Homepage: https://github.com/royqh1979/RedPanda-CPP
Package: redpanda-cpp-bin
Version: __VERSION__
Architecture: amd64
Depends: gcc, g++, make, gdb, gdbserver,
Depends: gcc, g++, make, gdb, gdbserver, astyle,
libc6 (>= 2.17), libstdc++6 (>= 4.8),
libdbus-1-3, libfontconfig1, libfreetype6, libwayland-client0, libwayland-cursor0, libwayland-server0, libx11-6, libx11-xcb1, libxcb1, libxcb-icccm4, libxcb-image0, libxcb-keysyms1, libxcb-randr0, libxcb-render-util0, libxcb-render0, libxcb-shape0, libxcb-shm0, libxcb-sync1, libxcb-xfixes0, libxcb-xinerama0, libxcb-xkb1, libxcb1, libxext6, libxkbcommon-x11-0, libxkbcommon0, libzstd1
Recommends: qterminal | deepin-terminal | konsole | gnome-terminal | terminator | lxterminal | mate-terminal | terminology | xfce4-terminal | alacritty | cool-retro-term | kitty | sakura | termit | tilix

View File

@ -1,11 +1,10 @@
#!/bin/bash
set -xe
set -xeuo pipefail
TMP_FOLDER=/build/redpanda-build
DISTRO_ID=$(grep ^ID= /etc/os-release | cut -d= -f2- | tr -d '"')
VERSION_ID=$(grep ^VERSION_ID= /etc/os-release | cut -d= -f2- | tr -d '"')
[[ -z $JOBS ]] && JOBS=$(nproc)
[[ -v JOBS ]] || JOBS=$(nproc)
# install deps
default_repositories=(
@ -16,7 +15,7 @@ default_repositories=(
ports.ubuntu.com
)
if [[ -n $MIRROR ]]
if [[ -v MIRROR ]]
then
for repo in ${default_repositories[@]}
do
@ -31,31 +30,13 @@ fi
export DEBIAN_FRONTEND=noninteractive
apt update
apt install -y --no-install-recommends \
build-essential debhelper g++-mingw-w64 \
libqt5svg5-dev qtbase5-dev qtbase5-dev-tools qttools5-dev-tools
apt install -y --no-install-recommends build-essential debhelper devscripts equivs
# prepare source
mkdir -p $TMP_FOLDER
./packages/debian/builddeb.sh
cd $SOURCE_DIR
cp -r packages/debian $TMP_FOLDER
cp -r tools $TMP_FOLDER
cp -r libs $TMP_FOLDER
cp -r RedPandaIDE $TMP_FOLDER
cp README.md $TMP_FOLDER
cp LICENSE $TMP_FOLDER
cp NEWS.md $TMP_FOLDER
cp -r platform $TMP_FOLDER
cp Red_Panda_CPP.pro $TMP_FOLDER
# build
cd $TMP_FOLDER
sed -i '/CONFIG += ENABLE_LUA_ADDON/ { s/^#\s*// }' RedPandaIDE/RedPandaIDE.pro
dpkg-buildpackage -us -uc -j$JOBS
file=$(ls /tmp/redpanda-cpp_*.deb)
basename=$(basename $file)
# copy back to host
cd ..
file=$(ls redpanda-cpp_*.deb)
mkdir -p $SOURCE_DIR/dist
cp $file $SOURCE_DIR/dist/${file/.deb/.$DISTRO_ID$VERSION_ID.deb}
mkdir -p dist
cp $file dist/${basename/.deb/.$DISTRO_ID$VERSION_ID.deb}

View File

@ -1,11 +1,10 @@
#!/bin/sh
#!/bin/bash
make distclean
set -xeuo pipefail
TMP_FOLDER=/tmp/redpandaide
test -n $TMP_FOLDER | rm -rf $TMP_FOLDER
test -z $TMP_FOLDER | mkdir $TMP_FOLDER
[[ -d $TMP_FOLDER ]] && rm -rf $TMP_FOLDER
mkdir -p "$TMP_FOLDER"
cp -r packages/debian $TMP_FOLDER
cp -r tools $TMP_FOLDER
@ -19,5 +18,6 @@ cp -r platform $TMP_FOLDER
cp Red_Panda_CPP.pro $TMP_FOLDER
cd $TMP_FOLDER
command -v mk-build-deps && mk-build-deps -i -t "apt -y --no-install-recommends" debian/control
sed -i '/CONFIG += ENABLE_LUA_ADDON/ { s/^#\s*// }' RedPandaIDE/RedPandaIDE.pro
dpkg-buildpackage -us -uc

View File

@ -5,8 +5,7 @@ set -xeuo pipefail
dnf install -y dnf-plugins-core git rpm-build rpmdevtools
rpmdev-setuptree
cd $SOURCE_DIR
./packages/fedora/buildrpm.sh
mkdir -p $SOURCE_DIR/dist
cp ~/rpmbuild/RPMS/$(uname -m)/redpanda-cpp-git-*.rpm $SOURCE_DIR/dist/
mkdir -p dist
cp ~/rpmbuild/RPMS/$(uname -m)/redpanda-cpp-git-*.rpm dist/

View File

@ -8,7 +8,7 @@ Source0: RedPanda-CPP.tar.gz
BuildRequires: gcc gcc-c++
BuildRequires: qt5-qtbase-devel qt5-qtsvg-devel qt5-qttools-devel
Requires: gcc gcc-c++
Requires: gcc gcc-c++ astyle
Requires: glibc-static libstdc++-static libasan
Requires: qt5-qtbase qt5-qtsvg

View File

@ -8,11 +8,10 @@ VERSION_ID=$(grep ^VERSION_ID= /etc/os-release | cut -d= -f2- | tr -d '"')
zypper in -y git rpm-build rpmdevtools sudo
rpmdev-setuptree
cd $SOURCE_DIR
./packages/opensuse/buildrpm.sh
file=$(ls ~/rpmbuild/RPMS/$(uname -m)/redpanda-cpp-git-*.rpm)
basename=$(basename $file)
mkdir -p $SOURCE_DIR/dist
cp $file $SOURCE_DIR/dist/${basename/.rpm/.$DISTRO_ID$VERSION_ID.rpm}
mkdir -p dist
cp $file dist/${basename/.rpm/.$DISTRO_ID$VERSION_ID.rpm}

View File

@ -8,7 +8,7 @@ Source0: RedPanda-CPP.tar.gz
BuildRequires: gcc gcc-c++
BuildRequires: libqt5-qtbase-devel libqt5-qtsvg-devel libqt5-qttools-devel
Requires: gcc gcc-c++
Requires: gcc gcc-c++ astyle
Requires: glibc-devel-static
Requires: libQt5Core5 libQt5Gui5 libQt5Svg5