Skip to content

Commit

Permalink
cmake: Migrate all facades to use BACKEND variables
Browse files Browse the repository at this point in the history
Migrates all CMake facades to use BACKEND variables which are
defined in backend.cmake variables, similar to GN.

Change-Id: I63dd1a81aa0a796366f6c78c4823e6081a6463f1
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/117413
Reviewed-by: Wyatt Hepler <[email protected]>
Commit-Queue: Auto-Submit <[email protected]>
Pigweed-Auto-Submit: Ewout van Bekkum <[email protected]>
  • Loading branch information
Ewout van Bekkum authored and CQ Bot Account committed Nov 10, 2022
1 parent 328902d commit 91a55b1
Show file tree
Hide file tree
Showing 34 changed files with 446 additions and 6 deletions.
5 changes: 5 additions & 0 deletions pw_assert/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# the License.

include($ENV{PW_ROOT}/pw_build/pigweed.cmake)
include($ENV{PW_ROOT}/pw_assert/backend.cmake)

pw_add_module_config(pw_assert_CONFIG)

Expand Down Expand Up @@ -49,6 +50,8 @@ if(DEFINED pw_assert_BACKEND)
endif()

pw_add_module_facade(pw_assert.assert
BACKEND
pw_assert.assert_BACKEND
HEADERS
public/pw_assert/assert.h
PUBLIC_INCLUDES
Expand All @@ -58,6 +61,8 @@ pw_add_module_facade(pw_assert.assert
)

pw_add_module_facade(pw_assert.check
BACKEND
pw_assert.check_BACKEND
HEADERS
public/pw_assert/check.h
public/pw_assert/internal/check_impl.h
Expand Down
22 changes: 22 additions & 0 deletions pw_assert/backend.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 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_guard(GLOBAL)

include($ENV{PW_ROOT}/pw_build/pigweed.cmake)

# Backend for the pw_assert module's CHECK facade.
pw_add_backend_variable(pw_assert.assert_BACKEND)

# Backend for the pw_assert module's ASSERT facade.
pw_add_backend_variable(pw_assert.check_BACKEND)
3 changes: 3 additions & 0 deletions pw_assert_basic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@
# the License.

include($ENV{PW_ROOT}/pw_build/pigweed.cmake)
include($ENV{PW_ROOT}/pw_assert_basic/backend.cmake)

pw_add_module_facade(pw_assert_basic.handler
BACKEND
pw_assert_basic.handler_BACKEND
HEADERS
public/pw_assert_basic/handler.h
PUBLIC_INCLUDES
Expand Down
29 changes: 29 additions & 0 deletions pw_assert_basic/backend.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# 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_guard(GLOBAL)

include($ENV{PW_ROOT}/pw_build/pigweed.cmake)

# Handler backend for the pw_assert_basic module which implements
# pw_assert_basic_HandleFailure, this defaults to the basic_handler.
#
# Note: Don't confuse pw_assert.check_BACKEND and
# pw_assert_basic.handler_BACKEND:
# 1) pw_assert.check_BACKEND must be set to pw_assert_basic.check_backend in
# order to use this module which ensures that asserts always invoke
# pw_assert_basic_HandleFailure.
# 2) pw_assert_basic.handler_BACKEND allows you to switch out the
# implementation of the handler which is invoked (i.e.
# pw_assert_basic_HandleFailure).
pw_add_backend_variable(pw_assert_basic.handler_BACKEND)
5 changes: 5 additions & 0 deletions pw_chrono/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# the License.

include($ENV{PW_ROOT}/pw_build/pigweed.cmake)
include($ENV{PW_ROOT}/pw_chrono/backend.cmake)
include($ENV{PW_ROOT}/pw_protobuf_compiler/proto.cmake)

pw_add_module_library(pw_chrono.epoch
Expand All @@ -23,6 +24,8 @@ pw_add_module_library(pw_chrono.epoch
)

pw_add_module_facade(pw_chrono.system_clock
BACKEND
pw_chrono.system_clock_BACKEND
HEADERS
public/pw_chrono/internal/system_clock_macros.h
public/pw_chrono/system_clock.h
Expand All @@ -36,6 +39,8 @@ pw_add_module_facade(pw_chrono.system_clock
)

pw_add_module_facade(pw_chrono.system_timer
BACKEND
pw_chrono.system_timer_BACKEND
HEADERS
public/pw_chrono/system_timer.h
PUBLIC_INCLUDES
Expand Down
22 changes: 22 additions & 0 deletions pw_chrono/backend.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 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_guard(GLOBAL)

include($ENV{PW_ROOT}/pw_build/pigweed.cmake)

# Backend for the pw_chrono module's system_clock.
pw_add_backend_variable(pw_chrono.system_clock_BACKEND)

# Backend for the pw_chrono module's system_timer.
pw_add_backend_variable(pw_chrono.system_timer_BACKEND)
7 changes: 7 additions & 0 deletions pw_cpu_exception/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@
# the License.

include($ENV{PW_ROOT}/pw_build/pigweed.cmake)
include($ENV{PW_ROOT}/pw_cpu_exception/backend.cmake)

pw_add_module_facade(pw_cpu_exception.entry
BACKEND
pw_cpu_exception.entry_BACKEND
HEADERS
public/pw_cpu_exception/entry.h
public/pw_cpu_exception/state.h
Expand All @@ -25,6 +28,8 @@ pw_add_module_facade(pw_cpu_exception.entry
)

pw_add_module_facade(pw_cpu_exception.handler
BACKEND
pw_cpu_exception.handler_BACKEND
HEADERS
public/pw_cpu_exception/handler.h
PUBLIC_INCLUDES
Expand All @@ -37,6 +42,8 @@ pw_add_module_facade(pw_cpu_exception.handler
)

pw_add_module_facade(pw_cpu_exception.support
BACKEND
pw_cpu_exception.support_BACKEND
HEADERS
public/pw_cpu_exception/support.h
PUBLIC_INCLUDES
Expand Down
21 changes: 21 additions & 0 deletions pw_cpu_exception/backend.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 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_guard(GLOBAL)

include($ENV{PW_ROOT}/pw_build/pigweed.cmake)

# Backends for the pw_cpu_exception module.
pw_add_backend_variable(pw_cpu_exception.entry_BACKEND)
pw_add_backend_variable(pw_cpu_exception.handler_BACKEND)
pw_add_backend_variable(pw_cpu_exception.support_BACKEND)
2 changes: 1 addition & 1 deletion pw_cpu_exception/backend.gni
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# the License.

declare_args() {
# Backend for the pw_cpu_exception module.
# Backends for the pw_cpu_exception module.
pw_cpu_exception_ENTRY_BACKEND = ""
pw_cpu_exception_HANDLER_BACKEND = ""
pw_cpu_exception_SUPPORT_BACKEND = ""
Expand Down
3 changes: 3 additions & 0 deletions pw_interrupt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@
# the License.

include($ENV{PW_ROOT}/pw_build/pigweed.cmake)
include($ENV{PW_ROOT}/pw_interrupt/backend.cmake)

pw_add_module_facade(pw_interrupt.context
BACKEND
pw_interrupt.context_BACKEND
HEADERS
public/pw_interrupt/context.h
PUBLIC_INCLUDES
Expand Down
19 changes: 19 additions & 0 deletions pw_interrupt/backend.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# 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_guard(GLOBAL)

include($ENV{PW_ROOT}/pw_build/pigweed.cmake)

# Backends for the pw_interrupt module.
pw_add_backend_variable(pw_interrupt.context_BACKEND)
2 changes: 1 addition & 1 deletion pw_interrupt/backend.gni
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
# the License.

declare_args() {
# Backend for the pw_interrupt module.
# Backends for the pw_interrupt module.
pw_interrupt_CONTEXT_BACKEND = ""
}
3 changes: 3 additions & 0 deletions pw_log/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# the License.

include($ENV{PW_ROOT}/pw_build/pigweed.cmake)
include($ENV{PW_ROOT}/pw_log/backend.cmake)
include($ENV{PW_ROOT}/pw_protobuf_compiler/proto.cmake)

pw_add_module_config(pw_log_CONFIG)
Expand All @@ -29,6 +30,8 @@ pw_add_module_library(pw_log.config
)

pw_add_module_facade(pw_log
BACKEND
pw_log_BACKEND
HEADERS
public/pw_log/levels.h
public/pw_log/log.h
Expand Down
19 changes: 19 additions & 0 deletions pw_log/backend.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# 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_guard(GLOBAL)

include($ENV{PW_ROOT}/pw_build/pigweed.cmake)

# Backend for the pw_log module.
pw_add_backend_variable(pw_log_BACKEND)
3 changes: 3 additions & 0 deletions pw_log_string/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# the License.

include($ENV{PW_ROOT}/pw_build/pigweed.cmake)
include($ENV{PW_ROOT}/pw_log_string/backend.cmake)

pw_add_module_library(pw_log_string
IMPLEMENTS_FACADES
Expand All @@ -29,6 +30,8 @@ pw_add_module_library(pw_log_string
)

pw_add_module_facade(pw_log_string.handler
BACKEND
pw_log_string.handler_BACKEND
HEADERS
public/pw_log_string/handler.h
PUBLIC_INCLUDES
Expand Down
20 changes: 20 additions & 0 deletions pw_log_string/backend.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# 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_guard(GLOBAL)

include($ENV{PW_ROOT}/pw_build/pigweed.cmake)

# The pw_log_string.handler backend implements the pw_Log C API which is also
# used by the pw_log_string module's implementation of the pw_log facade.
pw_add_backend_variable(pw_log_string.handler_BACKEND)
3 changes: 3 additions & 0 deletions pw_perf_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# the License.

include($ENV{PW_ROOT}/pw_build/pigweed.cmake)
include($ENV{PW_ROOT}/pw_perf_test/backend.cmake)
include($ENV{PW_ROOT}/pw_protobuf_compiler/proto.cmake)

pw_add_module_library(pw_perf_test.duration_unit
Expand All @@ -23,6 +24,8 @@ pw_add_module_library(pw_perf_test.duration_unit
)

pw_add_module_facade(pw_perf_test.timer
BACKEND
pw_perf_test.timer_BACKEND
HEADERS
public/pw_perf_test/internal/timer.h
PUBLIC_INCLUDES
Expand Down
18 changes: 18 additions & 0 deletions pw_perf_test/backend.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# 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_guard(GLOBAL)

include($ENV{PW_ROOT}/pw_build/pigweed.cmake)

pw_add_backend_variable(pw_perf_test.timer_BACKEND)
3 changes: 3 additions & 0 deletions pw_rpc/system_server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@
# the License.

include("$ENV{PW_ROOT}/pw_build/pigweed.cmake")
include($ENV{PW_ROOT}/pw_rpc/system_server/backend.cmake)

pw_add_module_facade(pw_rpc.system_server
BACKEND
pw_rpc.system_server_BACKEND
PUBLIC_DEPS
pw_rpc.server
pw_stream
Expand Down
19 changes: 19 additions & 0 deletions pw_rpc/system_server/backend.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# 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_guard(GLOBAL)

include($ENV{PW_ROOT}/pw_build/pigweed.cmake)

# Backend for the pw_rpc_system_server module.
pw_add_backend_variable(pw_rpc.system_server_BACKEND)
Loading

0 comments on commit 91a55b1

Please sign in to comment.