Skip to content

Commit ac21405

Browse files
committed
Update.
1 parent 0133964 commit ac21405

File tree

10 files changed

+2400
-2294
lines changed

10 files changed

+2400
-2294
lines changed

.clang-format

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ AllowShortIfStatementsOnASingleLine: false
55
IndentCaseLabels: false
66
ColumnLimit: 120
77
AccessModifierOffset: -2
8-
AllowShortFunctionsOnASingleLine: true
9-
AllowShortLambdasOnASingleLine: true
8+
AllowShortFunctionsOnASingleLine: false
9+
AllowShortLambdasOnASingleLine: false
1010

1111
AlignTrailingComments: true
1212

@@ -20,3 +20,5 @@ AlwaysBreakTemplateDeclarations: Yes
2020
#SeparateDefinitionBlocks: Leave
2121

2222
LineEnding: LF
23+
24+
ReflowComments: false

src/sw/build.h

Lines changed: 84 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,97 @@
11
// SPDX-License-Identifier: AGPL-3.0-only
22
// Copyright (C) 2024 Egor Pugin <egor.pugin@gmail.com>
33

4+
#include "command/command.h"
45
#include "input.h"
6+
#include "sw/builtin/vs_instance_helpers.h"
57

68
namespace sw {
79

8-
struct build {
9-
inputs_type inputs;
10-
// list of repos
10+
struct sw_script {
11+
struct file {
12+
path fn;
13+
std::vector<path> include_dirs;
14+
};
15+
16+
std::vector<file> files;
17+
std::vector<path> include_dirs;
18+
bool debug{};
19+
20+
// returns command
21+
void build() {
22+
//g++ src/client.cpp -Isrc -std=c++26 -g -O0 -lole32 -lOleAut32" -static-libstdc++ -static-libgcc -static -lpthread
23+
//clang src\client.cpp -Isrc -std=c++26 -g -O0
24+
//cl src\client.cpp /std:c++latest /nologo /EHsc -Isrc // has issues
25+
26+
#ifndef NDEBUG
27+
debug = 1;
28+
#endif
29+
30+
auto common_flags = [&](auto &&cmd) {
31+
for (auto &&f : files) {
32+
cmd += f.fn;
33+
}
34+
cmd += "-std=c++26";
35+
// -MD
36+
if (debug) {
37+
cmd += "-g", "-O0";
38+
}
39+
for (auto &&f : files) {
40+
for (auto &&i : f.include_dirs) {
41+
cmd += "-I", i;
42+
}
43+
}
44+
for (auto &&i : include_dirs) {
45+
cmd += "-I", i;
46+
}
47+
};
1148

12-
void run() {
13-
path x;
49+
if (auto gpp = resolve_executable("g++"); gpp && 0) {
50+
gcc_command cmd;
51+
cmd += *gpp;
52+
common_flags(cmd);
53+
cmd += "-lole32", "-lOleAut32";
54+
cmd += "-static-libstdc++", "-static-libgcc", "-static", "-lpthread";
55+
cmd();
56+
// clang is faster than mingw atm
57+
} else if (auto clang = resolve_executable("clang"); clang) {
58+
gcc_command cmd;
59+
cmd += *clang;
60+
common_flags(cmd);
61+
cmd();
62+
} else {
63+
// try msvc
64+
auto inst = enumerate_vs_instances();
65+
SW_UNIMPLEMENTED;
66+
}
67+
}
68+
};
69+
70+
struct build {
71+
inputs_type inputs;
72+
// list of repos
1473

15-
int a = 5;
16-
a++;
74+
void run() {
75+
sw_script ss;
76+
for (auto &&i : inputs) {
77+
visit(
78+
i.i,
79+
[&](specification_file_input &v) {
80+
ss.files.emplace_back(v.fn);
81+
},
82+
[&](directory_input &v) {
83+
SW_UNIMPLEMENTED;
84+
int a = 5;
85+
a++;
86+
},
87+
[&](direct_build_input &v) {
88+
SW_UNIMPLEMENTED;
89+
int a = 5;
90+
a++;
91+
});
1792
}
93+
ss.build();
94+
}
1895
};
1996

2097
} // namespace sw

src/sw/builtin/os_base.h

Lines changed: 61 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -10,126 +10,126 @@ namespace sw {
1010
namespace os {
1111

1212
struct windows {
13-
static constexpr auto name = "windows"sv;
13+
static constexpr auto name = "windows"sv;
1414

15-
static constexpr auto executable_extension = ".exe";
16-
static constexpr auto object_file_extension = ".obj";
17-
static constexpr auto static_library_extension = ".lib";
18-
static constexpr auto shared_library_extension = ".dll";
15+
static constexpr auto executable_extension = ".exe";
16+
static constexpr auto object_file_extension = ".obj";
17+
static constexpr auto static_library_extension = ".lib";
18+
static constexpr auto shared_library_extension = ".dll";
1919

20-
static bool is(string_view sv) {
21-
return name == sv;
22-
}
20+
static bool is(string_view sv) {
21+
return name == sv;
22+
}
2323

24-
// deps:
25-
// kernel32 dependency (winsdk.um)
24+
// deps:
25+
// kernel32 dependency (winsdk.um)
2626
};
2727

2828
struct mingw : windows {
29-
static constexpr auto name = "mingw"sv;
29+
static constexpr auto name = "mingw"sv;
3030

31-
static bool is(string_view sv) {
32-
return name == sv;
33-
}
31+
static bool is(string_view sv) {
32+
return name == sv;
33+
}
3434
};
3535

3636
struct cygwin : windows {
37-
static constexpr auto name = "cygwin"sv;
37+
static constexpr auto name = "cygwin"sv;
3838

39-
static constexpr auto static_library_extension = ".a";
40-
static constexpr auto object_file_extension = ".o";
39+
static constexpr auto static_library_extension = ".a";
40+
static constexpr auto object_file_extension = ".o";
4141

42-
static bool is(string_view sv) {
43-
return name == sv;
44-
}
42+
static bool is(string_view sv) {
43+
return name == sv;
44+
}
4545
};
4646

4747
struct unix {
48-
static constexpr auto object_file_extension = ".o";
49-
static constexpr auto static_library_extension = ".a";
48+
static constexpr auto object_file_extension = ".o";
49+
static constexpr auto static_library_extension = ".a";
5050
};
5151

5252
struct linux : unix {
53-
static constexpr auto name = "linux"sv;
53+
static constexpr auto name = "linux"sv;
5454

55-
static constexpr auto shared_library_extension = ".so";
55+
static constexpr auto shared_library_extension = ".so";
5656

57-
static bool is(string_view sv) {
58-
return name == sv;
59-
}
57+
static bool is(string_view sv) {
58+
return name == sv;
59+
}
6060
};
6161

6262
struct darwin : unix {
63-
static constexpr auto shared_library_extension = ".dylib";
63+
static constexpr auto shared_library_extension = ".dylib";
6464
};
6565

6666
struct macos : darwin {
67-
static constexpr auto name = "macos"sv;
67+
static constexpr auto name = "macos"sv;
6868

69-
static bool is(string_view sv) {
70-
return name == sv;
71-
}
69+
static bool is(string_view sv) {
70+
return name == sv;
71+
}
7272
};
7373
// ios etc
7474

7575
struct wasm : unix {
76-
static constexpr auto name = "wasm"sv;
76+
static constexpr auto name = "wasm"sv;
7777

78-
static constexpr auto executable_extension = ".html";
78+
static constexpr auto executable_extension = ".html";
7979

80-
static bool is(string_view sv) {
81-
return name == sv;
82-
}
80+
static bool is(string_view sv) {
81+
return name == sv;
82+
}
8383
};
8484

8585
} // namespace os
8686

8787
namespace build_type {
8888

8989
struct debug {
90-
static constexpr auto name = "debug"sv;
91-
static constexpr auto short_name = "d"sv;
90+
static constexpr auto name = "debug"sv;
91+
static constexpr auto short_name = "d"sv;
9292

93-
static bool is(string_view sv) {
94-
return name == sv || short_name == sv;
95-
}
93+
static bool is(string_view sv) {
94+
return name == sv || short_name == sv;
95+
}
9696
};
9797
struct minimum_size_release {
98-
static constexpr auto name = "minimum_size_release"sv;
99-
static constexpr auto short_name = "msr"sv;
98+
static constexpr auto name = "minimum_size_release"sv;
99+
static constexpr auto short_name = "msr"sv;
100100

101-
static bool is(string_view sv) {
102-
return name == sv || short_name == sv;
103-
}
101+
static bool is(string_view sv) {
102+
return name == sv || short_name == sv;
103+
}
104104
};
105105
struct release_with_debug_information {
106-
static constexpr auto name = "release_with_debug_information"sv;
107-
static constexpr auto short_name = "rwdi"sv;
106+
static constexpr auto name = "release_with_debug_information"sv;
107+
static constexpr auto short_name = "rwdi"sv;
108108

109-
static bool is(string_view sv) {
110-
return name == sv || short_name == sv;
111-
}
109+
static bool is(string_view sv) {
110+
return name == sv || short_name == sv;
111+
}
112112
};
113113
struct release {
114-
static constexpr auto name = "release"sv;
115-
static constexpr auto short_name = "r"sv;
114+
static constexpr auto name = "release"sv;
115+
static constexpr auto short_name = "r"sv;
116116

117-
static bool is(string_view sv) {
118-
return name == sv || short_name == sv;
119-
}
117+
static bool is(string_view sv) {
118+
return name == sv || short_name == sv;
119+
}
120120
};
121121

122122
} // namespace build_type
123123

124124
namespace library_type {
125125

126126
struct static_ {
127-
static constexpr auto name = "static"sv;
128-
static constexpr auto short_name = "st"sv;
127+
static constexpr auto name = "static"sv;
128+
static constexpr auto short_name = "st"sv;
129129
};
130130
struct shared {
131-
static constexpr auto name = "shared"sv;
132-
static constexpr auto short_name = "sh"sv;
131+
static constexpr auto name = "shared"sv;
132+
static constexpr auto short_name = "sh"sv;
133133
};
134134

135135
} // namespace library_type

0 commit comments

Comments
 (0)