Skip to content

Commit

Permalink
Added Day 1 ShapeExample tool written in C++.
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Galvan <[email protected]>
  • Loading branch information
cgalvan committed Oct 25, 2021
1 parent 29d5986 commit 7133528
Show file tree
Hide file tree
Showing 49 changed files with 1,198 additions and 0 deletions.
22 changes: 22 additions & 0 deletions cpp_gems/ShapeExample/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# {BEGIN_LICENSE}
# Copyright (c) Contributors to the Open 3D Engine Project.
# For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
# {END_LICENSE}

set(o3de_gem_path ${CMAKE_CURRENT_LIST_DIR})
set(o3de_gem_json ${o3de_gem_path}/gem.json)
o3de_read_json_key(o3de_gem_name ${o3de_gem_json} "gem_name")
o3de_restricted_path(${o3de_gem_json} o3de_gem_restricted_path)

ly_get_list_relative_pal_filename(pal_dir ${CMAKE_CURRENT_LIST_DIR}/Platform/${PAL_PLATFORM_NAME} "${o3de_gem_restricted_path}" ${o3de_gem_path} ${o3de_gem_name})

# Now that we have the platform abstraction layer (PAL) folder for this folder, thats where we will find the
# project cmake for this platform.
include(${pal_dir}/${PAL_PLATFORM_NAME_LOWERCASE}_gem.cmake)

ly_add_external_target_path(${CMAKE_CURRENT_LIST_DIR}/3rdParty)

add_subdirectory(Code)
168 changes: 168 additions & 0 deletions cpp_gems/ShapeExample/Code/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
#
# Copyright (c) Contributors to the Open 3D Engine Project.
# For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
#

# Currently we are in the Code folder: ${CMAKE_CURRENT_LIST_DIR}
# Get the platform specific folder ${pal_dir} for the current folder: ${CMAKE_CURRENT_LIST_DIR}/Platform/${PAL_PLATFORM_NAME}
# Note: ly_get_list_relative_pal_filename will take care of the details for us, as this may be a restricted platform
# in which case it will see if that platform is present here or in the restricted folder.
# i.e. It could here in our gem : Gems/ShapeExample/Code/Platform/<platorm_name> or
# <restricted_folder>/<platform_name>/Gems/ShapeExample/Code
ly_get_list_relative_pal_filename(pal_dir ${CMAKE_CURRENT_LIST_DIR}/Platform/${PAL_PLATFORM_NAME} ${o3de_gem_restricted_path} ${o3de_gem_path} ${o3de_gem_name})

# Now that we have the platform abstraction layer (PAL) folder for this folder, thats where we will find the
# traits for this platform. Traits for a platform are defines for things like whether or not something in this gem
# is supported by this platform.
include(${pal_dir}/PAL_${PAL_PLATFORM_NAME_LOWERCASE}.cmake)

# Add the ShapeExample.Static target
# Note: We include the common files and the platform specific files which are set in shapeexample_common_files.cmake
# and in ${pal_dir}/shapeexample_${PAL_PLATFORM_NAME_LOWERCASE}_files.cmake
ly_add_target(
NAME ShapeExample.Static STATIC
NAMESPACE Gem
FILES_CMAKE
shapeexample_files.cmake
${pal_dir}/shapeexample_${PAL_PLATFORM_NAME_LOWERCASE}_files.cmake
INCLUDE_DIRECTORIES
PUBLIC
Include
PRIVATE
Source
BUILD_DEPENDENCIES
PUBLIC
AZ::AzCore
AZ::AzFramework
)

# Here add ShapeExample target, it depends on the ShapeExample.Static
ly_add_target(
NAME ShapeExample ${PAL_TRAIT_MONOLITHIC_DRIVEN_MODULE_TYPE}
NAMESPACE Gem
FILES_CMAKE
shapeexample_shared_files.cmake
${pal_dir}/shapeexample_shared_${PAL_PLATFORM_NAME_LOWERCASE}_files.cmake
INCLUDE_DIRECTORIES
PUBLIC
Include
PRIVATE
Source
BUILD_DEPENDENCIES
PRIVATE
Gem::ShapeExample.Static
)

# By default, we will specify that the above target ShapeExample would be used by
# Client and Server type targets when this gem is enabled. If you don't want it
# active in Clients or Servers by default, delete one of both of the following lines:
ly_create_alias(NAME ShapeExample.Clients NAMESPACE Gem TARGETS Gem::ShapeExample)
ly_create_alias(NAME ShapeExample.Servers NAMESPACE Gem TARGETS Gem::ShapeExample)

