-
-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
x86 support #115
base: master
Are you sure you want to change the base?
x86 support #115
Changes from all commits
c4d03e2
fabe787
c9ebfcc
fb93a17
1d73dae
6e60de5
e51dc78
11a9d12
cd3d3bf
43e5c9a
a696e0b
31c0e68
9e66362
b292f33
b7bd57b
f5613b9
58f2ad7
1eeb1da
844708a
92ef8b7
167077a
10402ee
193a008
2e18d0e
1d52b22
4523168
8261002
00461f8
77a6f34
b9b4bb5
2d4cad1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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,17 +81,25 @@ jobs: | |
arch: arm64 | ||
|
||
runs-on: ${{ matrix.host }} | ||
needs: build | ||
needs: [build, build-32bit] | ||
steps: | ||
- name: install rust | ||
uses: hecrj/setup-rust-action@v1 | ||
with: | ||
rust-version: stable | ||
|
||
- name: install x | ||
if: ${{ matrix.host-arch == 'x64' }} | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: ${{ matrix.host }}-x | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not change the name of the artifact so that we can reuse this step? |
||
|
||
- 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 | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please trim (don't add) unnecessary whitespace. |
||
# 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) | ||
) | ||
}} | ||
Comment on lines
137
to
+146
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This thing is getting out of hand, perhaps we can create a separate |
||
run: ../x build --platform ${{ matrix.target.platform }} --arch ${{ matrix.target.arch }} --${{ matrix.opt }} | ||
working-directory: template | ||
env: | ||
PKG_CONFIG_SYSROOT_DIR: "/" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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<bool> { | ||
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) | ||
Comment on lines
+323
to
+326
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure I follow. This doesn't seem correct as you might be breaking fully-native builds here? That's where |
||
} else { | ||
Ok(self.platform() == Platform::host()? && self.arch() == Arch::host()?) | ||
} | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be nice to add the
.exe
suffix for Windows... And add a 32-bit Windows build?