mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Add --version and -V
This commit is contained in:
committed by
Christoffer Lerno
parent
729e26d37c
commit
87a91b25e5
@@ -10,16 +10,15 @@
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <utils/lib.h>
|
||||
|
||||
|
||||
|
||||
|
||||
#include "../utils/whereami.h"
|
||||
|
||||
|
||||
static int arg_index;
|
||||
static int arg_count;
|
||||
static const char** args;
|
||||
static const char* current_arg;
|
||||
extern const char* llvm_version;
|
||||
extern const char* llvm_target;
|
||||
|
||||
char *arch_os_target[ARCH_OS_TARGET_LAST + 1] = {
|
||||
[X86_FREEBSD] = "x86_freebsd",
|
||||
@@ -69,6 +68,7 @@ static void usage(void)
|
||||
OUTPUT(" --template <template> - Use a different template: \"lib\", \"staticlib\" or a path.");
|
||||
OUTPUT(" --about - Prints a short description of C3.");
|
||||
OUTPUT(" --symtab <value> - Sets the preferred symtab size.");
|
||||
OUTPUT(" -V --version - Print version information.");
|
||||
OUTPUT(" -E - Lex only.");
|
||||
OUTPUT(" -P - Only parse and output the AST as S-expressions.");
|
||||
OUTPUT(" -O0 - Optimizations off.");
|
||||
@@ -248,10 +248,25 @@ static void print_all_targets(void)
|
||||
}
|
||||
}
|
||||
|
||||
static void print_version(void)
|
||||
{
|
||||
OUTPUT("C3 Compiler Version: Pre-alpha %s", COMPILER_VERSION);
|
||||
OUTPUT("Installed directory: %s", find_executable_path());
|
||||
OUTPUT("LLVM version: %s", llvm_version);
|
||||
OUTPUT("LLVM default target: %s", llvm_target);
|
||||
}
|
||||
|
||||
static void parse_option(BuildOptions *options)
|
||||
{
|
||||
switch (current_arg[1])
|
||||
{
|
||||
case 'V':
|
||||
if (match_shortopt("V"))
|
||||
{
|
||||
print_version();
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
break;
|
||||
case 'g':
|
||||
if (match_shortopt("gline-tables-only"))
|
||||
{
|
||||
@@ -352,6 +367,11 @@ static void parse_option(BuildOptions *options)
|
||||
options->compile_option = COMPILE_LEX_PARSE_ONLY;
|
||||
return;
|
||||
case '-':
|
||||
if (match_longopt("version"))
|
||||
{
|
||||
print_version();
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
if (match_longopt("about"))
|
||||
{
|
||||
OUTPUT("The C3 Compiler");
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#define MAX_LIB_DIRS 1024
|
||||
#define MAX_FILES 2048
|
||||
|
||||
#define COMPILER_VERSION "A218"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
COMMAND_MISSING = 0,
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
|
||||
#include "llvm_codegen_internal.h"
|
||||
|
||||
|
||||
const char* llvm_version = LLVM_VERSION_STRING;
|
||||
const char* llvm_target = LLVM_DEFAULT_TARGET_TRIPLE;
|
||||
|
||||
static void diagnostics_handler(LLVMDiagnosticInfoRef ref, void *context)
|
||||
{
|
||||
|
||||
@@ -1083,7 +1083,7 @@ void target_setup(BuildTarget *target)
|
||||
|
||||
if (target->arch_os_target == ARCH_OS_TARGET_DEFAULT)
|
||||
{
|
||||
platform_target.target_triple = LLVMGetDefaultTargetTriple();
|
||||
platform_target.target_triple = LLVM_DEFAULT_TARGET_TRIPLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include "compiler_tests/tests.h"
|
||||
#include "utils/lib.h"
|
||||
|
||||
static int version = 102;
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
// First setup memory
|
||||
@@ -13,7 +12,7 @@ int main(int argc, const char *argv[])
|
||||
|
||||
|
||||
|
||||
DEBUG_LOG("Version: %d", version);
|
||||
DEBUG_LOG("Version: %s", COMPILER_VERSION);
|
||||
|
||||
|
||||
// Parse arguments.
|
||||
|
||||
Reference in New Issue
Block a user