Skip to content

Commit 1754d69

Browse files
committed
overhauled how artifacts are stored in build/
* added `LinkType` and `BuildLinkType` * tried to use `MUUK_TOML_FILE` more * changed `external/tests` to be in line w/ changes * got rid of `PackageType`
1 parent 44f68ff commit 1754d69

File tree

21 files changed

+208
-192
lines changed

21 files changed

+208
-192
lines changed

.github/workflows/build.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ jobs:
220220

221221
- name: Run C++ tests (Windows)
222222
if: runner.os == 'Windows'
223-
run: ./build/debug/test/test.exe
223+
run: ./build/debug/test.exe
224224

225225
# - name: Run C++ tests (Unix)
226226
# if: runner.os != 'Windows'

.vscode/launch.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"name": "(Windows) Build",
99
"type": "cppvsdbg",
1010
"request": "launch",
11-
"program": "${workspaceFolder}/build/debug/bin/bin.exe",
11+
"program": "${workspaceFolder}/build/debug/bin.exe",
1212
"args": [
1313
"build",
1414
"-c",
@@ -24,14 +24,14 @@
2424
"cwd": "${workspaceFolder}",
2525
"environment": [],
2626
"console": "integratedTerminal",
27-
"symbolSearchPath": "${workspaceFolder}/build/debug/bin",
27+
"symbolSearchPath": "${workspaceFolder}/build/debug",
2828
"preLaunchTask": "Build Debug (MSVC)"
2929
},
3030
{
3131
"name": "(Windows) Build Clang",
3232
"type": "cppvsdbg",
3333
"request": "launch",
34-
"program": "${workspaceFolder}/build/debug/bin/bin.exe",
34+
"program": "${workspaceFolder}/build/debug/bin.exe",
3535
"args": [
3636
"build",
3737
"-c",
@@ -47,7 +47,7 @@
4747
"cwd": "${workspaceFolder}",
4848
"environment": [],
4949
"console": "integratedTerminal",
50-
"symbolSearchPath": "${workspaceFolder}/build/debug/bin",
50+
"symbolSearchPath": "${workspaceFolder}/build/debug",
5151
"preLaunchTask": "Build Debug (MSVC)"
5252
},
5353
{
@@ -79,22 +79,22 @@
7979
"name": "(Windows) Install",
8080
"type": "cppvsdbg",
8181
"request": "launch",
82-
"program": "${workspaceFolder}/build/debug/bin/bin.exe",
82+
"program": "${workspaceFolder}/build/debug/bin.exe",
8383
"args": [
8484
"install"
8585
],
8686
"stopAtEntry": false,
8787
"cwd": "${workspaceFolder}",
8888
"environment": [],
8989
"console": "integratedTerminal",
90-
"symbolSearchPath": "${workspaceFolder}/build/debug/bin",
90+
"symbolSearchPath": "${workspaceFolder}/build/debug",
9191
// "preLaunchTask": "Build Debug (MSVC)"
9292
},
9393
{
9494
"name": "(Windows) Add Package",
9595
"type": "cppvsdbg",
9696
"request": "launch",
97-
"program": "${workspaceFolder}/build/debug/bin/bin.exe",
97+
"program": "${workspaceFolder}/build/debug/bin.exe",
9898
"args": [
9999
"add",
100100
"Neargye/magic_enum"
@@ -104,14 +104,14 @@
104104
"cwd": "${workspaceFolder}",
105105
"environment": [],
106106
"console": "integratedTerminal",
107-
"symbolSearchPath": "${workspaceFolder}/build/debug/bin",
107+
"symbolSearchPath": "${workspaceFolder}/build/debug",
108108
"preLaunchTask": "Build Debug (MSVC)"
109109
},
110110
{
111111
"name": "(Windows) Remove Package",
112112
"type": "cppvsdbg",
113113
"request": "launch",
114-
"program": "${workspaceFolder}/build/debug/bin/bin.exe",
114+
"program": "${workspaceFolder}/build/debug/bin.exe",
115115
"args": [
116116
"remove",
117117
"magic_enum"
@@ -121,7 +121,7 @@
121121
"cwd": "${workspaceFolder}",
122122
"environment": [],
123123
"console": "integratedTerminal",
124-
"symbolSearchPath": "${workspaceFolder}/build/debug/bin",
124+
"symbolSearchPath": "${workspaceFolder}/build/debug",
125125
},
126126
]
127127
}

deps/spdlog/3335c380a08c5e0f5117a66622df6afdb3d74959/muuk.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ git = 'https://github.com/gabime/spdlog.git'
55

66
[dependencies.fmt]
77
git = 'https://github.com/fmtlib/fmt.git'
8-
muuk_path = 'deps/fmt/muuk.toml'
9-
revision = '577fd3be883accf8629423ed77fcca8a24bccee2'
108
version = '577fd3be883accf8629423ed77fcca8a24bccee2'
119

1210
[library]

include/compiler.hpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,23 @@ namespace muuk {
7878
private:
7979
Year year_;
8080
};
81+
82+
enum class LinkType {
83+
STATIC,
84+
SHARED,
85+
NO_LINK
86+
};
87+
88+
enum class BuildLinkType {
89+
BINARY,
90+
STATIC,
91+
SHARED
92+
};
93+
94+
std::string to_string(BuildLinkType type);
95+
96+
std::string to_string(LinkType type);
97+
8198
} // namespace muuk
8299

