Skip to content

Commit 291b250

Browse files
committed
build: use rust --cfg
Fixed Cargo nonsense rust-lang/cargo#7463 rework winit_term configuration
1 parent c887257 commit 291b250

File tree

20 files changed

+147
-101
lines changed

20 files changed

+147
-101
lines changed

.cargo/config.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[build]
2+
rustflags = [@RUSTFLAGS_CFG@]

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,3 +347,4 @@ lib-src/seccomp-filter-exec.pfc
347347
# GDB history
348348
.gdb_history
349349
_gdb_history
350+
/.cargo/config.toml

Cargo.in

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,10 @@ default = [
5858

5959
# Compile with C xml2 library support.
6060
use-xml2 = []
61-
# Use a window system
62-
window-system = ["emacs/window-system"]
63-
# Use the x11 window system
64-
window-system-x11 = []
65-
# Use the nextstep window system
66-
window-system-nextstep = []
67-
window-system-pgtk = ["webrender"]
68-
# Use the w32 window system
69-
window-system-w32 = []
7061
# Build with git2rs support
7162
libgit = ["git", "ng-bindgen/libgit"]
72-
# Use the webrender window system
73-
webrender = ["dep:webrender_bindings", "ng-bindgen/window-system-winit"]
63+
# Use the webrender renderer
64+
webrender = ["dep:webrender_bindings"]
7465
window-system-winit = ["dep:winit_term", "webrender"]
7566
# Treat warnings as a build error on Travis.
7667
strict = []
@@ -101,7 +92,7 @@ git = "https://github.com/RazrFalcon/fontdb.git"
10192

10293
[patch.crates-io.surfman]
10394
git ="https://github.com/declantsien/surfman.git"
104-
rev = "ad2bf7faacb5b240a47ce280f72e914d1590712f"
95+
rev = "caddee293e1f6ec8b33caec6170585a89c2674b8"
10596

10697
[patch.crates-io.surfman-chains]
10798
git = "https://github.com/declantsien/surfman-chains.git"

Cargo.lock

Lines changed: 6 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure.ac

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2019,6 +2019,11 @@ if test "${with_winit}" = "yes"; then
20192019
no_x=yes
20202020
with_ns=no
20212021
window_system=winit
2022+
with_webrender=yes
2023+
fi
2024+
2025+
if test "${with_webrender}" = "yes"; then
2026+
with_cairo=no
20222027
fi
20232028

20242029
if test "${with_pgtk}" = "yes"; then
@@ -6341,6 +6346,7 @@ AC_SUBST(WINIT_IMPL_COCOA)
63416346

63426347
WEBRENDER_LIBS=
63436348
if test "${with_webrender}" = "yes" ; then
6349+
RUSTFLAGS_CFG="\"--cfg=use_webrender\", ${RUSTFLAGS_CFG}"
63446350
AC_DEFINE(USE_WEBRENDER, 1,
63456351
[Define to 1 if you want to use the webrender.])
63466352

@@ -7035,26 +7041,15 @@ WEBRENDER_DEFAULT_FEATURES=""
70357041
if test "$HAVE_LIBXML2" = "yes"; then
70367042
CARGO_DEFAULT_FEATURES="${CARGO_DEFAULT_FEATURES}\"use-xml2\", "
70377043
fi
7038-
if test "$window_system" != "none"; then
7039-
CARGO_DEFAULT_FEATURES="${CARGO_DEFAULT_FEATURES}\"window-system\", "
7040-
fi
7044+
dnl if test "$window_system" != "none"; then
7045+
RUSTFLAGS_CFG="\"--cfg=have_window_system\", ${RUSTFLAGS_CFG}"
7046+
dnl fi
7047+
RUSTFLAGS_CFG="\"--cfg=window_system=\\\"$window_system\\\"\", ${RUSTFLAGS_CFG}"
70417048
case "$window_system" in
7042-
x11)
7043-
CARGO_DEFAULT_FEATURES="${CARGO_DEFAULT_FEATURES}\"window-system-x11\", "
7044-
;;
7045-
nextstep)
7046-
CARGO_DEFAULT_FEATURES="${CARGO_DEFAULT_FEATURES}\"window-system-nextstep\", "
7047-
;;
7048-
w32)
7049-
CARGO_DEFAULT_FEATURES="${CARGO_DEFAULT_FEATURES}\"window-system-w32\", "
7050-
;;
7051-
pgtk)
7052-
CARGO_DEFAULT_FEATURES="${CARGO_DEFAULT_FEATURES}\"window-system-pgtk\", "
7053-
;;
70547049
winit)
70557050
CARGO_DEFAULT_FEATURES="${CARGO_DEFAULT_FEATURES}\"window-system-winit\", "
70567051
if test x$ac_enable_winit_x11 != x ; then
7057-
WINIT_DEFAULT_FEATURES="\"wr_x11\", ${WINIT_DEFAULT_FEATURES}"
7052+
WINIT_DEFAULT_FEATURES="\"x11\", ${WINIT_DEFAULT_FEATURES}"
70587053
fi
70597054
;;
70607055
esac
@@ -7074,6 +7069,8 @@ fi
70747069
if test "${HAVE_MODULES}" = "yes"; then
70757070
CARGO_DEFAULT_FEATURES="${CARGO_DEFAULT_FEATURES}\"ng-module\", "
70767071
fi
7072+
7073+
AC_SUBST(RUSTFLAGS_CFG)
70777074
AC_SUBST(CARGO_DEFAULT_FEATURES)
70787075
AC_SUBST(WINIT_DEFAULT_FEATURES)
70797076
AC_SUBST(WEBRENDER_DEFAULT_FEATURES)
@@ -7082,6 +7079,7 @@ webrender_src=$srcdir/rust_src/crates/webrender
70827079
AC_CONFIG_FILES([$webrender_src/Cargo.toml:$webrender_src/Cargo.in])
70837080
winit_term_src=$srcdir/rust_src/crates/winit-term
70847081
AC_CONFIG_FILES([$winit_term_src/Cargo.toml:$winit_term_src/Cargo.in])
7082+
AC_CONFIG_FILES([$srcdir/.cargo/config.toml:$srcdir/.cargo/config.in])
70857083
AC_CONFIG_FILES([$srcdir/rust_src/crates/emacs/build.rs])
70867084

