diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7651701f..1a8ac030 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,6 +32,26 @@ jobs: name: ${{ matrix.host }}-x path: bin/x${{ matrix.host == 'windows-latest' && '.exe' || '' }} + # Github doesn't have runners for anything but 64 bit + build-32bit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: hecrj/setup-rust-action@v1 + with: + targets: "i686-unknown-linux-gnu" + - name: multilib + run: sudo dpkg --add-architecture i386 && sudo apt-get update && sudo apt-get install gcc-multilib libssl-dev:i386 + - run: cargo install --path xbuild --root . --target i686-unknown-linux-gnu + env: + OPENSSL_LIB_DIR: /usr/lib/i386-linux-gnu/ + OPENSSL_INCLUDE_DIR: /usr/include/openssl/ + + - uses: actions/upload-artifact@v3 + with: + name: i686-x + path: bin/x + build-template: strategy: fail-fast: false @@ -40,10 +60,15 @@ jobs: - ubuntu-latest - macos-latest - windows-latest + host-arch: + - x86 + - x64 opt: - debug - release target: + - platform: linux + arch: x86 - platform: linux arch: x64 - platform: macos @@ -56,7 +81,7 @@ jobs: arch: arm64 runs-on: ${{ matrix.host }} - needs: build + needs: [build, build-32bit] steps: - name: install rust uses: hecrj/setup-rust-action@v1 @@ -64,9 +89,17 @@ jobs: rust-version: stable - name: install x + if: ${{ matrix.host-arch == 'x64' }} uses: actions/download-artifact@v3 with: name: ${{ matrix.host }}-x + + - name: install x i686 + if: ${{ matrix.host-arch == 'x86' }} + uses: actions/download-artifact@v3 + with: + name: i686-x + - run: chmod +x ./x if: ${{ matrix.host == 'ubuntu-latest' || matrix.host == 'macos-latest' }} @@ -90,15 +123,28 @@ jobs: if: ${{ matrix.host == 'ubuntu-latest' }} run: sudo apt-get update && sudo apt-get install libwebkit2gtk-4.0-dev libgtk-3-dev squashfs-tools + - name: install dependencies for i686 + if: ${{ matrix.host == 'ubuntu-latest' }} + run: sudo dpkg --add-architecture i386 && sudo apt-get update && sudo apt-get install libwebkit2gtk-4.0-dev:i386 libgtk-3-dev:i386 squashfs-tools:i386 libssl3:i386 gcc-multilib libglib2.0-0:i386 + - name: create project + if: ${{ !((matrix.host == 'macos-latest' || matrix.host == 'windows-latest') && matrix.host-arch == 'x86') }} run: ./x new template - + # only linux can target linux as it is not clear what that even is exactly # glibc/musl gtk/qt x11/wayland # windows doesn't support posix symlinks so can't cross compile to macos/ios - name: build project if: > - !(matrix.host == 'macos-latest' && matrix.target.platform == 'linux' || - matrix.host == 'windows-latest' && contains(fromJson('["linux", "macos", "ios"]'), matrix.target.platform)) + ${{ + !(matrix.host-arch == 'x64' && matrix.target.arch == 'x86' || + matrix.host == 'macos-latest' && matrix.host-arch == 'x86' || + matrix.host == 'windows-latest' && matrix.host-arch == 'x86' || + matrix.host == 'macos-latest' && matrix.target.platform == 'linux' || + matrix.host == 'windows-latest' && contains(fromJson('["linux", "macos", "ios"]'), matrix.target.platform) + ) + }} run: ../x build --platform ${{ matrix.target.platform }} --arch ${{ matrix.target.arch }} --${{ matrix.opt }} working-directory: template + env: + PKG_CONFIG_SYSROOT_DIR: "/" diff --git a/appimage/assets/runtime-i686 b/appimage/assets/runtime-i686 new file mode 100644 index 00000000..df6382a8 Binary files /dev/null and b/appimage/assets/runtime-i686 differ diff --git a/appimage/src/lib.rs b/appimage/src/lib.rs index c5ded81f..1df22d9d 100644 --- a/appimage/src/lib.rs +++ b/appimage/src/lib.rs @@ -7,8 +7,12 @@ use std::path::{Path, PathBuf}; use std::process::Command; use xcommon::Signer; +#[cfg(target_arch = "x86_64")] static RUNTIME: &[u8] = include_bytes!("../assets/runtime-x86_64"); +#[cfg(target_arch = "x86")] +static RUNTIME: &[u8] = include_bytes!("../assets/runtime-i686"); + pub struct AppImage { appdir: PathBuf, name: String, diff --git a/xbuild/src/devices/adb.rs b/xbuild/src/devices/adb.rs index 8a9d6bb3..c5ca32a0 100644 --- a/xbuild/src/devices/adb.rs +++ b/xbuild/src/devices/adb.rs @@ -325,7 +325,7 @@ impl Adb { "arm64-v8a" => Arch::Arm64, //"armeabi-v7a" => Arch::Arm, "x86_64" => Arch::X64, - //"x86" => Arch::X86, + "x86" => Arch::X86, abi => anyhow::bail!("unrecognized abi {}", abi), }; Ok(arch) diff --git a/xbuild/src/lib.rs b/xbuild/src/lib.rs index fd522bf2..5ff1846a 100644 --- a/xbuild/src/lib.rs +++ b/xbuild/src/lib.rs @@ -95,7 +95,7 @@ pub enum Arch { //Arm, Arm64, X64, - //X86, + X86, } impl Arch { @@ -104,6 +104,8 @@ impl Arch { Ok(Arch::X64) } else if cfg!(target_arch = "aarch64") { Ok(Arch::Arm64) + } else if cfg!(target_arch = "x86") { + Ok(Arch::X86) } else { anyhow::bail!("unsupported host"); } @@ -116,7 +118,7 @@ impl std::fmt::Display for Arch { //Self::Arm => write!(f, "arm"), Self::Arm64 => write!(f, "arm64"), Self::X64 => write!(f, "x64"), - //Self::X86 => write!(f, "x86"), + Self::X86 => write!(f, "x86"), } } } @@ -129,7 +131,7 @@ impl std::str::FromStr for Arch { //"arm" => Self::Arm, "arm64" => Self::Arm64, "x64" => Self::X64, - //"x86" => Self::X86, + "x86" => Self::X86, _ => anyhow::bail!("unsupported arch {}", arch), }) } @@ -283,6 +285,7 @@ impl CompileTarget { match self.arch() { Arch::Arm64 => apk::Target::Arm64V8a, Arch::X64 => apk::Target::X86_64, + Arch::X86 => apk::Target::X86, } } @@ -292,7 +295,7 @@ impl CompileTarget { match self.arch() { Arch::Arm64 => "aarch64-linux-android", //Arch::Arm => "arm-linux-androideabi", - //Arch::X86 => "i686-linux-android", + Arch::X86 => "i686-linux-android", Arch::X64 => "x86_64-linux-android", } } @@ -307,6 +310,7 @@ impl CompileTarget { (Arch::X64, Platform::Linux) => "x86_64-unknown-linux-gnu", (Arch::X64, Platform::Macos) => "x86_64-apple-darwin", (Arch::X64, Platform::Windows) => "x86_64-pc-windows-msvc", + (Arch::X86, Platform::Linux) => "i686-unknown-linux-gnu", (arch, platform) => anyhow::bail!( "unsupported arch/platform combination {} {}", arch, @@ -316,7 +320,13 @@ impl CompileTarget { } pub fn is_host(self) -> Result { - Ok(self.platform() == Platform::host()? && self.arch() == Arch::host()?) + // 32 bit binaries can run on 64 bit hardware, of particular use for testing + // This way 32 bit xbuild will produce 32 bit binaries, unless commanded otherwise + if cfg!(target_arch = "x86") { + Ok(false) + } else { + Ok(self.platform() == Platform::host()? && self.arch() == Arch::host()?) + } } }