From f76b564d957fc38c4f5015d554411b152297c87c Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Sat, 8 Jul 2017 23:25:29 -0400 Subject: [PATCH] started cleaning up site build --- build_site.sh | 9 ++------- meta/build.cpp | 11 +++++++---- meta/out_context.cpp | 19 ++++++++----------- site/sitegen.cpp | 27 --------------------------- 4 files changed, 17 insertions(+), 49 deletions(-) mode change 100644 => 100755 build_site.sh diff --git a/build_site.sh b/build_site.sh old mode 100644 new mode 100755 index e6e58276..38757812 --- a/build_site.sh +++ b/build_site.sh @@ -1,10 +1,5 @@ #!/bin/bash -WARNINGS="-Wno-write-strings" -FLAGS="-D_GNU_SOURCE -fPIC -fpermissive -DSITE_BUILD" - -BASEDIR="$PWD" -g++ $WARNINGS $FLAGS $BASEDIR/meta/build.cpp -g -o ../build/build -../build/build - +chmod 777 build.sh +./build.sh "-DSITE_BUILD" diff --git a/meta/build.cpp b/meta/build.cpp index a732ecbe..327426e8 100644 --- a/meta/build.cpp +++ b/meta/build.cpp @@ -195,7 +195,7 @@ get_defines_from_flags(u32 flags){ static 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){ Temp_Dir temp = fm_pushdir(out_path); - + Build_Line line; fm_init_build_line(&line); @@ -413,7 +413,6 @@ build(u32 flags, u32 arch, char *code_path, char *code_file, char *out_path, cha char *code_files[2]; code_files[0] = code_file; code_files[1] = 0; - build(flags, arch, code_path, code_files, out_path, out_file, defines, exports, inc_folders); } @@ -430,8 +429,12 @@ site_build(char *cdir, u32 flags){ { 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); + char *code_dir = fm_str("."); + char *asset_dir = fm_str("../site_resources"); + char *site_source_dir = fm_str("site/source_material"); + char *dest_dir = fm_str("../site"); + fm_make_folder_if_missing(dest_dir); + systemf("%s %s %s %s %s", cmd, code_dir, asset_dir, site_source_dir, dest_dir); END_TIME_SECTION("run sitegen"); } } diff --git a/meta/out_context.cpp b/meta/out_context.cpp index cb72b558..c9d802af 100644 --- a/meta/out_context.cpp +++ b/meta/out_context.cpp @@ -87,19 +87,16 @@ do_file_copy(Partition *part, char *src_file, char *dst_dir, char *dst_file){ if (in){ fseek(in, 0, SEEK_END); int32_t file_size = ftell(in); - if (mem_size >= file_size){ - fseek(in, 0, SEEK_SET); - fread(mem, 1, file_size, in); - - FILE *out = fopen(dst, "wb"); - if (out){ - fwrite(mem, 1, file_size, out); - fclose(out); - success = 1; + fseek(in, 0, SEEK_SET); + fread(mem, 1, file_size, in); + FILE *out = fopen(dst, "wb"); + if (out){ + fwrite(mem, 1, file_size, out); + fclose(out); + success = 1; + } } - } - fclose(in); } end_temp_memory(temp); diff --git a/site/sitegen.cpp b/site/sitegen.cpp index 82ea501f..8520aa4f 100644 --- a/site/sitegen.cpp +++ b/site/sitegen.cpp @@ -95,33 +95,6 @@ allocate_app_api(Partition *part, i32 count){ return(app_api); } -static void -assert_files_are_equal(char *directory, char *filename1, char *filename2){ - char space[256]; - String name = make_fixed_width_string(space); - append_sc(&name, directory); - append_sc(&name, "/"); - append_sc(&name, filename1); - terminate_with_null(&name); - - String file1 = file_dump(name.str); - - name.size = 0; - append_sc(&name, directory); - append_sc(&name, "/"); - append_sc(&name, filename2); - terminate_with_null(&name); - - String file2 = file_dump(name.str); - - if (!match_ss(file1, file2)){ - fprintf(stderr, "Failed transitional test: %s != %s\n", filename1, filename2); - } - else{ - fprintf(stderr, "Passed transitional test: %s == %s\n", filename1, filename2); - } -} - static void do_html_output(Document_System *doc_system, Partition *part, char *dst_directory, Abstract_Item *doc){ // NOTE(allen): Output