Skip to content
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

Closed
wants to merge 55 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
836e81f
.gitignore rustc ice .txt files
correabuscar Apr 10, 2024
34310c5
make KEY_F() function a const fn
correabuscar Apr 10, 2024
ab8fd26
prefix with KEY_ the keypad keys A1,A3,B2,C1,C3
correabuscar Apr 10, 2024
e4a1b4f
define A_ITALIC if it's defined in header
correabuscar Apr 10, 2024
7fd51d9
make it compile in Gentoo & NixOS, not just Fedora
correabuscar Apr 10, 2024
ab37570
dedup some code
correabuscar Apr 11, 2024
34b50ec
rustfmt build.rs
correabuscar Apr 11, 2024
0e46c9b
unnecessary format!, use .to_string
correabuscar Apr 11, 2024
627e812
move down var declaration
correabuscar Apr 11, 2024
1439cf6
help user know why compilation might've failed
correabuscar Apr 11, 2024
5eccd8e
get rid of build.rs clippy warnings
correabuscar Apr 11, 2024
bd907ec
typo
correabuscar Apr 11, 2024
22ede03
avoid a false positive warning
correabuscar Apr 11, 2024
344549e
fix warnings from cargo test --all-features
correabuscar Apr 11, 2024
2f143fc
`pkgs.pkg-config` is needed on NixOS
correabuscar Apr 11, 2024
b11c398
use latest cc-rs (1.0.92) for build.rs
correabuscar Apr 12, 2024
6a035d6
use ncurses(6) instead of 5 on NixOS
correabuscar Apr 13, 2024
e7e2363
revamp build.rs to be better at error reporting
correabuscar Apr 13, 2024
d69a043
fix NixOS warning about _FORTIFY_SOURCE needing -O
correabuscar Apr 13, 2024
226b846
undeprecate printw, since it's fixed now
correabuscar Apr 13, 2024
e3eb2ff
name the fmt arg for ll::vwprintw & ll::vw_printw
correabuscar Apr 13, 2024
9f96fbb
unused_braces: Unnecessary braces in use statement
correabuscar Apr 13, 2024
a2ad6de
fix link_name=box warning + add r#box too
correabuscar Apr 13, 2024
2dbd207
fix unused import warning on ex_5 and ex_7
correabuscar Apr 13, 2024
8974f44
fix 'unused doc comment' warning
correabuscar Apr 13, 2024
d43c79d
set fallback lib name for menu & panel too
correabuscar Apr 14, 2024
0ed3b2e
use fallback for tinfo lib eg. if no `pkg-config`
correabuscar Apr 15, 2024
9655fea
default to not deletin anything build.rs generated
correabuscar Apr 15, 2024
ebf875b
handle better when TERM isn't in terminal database
correabuscar Apr 15, 2024
8deefe2
be helpful by suggesting TERM env.var change
correabuscar Apr 15, 2024
d256c29
build.rs: connect lib fallback with lib names
correabuscar Apr 16, 2024
4c99e99
use same indent and flush output in genconstants.c
correabuscar Apr 17, 2024
19b2aeb
some build.rs deduppage and improvements
correabuscar Apr 17, 2024
b484d33
make undefined symbols more useful in dependants
correabuscar Apr 19, 2024
d0e98ee
ensure cargo:warning doesn't contain \n
correabuscar Apr 19, 2024
bc272eb
fix the try_link() logic in build.rs
correabuscar Apr 19, 2024
6629827
cargo-warn when using non-utf8 LANG for wide feat.
correabuscar Apr 20, 2024
3fd8920
suggest libncurses-dev package on Ubuntu
correabuscar Apr 20, 2024
d50e3ab
dedup build.rs code for menu/panel lib finding
correabuscar Apr 20, 2024
e3ae3e2
get rid of Path::display() in build.rs
correabuscar Apr 21, 2024
2a49edb
small build.rs improvements
correabuscar Apr 21, 2024
7bd7980
use addr_of!() to get rid of warning; set MSRV.
correabuscar Apr 21, 2024
3543ea6
feature not_OnceLock allows MSRV as low as 1.57.0
correabuscar Apr 21, 2024
3b9c481
small comments&text corrections in build.rs
correabuscar Apr 22, 2024
05bd456
restructure args/envs getting of cmd in build.rs
correabuscar Apr 22, 2024
a68a85b
set edition to 2015 to get rid of warning
correabuscar Apr 22, 2024
ac86ba9
set edition to 2021, with the relevant changes
correabuscar Apr 22, 2024
bd1f1bc
fix `cargo clippy` warnings on build.rs
correabuscar Apr 22, 2024
ab9f4bd
reduce MSRV to 1.57.0 by removing OnceLock
correabuscar Apr 23, 2024
998358e
fix some clippy pedantic warnings in build.rs
correabuscar Apr 23, 2024
c760a16
inline ncurses::box_(...) too
correabuscar Apr 24, 2024
4e98478
say it won't build on windows, but will on WSL
correabuscar Apr 27, 2024
6550ad1
remove code that was testing build.rs
correabuscar May 22, 2024
4cb88d6
build.rs: imp. function to show weird paths as hex
correabuscar May 29, 2024
689f33c
increase version to reflect the changes
correabuscar Jun 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ bin
Cargo.lock
.*
*.swp
rustc-ice-*.txt
21 changes: 19 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ncurses"
version = "6.0.0"
version = "6.0.1"
authors = [ "[email protected]" ]
description = "A very thin wrapper around the ncurses TUI library"
documentation = "https://github.com/jeaye/ncurses-rs"
Expand All @@ -9,10 +9,27 @@ repository = "https://github.com/jeaye/ncurses-rs"
readme = "README.md"
keywords = ["ncurses","TUI"]
license = "MIT"
#If the edition field is not present in Cargo.toml, then the 2015 edition is assumed for backwards compatibility.
#Set to avoid a warning with newer rust:
#The Rust 2021 Edition was introduced in Rust 1.56.0.
edition = "2021"
build = "build.rs"
#https://doc.rust-lang.org/cargo/reference/manifest.html#the-rust-version-field
rust-version = "1.57.0"
#Using this key rust-version= here aka MSRV, makes 1.56.0 be the minimum supported rust version(MSRV)
#The first version of Cargo that supports this field was released with Rust 1.56.0. In older releases, the field will be ignored, and Cargo will display a warning.
#Due to addr_of!() MSRV 1.51.0 is required minimum.
#cc 1.0.92 requires 1.53.0 MSRV(but its `cargo test` passes only with 1.63.0),
# however `cargo build` will pull latest cc due to Cargo.lock missing(on first repo clone)
# and cc version specified isn't fixed like cc="=1.0.92", so:
# due to latest cc pulled being 1.0.95(21Apr2024) it requires 1.63.0 MSRV (ie: `cargo msrv list`)
#Due to build.rs' use of std::process::Command::get_*() MSRV is 1.57.0
#To minimize MSRV further you can set `cc = "=1.0.92"` (note the extra "=") below then run `cargo update`
# that makes MSRV be 1.53.0 minimum, but other things will raise it to 1.57.0
#MSRV is 1.56.0 due to the above edition="2021"

