core: Allow assembly only outputs

Signed-off-by: Ian Moffett <ian@mirocom.org>
This commit is contained in:
2026-02-18 09:37:32 -05:00
parent 29479b5ac6
commit c3bbf59303

View File

@@ -9,9 +9,9 @@
/* Compiler version */
#define RIFLE_VERSION "0.0.2"
/* Output file */
static const char *output_fmt = "elf64";
static const char *output_file = "a.out";
static bool asm_only = false;
static void
help(void)
@@ -21,6 +21,7 @@ help(void)
"------------------------------------\n"
"[-h] Display this help menu\n"
"[-v] Display the version\n"
"[-a] Assembly output\n"
"[-f] Output format\n"
"[-o] Output file\n"
);
@@ -56,16 +57,20 @@ compile(const char *in_path)
}
rifle_state_destroy(&state);
snprintf(
buf,
sizeof(buf),
"nasm -f%s %s -o %s",
output_fmt,
ASMOUT,
output_file
);
if (!asm_only) {
snprintf(
buf,
sizeof(buf),
"nasm -f%s %s -o %s",
output_fmt,
ASMOUT,
output_file
);
system(buf);
remove(ASMOUT);
}
system(buf);
return 0;
}
@@ -76,7 +81,7 @@ main(int argc, char **argv)
int opt;
/* Begin parsing command line options */
while ((opt = getopt(argc, argv, "hvf:o:")) != -1) {
while ((opt = getopt(argc, argv, "hvaf:o:")) != -1) {
switch (opt) {
case 'h':
help();
@@ -84,6 +89,9 @@ main(int argc, char **argv)
case 'v':
version();
return -1;
case 'a':
asm_only = true;
break;
case 'o':
output_file = strdup(optarg);
break;