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