Compare commits
3 commits
5ee324d8c1
...
4206dcc543
Author | SHA1 | Date | |
---|---|---|---|
![]() |
4206dcc543 | ||
![]() |
ee7d6ac857 | ||
![]() |
c4ccc85e6e |
35
.github/workflows/rust.yml
vendored
35
.github/workflows/rust.yml
vendored
|
@ -13,7 +13,6 @@ env:
|
||||||
RUSTFLAGS: "-Dwarnings"
|
RUSTFLAGS: "-Dwarnings"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|
||||||
build-gnu-apt:
|
build-gnu-apt:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
@ -40,6 +39,24 @@ jobs:
|
||||||
- name: build example -- glibc debug
|
- name: build example -- glibc debug
|
||||||
run: cd example && make clean && make TARGET=aarch64-unknown-linux-gnu PROFILE=debug
|
run: cd example && make clean && make TARGET=aarch64-unknown-linux-gnu PROFILE=debug
|
||||||
|
|
||||||
|
# this _should_ have been -stable, but there is a bug when running in the container ("Invalid cross-device link")
|
||||||
|
build-musl-beta:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Update repos
|
||||||
|
run: sudo apt-get update -qq
|
||||||
|
- name: Install toolchain
|
||||||
|
run: sudo apt-get install -qy liblzma-dev gcc make pkgconf musl-dev musl-tools rustup
|
||||||
|
- name: install rust target
|
||||||
|
run: rustup default beta && rustup target add aarch64-unknown-linux-musl && rustup component add rust-src && rustup update
|
||||||
|
|
||||||
|
- name: build example -- musl release
|
||||||
|
run: cd example && make clean && make TARGET=aarch64-unknown-linux-musl PROFILE=release MUSL=1 CARGO="rustup run beta cargo"
|
||||||
|
- name: build example -- musl debug
|
||||||
|
run: cd example && make clean && make TARGET=aarch64-unknown-linux-musl PROFILE=debug MUSL=1 CARGO="rustup run beta cargo"
|
||||||
|
|
||||||
build-size-gnu-unstable:
|
build-size-gnu-unstable:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
@ -54,3 +71,19 @@ jobs:
|
||||||
|
|
||||||
- name: build example -- glibc size-optimized
|
- name: build example -- glibc size-optimized
|
||||||
run: cd example && make clean && make TARGET=aarch64-unknown-linux-gnu PROFILE=size-optimized CARGO="rustup run nightly cargo"
|
run: cd example && make clean && make TARGET=aarch64-unknown-linux-gnu PROFILE=size-optimized CARGO="rustup run nightly cargo"
|
||||||
|
|
||||||
|
|
||||||
|
build-size-musl-unstable:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Update repos
|
||||||
|
run: sudo apt-get update -qq
|
||||||
|
- name: Install toolchain
|
||||||
|
run: sudo apt-get install -qy liblzma-dev gcc make pkgconf musl-dev musl-tools rustup
|
||||||
|
- name: install rust targets
|
||||||
|
run: rustup toolchain install nightly -t aarch64-unknown-linux-musl -c rust-src --no-self-update
|
||||||
|
|
||||||
|
- name: build example -- musl size-optimized
|
||||||
|
run: cd example && make clean && make TARGET=aarch64-unknown-linux-musl PROFILE=size-optimized MUSL=1 LTO=1 CARGO="rustup run nightly cargo"
|
||||||
|
|
|
@ -31,6 +31,7 @@ endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
RUST_TARGET_DIR := $(REPO_ROOT)/target/$(TARGET)/$(CFG_PROFILE)
|
RUST_TARGET_DIR := $(REPO_ROOT)/target/$(TARGET)/$(CFG_PROFILE)
|
||||||
|
OUT_DIR := $(realpath $(THIS_DIR)/out/)
|
||||||
|
|
||||||
ifeq ($(CFG_PROFILE), size-optimized)
|
ifeq ($(CFG_PROFILE), size-optimized)
|
||||||
CARGO_PROFILE := size-optimized
|
CARGO_PROFILE := size-optimized
|
||||||
|
@ -91,7 +92,7 @@ all: $(_bins)
|
||||||
clean: clean-c clean-rust
|
clean: clean-c clean-rust
|
||||||
|
|
||||||
clean-c:
|
clean-c:
|
||||||
rm -r out || true
|
rm -r $(OUT_DIR) || true
|
||||||
|
|
||||||
clean-rust:
|
clean-rust:
|
||||||
rm $(SERVICEPOINT_HEADER_OUT)/servicepoint.h || true
|
rm $(SERVICEPOINT_HEADER_OUT)/servicepoint.h || true
|
||||||
|
@ -122,7 +123,7 @@ sizes: $(_bins)
|
||||||
ls -lB out
|
ls -lB out
|
||||||
|
|
||||||
analyze-size: out/$(BIN)_unstripped
|
analyze-size: out/$(BIN)_unstripped
|
||||||
nm --print-size --size-sort --reverse-sort --radix=d --demangle out/$(BIN)_unstripped \
|
nm --print-size --size-sort --reverse-sort --radix=d --demangle $(OUT_DIR)/$(BIN)_unstripped \
|
||||||
| awk '{size=$$2+0; print size "\t" $$4}' \
|
| awk '{size=$$2+0; print size "\t" $$4}' \
|
||||||
| less
|
| less
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
use crate::{heap_drop, heap_move, heap_move_nonnull, heap_remove, ByteSlice};
|
use crate::{heap_drop, heap_move, heap_move_nonnull, heap_remove, ByteSlice};
|
||||||
use servicepoint::{
|
use servicepoint::{BinaryOperation, BitVecCommand, CompressionCode, DisplayBitVec, Packet};
|
||||||
BinaryOperation, BitVecCommand, CompressionCode, DisplayBitVec, Packet,
|
|
||||||
};
|
|
||||||
use std::ptr::NonNull;
|
use std::ptr::NonNull;
|
||||||
|
|
||||||
/// A vector of bits
|
/// A vector of bits
|
||||||
|
|
|
@ -32,10 +32,10 @@ pub use crate::byte_slice::*;
|
||||||
pub use crate::char_grid::*;
|
pub use crate::char_grid::*;
|
||||||
pub use crate::cp437_grid::*;
|
pub use crate::cp437_grid::*;
|
||||||
pub use crate::packet::*;
|
pub use crate::packet::*;
|
||||||
pub use crate::typed_command::*;
|
|
||||||
pub use crate::udp::*;
|
|
||||||
pub use servicepoint::CommandCode;
|
pub use servicepoint::CommandCode;
|
||||||
use std::ptr::NonNull;
|
use std::ptr::NonNull;
|
||||||
|
pub use crate::typed_command::*;
|
||||||
|
pub use crate::udp::*;
|
||||||
|
|
||||||
mod bitmap;
|
mod bitmap;
|
||||||
mod bitvec;
|
mod bitvec;
|
||||||
|
@ -69,4 +69,4 @@ pub(crate) unsafe fn heap_remove<T>(x: NonNull<T>) -> T {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This is a type only used by cbindgen to have a type for pointers.
|
/// This is a type only used by cbindgen to have a type for pointers.
|
||||||
pub struct UdpSocket;
|
pub struct UdpSocket;
|
|
@ -16,7 +16,9 @@ use std::ptr::NonNull;
|
||||||
/// sp_udp_send_command(connection, sp_command_clear());
|
/// sp_udp_send_command(connection, sp_command_clear());
|
||||||
/// ```
|
/// ```
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn sp_udp_open(host: NonNull<c_char>) -> *mut UdpSocket {
|
pub unsafe extern "C" fn sp_udp_open(
|
||||||
|
host: NonNull<c_char>,
|
||||||
|
) -> *mut UdpSocket {
|
||||||
let host = unsafe { CStr::from_ptr(host.as_ptr()) }
|
let host = unsafe { CStr::from_ptr(host.as_ptr()) }
|
||||||
.to_str()
|
.to_str()
|
||||||
.expect("Bad encoding");
|
.expect("Bad encoding");
|
||||||
|
@ -107,9 +109,7 @@ pub unsafe extern "C" fn sp_udp_send_header(
|
||||||
header,
|
header,
|
||||||
payload: vec![],
|
payload: vec![],
|
||||||
};
|
};
|
||||||
unsafe { udp_connection.as_ref() }
|
unsafe { udp_connection.as_ref() }.send(&Vec::from(packet)).is_ok()
|
||||||
.send(&Vec::from(packet))
|
|
||||||
.is_ok()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Closes and deallocates a [UdpConnection].
|
/// Closes and deallocates a [UdpConnection].
|
||||||
|
|
Loading…
Reference in a new issue