diff --git a/.github/workflows/Check.yml b/.github/workflows/Check.yml index b432d3d..745fc80 100644 --- a/.github/workflows/Check.yml +++ b/.github/workflows/Check.yml @@ -21,8 +21,8 @@ jobs: matrix: target: - linux - - esp32 - - esp32s3 +# - esp32 +# - esp32s3 steps: - name: Setup | Checkout repository @@ -48,7 +48,7 @@ jobs: ldproxy: true - name: Setup | Install necessary dependencies - run: sudo apt-get install -y libsdl2-dev gcc-multilib + run: sudo apt-get install -y gcc-multilib - name: Setup | Build and source build tool run: source Export.sh @@ -60,4 +60,4 @@ jobs: run: Build_tool/target/release/Build_tool clippy ${{ matrix.target }} --all-features --workspace -- -D warnings - name: Run | Tests - run: Build_tool/target/release/Build_tool test ${{ matrix.target }} --all -- --include-ignored + run: Build_tool/target/release/Build_tool test ${{ matrix.target }} --all diff --git a/Cargo.toml b/Cargo.toml index 6f3854f..be42c69 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,40 +1,10 @@ -[workspace] -members = [ - "Modules/File_system", - "Modules/Virtual_machine", - "Modules/Graphics", - "Modules/Task", - "Modules/Users", - "Modules/Drivers", - "Modules/Peripherals", - "Modules/Memory", - "Modules/Time", - "Modules/ABI", - "Modules/Virtual_file_system", - "Modules/LittleFS", - "Modules/Target", - "Modules/Bindings/Utilities", - "Modules/Bindings/Host", - "Modules/Bindings/WASM", - "Modules/Executables/Shell/Command_line", - "Modules/Executable", - "Modules/Executables/WASM", - "Modules/Executables/Shell/Graphical", - "Modules/Executables/Terminal", -] -exclude = [ - "Modules/Virtual_machine/Tests/WASM_test", - "Modules/Bindings/Tests/WASM_test", -] - [package] name = "Xila" version = "0.1.0" authors = ["Alix ANNERAUD "] edition = "2021" resolver = "2" -rust-version = "1.71" - +rust-version = "1.82.0" [dependencies] # - WASM @@ -84,3 +54,33 @@ WASM = ["dep:WASM_bindings"] name = "Native" path = "Examples/Native.rs" required-features = ["Host"] + +[workspace] +members = [ + "Modules/File_system", + "Modules/Virtual_machine", + "Modules/Graphics", + "Modules/Task", + "Modules/Users", + "Modules/Drivers", + "Modules/Peripherals", + "Modules/Memory", + "Modules/Time", + "Modules/ABI", + "Modules/Virtual_file_system", + "Modules/LittleFS", + "Modules/Target", + "Modules/Bindings/Utilities", + "Modules/Bindings/Host", + "Modules/Bindings/WASM", + "Modules/Executables/Shell/Command_line", + "Modules/Executable", + "Modules/Executables/WASM", + "Modules/Executables/Shell/Graphical", + "Modules/Executables/Terminal", +] +exclude = [ + "Modules/Virtual_machine/Tests/WASM_test", + "Modules/Bindings/Tests/WASM_test", + "Build_tool", +] diff --git a/Modules/Bindings/Host/Tests/WASM_test/src/main.rs b/Modules/Bindings/Host/Tests/WASM_test/src/main.rs index eae1314..a4b4856 100644 --- a/Modules/Bindings/Host/Tests/WASM_test/src/main.rs +++ b/Modules/Bindings/Host/Tests/WASM_test/src/main.rs @@ -1,5 +1,6 @@ #![allow(non_snake_case)] #![allow(non_camel_case_types)] +#![allow(non_upper_case_globals)] use WASM_bindings::*; @@ -11,7 +12,6 @@ fn main() { let mut Window = Xila_graphics_object_t::MAX; let mut Button = Xila_graphics_object_t::MAX; let mut Label = Xila_graphics_object_t::MAX; - let mut Deleted_label = Xila_graphics_object_t::MAX; unsafe { println!("Window : {:x}", Window); @@ -25,7 +25,7 @@ fn main() { println!("Button : {:x}", Button); Xila_graphics_label_create(Button, &mut Label as *mut _); - Xila_graphics_label_set_text(Label, "Hello, world!\0".as_ptr() as *mut _); + Xila_graphics_label_set_text(Label, c"Hello, world!".as_ptr() as *mut _); println!("Label : {:x}", Label); @@ -46,11 +46,13 @@ fn main() { if Target == Button { Xila_graphics_label_set_text( Label, - "Button pressed!\0".as_ptr() as *mut _, + c"Button pressed!".as_ptr() as *mut _, ); } } - _ => {} + Event => { + println!("Event : {}", Event); + } } Xila_graphics_window_next_event(Window); diff --git a/Modules/LittleFS/src/File.rs b/Modules/LittleFS/src/File.rs index da61428..6158f6b 100644 --- a/Modules/LittleFS/src/File.rs +++ b/Modules/LittleFS/src/File.rs @@ -234,24 +234,6 @@ impl File_type { Ok(Metadata) } - pub fn Get_metadata_mutable(&mut self) -> Result_type<&mut Metadata_type> { - let Configuration = unsafe { self.0.File.cfg.read() }; - - if Configuration.attr_count == 0 { - return Err(Error_type::No_attribute); - } - - let Attributes = unsafe { Configuration.attrs.read() }; - - if Attributes.size != size_of::() as u32 { - return Err(Error_type::No_attribute); - } - - let Metadata = unsafe { &mut *(Attributes.buffer as *mut Metadata_type) }; - - Ok(Metadata) - } - pub fn Get_mode(&self) -> Mode_type { self.0.Flags.Get_mode() } diff --git a/Modules/LittleFS/src/File_system.rs b/Modules/LittleFS/src/File_system.rs index 0dcd382..663ecbc 100644 --- a/Modules/LittleFS/src/File_system.rs +++ b/Modules/LittleFS/src/File_system.rs @@ -2,9 +2,10 @@ use core::mem::MaybeUninit; use std::{collections::BTreeMap, ffi::CString, sync::RwLock}; use File_system::{ - Device_type, Entry_type, File_identifier_type, File_system_identifier_type, File_system_traits, - Flags_type, Get_new_file_identifier, Inode_type, Local_file_identifier_type, Metadata_type, - Mode_type, Path_type, Position_type, Size_type, Statistics_type, Time_type, Type_type, + Device_type, Entry_type, File_identifier_inner_type, File_identifier_type, + File_system_identifier_type, File_system_traits, Flags_type, Get_new_file_identifier, + Inode_type, Local_file_identifier_type, Metadata_type, Mode_type, Path_type, Position_type, + Size_type, Statistics_type, Time_type, Type_type, }; use Users::{Group_identifier_type, User_identifier_type}; @@ -158,9 +159,9 @@ impl File_system_type { } #[cfg(target_pointer_width = "64")] - const Directory_flag: u32 = 1 << 31; + const Directory_flag: File_identifier_inner_type = 1 << 31; #[cfg(target_pointer_width = "32")] - const Directory_flag: u32 = 1 << 15; + const Directory_flag: File_identifier_inner_type = 1 << 15; const Directory_minimum: File_identifier_type = File_identifier_type::New(Self::Directory_flag); diff --git a/Modules/Virtual_machine/Tests/WASM_test/src/main.rs b/Modules/Virtual_machine/Tests/WASM_test/src/main.rs index 9d58caf..0a653f3 100644 --- a/Modules/Virtual_machine/Tests/WASM_test/src/main.rs +++ b/Modules/Virtual_machine/Tests/WASM_test/src/main.rs @@ -97,6 +97,11 @@ fn Test_directory() { } } +/// Allocate memory +/// +/// # Safety +/// +/// This function is unsafe because it may return an invalid pointer. #[no_mangle] pub unsafe extern "C" fn Allocate(Size: usize) -> *mut u8 { let Layout = std::alloc::Layout::from_size_align(Size, std::mem::size_of::()).unwrap(); @@ -104,6 +109,11 @@ pub unsafe extern "C" fn Allocate(Size: usize) -> *mut u8 { std::alloc::alloc(Layout) } +/// Deallocate memory +/// +/// # Safety +/// +/// This function is unsafe because it may cause undefined behavior if the pointer is invalid. #[no_mangle] pub unsafe extern "C" fn Deallocate(Pointer: *mut u8, Size: usize) { let Layout = std::alloc::Layout::from_size_align(Size, std::mem::size_of::()).unwrap(); diff --git a/Modules/Virtual_machine/WAMR/include/platform_internal.h b/Modules/Virtual_machine/WAMR/include/platform_internal.h index d520e62..04525e3 100644 --- a/Modules/Virtual_machine/WAMR/include/platform_internal.h +++ b/Modules/Virtual_machine/WAMR/include/platform_internal.h @@ -124,6 +124,8 @@ extern "C" uint64_t os_get_invalid_handle(); + int os_getpagesize(); + #ifdef __cplusplus } #endif /* end of extern "C" */ diff --git a/src/lib.rs b/src/lib.rs index 6ad054c..c423455 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,5 +2,5 @@ #![allow(non_camel_case_types)] #![allow(non_upper_case_globals)] -#[cfg(feature = "WASM")] -use WASM_bindings::*; +#[cfg(all(target_arch = "wasm32", feature = "WASM"))] +pub use WASM_bindings::*;