mfgtool ah 可以使用ninja编译

This commit is contained in:
2025-01-13 18:38:58 +08:00
parent b29b776229
commit 9e297aa436
9 changed files with 203 additions and 1 deletions

1
.gitignore vendored
View File

@@ -43,3 +43,4 @@ mfgtool/ah/ah
mfgtool/lzma/elzma
mfgtool/oem_tool/oem_tool
mfgtool/*.o
out/

10
.gn Normal file
View File

@@ -0,0 +1,10 @@
buildconfig = "//build/BUILDCONFIG.gn"
root = "//mfgtool"
script_executable = "/usr/bin/env"

21
build/BUILD.gn Normal file
View File

@@ -0,0 +1,21 @@
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
config("compiler_defaults") {
if (current_os == "linux") {
cflags = [
"-fPIC",
"-pthread",
]
}
}
config("executable_ldconfig") {
if (!is_mac) {
ldflags = [
"-Wl,-rpath=\$ORIGIN/",
"-Wl,-rpath-link=",
]
}
}

41
build/BUILDCONFIG.gn Executable file
View File

@@ -0,0 +1,41 @@
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
if (target_os == "") {
target_os = host_os
}
if (target_cpu == "") {
target_cpu = host_cpu
}
if (current_cpu == "") {
current_cpu = target_cpu
}
if (current_os == "") {
current_os = target_os
}
is_linux = host_os == "linux" && current_os == "linux" && target_os == "linux"
is_mac = host_os == "mac" && current_os == "mac" && target_os == "mac"
# All binary targets will get this list of configs by default.
_shared_binary_target_configs = [ "//build:compiler_defaults" ]
# Apply that default list to the binary target types.
set_defaults("executable") {
configs = _shared_binary_target_configs
# Executables get this additional configuration.
configs += [ "//build:executable_ldconfig" ]
}
set_defaults("static_library") {
configs = _shared_binary_target_configs
}
set_defaults("shared_library") {
configs = _shared_binary_target_configs
}
set_defaults("source_set") {
configs = _shared_binary_target_configs
}
set_default_toolchain("//build/toolchain:gcc")

17
build/config.gn Normal file
View File

@@ -0,0 +1,17 @@
if (target_cpu == ""){
target_cpu = "x64"
}
if (target_os == ""){
target_os = "linux"
}
if (current_cpu == ""){
current_cpu = target_cpu
}
if (current_os == ""){
current_os = target_os
}
set_default_toolchain(":gcc")

88
build/toolchain/BUILD.gn Executable file
View File

@@ -0,0 +1,88 @@
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
toolchain("gcc") {
tool("cc") {
depfile = "{{output}}.d"
command = "gcc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}"
depsformat = "gcc"
description = "CC {{output}}"
outputs =
[ "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o" ]
}
tool("cxx") {
depfile = "{{output}}.d"
command = "g++ -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} -c {{source}} -o {{output}}"
depsformat = "gcc"
description = "CXX {{output}}"
outputs =
[ "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o" ]
}
tool("alink") {
command = "rm -f {{output}} && ar rcs {{output}} {{inputs}}"
description = "AR {{target_output_name}}{{output_extension}}"
outputs =
[ "{{target_out_dir}}/{{target_output_name}}{{output_extension}}" ]
default_output_extension = ".a"
output_prefix = "lib"
}
tool("solink") {
soname = "{{target_output_name}}{{output_extension}}" # e.g. "libfoo.so".
sofile = "{{output_dir}}/$soname"
rspfile = soname + ".rsp"
if (is_mac) {
os_specific_option = "-install_name @executable_path/$sofile"
rspfile_content = "{{inputs}} {{solibs}} {{libs}}"
} else {
os_specific_option = "-Wl,-soname=$soname"
rspfile_content = "-Wl,--whole-archive {{inputs}} {{solibs}} -Wl,--no-whole-archive {{libs}}"
}
command = "g++ -shared {{ldflags}} -o $sofile $os_specific_option @$rspfile"
description = "SOLINK $soname"
# Use this for {{output_extension}} expansions unless a target manually
# overrides it (in which case {{output_extension}} will be what the target
# specifies).
default_output_extension = ".so"
# Use this for {{output_dir}} expansions unless a target manually overrides
# it (in which case {{output_dir}} will be what the target specifies).
default_output_dir = "{{root_out_dir}}"
outputs = [ sofile ]
link_output = sofile
depend_output = sofile
output_prefix = "lib"
}
tool("link") {
outfile = "{{target_output_name}}{{output_extension}}"
rspfile = "$outfile.rsp"
if (is_mac) {
command = "g++ {{ldflags}} -o $outfile @$rspfile {{solibs}} {{libs}}"
} else {
command = "g++ {{ldflags}} -o $outfile -Wl,--start-group @$rspfile {{solibs}} -Wl,--end-group {{libs}}"
}
description = "LINK $outfile"
default_output_dir = "{{root_out_dir}}"
rspfile_content = "{{inputs}}"
outputs = [ outfile ]
}
tool("stamp") {
command = "touch {{output}}"
description = "STAMP {{output}}"
}
tool("copy") {
command = "cp -af {{source}} {{output}}"
description = "COPY {{source}} {{output}}"
}
}

11
mfgtool/BUILD.gn Normal file
View File

@@ -0,0 +1,11 @@
group("mfgtools") {
deps = [
# This will expand to the name "//tutorial:tutorial" which is the full name
# of our new target. Run "gn help labels" for more.
# "//ah:aha",
"ah:aha"
]
}

13
mfgtool/ah/BUILD.gn Normal file
View File

@@ -0,0 +1,13 @@
executable("aha") {
sources = [
"add_header_v1.c",
"../ram/src/crc.c",
"../ram/src/sha256.c"
]
include_dirs = [
"../ram/inc",
"../../inc",
"../../inc/utils"
]
}

View File

@@ -122,7 +122,7 @@ uint32_t iot_oem_read_mtd_ext(uint8_t *buff,uint32_t buff_size)
uint8_t fw_prtition = PART_NUM_FW1;
char str_buff[10]={0};
imgHdr hdr={0};
imgHdr run_fw_hdr;
imgHdr run_fw_hdr={0};
const uint8_t *data;
const char *oem_ext_magic_str = IOT_OEM_EXT_MAGIC_STR;
int oem_ext_magic_str_len = strlen(oem_ext_magic_str);