| # Copyright 2022 The Chromium Authors |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| import("//build/config/android/config.gni") |
| import("//testing/test.gni") |
| |
| config("pthreadpool_config") { |
| include_dirs = [ |
| "src/include", |
| "src/src", |
| ] |
| |
| # The platform-specific synchronizations are not needed for Chromium Jobs |
| # API integration. |
| defines = [ |
| "PTHREADPOOL_USE_EVENT=0", |
| "PTHREADPOOL_USE_FUTEX=0", |
| "PTHREADPOOL_USE_GCD=0", |
| "PTHREADPOOL_USE_CONDVAR=0", |
| ] |
| } |
| |
| # This is a target that depends on //base. |
| source_set("pthreadpool") { |
| public = [ "src/include/pthreadpool.h" ] |
| |
| sources = [ |
| "src/src/fastpath.c", |
| "src/src/memory.c", |
| "src/src/portable-api.c", |
| "src/src/threadpool-atomics.h", |
| "src/src/threadpool-common.h", |
| "src/src/threadpool-object.h", |
| "src/src/threadpool-utils.h", |
| ] |
| |
| # Use Chromium Jobs API. |
| sources += [ "chromium/jobs.cc" ] |
| |
| configs -= [ "//build/config/compiler:chromium_code" ] |
| configs += [ "//build/config/compiler:no_chromium_code" ] |
| |
| public_configs = [ ":pthreadpool_config" ] |
| |
| deps = [ |
| "//base", |
| "//third_party/fxdiv", |
| ] |
| } |
| |
| test("pthreadpool_unittests") { |
| testonly = true |
| |
| sources = [ "chromium/pthreadpool_unittests.cc" ] |
| |
| public_configs = [ ":pthreadpool_config" ] |
| |
| deps = [ |
| ":pthreadpool", |
| "//base/test:run_all_unittests", |
| "//base/test:test_support", |
| "//testing/gtest", |
| ] |
| } |
| |
| config("pthreadpool_standalone_config") { |
| include_dirs = [ |
| "src/include", |
| "src/src", |
| ] |
| defines = [ "PTHREADPOOL_USE_GCD=0" ] |
| } |
| |
| # This is a target that cannot depend on //base. |
| source_set("pthreadpool_standalone") { |
| public = [ "src/include/pthreadpool.h" ] |
| |
| sources = [ |
| "src/src/fastpath.c", |
| "src/src/memory.c", |
| "src/src/portable-api.c", |
| "src/src/threadpool-atomics.h", |
| "src/src/threadpool-common.h", |
| "src/src/threadpool-object.h", |
| "src/src/threadpool-utils.h", |
| ] |
| |
| if (is_win) { |
| sources += [ "src/src/windows.c" ] |
| } else { |
| sources += [ "src/src/pthreads.c" ] |
| } |
| |
| if (!(is_android && use_order_profiling)) { |
| assert_no_deps = [ "//base" ] |
| } |
| |
| configs -= [ "//build/config/compiler:chromium_code" ] |
| configs += [ "//build/config/compiler:no_chromium_code" ] |
| configs += [ "//build/config/sanitizers:cfi_icall_disable" ] |
| |
| public_configs = [ ":pthreadpool_standalone_config" ] |
| |
| deps = [ "//third_party/fxdiv" ] |
| } |