Add GN Build Files and Custom Modifications

Issue:https://gitee.com/openharmony/build/issues/I6UFTP
Signed-off-by: lubinglun <lubinglun@huawei.com>
This commit is contained in:
lubinglun
2023-04-12 17:26:52 +08:00
parent 559fc6a73d
commit e6cec0912e
3 changed files with 35 additions and 7 deletions
+28
View File
@@ -0,0 +1,28 @@
# Copyright (c) 2023 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//build/ohos.gni")
ohos_cargo_crate("lib") {
crate_name = "cexpr"
crate_type = "rlib"
crate_root = "src/lib.rs"
sources = ["src/lib.rs"]
edition = "2018"
cargo_pkg_version = "0.5.0"
cargo_pkg_authors = "Jethro Beekman <jethro@jbeekman.nl>"
cargo_pkg_name = "cexpr"
cargo_pkg_description = "A C expression parser and evaluator"
deps = ["//third_party/rust/crates/nom:lib"]
}
+6 -6
View File
@@ -308,7 +308,7 @@ impl<'a> PRef<'a> {
pair(complete(one_of_punctuation(&["*", "/", "%"][..])), |i| {
self.unary(i)
}),
acc,
move || acc.clone(),
|mut acc, (op, val): (&[u8], EvalResult)| {
match op[0] as char {
'*' => acc *= &val,
@@ -327,7 +327,7 @@ impl<'a> PRef<'a> {
pair(complete(one_of_punctuation(&["+", "-"][..])), |i| {
self.mul_div_rem(i)
}),
acc,
move || acc.clone(),
|mut acc, (op, val): (&[u8], EvalResult)| {
match op[0] as char {
'+' => acc += &val,
@@ -345,7 +345,7 @@ impl<'a> PRef<'a> {
pair(complete(one_of_punctuation(&["<<", ">>"][..])), |i| {
self.add_sub(i)
}),
acc,
move || acc.clone(),
|mut acc, (op, val): (&[u8], EvalResult)| {
match op {
b"<<" => acc <<= &val,
@@ -361,7 +361,7 @@ impl<'a> PRef<'a> {
let (input, acc) = self.shl_shr(input)?;
numeric(fold_many0(
preceded(complete(p("&")), |i| self.shl_shr(i)),
acc,
move || acc.clone(),
|mut acc, val: EvalResult| {
acc &= &val;
acc
@@ -373,7 +373,7 @@ impl<'a> PRef<'a> {
let (input, acc) = self.and(input)?;
numeric(fold_many0(
preceded(complete(p("^")), |i| self.and(i)),
acc,
move || acc.clone(),
|mut acc, val: EvalResult| {
acc ^= &val;
acc
@@ -385,7 +385,7 @@ impl<'a> PRef<'a> {
let (input, acc) = self.xor(input)?;
numeric(fold_many0(
preceded(complete(p("|")), |i| self.xor(i)),
acc,
move || acc.clone(),
|mut acc, val: EvalResult| {
acc |= &val;
acc
+1 -1
View File
@@ -224,7 +224,7 @@ fn c_string(i: &[u8]) -> nom::IResult<&[u8], Vec<u8>> {
map(escaped_char, |c: CChar| c.into()),
map(is_not([b'\\', b'"']), |c: &[u8]| c.into()),
)),
Vec::new(),
Vec::new,
|mut v: Vec<u8>, res: Vec<u8>| {
v.extend_from_slice(&res);
v