Skip to content

Commit

Permalink
Use experimental::fs if fs is not supported (MeteoSwiss-APN#640)
Browse files Browse the repository at this point in the history
## Technical Description

Use std::experimental::filesystem if std::filesystem is not supported, i.e. gcc < 8.
  • Loading branch information
havogt authored and mroethlin committed Jan 23, 2020
1 parent d933ffe commit 2662ecb
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
10 changes: 4 additions & 6 deletions dawn/src/dawn/Compiler/DawnCompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,14 @@
#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"
#include "dawn/Support/Unreachable.h"
#include "dawn/Validator/GridTypeChecker.h"
#include "dawn/Validator/LocationTypeChecker.h"

#include <filesystem>

namespace dawn {

namespace {
Expand Down Expand Up @@ -236,9 +235,8 @@ std::unique_ptr<OptimizerContext> DawnCompiler::runOptimizer(std::shared_ptr<SIR
<< instantiation->getName() << "`";

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<std::string>(p.stem()) + "." + std::to_string(i) +
".iir",
instantiation, serializationKind);
Expand Down Expand Up @@ -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
} // namespace dawn
26 changes: 26 additions & 0 deletions dawn/src/dawn/Support/FileSystem.h
Original file line number Diff line number Diff line change
@@ -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(<filesystem>)
#include <filesystem>
namespace fs = std::filesystem;
#elif __has_include(<experimental/filesystem>)
#include <experimental/filesystem>
namespace fs = std::experimental::filesystem;
#endif

#endif

0 comments on commit 2662ecb

Please sign in to comment.