# If we are on a host platform, we want to add the host tools targets like the ShapeExample.Editor target which
# will also depend on ShapeExample.Static
if(PAL_TRAIT_BUILD_HOST_TOOLS)
ly_add_target(
NAME ShapeExample.Editor.Static STATIC
NAMESPACE Gem
AUTOMOC
AUTORCC
FILES_CMAKE
shapeexample_editor_files.cmake
INCLUDE_DIRECTORIES
PRIVATE
Source
PUBLIC
Include
BUILD_DEPENDENCIES
PUBLIC
AZ::AzToolsFramework
Gem::ShapeExample.Static
)

ly_add_target(
NAME ShapeExample.Editor GEM_MODULE
NAMESPACE Gem
AUTOMOC
FILES_CMAKE
shapeexample_editor_shared_files.cmake
INCLUDE_DIRECTORIES
PRIVATE
Source
PUBLIC
Include
BUILD_DEPENDENCIES
PUBLIC
Gem::ShapeExample.Editor.Static
)

# By default, we will specify that the above target ShapeExample would be used by
# Tool and Builder type targets when this gem is enabled. If you don't want it
# active in Tools or Builders by default, delete one of both of the following lines:
ly_create_alias(NAME ShapeExample.Tools NAMESPACE Gem TARGETS Gem::ShapeExample.Editor)
ly_create_alias(NAME ShapeExample.Builders NAMESPACE Gem TARGETS Gem::ShapeExample.Editor)


endif()

################################################################################
# Tests
################################################################################
# See if globally, tests are supported
if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
# We globally support tests, see if we support tests on this platform for ShapeExample.Static
if(PAL_TRAIT_SHAPEEXAMPLE_TEST_SUPPORTED)
# We support ShapeExample.Tests on this platform, add ShapeExample.Tests target which depends on ShapeExample.Static
ly_add_target(
NAME ShapeExample.Tests ${PAL_TRAIT_TEST_TARGET_TYPE}
NAMESPACE Gem
FILES_CMAKE
shapeexample_files.cmake
shapeexample_tests_files.cmake
INCLUDE_DIRECTORIES
PRIVATE
Tests
Source
BUILD_DEPENDENCIES
PRIVATE
AZ::AzTest
AZ::AzFramework
Gem::ShapeExample.Static
)

# Add ShapeExample.Tests to googletest
ly_add_googletest(
NAME Gem::ShapeExample.Tests
)
endif()

# If we are a host platform we want to add tools test like editor tests here
if(PAL_TRAIT_BUILD_HOST_TOOLS)
# We are a host platform, see if Editor tests are supported on this platform
if(PAL_TRAIT_SHAPEEXAMPLE_EDITOR_TEST_SUPPORTED)
# We support ShapeExample.Editor.Tests on this platform, add ShapeExample.Editor.Tests target which depends on ShapeExample.Editor
ly_add_target(
NAME ShapeExample.Editor.Tests ${PAL_TRAIT_TEST_TARGET_TYPE}
NAMESPACE Gem
FILES_CMAKE
shapeexample_editor_tests_files.cmake
INCLUDE_DIRECTORIES
PRIVATE
Tests
Source
BUILD_DEPENDENCIES
PRIVATE
AZ::AzTest
Gem::ShapeExample.Editor
)

# Add ShapeExample.Editor.Tests to googletest
ly_add_googletest(
NAME Gem::ShapeExample.Editor.Tests
)
endif()
endif()
endif()
38 changes: 38 additions & 0 deletions cpp_gems/ShapeExample/Code/Include/ShapeExample/ShapeExampleBus.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/

#pragma once

#include <AzCore/EBus/EBus.h>
#include <AzCore/Interface/Interface.h>

namespace ShapeExample
{
class ShapeExampleRequests
{
public:
AZ_RTTI(ShapeExampleRequests, "{6c820bf6-e166-4ca6-a817-68a9ee27b837}");
virtual ~ShapeExampleRequests() = default;
// Put your public methods here
};

class ShapeExampleBusTraits
: public AZ::EBusTraits
{
public:
//////////////////////////////////////////////////////////////////////////
// EBusTraits overrides
static constexpr AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
static constexpr AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
//////////////////////////////////////////////////////////////////////////
};

using ShapeExampleRequestBus = AZ::EBus<ShapeExampleRequests, ShapeExampleBusTraits>;
using ShapeExampleInterface = AZ::Interface<ShapeExampleRequests>;

} // namespace ShapeExample
11 changes: 11 additions & 0 deletions cpp_gems/ShapeExample/Code/Platform/Android/PAL_android.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#
# Copyright (c) Contributors to the Open 3D Engine Project.
# For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
#

