# Copyright (c) 2021 Huawei Device Co., Ltd.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.

import("//build/ohos.gni")

config("f2fs-defaults") {
  cflags = [
    "-Wno-pointer-sign",
    "-Wno-unused-variable",
    "-Wno-string-plus-int",
    "-Wno-error=format",
  ]
  if (current_toolchain == host_toolchain) {
    cflags += ["-DCONF_TARGET_HOST"]
  }
}

###################################################
##Build mkfs.f2fs
ohos_executable("mkfs.f2fs") {
  branch_protector_ret = "pac_ret"
  configs = [ ":f2fs-defaults" ]
  sources = [
    "../lib/extra_fsck.c",
    "f2fs_format.c",
    "f2fs_format_main.c",
    "f2fs_format_utils.c",
  ]

  include_dirs = [
    ".",
    "//third_party/f2fs-tools",
    "//third_party/f2fs-tools/lib",
    "//third_party/f2fs-tools/include",
  ]

  deps = [ "//third_party/f2fs-tools/lib:libf2fs" ]

  external_deps = [
    "e2fsprogs:libext2_uuid",
    "e2fsprogs:libdacconfig"
  ]

  defines = [ "HAVE_CONFIG_H" ]

  install_enable = true
  subsystem_name = "thirdparty"
  part_name = "f2fs-tools"
  install_images = [
    "system",
    "updater",
  ]
}