-
Notifications
You must be signed in to change notification settings - Fork 104
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 <alexandre.bury@gmail.com> 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 <alexandre.bury@gmail.com> * get rid of unused warning for addstr --------- Co-authored-by: Alexandre Bury <alexandre.bury@gmail.com>
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_5with--features=menu) and fail to build on NixOS or Gentoo.This PR was initially spawned from: #201 (comment)
The following were used successfully:
cargo buildcargo test(though there are 0 tests)cargo build --all-featurescargo test --all-featurescargo build --all-targetscargo test --all-targetscargo build --all-targets --all-featurescargo test --all-targets --all-features... on each of these target environments:
nix-shellwhich uses ./shell.nixfile)ncurses&pkgconfncurses&pkgconf(ie. do# pkg install ncurses pkgconf)pkg-config(which it doesn't findncurses) and no explicit ncurses installed(butbase75andcomp75has the libs respectively the headers) - it builds and passes all tests(even ofcursiveandpancurses) but the examples look broken/unusable incursive(TERM=vt220) - inncurses-rsdoesn't detectF1to exit fromex_4andex_5- this depends onTERMenv.var, for example if it'sTERM=alacrittythey work.LC_CTYPE=en_US.UTF-8orLANG=en_US.UTF-8to be set otherwise it looks as if it doesn't have wide chars support socursiveandpancusesexamples look pretty broken.libncurses-dev)pkg-configandpkgconfinstalled.pkg-configinstalled.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-rsv5 to v6 after this PR is in):cursive) - needs acargo updatefirst and its depcursive_table_viewto be updated with this PR first.Ideal TODO(s):
(left to be done by the maintainer of the repo, unless told otherwise)build.rsbuild.rsbuild.rsx86_64-pc-windows-gnu) (compile,test, maybe also run examples)LC_MESSAGESwere 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,pancursesis supposed to work on Windows and it usesncurses-rs,pancursesusespdcurses-syson Windows) howeverbuild.rshas somecfg!(windows)in code.pancursescompiles with this PR, on Windows. (it's unaffected)ex_5linking which fails on NixOS whencargo test --all-featuresis used (is fine on Fedora and Gentoo though) - unclear why it can't find themenulib unless specified like:RUSTFLAGS='-l menu' cargo test --features=menu// fixed by ensuringpkgs.pkg-configexisted in thenix-shellrustfmtonbuild.rs?cargo:rerun-if-env-changed-Land the path as separate.arg()s not merged into one..display(), we definitely don't want\0to be part of the path i believe.PATHand 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 useCCenv.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.rscommit 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 insteadprintwis 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) -> i3not a foreign function or staticUNCLEARlink_namedoc - ok i think i understand the intention now: we wanted to usencurses::box_in rust but thencurses::ll:box_one must map to one namedboxfrom the ncurses lib. But I'm not sure why this was done instead of just usingboxfrom the start, ah I seeexpected identifier, found reserved keywordbut nowr#boxcould be used, except thatbox_would also have to be used for compatibility.r#boxtoo for both rust andll.warning: creating a shared reference to mutable static is discouraged&wrapped::acs_map as *const chtypeshared reference to mutable static- apparently nothing now uses this anymore, in this crate, but was added by this commit.cargo clippyand fix:error: this public function might dereference a raw pointer but is not marked unsafestr::from_utf8_unchecked(CStr::from_ptr(ptr).to_bytes()).to_owned()ll::copywin(src_win, dest_win, src_min_row, src_min_col,warning: ncurses@6.0.0: 414 | # warning _FORTIFY_SOURCE requires compiling with optimization (-O)wouldn't compilethis was due toncurses-rsfor other reasons eg.ERROKTERM=linuxinstead ofTERM=xtermnow 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=cursesshould work, I estimate.cargo testthough) - even though they happen due to feature not being active.cargo build --features widenix-shellin repo dir (I didn't noticeshell.nixexisted until late) than havingpkgs.ncursesinstalled system-wide and then settingPKG_CONFIG_PATHbefore runningcargo buildin 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 prefixesfirst, 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-featurescompileswarning: unused doc commentwarning: unusedResultthat must be usedfor functions that would Err due to any\0in &str whenCString::newprocesses 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.rsrevamping eg. seen hereex_5will fail on FreeBSD unless it haspkgconfinstalled (ie.pkg install pkgconf)ncurses5thenncursessince the latter is version 6(or presumably latest so at least 5 or more), don't we want to use the latest version? Wasncursesever lower version thanncurses5in 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_6in FreeBSD, see why it's black screen except the bottom shows<-Press Space->- that being said, comments invimare very dark blue which are unreadable! - Ok it hasTERM=xtermin text console, but works well withTERM=vt100orTERM=vt220, tho no colors; withTERM=xterm-256coloris that dark blue from vim comments mostly, but still better than that black one from before. Gonna say it's FreeBSD at fault here becausevimcolors 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=1andNCURSESW_NO_PKG_CONFIG=1(andncursesandncursesw5don't exist on system) which emulatespkg-confignot existing, then, at least on Gentoo,libtinfo(w)doesn't get linked in, and so for exampleex_5it will fail to link because we have no fallback for linkingtinfolib too, fallback was there only forncurseslib.And the good thing is ifit doesn't it's just like addingtinfoisn't needed, such as on NixOS, and we could still tellcargoviaprintln!("cargo:rustc-link-lib=tinfo");(ortinfow) to link it,cargowill gracefully ignore it if it doesn't exist.(or so I hear, must test)-ltinfoto 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 OpenBSDTERMis 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_CTYPEorLANGare set to anything withutf-8(case insensitive) in them, then cargo warn thatwidefeature won't display correctly, but only ifwidefeature 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-8exactly on OpenBSD, else it won't work. Howeverenoren_USor even ``(empty) can be used in any case (we don't check for these though), so evenLANG=.UTF-8works (but not on Gentoo for example)--features=not_OnceLockand pinning build depcc="=1.0.92and changingrust-version="1.57.0"inCargo.toml.cc="=1.0.92"passescargo buildwith MSRV1.53.0but notcargo testunless MSRV is1.63.0cc="=1.0.95"needs1.63.0cc="=1.0.18"(the pre-PR value) has MSRV1.19.0(forcargo build) but it doesn't passcargo testwith any rust version.cc="=1.0.40"(randomly picked) passescargo testfor MSRV1.40.0(coincidence) andcargo buildMSRV is1.19.0.replaceremove OnceLock and just don't care about repetitions forOnceLockinbuild.rswhich requires MSRV1.70.0with something else maybeAtomicBool+Mutexwhich have MSRV1.0.0cargo:rerun-if-env-changed, MSRV is now1.57.0, but remember thatccis1.0.95at the moment (Cargo.locknot being in the repo) thus MSRV is1.63.0just likeccneeds.cargo build --features=test_build_rs_of_ncurses_rswhich was testing only some of thebuild.rsinternal code. This testing would've only be useful for devs ofncurses-rsbasically, but it wasn't testing enough of the code anyway. Did help during the PR though. Removed as per this.