83100
#endif

include/lockgen/config/base.hpp

Lines changed: 19 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@
1313
#include "toml_ext.hpp"
1414
#include "util.hpp"
1515

16-
enum class LinkType {
17-
STATIC,
18-
SHARED
19-
};
20-
2116
struct Feature {
2217
std::unordered_set<std::string> defines;
2318
std::unordered_set<std::string> undefines;
@@ -42,6 +37,15 @@ inline void force_oneline(toml::value& v) {
4237
if constexpr (Derived::enable_##enable_macro) \
4338
maybe_set(out, #field_name, field_name)
4439

40+
/// Serializes and globs a vector of source files to a TOML array.
41+
#define SERIALIZE_GLOB_SOURCES(field) \
42+
if constexpr (Derived::enable_##field) { \
43+
toml::array arr; \
44+
for (const auto& s : expand_glob_sources(field)) \
45+
arr.push_back(s.serialize()); \
46+
maybe_set(out, #field, arr); \
47+
}
48+
4549
struct Dependency {
4650
std::string name;
4751
std::string git_url;
@@ -125,18 +129,8 @@ struct BaseFields {
125129
}
126130

127131
void serialize(toml::value& out) const {
128-
if constexpr (Derived::enable_modules) {
129-
toml::array module_array;
130-
for (const auto& s : expand_glob_sources(modules))
131-
module_array.push_back(s.serialize());
132-
maybe_set(out, "modules", module_array);
133-
}
134-
if constexpr (Derived::enable_sources) {
135-
toml::array src_array;
136-
for (const auto& s : expand_glob_sources(sources))
137-
src_array.push_back(s.serialize());
138-
maybe_set(out, "sources", src_array);
139-
}
132+
SERIALIZE_GLOB_SOURCES(modules);
133+
SERIALIZE_GLOB_SOURCES(sources);
140134

141135
MAYBE_SET_FIELD(include, include);
142136
MAYBE_SET_FIELD(defines, defines);
@@ -171,7 +165,7 @@ struct BaseFields {
171165
merge(libs, other.libs);
172166
}
173167

174-
std::vector<source_file> parse_sources(const toml::value& section, const std::string& base_path, const std::string& key = "sources") {
168+
static std::vector<source_file> parse_sources(const toml::value& section, const std::string& base_path, const std::string& key = "sources") {
175169
std::vector<source_file> temp_sources;
176170
if (!section.contains(key))
177171
return temp_sources;
@@ -195,7 +189,10 @@ struct BaseFields {
195189
file_path = source_entry;
196190
}
197191

198-
std::filesystem::path full_path = std::filesystem::path(base_path) / file_path;
192+
std::filesystem::path full_path = std::filesystem::path(file_path);
193+
if (!full_path.is_absolute())
194+
full_path = std::filesystem::path(base_path) / full_path;
195+
199196
temp_sources.emplace_back(
200197
util::file_system::to_linux_path(full_path.lexically_normal().string()),
201198
extracted_cflags);
@@ -210,9 +207,9 @@ struct BaseFields {
210207
for (const auto& s : input_sources) {
211208
try {
212209
std::vector<std::filesystem::path> globbed_paths = glob::glob(s.path);
213-
for (const auto& path : globbed_paths) {
210+
for (const auto& path : globbed_paths)
214211
expanded.emplace_back(util::file_system::to_linux_path(path.string()), s.cflags);
215-
}
212+
216213
} catch (const std::exception& e) {
217214
muuk::logger::warn("Error while globbing '{}': {}", s.path, e.what());
218215
}
@@ -302,28 +299,4 @@ struct ProfileConfig : BaseConfig<ProfileConfig> {
302299
const std::string& base_path);
303300

304301
void serialize(toml::value& out) const;
305-
};
306-
307-
struct Library : BaseConfig<Library> {
308-
std::string name;
309-
std::string version;
310-
std::unordered_set<std::string> profiles;
311-
312-
static constexpr bool enable_compilers = false;
313-
static constexpr bool enable_platforms = false;
314-
static constexpr bool enable_dependencies = false;
315-
316-
struct External {
317-
std::string type, path;
318-
std::vector<std::string> args;
319-
std::vector<std::string> outputs;
320-
321-
void load(const toml::value& v);
322-
void serialize(toml::value& out) const;
323-
};
324-
325-
External external;
326-
327-
void load(const std::string& name_, const std::string& version_, const std::string& base_path_, const toml::value& v);
328-
void serialize(toml::value& out, Platforms platforms, Compilers compilers) const;
329-
};
302+
};

include/lockgen/config/build.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <glob/glob.hpp>
88
#include <toml.hpp>
99

10+
#include "compiler.hpp"
1011
#include "lockgen/config/base.hpp"
1112
#include "lockgen/config/package.hpp"
1213

@@ -17,6 +18,8 @@ struct Build : BaseConfig<Build> {
1718
static constexpr bool enable_compilers = false;
1819
static constexpr bool enable_platforms = false;
1920

21+
muuk::BuildLinkType link_type = muuk::BuildLinkType::BINARY;
22+
2023
void merge(const Package& package);
2124
Result<void> serialize(toml::value& out) const;
2225
void load(const toml::value& v, const std::string& base_path);

include/lockgen/config/library.hpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#pragma once
2+
3+
#include <string>
4+
#include <unordered_set>
5+
6+
#include <glob/glob.hpp>
7+
#include <toml.hpp>
8+
9+
#include "compiler.hpp"
10+
#include "lockgen/config/base.hpp"
11+
12+
struct Library : BaseConfig<Library> {
13+
std::string name;
14+
std::string version;
15+
std::unordered_set<std::string> profiles;
16+
17+
muuk::LinkType link_type = muuk::LinkType::STATIC;
18+
19+
static constexpr bool enable_compilers = false;
20+
static constexpr bool enable_platforms = false;
21+
static constexpr bool enable_dependencies = false;
22+
23+
struct External {
24+
std::string type, path;
25+
std::vector<std::string> args;
26+
std::vector<std::string> outputs;
27+
28+
void load(const toml::value& v);
29+
void serialize(toml::value& out) const;
30+
};
31+
32+
External external;
33+
34+
void load(const std::string& name_, const std::string& version_, const std::string& base_path_, const toml::value& v);
35+
void serialize(toml::value& out, Platforms platforms, Compilers compilers) const;
36+
};

include/lockgen/config/package.hpp

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,39 +7,17 @@
77
#include <glob/glob.hpp>
88
#include <toml.hpp>
99

10+
#include "compiler.hpp"
1011
#include "lockgen/config/base.hpp"
12+
#include "lockgen/config/library.hpp"
1113
#include "muuk.hpp"
1214

13-
class PackageType {
14-
public:
15-
enum class Type {
16-
LIBRARY,
17-
BUILD
18-
};
19-
20-
static const PackageType LIBRARY;
21-
static const PackageType BUILD;
22-
23-
explicit PackageType(Type type);
24-
25-
static std::string to_string(Type type);
26-
std::string to_string() const;
27-
static PackageType from_string(const std::string& typeStr);
28-
29-
bool operator==(const PackageType& other) const;
30-
bool operator!=(const PackageType& other) const;
31-
32-
private:
33-
Type type_;
34-
};
35-
3615
class Package {
3716
public:
3817
Package(
3918
const std::string& name,
4019
const std::string& version,
41-
const std::string& base_path,
42-
const PackageType package_type);
20+
const std::string& base_path);
4321

4422
void merge(const Package& child_pkg);
4523

@@ -49,7 +27,6 @@ class Package {
4927
std::string name;
5028
std::string version;
5129
std::string base_path;
52-
PackageType package_type; // "library" or "build"
5330

5431
/// Git URL or local path
5532
std::string source;
@@ -66,7 +43,7 @@ class Package {
6643
std::unordered_map<std::string, Feature> features;
6744

6845
/// Preferred link type for the package.
69-
LinkType link_type = LinkType::STATIC;
46+
muuk::LinkType link_type = muuk::LinkType::STATIC;
7047

7148
/// Compiler-specific settings parsed from `[compiler]`.
7249
Compilers compilers_config;

include/lockgen/muuklockgen.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ class MuukLockGenerator {
3838

3939
DependencyMap resolved_packages;
4040

41-
// TODO: Address why I there are two maps for builds
42-
std::unordered_map<std::string, std::shared_ptr<Package>> builds;
4341
std::unordered_map<std::string, std::shared_ptr<Build>> builds_;
4442

4543
std::shared_ptr<Package> base_package_;

include/muuk_schema.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ namespace muuk {
116116
{"include", {false, TomlArray{TomlType::String}}},
117117
{"cflags", {false, TomlArray{TomlType::String}}},
118118
{"system_include", {false, TomlArray{TomlType::String}}},
119+
{"link", {false, TomlType::String}},
119120
{"dependencies", {false, TomlType::Table, {}}
120121
}}}
121122
}}}},

0 commit comments

Comments
 (0)