diff --git a/BUILD.gn b/BUILD.gn index 66650948acff7523e0e4ec16f9a4e03394aa51f8..f4af6178faa70e7d8595910e78a3966162f06974 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 c1b82294b7342b56e2a8c5ceba575726869f3498..8a700569e199c84ef4017b32fb75118c5c5d5561 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 5030ef0376b4dc409effe8e0d1ee87aa5824df63..c50cd4b97c8ea433c3844570f180ec08bcb8d4c3 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