From: hgn Date: Thu, 25 Sep 2025 20:08:30 +0000 (+0000) Subject: ok X-Git-Url: https://skaterift.com/git/?a=commitdiff_plain;h=1ebf36ef55961aa82ace6d5d32fcbb0e176b0f9d;p=vg.git ok --- diff --git a/source/foundation/logging.c b/source/foundation/logging.c index 9f5f778..f8f6999 100644 --- a/source/foundation/logging.c +++ b/source/foundation/logging.c @@ -30,8 +30,18 @@ struct stream *_log_event( u32 type, const c8 *code_location ) { struct stream *output = _get_console_stream(); string_append( output, KBLK ); + + u32 line_start = output->offset; + + i32 s = buffer_last_index( code_location, '/', 0 ); + if( s != -1 ) + { + string_append( output, "..." ); + code_location += s+1; + } string_append( output, code_location ); - while( output->offset < 32 ) string_append_c8( output, ' ' ); + + while( (output->offset-line_start) < 32 ) string_append_c8( output, ' ' ); if( type == $error ) string_append( output, KRED "ERR|" ); else if( type == $warning ) string_append( output, KYEL "WRN|" ); else if( type == $ok ) string_append( output, KGRN "OK |" ); diff --git a/source/foundation/options.c b/source/foundation/options.c index 2d2554a..9a98b9b 100644 --- a/source/foundation/options.c +++ b/source/foundation/options.c @@ -217,18 +217,10 @@ static struct argument *_argument_get_named( enum argument_type type, const c8 * struct argument *arg = &_options.arguments[ i ]; if( arg->type == type ) { - for( u32 j=0; arg->name_length; j ++ ) + if( compare_buffers( arg->name, arg->name_length, name, 0 ) ) { - c8 ca = name[j], cb = arg->name[j]; - if( ca == cb ) - { - if( ca == 0 ) - { - arg->used = 0xffffffff; - return arg; - } - } - else break; + arg->used = 0xffffffff; + return arg; } } } diff --git a/source/tools/metacompiler.c b/source/tools/metacompiler.c index b141638..d682816 100644 --- a/source/tools/metacompiler.c +++ b/source/tools/metacompiler.c @@ -2,19 +2,15 @@ struct { - bool address_sanitizer, - thread_sanitizer, - no_pdb; - - c8 binary_name[ 128 ]; + c8 project_name[ 128 ]; struct stack_allocator all; } static _metacompiler; -struct source_file +struct command { - enum source_type + enum command_type { k_source_c, k_source_include_path @@ -41,12 +37,12 @@ void _parse_kv_block( struct keyvalues *kvs, u32 block, const c8 *folder ) if( compare_buffers( keyvalues_key( kvs, kv, NULL ), 0, "name", 0 ) ) { buffer_copy( keyvalues_value( kvs, kv, NULL ), 0, - _metacompiler.binary_name, sizeof(_metacompiler.binary_name ) ); + _metacompiler.project_name, sizeof(_metacompiler.project_name) ); } if( compare_buffers( keyvalues_key( kvs, kv, NULL ), 0, "add", 0 ) ) { - struct source_file *source = stretchy_append( &_source_list ); + struct command *source = stretchy_append( &_source_list ); source->type = k_source_c; stream_open_stack( &source->path, &_metacompiler.all, k_stream_null_terminate ); @@ -55,7 +51,7 @@ void _parse_kv_block( struct keyvalues *kvs, u32 block, const c8 *folder ) if( compare_buffers( keyvalues_key( kvs, kv, NULL ), 0, "include", 0 ) ) { - struct source_file *source = stretchy_append( &_source_list ); + struct command *source = stretchy_append( &_source_list ); source->type = k_source_include_path; stream_open_stack( &source->path, &_metacompiler.all, k_stream_null_terminate ); @@ -110,37 +106,109 @@ void system_call( const c8 *call ) ASSERT_CRITICAL( system(call) == 0 ); } +static i32 enum_read( const c8 *options[], u32 option_count, const c8 *input ) +{ + for( i32 i=0; i" )) ) { struct stream arg_stream; @@ -148,27 +216,28 @@ i32 main( i32 argc, const c8 *argv[] ) ASSERT_CRITICAL( string_parse_u64( &arg_stream, &processors ) == k_string_parse_ok ); } - list_file = _option(); - - //if( (arg = _option_long_argument( "platform", + const c8 *target_file_path = NULL; + target_file_path = _option(); + ASSERT_CRITICAL( target_file_path ); _options_check_end(); stack_init( &_metacompiler.all, NULL, BYTES_MB(64), "Everything" ); - ASSERT_CRITICAL( list_file ); $log( $info, {"Building source tree"} ); - stretchy_init( &_source_list, sizeof(struct source_file) ); - _append_kv_list( list_file ); + stretchy_init( &_source_list, sizeof(struct command) ); + _append_kv_list( target_file_path ); + + buffer_copy( "project", 0, _metacompiler.project_name, sizeof(_metacompiler.project_name) ); u32 temp_frame = _start_temporary_frame(); { - c8 *output_folder = realpath( list_file, NULL ); + c8 *output_folder = realpath( target_file_path, NULL ); if( !output_folder ) { - $log( $fatal, {"'"}, {list_file}, {"' "}, $errno() ); + $log( $fatal, {"'"}, {target_file_path}, {"' "}, $errno() ); _fatal_exit(); } @@ -176,9 +245,19 @@ i32 main( i32 argc, const c8 *argv[] ) if( s != -1 ) output_folder[s] = '\0'; + struct stream tripple_string; + stream_open_stack( &tripple_string, _temporary_stack_allocator(), k_stream_null_terminate ); + $v_string( &tripple_string, {architecture_names[arch]}, {"-"}, {platform_names[platform]} ); + if( platform == k_platform_linux ) + { + $v_string( &tripple_string, {"-gnu"} ); + if( libc != k_libc_version_native ) + $v_string( &tripple_string, {"."}, {libc_names[libc]} ); + } + struct stream folder_string; stream_open_stack( &folder_string, _temporary_stack_allocator(), k_stream_null_terminate ); - $v_string( &folder_string, {output_folder}, {"/bin/"}, {"project"}, {"-linux-x86_64-zig-cc"} ); + $v_string( &folder_string, {output_folder}, {"/bin/"}, {_metacompiler.project_name}, {"-"}, $string(&tripple_string) ); free(output_folder); @@ -188,27 +267,30 @@ i32 main( i32 argc, const c8 *argv[] ) system_call( string_get( &command_string ) ); - stream_open_stack( &command_string, _temporary_stack_allocator(), k_stream_null_terminate ); $v_string( &command_string, {"taskset -c 0-"}, $unsigned(processors), {" zig cc -Wall -Wno-unused-function -std=c99 -D_DEFAULT_SOURCE \\\n"}, {" -include \"common_api.h\" \\\n"} ); + $v_string( &command_string, {" -target "}, $string(&tripple_string) ); + $v_string( &command_string, {" \\\n"} ); + for( u32 i=0; itype == k_source_include_path ) $v_string( &command_string, {" -I"}, $string(&source->path), {" \\\n"} ); } for( u32 i=0; itype == k_source_c ) $v_string( &command_string, {" "}, $string(&source->path), {" \\\n"} ); } - $v_string( &command_string, {"-o "}, $string( &folder_string ), {"/project"} ); + $v_string( &command_string, {"-o "}, $string( &folder_string ), {"/"}, + {_metacompiler.project_name}, {"-"}, $string(&tripple_string) ); system_call( string_get( &command_string ) ); } _end_temporary_frame( temp_frame );