add glslang

Signed-off-by: zhongning5 <zhongning5@huawei.com>
This commit is contained in:
zhongning5
2024-05-16 19:29:22 +08:00
parent 4cd89d2c99
commit ae7ab6d1de
3 changed files with 60 additions and 24 deletions
+36 -21
View File
@@ -31,6 +31,7 @@
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
import("//build/ohos.gni")
import("build_overrides/glslang.gni")
# Both Chromium and Fuchsia use by default a set of warning errors
@@ -276,9 +277,13 @@ template("glslang_sources_common") {
]
include_dirs += [ "${spirv_tools_dir}/include" ]
}
configs -= _configs_to_remove
configs += _configs_to_add
if (build_ohos_sdk) {
defines += [ "OH_SDK" ]
cflags += [ "-std=c++17" ]
} else {
configs -= _configs_to_remove
configs += _configs_to_add
}
}
}
@@ -288,7 +293,7 @@ glslang_sources_common("glslang_lib_sources") {
}
glslang_sources_common("glslang_sources") {
enable_opt = true
enable_opt = false
enable_hlsl = true
}
@@ -299,20 +304,29 @@ source_set("glslang_default_resource_limits_sources") {
"glslang/ResourceLimits/ResourceLimits.cpp",
]
public_configs = [ ":glslang_public" ]
configs -= _configs_to_remove
configs += _configs_to_add
if (!build_ohos_sdk) {
configs -= _configs_to_remove
configs += _configs_to_add
}
}
executable("glslang_validator") {
ohos_executable("glslang_validator") {
sources = [
"StandAlone/DirStackFileIncluder.h",
"StandAlone/StandAlone.cpp",
]
if (!is_win) {
cflags = [ "-Woverflow" ]
cflags = [
"-Woverflow",
"-std=c++17",
]
} else {
cflags = [ "-std=c++17" ]
}
defines = [ "ENABLE_OPT=1" ]
defines = [
"ENABLE_OPT=1",
"OH_SDK",
]
deps = [
":glslang_build_info",
":glslang_default_resource_limits_sources",
@@ -325,24 +339,25 @@ executable("glslang_validator") {
"${target_gen_dir}/include",
"${spirv_tools_dir}/include",
]
configs -= _configs_to_remove
configs += _configs_to_add
install_enable = true
part_name = "graphic_2d"
subsystem_name = "graphic"
}
executable("spirv-remap") {
ohos_executable("spirv-remap") {
sources = [ "StandAlone/spirv-remap.cpp" ]
defines = [ "ENABLE_OPT=1" ]
defines = [
"ENABLE_OPT=1",
"OH_SDK",
]
deps = [ ":glslang_sources" ]
cflags = [ "-std=c++17" ]
include_dirs = [ "${spirv_tools_dir}/include" ]
configs -= _configs_to_remove
configs += _configs_to_add
install_enable = true
part_name = "graphic_2d"
subsystem_name = "graphic"
}
import("//build/ohos.gni")
group("glslang") {
deps = [
"//third_party/glslang/SPIRV:libdeqp_spirv",
+23 -2
View File
@@ -37,7 +37,11 @@
#include <fstream>
#include <cstring>
#include <stdexcept>
#ifndef OH_SDK
#include <filesystem>
#else
#include <sys/stat.h>
#endif
//
// Include remapper
@@ -90,8 +94,11 @@ namespace {
fp.open(inFilename, std::fstream::in | std::fstream::binary);
if (fp.fail())
#ifndef OH_SDK
errHandler("error opening file for read: ");
#else
errHandler("error opening file for read, errno : " + std::to_string(errno));
#endif // OH_SDK
// Reserve space (for efficiency, not for correctness)
fp.seekg(0, fp.end);
spv.reserve(size_t(fp.tellg()) / sizeof(SpvWord));
@@ -362,6 +369,17 @@ namespace {
} // namespace
#ifdef OH_SDK
static bool IsDirectory(const std::string& path)
{
struct stat info;
if (stat(path.c_str(), &info) != 0) {
return false;
}
return S_ISDIR(info.st_mode);
}
#endif // OH_SDK
int main(int argc, char** argv)
{
std::vector<std::string> inputFiles;
@@ -386,8 +404,11 @@ int main(int argc, char** argv)
const bool isMultiInput = inputFiles.size() > 1;
const bool isMultiOutput = outputDirOrFiles.size() > 1;
#ifndef OH_SDK
const bool isSingleOutputDir = !isMultiOutput && std::filesystem::is_directory(outputDirOrFiles[0]);
#else
const bool isSingleOutputDir = !isMultiOutput && IsDirectory(outputDirOrFiles[0]);
#endif
if (isMultiInput && !isMultiOutput && !isSingleOutputDir)
usage(argv[0], "Output is not a directory.");
+1 -1
View File
@@ -39,7 +39,7 @@
#include <cstdio>
#if !defined(__Fuchsia__)
#if !defined(__Fuchsia__) && !defined(OH_SDK)
#include <sys/resource.h>
#endif