pw_thread_freertos: Add CMake support
Change-Id: Ie34b4d7e45bd59bb418d682c8bcb581d2a522778
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/79724
Reviewed-by: Keir Mierle <keir@google.com>
Pigweed-Auto-Submit: Ewout van Bekkum <ewout@google.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b33e59e..a6d54f3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -67,6 +67,7 @@
add_subdirectory(pw_sys_io EXCLUDE_FROM_ALL)
add_subdirectory(pw_sys_io_stdio EXCLUDE_FROM_ALL)
add_subdirectory(pw_system EXCLUDE_FROM_ALL)
+add_subdirectory(pw_thread_freertos EXCLUDE_FROM_ALL)
add_subdirectory(pw_tokenizer EXCLUDE_FROM_ALL)
add_subdirectory(pw_trace EXCLUDE_FROM_ALL)
add_subdirectory(pw_trace_tokenized EXCLUDE_FROM_ALL)
diff --git a/pw_thread_freertos/CMakeLists.txt b/pw_thread_freertos/CMakeLists.txt
new file mode 100644
index 0000000..1e524f6
--- /dev/null
+++ b/pw_thread_freertos/CMakeLists.txt
@@ -0,0 +1,155 @@
+# Copyright 2022 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.
+
+include($ENV{PW_ROOT}/pw_build/pigweed.cmake)
+
+pw_add_module_config(pw_thread_freertos_CONFIG)
+
+pw_add_module_library(pw_thread_freertos.config
+ HEADERS
+ public/pw_thread_freertos/config.h
+ PUBLIC_INCLUDES
+ public
+ PUBLIC_DEPS
+ pw_third_party.freertos
+ ${pw_thread_freertos_CONFIG}
+)
+
+# This target provides the backend for pw::thread::Id & pw::this_thread::get_id.
+pw_add_module_library(pw_thread_freertos.id
+ IMPLEMENTS_FACADES
+ pw_thread.id
+ HEADERS
+ public/pw_thread_freertos/id_inline.h
+ public/pw_thread_freertos/id_native.h
+ public_overrides/pw_thread_backend/id_inline.h
+ public_overrides/pw_thread_backend/id_native.h
+ PUBLIC_INCLUDES
+ public
+ public_overrides
+ PUBLIC_DEPS
+ pw_assert
+ pw_interrupt.context
+ pw_third_party.freertos
+)
+
+# This target provides the backend for pw::this_thread::sleep_{for,until}.
+pw_add_module_library(pw_thread_freertos.sleep
+ IMPLEMENTS_FACADES
+ pw_thread.sleep
+ HEADERS
+ public/pw_thread_freertos/sleep_inline.h
+ public_overrides/pw_thread_backend/sleep_inline.h
+ PUBLIC_INCLUDES
+ public
+ public_overrides
+ PUBLIC_DEPS
+ pw_chrono.system_clock
+ SOURCES
+ sleep.cc
+ PRIVATE_DEPS
+ pw_assert
+ pw_chrono_freertos.system_clock
+ pw_third_party.freertos
+ pw_thread.id
+)
+
+# This target provides the backend for pw::thread::Thread and the headers needed
+# for thread creation.
+pw_add_module_library(pw_thread_freertos.thread
+ IMPLEMENTS_FACADES
+ pw_thread.thread
+ HEADERS
+ public/pw_thread_freertos/context.h
+ public/pw_thread_freertos/options.h
+ public/pw_thread_freertos/thread_inline.h
+ public/pw_thread_freertos/thread_native.h
+ public_overrides/pw_thread_backend/thread_inline.h
+ public_overrides/pw_thread_backend/thread_native.h
+ PUBLIC_INCLUDES
+ public
+ public_overrides
+ PUBLIC_DEPS
+ pw_assert
+ pw_polyfill.span
+ pw_string
+ pw_third_party.freertos
+ pw_thread.id
+ pw_thread_freertos.config
+ SOURCES
+ thread.cc
+)
+
+# This target provides the backend for pw::this_thread::yield.
+pw_add_module_library(pw_thread_freertos.yield
+ IMPLEMENTS_FACADES
+ pw_thread.yield
+ HEADERS
+ public/pw_thread_freertos/yield_inline.h
+ public_overrides/pw_thread_backend/yield_inline.h
+ PUBLIC_INCLUDES
+ public
+ public_overrides
+ PUBLIC_DEPS
+ pw_assert
+ pw_third_party.freertos
+ pw_thread.id
+)
+
+pw_add_module_library(pw_thread_freertos.util
+ HEADERS
+ public/pw_thread_freertos/util.h
+ PUBLIC_INCLUDES
+ public
+ PUBLIC_DEPS
+ pw_third_party.freertos
+ pw_function
+ pw_polyfill.span
+ pw_status
+ SOURCES
+ util.cc
+ PRIVATE_DEPS
+ pw_log
+)
+
+pw_add_module_library(pw_thread_freertos.snapshot
+ HEADERS
+ public/pw_thread_freertos/snapshot.h
+ PUBLIC_INCLUDES
+ public
+ PUBLIC_DEPS
+ pw_function
+ pw_polyfill.span
+ pw_protobuf
+ pw_status
+ pw_third_party.freertos
+ pw_thread.protos.pwpb
+ pw_thread.snapshot
+ pw_thread_freertos.config
+ SOURCES
+ snapshot.cc
+ PRIVATE_DEPS
+ pw_thread_freertos.freertos_tsktcb
+ pw_thread_freertos.util
+ pw_log
+)
+
+pw_add_facade(pw_thread_freertos.freertos_tsktcb
+ HEADERS
+ public/pw_thread_freertos/freertos_tsktcb.h
+ PUBLIC_INCLUDES
+ public
+ PUBLIC_DEPS
+ pw_third_party.freertos
+)