Skip to content

Commit

Permalink
Prepare whoami v1.5.2 (#113)
Browse files Browse the repository at this point in the history
  • Loading branch information
AldaronLau committed Sep 3, 2024
1 parent 0f32409 commit c1dfdec
Show file tree
Hide file tree
Showing 12 changed files with 73 additions and 42 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ jobs:
- i686-unknown-linux-gnu
- wasm32-wasi
- x86_64-apple-darwin
- x86_64-unknown-redox
- x86_64-unknown-illumos
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
Expand Down Expand Up @@ -82,7 +80,7 @@ jobs:
- run: cargo clippy --all-features --target=${{ matrix.cc }} -- -D warnings
- run: cargo update
- run: cargo clippy --no-default-features --target=${{ matrix.cc }} -- -D warnings
- run: RUSTFLAGS="--cfg target_os=\"daku\"" cargo clippy --target=${{ matrix.cc }} -- -D warnings
- run: RUSTFLAGS="--cfg daku" cargo clippy --target=${{ matrix.cc }} -- -D warnings
test:
runs-on: ${{ matrix.os }}
strategy:
Expand Down Expand Up @@ -111,7 +109,7 @@ jobs:
toolchain: ${{ matrix.tc }}
override: true
- run: cargo update
- run: cargo test --all --all-features --target=x86_64-apple-darwin
- run: cargo test --all --all-features
cross-compile:
runs-on: ${{ matrix.os }}
strategy:
Expand Down Expand Up @@ -139,7 +137,7 @@ jobs:
strategy:
matrix:
os: [macos-latest]
tc: [1.40.0, stable, beta, nightly]
tc: [stable, beta, nightly]
cc: [aarch64-apple-ios]
steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -185,8 +183,8 @@ jobs:
- run: cargo build --all-features --target=${{ matrix.cc }}
- run: cargo update
- run: cargo build --no-default-features --target=${{ matrix.cc }}
- run: RUSTFLAGS="--cfg target_os=\"daku\"" cargo build --target=${{ matrix.cc }}
cross-compile-illumos:
- run: RUSTFLAGS="--cfg daku" cargo build --target=${{ matrix.cc }}
cross-compile-illumos-and-checks:
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand All @@ -198,12 +196,13 @@ jobs:
- uses: actions-rs/toolchain@v1
with:
profile: minimal
components: clippy
toolchain: ${{ matrix.tc }}
target: ${{ matrix.cc }}
override: true
- run: cargo update
- run: cargo build --all-features --target=${{ matrix.cc }}
cross-compile-redox:
- run: cargo clippy --all-features --target=${{ matrix.cc }} -- -D warnings
cross-compile-redox-and-checks:
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand All @@ -215,8 +214,9 @@ jobs:
- uses: actions-rs/toolchain@v1
with:
profile: minimal
components: clippy
toolchain: ${{ matrix.tc }}
target: ${{ matrix.cc }}
override: true
- run: cargo update
- run: cargo build --all-features --target=${{ matrix.cc }}
- run: cargo clippy --all-features --target=${{ matrix.cc }} -- -D warnings
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog], and this project adheres to
[Semantic Versioning].

## [1.5.2] - 2024-09-02

### Changed

- Updated redox\_syscall to 0.5
- Replace `target_os = daku` with `daku` cfg
- Improved repository documentation

## [1.5.1] - 2024-03-09

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "whoami"
version = "1.5.1"
version = "1.5.2"
edition = "2018"
license = "Apache-2.0 OR BSL-1.0 OR MIT"
documentation = "https://docs.rs/whoami"
Expand Down Expand Up @@ -34,7 +34,7 @@ version = "0.5"
version = "0.1"

# Target-specific dependency for web browser
[target.'cfg(all(target_arch = "wasm32", not(target_os = "wasi"), not(target_os = "daku")))'.dependencies.web-sys]
[target.'cfg(all(target_arch = "wasm32", not(target_os = "wasi"), not(daku)))'.dependencies.web-sys]
version = "0.3"
features = ["Navigator", "Document", "Window", "Location"]
optional = true
Expand All @@ -44,3 +44,6 @@ default = ["web"]
# Enabling this feature indicates that the wasm32-unknown-unknown target should
# be assumed to be in a web environment where it can call DOM APIs.
web = ["web-sys"]