set(PAL_TRAIT_SHAPEEXAMPLE_SUPPORTED TRUE)
set(PAL_TRAIT_SHAPEEXAMPLE_TEST_SUPPORTED TRUE)
set(PAL_TRAIT_SHAPEEXAMPLE_EDITOR_TEST_SUPPORTED FALSE)
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#
# Copyright (c) Contributors to the Open 3D Engine Project.
# For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
#

# Platform specific files for Android
# i.e. ../Source/Android/ShapeExampleAndroid.cpp
# ../Source/Android/ShapeExampleAndroid.h
# ../Include/Android/ShapeExampleAndroid.h

set(FILES
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#
# Copyright (c) Contributors to the Open 3D Engine Project.
# For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
#

# Platform specific files for Android
# i.e. ../Source/Android/ShapeExampleAndroid.cpp
# ../Source/Android/ShapeExampleAndroid.h
# ../Include/Android/ShapeExampleAndroid.h

set(FILES
)
11 changes: 11 additions & 0 deletions cpp_gems/ShapeExample/Code/Platform/Linux/PAL_linux.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#
# Copyright (c) Contributors to the Open 3D Engine Project.
# For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
#

set(PAL_TRAIT_SHAPEEXAMPLE_SUPPORTED TRUE)
set(PAL_TRAIT_SHAPEEXAMPLE_TEST_SUPPORTED TRUE)
set(PAL_TRAIT_SHAPEEXAMPLE_EDITOR_TEST_SUPPORTED TRUE)
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#
# Copyright (c) Contributors to the Open 3D Engine Project.
# For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
#

# Platform specific files for Linux
# i.e. ../Source/Linux/ShapeExampleLinux.cpp
# ../Source/Linux/ShapeExampleLinux.h
# ../Include/Linux/ShapeExampleLinux.h

set(FILES
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#
# Copyright (c) Contributors to the Open 3D Engine Project.
# For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
#

# Platform specific files for Linux
# i.e. ../Source/Linux/ShapeExampleLinux.cpp
# ../Source/Linux/ShapeExampleLinux.h
# ../Include/Linux/ShapeExampleLinux.h

set(FILES
)
11 changes: 11 additions & 0 deletions cpp_gems/ShapeExample/Code/Platform/Mac/PAL_mac.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#
# Copyright (c) Contributors to the Open 3D Engine Project.
# For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
#

set(PAL_TRAIT_SHAPEEXAMPLE_SUPPORTED TRUE)
set(PAL_TRAIT_SHAPEEXAMPLE_TEST_SUPPORTED TRUE)
set(PAL_TRAIT_SHAPEEXAMPLE_EDITOR_TEST_SUPPORTED TRUE)
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#
# Copyright (c) Contributors to the Open 3D Engine Project.
# For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
#

# Platform specific files for Mac
# i.e. ../Source/Mac/ShapeExampleMac.cpp
# ../Source/Mac/ShapeExampleMac.h
# ../Include/Mac/ShapeExampleMac.h

set(FILES
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#
# Copyright (c) Contributors to the Open 3D Engine Project.
# For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
#

# Platform specific files for Mac
# i.e. ../Source/Mac/ShapeExampleMac.cpp
# ../Source/Mac/ShapeExampleMac.h
# ../Include/Mac/ShapeExampleMac.h

set(FILES
)
11 changes: 11 additions & 0 deletions cpp_gems/ShapeExample/Code/Platform/Windows/PAL_windows.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#
# Copyright (c) Contributors to the Open 3D Engine Project.
# For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
#

set(PAL_TRAIT_SHAPEEXAMPLE_SUPPORTED TRUE)
set(PAL_TRAIT_SHAPEEXAMPLE_TEST_SUPPORTED TRUE)
set(PAL_TRAIT_SHAPEEXAMPLE_EDITOR_TEST_SUPPORTED TRUE)
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#
# Copyright (c) Contributors to the Open 3D Engine Project.
# For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
#

# Platform specific files for Windows
# i.e. ../Source/Windows/ShapeExampleWindows.cpp
# ../Source/Windows/ShapeExampleWindows.h
# ../Include/Windows/ShapeExampleWindows.h

set(FILES
)
Loading

0 comments on commit 7133528

Please sign in to comment.