Skip to content

Commit 96bd5a6

Browse files
authored
Merge pull request RustPython#1208 from RustPython/coolreader18/redox-ci
Add Redox OS compilation to Travis using Redoxer
2 parents 344e123 + b24a86e commit 96bd5a6

7 files changed

Lines changed: 90 additions & 12 deletions

File tree

.travis.yml

Lines changed: 51 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
before_cache: |
2-
if command -v cargo; then
3-
! command -v cargo-sweep && cargo install cargo-sweep
4-
cargo sweep -i
5-
cargo sweep -t 15
6-
fi
1+
before_cache:
2+
- |
3+
if command -v cargo; then
4+
if ! command -v cargo-sweep; then
5+
cargo install cargo-sweep
6+
fi
7+
cargo sweep -i
8+
cargo sweep -t 15
9+
fi
10+
- rm -rf ~/.cargo/registry/src
711

812
matrix:
913
fast_finish: true
@@ -145,3 +149,44 @@ matrix:
145149
env:
146150
- JOBCACHE=7
147151
- TRAVIS_RUST_VERSION=stable
152+
153+
- name: Ensure compilation on Redox OS with Redoxer
154+
# language: minimal so that it actually uses bionic rather than xenial;
155+
# rust isn't yet available on bionic
156+
language: minimal
157+
dist: bionic
158+
if: type = cron
159+
cache:
160+
cargo: true
161+
directories:
162+
- $HOME/.redoxer
163+
- $HOME/.cargo
164+
before_install:
165+
# install rust as travis does for language: rust
166+
- curl -sSf https://build.travis-ci.org/files/rustup-init.sh | sh -s --
167+
--default-toolchain=$TRAVIS_RUST_VERSION -y
168+
- export PATH=${TRAVIS_HOME}/.cargo/bin:$PATH
169+
- rustc --version
170+
- rustup --version
171+
- cargo --version
172+
173+
- sudo apt-get update -qq
174+
- sudo apt-get install libfuse-dev
175+
install:
176+
- if ! command -v redoxer; then cargo install redoxfs redoxer; fi
177+
- redoxer install
178+
script:
179+
- bash redox/uncomment-cargo.sh
180+
- redoxer build --verbose
181+
- bash redox/comment-cargo.sh
182+
before_cache:
183+
- |
184+
if ! command -v cargo-sweep; then
185+
rustup install stable
186+
cargo +stable install cargo-sweep
187+
fi
188+
- cargo sweep -t 15
189+
- rm -rf ~/.cargo/registry/src
190+
env:
191+
- JOBCACHE=10
192+
- TRAVIS_RUST_VERSION=nightly

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ version = "0.2"
4242
name = "rustpython"
4343
path = "src/main.rs"
4444

45-
# Uncommment when you want to compile/check with redoxer
46-
# [patch.crates-io]
45+
[patch.crates-io]
46+
# REDOX START, Uncommment when you want to compile/check with redoxer
4747
# time = { git = "https://gitlab.redox-os.org/redox-os/time.git", branch = "redox-unix" }
4848
# libc = { git = "https://github.com/AdminXVII/libc", branch = "extra-traits-redox" }
4949
# nix = { git = "https://github.com/AdminXVII/nix", branch = "add-redox-support" }
50+
# REDOX END

redox/comment-cargo.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
cargo=${1:-Cargo.toml}
6+
7+
tmpfile=$(mktemp)
8+
9+
awk '
10+
/REDOX START/{redox=1; print; next}
11+
/REDOX END/{redox=0}
12+
{if (redox) print "#", $0; else print}
13+
' "$cargo" >"$tmpfile"
14+
15+
mv "$tmpfile" "$cargo"

redox/recipe.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
GIT=https://github.com/RustPython/RustPython
2+
BRANCH=release
23
CARGOFLAGS=--no-default-features
34
export BUILDTIME_RUSTPYTHONPATH=/lib/rustpython/
45

redox/uncomment-cargo.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
cargo=${1:-Cargo.toml}
6+
7+
tmpfile=$(mktemp)
8+
9+
awk '
10+
/REDOX START/{redox=1; print; next}
11+
/REDOX END/{redox=0}
12+
{if (redox) sub(/^#\s*/, ""); print}
13+
' "$cargo" >"$tmpfile"
14+
15+
mv "$tmpfile" "$cargo"

vm/src/stdlib/os.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::{env, fs};
88

99
#[cfg(unix)]
1010
use nix::errno::Errno;
11-
#[cfg(unix)]
11+
#[cfg(all(unix, not(target_os = "redox")))]
1212
use nix::pty::openpty;
1313
#[cfg(unix)]
1414
use nix::unistd::{self, Gid, Pid, Uid};
@@ -853,7 +853,7 @@ fn os_seteuid(euid: PyIntRef, vm: &VirtualMachine) -> PyResult<()> {
853853
unistd::seteuid(Uid::from_raw(euid)).map_err(|err| convert_nix_error(vm, err))
854854
}
855855

856-
#[cfg(unix)]
856+
#[cfg(all(unix, not(target_os = "redox")))]
857857
pub fn os_openpty(vm: &VirtualMachine) -> PyResult {
858858
match openpty(None, None) {
859859
Ok(r) => Ok(vm

vm/src/stdlib/socket.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::io::Read;
44
use std::io::Write;
55
use std::net::{Ipv4Addr, SocketAddr, TcpListener, TcpStream, ToSocketAddrs, UdpSocket};
66

7-
#[cfg(unix)]
7+
#[cfg(all(unix, not(target_os = "redox")))]
88
use nix::unistd::sethostname;
99

1010
use gethostname::gethostname;
@@ -388,7 +388,7 @@ fn socket_gethostname(vm: &VirtualMachine) -> PyResult {
388388
.map_err(|err| vm.new_os_error(err.into_string().unwrap()))
389389
}
390390

391-
#[cfg(unix)]
391+
#[cfg(all(unix, not(target_os = "redox")))]
392392
fn socket_sethostname(hostname: PyStringRef, vm: &VirtualMachine) -> PyResult<()> {
393393
sethostname(hostname.value.as_str()).map_err(|err| convert_nix_error(vm, err))
394394
}
@@ -449,6 +449,7 @@ fn extend_module_platform_specific(_vm: &VirtualMachine, module: PyObjectRef) ->
449449
fn extend_module_platform_specific(vm: &VirtualMachine, module: PyObjectRef) -> PyObjectRef {
450450
let ctx = &vm.ctx;
451451

452+
#[cfg(not(target_os = "redox"))]
452453
extend_module!(vm, module, {
453454
"sethostname" => ctx.new_rustfunc(socket_sethostname),
454455
});

0 commit comments

Comments
 (0)