[lints.rust]
unexpected_cfgs = { level = "allow", check-cfg = ['cfg(daku)'] }
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Retrieve the current user and environment through simple functions.
Check out the [documentation][0] for examples.

### Features

- Get the user's full name
- Get the user's username
- Get the user's preferred language(s)
Expand All @@ -27,7 +28,9 @@ Check out the [documentation][0] for examples.
- Get the devices's CPU architecture and its width

### Supported Platforms

WhoAmI targets all platforms that can run Rust, including:

- Linux
- Windows
- Mac OS
Expand All @@ -45,6 +48,7 @@ WhoAmI targets all platforms that can run Rust, including:
- Others? (make a PR or open an issue)

## MSRV

WhoAmI 1.x.y targets Rust 1.40.0 stable and later, and the 1.x.y track will
be maintained at least until the release of the Rust 2024 edition.

Expand All @@ -55,15 +59,18 @@ releases to be supported and receive bugfixes at least until sometime in 2027,
bumping MSRV only as needed.

## Binary

[whome](https://crates.io/crates/whome): `whoami` command RiR (Re-written in
Rust) that depends on this crate.

## Testing

The testing procedure is documented at
<https://github.com/ardaku/whoami/blob/v1/TESTING.md>. The full manual test
suite is run for each change that affects multiple platforms.

## License

Copyright © 2017-2024 The WhoAmI Contributors.

Licensed under any of
Expand All @@ -76,11 +83,13 @@ Licensed under any of
at your option.

### Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
licensed as described above, without any additional terms or conditions.

## Help

If you want help using or contributing to this library, feel free to send me an
email at [aldaronlau@gmail.com][13].

Expand Down
24 changes: 17 additions & 7 deletions TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ Device's CPU Arch whoami::arch(): Unknown: i86pc

<https://doc.redox-os.org/book/ch08-01-advanced-build.html#understanding-cross-compilation-for-redox>

Tested on Fedora Silverblue 39
Tested on Fedora Silverblue 40

### Update Rust Nightly and Stable

Expand All @@ -294,7 +294,7 @@ rustup target add --toolchain stable x86_64-unknown-redox
### Install pre-requisites

```shell
sudo dnf install git file autoconf vim bison flex genisoimage gperf glibc-devel.i686 expat expat-devel fuse-devel fuse3-devel gmp-devel perl-HTML-Parser libpng-devel libtool libjpeg-turbo-devel libvorbis-devel SDL2_ttf-devel mesa-libOSMesa-devel m4 nasm po4a syslinux texinfo sdl12-compat-devel ninja-build meson python3-mako make gcc gcc-c++ openssl patch automake perl-Pod-Html perl-FindBin gperf curl gettext-devel perl-Pod-Xhtml pkgconf-pkg-config cmake cbindgen just qemu doxygen 'perl(ExtUtils::MakeMaker)'
sudo dnf install git file autoconf vim bison flex genisoimage gperf glibc-devel.i686 expat expat-devel fuse-devel fuse3-devel gmp-devel perl-HTML-Parser libpng-devel libtool libjpeg-turbo-devel libvorbis-devel SDL2_ttf-devel mesa-libOSMesa-devel m4 nasm po4a syslinux texinfo sdl12-compat-devel ninja-build meson python3-mako make gcc gcc-c++ openssl patch automake perl-Pod-Html perl-FindBin gperf curl gettext-devel perl-Pod-Xhtml pkgconf-pkg-config cmake cbindgen just mpfr-devel qemu doxygen 'perl(ExtUtils::MakeMaker)'

cargo install --locked --force --version 0.1.1 cargo-config
```
Expand All @@ -305,27 +305,37 @@ cargo install --locked --force --version 0.1.1 cargo-config
mkdir -p build/
cd build/
git clone https://gitlab.redox-os.org/redox-os/redox.git --origin upstream --recursive
cd redox
git submodule update --recursive --init
```

### Create our demo recipe

Make sure whome is updated to the whoami testing branch.
Back in the root whoami directory, make sure whome is updated to the whoami
testing branch.

```shell
mkdir -p build/redox/cookbook/recipes/demos/whome/
cp recipe.toml build/redox/cookbook/recipes/demos/whome/
cp build/redox/config/desktop.toml config/x86_64/ardaku.toml
cp build/redox/config/desktop.toml build/redox/config/x86_64/ardaku.toml
```

In `config/x86_64/ardaku.toml`, under `[packages]`:
In `build/redox/config/x86_64/ardaku.toml`, under `[packages]`, add:

```toml
whome = {}
```

### Select the config
IN `build/redox/mk/config.mk`, set:

```make
CONFIG_NAME?=ardaku
```

### Build Redox

This takes a while
Back in `cd build/redox`, this takes a while

```shell
make all
Expand Down Expand Up @@ -358,7 +368,7 @@ realname: user
username: user
devicename: redox
hostname: redox
distro: Redox OS 0.8.0
distro: Redox OS 0.9.0
desktop_env: Orbital
platform: Redox
arch: Unknown: x86_64
Expand Down
2 changes: 1 addition & 1 deletion recipe.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[source]
git = "https://github.com/AldaronLau/whome.git"
rev = "0545b887c8419edddc79e5044e5d67f8ec9e0c30"
rev = "ddcadeae154bf2f907b43aed415a3feb209c7486"

