257 lines
		
	
	
		
			6.7 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
		
		
			
		
	
	
			257 lines
		
	
	
		
			6.7 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| 
								 | 
							
								# Copyright (c) 2021 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")
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								###############################################################################
							 | 
						||
| 
								 | 
							
								declare_args() {
							 | 
						||
| 
								 | 
							
								  c_utils_feature_coverage = false
							 | 
						||
| 
								 | 
							
								  c_utils_debug_refbase = false
							 | 
						||
| 
								 | 
							
								  c_utils_track_all = false
							 | 
						||
| 
								 | 
							
								  c_utils_print_track_at_once = false
							 | 
						||
| 
								 | 
							
								  c_utils_debug_log_enabled = false
							 | 
						||
| 
								 | 
							
								  c_utils_feature_intsan = true
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								config("utils_config") {
							 | 
						||
| 
								 | 
							
								  include_dirs = [ "include" ]
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								config("utils_coverage_config") {
							 | 
						||
| 
								 | 
							
								  visibility = [ ":*" ]
							 | 
						||
| 
								 | 
							
								  if (c_utils_feature_coverage) {
							 | 
						||
| 
								 | 
							
								    cflags = [ "--coverage" ]
							 | 
						||
| 
								 | 
							
								    ldflags = [ "--coverage" ]
							 | 
						||
| 
								 | 
							
								  }
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								config("debug_log_enabled") {
							 | 
						||
| 
								 | 
							
								  visibility = [ ":*" ]
							 | 
						||
| 
								 | 
							
								  defines = [ "DEBUG_UTILS" ]
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								config("debug_refbase") {
							 | 
						||
| 
								 | 
							
								  visibility = [ ":*" ]
							 | 
						||
| 
								 | 
							
								  defines = [ "DEBUG_REFBASE" ]
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								config("print_track_at_once") {
							 | 
						||
| 
								 | 
							
								  visibility = [ ":*" ]
							 | 
						||
| 
								 | 
							
								  defines = [ "PRINT_TRACK_AT_ONCE" ]
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								config("track_all") {
							 | 
						||
| 
								 | 
							
								  visibility = [ ":*" ]
							 | 
						||
| 
								 | 
							
								  defines = [ "TRACK_ALL" ]
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								sources_utils = [
							 | 
						||
| 
								 | 
							
								  "src/string_ex.cpp",
							 | 
						||
| 
								 | 
							
								  "src/unicode_ex.cpp",
							 | 
						||
| 
								 | 
							
								  "src/directory_ex.cpp",
							 | 
						||
| 
								 | 
							
								  "src/datetime_ex.cpp",
							 | 
						||
| 
								 | 
							
								  "src/refbase.cpp",
							 | 
						||
| 
								 | 
							
								  "src/parcel.cpp",
							 | 
						||
| 
								 | 
							
								  "src/semaphore_ex.cpp",
							 | 
						||
| 
								 | 
							
								  "src/thread_pool.cpp",
							 | 
						||
| 
								 | 
							
								  "src/file_ex.cpp",
							 | 
						||
| 
								 | 
							
								  "src/mapped_file.cpp",
							 | 
						||
| 
								 | 
							
								  "src/observer.cpp",
							 | 
						||
| 
								 | 
							
								  "src/thread_ex.cpp",
							 | 
						||
| 
								 | 
							
								  "src/io_event_handler.cpp",
							 | 
						||
| 
								 | 
							
								  "src/io_event_reactor.cpp",
							 | 
						||
| 
								 | 
							
								  "src/io_event_epoll.cpp",
							 | 
						||
| 
								 | 
							
								  "src/event_handler.cpp",
							 | 
						||
| 
								 | 
							
								  "src/event_reactor.cpp",
							 | 
						||
| 
								 | 
							
								  "src/event_demultiplexer.cpp",
							 | 
						||
| 
								 | 
							
								  "src/timer.cpp",
							 | 
						||
| 
								 | 
							
								  "src/timer_event_handler.cpp",
							 | 
						||
| 
								 | 
							
								  "src/ashmem.cpp",
							 | 
						||
| 
								 | 
							
								  "src/rwlock.cpp",
							 | 
						||
| 
								 | 
							
								]
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								if (current_os == "ios") {
							 | 
						||
| 
								 | 
							
								  sources_utils_ios = [
							 | 
						||
| 
								 | 
							
								    "src/directory_ex.cpp",
							 | 
						||
| 
								 | 
							
								    "src/parcel.cpp",
							 | 
						||
| 
								 | 
							
								    "src/refbase.cpp",
							 | 
						||
| 
								 | 
							
								    "src/rwlock.cpp",
							 | 
						||
| 
								 | 
							
								    "src/string_ex.cpp",
							 | 
						||
| 
								 | 
							
								  ]
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								ohos_static_library("utilsbase") {
							 | 
						||
| 
								 | 
							
								  if (current_os == "ios") {
							 | 
						||
| 
								 | 
							
								    sources = sources_utils_ios
							 | 
						||
| 
								 | 
							
								    configs = [ ":utils_coverage_config" ]
							 | 
						||
| 
								 | 
							
								    all_dependent_configs = [ ":utils_config" ]
							 | 
						||
| 
								 | 
							
								    public_deps = [ "//third_party/bounds_checking_function:libsec_static" ]
							 | 
						||
| 
								 | 
							
								    defines = [ "IOS_PLATFORM" ]
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    subsystem_name = "commonlibrary"
							 | 
						||
| 
								 | 
							
								    part_name = "c_utils"
							 | 
						||
| 
								 | 
							
								  } else {
							 | 
						||
| 
								 | 
							
								    sources = sources_utils
							 | 
						||
| 
								 | 
							
								    configs = [ ":utils_coverage_config" ]
							 | 
						||
| 
								 | 
							
								    all_dependent_configs = [ ":utils_config" ]
							 | 
						||
| 
								 | 
							
								    if (current_os != "android" && current_os != "ios") {
							 | 
						||
| 
								 | 
							
								      defines = [ "CONFIG_HILOG" ]
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								    if (c_utils_debug_log_enabled) {
							 | 
						||
| 
								 | 
							
								      configs += [ ":debug_log_enabled" ]
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								    external_deps = [ "hilog:libhilog_base" ]
							 | 
						||
| 
								 | 
							
								    public_deps = [ "//third_party/bounds_checking_function:libsec_static" ]
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    subsystem_name = "commonlibrary"
							 | 
						||
| 
								 | 
							
								    part_name = "c_utils"
							 | 
						||
| 
								 | 
							
								  }
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								ohos_static_library("utilsbase_rtti") {
							 | 
						||
| 
								 | 
							
								  visibility = [ "//foundation/multimedia/histreamer/engine/plugin/plugins/source/video_capture:std_video_capture" ]
							 | 
						||
| 
								 | 
							
								  sources = sources_utils
							 | 
						||
| 
								 | 
							
								  all_dependent_configs = [ ":utils_config" ]
							 | 
						||
| 
								 | 
							
								  if (current_os != "android" && current_os != "ios") {
							 | 
						||
| 
								 | 
							
								    defines = [ "CONFIG_HILOG" ]
							 | 
						||
| 
								 | 
							
								  }
							 | 
						||
| 
								 | 
							
								  external_deps = [ "hilog:libhilog_base" ]
							 | 
						||
| 
								 | 
							
								  public_deps = [ "//third_party/bounds_checking_function:libsec_static" ]
							 | 
						||
| 
								 | 
							
								  remove_configs = [ "//build/config/compiler:no_rtti" ]
							 | 
						||
| 
								 | 
							
								  cflags = [ "-frtti" ]
							 | 
						||
| 
								 | 
							
								  subsystem_name = "commonlibrary"
							 | 
						||
| 
								 | 
							
								  part_name = "c_utils"
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								ohos_shared_library("utils") {
							 | 
						||
| 
								 | 
							
								  innerapi_tags = [
							 | 
						||
| 
								 | 
							
								    "chipsetsdk",
							 | 
						||
| 
								 | 
							
								    "platformsdk",
							 | 
						||
| 
								 | 
							
								  ]
							 | 
						||
| 
								 | 
							
								  if (current_os == "ios") {
							 | 
						||
| 
								 | 
							
								    sources = sources_utils_ios
							 | 
						||
| 
								 | 
							
								    configs = [ ":utils_coverage_config" ]
							 | 
						||
| 
								 | 
							
								    all_dependent_configs = [ ":utils_config" ]
							 | 
						||
| 
								 | 
							
								    public_deps = [ "//third_party/bounds_checking_function:libsec_shared" ]
							 | 
						||
| 
								 | 
							
								    defines = [ "IOS_PLATFORM" ]
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    subsystem_name = "commonlibrary"
							 | 
						||
| 
								 | 
							
								    part_name = "c_utils"
							 | 
						||
| 
								 | 
							
								  } else {
							 | 
						||
| 
								 | 
							
								    sources = sources_utils
							 | 
						||
| 
								 | 
							
								    configs = [ ":utils_coverage_config" ]
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    if (!build_cross_platform_version) {
							 | 
						||
| 
								 | 
							
								      if (c_utils_feature_intsan) {
							 | 
						||
| 
								 | 
							
								        sanitize = {
							 | 
						||
| 
								 | 
							
								          integer_overflow = true
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 | 
							
								      }
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    if (c_utils_debug_refbase) {
							 | 
						||
| 
								 | 
							
								      configs += [ ":debug_refbase" ]
							 | 
						||
| 
								 | 
							
								      if (c_utils_track_all) {
							 | 
						||
| 
								 | 
							
								        configs += [ ":track_all" ]
							 | 
						||
| 
								 | 
							
								      }
							 | 
						||
| 
								 | 
							
								      if (c_utils_print_track_at_once) {
							 | 
						||
| 
								 | 
							
								        configs += [ ":print_track_at_once" ]
							 | 
						||
| 
								 | 
							
								      }
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								    all_dependent_configs = [ ":utils_config" ]
							 | 
						||
| 
								 | 
							
								    if (current_os != "android" && current_os != "ios") {
							 | 
						||
| 
								 | 
							
								      defines = [ "CONFIG_HILOG" ]
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								    if (c_utils_debug_log_enabled) {
							 | 
						||
| 
								 | 
							
								      configs += [ ":debug_log_enabled" ]
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								    external_deps = [ "hilog:libhilog_base" ]
							 | 
						||
| 
								 | 
							
								    public_deps = [ "//third_party/bounds_checking_function:libsec_shared" ]
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    subsystem_name = "commonlibrary"
							 | 
						||
| 
								 | 
							
								    part_name = "c_utils"
							 | 
						||
| 
								 | 
							
								    install_images = [
							 | 
						||
| 
								 | 
							
								      "system",
							 | 
						||
| 
								 | 
							
								      "updater",
							 | 
						||
| 
								 | 
							
								    ]
							 | 
						||
| 
								 | 
							
								  }
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								########## modules for `c_utils` in rust ##########
							 | 
						||
| 
								 | 
							
								# rust compiler is not supportted on mac
							 | 
						||
| 
								 | 
							
								if (host_os == "linux" && !is_asan && !build_cross_platform_version) {
							 | 
						||
| 
								 | 
							
								  import("//build/templates/rust/rust_cxx.gni")  # used for templates rust_cxx()
							 | 
						||
| 
								 | 
							
								  rust_cxx("cxx_rust_gen") {
							 | 
						||
| 
								 | 
							
								    sources = [
							 | 
						||
| 
								 | 
							
								      "src/rust/ashmem.rs",
							 | 
						||
| 
								 | 
							
								      "src/rust/directory_ex.rs",
							 | 
						||
| 
								 | 
							
								      "src/rust/file_ex.rs",
							 | 
						||
| 
								 | 
							
								    ]
							 | 
						||
| 
								 | 
							
								  }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								  ohos_static_library("utils_static_cxx_rust") {
							 | 
						||
| 
								 | 
							
								    sources = [
							 | 
						||
| 
								 | 
							
								      "src/ashmem.cpp",
							 | 
						||
| 
								 | 
							
								      "src/directory_ex.cpp",
							 | 
						||
| 
								 | 
							
								      "src/file_ex.cpp",
							 | 
						||
| 
								 | 
							
								      "src/refbase.cpp",
							 | 
						||
| 
								 | 
							
								    ]
							 | 
						||
| 
								 | 
							
								    sources += get_target_outputs(":cxx_rust_gen")
							 | 
						||
| 
								 | 
							
								    defines = [ "UTILS_CXX_RUST" ]
							 | 
						||
| 
								 | 
							
								    include_dirs = [
							 | 
						||
| 
								 | 
							
								      "include",
							 | 
						||
| 
								 | 
							
								      "${target_gen_dir}",
							 | 
						||
| 
								 | 
							
								      "//third_party/rust/crates/cxx/include",
							 | 
						||
| 
								 | 
							
								    ]
							 | 
						||
| 
								 | 
							
								    deps = [
							 | 
						||
| 
								 | 
							
								      ":cxx_rust_gen",
							 | 
						||
| 
								 | 
							
								      "//third_party/rust/crates/cxx:cxx_cppdeps",
							 | 
						||
| 
								 | 
							
								    ]
							 | 
						||
| 
								 | 
							
								    public_deps = [ "//third_party/bounds_checking_function:libsec_shared" ]
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    subsystem_name = "commonlibrary"
							 | 
						||
| 
								 | 
							
								    part_name = "c_utils"
							 | 
						||
| 
								 | 
							
								  }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								  ohos_rust_shared_library("utils_rs") {
							 | 
						||
| 
								 | 
							
								    sources = [
							 | 
						||
| 
								 | 
							
								      "src/rust/ashmem.rs",
							 | 
						||
| 
								 | 
							
								      "src/rust/directory_ex.rs",
							 | 
						||
| 
								 | 
							
								      "src/rust/file_ex.rs",
							 | 
						||
| 
								 | 
							
								      "src/rust/lib.rs",
							 | 
						||
| 
								 | 
							
								    ]
							 | 
						||
| 
								 | 
							
								    deps = [
							 | 
						||
| 
								 | 
							
								      ":utils_static_cxx_rust",
							 | 
						||
| 
								 | 
							
								      "//third_party/rust/crates/cxx:lib",
							 | 
						||
| 
								 | 
							
								    ]
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    crate_root = "src/rust/lib.rs"
							 | 
						||
| 
								 | 
							
								    crate_name = "utils_rust"
							 | 
						||
| 
								 | 
							
								    crate_type = "dylib"
							 | 
						||
| 
								 | 
							
								    output_extension = "dylib.so"
							 | 
						||
| 
								 | 
							
								    subsystem_name = "commonlibrary"
							 | 
						||
| 
								 | 
							
								    part_name = "c_utils"
							 | 
						||
| 
								 | 
							
								    install_images = [
							 | 
						||
| 
								 | 
							
								      "system",
							 | 
						||
| 
								 | 
							
								      "updater",
							 | 
						||
| 
								 | 
							
								    ]
							 | 
						||
| 
								 | 
							
								  }
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								group("utils_rust") {
							 | 
						||
| 
								 | 
							
								  public_deps = []
							 | 
						||
| 
								 | 
							
								  if (host_os == "linux" && !is_asan && !build_cross_platform_version) {
							 | 
						||
| 
								 | 
							
								    public_deps += [ ":utils_rs" ]
							 | 
						||
| 
								 | 
							
								  }
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								###############################################################################
							 |