From 9e8dff7d42fc47fa4f2285ea6ae806f4715e7807 Mon Sep 17 00:00:00 2001 From: Arcady Goldmints-Orlov Date: Thu, 21 Sep 2023 16:26:59 -0400 Subject: [PATCH] Move definition of GLSLANG_EXPORT to visibility.h The GLSLANG_EXPORT macro is already used (and defined) in two separate places and will be used in a few more in the near future. To reduce duplication it is now in its own header. --- glslang/CMakeLists.txt | 1 + glslang/Include/glslang_c_interface.h | 17 +-------- glslang/Include/visibility.h | 51 +++++++++++++++++++++++++++ glslang/Public/ShaderLang.h | 17 +-------- 4 files changed, 54 insertions(+), 32 deletions(-) create mode 100644 glslang/Include/visibility.h diff --git a/glslang/CMakeLists.txt b/glslang/CMakeLists.txt index 7fc0d87a4..4beb1da33 100644 --- a/glslang/CMakeLists.txt +++ b/glslang/CMakeLists.txt @@ -261,6 +261,7 @@ if(GLSLANG_ENABLE_INSTALL) Include/glslang_c_shader_types.h Include/ResourceLimits.h MachineIndependent/iomapper.h + Include/visibility.h MachineIndependent/Versions.h) foreach(file ${PUBLIC_HEADERS}) diff --git a/glslang/Include/glslang_c_interface.h b/glslang/Include/glslang_c_interface.h index a78b9f5df..cbf10b455 100644 --- a/glslang/Include/glslang_c_interface.h +++ b/glslang/Include/glslang_c_interface.h @@ -37,6 +37,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include "glslang_c_shader_types.h" +#include "visibility.h" typedef struct glslang_shader_s glslang_shader_t; typedef struct glslang_program_s glslang_program_t; @@ -244,22 +245,6 @@ typedef struct glslang_spv_options_s { extern "C" { #endif -#ifdef GLSLANG_IS_SHARED_LIBRARY - #ifdef _WIN32 - #ifdef GLSLANG_EXPORTING - #define GLSLANG_EXPORT __declspec(dllexport) - #else - #define GLSLANG_EXPORT __declspec(dllimport) - #endif - #elif __GNUC__ >= 4 - #define GLSLANG_EXPORT __attribute__((visibility("default"))) - #endif -#endif // GLSLANG_IS_SHARED_LIBRARY - -#ifndef GLSLANG_EXPORT -#define GLSLANG_EXPORT -#endif - GLSLANG_EXPORT void glslang_get_version(glslang_version_t* version); GLSLANG_EXPORT int glslang_initialize_process(void); diff --git a/glslang/Include/visibility.h b/glslang/Include/visibility.h new file mode 100644 index 000000000..d6b6bb343 --- /dev/null +++ b/glslang/Include/visibility.h @@ -0,0 +1,51 @@ +// +// Copyright (C) 2023 LunarG, Inc. +// +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// +// Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// +// Neither the name of 3Dlabs Inc. Ltd. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +// COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// +#ifdef GLSLANG_IS_SHARED_LIBRARY + #ifdef _WIN32 + #ifdef GLSLANG_EXPORTING + #define GLSLANG_EXPORT __declspec(dllexport) + #else + #define GLSLANG_EXPORT __declspec(dllimport) + #endif + #elif __GNUC__ >= 4 + #define GLSLANG_EXPORT __attribute__((visibility("default"))) + #endif +#endif // GLSLANG_IS_SHARED_LIBRARY + +#ifndef GLSLANG_EXPORT +#define GLSLANG_EXPORT +#endif + + diff --git a/glslang/Public/ShaderLang.h b/glslang/Public/ShaderLang.h index 9e8398c8e..d78803071 100644 --- a/glslang/Public/ShaderLang.h +++ b/glslang/Public/ShaderLang.h @@ -38,6 +38,7 @@ #define _COMPILER_INTERFACE_INCLUDED_ #include "../Include/ResourceLimits.h" +#include "../Include/visibility.h" #include "../MachineIndependent/Versions.h" #include @@ -49,22 +50,6 @@ #define C_DECL #endif -#ifdef GLSLANG_IS_SHARED_LIBRARY - #ifdef _WIN32 - #ifdef GLSLANG_EXPORTING - #define GLSLANG_EXPORT __declspec(dllexport) - #else - #define GLSLANG_EXPORT __declspec(dllimport) - #endif - #elif __GNUC__ >= 4 - #define GLSLANG_EXPORT __attribute__((visibility("default"))) - #endif -#endif // GLSLANG_IS_SHARED_LIBRARY - -#ifndef GLSLANG_EXPORT -#define GLSLANG_EXPORT -#endif - // // This is the platform independent interface between an OGL driver // and the shading language compiler/linker.