mirror of
https://github.com/trussed-dev/littlefs2-sys.git
synced 2026-06-20 04:16:31 -07:00
Expose v2.1.4
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
/target
|
||||
**/*.rs.bk
|
||||
Cargo.lock
|
||||
@@ -0,0 +1,3 @@
|
||||
[submodule "littlefs"]
|
||||
path = littlefs
|
||||
url = https://github.com/ARMmbed/littlefs
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
[package]
|
||||
name = "littlefs2-sys"
|
||||
description = "Low-level bindings to LittleFS"
|
||||
version = "0.1.0"
|
||||
authors = ["Nicolas Stalder <n@stalder.io>"]
|
||||
edition = "2018"
|
||||
license = "BSD-3-Clause"
|
||||
readme = "README.md"
|
||||
categories = ["embedded", "filesystem", "no-std"]
|
||||
repository = "https://github.com/nickray/littlefs2-sys"
|
||||
|
||||
[dependencies]
|
||||
cty = "0.2.1"
|
||||
|
||||
[build-dependencies]
|
||||
bindgen = "0.52.0"
|
||||
cc = "1.0.25"
|
||||
@@ -0,0 +1,24 @@
|
||||
Copyright (c) 2017, Arm Limited. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
- Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or
|
||||
other materials provided with the distribution.
|
||||
- Neither the name of ARM nor the names of its contributors may be used to
|
||||
endorse or promote products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
@@ -0,0 +1,40 @@
|
||||
<h1 align="center">littlefs2-sys</h1>
|
||||
<div align="center">
|
||||
<strong>
|
||||
Low-level bindings to LittleFS
|
||||
</strong>
|
||||
</div>
|
||||
|
||||
<br />
|
||||
|
||||
<div align="center">
|
||||
<!-- Crates version -->
|
||||
<a href="https://crates.io/crates/littlefs2-sys">
|
||||
<img src="https://img.shields.io/crates/v/littlefs2-sys.svg?style=flat-square"
|
||||
alt="Crates.io version" />
|
||||
</a>
|
||||
<!-- Downloads -->
|
||||
<a href="https://crates.io/crates/littlefs2-sys">
|
||||
<img src="https://img.shields.io/crates/d/littlefs2-sys.svg?style=flat-square"
|
||||
alt="Download" />
|
||||
</a>
|
||||
<!-- API docs -->
|
||||
<a href="https://docs.rs/littlefs2-sys">
|
||||
<img src="https://img.shields.io/badge/docs-latest-blue.svg?style=flat-square"
|
||||
alt="main branch API docs" />
|
||||
</a>
|
||||
</div>
|
||||
|
||||
## What is this?
|
||||
|
||||
Low-level bindings to the [littlefs](littlefs) microcontroller filesystem.
|
||||
|
||||
[littlefs]: https://github.com/ARMmbed/littlefs
|
||||
|
||||
Currently, release v2.1.4 is exposed.
|
||||
|
||||
#### License
|
||||
|
||||
<sup>LittleFS licensed under [BSD-3-Clause](LICENSE-BSD3), as are these bindings.</sup>
|
||||
<br>
|
||||
<sub>The file `strings.c` is licensed under GPL-2.0</sub>
|
||||
@@ -0,0 +1,28 @@
|
||||
use std::env;
|
||||
use std::path::PathBuf;
|
||||
|
||||
fn main() {
|
||||
cc::Build::new()
|
||||
.flag("-std=c11")
|
||||
.flag("-DLFS_NO_MALLOC")
|
||||
.flag("-DLFS_NO_ASSERT")
|
||||
.flag("-DLFS_NO_DEBUG")
|
||||
.flag("-DLFS_NO_WARN")
|
||||
.flag("-DLFS_NO_ERROR")
|
||||
.file("littlefs/lfs.c")
|
||||
.file("littlefs/lfs_util.c")
|
||||
.file("string.c")
|
||||
.compile("lfs-sys");
|
||||
|
||||
let bindings = bindgen::Builder::default()
|
||||
.header("littlefs/lfs.h")
|
||||
.use_core()
|
||||
.ctypes_prefix("cty")
|
||||
.generate()
|
||||
.expect("Unable to generate bindings");
|
||||
|
||||
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
|
||||
bindings
|
||||
.write_to_file(out_path.join("bindings.rs"))
|
||||
.expect("Couldn't write bindings!");
|
||||
}
|
||||
Submodule
+1
Submodule littlefs added at ce2c01f098
@@ -0,0 +1,5 @@
|
||||
#![no_std]
|
||||
#![allow(non_upper_case_globals)]
|
||||
#![allow(non_camel_case_types)]
|
||||
|
||||
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
|
||||
@@ -0,0 +1,59 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
/*
|
||||
* linux/lib/string.c
|
||||
*
|
||||
* Copyright (C) 1991, 1992 Linus Torvalds
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
size_t strspn(const char *s, const char *accept)
|
||||
{
|
||||
const char *p;
|
||||
const char *a;
|
||||
size_t count = 0;
|
||||
|
||||
for (p = s; *p != '\0'; ++p) {
|
||||
for (a = accept; *a != '\0'; ++a) {
|
||||
if (*p == *a)
|
||||
break;
|
||||
}
|
||||
if (*a == '\0')
|
||||
return count;
|
||||
++count;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
size_t strcspn(const char *s, const char *reject)
|
||||
{
|
||||
const char *p;
|
||||
const char *r;
|
||||
size_t count = 0;
|
||||
|
||||
for (p = s; *p != '\0'; ++p) {
|
||||
for (r = reject; *r != '\0'; ++r) {
|
||||
if (*p == *r)
|
||||
return count;
|
||||
}
|
||||
++count;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
size_t strlen(const char *s)
|
||||
{
|
||||
const char *sc;
|
||||
|
||||
for (sc = s; *sc != '\0'; ++sc)
|
||||
/* nothing */;
|
||||
return sc - s;
|
||||
}
|
||||
|
||||
char *strchr(const char *s, int c)
|
||||
{
|
||||
for (; *s != (char)c; ++s)
|
||||
if (*s == '\0')
|
||||
return NULL;
|
||||
return (char *)s;
|
||||
}
|
||||
Reference in New Issue
Block a user