Skip to content

Commit 4a614a0

Browse files
committed
CI work.
1 parent d36c7d0 commit 4a614a0

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

source/compiler/compiler/compiler.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,18 @@ namespace sigma {
8686
utility::fs::file<utility::contiguous_container<utility::byte>>::save(path, module.generate_object_file());
8787
}
8888

89-
auto compiler::get_emit_target_from_path(const filepath& path) -> utility::result<emit_target> {
89+
auto compiler::get_emit_target_from_path(const filepath& path) const -> utility::result<emit_target> {
9090
if(path.get_extension() == ".exe") {
9191
return emit_target::EXECUTABLE;
9292
}
9393

94-
if(path.get_extension() == ".obj" || path.get_extension() == ".o") {
94+
if(path.get_extension() == ".obj") {
95+
ASSERT(m_description.target.get_system() == ir::system::WINDOWS, "incompatible target and object format");
96+
return emit_target::OBJECT;
97+
}
98+
99+
if (path.get_extension() == ".o") {
100+
ASSERT(m_description.target.get_system() == ir::system::LINUX, "incompatible target and object format");
95101
return emit_target::OBJECT;
96102
}
97103

source/compiler/compiler/compiler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ namespace sigma {
4747
static auto verify_file(const filepath& path) -> utility::result<void>;
4848
static void emit_object_file(ir::module& module, const filepath& path);
4949

50-
static auto get_emit_target_from_path(const filepath& path) -> utility::result<emit_target>;
50+
auto get_emit_target_from_path(const filepath& path) const -> utility::result<emit_target>;
5151
private:
5252
compiler_description m_description;
5353

source/compiler/main.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ i32 compile(const parametric::parameters& params) {
99
.emit_path = params.get<filepath>("emit"),
1010

1111
// default to x64 win for now
12-
.target = { sigma::ir::arch::X64, sigma::ir::system::WINDOWS },
12+
.target = {
13+
params.get<sigma::ir::arch>("arch"),
14+
params.get<sigma::ir::system>("system")
15+
},
1316
};
1417

1518
// compile the specified description, check for errors after we finish
@@ -45,8 +48,8 @@ auto main(i32 argc, char* argv[]) -> i32 {
4548

4649
compile_command.add_positional_argument<filepath>("file", "source file to compile");
4750
compile_command.add_flag<filepath>("emit", "filepath to emit to", "e", "./a.obj");
48-
compile_command.add_flag<sigma::ir::arch>("arch", "CPU architecture to compile for [x64]");
49-
compile_command.add_flag<sigma::ir::system>("system", "operating system to compile for [windows, linux]");
51+
compile_command.add_flag<sigma::ir::arch>("arch", "CPU architecture to compile for [x64]", "", sigma::ir::arch::X64);
52+
compile_command.add_flag<sigma::ir::system>("system", "operating system to compile for [windows, linux]", "", sigma::ir::system::WINDOWS);
5053

5154
// TODO: add support for emitting multiple files at once
5255

0 commit comments

Comments
 (0)