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

Remove libstd from objc-sys and block-sys #305

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ jobs:
CXXFLAGS: ${{ matrix.cflags }}
ASMFLAGS: ${{ matrix.cflags }}
LDFLAGS: ${{ matrix.cflags }}
NDF_ARGS: --no-default-features --features=${{ matrix.runtime || 'apple' }} ${{ matrix.args }}
ARGS: --no-default-features --features=std,${{ matrix.runtime || 'apple' }} ${{ matrix.args }}
# Use --no-fail-fast, except with dinghy
TESTARGS: ${{ matrix.dinghy && ' ' || '--no-fail-fast' }} ${{ matrix.test-args }}
Expand Down Expand Up @@ -369,6 +370,11 @@ jobs:
- name: Build
run: $CMD build ${{ env.ARGS }}

- name: Build objc-sys/block-sys with no_std
run: |
$CMD build ${{ env.NDF_ARGS }} -p objc-sys
$CMD build ${{ env.NDF_ARGS }} -p block-sys

- name: Check documentation
run: $CMD doc ${{ env.ARGS }} --no-deps --document-private-items

Expand Down
9 changes: 3 additions & 6 deletions crates/block-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@
#![cfg_attr(feature = "unstable-docsrs", feature(doc_auto_cfg, doc_cfg_hide))]
#![cfg_attr(feature = "unstable-docsrs", doc(cfg_hide(doc)))]

#[cfg(feature = "std")]
extern crate std;

#[cfg(not(feature = "std"))]
compile_error!("The `std` feature currently must be enabled.");

Comment on lines +27 to -31
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do roughly the same setup as I did in this PR to the url project (for both alloc and std, since neither are required).

// Ensure linkage actually happens
#[cfg(feature = "gnustep-1-7")]
extern crate objc_sys as _;
Expand All @@ -38,9 +36,8 @@ extern crate objc_sys as _;
extern "C" {}

use core::cell::UnsafeCell;
use core::ffi::c_void;
use core::ffi::{c_char, c_ulong, c_void};
use core::marker::{PhantomData, PhantomPinned};
use std::os::raw::{c_char, c_ulong};

#[repr(C)]
pub struct Class {
Expand Down Expand Up @@ -415,7 +412,7 @@ pub struct Block_byref_extended {
pub layout: *const c_char,
}

#[cfg(test)]
#[cfg(all(test, feature = "std"))]
mod tests {
use super::*;
use core::ptr;
Expand Down
1 change: 0 additions & 1 deletion crates/objc-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ build = "build.rs"
# correct feature flag is not specified.
default = ["std", "apple"]

# Currently not possible to turn off, put here for forwards compatibility.
std = ["alloc"]
alloc = []

Expand Down
2 changes: 1 addition & 1 deletion crates/objc-sys/src/class.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::os::raw::{c_char, c_int, c_uint};
use core::ffi::{c_char, c_int, c_uint};

#[cfg(any(doc, not(objfw)))]
use crate::{objc_ivar, objc_method, objc_object, objc_property, objc_property_attribute_t};
Expand Down
2 changes: 1 addition & 1 deletion crates/objc-sys/src/constants.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Various common #defines and enum constants.

#[cfg(any(doc, apple))]
use std::os::raw::c_int;
use core::ffi::c_int;

use crate::{id, objc_class, BOOL};

Expand Down
6 changes: 3 additions & 3 deletions crates/objc-sys/src/exception.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
//! Apple: `objc-exception.h`
//! GNUStep: `eh_personality.c`, which is a bit brittle to rely on, but I
//! think it's fine...
use core::ffi::c_void;
#[cfg(any(doc, apple_new))]
use std::os::raw::c_int;
use core::ffi::c_int;
#[cfg(feature = "unstable-exception")]
use std::os::raw::c_uchar;
use core::ffi::c_uchar;
use core::ffi::c_void;

#[cfg(any(doc, apple_new))]
use crate::objc_class;
Expand Down
7 changes: 1 addition & 6 deletions crates/objc-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,9 @@
#![cfg_attr(feature = "unstable-docsrs", feature(doc_auto_cfg, doc_cfg_hide))]
#![cfg_attr(feature = "unstable-docsrs", doc(cfg_hide(doc)))]

// TODO: Remove this and add "no-std" category to Cargo.toml
// Requires a better solution for C-types in `no_std` crates.
// See https://github.com/japaric/cty/issues/14.
#[cfg(feature = "std")]
extern crate std;

#[cfg(not(feature = "std"))]
compile_error!("The `std` feature currently must be enabled.");

#[cfg(doctest)]
#[doc = include_str!("../README.md")]
extern "C" {}
Expand Down
4 changes: 2 additions & 2 deletions crates/objc-sys/src/method.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::os::raw::c_char;
use core::ffi::c_char;
#[cfg(any(doc, not(objfw)))]
use std::os::raw::c_uint;
use core::ffi::c_uint;

#[cfg(any(doc, not(objfw)))]
use crate::IMP;
Expand Down
2 changes: 1 addition & 1 deletion crates/objc-sys/src/object.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use core::ffi::c_char;
#[cfg(any(doc, not(objfw)))]
use core::ffi::c_void;
use std::os::raw::c_char;

#[cfg(any(doc, not(objfw)))]
use crate::objc_ivar;
Expand Down
4 changes: 2 additions & 2 deletions crates/objc-sys/src/property.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::os::raw::c_char;
use core::ffi::c_char;
#[cfg(any(doc, not(objfw)))]
use std::os::raw::c_uint;
use core::ffi::c_uint;

use crate::OpaqueData;

Expand Down
4 changes: 2 additions & 2 deletions crates/objc-sys/src/protocol.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::os::raw::c_char;
use core::ffi::c_char;
#[cfg(any(doc, not(objfw)))]
use std::os::raw::c_uint;
use core::ffi::c_uint;

#[cfg(any(doc, not(objfw)))]
use crate::{objc_method_description, objc_property, objc_property_attribute_t, objc_selector};
Expand Down
2 changes: 1 addition & 1 deletion crates/objc-sys/src/selector.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::os::raw::c_char;
use core::ffi::c_char;

use crate::{OpaqueData, BOOL};

Expand Down
2 changes: 1 addition & 1 deletion crates/objc-sys/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ mod inner {
mod inner {
// windows && !32bit-MinGW
#[cfg(all(windows, not(all(target_pointer_width = "64", target_env = "gnu"))))]
pub(crate) type BOOL = std::os::raw::c_int;
pub(crate) type BOOL = core::ffi::c_int;

// The inverse
#[cfg(not(all(windows, not(all(target_pointer_width = "64", target_env = "gnu")))))]
Expand Down
8 changes: 4 additions & 4 deletions crates/objc-sys/src/various.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use core::ffi::c_void;
#[cfg(any(doc, not(objfw)))]
use std::os::raw::c_char;
use std::os::raw::c_int;
use core::ffi::c_char;
use core::ffi::c_int;
#[cfg(any(doc, apple))]
use std::os::raw::c_uint;
use core::ffi::c_uint;
use core::ffi::c_void;

#[cfg(any(doc, not(objfw)))]
use crate::{objc_AssociationPolicy, BOOL};
Expand Down