From 2662ecb03436b2efe466f0aa8dc528269befcbd4 Mon Sep 17 00:00:00 2001 From: Hannes Vogt Date: Thu, 23 Jan 2020 11:13:21 +0100 Subject: [PATCH] Use experimental::fs if fs is not supported (#640) ## Technical Description Use std::experimental::filesystem if std::filesystem is not supported, i.e. gcc < 8. --- dawn/src/dawn/Compiler/DawnCompiler.cpp | 10 ++++------ dawn/src/dawn/Support/FileSystem.h | 26 +++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 6 deletions(-) create mode 100644 dawn/src/dawn/Support/FileSystem.h diff --git a/dawn/src/dawn/Compiler/DawnCompiler.cpp b/dawn/src/dawn/Compiler/DawnCompiler.cpp index fb0f1e3ab..74ead87d9 100644 --- a/dawn/src/dawn/Compiler/DawnCompiler.cpp +++ b/dawn/src/dawn/Compiler/DawnCompiler.cpp @@ -48,6 +48,7 @@ #include "dawn/Serialization/IIRSerializer.h" #include "dawn/Support/Array.h" #include "dawn/Support/EditDistance.h" +#include "dawn/Support/FileSystem.h" #include "dawn/Support/Logging.h" #include "dawn/Support/StringSwitch.h" #include "dawn/Support/StringUtil.h" @@ -55,8 +56,6 @@ #include "dawn/Validator/GridTypeChecker.h" #include "dawn/Validator/LocationTypeChecker.h" -#include - namespace dawn { namespace { @@ -236,9 +235,8 @@ std::unique_ptr DawnCompiler::runOptimizer(std::shared_ptrgetName() << "`"; if(options_->SerializeIIR) { - const std::filesystem::path p(options_->OutputFile.empty() - ? instantiation->getMetaData().getFileName() - : options_->OutputFile); + const fs::path p(options_->OutputFile.empty() ? instantiation->getMetaData().getFileName() + : options_->OutputFile); IIRSerializer::serialize(static_cast(p.stem()) + "." + std::to_string(i) + ".iir", instantiation, serializationKind); @@ -332,4 +330,4 @@ DiagnosticsEngine& DawnCompiler::getDiagnostics() { return *diagnostics_.get(); const Options& DawnCompiler::getOptions() const { return *options_.get(); } Options& DawnCompiler::getOptions() { return *options_.get(); } -} // namespace dawn \ No newline at end of file +} // namespace dawn diff --git a/dawn/src/dawn/Support/FileSystem.h b/dawn/src/dawn/Support/FileSystem.h new file mode 100644 index 000000000..dca3a30b1 --- /dev/null +++ b/dawn/src/dawn/Support/FileSystem.h @@ -0,0 +1,26 @@ +//===--------------------------------------------------------------------------------*- C++ -*-===// +// _ +// | | +// __| | __ ___ ___ ___ +// / _` |/ _` \ \ /\ / / '_ | +// | (_| | (_| |\ V V /| | | | +// \__,_|\__,_| \_/\_/ |_| |_| - Compiler Toolchain +// +// +// This file is distributed under the MIT License (MIT). +// See LICENSE.txt for details. +// +//===------------------------------------------------------------------------------------------===// + +#ifndef DAWN_SUPPORT_FILESYSTEM_H +#define DAWN_SUPPORT_FILESYSTEM_H + +#if __has_include() +#include +namespace fs = std::filesystem; +#elif __has_include() +#include +namespace fs = std::experimental::filesystem; +#endif + +#endif