merged with partial fuck up on mac

master
Allen Webster 2017-07-09 23:39:33 -04:00
commit d26a21ab20
7 changed files with 113 additions and 64 deletions

21
build_string.bat Normal file
View File

@ -0,0 +1,21 @@
@echo off
build.bat /DSTRING_BUILD
REM SET OPTS=-W4 -wd4310 -wd4100 -wd4201 -wd4505 -wd4996 -wd4127 -wd4510 -wd4512 -wd4610 -wd4390 -WX
REM SET OPTS=%OPTS% -wd4611 -GR- -EHa- -nologo -FC
REM
REM SET FirstError=0
REM
REM pushd ..\build
REM cl %OPTS% ..\code\string\4ed_string_builder.cpp /Zi /Festring_builder
REM if %ERRORLEVEL% neq 0 (set FirstError=1)
REM if %ERRORLEVEL% neq 0 (goto END)
REM popd
REM
REM pushd string
REM ..\..\build\string_builder
REM if %ERRORLEVEL% neq 0 (set FirstError=1)
REM popd
REM
REM :END

View File

@ -1,6 +1,11 @@
/* /*
4coder development build rule. * Mr. 4th Dimention - Allen Webster
*/ *
* ??.??.????
*
* 4coder development build rule.
*
*/
// TOP // TOP
@ -189,20 +194,19 @@ get_defines_from_flags(u32 flags){
"user32.lib winmm.lib gdi32.lib opengl32.lib " \ "user32.lib winmm.lib gdi32.lib opengl32.lib " \
"..\\foreign_x86\\freetype.lib" "..\\foreign_x86\\freetype.lib"
#define CL_ICON "..\\res\\icon.res" #define CL_ICON "..\\res\\icon.res"
static void internal void
build(u32 flags, u32 arch, char *code_path, char **code_files, char *out_path, char *out_file, char **defines, char **exports, char **inc_folders){ build(u32 flags, u32 arch, char *code_path, char **code_files, char *out_path, char *out_file, char **defines, char **exports, char **inc_folders){
Temp_Dir temp = fm_pushdir(out_path); Temp_Dir temp = fm_pushdir(out_path);
Build_Line line; Build_Line line;
fm_init_build_line(&line); fm_init_build_line(&line);
if (arch == Arch_X86){ if (arch == Arch_X86){
fm_add_to_line(line, "%s\\windows_scripts\\setup_cl_x86.bat &", code_path); fm_add_to_line(line, "%s\\windows_scripts\\setup_cl_x86.bat &", code_path);
} }
fm_add_to_line(line, "cl"); fm_add_to_line(line, "cl");
if (flags & OPTS){ if (flags & OPTS){
@ -210,8 +214,8 @@ build(u32 flags, u32 arch, char *code_path, char **code_files, char *out_path, c
} }
switch (arch){ switch (arch){
case Arch_X64: fm_add_to_line(line, "/DFTECH_64_BIT"); break; case Arch_X64: fm_add_to_line(line, "-DFTECH_64_BIT"); break;
case Arch_X86: fm_add_to_line(line, "/DFTECH_32_BIT"); break; case Arch_X86: fm_add_to_line(line, "-DFTECH_32_BIT"); break;
default: InvalidCodePath; default: InvalidCodePath;
} }
@ -219,7 +223,7 @@ build(u32 flags, u32 arch, char *code_path, char **code_files, char *out_path, c
if (inc_folders != 0){ if (inc_folders != 0){
for (u32 i = 0; inc_folders[i] != 0; ++i){ for (u32 i = 0; inc_folders[i] != 0; ++i){
char *str = fm_str(code_path, "/", inc_folders[i]); char *str = fm_str(code_path, "/", inc_folders[i]);
fm_add_to_line(line, "/I%s", str); fm_add_to_line(line, "-I%s", str);
} }
} }
@ -236,51 +240,51 @@ build(u32 flags, u32 arch, char *code_path, char **code_files, char *out_path, c
} }
if (flags & DEBUG_INFO){ if (flags & DEBUG_INFO){
fm_add_to_line(line, "/Zi"); fm_add_to_line(line, "-Zi");
} }
if (flags & OPTIMIZATION){ if (flags & OPTIMIZATION){
fm_add_to_line(line, "/O2"); fm_add_to_line(line, "-O2");
} }
if (flags & SHARED_CODE){ if (flags & SHARED_CODE){
fm_add_to_line(line, "/LD"); fm_add_to_line(line, "-LD");
} }
if (defines != 0){ if (defines != 0){
for (u32 i = 0; defines[i] != 0; ++i){ for (u32 i = 0; defines[i] != 0; ++i){
char *define_flag = fm_str("/D", defines[i]); char *define_flag = fm_str("-D", defines[i]);
fm_add_to_line(line, define_flag); fm_add_to_line(line, "%s", define_flag);
} }
} }
for (u32 i = 0; code_files[i]; ++i){ for (u32 i = 0; code_files[i]; ++i){
fm_add_to_line(line, "\"%s\\%s\"", code_path, code_files[i]); fm_add_to_line(line, "\"%s\\%s\"", code_path, code_files[i]);
} }
fm_add_to_line(line, "/Fe%s", out_file); fm_add_to_line(line, "-Fe%s", out_file);
fm_add_to_line(line, "/link /INCREMENTAL:NO"); fm_add_to_line(line, "-link -INCREMENTAL:NO");
switch (arch){ switch (arch){
case Arch_X64: fm_add_to_line(line, "/MACHINE:X64"); break; case Arch_X64: fm_add_to_line(line, "-MACHINE:X64"); break;
case Arch_X86: fm_add_to_line(line, "/MACHINE:X86"); break; case Arch_X86: fm_add_to_line(line, "-MACHINE:X86"); break;
default: InvalidCodePath; default: InvalidCodePath;
} }
if (flags & DEBUG_INFO){ if (flags & DEBUG_INFO){
fm_add_to_line(line, "/DEBUG"); fm_add_to_line(line, "-DEBUG");
} }
if (flags & SHARED_CODE){ if (flags & SHARED_CODE){
Assert(exports != 0); Assert(exports != 0);
fm_add_to_line(line, "/OPT:REF"); fm_add_to_line(line, "-OPT:REF");
for (u32 i = 0; exports[i] != 0; ++i){ for (u32 i = 0; exports[i] != 0; ++i){
char *str = fm_str("/EXPORT:", exports[i]); char *str = fm_str("-EXPORT:", exports[i]);
fm_add_to_line(line, "%s", str); fm_add_to_line(line, "%s", str);
} }
} }
else{ else{
fm_add_to_line(line, "/NODEFAULTLIB:library"); fm_add_to_line(line, "-NODEFAULTLIB:library");
} }
fm_finish_build_line(&line); fm_finish_build_line(&line);
@ -320,7 +324,7 @@ build(u32 flags, u32 arch, char *code_path, char **code_files, char *out_path, c
# error gcc options not set for this platform # error gcc options not set for this platform
#endif #endif
static void internal void
build(u32 flags, u32 arch, char *code_path, char **code_files, char *out_path, char *out_file, char **defines, char **exports, char **inc_folders){ build(u32 flags, u32 arch, char *code_path, char **code_files, char *out_path, char *out_file, char **defines, char **exports, char **inc_folders){
Build_Line line; Build_Line line;
fm_init_build_line(&line); fm_init_build_line(&line);
@ -387,7 +391,7 @@ build(u32 flags, u32 arch, char *code_path, char **code_files, char *out_path, c
fm_add_to_line(line, "%s", define_flag); fm_add_to_line(line, "%s", define_flag);
} }
} }
fm_add_to_line(line, "-I\"%s\"", code_path); fm_add_to_line(line, "-I\"%s\"", code_path);
for (u32 i = 0; code_files[i] != 0; ++i){ for (u32 i = 0; code_files[i] != 0; ++i){
fm_add_to_line(line, "\"%s/%s\"", code_path, code_files[i]); fm_add_to_line(line, "\"%s/%s\"", code_path, code_files[i]);
@ -408,7 +412,7 @@ build(u32 flags, u32 arch, char *code_path, char **code_files, char *out_path, c
# error build function not defined for this compiler # error build function not defined for this compiler
#endif #endif
static void internal void
build(u32 flags, u32 arch, char *code_path, char *code_file, char *out_path, char *out_file, char **defines, char **exports, char **inc_folders){ build(u32 flags, u32 arch, char *code_path, char *code_file, char *out_path, char *out_file, char **defines, char **exports, char **inc_folders){
char *code_files[2]; char *code_files[2];
code_files[0] = code_file; code_files[0] = code_file;
@ -416,7 +420,7 @@ build(u32 flags, u32 arch, char *code_path, char *code_file, char *out_path, cha
build(flags, arch, code_path, code_files, out_path, out_file, defines, exports, inc_folders); build(flags, arch, code_path, code_files, out_path, out_file, defines, exports, inc_folders);
} }
static void internal void
site_build(char *cdir, u32 flags){ site_build(char *cdir, u32 flags){
{ {
char *file = fm_str("site/4ed_sitegen.cpp"); char *file = fm_str("site/4ed_sitegen.cpp");
@ -426,7 +430,7 @@ site_build(char *cdir, u32 flags){
END_TIME_SECTION("build sitegen"); END_TIME_SECTION("build sitegen");
} }
{ if (prev_error == 0){
BEGIN_TIME_SECTION(); BEGIN_TIME_SECTION();
char *cmd = fm_str(BUILD_DIR"/sitegen"); char *cmd = fm_str(BUILD_DIR"/sitegen");
char *code_dir = fm_str("."); char *code_dir = fm_str(".");
@ -439,7 +443,7 @@ site_build(char *cdir, u32 flags){
} }
} }
static void internal void
build_and_run(char *cdir, char *filename, char *name, u32 flags){ build_and_run(char *cdir, char *filename, char *name, u32 flags){
char *dir = fm_str(BUILD_DIR); char *dir = fm_str(BUILD_DIR);
@ -458,17 +462,36 @@ build_and_run(char *cdir, char *filename, char *name, u32 flags){
} }
} }
static void internal void
fsm_generator(char *cdir){ fsm_generator(char *cdir){
build_and_run(cdir, "meta/4ed_fsm_table_generator.cpp", "fsmgen", OPTS | DEBUG_INFO); build_and_run(cdir, "meta/4ed_fsm_table_generator.cpp", "fsmgen", OPTS | DEBUG_INFO);
} }
static void internal void
metagen(char *cdir){ metagen(char *cdir){
build_and_run(cdir, "meta/4ed_metagen.cpp", "metagen", OPTS | DEBUG_INFO); build_and_run(cdir, "meta/4ed_metagen.cpp", "metagen", OPTS | DEBUG_INFO);
} }
static void internal void
string_build(char *cdir){
char *dir = fm_str(BUILD_DIR);
{
char *file = fm_str("string/4ed_string_builder.cpp");
BEGIN_TIME_SECTION();
build(OPTS | DEBUG_INFO, Arch_X64, cdir, file, dir, "string_builder", 0, 0, includes);
END_TIME_SECTION("build string_builder");
}
if (prev_error == 0){
char *cmd = fm_str(cdir, "/", dir, "/string_builder");
BEGIN_TIME_SECTION();
fm_execute_in_dir(fm_str(cdir, "/string"), cmd, 0);
END_TIME_SECTION("run string_builder");
}
}
internal void
do_buildsuper(char *cdir, char *file, u32 arch){ do_buildsuper(char *cdir, char *file, u32 arch){
BEGIN_TIME_SECTION(); BEGIN_TIME_SECTION();
Temp_Dir temp = fm_pushdir(fm_str(BUILD_DIR)); Temp_Dir temp = fm_pushdir(fm_str(BUILD_DIR));
@ -485,7 +508,7 @@ do_buildsuper(char *cdir, char *file, u32 arch){
END_TIME_SECTION("build custom"); END_TIME_SECTION("build custom");
} }
static void internal void
build_main(char *cdir, b32 update_local_theme, u32 flags, u32 arch){ build_main(char *cdir, b32 update_local_theme, u32 flags, u32 arch){
char *dir = fm_str(BUILD_DIR); char *dir = fm_str(BUILD_DIR);
@ -515,7 +538,7 @@ build_main(char *cdir, b32 update_local_theme, u32 flags, u32 arch){
} }
} }
static void internal void
standard_build(char *cdir, u32 flags, u32 arch){ standard_build(char *cdir, u32 flags, u32 arch){
fsm_generator(cdir); fsm_generator(cdir);
metagen(cdir); metagen(cdir);
@ -541,7 +564,7 @@ get_4coder_dist_name(u32 platform, char *tier, u32 arch){
return(name); return(name);
} }
static void internal void
package(char *cdir){ package(char *cdir){
// NOTE(allen): meta // NOTE(allen): meta
fsm_generator(cdir); fsm_generator(cdir);
@ -664,6 +687,9 @@ int main(int argc, char **argv){
#elif defined(SITE_BUILD) #elif defined(SITE_BUILD)
site_build(cdir, DEBUG_INFO); site_build(cdir, DEBUG_INFO);
#elif defined(STRING_BUILD)
string_build(cdir);
#else #else
# error No build type specified. # error No build type specified.
#endif #endif

View File

@ -503,7 +503,7 @@ fm__prepare(umem item_size, void *i1, va_list list){
umem size = listsize(i1, item_size); umem size = listsize(i1, item_size);
void *result = (void*)fm__push(size); void *result = (void*)fm__push(size);
memcpy(result, i1, size); memcpy(result, i1, size);
void *ln = va_arg(list, void*); void *ln = va_arg(list, void*);
for (;ln != 0;){ for (;ln != 0;){
size = listsize(ln, item_size); size = listsize(ln, item_size);
@ -511,7 +511,7 @@ fm__prepare(umem item_size, void *i1, va_list list){
memcpy(new_str, ln, size); memcpy(new_str, ln, size);
ln = va_arg(list, void*); ln = va_arg(list, void*);
} }
void *terminator = (void*)fm__push(item_size); void *terminator = (void*)fm__push(item_size);
memset(terminator, 0, item_size); memset(terminator, 0, item_size);
return(result); return(result);

View File

@ -1,15 +1,16 @@
extensions=".c.cpp.h.m.bat.sh.4coder"; extensions=".c.cpp.h.m.bat.sh.4coder";
open_recursively=true; open_recursively=true;
fkey_command_win[1] = {"echo build: x64 & build.bat", "*compilation*", true , true }; fkey_command_win[1] = {"echo build: x64 & build.bat", "*compilation*" , true , true };
fkey_command_win[2] = {"build_site.bat", "*site*", false , true }; fkey_command_win[2] = {"build_site.bat" , "*site*" , false, true };
fkey_command_win[3] = {"string\\build.bat", "*compilation*", true , true }; fkey_command_win[3] = {"build_string.bat" , "*compilation*" , true , true };
fkey_command_win[4] = {"echo build: x86 & build.bat /DDEV_BUILD_X86", "*compilation*", true , true }; fkey_command_win[4] = {"echo build: x86 & build.bat /DDEV_BUILD_X86" , "*compilation*", true, true };
fkey_command_win[5] = {"..\\misc\\run.bat", "*run*", false, false }; fkey_command_win[5] = {"..\\misc\\run.bat" , "*run*" , false, false };
fkey_command_win[6] = {"run_profile.bat", "*profile*", false, true }; fkey_command_win[6] = {"run_profile.bat" , "*profile*" , false, true };
fkey_command_win[12] = {"package.bat", "*package*", false, true }; fkey_command_win[12] = {"package.bat" , "*package*" , false, true };
fkey_command_linux[1] = {"echo build: x64 & ./build.sh", "*compilation*", true , true }; fkey_command_linux[1] = {"echo build: x64 & ./build.sh", "*compilation*" , true , true };
fkey_command_linux[2] = {"build_site.sh", "*site*", false , true }; fkey_command_linux[2] = {"build_site.sh" , "*site*" , false, true };
fkey_command_linux[4] = {"echo build: x86 & ./build.sh -DDEV_BUILD_X86", "*compilation*", true, true }; fkey_command_linux[3] = {"build_string.sh" , "*compilation*" , true , true };
fkey_command_linux[12] = {"./package.sh", "*package*", false, true }; fkey_command_linux[4] = {"echo build: x86 & ./build.sh -DDEV_BUILD_X86" , "*compilation*", true, true };
fkey_command_linux[12] = {"./package.sh" , "*package*" , false, true };

View File

@ -1,5 +1,5 @@
1 1
0 0
98 92

View File

@ -1,11 +1,16 @@
/* /*
Builder for the 4coder_string.h header. * Mr. 4th Dimention - Allen Webster
By Allen Webster *
Created 21.01.2017 (dd.mm.yyyy) * 21.01.2017
*/ *
* Builder for the 4coder_string.h header.
*
*/
// TOP // TOP
// TODO(allen): Make sure to only publish the 4coder_string.h if it builds and passes a series of tests.
#define BUILD_NUMBER_FILE "4coder_string_build_num.txt" #define BUILD_NUMBER_FILE "4coder_string_build_num.txt"
#define GENERATED_FILE "4coder_string.h" #define GENERATED_FILE "4coder_string.h"
@ -15,31 +20,28 @@ Created 21.01.2017 (dd.mm.yyyy)
#define PUBLISH_FOLDER ".." SLASH "4coder_helper" #define PUBLISH_FOLDER ".." SLASH "4coder_helper"
#include "../4cpp/4cpp_lexer.h" #include "../4cpp/4cpp_lexer.h"
// TODO(allen): Make sure to only publish the 4coder_string.h if it builds and passes a series of tests.
#define FSTRING_IMPLEMENTATION #define FSTRING_IMPLEMENTATION
#include "../4coder_lib/4coder_string.h" #include "../4coder_lib/4coder_string.h"
#include "../4ed_defines.h" #include "../4ed_defines.h"
#include "../meta/4ed_meta_defines.h" #include "../meta/4ed_meta_defines.h"
#define FTECH_FILE_MOVING_IMPLEMENTATION #define FTECH_FILE_MOVING_IMPLEMENTATION
#include "../meta/4ed_file_moving.h" #include "../meta/4ed_file_moving.h"
#include "../4coder_lib/4coder_mem.h"
#include "../meta/4ed_meta_parser.cpp"
#include "../meta/4ed_out_context.cpp"
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "../4coder_lib/4coder_mem.h"
#define V_MAJ_NUM 1 #define V_MAJ_NUM 1
#define V_MIN_NUM 0 #define V_MIN_NUM 0
#define V_MAJ STR_(V_MAJ_NUM) #define V_MAJ STR_(V_MAJ_NUM)
#define V_MIN STR_(V_MIN_NUM) #define V_MIN STR_(V_MIN_NUM)
#include "../meta/4ed_meta_parser.cpp"
#include "../meta/4ed_out_context.cpp"
static b32 static b32
parse_build_number(char *file_name, i32 *major_out, i32 *minor_out, i32 *build_out){ parse_build_number(char *file_name, i32 *major_out, i32 *minor_out, i32 *build_out){
b32 result = false; b32 result = false;
@ -162,6 +164,7 @@ file_move(char *path, char *file_name){
int main(){ int main(){
META_BEGIN(); META_BEGIN();
fm_init_system();
fm_init_system(); fm_init_system();
@ -280,8 +283,6 @@ int main(){
Item_Node *item = string_unit.set.items + j; Item_Node *item = string_unit.set.items + j;
if (item->t == Item_Function){ if (item->t == Item_Function){
//append_ss (&line, item->marker);
//append_padding (&line, ' ', RETURN_PADDING);
append_ss (&line, item->ret); append_ss (&line, item->ret);
append_padding (&line, ' ', SIG_PADDING); append_padding (&line, ' ', SIG_PADDING);
append_ss (&line, item->name); append_ss (&line, item->name);