Skip to content

Commit f2b246f

Browse files
committed
Add ViewportStreamer Gem
1 parent 864000e commit f2b246f

File tree

48 files changed

+894
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+894
-0
lines changed

Gems/ViewportStreamer/.gitignore

Whitespace-only changes.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
o3de_gem_setup("ViewportStreamer")
3+
4+
ly_add_external_target_path(${CMAKE_CURRENT_SOURCE_DIR}/3rdParty)
5+
6+
add_subdirectory(Code)
Lines changed: 252 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,252 @@
1+
2+
# Currently we are in the Code folder: ${CMAKE_CURRENT_LIST_DIR}
3+
# Get the platform specific folder ${pal_dir} for the current folder: ${CMAKE_CURRENT_LIST_DIR}/Platform/${PAL_PLATFORM_NAME}
4+
# Note: o3de_pal_dir will take care of the details for us, as this may be a restricted platform
5+
# in which case it will see if that platform is present here or in the restricted folder.
6+
# i.e. It could here in our gem : Gems/ViewportStreamer/Code/Platform/<platorm_name> or
7+
# <restricted_folder>/<platform_name>/Gems/ViewportStreamer/Code
8+
o3de_pal_dir(pal_dir ${CMAKE_CURRENT_LIST_DIR}/Platform/${PAL_PLATFORM_NAME} "${gem_restricted_path}" "${gem_path}" "${gem_parent_relative_path}")
9+
10+
# Now that we have the platform abstraction layer (PAL) folder for this folder, thats where we will find the
11+
# traits for this platform. Traits for a platform are defines for things like whether or not something in this gem
12+
# is supported by this platform.
13+
include(${pal_dir}/PAL_${PAL_PLATFORM_NAME_LOWERCASE}.cmake)
14+
15+
# Check to see if building the Gem Modules are supported for the current platform
16+
if(NOT PAL_TRAIT_VIEWPORTSTREAMER_SUPPORTED)
17+
return()
18+
endif()
19+
20+
# The ${gem_name}.API target declares the common interface that users of this gem should depend on in their targets
21+
ly_add_target(
22+
NAME ${gem_name}.API INTERFACE
23+
NAMESPACE Gem
24+
FILES_CMAKE
25+
viewportstreamer_api_files.cmake
26+
${pal_dir}/viewportstreamer_api_files.cmake
27+
INCLUDE_DIRECTORIES
28+
INTERFACE
29+
Include
30+
BUILD_DEPENDENCIES
31+
INTERFACE
32+
AZ::AzCore
33+
)
34+
35+
# The ${gem_name}.Private.Object target is an internal target
36+
# It should not be used outside of this Gems CMakeLists.txt
37+
ly_add_target(
38+
NAME ${gem_name}.Private.Object STATIC
39+
NAMESPACE Gem
40+
FILES_CMAKE
41+
viewportstreamer_private_files.cmake
42+
${pal_dir}/viewportstreamer_private_files.cmake
43+
TARGET_PROPERTIES
44+
O3DE_PRIVATE_TARGET TRUE
45+
INCLUDE_DIRECTORIES
46+
PRIVATE
47+
Include
48+
Source
49+
BUILD_DEPENDENCIES
50+
PUBLIC
51+
AZ::AzCore
52+
AZ::AzFramework
53+
Gem::Atom_RPI.Public
54+
Gem::ROS2.Static
55+
)
56+
57+
58+
target_depends_on_ros2_packages(${gem_name}.Private.Object rclcpp sensor_msgs)
59+
60+
# Here add ${gem_name} target, it depends on the Private Object library and Public API interface
61+
ly_add_target(
62+
NAME ${gem_name} ${PAL_TRAIT_MONOLITHIC_DRIVEN_MODULE_TYPE}
63+
NAMESPACE Gem
64+
FILES_CMAKE
65+
viewportstreamer_shared_files.cmake
66+
${pal_dir}/viewportstreamer_shared_files.cmake
67+
INCLUDE_DIRECTORIES
68+
PUBLIC
69+
Include
70+
PRIVATE
71+
Source
72+
BUILD_DEPENDENCIES
73+
PUBLIC
74+
Gem::${gem_name}.API
75+
PRIVATE
76+
Gem::${gem_name}.Private.Object
77+
)
78+
79+
# Include the gem name into the Client Module source file
80+
# for use with the AZ_DECLARE_MODULE_CLASS macro
81+
# This is to allow renaming of the gem to also cause
82+
# the CreateModuleClass_Gem_<gem-name> function which
83+
# is used to bootstrap the gem in monolithic builds to link to the new gem name
84+
ly_add_source_properties(
85+
SOURCES
86+
Source/Clients/ViewportStreamerModule.cpp
87+
PROPERTY COMPILE_DEFINITIONS
88+
VALUES
89+
O3DE_GEM_NAME=${gem_name}
90+
O3DE_GEM_VERSION=${gem_version})
91+
92+
# By default, we will specify that the above target ${gem_name} would be used by
93+
# Client and Server type targets when this gem is enabled. If you don't want it
94+
# active in Clients or Servers by default, delete one of both of the following lines:
95+
ly_create_alias(NAME ${gem_name}.Clients NAMESPACE Gem TARGETS Gem::${gem_name})
96+
ly_create_alias(NAME ${gem_name}.Servers NAMESPACE Gem TARGETS Gem::${gem_name})
97+
ly_create_alias(NAME ${gem_name}.Unified NAMESPACE Gem TARGETS Gem::${gem_name})
98+
99+
# For the Client and Server variants of ${gem_name} Gem, an alias to the ${gem_name}.API target will be made
100+
ly_create_alias(NAME ${gem_name}.Clients.API NAMESPACE Gem TARGETS Gem::${gem_name}.API)
101+
ly_create_alias(NAME ${gem_name}.Servers.API NAMESPACE Gem TARGETS Gem::${gem_name}.API)
102+
ly_create_alias(NAME ${gem_name}.Unified.API NAMESPACE Gem TARGETS Gem::${gem_name}.API)
103+
104+
# Add in CMake dependencies for each gem dependency listed in this gem's gem.json file
105+
# for the Clients, Servers, Unified gem variants
106+
o3de_add_variant_dependencies_for_gem_dependencies(GEM_NAME ${gem_name} VARIANTS Clients Servers Unified)
107+
108+
# If we are on a host platform, we want to add the host tools targets like the ${gem_name}.Editor MODULE target
109+
if(PAL_TRAIT_BUILD_HOST_TOOLS)
110+
# The ${gem_name}.Editor.API target can be used by other gems that want to interact with the ${gem_name}.Editor module
111+
ly_add_target(
112+
NAME ${gem_name}.Editor.API INTERFACE
113+
NAMESPACE Gem
114+
FILES_CMAKE
115+
viewportstreamer_editor_api_files.cmake
116+
${pal_dir}/viewportstreamer_editor_api_files.cmake
117+
INCLUDE_DIRECTORIES
118+
INTERFACE
119+
Include
120+
BUILD_DEPENDENCIES
121+
INTERFACE
122+
AZ::AzToolsFramework
123+
)
124+
125+
# The ${gem_name}.Editor.Private.Object target is an internal target
126+
# which is only to be used by this gems CMakeLists.txt and any subdirectories
127+
# Other gems should not use this target
128+
ly_add_target(
129+
NAME ${gem_name}.Editor.Private.Object STATIC
130+
NAMESPACE Gem
131+
FILES_CMAKE
132+
viewportstreamer_editor_private_files.cmake
133+
TARGET_PROPERTIES
134+
O3DE_PRIVATE_TARGET TRUE
135+
INCLUDE_DIRECTORIES
136+
PRIVATE
137+
Include
138+
Source
139+
BUILD_DEPENDENCIES
140+
PUBLIC
141+
AZ::AzToolsFramework
142+
${gem_name}.Private.Object
143+
)
144+
145+
target_depends_on_ros2_packages(${gem_name}.Editor.Private.Object rclcpp sensor_msgs)
146+
147+
ly_add_target(
148+
NAME ${gem_name}.Editor GEM_MODULE
149+
NAMESPACE Gem
150+
AUTOMOC
151+
FILES_CMAKE
152+
viewportstreamer_editor_shared_files.cmake
153+
INCLUDE_DIRECTORIES
154+
PRIVATE
155+
Source
156+
PUBLIC
157+
Include
158+
BUILD_DEPENDENCIES
159+
PUBLIC
160+
Gem::${gem_name}.Editor.API
161+
PRIVATE
162+
Gem::${gem_name}.Editor.Private.Object
163+
)
164+
165+
# Include the gem name into the Editor Module source file
166+
# for use with the AZ_DECLARE_MODULE_CLASS macro
167+
# This is to allow renaming of the gem to also cause
168+
# the CreateModuleClass_Gem_<gem-name> function which
169+
# is used to bootstrap the gem in monolithic builds to link to the new gem name
170+
ly_add_source_properties(
171+
SOURCES
172+
Source/Tools/ViewportStreamerEditorModule.cpp
173+
PROPERTY COMPILE_DEFINITIONS
174+
VALUES
175+
O3DE_GEM_NAME=${gem_name}
176+
O3DE_GEM_VERSION=${gem_version})
177+
178+
# By default, we will specify that the above target ${gem_name} would be used by
179+
# Tool and Builder type targets when this gem is enabled. If you don't want it
180+
# active in Tools or Builders by default, delete one of both of the following lines:
181+
ly_create_alias(NAME ${gem_name}.Tools NAMESPACE Gem TARGETS Gem::${gem_name}.Editor)
182+
ly_create_alias(NAME ${gem_name}.Builders NAMESPACE Gem TARGETS Gem::${gem_name}.Editor)
183+
184+
# For the Tools and Builders variants of ${gem_name} Gem, an alias to the ${gem_name}.Editor API target will be made
185+
ly_create_alias(NAME ${gem_name}.Tools.API NAMESPACE Gem TARGETS Gem::${gem_name}.Editor.API)
186+
ly_create_alias(NAME ${gem_name}.Builders.API NAMESPACE Gem TARGETS Gem::${gem_name}.Editor.API)
187+
188+
# Add in CMake dependencies for each gem dependency listed in this gem's gem.json file
189+
# for the Tools and Builders gem variants
190+
o3de_add_variant_dependencies_for_gem_dependencies(GEM_NAME ${gem_name} VARIANTS Tools Builders)
191+
endif()
192+
193+
################################################################################
194+
# Tests
195+
################################################################################
196+
# See if globally, tests are supported
197+
if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
198+
# We globally support tests, see if we support tests on this platform for ${gem_name}.Tests
199+
if(PAL_TRAIT_VIEWPORTSTREAMER_TEST_SUPPORTED)
200+
# We support ${gem_name}.Tests on this platform, add dependency on the Private Object target
201+
ly_add_target(
202+
NAME ${gem_name}.Tests ${PAL_TRAIT_TEST_TARGET_TYPE}
203+
NAMESPACE Gem
204+
FILES_CMAKE
205+
viewportstreamer_tests_files.cmake
206+
INCLUDE_DIRECTORIES
207+
PRIVATE
208+
Tests
209+
Source
210+
Include
211+
BUILD_DEPENDENCIES
212+
PRIVATE
213+
AZ::AzTest
214+
AZ::AzFramework
215+
Gem::${gem_name}.Private.Object
216+
)
217+
218+
# Add ${gem_name}.Tests to googletest
219+
ly_add_googletest(
220+
NAME Gem::${gem_name}.Tests
221+
)
222+
endif()
223+
224+
# If we are a host platform we want to add tools test like editor tests here
225+
if(PAL_TRAIT_BUILD_HOST_TOOLS)
226+
# We are a host platform, see if Editor tests are supported on this platform
227+
if(PAL_TRAIT_VIEWPORTSTREAMER_EDITOR_TEST_SUPPORTED)
228+
# We support ${gem_name}.Editor.Tests on this platform, add ${gem_name}.Editor.Tests target which depends on
229+
# private ${gem_name}.Editor.Private.Object target
230+
ly_add_target(
231+
NAME ${gem_name}.Editor.Tests ${PAL_TRAIT_TEST_TARGET_TYPE}
232+
NAMESPACE Gem
233+
FILES_CMAKE
234+
viewportstreamer_editor_tests_files.cmake
235+
INCLUDE_DIRECTORIES
236+
PRIVATE
237+
Tests
238+
Source
239+
Include
240+
BUILD_DEPENDENCIES
241+
PRIVATE
242+
AZ::AzTest
243+
Gem::${gem_name}.Editor.Private.Object
244+
)
245+
246+
# Add ${gem_name}.Editor.Tests to googletest
247+
ly_add_googletest(
248+
NAME Gem::${gem_name}.Editor.Tests
249+
)
250+
endif()
251+
endif()
252+
endif()
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
#pragma once
3+
4+
namespace ViewportStreamer
5+
{
6+
// System Component TypeIds
7+
inline constexpr const char* ViewportStreamerComponentTypeId = "{1EF0EC12-33C2-45B7-B637-CAAF8DF7C25A}";
8+
9+
// Module derived classes TypeIds
10+
inline constexpr const char* ViewportStreamerModuleInterfaceTypeId = "{5C5BB679-067D-450E-8A11-A5E52DFF9B34}";
11+
inline constexpr const char* ViewportStreamerModuleTypeId = "{15FBBD78-71BC-4D43-B8E5-51AEC20DBE67}";
12+
// The Editor Module by default is mutually exclusive with the Client Module
13+
// so they use the Same TypeId
14+
inline constexpr const char* ViewportStreamerEditorModuleTypeId = ViewportStreamerModuleTypeId;
15+
} // namespace ViewportStreamer
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
set(PAL_TRAIT_VIEWPORTSTREAMER_SUPPORTED TRUE)
3+
set(PAL_TRAIT_VIEWPORTSTREAMER_TEST_SUPPORTED FALSE)
4+
set(PAL_TRAIT_VIEWPORTSTREAMER_EDITOR_TEST_SUPPORTED FALSE)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
set(FILES
3+
)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
# Platform specific files for Android
3+
# i.e. ../Source/Android/ViewportStreamerAndroid.cpp
4+
# ../Source/Android/ViewportStreamerAndroid.h
5+
# ../Include/Android/ViewportStreamerAndroid.h
6+
7+
set(FILES
8+
)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
# Platform specific files for Android
3+
# i.e. ../Source/Android/ViewportStreamerAndroid.cpp
4+
# ../Source/Android/ViewportStreamerAndroid.h
5+
# ../Include/Android/ViewportStreamerAndroid.h
6+
7+
set(FILES
8+
)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
set(PAL_TRAIT_VIEWPORTSTREAMER_SUPPORTED TRUE)
3+
set(PAL_TRAIT_VIEWPORTSTREAMER_TEST_SUPPORTED FALSE)
4+
set(PAL_TRAIT_VIEWPORTSTREAMER_EDITOR_TEST_SUPPORTED FALSE)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
set(FILES
3+
)

0 commit comments

Comments
 (0)