cleaning up lots of build related stuff

master
Allen Webster 2017-07-07 19:54:50 -04:00
parent dd2a862263
commit 2c0e22e7e1
17 changed files with 411 additions and 460 deletions

View File

@ -14,7 +14,7 @@
#include <assert.h>
#include <string.h>
#include "4tech_defines.h"
#include "4ed_defines.h"
#include "4coder_API/custom.h"

2
site/build.sh → build_site.sh Executable file → Normal file
View File

@ -6,3 +6,5 @@ FLAGS="-D_GNU_SOURCE -fPIC -fpermissive -DSITE_BUILD"
BASEDIR="$PWD"
g++ $WARNINGS $FLAGS $BASEDIR/meta/build.cpp -g -o ../build/build
../build/build

View File

@ -13,78 +13,127 @@ By Allen Webster
#include <stdio.h> // include system for windows
#include <stdlib.h> // include system for linux (YAY!)
#include <stdarg.h>
#if defined(IS_WINDOWS)
# define ONLY_WINDOWS(x) x
# define ONLY_LINUX(x) (void)0
#define SLASH "\\"
static char platform_correct_slash = '\\';
#elif defined(IS_LINUX)
# define ONLY_WINDOWS(x) (void)0
# define ONLY_LINUX(x) x
#define SLASH "/"
static char platform_correct_slash = '/';
#elif defined(IS_MAC)
# define ONLY_WINDOWS(x) (void)0
# define ONLY_LINUX(x) (void)0
#define SLASH "/"
static char platform_correct_slash = '/';
#else
# define ONLY_WINDOWS(x) (void)0
# define ONLY_LINUX(x) (void)0
#define SLASH "/"
static char platform_correct_slash = '/';
#endif
//
// API
//
// System commands
static char SF_CMD[4096];
static i32 error_state = 0;
static i32 prev_error = 0;
#if defined(FM_PRINT_COMMANDS)
#define SYSTEMF_PRINTF(...) printf(__VA_ARGS__);
#else
#define SYSTEMF_PRINTF(...)
#endif
#define systemf(...) do{ \
int32_t n = snprintf(SF_CMD, sizeof(SF_CMD), __VA_ARGS__); \
AllowLocal(n); \
Assert(n < sizeof(SF_CMD)); \
/** printf("%s\n", SF_CMD); /**/ \
SYSTEMF_PRINTF("%s\n", SF_CMD); \
prev_error = system(SF_CMD); \
if (prev_error != 0) error_state = 1; \
}while(0)
static void init_time_system();
static u64 get_time();
static i32 get_current_directory(char *buffer, i32 max);
static void execute_in_dir(char *dir, char *str, char *args);
internal void fm_execute_in_dir(char *dir, char *str, char *args);
static void make_folder_if_missing(char *dir, char *folder);
static void clear_folder(char *folder);
static void delete_file(char *file);
static void copy_file(char *path, char *file, char *folder1, char *folder2, char *newname);
static void copy_all(char *source, char *tag, char *folder);
static void zip(char *parent, char *folder, char *dest);
// Init
internal void fm_init_system();
static void slash_fix(char *path);
#define DECL_STR(n,s) char n[] = s; slash_fix(n)
// Timing
internal u64 fm_get_time();
#define LLU_CAST(n) (long long unsigned int)(n)
#define BEGIN_TIME_SECTION() uint64_t start = fm_get_time()
#define END_TIME_SECTION(n) uint64_t total = fm_get_time() - start; printf("%-20s: %.2llu.%.6llu\n", (n), LLU_CAST(total/1000000), LLU_CAST(total%1000000));
// Files and Folders Manipulation
internal void fm_make_folder_if_missing(char *dir, char *folder);
internal void fm_clear_folder(char *folder);
internal void fm_delete_file(char *file);
internal void fm_copy_file(char *path, char *file, char *folder1, char *folder2, char *newname);
internal void fm_copy_all(char *source, char *tag, char *folder);
internal void fm_copy_folder(char *dst_dir, char *src_folder);
// Zip
internal void fm_zip(char *parent, char *folder, char *dest);
// File Name Manipulation
internal void fm_slash_fix(char *path);
internal char *fm_prepare_string_internal(char *s1, ...);
#define fm_prepare_string(...) fm_prepare_string_internal(__VA_ARGS__, 0)
typedef umem Temp_Memory;
internal Temp_Memory fm_begin_temp();
internal void fm_end_temp(Temp_Memory temp);
// File System Navigation
internal i32 fm_get_current_directory(char *buffer, i32 max);
typedef struct Temp_Dir{
char dir[512];
} Temp_Dir;
static Temp_Dir pushdir(char *dir);
static void popdir(Temp_Dir temp);
internal Temp_Dir fm_pushdir(char *dir);
internal void fm_popdir(Temp_Dir temp);
// Slashes
#if defined(IS_WINDOWS)
#define SLASH "\\"
static char platform_correct_slash = '\\';
#elif defined(IS_LINUX) || defined(IS_MAC)
#define SLASH "/"
static char platform_correct_slash = '/';
#else
#error Slash not set for this platform.
#endif
#endif
//
// Implementation
//
#if defined(FTECH_FILE_MOVING_IMPLEMENTATION) && !defined(FTECH_FILE_MOVING_IMPL_GUARD)
#define FTECH_FILE_MOVING_IMPL_GUARD
char *fm_arena_memory = 0;
umem fm_arena_pos = 0;
umem fm_arena_max = 0;
internal void
fm__init_memory(){
fm_arena_max = MB(16);
fm_arena_memory = (char*)malloc(fm_arena_max);
}
internal Temp_Memory
fm_begin_temp(){
return(fm_arena_pos);
}
internal void
fm_end_temp(Temp_Memory temp){
fm_arena_pos = temp;
}
internal void*
fm__push(umem size){
void *result = fm_arena_memory + fm_arena_pos;
if (size + fm_arena_pos > fm_arena_max){
result = 0;
}
else{
fm_arena_pos += size;
}
return(result);
}
#if defined(IS_WINDOWS)
typedef uint32_t DWORD;
@ -123,8 +172,17 @@ extern "C"{
static uint64_t perf_frequency;
static void
fm_init_system(){
LARGE_INTEGER lint;
if (QueryPerformanceFrequency(&lint)){
perf_frequency = lint.QuadPart;
}
fm__init_memory();
}
static Temp_Dir
pushdir(char *dir){
fm_pushdir(char *dir){
Temp_Dir temp = {0};
GetCurrentDirectoryA(sizeof(temp.dir), temp.dir);
SetCurrentDirectoryA(dir);
@ -132,20 +190,12 @@ pushdir(char *dir){
}
static void
popdir(Temp_Dir temp){
fm_popdir(Temp_Dir temp){
SetCurrentDirectoryA(temp.dir);
}
static void
init_time_system(){
LARGE_INTEGER lint;
if (QueryPerformanceFrequency(&lint)){
perf_frequency = lint.QuadPart;
}
}
static uint64_t
get_time(){
fm_get_time(){
uint64_t time = 0;
LARGE_INTEGER lint;
if (QueryPerformanceCounter(&lint)){
@ -156,22 +206,22 @@ get_time(){
}
static int32_t
get_current_directory(char *buffer, int32_t max){
fm_get_current_directory(char *buffer, int32_t max){
int32_t result = GetCurrentDirectoryA(max, buffer);
return(result);
}
static void
execute_in_dir(char *dir, char *str, char *args){
fm_execute_in_dir(char *dir, char *str, char *args){
if (dir){
Temp_Dir temp = pushdir(dir);
Temp_Dir temp = fm_pushdir(dir);
if (args){
systemf("call \"%s\" %s", str, args);
}
else{
systemf("call \"%s\"", str);
}
popdir(temp);
fm_popdir(temp);
}
else{
if (args){
@ -184,7 +234,7 @@ execute_in_dir(char *dir, char *str, char *args){
}
static void
slash_fix(char *path){
fm_slash_fix(char *path){
if (path){
for (int32_t i = 0; path[i]; ++i){
if (path[i] == '/') path[i] = '\\';
@ -193,7 +243,7 @@ slash_fix(char *path){
}
static void
make_folder_if_missing(char *dir, char *folder){
fm_make_folder_if_missing(char *dir, char *folder){
char space[1024];
String path = make_fixed_width_string(space);
append_sc(&path, dir);
@ -215,17 +265,17 @@ make_folder_if_missing(char *dir, char *folder){
}
static void
clear_folder(char *folder){
fm_clear_folder(char *folder){
systemf("del /S /Q /F %s\\* & rmdir /S /Q %s & mkdir %s", folder, folder, folder);
}
static void
delete_file(char *file){
fm_delete_file(char *file){
systemf("del %s", file);
}
static void
copy_file(char *path, char *file, char *folder1, char *folder2, char *newname){
fm_copy_file(char *path, char *file, char *folder1, char *folder2, char *newname){
char src[256], dst[256];
String b = make_fixed_width_string(src);
if (path){
@ -254,7 +304,7 @@ copy_file(char *path, char *file, char *folder1, char *folder2, char *newname){
}
static void
copy_all(char *source, char *tag, char *folder){
fm_copy_all(char *source, char *tag, char *folder){
if (source){
systemf("copy %s\\%s %s\\*", source, tag, folder);
}
@ -264,15 +314,15 @@ copy_all(char *source, char *tag, char *folder){
}
static void
zip(char *parent, char *folder, char *dest){
fm_zip(char *parent, char *folder, char *dest){
char cdir[512];
get_current_directory(cdir, sizeof(cdir));
fm_get_current_directory(cdir, sizeof(cdir));
Temp_Dir temp = pushdir(parent);
systemf("%s\\zip %s\\4tech_gobble.zip", cdir, cdir);
popdir(temp);
Temp_Dir temp = fm_pushdir(parent);
systemf("%s\\zip %s\\4ed_gobble.zip", cdir, cdir);
fm_popdir(temp);
systemf("copy %s\\4tech_gobble.zip %s & del %s\\4tech_gobble.zip", cdir, dest, cdir);
systemf("copy %s\\4ed_gobble.zip %s & del %s\\4ed_gobble.zip", cdir, dest, cdir);
}
#elif defined(IS_LINUX) || defined(IS_MAC)
@ -281,7 +331,7 @@ zip(char *parent, char *folder, char *dest){
#include <unistd.h>
static Temp_Dir
pushdir(char *dir){
fm_pushdir(char *dir){
Temp_Dir temp;
char *result = getcwd(temp.dir, sizeof(temp.dir));
int32_t chresult = chdir(dir);
@ -294,17 +344,17 @@ pushdir(char *dir){
}
static void
popdir(Temp_Dir temp){
fm_popdir(Temp_Dir temp){
chdir(temp.dir);
}
static void
init_time_system(){
fm_init_time_system(){
// NOTE(allen): do nothing
}
static uint64_t
get_time(){
fm_get_time(){
struct timespec spec;
uint64_t result;
clock_gettime(CLOCK_MONOTONIC, &spec);
@ -313,7 +363,7 @@ get_time(){
}
static int32_t
get_current_directory(char *buffer, int32_t max){
fm_get_current_directory(char *buffer, int32_t max){
int32_t result = 0;
char *d = getcwd(buffer, max);
if (d == buffer){
@ -323,15 +373,15 @@ get_current_directory(char *buffer, int32_t max){
}
static void
execute_in_dir(char *dir, char *str, char *args){
fm_execute_in_dir(char *dir, char *str, char *args){
if (dir){
if (args){
Temp_Dir temp = pushdir(dir);
Temp_Dir temp = fm_pushdir(dir);
systemf("%s %s", str, args);
popdir(temp);
}
else{
Temp_Dir temp = pushdir(dir);
Temp_Dir temp = fm_pushdir(dir);
systemf("%s", str);
popdir(temp);
}
@ -347,10 +397,10 @@ execute_in_dir(char *dir, char *str, char *args){
}
static void
slash_fix(char *path){}
fm_slash_fix(char *path){}
static void
make_folder_if_missing(char *dir, char *folder){
fm_make_folder_if_missing(char *dir, char *folder){
if (folder){
systemf("mkdir -p %s/%s", dir, folder);
}
@ -360,17 +410,17 @@ make_folder_if_missing(char *dir, char *folder){
}
static void
clear_folder(char *folder){
fm_clear_folder(char *folder){
systemf("rm -rf %s*", folder);
}
static void
delete_file(char *file){
fm_delete_file(char *file){
systemf("rm %s", file);
}
static void
copy_file(char *path, char *file, char *folder1, char *folder2, char *newname){
fm_copy_file(char *path, char *file, char *folder1, char *folder2, char *newname){
if (!newname){
newname = file;
}
@ -394,7 +444,7 @@ copy_file(char *path, char *file, char *folder1, char *folder2, char *newname){
}
static void
copy_all(char *source, char *tag, char *folder){
fm_copy_all(char *source, char *tag, char *folder){
if (source){
systemf("cp -f %s/%s %s", source, tag, folder);
}
@ -404,11 +454,11 @@ copy_all(char *source, char *tag, char *folder){
}
static void
zip(char *parent, char *folder, char *file){
Temp_Dir temp = pushdir(parent);
fm_zip(char *parent, char *folder, char *file){
Temp_Dir temp = fm_pushdir(parent);
printf("PARENT DIR: %s\n", parent);
systemf("zip -r %s %s", file, folder);
popdir(temp);
}
@ -416,6 +466,48 @@ zip(char *parent, char *folder, char *file){
#error This OS is not supported yet
#endif
internal void
fm_copy_folder(char *dst_dir, char *src_folder){
fm_make_folder_if_missing(dst_dir, src_folder);
char space[256];
String copy_name = make_fixed_width_string(space);
append_sc(&copy_name, dst_dir);
append_s_char(&copy_name, platform_correct_slash);
append_sc(&copy_name, src_folder);
terminate_with_null(&copy_name);
fm_copy_all(src_folder, "*", copy_name.str);
}
internal char*
fm_prepare_string_internal(char *s1, ...){
i32 len = str_size(s1);
char *result = (char*)fm__push(len);
memcpy(result, s1, len);
va_list list;
va_start(list, s1);
for (;;){
char *sn = va_arg(list, char*);
if (sn == 0){
break;
}
else{
len = str_size(sn);
char *new_str = (char*)fm__push(len);
memcpy(new_str, sn, len);
}
}
va_end(list);
char *terminator = (char*)fm__push(1);
*terminator = 0;
fm_slash_fix(result);
return(result);
}
#endif
// BOTTOM

View File

@ -9,7 +9,7 @@ Created 21.01.2017 (dd.mm.yyyy)
#if !defined(FTECH_META_DEFINES_H)
#define FTECH_META_DEFINES_H
#include "../4tech_defines.h"
#include "../4ed_defines.h"
#include <setjmp.h>
#include <stdio.h>

View File

@ -15,7 +15,7 @@
#define API_H "4coder_API/app_functions.h"
#define OS_API_H "4ed_os_custom_api.h"
#include "4tech_meta_defines.h"
#include "4ed_meta_defines.h"
#include "../4coder_API/version.h"
#define FSTRING_IMPLEMENTATION

View File

@ -4,8 +4,10 @@
// TOP
#include "../4tech_defines.h"
#include "4tech_file_moving.h"
//#define FM_PRINT_COMMANDS
#include "../4ed_defines.h"
#include "4ed_file_moving.h"
#include <assert.h>
#include <string.h>
@ -19,17 +21,6 @@
// reusable
//
#define IS_64BIT
#define LLU_CAST(n) (long long unsigned int)(n)
#define BEGIN_TIME_SECTION() uint64_t start = get_time()
#define END_TIME_SECTION(n) uint64_t total = get_time() - start; printf("%-20s: %.2llu.%.6llu\n", (n), LLU_CAST(total/1000000), LLU_CAST(total%1000000));
//
// 4coder specific
//
#if defined(IS_WINDOWS)
#define EXE ".exe"
#elif defined(IS_LINUX) || defined(IS_MAC)
@ -70,23 +61,6 @@ swap_ptr(char **A, char **B){
*B = a;
}
enum{
OPTS = 0x1,
INCLUDES = 0x2,
LIBS = 0x4,
ICON = 0x8,
SHARED_CODE = 0x10,
DEBUG_INFO = 0x20,
SUPER = 0x40,
INTERNAL = 0x80,
OPTIMIZATION = 0x100,
KEEP_ASSERT = 0x200,
SITE_INCLUDES = 0x400,
X86 = 0x800,
LOG = 0x1000,
};
#define BUILD_LINE_MAX 4096
typedef struct Build_Line{
char build_optionsA[BUILD_LINE_MAX];
@ -124,6 +98,81 @@ init_build_line(Build_Line *line){
#endif
//
// 4coder specific
//
enum{
Platform_Windows,
Platform_Linux,
Platform_Mac,
//
Platform_COUNT,
};
enum{
Compiler_CL,
Compiler_GCC,
//
Compiler_COUNT,
};
#if defined(IS_WINDOWS)
# define THIS_OS Platform_Windows
#elif defined(IS_LINUX)
# define THIS_OS Platform_Linux
#elif defined(IS_MAC)
# define THIS_OS Platform_Mac
#else
# error This platform is not enumerated.
#endif
#if defined(IS_CL)
# define THIS_COMPILER Compiler_CL
#elif defined(IS_GCC)
# define THIS_COMPILER Compiler_GCC
#else
# error This compilers is not enumerated.
#endif
char *windows_platform_layer[] = { "platform_win32\\win32_4ed.cpp", 0 };
char *linux_platform_layer[] = { "platform_linux/linux_4ed.cpp", 0 };
char *mac_platform_layer[] = { "platform_mac/mac_4ed.m", "platform_mac/mac_4ed.cpp", 0 };
char **platform_layers[Platform_COUNT] = {
windows_platform_layer,
linux_platform_layer ,
mac_platform_layer ,
};
char *windows_cl_platform_inc[] = { ".", "platform_all", 0 };
char *linux_gcc_platform_inc[] = { "platform_all", "platform_unix", 0 };
char *mac_gcc_platform_inc[] = { "platform_all", "platform_unix", 0 };
char **platform_includes[Platform_COUNT][Compiler_COUNT] = {
{windows_cl_platform_inc, 0 },
{0 , linux_gcc_platform_inc },
{0 , mac_gcc_platform_inc },
};
#define BUILD_DIR "../build"
enum{
OPTS = 0x1,
INCLUDES = 0x2,
LIBS = 0x4,
ICON = 0x8,
SHARED_CODE = 0x10,
DEBUG_INFO = 0x20,
SUPER = 0x40,
INTERNAL = 0x80,
OPTIMIZATION = 0x100,
KEEP_ASSERT = 0x200,
SITE_INCLUDES = 0x400,
X86 = 0x800,
LOG = 0x1000,
};
#if defined(IS_CL)
//
@ -255,9 +304,9 @@ build(u32 flags, char *code_path, char **code_files, char *out_path, char *out_f
swap_ptr(&link_line.build_options, &link_line.build_options_prev);
swap_ptr(&line_prefix.build_options, &line_prefix.build_options_prev);
Temp_Dir temp = pushdir(out_path);
Temp_Dir temp = fm_pushdir(out_path);
systemf("%scl %s /Fe%s /link /INCREMENTAL:NO %s", line_prefix.build_options, line.build_options, out_file, link_line.build_options);
popdir(temp);
fm_popdir(temp);
}
#elif defined(IS_GCC)
@ -402,7 +451,7 @@ build(u32 flags, char *code_path, char *code_file, char *out_path, char *out_fil
static void
buildsuper(char *code_path, char *out_path, char *filename, b32 x86_build){
Temp_Dir temp = pushdir(out_path);
Temp_Dir temp = fm_pushdir(out_path);
#if defined(IS_CL)
{
char *prefix_1 = "";
@ -422,63 +471,14 @@ buildsuper(char *code_path, char *out_path, char *filename, b32 x86_build){
#else
# error The build rule for this compiler is not ready
#endif
popdir(temp);
fm_popdir(temp);
}
#if defined(IS_WINDOWS)
char *PLAT_LAYER[] = { "platform_win32\\win32_4ed.cpp", 0 };
# if defined(IS_CL)
char *PLAT_INC[] = {
".",
"platform_all",
0
};
# else
# error PLAT_INC not defines for this compiler/platform combo
# endif
#elif defined(IS_LINUX)
char *PLAT_LAYER[] = { "platform_linux/linux_4ed.cpp", 0 };
# if defined(IS_GCC)
char *PLAT_INC[] = {
"platform_all",
"platform_unix",
0
};
# else
# error PLAT_INC not defines for this compiler/platform combo
# endif
#elif defined(IS_MAC)
char *PLAT_LAYER[] = {
"platform_mac/mac_4ed.m",
"platform_mac/mac_4ed.cpp",
0
};
# if defined(IS_GCC)
char *PLAT_INC[] = {
"platform_all",
"platform_unix",
0
};
# else
# error PLAT_INC not defines for this compiler/platform combo
# endif
#else
# error No platform layer defined for this OS.
#endif
#define BUILD_DIR "../build"
static void
fsm_generator(char *cdir){
{
DECL_STR(file, "meta/fsm_table_generator.cpp");
DECL_STR(dir, BUILD_DIR);
char *file = fm_prepare_string("meta/fsm_table_generator.cpp", 0);
char *dir = fm_prepare_string(BUILD_DIR, 0);
BEGIN_TIME_SECTION();
build(OPTS | DEBUG_INFO, cdir, file, dir, "fsmgen", 0, 0);
@ -486,9 +486,9 @@ fsm_generator(char *cdir){
}
if (prev_error == 0){
DECL_STR(cmd, BUILD_DIR"/fsmgen");
char *cmd = fm_prepare_string(BUILD_DIR"/fsmgen", 0);
BEGIN_TIME_SECTION();
execute_in_dir(cdir, cmd, 0);
fm_execute_in_dir(cdir, cmd, 0);
END_TIME_SECTION("run fsm generator");
}
}
@ -496,8 +496,8 @@ fsm_generator(char *cdir){
static void
metagen(char *cdir){
{
DECL_STR(file, "meta/4ed_metagen.cpp");
DECL_STR(dir, BUILD_DIR);
char *file = fm_prepare_string("meta/4ed_metagen.cpp", 0);
char *dir = fm_prepare_string(BUILD_DIR, 0);
BEGIN_TIME_SECTION();
build(OPTS | INCLUDES | DEBUG_INFO, cdir, file, dir, "metagen", 0, 0);
@ -505,9 +505,9 @@ metagen(char *cdir){
}
if (prev_error == 0){
DECL_STR(cmd, BUILD_DIR"/metagen");
char *cmd = fm_prepare_string(BUILD_DIR"/metagen", 0);
BEGIN_TIME_SECTION();
execute_in_dir(cdir, cmd, 0);
fm_execute_in_dir(cdir, cmd, 0);
END_TIME_SECTION("run metagen");
}
}
@ -555,7 +555,7 @@ do_buildsuper(char *cdir, i32 custom_option, u32 flags){
x86_build = true;
}
DECL_STR(dir, BUILD_DIR);
char *dir = fm_prepare_string(BUILD_DIR, 0);
buildsuper(cdir, dir, str.str, x86_build);
END_TIME_SECTION("build custom");
@ -563,10 +563,10 @@ do_buildsuper(char *cdir, i32 custom_option, u32 flags){
static void
build_main(char *cdir, u32 flags){
DECL_STR(dir, BUILD_DIR);
char *dir = fm_prepare_string(BUILD_DIR);
{
DECL_STR(file, "4ed_app_target.cpp");
char *file = fm_prepare_string("4ed_app_target.cpp");
BEGIN_TIME_SECTION();
build(OPTS | INCLUDES | SHARED_CODE | flags, cdir, file, dir, "4ed_app" DLL, "/EXPORT:app_get_functions", 0);
END_TIME_SECTION("build 4ed_app");
@ -574,18 +574,17 @@ build_main(char *cdir, u32 flags){
{
BEGIN_TIME_SECTION();
build(OPTS | INCLUDES | LIBS | ICON | flags, cdir, PLAT_LAYER, dir, "4ed", 0, PLAT_INC);
build(OPTS | INCLUDES | LIBS | ICON | flags, cdir, platform_layers[THIS_OS], dir, "4ed", 0, platform_includes[THIS_OS][THIS_COMPILER]);
END_TIME_SECTION("build 4ed");
}
{
BEGIN_TIME_SECTION();
DECL_STR(themes_folder, "../build/themes");
DECL_STR(source_themes_folder, "themes");
clear_folder(themes_folder);
make_folder_if_missing(themes_folder, 0);
copy_all(source_themes_folder, "*", themes_folder);
char *themes_folder = fm_prepare_string("../build/themes");
char *source_themes_folder = fm_prepare_string("themes");
fm_clear_folder(themes_folder);
fm_make_folder_if_missing(themes_folder, 0);
fm_copy_all(source_themes_folder, "*", themes_folder);
END_TIME_SECTION("move files");
}
}
@ -604,8 +603,8 @@ standard_build(char *cdir, u32 flags){
static void
site_build(char *cdir, u32 flags){
{
DECL_STR(file, "site/sitegen.cpp");
DECL_STR(dir, BUILD_DIR"/site");
char *file = fm_prepare_string("site/sitegen.cpp");
char *dir = fm_prepare_string(BUILD_DIR"/site");
BEGIN_TIME_SECTION();
build(OPTS | SITE_INCLUDES | flags, cdir, file, dir, "sitegen", 0, 0);
END_TIME_SECTION("build sitegen");
@ -613,7 +612,7 @@ site_build(char *cdir, u32 flags){
{
BEGIN_TIME_SECTION();
DECL_STR(cmd, "../build/site/sitegen . ../site_resources site/source_material ../site");
char *cmd = fm_prepare_string("../build/site/sitegen . ../site_resources site/source_material ../site");
systemf("%s", cmd);
END_TIME_SECTION("run sitegen");
}
@ -646,9 +645,9 @@ get_4coder_dist_name(String *zip_file, b32 OS_specific, char *folder, char *tier
if (OS_specific){
#if defined(IS_WINDOWS)
append_sc(zip_file, "-win");
#elif defined(IS_LINUX) && defined(IS_64BIT)
#elif defined(IS_LINUX)
append_sc(zip_file, "-linux");
#elif defined(IS_MAC) && defined(IS_64BIT)
#elif defined(IS_MAC)
append_sc(zip_file, "-mac");
#else
#error No OS string for zips on this OS
@ -662,21 +661,7 @@ get_4coder_dist_name(String *zip_file, b32 OS_specific, char *folder, char *tier
append_sc (zip_file, ext);
terminate_with_null(zip_file);
slash_fix(zip_file->str);
}
static void
copy_folder(char *dst_dir, char *src_folder){
make_folder_if_missing(dst_dir, src_folder);
char space[256];
String copy_name = make_fixed_width_string(space);
append_sc(&copy_name, dst_dir);
append_s_char(&copy_name, platform_correct_slash);
append_sc(&copy_name, src_folder);
terminate_with_null(&copy_name);
copy_all(src_folder, "*", copy_name.str);
fm_slash_fix(zip_file->str);
}
static void
@ -690,294 +675,182 @@ package(char *cdir){
#define SITE_DIR "../site"
#define PACK_FONTS_DIR "../code/dist_files/fonts"
char *build_dir = fm_prepare_string(BUILD_DIR);
char *site_dir = fm_prepare_string(SITE_DIR);
char *pack_dir = fm_prepare_string(PACK_DIR);
char *pack_fonts_dir = fm_prepare_string(PACK_FONTS_DIR);
DECL_STR(build_dir, BUILD_DIR);
DECL_STR(site_dir, SITE_DIR);
DECL_STR(pack_dir, PACK_DIR);
DECL_STR(pack_fonts_dir, PACK_FONTS_DIR);
u32 arch_count = 2;
char *arch_names[] = {
"x64",
"x86",
};
Assert(ArrayCount(arch_names) == arch_count);
#define PACK_ALPHA_PAR_DIR "../current_dist"
#define PACK_ALPHA_DIR PACK_ALPHA_PAR_DIR"/4coder"
#define PACK_ALPHA_FONTS_DIR PACK_ALPHA_DIR"/fonts"
DECL_STR(pack_alpha_par_dir, PACK_ALPHA_PAR_DIR);
DECL_STR(pack_alpha_dir, PACK_ALPHA_DIR);
DECL_STR(pack_alpha_fonts_dir, PACK_ALPHA_FONTS_DIR);
u32 arch_flags[] = {
0,
X86,
};
Assert(ArrayCount(arch_flags) == arch_count);
#define PACK_ALPHA_X86_PAR_DIR "../current_dist_x86"
#define PACK_ALPHA_X86_DIR PACK_ALPHA_X86_PAR_DIR"/4coder"
#define PACK_ALPHA_X86_FONTS_DIR PACK_ALPHA_X86_DIR"/fonts"
DECL_STR(pack_alpha_x86_par_dir, PACK_ALPHA_X86_PAR_DIR);
DECL_STR(pack_alpha_x86_dir, PACK_ALPHA_X86_DIR);
DECL_STR(pack_alpha_x86_fonts_dir, PACK_ALPHA_X86_FONTS_DIR);
char *base_package_root = "../current_dist";
// NOTE(allen): alpha
{
char *dest_dirs[] = {
pack_alpha_dir,
pack_alpha_x86_dir,
};
char *dest_par_dirs[] = {
pack_alpha_par_dir,
pack_alpha_x86_par_dir,
};
char *dest_fonts_dirs[] = {
pack_alpha_fonts_dir,
pack_alpha_x86_fonts_dir,
};
char *zip_dirs[] = {
"alpha",
"alpha_x86",
};
Temp_Memory temp = fm_begin_temp();
char *tier = "alpha";
char *archs[] = {
"x64",
"x86",
};
Assert(ArrayCount(dest_dirs) == ArrayCount(dest_par_dirs));
u32 count = ArrayCount(dest_dirs);
char *tier_package_root = fm_prepare_string(base_package_root, "_", tier);
u32 base_flags = OPTIMIZATION | KEEP_ASSERT | DEBUG_INFO | LOG;
u32 flags[] = {
0,
X86,
};
for (u32 i = 0; i < count; ++i){
char *dir = dest_dirs[i];
char *par_dir = dest_par_dirs[i];
char *fonts_dir = dest_fonts_dirs[i];
char *zip_dir = zip_dirs[i];
char *arch = archs[i];
for (u32 i = 0; i < arch_count; ++i){
char *package_root = fm_prepare_string(tier_package_root, "_", arch_names[i]);
char *par_dir = fm_prepare_string(package_root);
char *dir = fm_prepare_string(par_dir, "/4coder");
char *fonts_dir = fm_prepare_string(dir, "/fonts");
char *zip_dir = fm_prepare_string(tier, "_", arch_names[i]);
build_main(cdir, base_flags | flags[i]);
build_main(cdir, base_flags | arch_flags[i]);
clear_folder(par_dir);
make_folder_if_missing(dir, 0);
make_folder_if_missing(dir, "fonts");
make_folder_if_missing(pack_dir, zip_dir);
copy_file(build_dir, "4ed" EXE, dir, 0, 0);
copy_file(build_dir, "4ed_app" DLL, dir, 0, 0);
copy_all(pack_fonts_dir, "*", fonts_dir);
copy_file(cdir, "release-config.4coder", dir, 0, "config.4coder");
fm_clear_folder(par_dir);
fm_make_folder_if_missing(dir, 0);
fm_make_folder_if_missing(dir, "fonts");
fm_make_folder_if_missing(pack_dir, zip_dir);
fm_copy_file(build_dir, "4ed" EXE, dir, 0, 0);
fm_copy_file(build_dir, "4ed_app" DLL, dir, 0, 0);
fm_copy_all(pack_fonts_dir, "*", fonts_dir);
fm_copy_file(cdir, "release-config.4coder", dir, 0, "config.4coder");
copy_folder(dir, "themes");
fm_copy_folder(dir, "themes");
copy_file(cdir, "LICENSE.txt", dir, 0, 0);
copy_file(cdir, "README.txt", dir, 0, 0);
fm_copy_file(cdir, "LICENSE.txt", dir, 0, 0);
fm_copy_file(cdir, "README.txt", dir, 0, 0);
get_4coder_dist_name(&str, true, zip_dir, tier, arch, "zip");
zip(par_dir, "4coder", str.str);
get_4coder_dist_name(&str, true, zip_dir, tier, arch_names[i], "zip");
fm_zip(par_dir, "4coder", str.str);
}
fm_end_temp(temp);
}
// NOTE(allen): super
#define PACK_SUPER_PAR_DIR "../current_dist_super"
#define PACK_SUPER_DIR PACK_SUPER_PAR_DIR"/4coder"
#define PACK_SUPER_FONTS_DIR PACK_SUPER_DIR"/fonts"
DECL_STR(pack_super_par_dir, PACK_SUPER_PAR_DIR);
DECL_STR(pack_super_dir, PACK_SUPER_DIR);
DECL_STR(pack_super_fonts_dir, PACK_SUPER_FONTS_DIR);
#define PACK_SUPER_X86_PAR_DIR "../current_dist_super_x86"
#define PACK_SUPER_X86_DIR PACK_SUPER_X86_PAR_DIR"/4coder"
#define PACK_SUPER_X86_FONTS_DIR PACK_SUPER_X86_DIR"/fonts"
DECL_STR(pack_super_x86_par_dir, PACK_SUPER_X86_PAR_DIR);
DECL_STR(pack_super_x86_dir, PACK_SUPER_X86_DIR);
DECL_STR(pack_super_x86_fonts_dir, PACK_SUPER_X86_FONTS_DIR);
{
char *dest_dirs[] = {
pack_super_dir,
pack_super_x86_dir,
};
char *dest_par_dirs[] = {
pack_super_par_dir,
pack_super_x86_par_dir,
};
char *dest_fonts_dirs[] = {
pack_super_fonts_dir,
pack_super_x86_fonts_dir,
};
char *zip_dirs[] = {
"super",
"super_x86",
};
Temp_Memory temp = fm_begin_temp();
char *tier = "super";
char *archs[] = {
"x64",
"x86",
};
Assert(ArrayCount(dest_dirs) == ArrayCount(dest_par_dirs));
u32 count = ArrayCount(dest_dirs);
u32 base_flags = OPTIMIZATION | KEEP_ASSERT | DEBUG_INFO | SUPER | LOG;
u32 flags[] = {
0,
X86,
};
for (u32 i = 0; i < count; ++i){
char *dir = dest_dirs[i];
char *par_dir = dest_par_dirs[i];
char *fonts_dir = dest_fonts_dirs[i];
char *zip_dir = zip_dirs[i];
char *arch = archs[i];
char *tier_package_root = fm_prepare_string(base_package_root, "_", tier);
u32 base_flags = OPTIMIZATION | KEEP_ASSERT | DEBUG_INFO | LOG | SUPER;
for (u32 i = 0; i < arch_count; ++i){
char *package_root = fm_prepare_string(tier_package_root, "_", arch_names[i]);
char *par_dir = fm_prepare_string(package_root);
char *dir = fm_prepare_string(par_dir, "/4coder");
char *fonts_dir = fm_prepare_string(dir, "/fonts");
char *zip_dir = fm_prepare_string(tier, "_", arch_names[i]);
build_main(cdir, base_flags | flags[i]);
do_buildsuper(cdir, Custom_Default, flags[i]);
build_main(cdir, base_flags | arch_flags[i]);
do_buildsuper(cdir, Custom_Default, arch_flags[i]);
clear_folder(par_dir);
make_folder_if_missing(dir, 0);
make_folder_if_missing(dir, "fonts");
make_folder_if_missing(pack_dir, zip_dir);
fm_clear_folder(par_dir);
fm_make_folder_if_missing(dir, 0);
fm_make_folder_if_missing(dir, "fonts");
fm_make_folder_if_missing(pack_dir, zip_dir);
copy_file(build_dir, "4ed" EXE, dir, 0, 0);
copy_file(build_dir, "4ed_app" DLL, dir, 0, 0);
copy_file(build_dir, "custom_4coder" DLL, dir, 0, 0);
copy_all(pack_fonts_dir, "*", fonts_dir);
copy_file(cdir, "release-config.4coder", dir, 0, "config.4coder");
fm_copy_file(build_dir, "4ed" EXE, dir, 0, 0);
fm_copy_file(build_dir, "4ed_app" DLL, dir, 0, 0);
fm_copy_file(build_dir, "custom_4coder" DLL, dir, 0, 0);
fm_copy_all(pack_fonts_dir, "*", fonts_dir);
fm_copy_file(cdir, "release-config.4coder", dir, 0, "config.4coder");
copy_all(0, "4coder_*", dir);
fm_copy_all(0, "4coder_*", dir);
if (!(flags[i] & X86)){
copy_file(0, "buildsuper" BAT, dir, 0, 0);
if (!(arch_flags[i] & X86)){
fm_copy_file(0, "buildsuper" BAT, dir, 0, "buildsuper" BAT);
}
else{
copy_file(0, "buildsuper_x86" BAT, dir, 0, "buildsuper" BAT);
fm_copy_file(0, "buildsuper_x86" BAT, dir, 0, "buildsuper" BAT);
}
#if defined(IS_WINDOWS)
copy_folder(dir, "windows_scripts");
fm_copy_folder(dir, "windows_scripts");
#endif
copy_folder(dir, "4coder_API");
copy_folder(dir, "4coder_helper");
copy_folder(dir, "4coder_lib");
copy_folder(dir, "4cpp");
copy_folder(dir, "languages");
copy_folder(dir, "themes");
fm_copy_folder(dir, "4coder_API");
fm_copy_folder(dir, "4coder_helper");
fm_copy_folder(dir, "4coder_lib");
fm_copy_folder(dir, "4cpp");
fm_copy_folder(dir, "languages");
fm_copy_folder(dir, "themes");
copy_file(cdir, "LICENSE.txt", dir, 0, 0);
copy_file(cdir, "README.txt", dir, 0, 0);
fm_copy_file(cdir, "LICENSE.txt", dir, 0, 0);
fm_copy_file(cdir, "README.txt", dir, 0, 0);
get_4coder_dist_name(&str, true, zip_dir, tier, arch, "zip");
zip(par_dir, "4coder", str.str);
get_4coder_dist_name(&str, true, zip_dir, tier, arch_names[i], "zip");
fm_zip(par_dir, "4coder", str.str);
}
make_folder_if_missing(pack_dir, "super-docs");
fm_make_folder_if_missing(pack_dir, "super-docs");
get_4coder_dist_name(&str, false, "super-docs", "API", 0, "html");
String str2 = front_of_directory(str);
copy_file(site_dir, "custom_docs.html", pack_dir, "super-docs", str2.str);
fm_copy_file(site_dir, "custom_docs.html", pack_dir, "super-docs", str2.str);
fm_end_temp(temp);
}
// NOTE(allen): power
#define PACK_POWER_PAR_DIR "../current_dist_power"
#define PACK_POWER_DIR PACK_POWER_PAR_DIR"/power"
DECL_STR(pack_power_par_dir, PACK_POWER_PAR_DIR);
DECL_STR(pack_power_dir, PACK_POWER_DIR);
clear_folder(pack_power_par_dir);
make_folder_if_missing(pack_power_dir, 0);
make_folder_if_missing(pack_dir, "power");
copy_all("power", "*", pack_power_dir);
get_4coder_dist_name(&str, 0, "power", 0, 0, "zip");
zip(pack_power_par_dir, "power", str.str);
{
Temp_Memory temp = fm_begin_temp();
char *pack_power_par_dir = fm_prepare_string("../current_dist_power");
char *pack_power_dir = fm_prepare_string(pack_power_par_dir, "/power");
fm_clear_folder(pack_power_par_dir);
fm_make_folder_if_missing(pack_power_dir, 0);
fm_make_folder_if_missing(pack_dir, "power");
fm_copy_all("power", "*", pack_power_dir);
get_4coder_dist_name(&str, 0, "power", "power", 0, "zip");
fm_zip(pack_power_par_dir, "power", str.str);
fm_end_temp(temp);
}
}
#if defined(DEV_BUILD) || defined(OPT_BUILD)
int main(int argc, char **argv){
init_time_system();
fm_init_system();
char cdir[256];
BEGIN_TIME_SECTION();
i32 n = get_current_directory(cdir, sizeof(cdir));
i32 n = fm_get_current_directory(cdir, sizeof(cdir));
assert(n < sizeof(cdir));
END_TIME_SECTION("current directory");
#if defined(DEV_BUILD) || defined(OPT_BUILD) || defined(DEV_BUILD_X86)
u32 flags = DEBUG_INFO | SUPER | INTERNAL | LOG;
#if defined(OPT_BUILD)
flags |= OPTIMIZATION;
#endif
#if defined(DEV_BUILD_X86)
flags |= X86;
#endif
standard_build(cdir, flags);
return(error_state);
}
#elif defined(DEV_BUILD_X86)
int main(int argc, char **argv){
init_time_system();
char cdir[256];
BEGIN_TIME_SECTION();
i32 n = get_current_directory(cdir, sizeof(cdir));
assert(n < sizeof(cdir));
END_TIME_SECTION("current directory");
u32 flags = DEBUG_INFO | SUPER | INTERNAL | X86 | LOG;
standard_build(cdir, flags);
return(error_state);
}
#elif defined(PACKAGE)
int main(int argc, char **argv){
init_time_system();
char cdir[256];
BEGIN_TIME_SECTION();
i32 n = get_current_directory(cdir, sizeof(cdir));
assert(n < sizeof(cdir));
END_TIME_SECTION("current directory");
package(cdir);
return(error_state);
}
#elif defined(SITE_BUILD)
int main(int argc, char **argv){
init_time_system();
char cdir[256];
BEGIN_TIME_SECTION();
i32 n = get_current_directory(cdir, sizeof(cdir));
assert(n < sizeof(cdir));
END_TIME_SECTION("current directory");
site_build(cdir, DEBUG_INFO);
#else
#error No build type specified.
#endif
return(error_state);
}
#else
#error No build type specified
#endif
#define FTECH_FILE_MOVING_IMPLEMENTATION
#include "4tech_file_moving.h"
#include "4ed_file_moving.h"
// BOTTOM

View File

@ -14,7 +14,7 @@
#include <assert.h>
#include <string.h>
#include "4tech_defines.h"
#include "4ed_defines.h"
#include "4coder_API/version.h"
#include "4coder_lib/4coder_utf8.h"

View File

@ -11,7 +11,7 @@
#define IS_PLAT_LAYER
#include "4tech_defines.h"
#include "4ed_defines.h"
#include "4coder_API/version.h"
#include "4coder_lib/4coder_utf8.h"

View File

@ -9,7 +9,7 @@
// TOP
#include "4tech_defines.h"
#include "4ed_defines.h"
#include "4coder_API/version.h"
#define WINDOW_NAME "4coder" VERSION

View File

@ -35,7 +35,7 @@
#define FPS 60
#define frame_useconds (1000000 / FPS)
#include "4tech_defines.h"
#include "4ed_defines.h"
#include "4coder_API/version.h"
#define WINDOW_NAME L"4coder: " L_VERSION

View File

@ -2,7 +2,7 @@ extensions=".c.cpp.h.m.bat.sh.4coder";
open_recursively=true;
fkey_command_win[1] = {"echo build: x64 & build.bat", "*compilation*", true , true };
fkey_command_win[2] = {"site\\build.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[4] = {"echo build: x86 & build.bat /DDEV_BUILD_X86", "*compilation*", true , true };
fkey_command_win[5] = {"..\\misc\\run.bat", "*run*", false, false };
@ -10,6 +10,6 @@ fkey_command_win[6] = {"run_profile.bat", "*profile*", 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[2] = {"site/build.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[12] = {"./package.sh", "*package*", false, true };

View File

@ -1,16 +0,0 @@
@echo off
SET OPTS=/W4 /wd4310 /wd4100 /wd4201 /wd4505 /wd4996 /wd4127 /wd4510 /wd4512 /wd4610 /wd4390 /WX
SET OPTS=%OPTS% /GR- /EHa- /nologo /FC
SET FirstError=0
pushd ..\build
cl %OPTS% ..\code\meta\build.cpp /Zi /Febuild /DSITE_BUILD
if %ERRORLEVEL% neq 0 (set FirstError=1)
popd
..\build\build
if %ERRORLEVEL% neq 0 (set FirstError=1)

View File

@ -20,8 +20,8 @@
#include <stdio.h>
#include <string.h>
#include "../4tech_defines.h"
#include "../meta/4tech_meta_defines.h"
#include "../4ed_defines.h"
#include "../meta/4ed_meta_defines.h"
#include "../4coder_API/version.h"
#define FSTRING_IMPLEMENTATION

View File

@ -1,5 +1,5 @@
1
0
86
87

View File

@ -11,9 +11,9 @@ Created 21.01.2017 (dd.mm.yyyy)
#define FSTRING_IMPLEMENTATION
#include "../4coder_lib/4coder_string.h"
#include "../4tech_defines.h"
#include "../meta/4tech_meta_defines.h"
#include "../meta/4tech_file_moving.h"
#include "../4ed_defines.h"
#include "../meta/4ed_meta_defines.h"
#include "../meta/4ed_file_moving.h"
#define BUILD_NUMBER_FILE "4coder_string_build_num.txt"
@ -480,7 +480,7 @@ int main(){
}
#define FTECH_FILE_MOVING_IMPLEMENTATION
#include "../meta/4tech_file_moving.h"
#include "../meta/4ed_file_moving.h"
// BOTTOM