mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
Use name of source file as output_name
This commit is contained in:
+2
-2
@@ -7788,8 +7788,8 @@ bool ir_gen_init(irGen *s, Checker *c) {
|
|||||||
String init_fullpath = c->parser->init_fullpath;
|
String init_fullpath = c->parser->init_fullpath;
|
||||||
|
|
||||||
if (build_context.out_filepath.len == 0) {
|
if (build_context.out_filepath.len == 0) {
|
||||||
// s->output_name = filename_from_path(init_fullpath);
|
s->output_name = remove_directory_from_path(init_fullpath);
|
||||||
s->output_name = str_lit("main");
|
s->output_name = remove_extension_from_path(s->output_name);
|
||||||
s->output_base = s->output_name;
|
s->output_base = s->output_name;
|
||||||
} else {
|
} else {
|
||||||
s->output_name = build_context.out_filepath;
|
s->output_name = build_context.out_filepath;
|
||||||
|
|||||||
@@ -276,6 +276,15 @@ String filename_from_path(String s) {
|
|||||||
return make_string(nullptr, 0);
|
return make_string(nullptr, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String remove_extension_from_path(String const &s) {
|
||||||
|
for (isize i = s.len-1; i >= 0; i--) {
|
||||||
|
if (s[i] == '.') {
|
||||||
|
return substring(s, 0, i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
String remove_directory_from_path(String const &s) {
|
String remove_directory_from_path(String const &s) {
|
||||||
isize len = 0;
|
isize len = 0;
|
||||||
for (isize i = s.len-1; i >= 0; i--) {
|
for (isize i = s.len-1; i >= 0; i--) {
|
||||||
@@ -287,6 +296,7 @@ String remove_directory_from_path(String const &s) {
|
|||||||
}
|
}
|
||||||
return substring(s, s.len-len, s.len);
|
return substring(s, s.len-len, s.len);
|
||||||
}
|
}
|
||||||
|
|
||||||
String directory_from_path(String const &s) {
|
String directory_from_path(String const &s) {
|
||||||
isize i = s.len-1;
|
isize i = s.len-1;
|
||||||
for (; i >= 0; i--) {
|
for (; i >= 0; i--) {
|
||||||
|
|||||||
Reference in New Issue
Block a user