# 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")
import("//build/test.gni")
import("//foundation/ability/idl_tool/idl_tool.gni")

module_output_path = "idl/unittest"

IDL_DIR = "../../.."

config("idl_unittest_test_config") {
  include_dirs = [
    "../../common/",
    "${IDL_DIR}/",
  ]
}

common_sources = [
  "${IDL_DIR}/ast/ast_array_type.cpp",
  "${IDL_DIR}/ast/ast_boolean_type.cpp",
  "${IDL_DIR}/ast/ast_byte_type.cpp",
  "${IDL_DIR}/ast/ast_char_type.cpp",
  "${IDL_DIR}/ast/ast_double_type.cpp",
  "${IDL_DIR}/ast/ast_float_type.cpp",
  "${IDL_DIR}/ast/ast_integer_type.cpp",
  "${IDL_DIR}/ast/ast_interface_type.cpp",
  "${IDL_DIR}/ast/ast_list_type.cpp",
  "${IDL_DIR}/ast/ast_long_type.cpp",
  "${IDL_DIR}/ast/ast_map_type.cpp",
  "${IDL_DIR}/ast/ast_method.cpp",
  "${IDL_DIR}/ast/ast_module.cpp",
  "${IDL_DIR}/ast/ast_namespace.cpp",
  "${IDL_DIR}/ast/ast_node.cpp",
  "${IDL_DIR}/ast/ast_parameter.cpp",
  "${IDL_DIR}/ast/ast_sequenceable_type.cpp",
  "${IDL_DIR}/ast/ast_short_type.cpp",
  "${IDL_DIR}/ast/ast_string_type.cpp",
  "${IDL_DIR}/ast/ast_type.cpp",
  "${IDL_DIR}/ast/ast_void_type.cpp",
]

common_sources += [
  "${IDL_DIR}/codegen/code_emitter.cpp",
  "${IDL_DIR}/codegen/code_generator.cpp",
  "${IDL_DIR}/codegen/cpp_code_emitter.cpp",
  "${IDL_DIR}/codegen/ts_code_emitter.cpp",
]

common_sources += [
  "${IDL_DIR}/metadata/metadata_builder.cpp",
  "${IDL_DIR}/metadata/metadata_dumper.cpp",
  "${IDL_DIR}/metadata/metadata_reader.cpp",
  "${IDL_DIR}/metadata/metadata_serializer.cpp",
]

common_sources += [
  "${IDL_DIR}/parser/lexer.cpp",
  "${IDL_DIR}/parser/parser.cpp",
]

common_sources += [
  "${IDL_DIR}/util/file.cpp",
  "${IDL_DIR}/util/light_refcount_base.cpp",
  "${IDL_DIR}/util/logger.cpp",
  "${IDL_DIR}/util/options.cpp",
  "${IDL_DIR}/util/string.cpp",
  "${IDL_DIR}/util/string_builder.cpp",
  "${IDL_DIR}/util/string_pool.cpp",
]

ohos_unittest("metadata_serializer_test") {
  module_out_path = module_output_path
  include_dirs = [ "${IDL_TOOL_DIR}" ]

  sources = [ "metadata_serializer_test.cpp" ]

  sources += common_sources

  deps = []

  external_deps = [
    "c_utils:utils",
    "hilog:libhilog",
  ]

  part_name = "idl_tool"
  subsystem_name = "ability"
}

group("unittest") {
  testonly = true
  deps = [ ":metadata_serializer_test" ]
}