pw_thread_threadx: Enable pw::thread::Thread for ThreadX
Change-Id: Ied43a085786a60d7b1a0681ab51c8d00a0eb0319
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/40381
Reviewed-by: Ewout van Bekkum <ewout@google.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
Pigweed-Auto-Submit: Ewout van Bekkum <ewout@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
diff --git a/pw_thread_threadx/BUILD.gn b/pw_thread_threadx/BUILD.gn
index 954615f..f7a090b 100644
--- a/pw_thread_threadx/BUILD.gn
+++ b/pw_thread_threadx/BUILD.gn
@@ -1,4 +1,4 @@
-# Copyright 2020 The Pigweed Authors
+# 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
@@ -14,10 +14,19 @@
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_threadx_CONFIG = pw_build_DEFAULT_MODULE_CONFIG
+}
config("public_include_path") {
include_dirs = [ "public" ]
@@ -29,6 +38,15 @@
visibility = [ ":*" ]
}
+pw_source_set("config") {
+ public = [ "public/pw_thread_threadx/config.h" ]
+ public_configs = [ ":public_include_path" ]
+ public_deps = [
+ "$dir_pw_third_party/threadx",
+ pw_thread_threadx_CONFIG,
+ ]
+}
+
# This target provides the backend for pw::thread::Id.
pw_source_set("id") {
public_configs = [
@@ -50,7 +68,7 @@
}
if (pw_chrono_SYSTEM_CLOCK_BACKEND != "" && pw_thread_SLEEP_BACKEND != "") {
- # This target provides the backend for pw::thread::sleep_{for,until}.
+ # This target provides the backend for pw::this_thread::sleep_{for,until}.
pw_source_set("sleep") {
public_configs = [
":public_include_path",
@@ -72,12 +90,37 @@
pw_thread_OVERRIDE_SYSTEM_CLOCK_BACKEND_CHECK ||
pw_chrono_SYSTEM_CLOCK_BACKEND ==
"$dir_pw_chrono_threadx:system_clock",
- "The ThreadX pw::thread::sleep_{for,until} backend only works with " +
- "the ThreadX pw::chrono::SystemClock backend.")
+ "The ThreadX pw::this_thread::sleep_{for,until} backend only works with " + "the ThreadX pw::chrono::SystemClock backend.")
}
}
-# This target provides the backend for pw::thread::yield.
+# 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_third_party/threadx",
+ "$dir_pw_thread:id",
+ "$dir_pw_thread:thread.facade",
+ ]
+ public = [
+ "public/pw_thread_threadx/context.h",
+ "public/pw_thread_threadx/options.h",
+ "public/pw_thread_threadx/thread_inline.h",
+ "public/pw_thread_threadx/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::this_thread::yield.
pw_source_set("yield") {
public_configs = [
":public_include_path",
@@ -95,6 +138,30 @@
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_threadx:thread"
+ deps = [
+ ":test_threads",
+ "$dir_pw_thread:thread_facade_test",
+ ]
+}
+
pw_doc_group("docs") {
sources = [ "docs.rst" ]
}