From ce1d2c0a53ba24dbf6cd10c59cf528fb5476ffab Mon Sep 17 00:00:00 2001 From: liliaoyuan <907077378@qq.com> Date: Wed, 9 Apr 2025 16:37:42 +0800 Subject: [PATCH] =?UTF-8?q?=20=20=20=20=E9=97=AE=E9=A2=98=E6=A0=B9?= =?UTF-8?q?=E5=9B=A0=EF=BC=9A=E9=80=82=E9=85=8Doh5.0=E5=B0=8F=E5=9E=8B?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E3=80=82=20=20=20=20=20=E8=A7=A3=E5=86=B3?= =?UTF-8?q?=E6=96=B9=E6=A1=88=EF=BC=9A=E9=80=82=E9=85=8Doh5.0=E5=B0=8F?= =?UTF-8?q?=E5=9E=8B=E7=B3=BB=E7=BB=9F=E3=80=82=20=20=20=20=20=E6=98=AF?= =?UTF-8?q?=E5=90=A6=E5=AE=8C=E6=88=90=E5=8F=98=E6=88=90=E8=A7=84=E8=8C=83?= =?UTF-8?q?=E8=87=AA=E6=A3=80=EF=BC=9AY=20=20=20=20=20=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E7=BC=96=E8=AF=91=E4=B8=94=E9=AA=8C=E8=AF=81=E9=80=9A=E8=BF=87?= =?UTF-8?q?=EF=BC=9AY=20=20=20=20=20=E5=BD=B1=E5=93=8D=E7=9A=84=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E4=B8=8E=E5=B9=B3=E5=8F=B0=E8=8C=83=E5=9B=B4=EF=BC=9A?= =?UTF-8?q?gateway=20=20=20=20=20=E5=9B=A2=E9=98=9F:=20H=20=20=20=20=20Sig?= =?UTF-8?q?ned-off-by:=E6=9D=8E=E8=BE=BD=E5=8E=9F=20<907077378@qq.com>?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BUILD.gn | 174 +++++++++++++++++++++++++++++++++++++++------------- bundle.json | 18 +++++- config.h | 4 +- 3 files changed, 150 insertions(+), 46 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index 66650948..f4af6178 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -11,7 +11,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//build/ohos.gni") +if (defined(ohos_lite)) { + import("//build/lite/config/component/lite_component.gni") +} else { + import("//build/ohos.gni") +} import("//third_party/elfutils/elfutils_config.gni") config("elfutils_defaults") { @@ -28,53 +32,139 @@ config("elfutils_public_config") { include_dirs = [ "include" ] } -# Build libelf -ohos_static_library("libelf_static") { - configs = [ ":elfutils_defaults" ] +if (defined(ohos_lite)) { + lite_library("libelf") { + if (ohos_kernel_type == "liteos_m") { + target_type = "static_library" + } else { + target_type = "shared_library" + } - sources = sources_libelf + defines = [ + "HAVE_CONFIG_H", + "_GNU_SOURCE", + "NMNES=1000", + "DISABLE_HAVE_ERROR_H=1", + ] - include_dirs = [ - "//third_party/elfutils", - "//third_party/elfutils/lib", - "//third_party/elfutils/libelf", - ] + cflags = [ + "-std=gnu99", + "-Wall", + "-Wno-int-conversion", + ] - deps = [ "//third_party/zlib:libz" ] + sources = sources_libelf - license_file = "COPYING-LGPLV3" - subsystem_name = "thirdparty" - part_name = "elfutils" -} + include_dirs = [ + "//third_party/elfutils", + "//third_party/elfutils/lib", + "//third_party/elfutils/libelf", + "//third_party/zlib", + ] -# Build libdw -ohos_static_library("libdw_static") { - configs = [ ":elfutils_defaults" ] - - sources = sources_backends - sources += sources_libcpu - sources += sources_libdw - sources += sources_libdwelf - sources += sources_libdwfl - sources += sources_libebl - - include_dirs = [ - "//third_party/elfutils", - "//third_party/elfutils/lib", - "//third_party/elfutils/libasm", - "//third_party/elfutils/libelf", - "//third_party/elfutils/libcpu", - "//third_party/elfutils/libdw", - "//third_party/elfutils/libdwelf", - "//third_party/elfutils/libdwfl", - "//third_party/elfutils/libebl", - ] + deps = [ "//third_party/zlib:libz" ] + } + lite_library("libdw") { + if (ohos_kernel_type == "liteos_m") { + target_type = "static_library" + } else { + target_type = "shared_library" + } + + defines = [ + "HAVE_CONFIG_H", + "_GNU_SOURCE", + "NMNES=1000", + "DISABLE_HAVE_ERROR_H=1", + ] + + remove_configs = [ + "//build/lite/config:language_c" + ] + cflags = [ + "-std=gnu99", + "-Wall", + "-Wno-unused-result", + "-Wno-format-nonliteral", + "-Wno-int-conversion", + ] + + sources = sources_backends + sources += sources_libcpu + sources += sources_libdw + sources += sources_libdwelf + sources += sources_libdwfl + sources += sources_libebl + + include_dirs = [ + "//third_party/elfutils", + "//third_party/elfutils/lib", + "//third_party/elfutils/libasm", + "//third_party/elfutils/libelf", + "//third_party/elfutils/libcpu", + "//third_party/elfutils/libdw", + "//third_party/elfutils/libdwelf", + "//third_party/elfutils/libdwfl", + "//third_party/elfutils/libebl", + "//third_party/zlib", + ] + + public_configs = [ ":elfutils_public_config" ] + + deps = [ + ":libelf", + "//third_party/musl-fts:libfts", + ] + } +} else { + # Build libelf + ohos_static_library("libelf_static") { + configs = [ ":elfutils_defaults" ] + + sources = sources_libelf + + include_dirs = [ + "//third_party/elfutils", + "//third_party/elfutils/lib", + "//third_party/elfutils/libelf", + ] + + deps = [ "//third_party/zlib:libz" ] + + license_file = "COPYING-LGPLV3" + subsystem_name = "thirdparty" + part_name = "elfutils" + } + + # Build libdw + ohos_static_library("libdw_static") { + configs = [ ":elfutils_defaults" ] + + sources = sources_backends + sources += sources_libcpu + sources += sources_libdw + sources += sources_libdwelf + sources += sources_libdwfl + sources += sources_libebl + + include_dirs = [ + "//third_party/elfutils", + "//third_party/elfutils/lib", + "//third_party/elfutils/libasm", + "//third_party/elfutils/libelf", + "//third_party/elfutils/libcpu", + "//third_party/elfutils/libdw", + "//third_party/elfutils/libdwelf", + "//third_party/elfutils/libdwfl", + "//third_party/elfutils/libebl", + ] - public_configs = [ ":elfutils_public_config" ] + public_configs = [ ":elfutils_public_config" ] - deps = [ ":libelf_static" ] + deps = [ ":libelf_static" ] - license_file = "COPYING-LGPLV3" - subsystem_name = "thirdparty" - part_name = "elfutils" + license_file = "COPYING-LGPLV3" + subsystem_name = "thirdparty" + part_name = "elfutils" + } } diff --git a/bundle.json b/bundle.json index c1b82294..8a700569 100644 --- a/bundle.json +++ b/bundle.json @@ -18,12 +18,18 @@ "subsystem": "thirdparty", "syscap": [], "features": [], - "adapted_system_type": [ "standard" ], + "adapted_system_type": [ "small","standard" ], "rom": "", "ram": "", "deps": { - "components": [], - "third_party": [] + "components": [ + "zlib", + "musl-fts" + ], + "third_party": [ + "zlib", + "musl-fts" + ] }, "build": { "sub_component": [], @@ -36,6 +42,12 @@ ] }, "name": "//third_party/elfutils:libdw_static" + }, + { + "name": "//third_party/elfutils:libelf" + }, + { + "name": "//third_party/elfutils:libdw" } ], "test": [] diff --git a/config.h b/config.h index 5030ef03..c50cd4b9 100644 --- a/config.h +++ b/config.h @@ -60,7 +60,9 @@ #define HAVE_DECL_STRERROR_R 1 /* Define to 1 if you have the header file. */ -#define HAVE_ERROR_H 1 +#ifndef DISABLE_HAVE_ERROR_H + #define HAVE_ERROR_H 1 +#endif /* Define to 1 if you have the header file. */ #define HAVE_ERR_H 1 -- Gitee