70877085
dnl NB we have to cheat and use the ac_... version because abs_top_srcdir

rust_src/build.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ extern crate ng_bindgen;
33
use ng_bindgen::{env_var, generate_include_files, BuildError};
44

55
fn main() {
6-
println!("cargo:rustc-cfg=window_system=\"winit\"");
76
// TODO watch relevent files to re rerun, rs files under crates?
87

98
// generates include files for the crates from the directory "crates"

rust_src/crates/emacs/Cargo.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,3 @@ memoffset = "0.6.4"
1616
bindgen = "0.46"
1717
regex = "1.6"
1818
libc = "0.2"
19-
20-
[features]
21-
window-system = []
22-
window-system-winit = ["window-system"]

rust_src/crates/emacs/src/frame.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::{
1212
window::LispWindowRef,
1313
};
1414

15-
#[cfg(feature = "window-system")]
15+
#[cfg(have_window_system)]
1616
use {
1717
crate::bindings::{gui_default_parameter, resource_types, vertical_scroll_bar_type},
1818
std::ffi::CString,
@@ -45,11 +45,11 @@ impl LispFrameRef {
4545
}
4646

4747
pub fn has_tooltip(self) -> bool {
48-
#[cfg(feature = "window-system")]
48+
#[cfg(have_window_system)]
4949
{
5050
self.tooltip()
5151
}
52-
#[cfg(not(feature = "window-system"))]
52+
#[cfg(not(have_window_system))]
5353
{
5454
false
5555
}
@@ -60,16 +60,16 @@ impl LispFrameRef {
6060
}
6161

6262
pub fn vertical_scroll_bar_type(self) -> u32 {
63-
#[cfg(feature = "window-system")]
63+
#[cfg(have_window_system)]
6464
{
6565
(*self).vertical_scroll_bar_type()
6666
}
67-
#[cfg(not(feature = "window-system"))]
67+
#[cfg(not(have_window_system))]
6868
0
6969
}
7070

7171
pub fn scroll_bar_area_width(self) -> i32 {
72-
#[cfg(feature = "window-system")]
72+
#[cfg(have_window_system)]
7373
{
7474
match self.vertical_scroll_bar_type() {
7575
vertical_scroll_bar_type::vertical_scroll_bar_left
@@ -79,22 +79,22 @@ impl LispFrameRef {
7979
_ => 0,
8080
}
8181
}
82-
#[cfg(not(feature = "window-system"))]
82+
#[cfg(not(have_window_system))]
8383
{
8484
0
8585
}
8686
}
8787

8888
pub fn horizontal_scroll_bar_height(self) -> i32 {
89-
#[cfg(feature = "window-system")]
89+
#[cfg(have_window_system)]
9090
{
9191
if self.horizontal_scroll_bars() {
9292
self.config_scroll_bar_height
9393
} else {
9494
0
9595
}
9696
}
97-
#[cfg(not(feature = "window-system"))]
97+
#[cfg(not(have_window_system))]
9898
{
9999
0
100100
}
@@ -134,7 +134,7 @@ impl LispFrameRef {
134134
}
135135
}
136136

137-
#[cfg(feature = "window-system")]
137+
#[cfg(have_window_system)]
138138
pub fn gui_default_parameter(
139139
mut self,
140140
alist: LispObject,

rust_src/crates/emacs/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub mod lisp;
3232
pub mod eval;
3333
pub mod font;
3434
pub mod frame;
35-
#[cfg(feature = "window-system")]
35+
#[cfg(have_window_system)]
3636
pub mod glyph;
3737
pub mod keyboard;
3838
pub mod list;

rust_src/crates/emacs/src/window.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,22 @@ impl LispWindowRef {
3030
self.frame.into()
3131
}
3232

33-
#[cfg(not(feature = "window-system-winit"))]
33+
#[cfg(not(window_system = "winit"))]
3434
pub fn is_menu_bar(self) -> bool {
3535
unimplemented!();
3636
}
3737

38-
#[cfg(feature = "window-system-winit")]
38+
#[cfg(window_system = "winit")]
3939
pub fn is_menu_bar(self) -> bool {
4040
false
4141
}
4242

43-
#[cfg(not(feature = "window-system-winit"))]
43+
#[cfg(not(window_system = "winit"))]
4444
pub fn is_tool_bar(self) -> bool {
4545
unimplemented!();
4646
}
4747

48-
#[cfg(feature = "window-system-winit")]
48+
#[cfg(window_system = "winit")]
4949
pub fn is_tool_bar(self) -> bool {
5050
false
5151
}

rust_src/crates/webrender/Cargo.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ build = "build.rs"
88
path = "src/lib.rs"
99

1010
[dependencies]
11-
emacs = { path = "../emacs", features = ["window-system-winit"] }
11+
emacs = { path = "../emacs" }
1212
lisp-macros = { path = "../lisp_macros" }
1313
lisp-util = { path = "../lisp_util" }
1414
colors = { path = "../../../etc/colors" }

rust_src/crates/winit-term/Cargo.in

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ build = "build.rs"
88
path = "src/lib.rs"
99

1010
[dependencies]
11-
emacs = { path = "../emacs", features = ["window-system-winit"] }
11+
emacs = { path = "../emacs" }
1212
lisp-macros = { path = "../lisp_macros" }
1313
lisp-util = { path = "../lisp_util" }
1414
webrender_bindings = { path = "../webrender/" }
@@ -62,6 +62,6 @@ optional = true
6262
core-foundation = "0.9.2"
6363

6464
[features]
65-
default = ["wr_wayland", @WINIT_DEFAULT_FEATURES@]
66-
wr_x11 = ["x11", "copypasta/x11", "surfman/sm-x11"]
67-
wr_wayland = ["copypasta/wayland"]
65+
default = ["wayland", @WINIT_DEFAULT_FEATURES@]
66+
x11 = ["dep:x11", "copypasta/x11", "surfman/sm-x11"]
67+
wayland = ["copypasta/wayland"]

rust_src/crates/winit-term/build.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ fn main() {
3434
free_unix: { all(unix, not(apple), not(android_platform)) },
3535

3636
// Native displays.
37-
x11_platform: { all(feature = "wr_x11", free_unix, not(wasm)) },
38-
wayland_platform: { all(feature = "wr_wayland", free_unix, not(wasm)) },
37+
x11_platform: { all(feature = "x11", free_unix, not(wasm)) },
38+
wayland_platform: { all(feature = "wayland", free_unix, not(wasm)) },
3939
}
4040
}

rust_src/ng-bindgen/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,3 @@ path = "lib.rs"
2222
libgit = []
2323
javascript = []
2424
ng-module = []
25-
window-system-winit = []

rust_src/ng-bindgen/lib.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,8 +474,11 @@ fn build_ignored_crates(path: &PathBuf) -> bool {
474474
#[cfg(not(feature = "ng-module"))]
475475
ignored_crates.push("ng_module");
476476

477-
#[cfg(not(feature = "window-system-winit"))]
478-
ignored_crates.push("winit");
477+
#[cfg(not(window_system = "winit"))]
478+
ignored_crates.push("winit-term");
479+
480+
#[cfg(not(use_webrender))]
481+
ignored_crates.push("webrender");
479482

480483
let crate_path = path_as_str(path.file_name()).to_string();
481484

0 commit comments

Comments
 (0)