[build-dependencies]
cc = "1.0.18"
cc = "1.0.92"
pkg-config = "0.3"

[dependencies]
Expand Down
1,299 changes: 1,208 additions & 91 deletions build.rs

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions examples/ex_5.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#[allow(unused_imports)]
extern crate ncurses;

#[cfg(feature="menu")]
use ncurses::*;

#[cfg(feature="menu")]
Expand Down Expand Up @@ -38,8 +39,8 @@ fn main() {

/* Print a border around the main window */
box_(my_menu_win, 0, 0);
mvprintw(LINES() - 3, 0, "Press <ENTER> to see the option selected");
mvprintw(LINES() - 2, 0, "F1 to exit");
mvprintw(LINES() - 3, 0, "Press <ENTER> to see the option selected").unwrap();//safe
mvprintw(LINES() - 2, 0, "F1 to exit").unwrap(); //safe
refresh();

/* Post the menu */
Expand All @@ -60,7 +61,8 @@ fn main() {
10 => {/* Enter */
mv(20, 0);
clrtoeol();
mvprintw(20, 0, &format!("Item selected is : {}", item_name(current_item(my_menu)))[..]);
mvprintw(20, 0, &format!("Item selected is : {}", item_name(current_item(my_menu)))[..]).unwrap();
//unwrap() here is safe unless the items have any \0 (nul) char in them, then it will panic!
pos_menu_cursor(my_menu);
},
_ => {}
Expand Down
5 changes: 3 additions & 2 deletions examples/ex_7.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@

extern crate ncurses;

#[cfg(feature = "wide")]
use std::char;
use ncurses::*;

#[cfg(feature = "wide")]
fn main()
{
let locale_conf = LcCategory::all;
setlocale(locale_conf, "en_US.UTF-8");
setlocale(locale_conf, "en_US.UTF-8").unwrap();//safe due to this &str having no \0 in it

/* Setup ncurses. */
initscr();
Expand Down Expand Up @@ -56,7 +57,7 @@ fn main()

Some(WchResult::Char(c)) => {
/* Enable attributes and output message. */
addstr("\nKey pressed: ");
addstr("\nKey pressed: ").unwrap();//safe, no \0 in this &str
attron(A_BOLD | A_BLINK);
addstr(format!("{}\n", char::from_u32(c as u32).expect("Invalid char")).as_ref()).unwrap();
attroff(A_BOLD | A_BLINK);
Expand Down
3 changes: 2 additions & 1 deletion shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ pkgs.stdenv.mkDerivation
name = "ncurses-rs";
buildInputs = with pkgs;
[
pkgs.pkg-config
pkgs.cargo
pkgs.rustup
pkgs.rustfmt
pkgs.ncurses5
pkgs.ncurses
];
}
8 changes: 5 additions & 3 deletions src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ use super::ll::*;

mod wrapped {
use libc::{ c_char, c_int };
use ll::chtype;
use ll::WINDOW;
use crate::ll::chtype;
use crate::ll::WINDOW;

extern "C"
{
Expand Down Expand Up @@ -58,7 +58,9 @@ wrap_extern!(LINES: c_int);
wrap_extern!(TABSIZE: c_int);
pub fn acs_map() -> *const chtype {
unsafe {
&wrapped::acs_map as *const chtype
std::ptr::addr_of!(wrapped::acs_map) as *const chtype
// addr_of! needs minimum rust 1.51.0, if want lower, try this instead:
// &wrapped::acs_map as *const chtype
}
}

Expand Down
Loading