-
Notifications
You must be signed in to change notification settings - Fork 99
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
Makes the build more robust and fixes compile errors and warnings #218
Conversation
files like: rustc-ice-2024-04-10T18_21_42-154961.txt made due to using rust flags: -Z treat-err-as-bug=5
so that it can be used like this: pub const KEY_F15: i32 = ncurses::KEY_F(15); which is what pancurses uses.
or else they aren't defined. (regression)
(regression)
but ncurses-rs needs the changes in this PR first: jeaye/ncurses-rs#218 (except the .gitignore and build.rs changes from there)
This comment was marked as resolved.
This comment was marked as resolved.
ncurses-rs
v6 compile/run and be compatible with some previous users of v5 if they upgrade&patch
else this will fail to find `menu` lib: $ nix-shell $ cargo test --features=menu unless you'd do it like this: $ RUSTFLAGS='-l menu' cargo test --features=menu This was true even before PR jeaye#218
These appear unrelated to the PR to me.
https://tldp.org/HOWTO/NCURSES-Programming-HOWTO/printw.html |
ncurses-rs
v6 compile/run and be compatible with some previous users of v5 if they upgrade&patchncurses-rs
v6 compile/run and allow cursive
and pancurses
to compile(if they upgrade&patch)
This comment was marked as resolved.
This comment was marked as resolved.
ncurses-rs
v6 compile/run and allow cursive
and pancurses
to compile(if they upgrade&patch)ncurses-rs
v6 compile and allows cursive
and pancurses
to compile(if they upgrade&patch)
else this will fail to find `menu` lib: $ nix-shell $ cargo test --features=menu unless you'd do it like this: $ RUSTFLAGS='-l menu' cargo test --features=menu This was true even before PR jeaye#218
8a0a10e
to
800b88a
Compare
...provided the libs/includes are installed system-wide already. Decided not to split this in different commits (which each still compile) due to too much redundant work, since everything is already done in this one commit.
As a reminder, worst case, you could just consider(ie. cherry pick) only the last 3 commits from the day of April 11th, seen here at the top: https://github.com/jeaye/ncurses-rs/pull/218/commits (EDIT: these1) and ignore the rest(ie. from april 18th and onwards) or even forget about the whole rest of PR, because those 3 commits are the only ones needed to get the other projects (cursive, pancurses) to work (and PRs for them are already prepared). Meanwhile, I could just take another look to see if indeed those 3 commits are indeed enough. EDIT: I've done the checking:
that testing of I can just make a commit to remove that testing
the code could probably be minimized more I guess, but it's mainly this much because it's meant to handle many build cases with better reporting in case of build failures, otherwise whoever's building it might be spending more time trying to figure out what went wrong which is something I was trying to spare/avoid. This is arguably not commonplace... Footnotes
|
3b004eb
to
e8fa0e4
Compare
but ncurses-rs needs the changes in this PR first: jeaye/ncurses-rs#218 (except the .gitignore and build.rs changes from there)
but ncurses-rs needs the changes in this PR first: jeaye/ncurses-rs#218 (except the .gitignore and build.rs changes from there)
but ncurses-rs needs the changes in this PR first: jeaye/ncurses-rs#218 (except the .gitignore and build.rs changes from there)
as suggested in: jeaye#218 (comment) Before this removal, this command was testing _some_ build.rs functionality: $ cargo build --features=test_build_rs_of_ncurses_rs
* previously char range 0x00 to 0x1F weren't hexified * even if valid utf-8, still show \0 as \x00 (even though in our use case \0 wouldn't be seen due to being converted by Command::arg/args earlier to "<string-with-nul>") * passes the tests that were there thus far but got removed by prev. commit
e8fa0e4
to
4cb88d6
Compare
I'm out of my depth, here. |
but ncurses-rs needs the changes in this PR first: jeaye/ncurses-rs#218 (except the .gitignore and build.rs changes from there)
Ditto. :-) |
but ncurses-rs needs the changes in this PR first: jeaye/ncurses-rs#218 (except the .gitignore and build.rs changes from there)
but ncurses-rs needs the changes in this PR first: jeaye/ncurses-rs#218 (except the .gitignore and build.rs changes from there)
but ncurses-rs needs the changes in this PR first: jeaye/ncurses-rs#218 (except the .gitignore and build.rs changes from there)
but ncurses-rs needs the changes in this PR first: jeaye/ncurses-rs#218 (except the .gitignore and build.rs changes from there)
I (somehow lol)realize now that I've been too stubborn about it and that @vwbusguy was right about this PR needing to be split into two others. So I'll attempt to do this next, so this PR will remain the build improvement one and a new PR will do ONLY the needed stuff for |
cursive
and pancurses
to compile(if they upgrade&patch)but ncurses-rs needs the changes in this PR first: jeaye/ncurses-rs#218 (except the .gitignore and build.rs changes from there)
but ncurses-rs needs the changes in this PR first: jeaye/ncurses-rs#218 (except the .gitignore and build.rs changes from there)
which means that ncurses-rs already has the needed changes in this PR: jeaye/ncurses-rs#220 and/or from this PR: jeaye/ncurses-rs#218
which means that ncurses-rs already has the needed changes in this PR: jeaye/ncurses-rs#220 and/or from this PR: jeaye/ncurses-rs#218
which means that ncurses-rs already has the needed changes in this PR: jeaye/ncurses-rs#220 and/or from this PR: jeaye/ncurses-rs#218
which means that ncurses-rs already has the needed changes in this PR: jeaye/ncurses-rs#220 and/or from this PR: jeaye/ncurses-rs#218
Closing this to allow someone else in the future to come along and do things better, less verbose and more maintainable(!), and so they won't feel deterred by the existence of this PR to make it their own way :) |
which means that ncurses-rs already has the needed changes in this PR: jeaye/ncurses-rs#220 and/or from this PR: jeaye/ncurses-rs#218
* make it work with ncurses-rs >=6.0.1 which means that ncurses-rs already has the needed changes in this PR: jeaye/ncurses-rs#220 and/or from this PR: jeaye/ncurses-rs#218 * get rid of a warning when using newterm newterm https://github.com/jeaye/ncurses-rs/blob/3aa22bc279e4929e3ab69d49f75a18eda3e431e9/src/lib.rs#L1023-L1029 CString::new https://doc.rust-lang.org/std/ffi/struct.CString.html#method.new bubble up this newterm error as suggested here: #778 (comment) Co-authored-by: Alexandre Bury <[email protected]> preserve original error in the panic report otherwise, we'd not know why ncurses-rs newterm errored directly include the variable name in the format! expression as suggested here: #778 (comment) Co-authored-by: Alexandre Bury <[email protected]> * get rid of unused warning for addstr --------- Co-authored-by: Alexandre Bury <[email protected]>
UPDATE: Part of this PR is now duplicated into #220 (for the case when the backwards-compatible(iirc) improvements here aren't wanted, or seem too much to review) but in this PR I've kept the commits that #220 has, for now, so merging either one or both should be possible.
This PR preserves the changes that were already done in v6 here(or, well, until this point) and attempts to "fix" some of the missing things... while also making sure compilation doesn't fail on a bunch of target environments and if it does fail, that the user trying to build it has plenty of helpful information about it. Before this PR it would build on Fedora and Ubuntu (and OpenBSD/FreeBSD but fail to link
ex_5
with--features=menu
) and fail to build on NixOS or Gentoo.This PR was initially spawned from: #201 (comment)
The following were used successfully:
cargo build
cargo test
(though there are 0 tests)cargo build --all-features
cargo test --all-features
cargo build --all-targets
cargo test --all-targets
cargo build --all-targets --all-features
cargo test --all-targets --all-features
... on each of these target environments:
nix-shell
which uses ./shell.nix
file)ncurses
&pkgconf
ncurses
&pkgconf
(ie. do# pkg install ncurses pkgconf
)pkg-config
(which it doesn't findncurses
) and no explicit ncurses installed(butbase75
andcomp75
has the libs respectively the headers) - it builds and passes all tests(even ofcursive
andpancurses
) but the examples look broken/unusable incursive
(TERM=vt220
) - inncurses-rs
doesn't detectF1
to exit fromex_4
andex_5
- this depends onTERM
env.var, for example if it'sTERM=alacritty
they work.LC_CTYPE=en_US.UTF-8
orLANG=en_US.UTF-8
to be set otherwise it looks as if it doesn't have wide chars support socursive
andpancuses
examples look pretty broken.libncurses-dev
)pkg-config
andpkgconf
installed.pkg-config
installed.ex_5
(ld: symbol(s) not found for architecture x86_64
) unless you brew ncurses and set PKG_CONFIG_PATH like said here)... and on the following repos that use
ncurses-rs
(if they applied their own patches for which they've PR already waiting in draft mode, to transition from usingncurses-rs
v5 to v6 after this PR is in):cursive
) - needs acargo update
first and its depcursive_table_view
to be updated with this PR first.Ideal TODO(s):
(left to be done by the maintainer of the repo, unless told otherwise)build.rs
build.rs
build.rs
x86_64-pc-windows-gnu
) (compile,test, maybe also run examples)LC_MESSAGES
were removed (it's in two places) - no idea what about them but it's probably no good to do this.actually this isn't entirely true,(eh,pancurses
is supposed to work on Windows and it usesncurses-rs
,pancurses
usespdcurses-sys
on Windows) howeverbuild.rs
has somecfg!(windows)
in code.pancurses
compiles with this PR, on Windows. (it's unaffected)ex_5
linking which fails on NixOS whencargo test --all-features
is used (is fine on Fedora and Gentoo though) - unclear why it can't find themenu
lib unless specified like:RUSTFLAGS='-l menu' cargo test --features=menu
// fixed by ensuringpkgs.pkg-config
existed in thenix-shell
rustfmt
onbuild.rs
?cargo:rerun-if-env-changed
-L
and the path as separate.arg()
s not merged into one..display()
, we definitely don't want\0
to be part of the path i believe.PATH
and having the same name as compiler executable there, because otherwise doesn't seem to use an env var to set the executable for compiler to use EDIT: it does actually useCC
env.var.) to use a script thus paths would be passed to a script acting as the compiler. Defaulting to using.display()
on Path/PathBuf just like previous code did. But this would be bad if compiler is a script, but it's not something we can control or pre-escape from here really.git bisect
; this means, squashing the commits before merge wouldn't be necessary. For this reason decided not to break that bigbuild.rs
commit into smaller commits anymore, but also because it's doing lots of refactoring.warning: use of deprecated function printw: printw format support is disabled. Use addstr instead
printw
is a rust function accepting only 1 arg, thereforeformat!()
would be used for formatting before calling it.warning: attribute should be applied to a foreign function or static
#[link_name="box"] pub fn box_(w: WINDOW, v: chtype, h: chtype) -> i3
not a foreign function or static
UNCLEARlink_name
doc - ok i think i understand the intention now: we wanted to usencurses::box_
in rust but thencurses::ll:box_
one must map to one namedbox
from the ncurses lib. But I'm not sure why this was done instead of just usingbox
from the start, ah I seeexpected identifier, found reserved keyword
but nowr#box
could be used, except thatbox_
would also have to be used for compatibility.r#box
too for both rust andll
.warning: creating a shared reference to mutable static is discouraged
&wrapped::acs_map as *const chtype
shared reference to mutable static
- apparently nothing now uses this anymore, in this crate, but was added by this commit.cargo clippy
and fix:error: this public function might dereference a raw pointer but is not marked unsafe
str::from_utf8_unchecked(CStr::from_ptr(ptr).to_bytes()).to_owned()
ll::copywin(src_win, dest_win, src_min_row, src_min_col,
warning: [email protected]: 414 | # warning _FORTIFY_SOURCE requires compiling with optimization (-O)
wouldn't compilethis was due toncurses-rs
for other reasons eg.ERR
OK
TERM=linux
instead ofTERM=xterm
now compiles but ex_7 won't link; and I couldn't get NetBSD to see its own packages, sees 0)NCURSES_RS_RUSTC_LINK_LIB=curses
should work, I estimate.cargo test
though) - even though they happen due to feature not being active.cargo build --features wide
nix-shell
in repo dir (I didn't noticeshell.nix
existed until late) than havingpkgs.ncurses
installed system-wide and then settingPKG_CONFIG_PATH
before runningcargo build
in repo dir. Both work.Build
's.flag_if_supported()
(or just.flag()
) to add compiler flags instead of (the old way)directly via the compiler that was gotten via.try_get_compiler()
, I just kept the old way there so far (maybe there's a good reason for it, unsure).NCURSES_RS_CFLAGS
- well that method will trysearch for an environment variable with appropriate target prefixes
first, so a bunch of differently named env. vars will be checked first kind of breaking compatibility with the way it worked before, although this would be a better way, arguably.cargo test --all-features
compileswarning: unused doc comment
warning: unused
Resultthat must be used
for functions that would Err due to any\0
in &str whenCString::new
processes it..unwrap_or_else(|_|
but show them instead, so start with.unwrap_or_else(|e|
... and showe
- this was introduced by a commit in this PR, but now force pushed as fixed.build.rs
revamping eg. seen hereex_5
will fail on FreeBSD unless it haspkgconf
installed (ie.pkg install pkgconf
)ncurses5
thenncurses
since the latter is version 6(or presumably latest so at least 5 or more), don't we want to use the latest version? Wasncurses
ever lower version thanncurses5
in the past? Since we stop if we findncurses5
, this means we'd be using 5 instead of 6 if somehow both are present. This was the behavior before this PR.If this is checked-marked then I've switched it to: tryI left this as it was because I've no way to test that it broke before and isn't now.ncurses(w)
thenncurses(w)5
, stop on first find; same for 'menu' and 'panel'ex_6
in FreeBSD, see why it's black screen except the bottom shows<-Press Space->
- that being said, comments invim
are very dark blue which are unreadable! - Ok it hasTERM=xterm
in text console, but works well withTERM=vt100
orTERM=vt220
, tho no colors; withTERM=xterm-256color
is that dark blue from vim comments mostly, but still better than that black one from before. Gonna say it's FreeBSD at fault here becausevim
colors are also weird.tinfo(w)
as fallback in case it might exist(like on Gentoo) but won't affect NixOS which doesn't have it(due to theno it's not!); so, whencargo
's gonna ignore if it doesn't existpkg-config
(/pkgconf
) doesn't exist or i've setNCURSES_NO_PKG_CONFIG=1
andNCURSESW_NO_PKG_CONFIG=1
(andncurses
andncursesw5
don't exist on system) which emulatespkg-config
not existing, then, at least on Gentoo,libtinfo(w)
doesn't get linked in, and so for exampleex_5
it will fail to link because we have no fallback for linkingtinfo
lib too, fallback was there only forncurses
lib.And the good thing is ifit doesn't it's just like addingtinfo
isn't needed, such as on NixOS, and we could still tellcargo
viaprintln!("cargo:rustc-link-lib=tinfo");
(ortinfow
) to link it,cargo
will gracefully ignore it if it doesn't exist.(or so I hear, must test)-ltinfo
to linker, fails if it doesn't exist, like on NixOS - must find a way here... I've an idea to try.LC_CTYPE="en_US.UTF-8"
on OpenBSDTERM
is unknown on the system, errors like: error[E0432]: unresolved importconstants::TRUE
- with this fixed, I can definitely go back to trying sabotage linux's netbsd-curses then, which was failing like this before.try_link()
(which this PR added inbuild.rs
) which would fail to find libmenu but say it would still tell cargo to link it, so it worked anyway. Fixed it now to try linking with ncurses if without it fails, thus detecting that libmenu links successfully and thus not show the wrong warning.LC_ALL
,LC_CTYPE
orLANG
are set to anything withutf-8
(case insensitive) in them, then cargo warn thatwide
feature won't display correctly, but only ifwide
feature is enabled. OpenBSD 7.5 has none of these set, by default (maybe I didn't follow the install instructions, else I would've set them manually, but they're for sure not set automatically)UTF-8
exactly on OpenBSD, else it won't work. Howeveren
oren_US
or even ``(empty) can be used in any case (we don't check for these though), so evenLANG=.UTF-8
works (but not on Gentoo for example)--features=not_OnceLock
and pinning build depcc="=1.0.92
and changingrust-version="1.57.0"
inCargo.toml
.cc="=1.0.92"
passescargo build
with MSRV1.53.0
but notcargo test
unless MSRV is1.63.0
cc="=1.0.95"
needs1.63.0
cc="=1.0.18"
(the pre-PR value) has MSRV1.19.0
(forcargo build
) but it doesn't passcargo test
with any rust version.cc="=1.0.40"
(randomly picked) passescargo test
for MSRV1.40.0
(coincidence) andcargo build
MSRV is1.19.0
.replaceremove OnceLock and just don't care about repetitions forOnceLock
inbuild.rs
which requires MSRV1.70.0
with something else maybeAtomicBool
+Mutex
which have MSRV1.0.0
cargo:rerun-if-env-changed
, MSRV is now1.57.0
, but remember thatcc
is1.0.95
at the moment (Cargo.lock
not being in the repo) thus MSRV is1.63.0
just likecc
needs.cargo build --features=test_build_rs_of_ncurses_rs
which was testing only some of thebuild.rs
internal code. This testing would've only be useful for devs ofncurses-rs
basically, but it wasn't testing enough of the code anyway. Did help during the PR though. Removed as per this.