# Copyright 2018 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//build/config/features.gni")

if (safe_browsing_mode == 1) {
  static_library("unrar") {
    sources = [
      "src/archive.cpp",
      "src/arcread.cpp",
      "src/blake2s.cpp",
      "src/cmddata.cpp",
      "src/consio.cpp",
      "src/crc.cpp",
      "src/crypt.cpp",
      "src/encname.cpp",
      "src/errhnd.cpp",
      "src/extinfo.cpp",
      "src/extract.cpp",
      "src/filcreat.cpp",
      "src/file.cpp",
      "src/filefn.cpp",
      "src/filestr.cpp",
      "src/find.cpp",
      "src/getbits.cpp",
      "src/global.cpp",
      "src/hash.cpp",
      "src/headers.cpp",
      "src/list.cpp",
      "src/match.cpp",
      "src/options.cpp",
      "src/pathfn.cpp",
      "src/qopen.cpp",
      "src/rarvm.cpp",
      "src/rawread.cpp",
      "src/rdwrfn.cpp",
      "src/recvol.cpp",
      "src/resource.cpp",
      "src/rijndael.cpp",
      "src/rs.cpp",
      "src/rs16.cpp",
      "src/scantree.cpp",
      "src/secpassword.cpp",
      "src/sha1.cpp",
      "src/sha256.cpp",
      "src/smallfn.cpp",
      "src/strfn.cpp",
      "src/strlist.cpp",
      "src/system.cpp",
      "src/threadpool.cpp",
      "src/timefn.cpp",
      "src/ui.cpp",
      "src/unicode.cpp",
      "src/unpack.cpp",
      "src/volume.cpp",
    ]
    if (is_win) {
      sources += [ "src/isnt.cpp" ]
    }

    configs -= [ "//build/config/compiler:chromium_code" ]
    configs += [ "//build/config/compiler:no_chromium_code" ]

    defines = [
      "_FILE_OFFSET_BITS=64",
      "LARGEFILE_SOURCE",
      "RAR_SMP",
      "SILENT",

      # The following is set to disable certain macro definitions in the unrar
      # source code.
      "CHROMIUM_UNRAR",

      # Disables exceptions in unrar, replaces them with process termination.
      "UNRAR_NO_EXCEPTIONS",
    ]

    deps = [
      "//base",
    ]
  }
}