[build]
template = "cargo"
24 changes: 12 additions & 12 deletions src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,19 +173,19 @@ pub fn langs() -> Result<impl Iterator<Item = Language>> {
let langs = langs
.split(';')
.map(ToString::to_string)
.collect::<Vec<_>>();
.filter_map(|lang| {
let lang = lang
.split_terminator('.')
.next()
.unwrap_or_default()
.replace(|x| ['_', '-'].contains(&x), "/");

Ok(langs.into_iter().filter_map(|lang| {
let lang = lang
.split_terminator('.')
.next()
.unwrap_or_default()
.replace(|x| ['_', '-'].contains(&x), "/");
if lang == "C" {
return None;
}

if lang == "C" {
return None;
}
Some(Language::__(Box::new(lang)))
});

Some(Language::__(Box::new(lang)))
}))
Ok(langs.collect::<Vec<_>>().into_iter())
}
7 changes: 2 additions & 5 deletions src/os.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
#![allow(unsafe_code)]

// Daku
#[cfg_attr(
all(target_arch = "wasm32", target_os = "daku"),
path = "os/daku.rs"
)]
#[cfg_attr(all(target_arch = "wasm32", daku), path = "os/daku.rs")]
// Redox
#[cfg_attr(
all(target_os = "redox", not(target_arch = "wasm32")),
Expand Down Expand Up @@ -36,7 +33,7 @@
all(
target_arch = "wasm32",
not(target_os = "wasi"),
not(target_os = "daku"),
not(daku),
feature = "web",
),
path = "os/web.rs"
Expand Down
2 changes: 1 addition & 1 deletion src/os/target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl Target for Os {

#[inline(always)]
fn platform(self) -> Platform {
if cfg!(target_os = "daku") {
if cfg!(daku) {
Platform::Unknown("Daku".to_string())
} else if cfg!(target_os = "wasi") {
Platform::Unknown("WASI".to_string())
Expand Down
2 changes: 2 additions & 0 deletions src/os/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ extern "system" {
}

#[cfg(target_os = "macos")]
// FIXME: seemingly false positive for link lint
#[allow(clippy::duplicated_attributes)]
#[link(name = "CoreFoundation", kind = "framework")]
#[link(name = "SystemConfiguration", kind = "framework")]
extern "system" {
Expand Down
8 changes: 5 additions & 3 deletions src/os/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::{
convert::TryInto,
ffi::OsString,
io::{Error, ErrorKind},
mem::MaybeUninit,
mem::{self, MaybeUninit},
os::{
raw::{c_char, c_int, c_uchar, c_ulong, c_ushort, c_void},
windows::ffi::OsStringExt,
Expand Down Expand Up @@ -351,13 +351,15 @@ impl Target for Os {

let get_version: unsafe extern "system" fn(
a: *mut OsVersionInfoEx,
) -> u32 = unsafe { std::mem::transmute(func) };
) -> u32 = unsafe { mem::transmute(func) };

let mut version = MaybeUninit::<OsVersionInfoEx>::zeroed();

// FIXME `mem::size_of` seemingly false positive for lint
#[allow(unused_qualifications)]
let version = unsafe {
(*version.as_mut_ptr()).os_version_info_size =
std::mem::size_of::<OsVersionInfoEx>() as u32;
mem::size_of::<OsVersionInfoEx>() as u32;
get_version(version.as_mut_ptr());

if FreeLibrary(inst) == 0 {
Expand Down

0 comments on commit c1dfdec

Please sign in to comment.