fix: fatbinary generation with "-out_dir"

Directories are created if needed before generating fatbinary.

Related-To: NEO-11500

Signed-off-by: Oskar Hubert Weber <oskar.hubert.weber@intel.com>
This commit is contained in:
Oskar Hubert Weber
2024-07-01 12:10:27 +00:00
committed by Compute-Runtime-Automation
parent aed96cede4
commit a7ddf7848b
3 changed files with 34 additions and 6 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2023 Intel Corporation
* Copyright (C) 2018-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -7,6 +7,7 @@
#pragma once
#include <cinttypes>
#include <optional>
#include <string.h>
#include <string>
#include <vector>
@@ -15,9 +16,33 @@ namespace NEO {
namespace Directory {
extern bool returnEmptyFilesVector;
inline constexpr char returnDirs = 1 << 0;
inline constexpr char createDirs = 1 << 1;
std::vector<std::string> getFiles(const std::string &path);
void createDirectory(const std::string &path);
inline std::optional<std::vector<std::string>> getDirectories(const std::string &path, char flags) {
std::optional<std::vector<std::string>> directories;
if (flags & returnDirs) {
directories.emplace();
}
std::string tmp;
size_t pos = 0;
while (pos != std::string::npos) {
pos = path.find_first_of("/\\", pos + 1);
tmp = path.substr(0, pos);
if (flags & createDirs) {
createDirectory(tmp);
}
if (flags & returnDirs) {
directories->push_back(tmp);
}
}
return directories;
}
} // namespace Directory
inline int parseBdfString(const std::string &pciBDF, uint16_t &domain, uint8_t &bus, uint8_t &device, uint8_t &function) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2023 Intel Corporation
* Copyright (C) 2018-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -45,6 +45,7 @@ std::vector<std::string> getFiles(const std::string &path) {
void createDirectory(const std::string &path) {
const mode_t mode = 0777; // 777 in base 8
[[maybe_unused]] auto status = mkdir(path.c_str(), mode);
DEBUG_BREAK_IF(status != 0);
DEBUG_BREAK_IF(status != 0 && errno != EEXIST);
}
}; // namespace NEO::Directory