Line |
Branch |
Exec |
Source |
1 |
|
|
// Copyright (c) 2021-2025 ChilliBits. All rights reserved. |
2 |
|
|
|
3 |
|
|
#pragma once |
4 |
|
|
|
5 |
|
|
#include <filesystem> |
6 |
|
|
#include <string> |
7 |
|
|
|
8 |
|
|
namespace spice::compiler { |
9 |
|
|
|
10 |
|
|
// Forward declarations |
11 |
|
|
struct CliOptions; |
12 |
|
|
|
13 |
|
|
struct ExecResult { |
14 |
|
|
std::string output; |
15 |
|
|
int exitCode; |
16 |
|
|
}; |
17 |
|
|
|
18 |
|
|
struct ExternalBinaryFinderResult { |
19 |
|
|
const char* name; |
20 |
|
|
std::string path; |
21 |
|
|
}; |
22 |
|
|
|
23 |
|
|
/** |
24 |
|
|
* Util class for file-related work |
25 |
|
|
*/ |
26 |
|
|
class FileUtil { |
27 |
|
|
public: |
28 |
|
|
static void writeToFile(const std::filesystem::path &filePath, const std::string &fileContent); |
29 |
|
|
static std::string getFileContent(const std::filesystem::path &filePath); |
30 |
|
|
static size_t getLineCount(const std::filesystem::path &filePath); |
31 |
|
|
static ExecResult exec(const std::string &command, bool redirectStdErrToStdOut = false); |
32 |
|
|
static bool isCommandAvailable(const std::string &cmd); |
33 |
|
|
static bool isGraphvizInstalled(); |
34 |
|
|
static ExternalBinaryFinderResult findLinkerInvoker(); |
35 |
|
|
static ExternalBinaryFinderResult findLinker(const CliOptions& cliOptions); |
36 |
|
|
static std::filesystem::path getStdDir(); |
37 |
|
|
static std::filesystem::path getBootstrapDir(); |
38 |
|
|
static std::filesystem::path getSpiceBinDir(); |
39 |
|
|
}; |
40 |
|
|
|
41 |
|
|
} // namespace spice::compiler |
42 |
|
|
|