lots of clean up on the build system

master
Allen Webster 2017-07-08 15:25:23 -04:00
parent 0f307c67ac
commit 0642d555fc
5 changed files with 250 additions and 320 deletions

View File

@ -8,6 +8,12 @@
#define VERSION_NUMBER VN_(MAJOR,MINOR,PATCH) #define VERSION_NUMBER VN_(MAJOR,MINOR,PATCH)
#define VERSION_STRING "alpha " VERSION_NUMBER #define VERSION_STRING "alpha " VERSION_NUMBER
#define ST__(s) #s
#define ST_(s) ST__(s)
#define MAJOR_STR ST_(MAJOR)
#define MINOR_STR ST_(MINOR)
#define PATCH_STR ST_(PATCH)
#if defined(FRED_SUPER) #if defined(FRED_SUPER)
#define VERSION_TYPE " super!" #define VERSION_TYPE " super!"
#else #else

0
buildsuper.sh → buildsuper_x64.sh Executable file → Normal file
View File

View File

@ -14,6 +14,7 @@ By Allen Webster
#include <stdio.h> // include system for windows #include <stdio.h> // include system for windows
#include <stdlib.h> // include system for linux (YAY!) #include <stdlib.h> // include system for linux (YAY!)
#include <stdarg.h> #include <stdarg.h>
#include <string.h>
// //
// API // API
@ -57,7 +58,7 @@ internal void fm_clear_folder(char *folder);
internal void fm_delete_file(char *file); internal void fm_delete_file(char *file);
internal void fm_copy_file(char *file, char *newname); internal void fm_copy_file(char *file, char *newname);
internal void fm_copy_all(char *source, char *tag, char *folder); internal void fm_copy_all(char *source, char *tag, char *folder);
internal void fm_copy_folder(char *dst_dir, char *src_folder); internal void fm_copy_folder(char *src_dir, char *dst_dir, char *src_folder);
// Zip // Zip
internal void fm_zip(char *parent, char *folder, char *dest); internal void fm_zip(char *parent, char *folder, char *dest);
@ -303,7 +304,7 @@ fm_execute_in_dir(char *dir, char *str, char *args){
static void static void
fm_slash_fix(char *path){ fm_slash_fix(char *path){
if (path){ if (path != 0){
for (int32_t i = 0; path[i]; ++i){ for (int32_t i = 0; path[i]; ++i){
if (path[i] == '/') path[i] = '\\'; if (path[i] == '/') path[i] = '\\';
} }
@ -312,20 +313,16 @@ fm_slash_fix(char *path){
static void static void
fm_make_folder_if_missing(char *dir){ fm_make_folder_if_missing(char *dir){
char space[1024]; char *path = fm_str(dir);
String path = make_fixed_width_string(space); char *p = path;
append_sc(&path, dir);
terminate_with_null(&path);
char *p = path.str;
for (; *p; ++p){ for (; *p; ++p){
if (*p == '\\'){ if (*p == '\\'){
*p = 0; *p = 0;
CreateDirectoryA(path.str, 0); CreateDirectoryA(path, 0);
*p = '\\'; *p = '\\';
} }
} }
CreateDirectoryA(path.str, 0); CreateDirectoryA(path, 0);
} }
static void static void
@ -482,22 +479,17 @@ fm_zip(char *parent, char *folder, char *file){
#endif #endif
internal void internal void
fm_copy_folder(char *dst_dir, char *src_folder){ fm_copy_folder(char *src_dir, char *dst_dir, char *src_folder){
Temp_Dir temp = fm_pushdir(src_dir);
fm_make_folder_if_missing(fm_str(dst_dir, "/", src_folder)); fm_make_folder_if_missing(fm_str(dst_dir, "/", src_folder));
char *copy_name = fm_str(dst_dir, "/", src_folder);
char space[256]; fm_copy_all(src_folder, "*", copy_name);
String copy_name = make_fixed_width_string(space); fm_popdir(temp);
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* internal char*
fm_prepare_string_internal(char *s1, ...){ fm_prepare_string_internal(char *s1, ...){
i32 len = str_size(s1); umem len = strlen(s1);
char *result = (char*)fm__push(len); char *result = (char*)fm__push(len);
memcpy(result, s1, len); memcpy(result, s1, len);
@ -509,7 +501,7 @@ fm_prepare_string_internal(char *s1, ...){
break; break;
} }
else{ else{
len = str_size(sn); len = strlen(sn);
char *new_str = (char*)fm__push(len); char *new_str = (char*)fm__push(len);
memcpy(new_str, sn, len); memcpy(new_str, sn, len);
} }

View File

@ -7,22 +7,14 @@
//#define FM_PRINT_COMMANDS //#define FM_PRINT_COMMANDS
#include "../4ed_defines.h" #include "../4ed_defines.h"
#include "4ed_file_moving.h"
#include <assert.h> #define FTECH_FILE_MOVING_IMPLEMENTATION
#include <string.h> #include "4ed_file_moving.h"
#include "../4coder_API/version.h" #include "../4coder_API/version.h"
#define FSTRING_IMPLEMENTATION
#include "../4coder_lib/4coder_string.h"
// //
// reusable // OS and compiler index
//
//
// 4coder specific
// //
enum{ enum{
@ -31,6 +23,13 @@ enum{
Platform_Mac, Platform_Mac,
// //
Platform_COUNT, Platform_COUNT,
Platform_None = Platform_COUNT,
};
char *platform_names[] = {
"win",
"linux",
"mac",
}; };
enum{ enum{
@ -38,26 +37,44 @@ enum{
Compiler_GCC, Compiler_GCC,
// //
Compiler_COUNT, Compiler_COUNT,
Compiler_None = Compiler_COUNT,
};
char *compiler_names[] = {
"cl",
"gcc",
}; };
#if defined(IS_WINDOWS) #if defined(IS_WINDOWS)
# define THIS_OS Platform_Windows # define This_OS Platform_Windows
#elif defined(IS_LINUX) #elif defined(IS_LINUX)
# define THIS_OS Platform_Linux # define This_OS Platform_Linux
#elif defined(IS_MAC) #elif defined(IS_MAC)
# define THIS_OS Platform_Mac # define This_OS Platform_Mac
#else #else
# error This platform is not enumerated. # error This platform is not enumerated.
#endif #endif
#if defined(IS_CL) #if defined(IS_CL)
# define THIS_COMPILER Compiler_CL # define This_Compiler Compiler_CL
#elif defined(IS_GCC) #elif defined(IS_GCC)
# define THIS_COMPILER Compiler_GCC # define This_Compiler Compiler_GCC
#else #else
# error This compilers is not enumerated. # error This compilers is not enumerated.
#endif #endif
//
// Universal directories
//
#define BUILD_DIR "../build"
#define PACK_DIR "../distributions"
#define SITE_DIR "../site"
//
// Platform layer file tables
//
char *windows_platform_layer[] = { "platform_win32\\win32_4ed.cpp", 0 }; char *windows_platform_layer[] = { "platform_win32\\win32_4ed.cpp", 0 };
char *linux_platform_layer[] = { "platform_linux/linux_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 *mac_platform_layer[] = { "platform_mac/mac_4ed.m", "platform_mac/mac_4ed.cpp", 0 };
@ -78,7 +95,46 @@ char **platform_includes[Platform_COUNT][Compiler_COUNT] = {
{0 , mac_gcc_platform_inc }, {0 , mac_gcc_platform_inc },
}; };
#define BUILD_DIR "../build" //
// Custom targets
//
enum{
Custom_Default,
Custom_Experiments,
Custom_Casey,
Custom_ChronalVim,
//
Custom_COUNT
};
char *custom_files[] = {
"../code/4coder_default_bindings.cpp",
"../code/power/4coder_experiments.cpp",
"../code/power/4coder_casey.cpp",
"../4vim/4coder_chronal.cpp",
};
//
// Architectures
//
enum{
Arch_X64,
Arch_X86,
//
Arch_COUNT,
Arch_None = Arch_COUNT,
};
char *arch_names[] = {
"x64",
"x86",
};
//
// Build flags
//
enum{ enum{
OPTS = 0x1, OPTS = 0x1,
@ -92,15 +148,14 @@ enum{
OPTIMIZATION = 0x100, OPTIMIZATION = 0x100,
KEEP_ASSERT = 0x200, KEEP_ASSERT = 0x200,
SITE_INCLUDES = 0x400, SITE_INCLUDES = 0x400,
X86 = 0x800, LOG = 0x800,
LOG = 0x1000,
}; };
#if defined(IS_CL) //
// build implementation: cl
//
// #if defined(IS_CL)
// cl build
//
#define CL_OPTS \ #define CL_OPTS \
"-W4 -wd4310 -wd4100 -wd4201 -wd4505 -wd4996 " \ "-W4 -wd4310 -wd4100 -wd4201 -wd4505 -wd4996 " \
@ -121,19 +176,20 @@ enum{
#define CL_ICON "..\\res\\icon.res" #define CL_ICON "..\\res\\icon.res"
#define CL_X64 "-MACHINE:X64"
#define CL_X86 "-MACHINE:X86" #define CL_X86 "-MACHINE:X86"
static void static void
build(u32 flags, char *code_path, char **code_files, char *out_path, char *out_file, char *exports, char **inc_folders){ build(u32 flags, u32 arch, char *code_path, char **code_files, char *out_path, char *out_file, char *exports, char **inc_folders){
Build_Line line; Build_Line line;
Build_Line link_line; Build_Line link_line;
Build_Line line_prefix; Build_Line line_prefix;
fm_init_build_line(&line); fm_init_build_line(&line);
fm_init_build_line(&link_line); fm_init_build_line(&link_line);
fm_init_build_line(&line_prefix); fm_init_build_line(&line_prefix);
if (flags & X86){ if (arch == Arch_X86){
fm_add_to_line(line_prefix, "%s\\windows_scripts\\setup_cl_x86.bat & ", code_path); fm_add_to_line(line_prefix, "%s\\windows_scripts\\setup_cl_x86.bat & ", code_path);
} }
@ -141,8 +197,14 @@ build(u32 flags, char *code_path, char **code_files, char *out_path, char *out_f
fm_add_to_line(line, CL_OPTS); fm_add_to_line(line, CL_OPTS);
} }
if (flags & X86){ switch (arch){
fm_add_to_line(line, "/DFTECH_32_BIT"); case Arch_X64:
fm_add_to_line(line, "/DFTECH_64_BIT"); break;
case Arch_X86:
fm_add_to_line(line, "/DFTECH_32_BIT"); break;
default: InvalidCodePath;
} }
if (flags & LOG){ if (flags & LOG){
@ -164,11 +226,14 @@ build(u32 flags, char *code_path, char **code_files, char *out_path, char *out_f
} }
if (flags & LIBS){ if (flags & LIBS){
if (flags & X86){ switch (arch){
fm_add_to_line(line, CL_LIBS_X86); case Arch_X64:
} fm_add_to_line(line, CL_LIBS_X64); break;
else{
fm_add_to_line(line, CL_LIBS_X64); case Arch_X86:
fm_add_to_line(line, CL_LIBS_X86); break;
default: InvalidCodePath;
} }
} }
@ -200,8 +265,14 @@ build(u32 flags, char *code_path, char **code_files, char *out_path, char *out_f
fm_add_to_line(line, "/DFRED_KEEP_ASSERT"); fm_add_to_line(line, "/DFRED_KEEP_ASSERT");
} }
if (flags & X86){ switch (arch){
fm_add_to_line(link_line, CL_X86); case Arch_X64:
fm_add_to_line(link_line, CL_X64); break;
case Arch_X86:
fm_add_to_line(link_line, CL_X86); break;
default: InvalidCodePath;
} }
if (flags & DEBUG_INFO){ if (flags & DEBUG_INFO){
@ -210,7 +281,7 @@ build(u32 flags, char *code_path, char **code_files, char *out_path, char *out_f
char link_type_string[1024]; char link_type_string[1024];
if (flags & SHARED_CODE){ if (flags & SHARED_CODE){
assert(exports); Assert(exports);
snprintf(link_type_string, sizeof(link_type_string), "/OPT:REF %s", exports); snprintf(link_type_string, sizeof(link_type_string), "/OPT:REF %s", exports);
} }
else{ else{
@ -231,11 +302,11 @@ build(u32 flags, char *code_path, char **code_files, char *out_path, char *out_f
fm_popdir(temp); fm_popdir(temp);
} }
#elif defined(IS_GCC) //
// build implementation: gcc
//
// #elif defined(IS_GCC)
// gcc build
//
#if defined(IS_LINUX) #if defined(IS_LINUX)
@ -363,25 +434,44 @@ build(u32 flags, char *code_path, char **code_files, char *out_path, char *out_f
#endif #endif
static void static void
build(u32 flags, char *code_path, char *code_file, char *out_path, char *out_file, char *exports, char **inc_folders){ build(u32 flags, u32 arch, char *code_path, char *code_file, char *out_path, char *out_file, char *exports, char **inc_folders){
char *code_files[2]; char *code_files[2];
code_files[0] = code_file; code_files[0] = code_file;
code_files[1] = 0; code_files[1] = 0;
build(flags, code_path, code_files, out_path, out_file, exports, inc_folders); build(flags, arch, code_path, code_files, out_path, out_file, exports, inc_folders);
}
static void
site_build(char *cdir, u32 flags){
{
char *file = fm_str("site/sitegen.cpp");
char *dir = fm_str(BUILD_DIR);
BEGIN_TIME_SECTION();
build(OPTS | SITE_INCLUDES | flags, Arch_X64, cdir, file, dir, "sitegen", 0, 0);
END_TIME_SECTION("build sitegen");
}
{
BEGIN_TIME_SECTION();
char *cmd = fm_str(BUILD_DIR"/sitegen");
char *args = fm_str(". ../site_resources site/source_material ../site");
systemf("%s %s", cmd, args);
END_TIME_SECTION("run sitegen");
}
} }
static void static 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);
{ {
char *file = fm_str(filename); char *file = fm_str(filename);
BEGIN_TIME_SECTION(); BEGIN_TIME_SECTION();
build(flags, cdir, file, dir, name, 0, 0); build(flags, Arch_X64, cdir, file, dir, name, 0, 0);
END_TIME_SECTION(fm_str("build ", name)); END_TIME_SECTION(fm_str("build ", name));
} }
if (prev_error == 0){ if (prev_error == 0){
char *cmd = fm_str(dir, "/", name); char *cmd = fm_str(dir, "/", name);
BEGIN_TIME_SECTION(); BEGIN_TIME_SECTION();
@ -401,92 +491,40 @@ metagen(char *cdir){
} }
static void static void
buildsuper(char *code_path, char *out_path, char *filename, b32 x86_build){ do_buildsuper(char *cdir, char *file, u32 arch){
Temp_Dir temp = fm_pushdir(out_path);
#if defined(IS_WINDOWS)
{
char *build_script = "buildsuper.bat";
if (x86_build){
build_script = "buildsuper_x86.bat";
}
systemf("call \"%s\\%s\" \"%s\"", code_path, build_script, filename);
}
#elif defined(IS_LINUX) || defined(IS_MAC)
{
char *build_script = "buildsuper.sh";
if (x86_build){
build_script = "buildsuper_x86.sh";
}
systemf("\"%s/%s\" \"%s\"", code_path, build_script, filename);
}
#else
# error The buildsuper rule for this OS is not ready
#endif
fm_popdir(temp);
}
enum{
Custom_Default,
Custom_Experiments,
Custom_Casey,
Custom_ChronalVim,
Custom_COUNT
};
static void
do_buildsuper(char *cdir, i32 custom_option, u32 flags){
BEGIN_TIME_SECTION(); BEGIN_TIME_SECTION();
Temp_Dir temp = fm_pushdir(fm_str(BUILD_DIR));
char *str = 0; char *build_script = fm_str("buildsuper_", arch_names[arch], BAT);
switch (custom_option){
case Custom_Default:
{
str = fm_str("../code/4coder_default_bindings.cpp");
}break;
case Custom_Experiments:
{
str = fm_str("../code/power/4coder_experiments.cpp");
}break;
case Custom_Casey:
{
str = fm_str("../code/power/4coder_casey.cpp");
}break;
case Custom_ChronalVim:
{
str = fm_str("../4vim/4coder_chronal.cpp");
}break;
}
if (str != 0){ char *build_command = fm_str("\"", cdir, "/", build_script, "\" \"", file, "\"");
b32 x86_build = ((flags & X86) != 0); if (This_OS == Platform_Windows){
char *dir = fm_str(BUILD_DIR); build_command = fm_str("call ", build_command);
buildsuper(cdir, dir, str
, x86_build);
END_TIME_SECTION("build custom");
} }
systemf(build_command);
fm_popdir(temp);
END_TIME_SECTION("build custom");
} }
static void static void
build_main(char *cdir, u32 flags){ build_main(char *cdir, b32 update_local_theme, u32 flags, u32 arch){
char *dir = fm_str(BUILD_DIR); char *dir = fm_str(BUILD_DIR);
{ {
char *file = fm_str("4ed_app_target.cpp"); char *file = fm_str("4ed_app_target.cpp");
BEGIN_TIME_SECTION(); BEGIN_TIME_SECTION();
build(OPTS | INCLUDES | SHARED_CODE | flags, cdir, file, dir, "4ed_app" DLL, "/EXPORT:app_get_functions", 0); build(OPTS | INCLUDES | SHARED_CODE | flags, arch, cdir, file, dir, "4ed_app" DLL, "/EXPORT:app_get_functions", 0);
END_TIME_SECTION("build 4ed_app"); END_TIME_SECTION("build 4ed_app");
} }
{ {
BEGIN_TIME_SECTION(); BEGIN_TIME_SECTION();
build(OPTS | INCLUDES | LIBS | ICON | flags, cdir, platform_layers[THIS_OS], dir, "4ed", 0, platform_includes[THIS_OS][THIS_COMPILER]); build(OPTS | INCLUDES | LIBS | ICON | flags, arch, cdir, platform_layers[This_OS], dir, "4ed", 0, platform_includes[This_OS][This_Compiler]);
END_TIME_SECTION("build 4ed"); END_TIME_SECTION("build 4ed");
} }
{ if (update_local_theme){
BEGIN_TIME_SECTION(); BEGIN_TIME_SECTION();
char *themes_folder = fm_str("../build/themes"); char *themes_folder = fm_str("../build/themes");
char *source_themes_folder = fm_str("themes"); char *source_themes_folder = fm_str("themes");
@ -498,219 +536,113 @@ build_main(char *cdir, u32 flags){
} }
static void static void
standard_build(char *cdir, u32 flags){ standard_build(char *cdir, u32 flags, u32 arch){
fsm_generator(cdir); fsm_generator(cdir);
metagen(cdir); metagen(cdir);
do_buildsuper(cdir, Custom_Default, flags); do_buildsuper(cdir, fm_str(custom_files[Custom_Default]), arch);
//do_buildsuper(cdir, Custom_Experiments, flags); //do_buildsuper(cdir, fm_str(custom_files[Custom_Experiments]), arch);
//do_buildsuper(cdir, Custom_Casey, flags); //do_buildsuper(cdir, fm_str(custom_files[Custom_Casey]), arch);
//do_buildsuper(cdir, Custom_ChronalVim, flags); //do_buildsuper(cdir, fm_str(custom_files[Custom_ChronalVim]), arch);
build_main(cdir, flags); build_main(cdir, true, flags, arch);
} }
static void internal char*
site_build(char *cdir, u32 flags){ get_4coder_dist_name(u32 platform, char *tier, u32 arch){
{ char *name = fm_str("4coder-alpha-"MAJOR_STR"-"MINOR_STR"-"PATCH_STR);
char *file = fm_str("site/sitegen.cpp"); if (strcmp(tier, "alpha") != 0){
char *dir = fm_str(BUILD_DIR"/site"); name = fm_str(name, "-", tier);
BEGIN_TIME_SECTION();
build(OPTS | SITE_INCLUDES | flags, cdir, file, dir, "sitegen", 0, 0);
END_TIME_SECTION("build sitegen");
} }
if (platform != Platform_None){
{ name = fm_str(name, "-", platform_names[platform]);
BEGIN_TIME_SECTION();
char *cmd = fm_str("../build/site/sitegen . ../site_resources site/source_material ../site");
systemf("%s", cmd);
END_TIME_SECTION("run sitegen");
} }
} if (arch != Arch_None){
name = fm_str(name, "-", arch_names[arch]);
#define PACK_DIR "../distributions"
static void
get_4coder_dist_name(String *zip_file, b32 OS_specific, char *folder, char *tier, char *arch, char *ext){
zip_file->size = 0;
append_sc(zip_file, PACK_DIR"/");
if (folder != 0){
append_sc(zip_file, folder);
append_sc(zip_file, "/");
} }
append_sc(zip_file, "4coder-"); return(name);
append_sc (zip_file, "alpha");
append_sc (zip_file, "-");
append_int_to_str (zip_file, MAJOR);
append_sc (zip_file, "-");
append_int_to_str (zip_file, MINOR);
append_sc (zip_file, "-");
append_int_to_str (zip_file, PATCH);
if (tier != 0 && !match_cc(tier, "alpha")){
append_sc (zip_file, "-");
append_sc (zip_file, tier);
}
if (OS_specific){
#if defined(IS_WINDOWS)
append_sc(zip_file, "-win");
#elif defined(IS_LINUX)
append_sc(zip_file, "-linux");
#elif defined(IS_MAC)
append_sc(zip_file, "-mac");
#else
#error No OS string for zips on this OS
#endif
}
if (arch != 0){
append_sc (zip_file, "-");
append_sc (zip_file, arch);
}
append_sc (zip_file, ".");
append_sc (zip_file, ext);
terminate_with_null(zip_file);
fm_slash_fix(zip_file->str);
} }
static void static void
package(char *cdir){ package(char *cdir){
char str_space[1024];
String str = make_fixed_width_string(str_space);
// NOTE(allen): meta // NOTE(allen): meta
fsm_generator(cdir); fsm_generator(cdir);
metagen(cdir); metagen(cdir);
#define SITE_DIR "../site"
#define PACK_FONTS_DIR "../code/dist_files/fonts"
char *build_dir = fm_str(BUILD_DIR); char *build_dir = fm_str(BUILD_DIR);
char *site_dir = fm_str(SITE_DIR);
char *pack_dir = fm_str(PACK_DIR); char *pack_dir = fm_str(PACK_DIR);
char *pack_fonts_dir = fm_str(PACK_FONTS_DIR); char *fonts_source_dir = fm_str("../code/dist_files/fonts");
u32 arch_count = 2;
char *arch_names[] = {
"x64",
"x86",
};
Assert(ArrayCount(arch_names) == arch_count);
u32 arch_flags[] = {
0,
X86,
};
Assert(ArrayCount(arch_flags) == arch_count);
char *base_package_root = "../current_dist"; char *base_package_root = "../current_dist";
// NOTE(allen): alpha // NOTE(allen): alpha and super builds
{ enum{
Tier_Alpha,
Tier_Super,
Tier_COUNT
};
char *tiers[] = { "alpha", "super" };
u32 base_flags = OPTIMIZATION | KEEP_ASSERT | DEBUG_INFO | LOG;
u32 tier_flags[] = { 0, SUPER, };
for (u32 tier_index = 0; tier_index < Tier_COUNT; ++tier_index){
char *tier = tiers[tier_index];
u32 flags = base_flags | tier_flags[tier_index];
Temp_Memory temp = fm_begin_temp(); Temp_Memory temp = fm_begin_temp();
char *tier = "alpha";
char *tier_package_root = fm_str(base_package_root, "_", tier); char *tier_package_root = fm_str(base_package_root, "_", tier);
u32 base_flags = OPTIMIZATION | KEEP_ASSERT | DEBUG_INFO | LOG; for (u32 arch = 0; arch < Arch_COUNT; ++arch){
for (u32 i = 0; i < arch_count; ++i){ char *par_dir = fm_str(tier_package_root, "_", arch_names[arch]);
char *package_root = fm_str(tier_package_root, "_", arch_names[i]); char *dir = fm_str(par_dir, "/4coder");
char *par_dir = fm_str(package_root); char *fonts_dir = fm_str(dir, "/fonts");
char *dir = fm_str(par_dir, "/4coder"); char *zip_dir = fm_str(pack_dir, "/", tier, "_", arch_names[arch]);
char *fonts_dir = fm_str(dir, "/fonts");
char *zip_dir = fm_str(tier, "_", arch_names[i]);
build_main(cdir, base_flags | arch_flags[i]); build_main(cdir, false, flags, arch);
fm_clear_folder(par_dir); fm_clear_folder(par_dir);
fm_make_folder_if_missing(dir); fm_make_folder_if_missing(dir);
fm_make_folder_if_missing(fonts_dir);
fm_make_folder_if_missing(fm_str(pack_dir, "/", zip_dir));
fm_copy_file(fm_str(build_dir, "/4ed"EXE), fm_str(dir, "/4ed"EXE));
fm_copy_file(fm_str(build_dir, "/4ed_app"DLL), fm_str(dir, "/4ed_app"DLL));
fm_copy_all(pack_fonts_dir, "*", fonts_dir);
fm_copy_file(fm_str(cdir, "/release-config.4coder"), fm_str(dir, "/config.4coder"));
fm_copy_folder(dir, "themes");
fm_copy_file(fm_str(cdir, "/LICENSE.txt"), fm_str(dir, "/LICENSE.txt"));
fm_copy_file(fm_str(cdir, "/README.txt"), fm_str(dir, "/README.txt"));
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
{
Temp_Memory temp = fm_begin_temp();
char *tier = "super";
char *tier_package_root = fm_str(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_str(tier_package_root, "_", arch_names[i]);
char *par_dir = fm_str(package_root);
char *dir = fm_str(par_dir, "/4coder");
char *fonts_dir = fm_str(dir, "/fonts");
char *zip_dir = fm_str(tier, "_", arch_names[i]);
build_main(cdir, base_flags | arch_flags[i]);
do_buildsuper(cdir, Custom_Default, arch_flags[i]);
fm_clear_folder(par_dir);
fm_make_folder_if_missing(dir);
fm_make_folder_if_missing(fonts_dir);
fm_make_folder_if_missing(fm_str(pack_dir, "/", zip_dir));
fm_copy_file(fm_str(build_dir, "/4ed" EXE), fm_str(dir, "/4ed" EXE)); fm_copy_file(fm_str(build_dir, "/4ed" EXE), fm_str(dir, "/4ed" EXE));
fm_copy_file(fm_str(build_dir, "/4ed_app" DLL), fm_str(dir, "/4ed_app" DLL)); fm_copy_file(fm_str(build_dir, "/4ed_app" DLL), fm_str(dir, "/4ed_app" DLL));
fm_copy_file(fm_str(build_dir, "/custom_4coder" DLL), fm_str(dir, "/custom_4coder" DLL));
fm_copy_all(pack_fonts_dir, "*", fonts_dir);
fm_copy_file(fm_str(cdir, "/release-config.4coder"), fm_str(dir, "/config.4coder"));
fm_copy_all(0, "4coder_*", dir);
if (!(arch_flags[i] & X86)){
fm_copy_file("buildsuper" BAT, fm_str(dir, "/buildsuper" BAT));
}
else{
fm_copy_file("buildsuper_x86" BAT, fm_str(dir, "/buildsuper" BAT));
}
#if defined(IS_WINDOWS)
fm_copy_folder(dir, "windows_scripts");
#endif
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");
fm_copy_folder(cdir, dir, "themes");
fm_copy_file(fm_str(cdir, "/LICENSE.txt"), fm_str(dir, "/LICENSE.txt")); fm_copy_file(fm_str(cdir, "/LICENSE.txt"), fm_str(dir, "/LICENSE.txt"));
fm_copy_file(fm_str(cdir, "/README.txt"), fm_str(dir, "/README.txt")); fm_copy_file(fm_str(cdir, "/README.txt"), fm_str(dir, "/README.txt"));
get_4coder_dist_name(&str, true, zip_dir, tier, arch_names[i], "zip"); fm_make_folder_if_missing(fonts_dir);
fm_zip(par_dir, "4coder", str.str); fm_copy_all(fonts_source_dir, "*", fonts_dir);
fm_copy_file(fm_str(cdir, "/release-config.4coder"), fm_str(dir, "/config.4coder"));
if (tier_index == Tier_Super){
fm_copy_all(0, "4coder_*", dir);
do_buildsuper(cdir, fm_str(custom_files[Custom_Default]), arch);
fm_copy_file(fm_str(build_dir, "/custom_4coder" DLL), fm_str(dir, "/custom_4coder" DLL));
char *build_script = fm_str("buildsuper_", arch_names[arch], BAT);
fm_copy_file(build_script, fm_str(dir, "/buildsuper" BAT));
if (This_OS == Platform_Windows){
fm_copy_folder(cdir, dir, "windows_scripts");
}
fm_copy_folder(cdir, dir, "4coder_API");
fm_copy_folder(cdir, dir, "4coder_helper");
fm_copy_folder(cdir, dir, "4coder_lib");
fm_copy_folder(cdir, dir, "4cpp");
fm_copy_folder(cdir, dir, "languages");
}
char *dist_name = get_4coder_dist_name(This_OS, tier, arch);
char *zip_name = fm_str(zip_dir, "/", dist_name, ".zip");
fm_make_folder_if_missing(zip_dir);
fm_zip(par_dir, "4coder", zip_name);
} }
fm_make_folder_if_missing(fm_str(pack_dir, "/super-docs"));
get_4coder_dist_name(&str, false, "super-docs", "API", 0, "html");
String str2 = front_of_directory(str);
fm_copy_file(fm_str(site_dir, "/custom_docs.html"), fm_str(pack_dir, "/super-docs/", str2.str));
fm_end_temp(temp); fm_end_temp(temp);
} }
// NOTE(allen): power // NOTE(allen): power
{ {
Temp_Memory temp = fm_begin_temp(); Temp_Memory temp = fm_begin_temp();
char *pack_power_par_dir = fm_str("../current_dist_power"); char *pack_power_par_dir = fm_str("../current_dist_power");
char *pack_power_dir = fm_str(pack_power_par_dir, "/power"); char *pack_power_dir = fm_str(pack_power_par_dir, "/power");
@ -719,48 +651,48 @@ package(char *cdir){
fm_make_folder_if_missing(fm_str(pack_dir, "/power")); fm_make_folder_if_missing(fm_str(pack_dir, "/power"));
fm_copy_all("power", "*", pack_power_dir); fm_copy_all("power", "*", pack_power_dir);
get_4coder_dist_name(&str, 0, "power", "power", 0, "zip"); char *dist_name = get_4coder_dist_name(Platform_None, "power", Arch_None);
fm_zip(pack_power_par_dir, "power", str.str); char *zip_name = fm_str(pack_dir, "/power/", dist_name, ".zip");
fm_zip(pack_power_par_dir, "power", zip_name);
fm_end_temp(temp); fm_end_temp(temp);
} }
} }
int main(int argc, char **argv){ int main(int argc, char **argv){
fm_init_system(); fm_init_system();
char cdir[256];
char cdir[256];
BEGIN_TIME_SECTION(); BEGIN_TIME_SECTION();
i32 n = fm_get_current_directory(cdir, sizeof(cdir)); i32 n = fm_get_current_directory(cdir, sizeof(cdir));
assert(n < sizeof(cdir)); Assert(n < sizeof(cdir));
END_TIME_SECTION("current directory"); END_TIME_SECTION("current directory");
#if defined(DEV_BUILD) || defined(OPT_BUILD) || defined(DEV_BUILD_X86) #if defined(DEV_BUILD) || defined(OPT_BUILD) || defined(DEV_BUILD_X86)
u32 flags = DEBUG_INFO | SUPER | INTERNAL | LOG; u32 flags = DEBUG_INFO | SUPER | INTERNAL | LOG;
u32 arch = Arch_X64;
#if defined(OPT_BUILD) #if defined(OPT_BUILD)
flags |= OPTIMIZATION; flags |= OPTIMIZATION;
#endif #endif
#if defined(DEV_BUILD_X86) #if defined(DEV_BUILD_X86)
flags |= X86; arch = Arch_X86;
#endif #endif
standard_build(cdir, flags); standard_build(cdir, flags, arch);
#elif defined(PACKAGE) #elif defined(PACKAGE)
package(cdir); package(cdir);
#elif defined(SITE_BUILD) #elif defined(SITE_BUILD)
site_build(cdir, DEBUG_INFO); site_build(cdir, DEBUG_INFO);
#else #else
#error No build type specified. # error No build type specified.
#endif #endif
return(error_state); return(error_state);
} }
#define FTECH_FILE_MOVING_IMPLEMENTATION
#include "4ed_file_moving.h" //#include "4ed_file_moving.h"
// BOTTOM // BOTTOM