blob: 383b6a68156c5be8635c5f79e7845dcb7d346ee4 [file] [log] [blame]
# Copyright 2021 The Pigweed Authors
#
# 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
#
# https://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_overrides/pigweed.gni")
import("$dir_pw_build/module_config.gni")
import("$dir_pw_build/target_types.gni")
import("$dir_pw_chrono/backend.gni")
import("$dir_pw_docgen/docs.gni")
import("$dir_pw_thread/backend.gni")
import("$dir_pw_unit_test/test.gni")
declare_args() {
# The build target that overrides the default configuration options for this
# module. This should point to a source set that provides defines through a
# public config (which may -include a file or add defines directly).
pw_thread_embos_CONFIG = pw_build_DEFAULT_MODULE_CONFIG
}
config("public_include_path") {
include_dirs = [ "public" ]
visibility = [ ":*" ]
}
config("backend_config") {
include_dirs = [ "public_overrides" ]
visibility = [ ":*" ]
}
pw_source_set("config") {
public = [ "public/pw_thread_embos/config.h" ]
public_configs = [ ":public_include_path" ]
public_deps = [
"$dir_pw_third_party/embos",
pw_thread_embos_CONFIG,
]
}
# This target provides the backend for pw::thread::Id.
pw_source_set("id") {
public_configs = [
":public_include_path",
":backend_config",
]
public_deps = [
"$dir_pw_assert",
"$dir_pw_interrupt:context",
"$dir_pw_third_party/embos",
]
public = [
"public/pw_thread_embos/id_inline.h",
"public/pw_thread_embos/id_native.h",
"public_overrides/pw_thread_backend/id_inline.h",
"public_overrides/pw_thread_backend/id_native.h",
]
deps = [ "$dir_pw_thread:id.facade" ]
}
if (pw_chrono_SYSTEM_CLOCK_BACKEND != "" && pw_thread_SLEEP_BACKEND != "") {
# This target provides the backend for pw::thread::sleep_{for,until}.
pw_source_set("sleep") {
public_configs = [
":public_include_path",
":backend_config",
]
public = [
"public/pw_thread_embos/sleep_inline.h",
"public_overrides/pw_thread_backend/sleep_inline.h",
]
public_deps = [ "$dir_pw_chrono:system_clock" ]
sources = [ "sleep.cc" ]
deps = [
"$dir_pw_assert",
"$dir_pw_chrono_embos:system_clock",
"$dir_pw_third_party/embos",
"$dir_pw_thread:id",
"$dir_pw_thread:sleep.facade",
]
assert(pw_thread_OVERRIDE_SYSTEM_CLOCK_BACKEND_CHECK ||
pw_chrono_SYSTEM_CLOCK_BACKEND ==
"$dir_pw_chrono_embos:system_clock",
"The embOS pw::thread::sleep_{for,until} backend only works with " +
"the embOS pw::chrono::SystemClock backend.")
}
}
# This target provides the backend for pw::thread::Thread and the headers needed
# for thread creation.
pw_source_set("thread") {
public_configs = [
":public_include_path",
":backend_config",
]
public_deps = [
":config",
"$dir_pw_assert",
"$dir_pw_string",
"$dir_pw_third_party/embos",
"$dir_pw_thread:id",
"$dir_pw_thread:thread.facade",
]
public = [
"public/pw_thread_embos/context.h",
"public/pw_thread_embos/options.h",
"public/pw_thread_embos/thread_inline.h",
"public/pw_thread_embos/thread_native.h",
"public_overrides/pw_thread_backend/thread_inline.h",
"public_overrides/pw_thread_backend/thread_native.h",
]
allow_circular_includes_from = [ "$dir_pw_thread:thread.facade" ]
sources = [ "thread.cc" ]
}
# This target provides the backend for pw::thread::yield.
pw_source_set("yield") {
public_configs = [
":public_include_path",
":backend_config",
]
public = [
"public/pw_thread_embos/yield_inline.h",
"public_overrides/pw_thread_backend/yield_inline.h",
]
public_deps = [
"$dir_pw_assert",
"$dir_pw_third_party/embos",
"$dir_pw_thread:id",
]
deps = [ "$dir_pw_thread:yield.facade" ]
}
pw_test_group("tests") {
tests = [ ":thread_backend_test" ]
}
pw_source_set("test_threads") {
public_deps = [ "$dir_pw_thread:test_threads" ]
sources = [ "test_threads.cc" ]
deps = [
"$dir_pw_chrono:system_clock",
"$dir_pw_thread:sleep",
"$dir_pw_thread:thread",
dir_pw_assert,
dir_pw_log,
]
}
pw_test("thread_backend_test") {
enable_if = pw_thread_THREAD_BACKEND == "$dir_pw_thread_embos:thread"
deps = [
":test_threads",
"$dir_pw_thread:thread_facade_test",
]
}
pw_doc_group("docs") {
sources = [ "docs.rst" ]
}