Merge pull request #1955 from RustPython/coolreader18/fix-redox

Fix redox compilation
This commit is contained in:
Jeong YunWon authored and GitHub committed 2020-06-03 13:33:41 +09:00
commit 596bbfa58d
8 files changed
+90 -30

No files matched your search

Generated
+32 -13
View File
@@ -267,9 +267,9 @@ checksum = "95e28fa049fda1c330bcf9d723be7663a899c4679724b34c81e9f5a326aab8cd"
[[package]]
name = "cfg-if"
version = "0.1.9"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33"
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
[[package]]
name = "chrono"
@@ -433,6 +433,16 @@ dependencies = [
"dirs-sys",
]
[[package]]
name = "dirs-next"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1cbcf9241d9e8d106295bd496bbe2e9cffd5fa098f2a8c9e2bbcbf09773c11a8"
dependencies = [
"cfg-if",
"dirs-sys-next",
]
[[package]]
name = "dirs-sys"
version = "0.3.4"
@@ -445,6 +455,17 @@ dependencies = [
"winapi",
]
[[package]]
name = "dirs-sys-next"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c60f7b8a8953926148223260454befb50c751d3c50e1c178c4fd1ace4083c9a"
dependencies = [
"libc",
"redox_users",
"winapi",
]
[[package]]
name = "dns-lookup"
version = "1.0.1"
@@ -791,9 +812,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "lexical"
version = "4.2.0"
version = "4.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eaad0ee8120fc0cf7df7e8fdbe79bf9d6189351404feb88f4e4a4bb5307bc594"
checksum = "0afaeae1c07c575338ef6809875bfea8daa9ea8b2ee381ef1f93ba0c6e32f003"
dependencies = [
"cfg-if",
"lexical-core",
@@ -802,12 +823,11 @@ dependencies = [
[[package]]
name = "lexical-core"
version = "0.6.7"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f86d66d380c9c5a685aaac7a11818bdfa1f733198dfd9ec09c70b762cd12ad6f"
checksum = "d7043aa5c05dd34fb73b47acb8c3708eac428de4545ea3682ed2f11293ebd890"
dependencies = [
"arrayvec 0.4.12",
"bitflags",
"cfg-if",
"rustc_version",
"ryu",
@@ -816,9 +836,9 @@ dependencies = [
[[package]]
name = "libc"
version = "0.2.68"
version = "0.2.71"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dea0c0405123bba743ee3f91f49b1c7cfb684eef0da0a50110f758ccf24cdff0"
checksum = "9457b06509d27052635f90d6466700c65095fdf75409b3fbdd903e988b886f49"
[[package]]
name = "libz-sys"
@@ -1524,7 +1544,7 @@ dependencies = [
"cfg-if",
"clap",
"cpython",
"dirs 2.0.1",
"dirs-next",
"env_logger",
"flame",
"flamescope",
@@ -2031,12 +2051,11 @@ dependencies = [
[[package]]
name = "time"
version = "0.1.42"
version = "0.1.43"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f"
checksum = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438"
dependencies = [
"libc",
"redox_syscall",
"winapi",
]
+4 -6
View File
@@ -27,7 +27,7 @@ clap = "2.33"
rustpython-compiler = {path = "compiler", version = "0.1.1"}
rustpython-parser = {path = "parser", version = "0.1.1"}
rustpython-vm = {path = "vm", version = "0.1.1"}
dirs = "=2.0.1"
dirs = { package = "dirs-next", version = "1.0" }
num-traits = "0.2.8"
cfg-if = "0.1"
@@ -47,10 +47,8 @@ path = "src/main.rs"
[patch.crates-io]
# REDOX START, Uncommment when you want to compile/check with redoxer
# time = { git = "https://gitlab.redox-os.org/redox-os/time.git", branch = "redox-unix" }
# nix = { git = "https://github.com/coolreader18/nix", branch = "add-redox-support" }
# # following patches are just waiting on a new version to be released to crates.io
# socket2 = { git = "https://github.com/alexcrichton/socket2-rs", rev = "75fe3f2fe0e3079ad9d4dfb3a19e60bea3f2f055" }
# rustyline = { git = "https://github.com/kkawakam/rustyline" }
# libc = { git = "https://github.com/rust-lang/libc" }
# nix = { git = "https://github.com/nix-rust/nix" }
# crossbeam-utils = { git = "https://github.com/crossbeam-rs/crossbeam" }
# socket2 = { git = "https://github.com/alexcrichton/socket2-rs" }
# REDOX END
+1 -1
View File
@@ -2042,7 +2042,7 @@ impl<O: OutputStream> Compiler<O> {
let mut compile_element = |element| {
self.compile_expression(element).map_err(|e| {
if matches!(e.error, CompileErrorType::InvalidStarExpr) {
if let CompileErrorType::InvalidStarExpr = e.error {
self.error(CompileErrorType::SyntaxError(
"iterable unpacking cannot be used in comprehension".to_owned(),
))
+17
View File
@@ -0,0 +1,17 @@
#!/usr/bin/env bash
set -eo pipefail
cd "$(dirname "$0")"
cd ../..
DIR=$(mktemp -d)
trap 'cd / && rm -rf "$DIR"' EXIT SIGINT
BUILDTIME_RUSTPYTHONPATH=/root/rustpython-lib redoxer build --release
cp target/x86_64-unknown-redox/release/rustpython -t "$DIR"
ln -s "$PWD"/Lib "$DIR"/rustpython-lib
redoxer exec -f "$DIR" -- ./rustpython "$@"
+1 -1
View File
@@ -102,7 +102,7 @@ crc32fast = "1.2.0"
adler32 = "1.0.3"
gethostname = "0.2.0"
subprocess = "0.2.2"
socket2 = { version = "0.3", features = ["unix"] }
socket2 = "0.3"
rustyline = "6.0"
openssl = { version = "0.10", features = ["vendored"], optional = true }
openssl-sys = { version = "0.9", optional = true }
+4
View File
@@ -9,6 +9,10 @@
#![allow(clippy::wrong_self_convention, clippy::implicit_hasher)]
#![doc(html_logo_url = "https://raw.githubusercontent.com/RustPython/RustPython/master/logo.png")]
#![doc(html_root_url = "https://docs.rs/rustpython-vm/")]
#![cfg_attr(
target_os = "redox",
feature(matches_macro, proc_macro_hygiene, result_map_or)
)]
#[cfg(feature = "flame-it")]
#[macro_use]
+10 -1
View File
@@ -1314,10 +1314,18 @@ fn os_urandom(size: usize, vm: &VirtualMachine) -> PyResult<Vec<u8>> {
#[cfg(any(target_os = "linux", target_os = "openbsd"))]
type ModeT = u32;
#[cfg(target_os = "redox")]
type ModeT = i32;
#[cfg(target_os = "macos")]
type ModeT = u16;
#[cfg(any(target_os = "macos", target_os = "linux", target_os = "openbsd"))]
#[cfg(any(
target_os = "macos",
target_os = "linux",
target_os = "openbsd",
target_os = "redox"
))]
fn os_umask(mask: ModeT, _vm: &VirtualMachine) -> PyResult<ModeT> {
let ret_mask = unsafe { libc::umask(mask) };
Ok(ret_mask)
@@ -1455,6 +1463,7 @@ fn os_utime(
#[cfg(unix)]
fn os_sync(_vm: &VirtualMachine) -> PyResult<()> {
#[cfg(not(target_os = "redox"))]
unsafe {
libc::sync();
}
+21 -8
View File
@@ -32,7 +32,21 @@ type RawSocket = std::os::unix::io::RawFd;
type RawSocket = std::os::windows::raw::SOCKET;
#[cfg(unix)]
use libc as c;
mod c {
pub use libc::*;
// https://gitlab.redox-os.org/redox-os/relibc/-/blob/master/src/header/netdb/mod.rs
#[cfg(target_os = "redox")]
pub const AI_PASSIVE: c_int = 0x01;
#[cfg(target_os = "redox")]
pub const AI_ALL: c_int = 0x10;
// https://gitlab.redox-os.org/redox-os/relibc/-/blob/master/src/header/sys_socket/constants.rs
#[cfg(target_os = "redox")]
pub const SO_TYPE: c_int = 3;
#[cfg(target_os = "redox")]
pub const MSG_OOB: c_int = 1;
#[cfg(target_os = "redox")]
pub const MSG_WAITALL: c_int = 256;
}
#[cfg(windows)]
mod c {
pub use winapi::shared::ws2def::*;
@@ -667,6 +681,8 @@ pub fn make_module(vm: &VirtualMachine) -> PyObjectRef {
"SHUT_WR" => ctx.new_int(c::SHUT_WR),
"SHUT_RDWR" => ctx.new_int(c::SHUT_RDWR),
"MSG_PEEK" => ctx.new_int(c::MSG_PEEK),
"MSG_OOB" => ctx.new_int(c::MSG_OOB),
"MSG_WAITALL" => ctx.new_int(c::MSG_WAITALL),
"IPPROTO_TCP" => ctx.new_int(c::IPPROTO_TCP),
"IPPROTO_UDP" => ctx.new_int(c::IPPROTO_UDP),
"IPPROTO_IP" => ctx.new_int(c::IPPROTO_IP),
@@ -674,20 +690,17 @@ pub fn make_module(vm: &VirtualMachine) -> PyObjectRef {
"IPPROTO_IPV6" => ctx.new_int(c::IPPROTO_IPV6),
"SOL_SOCKET" => ctx.new_int(c::SOL_SOCKET),
"SO_REUSEADDR" => ctx.new_int(c::SO_REUSEADDR),
"TCP_NODELAY" => ctx.new_int(c::TCP_NODELAY),
"SO_BROADCAST" => ctx.new_int(c::SO_BROADCAST),
"SO_TYPE" => ctx.new_int(c::SO_TYPE),
"SO_BROADCAST" => ctx.new_int(c::SO_BROADCAST),
"TCP_NODELAY" => ctx.new_int(c::TCP_NODELAY),
"AI_ALL" => ctx.new_int(c::AI_ALL),
"AI_PASSIVE" => ctx.new_int(c::AI_PASSIVE),
});
#[cfg(not(target_os = "redox"))]
extend_module!(vm, module, {
"getaddrinfo" => ctx.new_function(socket_getaddrinfo),
"gethostbyaddr" => ctx.new_function(socket_gethostbyaddr),
// non-redox constants
"MSG_OOB" => ctx.new_int(c::MSG_OOB),
"MSG_WAITALL" => ctx.new_int(c::MSG_WAITALL),
"AI_ALL" => ctx.new_int(c::AI_ALL),
"AI_PASSIVE" => ctx.new_int(c::AI_PASSIVE),
});
extend_module_platform_specific(vm, &module);