Skip to content

Commit 8577df4

Browse files
Replaced PLATFORM_EMSCRIPTEN CMake option and c++ macro with PLATFORM_WEB
1 parent b4e16a8 commit 8577df4

Some content is hidden

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

56 files changed

+171
-168
lines changed

BuildTools/CMake/BuildUtils.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ function(set_common_target_properties TARGET)
210210
endif()
211211
endif() # if(MSVC)
212212

213-
if (PLATFORM_EMSCRIPTEN)
213+
if (PLATFORM_WEB)
214214
if((${CMAKE_BUILD_TYPE} STREQUAL "Debug") AND (TARGET_TYPE STREQUAL EXECUTABLE) AND DILIGENT_EMSCRIPTEN_STRIP_DEBUG_INFO)
215215
# Strip debug info from WebAssembly binary. Without this option, the toolchain crashes on CI.
216216
target_link_options(${TARGET} PRIVATE "SHELL: -gseparate-dwarf -g0")
@@ -249,7 +249,7 @@ endfunction()
249249
function(get_backend_libraries_type _LIB_TYPE)
250250
if(PLATFORM_WIN32 OR PLATFORM_LINUX OR PLATFORM_ANDROID OR PLATFORM_UNIVERSAL_WINDOWS OR PLATFORM_MACOS)
251251
set(LIB_TYPE "shared")
252-
elseif(PLATFORM_IOS OR PLATFORM_TVOS OR PLATFORM_EMSCRIPTEN)
252+
elseif(PLATFORM_IOS OR PLATFORM_TVOS OR PLATFORM_WEB)
253253
# Statically link with the engine on iOS, tvOS and Emscripten.
254254
# It is also possible to link dynamically by
255255
# putting the library into the framework.
@@ -464,7 +464,7 @@ macro(FetchContent_DeclareShallowGit Name GIT_REPOSITORY GitRepository GIT_TAG G
464464
endmacro()
465465

466466
function(set_targets_emscripten_properties)
467-
if (PLATFORM_EMSCRIPTEN)
467+
if (PLATFORM_WEB)
468468
foreach(_TARGET IN LISTS ARGN)
469469
get_target_property(_TARGET_TYPE ${_TARGET} TYPE)
470470
if (_TARGET_TYPE STREQUAL "STATIC_LIBRARY")

CMakeLists.txt

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ set(PLATFORM_LINUX FALSE CACHE INTERNAL "")
4747
set(PLATFORM_MACOS FALSE CACHE INTERNAL "")
4848
set(PLATFORM_IOS FALSE CACHE INTERNAL "")
4949
set(PLATFORM_TVOS FALSE CACHE INTERNAL "")
50+
set(PLATFORM_WEB FALSE CACHE INTERNAL "")
5051
set(PLATFORM_EMSCRIPTEN FALSE CACHE INTERNAL "")
5152
set(D3D11_SUPPORTED FALSE CACHE INTERNAL "D3D11 is not supported")
5253
set(D3D12_SUPPORTED FALSE CACHE INTERNAL "D3D12 is not supported")
@@ -141,8 +142,9 @@ else()
141142
set(PLATFORM_TVOS TRUE CACHE INTERNAL "Target platform: tvOS")
142143
message("Target platform: tvOS " ${ARCH})
143144
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Emscripten")
144-
set(PLATFORM_EMSCRIPTEN TRUE CACHE INTERNAL "Target platform: Emscripten")
145-
message("Target platform: Emscripten " ${ARCH})
145+
set(PLATFORM_WEB TRUE CACHE INTERNAL "Target platform: Web")
146+
set(PLATFORM_EMSCRIPTEN TRUE CACHE INTERNAL "Build with Emscritpen")
147+
message("Target platform: Web " ${ARCH})
146148
else()
147149
message(FATAL_ERROR "Unsupported platform")
148150
endif()
@@ -210,11 +212,11 @@ elseif(PLATFORM_IOS)
210212
target_compile_definitions(Diligent-PublicBuildSettings INTERFACE PLATFORM_IOS=1 PLATFORM_APPLE=1)
211213
elseif(PLATFORM_TVOS)
212214
target_compile_definitions(Diligent-PublicBuildSettings INTERFACE PLATFORM_TVOS=1 PLATFORM_APPLE=1)
213-
elseif(PLATFORM_EMSCRIPTEN)
214-
set(GLES_SUPPORTED TRUE CACHE INTERNAL "OpenGLES is supported on Emscripten platform")
215-
set(WEBGPU_SUPPORTED TRUE CACHE INTERNAL "WebGPU is supported on Emscripten platform")
216-
set(ARCHIVER_SUPPORTED TRUE CACHE INTERNAL "Archiver is supported on Emscripten platform")
217-
target_compile_definitions(Diligent-PublicBuildSettings INTERFACE PLATFORM_EMSCRIPTEN=1)
215+
elseif(PLATFORM_WEB)
216+
set(GLES_SUPPORTED TRUE CACHE INTERNAL "OpenGLES is supported on Web platform")
217+
set(WEBGPU_SUPPORTED TRUE CACHE INTERNAL "WebGPU is supported on Web platform")
218+
set(ARCHIVER_SUPPORTED TRUE CACHE INTERNAL "Archiver is supported on Web platform")
219+
target_compile_definitions(Diligent-PublicBuildSettings INTERFACE PLATFORM_WEB=1 PLATFORM_EMSCRIPTEN=1)
218220
else()
219221
message(FATAL_ERROR "No PLATFORM_XXX variable defined. Make sure that 'DiligentCore' folder is processed first")
220222
endif()
@@ -268,7 +270,7 @@ if(PLATFORM_APPLE)
268270
endif()
269271
endif()
270272

271-
if(PLATFORM_WIN32 OR PLATFORM_LINUX OR PLATFORM_MACOS OR PLATFORM_EMSCRIPTEN)
273+
if(PLATFORM_WIN32 OR PLATFORM_LINUX OR PLATFORM_MACOS OR PLATFORM_WEB)
272274
option(DILIGENT_BUILD_TESTS "Build Diligent Engine tests" OFF)
273275
if(DILIGENT_BUILD_TESTS)
274276
set(DILIGENT_BUILD_CORE_TESTS TRUE CACHE INTERNAL "Build Core tests")
@@ -299,7 +301,7 @@ option(DILIGENT_NO_DIRECT3D12 "Disable Direct3D12 backend" OFF)
299301
option(DILIGENT_NO_OPENGL "Disable OpenGL/GLES backend" OFF)
300302
option(DILIGENT_NO_VULKAN "Disable Vulkan backend" OFF)
301303
option(DILIGENT_NO_METAL "Disable Metal backend" OFF)
302-
if (PLATFORM_EMSCRIPTEN)
304+
if (PLATFORM_WEB)
303305
option(DILIGENT_NO_WEBGPU "Disable WebGPU backend" OFF)
304306
else()
305307
option(DILIGENT_NO_WEBGPU "Disable WebGPU backend" ON)
@@ -370,7 +372,7 @@ endif()
370372

371373
add_library(Diligent-BuildSettings INTERFACE)
372374

373-
if (PLATFORM_EMSCRIPTEN)
375+
if (PLATFORM_WEB)
374376
target_compile_options(Diligent-BuildSettings INTERFACE
375377
"-pthread"
376378
"-mbulk-memory"

Common/interface/StringTools.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019-2022 Diligent Graphics LLC
2+
* Copyright 2019-2025 Diligent Graphics LLC
33
* Copyright 2015-2019 Egor Yusov
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -95,7 +95,7 @@ inline std::wstring WidenString(const std::string& Str)
9595

9696
inline int StrCmpNoCase(const char* Str1, const char* Str2, size_t NumChars)
9797
{
98-
#if PLATFORM_ANDROID || PLATFORM_LINUX || PLATFORM_MACOS || PLATFORM_IOS || PLATFORM_TVOS || PLATFORM_EMSCRIPTEN
98+
#if PLATFORM_ANDROID || PLATFORM_LINUX || PLATFORM_MACOS || PLATFORM_IOS || PLATFORM_TVOS || PLATFORM_WEB
9999
# define _strnicmp strncasecmp
100100
#endif
101101

@@ -104,7 +104,7 @@ inline int StrCmpNoCase(const char* Str1, const char* Str2, size_t NumChars)
104104

105105
inline int StrCmpNoCase(const char* Str1, const char* Str2)
106106
{
107-
#if PLATFORM_ANDROID || PLATFORM_LINUX || PLATFORM_MACOS || PLATFORM_IOS || PLATFORM_TVOS || PLATFORM_EMSCRIPTEN
107+
#if PLATFORM_ANDROID || PLATFORM_LINUX || PLATFORM_MACOS || PLATFORM_IOS || PLATFORM_TVOS || PLATFORM_WEB
108108
# define _stricmp strcasecmp
109109
#endif
110110

Graphics/Archiver/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ if(GL_SUPPORTED OR GLES_SUPPORTED)
148148
target_link_libraries(Diligent-Archiver-static PRIVATE GLEW::glew OpenGL::GL)
149149
elseif(PLATFORM_ANDROID)
150150
target_link_libraries(Diligent-Archiver-static PRIVATE GLESv3 EGL)
151-
elseif(PLATFORM_EMSCRIPTEN)
151+
elseif(PLATFORM_WEB)
152152
else()
153153
message(FATAL_ERROR "Unsupported platform")
154154
endif()
@@ -167,7 +167,7 @@ endif()
167167

168168
if(WEBGPU_SUPPORTED)
169169
target_link_libraries(Diligent-Archiver-static PRIVATE Diligent-GraphicsEngineWebGPU-static)
170-
if (NOT PLATFORM_EMSCRIPTEN)
170+
if (NOT PLATFORM_WEB)
171171
target_link_libraries(Diligent-Archiver-static PRIVATE dawn_native dawn_proc)
172172
endif()
173173
target_include_directories(Diligent-Archiver-static

Graphics/Archiver/interface/ArchiverFactoryLoader.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019-2024 Diligent Graphics LLC
2+
* Copyright 2019-2025 Diligent Graphics LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -28,7 +28,7 @@
2828

2929
#include "ArchiverFactory.h"
3030

31-
#if PLATFORM_ANDROID || PLATFORM_LINUX || PLATFORM_MACOS || PLATFORM_IOS || PLATFORM_TVOS || PLATFORM_EMSCRIPTEN || (PLATFORM_WIN32 && !defined(_MSC_VER))
31+
#if PLATFORM_ANDROID || PLATFORM_LINUX || PLATFORM_MACOS || PLATFORM_IOS || PLATFORM_TVOS || PLATFORM_WEB || (PLATFORM_WIN32 && !defined(_MSC_VER))
3232
// https://gcc.gnu.org/wiki/Visibility
3333
# define API_QUALIFIER __attribute__((visibility("default")))
3434
#elif PLATFORM_WIN32 || PLATFORM_UNIVERSAL_WINDOWS

Graphics/GraphicsEngine/interface/GraphicsTypes.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3546,7 +3546,7 @@ struct EngineCreateInfo
35463546
};
35473547
typedef struct EngineCreateInfo EngineCreateInfo;
35483548

3549-
#if PLATFORM_EMSCRIPTEN
3549+
#if PLATFORM_WEB
35503550
/// WebGL power preference.
35513551
DILIGENT_TYPED_ENUM(WEBGL_POWER_PREFERENCE, Uint8)
35523552
{
@@ -3626,7 +3626,7 @@ struct EngineGLCreateInfo DILIGENT_DERIVE(EngineCreateInfo)
36263626
/// * On Linux this affects the `DRI_PRIME` environment variable that is used by Mesa drivers that support PRIME.
36273627
ADAPTER_TYPE PreferredAdapterType DEFAULT_INITIALIZER(ADAPTER_TYPE_UNKNOWN);
36283628

3629-
#if PLATFORM_EMSCRIPTEN
3629+
#if PLATFORM_WEB
36303630
/// WebGL context attributes.
36313631
WebGLContextAttribs WebGLAttribs;
36323632
#endif

Graphics/GraphicsEngineOpenGL/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ elseif(PLATFORM_IOS)
143143
list(APPEND INCLUDE include/GLStubsIOS.h)
144144
list(APPEND SOURCE src/SwapChainGLIOS.mm)
145145
list(APPEND INCLUDE include/SwapChainGLIOS.hpp)
146-
elseif(PLATFORM_EMSCRIPTEN)
146+
elseif(PLATFORM_WEB)
147147
list(APPEND SOURCE src/GLContextEmscripten.cpp)
148148
list(APPEND SOURCE src/RenderDeviceGLESImpl.cpp)
149149
list(APPEND SOURCE src/SwapChainGLImpl.cpp)
@@ -213,7 +213,7 @@ elseif(PLATFORM_MACOS)
213213
set(PRIVATE_DEPENDENCIES ${PRIVATE_DEPENDENCIES} GLEW::glew OpenGL::GL)
214214
elseif(PLATFORM_IOS)
215215
set(PRIVATE_DEPENDENCIES ${PRIVATE_DEPENDENCIES} ${OPENGLES})
216-
elseif(PLATFORM_EMSCRIPTEN)
216+
elseif(PLATFORM_WEB)
217217
else()
218218
message(FATAL_ERROR "Unknown platform")
219219
endif()
@@ -274,7 +274,7 @@ if(PLATFORM_MACOS)
274274
elseif(PLATFORM_IOS)
275275
# Silence GLES deprecation warnings
276276
target_compile_definitions(Diligent-GraphicsEngineOpenGL-static PUBLIC GLES_SILENCE_DEPRECATION)
277-
elseif(PLATFORM_EMSCRIPTEN)
277+
elseif(PLATFORM_WEB)
278278
target_link_options(Diligent-GraphicsEngineOpenGL-static PUBLIC "SHELL: -s FULL_ES3=1 -s USE_PTHREADS=1")
279279
endif()
280280

Graphics/GraphicsEngineOpenGL/include/BufferGLImpl.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019-2024 Diligent Graphics LLC
2+
* Copyright 2019-2025 Diligent Graphics LLC
33
* Copyright 2015-2019 Egor Yusov
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -95,7 +95,7 @@ class BufferGLImpl final : public BufferBase<EngineGLImplTraits>, public AsyncWr
9595
const Uint32 m_BindTarget;
9696
const GLenum m_GLUsageHint;
9797

98-
#if PLATFORM_EMSCRIPTEN
98+
#if PLATFORM_WEB
9999
struct MappedData
100100
{
101101
std::vector<Uint8> Data;

Graphics/GraphicsEngineOpenGL/include/EngineGLImplTraits.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019-2024 Diligent Graphics LLC
2+
* Copyright 2019-2025 Diligent Graphics LLC
33
* Copyright 2015-2019 Egor Yusov
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -85,7 +85,7 @@ struct EngineGLImplTraits
8585
{
8686
#if PLATFORM_WIN32 || PLATFORM_LINUX || PLATFORM_MACOS
8787
static constexpr auto DeviceType = RENDER_DEVICE_TYPE_GL;
88-
#elif PLATFORM_ANDROID || PLATFORM_IOS || PLATFORM_EMSCRIPTEN
88+
#elif PLATFORM_ANDROID || PLATFORM_IOS || PLATFORM_WEB
8989
static constexpr auto DeviceType = RENDER_DEVICE_TYPE_GL;
9090
#else
9191
# error Unsupported platform

Graphics/GraphicsEngineOpenGL/include/GLContext.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019-2022 Diligent Graphics LLC
2+
* Copyright 2019-2025 Diligent Graphics LLC
33
* Copyright 2015-2019 Egor Yusov
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -37,7 +37,7 @@
3737
# include "GLContextMacOS.hpp"
3838
#elif PLATFORM_IOS
3939
# include "GLContextIOS.hpp"
40-
#elif PLATFORM_EMSCRIPTEN
40+
#elif PLATFORM_WEB
4141
# include "GLContextEmscripten.hpp"
4242
#else
4343
# error Unsupported platform

0 commit comments

Comments
 (0)