[WIP] Add syntax check for rust and C\C++ code (#108)

* proof of concept

* fix syntax for rust and add auto fix syntax

* fix syntax for C

* fix bug with files owner

* add information to wiki

* try to add ci

* format code from master

* even more format fixes

* change docker to docker-compose

* Exclude ./target_*/build directories from format check

* Run rustfmt only on project files

* add ulimit setup for long clang list

* merge

* fix rustfmt, exclude target Inc directory

* sync with master

* abspath

Co-authored-by: aanper <mail@s3f.ru>
Co-authored-by: Vadim Kaushan <admin@disasm.info>
This commit is contained in:
Nikita Beletskii
2020-09-30 02:18:30 +03:00
committed by GitHub
parent 7ded31c19d
commit 110a9efc3c
73 changed files with 4354 additions and 4667 deletions

View File

@@ -8,6 +8,8 @@ fn main() {
cbindgen::generate(&crate_dir)
.expect("Unable to generate cbindgen bindings")
.write_to_file(
Path::new(&crate_dir).join("bindings").join(format!("{}.h", pkg_name))
Path::new(&crate_dir)
.join("bindings")
.join(format!("{}.h", pkg_name)),
);
}
}

View File

@@ -1,14 +1,13 @@
#![no_std]
#[cfg(target_arch = "arm")]
use flipper_f1_sys::hal::{HAL_UART_Transmit_IT, huart1};
use flipper_f1_sys::hal::{huart1, HAL_UART_Transmit_IT};
#[no_mangle]
pub extern "C" fn add(a: u32, b: u32) -> u32 {
a + b
}
#[no_mangle]
pub extern "C" fn rust_uart_write() {
let string = "Rust test string\n";
@@ -28,12 +27,13 @@ pub extern "C" fn rust_uart_write() {
}
}
mod aux {
use core::panic::PanicInfo;
#[panic_handler]
fn panic(_info: &PanicInfo) -> ! {
loop { continue }
loop {
continue;
}
}
}

View File

@@ -54,7 +54,7 @@ impl BindingsGenerator {
"Middlewares/ST/STM32_USB_Device_Library/Core/Inc",
"Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc",
];
let stm32_sdk_includes = stm32_sdk_includes
.iter()
.map(|stm32_include| format!("{}/{}", self.clib_dir.to_string_lossy(), stm32_include));
@@ -64,28 +64,23 @@ impl BindingsGenerator {
let includes = [
// This are bindings generated by cbindgen nearby
&flipper_core_bindings.to_string_lossy(),
&self.gcc_include_dir.to_string_lossy(),
];
#[rustfmt::skip]
return bindgen::Builder::default()
.use_core()
.ctypes_prefix("self")
.blacklist_type("__uint8_t")
.blacklist_type("__uint32_t")
.blacklist_type("c_int")
.blacklist_type("__int32_t")
// TODO there's no .no_debug method, to disable only for specific type
.derive_debug(false)
.clang_arg("-DUSE_HAL_DRIVER")
.clang_arg("-DSTM32L476xx")
.clang_arg("-DBUTON_INVERT=false")
.clang_arg("-DDEBUG_UART=huart1")
.clang_args(
(includes.iter().map(|x| From::from(x as &str)).chain(stm32_sdk_includes))
.map(|include| format!("-I{}", include))
@@ -268,7 +263,7 @@ impl BindingsGenerator {
bindings
.write_to_file(result_path)
.expect("Couldn't write bindings!");
}
}
}
fn detect_gcc_inclide_dir() -> PathBuf {

View File

@@ -1,5 +1,4 @@
#![no_std]
#![allow(dead_code)]
#![allow(non_camel_case_types)]
#![allow(non_upper_case_globals)]
@@ -17,4 +16,4 @@ pub mod cmsis_os {
pub mod hal {
include!(concat!(env!("OUT_DIR"), "/stm32_hal_bindings.rs"));
include!(concat!(env!("OUT_DIR"), "/stm32_hal_statics.rs"));
}
}