Cleaning up package script output

This commit is contained in:
Allen Webster 2020-03-01 13:29:32 -08:00
parent 2ee9d05bd2
commit 3a27541ceb
14 changed files with 187 additions and 139 deletions

View File

@ -492,24 +492,20 @@ build_and_run(Arena *arena, char *cdir, char *filename, char *name, u32 flags){
{ {
char *file = fm_str(arena, filename); char *file = fm_str(arena, filename);
BEGIN_TIME_SECTION();
build(arena, flags, Arch_X64, cdir, file, dir, name, get_defines_from_flags(arena, flags), 0, includes); build(arena, flags, Arch_X64, cdir, file, dir, name, get_defines_from_flags(arena, flags), 0, includes);
END_TIME_SECTION(fm_str(arena, "build ", name));
} }
if (prev_error == 0){ if (prev_error == 0){
char *cmd = fm_str(arena, dir, "/", name); char *cmd = fm_str(arena, dir, "/", name);
BEGIN_TIME_SECTION();
fm_execute_in_dir(cdir, cmd, 0); fm_execute_in_dir(cdir, cmd, 0);
END_TIME_SECTION(fm_str(arena, "run ", name));
} }
} }
internal void internal void
buildsuper(Arena *arena, char *cdir, char *file, u32 arch){ buildsuper(Arena *arena, char *cdir, char *file, u32 arch){
printf("BUILDSUPER: cdir: %s; file: %s; arch: %u\n", cdir, file, arch); printf("BUILDSUPER:\n cdir = %s;\n file = %s;\n arch = %s;\n", cdir, file, arch_names[arch]);
fflush(stdout);
BEGIN_TIME_SECTION();
Temp_Dir temp = fm_pushdir(fm_str(arena, BUILD_DIR)); Temp_Dir temp = fm_pushdir(fm_str(arena, BUILD_DIR));
char *build_script_postfix = ""; char *build_script_postfix = "";
@ -536,7 +532,6 @@ buildsuper(Arena *arena, char *cdir, char *file, u32 arch){
systemf("%s", build_command); systemf("%s", build_command);
fm_popdir(temp); fm_popdir(temp);
END_TIME_SECTION("build custom");
fflush(stdout); fflush(stdout);
} }
@ -550,26 +545,20 @@ build_main(Arena *arena, char *cdir, b32 update_local_theme, u32 flags, u32 arch
char **build_includes = includes; char **build_includes = includes;
BEGIN_TIME_SECTION();
build(arena, OPTS | SHARED_CODE | flags, arch, cdir, file, dir, "4ed_app" DLL, get_defines_from_flags(arena, flags), exports, build_includes); build(arena, OPTS | SHARED_CODE | flags, arch, cdir, file, dir, "4ed_app" DLL, get_defines_from_flags(arena, flags), exports, build_includes);
END_TIME_SECTION("build 4ed_app");
} }
{ {
BEGIN_TIME_SECTION();
char **inc = (char**)fm_list(arena, includes, platform_includes[This_OS][This_Compiler]); char **inc = (char**)fm_list(arena, includes, platform_includes[This_OS][This_Compiler]);
build(arena, OPTS | LIBS | ICON | flags, arch, cdir, platform_layers[This_OS], dir, "4ed", get_defines_from_flags(arena, flags), 0, inc); build(arena, OPTS | LIBS | ICON | flags, arch, cdir, platform_layers[This_OS], dir, "4ed", get_defines_from_flags(arena, flags), 0, inc);
END_TIME_SECTION("build 4ed");
} }
if (update_local_theme){ if (update_local_theme){
BEGIN_TIME_SECTION();
char *themes_folder = fm_str(arena, "../build/themes"); char *themes_folder = fm_str(arena, "../build/themes");
char *source_themes_folder = fm_str(arena, "ship_files/themes"); char *source_themes_folder = fm_str(arena, "ship_files/themes");
fm_clear_folder(themes_folder); fm_clear_folder(themes_folder);
fm_make_folder_if_missing(arena, themes_folder); fm_make_folder_if_missing(arena, themes_folder);
fm_copy_all(source_themes_folder, themes_folder); fm_copy_all(source_themes_folder, themes_folder);
END_TIME_SECTION("move files");
} }
fflush(stdout); fflush(stdout);
@ -606,10 +595,10 @@ package_for_arch(Arena *arena, u32 arch, char *cdir, char *build_dir, char *pack
char *dir = fm_str(arena, parent_dir, SLASH "4coder"); char *dir = fm_str(arena, parent_dir, SLASH "4coder");
char *zip_dir = fm_str(arena, pack_dir, SLASH, tier_name, "_", arch_name); char *zip_dir = fm_str(arena, pack_dir, SLASH, tier_name, "_", arch_name);
printf("\nbuild: %s_%s\n", tier_name, arch_name); printf("\nBUILD: %s_%s\n", tier_name, arch_name);
printf("parent_dir: %s\n", parent_dir); printf(" parent_dir = %s;\n", parent_dir);
printf("dir: %s\n", dir); printf(" dir = %s;\n", dir);
printf("zip_dir: %s\n", zip_dir); printf(" zip_dir = %s;\n", zip_dir);
fflush(stdout); fflush(stdout);
buildsuper(arena, cdir, fm_str(arena, default_custom_target), arch); buildsuper(arena, cdir, fm_str(arena, default_custom_target), arch);
@ -634,10 +623,7 @@ package_for_arch(Arena *arena, u32 arch, char *cdir, char *build_dir, char *pack
if (tier == Tier_Super){ if (tier == Tier_Super){
char *custom_src_dir = fm_str(arena, cdir, SLASH, "custom"); char *custom_src_dir = fm_str(arena, cdir, SLASH, "custom");
char *custom_dst_dir = fm_str(arena, dir, SLASH, "custom"); char *custom_dst_dir = fm_str(arena, dir, SLASH, "custom");
// HACK(yuval): make_folder_if_missing seems to cause a second custom folder to be created inside the custom folder on macOS.
//if (This_OS != Platform_Mac){
fm_make_folder_if_missing(arena, custom_dst_dir); fm_make_folder_if_missing(arena, custom_dst_dir);
//}
fm_copy_all(custom_src_dir, custom_dst_dir); fm_copy_all(custom_src_dir, custom_dst_dir);
} }
@ -693,13 +679,11 @@ package(Arena *arena, char *cdir){
} }
int main(int argc, char **argv){ int main(int argc, char **argv){
Arena arena = fm_init_system(); Arena arena = fm_init_system(DetailLevel_FileOperations);
char cdir[256]; char cdir[256];
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");
u32 flags = SUPER; u32 flags = SUPER;
u32 arch = Arch_X64; u32 arch = Arch_X64;

24
bin/itchio_push_linux.sh Normal file
View File

@ -0,0 +1,24 @@
#!/bin/sh
if [ "$#" -lt "3" ]
then
echo need 3 parameters
exit
else
fake=$1
maj=$2
min=$3
vr=$fake.$maj.$min
fv=$fake-$maj-$min
flags="--fix-permissions --userversion=$vr"
dir=../current_dist_all_os
butler push $flags $dir/demo_x64/4coder-$fv-demo-linux-x64.zip 4coder/4coder:linux-x64-demo
butler push $flags $dir/demo_x64/4coder-$fv-demo-linux-x86.zip 4coder/4coder:linux-x86-demo
butler push $flags $dir/super_x64/4coder-$fv-super-linux-x64.zip 4coder/4coder:linux-x64
butler push $flags $dir/super_x64/4coder-$fv-super-linux-x86.zip 4coder/4coder:linux-x86
fi

4
bin/package-linux.sh Executable file
View File

@ -0,0 +1,4 @@
#!/bin/bash
chmod 777 bin/build-linux.sh
bin/build-linux.sh "-DPACKAGE"

View File

@ -1,4 +0,0 @@
#!/bin/bash
chmod 777 build.sh
./build.sh "-DPACKAGE"

View File

@ -145,7 +145,7 @@
#endif #endif
// NOTE(yuval): Changed this so that CALL_CONVENTION will be defined for all platforms // NOTE(yuval): Changed this so that CALL_CONVENTION will be defined for all platforms
#if ARCH_32BIT #if ARCH_32BIT && OS_WINDOWS
# define CALL_CONVENTION __stdcall # define CALL_CONVENTION __stdcall
#else #else
# define CALL_CONVENTION # define CALL_CONVENTION

View File

@ -17,10 +17,6 @@
#include <stdarg.h> #include <stdarg.h>
#include <string.h> #include <string.h>
//
// API
//
// System commands // System commands
static char SF_CMD[4096]; static char SF_CMD[4096];
static i32 error_state = 0; static i32 error_state = 0;
@ -43,15 +39,18 @@ if (prev_error != 0) error_state = 1; \
internal void fm_execute_in_dir(char *dir, char *str, char *args); internal void fm_execute_in_dir(char *dir, char *str, char *args);
// Init // Init
internal Arena fm_init_system(); enum{
DetailLevel_Basics = 0,
DetailLevel_FileOperations = 1,
DetailLevel_Everything = 2,
};
global i32 detail_level = 0;
internal Arena fm_init_system(i32 detail_level);
// Timing // Timing
internal u64 fm_get_time(); internal u64 fm_get_time();
#define LLU_CAST(n) (long long unsigned int)(n)
#define BEGIN_TIME_SECTION() u64 start = fm_get_time()
#define END_TIME_SECTION(n) u64 total = fm_get_time() - start; printf("%-20s: %.2llu.%.6llu\n", (n), LLU_CAST(total/1000000), LLU_CAST(total%1000000));
// Files and Folders Manipulation // Files and Folders Manipulation
internal void fm_make_folder_if_missing(Arena *arena, char *dir); internal void fm_make_folder_if_missing(Arena *arena, char *dir);
internal void fm_clear_folder(char *folder); internal void fm_clear_folder(char *folder);
@ -183,6 +182,16 @@ fm__init_memory(void){
return(make_arena_malloc(MB(512), 8)); return(make_arena_malloc(MB(512), 8));
} }
function b32
fm__show_details_for_file_operations(void){
return(detail_level >= DetailLevel_FileOperations);
}
function b32
fm__show_details_for_zip_output(void){
return(detail_level >= DetailLevel_Everything);
}
// //
// Windows implementation // Windows implementation
// //
@ -266,7 +275,8 @@ extern "C"{
global u64 perf_frequency; global u64 perf_frequency;
internal Arena internal Arena
fm_init_system(void){ fm_init_system(i32 det){
detail_level = det;
LARGE_INTEGER lint; LARGE_INTEGER lint;
if (QueryPerformanceFrequency(&lint)){ if (QueryPerformanceFrequency(&lint)){
perf_frequency = lint.QuadPart; perf_frequency = lint.QuadPart;
@ -351,7 +361,9 @@ fm_make_folder_if_missing(Arena *arena, char *dir){
internal void internal void
fm_clear_folder(char *folder){ fm_clear_folder(char *folder){
if (fm__show_details_for_file_operations()){
fprintf(stdout, "clearing folder %s\n", folder); fprintf(stdout, "clearing folder %s\n", folder);
}
fflush(stdout); fflush(stdout);
systemf("del /S /Q /F %s\\* > nul & rmdir /S /Q %s > nul & mkdir %s > nul", folder, folder, folder); systemf("del /S /Q /F %s\\* > nul & rmdir /S /Q %s > nul & mkdir %s > nul", folder, folder, folder);
} }
@ -363,14 +375,18 @@ fm_delete_file(char *file){
internal void internal void
fm_copy_file(char *file, char *newname){ fm_copy_file(char *file, char *newname){
if (fm__show_details_for_file_operations()){
printf("copy %s to %s\n", file, newname); printf("copy %s to %s\n", file, newname);
}
fflush(stdout); fflush(stdout);
CopyFileA(file, newname, 0); CopyFileA(file, newname, 0);
} }
internal void internal void
fm_copy_all(char *source, char *folder){ fm_copy_all(char *source, char *folder){
if (fm__show_details_for_file_operations()){
fprintf(stdout, "copy %s to %s\n", source, folder); fprintf(stdout, "copy %s to %s\n", source, folder);
}
fflush(stdout); fflush(stdout);
systemf("xcopy /s /e /y /q %s %s > nul", source, folder); systemf("xcopy /s /e /y /q %s %s > nul", source, folder);
} }
@ -394,17 +410,27 @@ fm_write_file(char *file_name, char *data, u32 size){
internal void internal void
fm_zip(char *parent, char *folder, char *dest){ fm_zip(char *parent, char *folder, char *dest){
if (fm__show_details_for_file_operations()){
printf("zipping %s\\%s to %s\n", parent, folder, dest); printf("zipping %s\\%s to %s\n", parent, folder, dest);
}
fflush(stdout); fflush(stdout);
char cdir[512]; char cdir[512];
fm_get_current_directory(cdir, sizeof(cdir)); fm_get_current_directory(cdir, sizeof(cdir));
char *hide_output = " > nul >> nul";
char *show_output = "";
char *output_rule = hide_output;
if (fm__show_details_for_zip_output()){
output_rule = show_output;
}
Temp_Dir temp = fm_pushdir(parent); Temp_Dir temp = fm_pushdir(parent);
systemf("%s\\bin\\zip %s\\4ed_gobble.zip > nul", cdir, cdir); systemf("%s\\bin\\zip %s\\4ed_gobble.zip%s", cdir, cdir, output_rule);
fm_popdir(temp); fm_popdir(temp);
systemf("copy %s\\4ed_gobble.zip %s > nul & del %s\\4ed_gobble.zip > nul", cdir, dest, cdir); systemf("copy %s\\4ed_gobble.zip %s%s & del %s\\4ed_gobble.zip%s",
cdir, dest, output_rule, cdir, output_rule);
} }
// //
@ -435,7 +461,8 @@ fm_popdir(Temp_Dir temp){
} }
internal Arena internal Arena
fm_init_system(){ fm_init_system(i32 det){
detail_level = det;
return(fm__init_memory()); return(fm__init_memory());
} }
@ -492,7 +519,9 @@ fm_make_folder_if_missing(Arena *arena, char *dir){
internal void internal void
fm_clear_folder(char *folder){ fm_clear_folder(char *folder){
if (fm__show_details_for_file_operations()){
fprintf(stdout, "clearing folder %s\n", folder); fprintf(stdout, "clearing folder %s\n", folder);
}
fflush(stdout); fflush(stdout);
systemf("rm -rf %s* > /dev/null", folder); systemf("rm -rf %s* > /dev/null", folder);
} }
@ -504,12 +533,19 @@ fm_delete_file(char *file){
internal void internal void
fm_copy_file(char *file, char *newname){ fm_copy_file(char *file, char *newname){
if (fm__show_details_for_file_operations()){
printf("copy %s to %s\n", file, newname);
}
fflush(stdout);
systemf("cp %s %s", file, newname); systemf("cp %s %s", file, newname);
} }
internal void internal void
fm_copy_all(char *source, char *folder){ fm_copy_all(char *source, char *folder){
if (fm__show_details_for_file_operations()){
fprintf(stdout, "copy %s to %s\n", source, folder); fprintf(stdout, "copy %s to %s\n", source, folder);
}
fflush(stdout);
systemf("cp -rf %s/* %s > /dev/null", source, folder); systemf("cp -rf %s/* %s > /dev/null", source, folder);
} }
@ -525,9 +561,20 @@ fm_write_file(char *file_name, char *data, u32 size){
internal void internal void
fm_zip(char *parent, char *folder, char *file){ fm_zip(char *parent, char *folder, char *file){
if (fm__show_details_for_file_operations()){
printf("zipping %s/%s to %s\n", parent, folder, file);
}
fflush(stdout);
char *hide_output = " > nul 2> nul";
char *show_output = "";
char *output_rule = hide_output;
if (fm__show_details_for_zip_output()){
output_rule = show_output;
}
Temp_Dir temp = fm_pushdir(parent); Temp_Dir temp = fm_pushdir(parent);
printf("PARENT DIR: %s\n", parent); systemf("zip -r %s %s%s", file, folder, output_rule);
systemf("zip -r %s %s", file, folder);
fm_popdir(temp); fm_popdir(temp);
} }

0
custom/bin/build_metadata.sh Normal file → Executable file
View File

49
custom/bin/buildsuper_x86-linux.sh Normal file → Executable file
View File

@ -1,52 +1,31 @@
#!/bin/bash #!/bin/bash
# Store the real CWD # If any command errors, stop the script
REAL_PWD="$PWD" set -e
# Find the code home folder # Store the real CWD
TARGET_FILE="$0" ME="$(readlink -f "$0")"
cd `dirname $TARGET_FILE` LOCATION="$(dirname "$ME")"
TARGET_FILE=`basename $TARGET_FILE` CODE_HOME="$(dirname "$LOCATION")"
while [ -L "$TARGET_FILE" ]
do
TARGET_FILE=`readlink $TARGET_FILE`
cd `dirname $TARGET_FILE`
TARGET_FILE=`basename $TARGET_FILE`
done
PHYS_DIR=`pwd -P`
SCRIPT_FILE=$PHYS_DIR/$TARGET_FILE
code_home=$(dirname "$SCRIPT_FILE")
# Find the most reasonable candidate build file # Find the most reasonable candidate build file
SOURCE="$1" SOURCE="$1"
if [ -z "$SOURCE" ]; then if [ -z "$SOURCE" ]; then
SOURCE="$code_home/4coder_default_bindings.cpp" SOURCE="$(readlink -f "$CODE_HOME/4coder_default_bindings.cpp")"
fi fi
TARGET_FILE="$SOURCE" opts="-Wno-write-strings -Wno-null-dereference -Wno-comment -Wno-switch -Wno-missing-declarations -Wno-logical-op-parentheses -g -DOS_LINUX=1 -DOS_WINDOWS=0 -DOS_MAC=1"
cd `dirname $TARGET_FILE`
TARGET_FILE=`basename $TARGET_FILE`
while [ -L "$TARGET_FILE" ]
do
TARGET_FILE=`readlink $TARGET_FILE`
cd `dirname $TARGET_FILE`
TARGET_FILE=`basename $TARGET_FILE`
done
PHYS_DIR=`pwd -P`
SOURCE=$PHYS_DIR/$TARGET_FILE
opts="-Wno-write-strings -Wno-null-dereference -Wno-comment -Wno-switch -Wno-writable-strings -g -DOS_LINUX=1 -DOS_WINDOWS=0 -DOS_MAC=1"
arch=-m32 arch=-m32
cd "$REAL_PWD"
preproc_file=4coder_command_metadata.i preproc_file=4coder_command_metadata.i
meta_macros="-DMETA_PASS" meta_macros="-DMETA_PASS"
g++ -I"$code_home" $meta_macros $arch $opts $debug -std=gnu++0x "$SOURCE" -E -o $preproc_file g++ -I"$CODE_HOME" $meta_macros $arch $opts $debug -std=c++11 "$SOURCE" -E -o $preproc_file
g++ -I"$code_home" $opts $debug -std=gnu++0x "$code_home/4coder_metadata_generator.cpp" -o metadata_generator g++ -I"$CODE_HOME" $opts $debug -std=c++11 "$CODE_HOME/4coder_metadata_generator.cpp" -o "$CODE_HOME/metadata_generator"
./metadata_generator -R "$code_home" "$PWD/$preproc_file" "$CODE_HOME/metadata_generator" -R "$CODE_HOME" "$PWD/$preproc_file"
g++ -I"$code_home" $arch $opts $debug -std=gnu++0x "$SOURCE" -shared -o custom_4coder.so -fPIC g++ -I"$CODE_HOME" $arch $opts $debug -std=gnu++0x "$SOURCE" -shared -o custom_4coder.so -fPIC
rm metadata_generator rm "$CODE_HOME/metadata_generator"
rm $preproc_file rm $preproc_file

0
custom/bin/detect_os.sh Normal file → Executable file
View File

View File

@ -210,22 +210,30 @@ typedef char GLchar;
typedef short GLshort; typedef short GLshort;
typedef signed char GLbyte; typedef signed char GLbyte;
typedef unsigned short GLushort; typedef unsigned short GLushort;
#if !OS_LINUX
typedef ptrdiff_t GLsizeiptr; typedef ptrdiff_t GLsizeiptr;
typedef ptrdiff_t GLintptr; typedef ptrdiff_t GLintptr;
#endif
#if OS_LINUX
typedef void GL_Debug_Function(GLenum src, typedef void GL_Debug_Function(GLenum src,
GLenum type, GLenum type,
GLuint id, GLuint id,
GLenum severity, GLenum severity,
GLsizei length, GLsizei length,
#ifdef OS_LINUX
const GLchar* message, const GLchar* message,
const void *user_data const void *user_data);
#else #else
typedef void GL_Debug_Function(GLenum src,
GLenum type,
GLuint id,
GLenum severity,
GLsizei length,
GLchar *message, GLchar *message,
void *user_data void *user_data);
#endif #endif
);
typedef GL_Debug_Function *GLDEBUGPROC; typedef GL_Debug_Function *GLDEBUGPROC;
#endif #endif

View File

@ -534,6 +534,12 @@ linux_set_icon(Display* d, Window w){
#include "linux_error_box.cpp" #include "linux_error_box.cpp"
function void
os_popup_error(char *title, char *message){
system_error_box(message);
exit(1);
}
//////////////////////////// ////////////////////////////
#include "linux_4ed_functions.cpp" #include "linux_4ed_functions.cpp"

View File

@ -47,8 +47,8 @@ command_list = {
{ .name = "package", { .name = "package",
.out = "*compilation*", .footer_panel = false, .save_dirty_files = true, .out = "*compilation*", .footer_panel = false, .save_dirty_files = true,
.cmd = { {"echo package & bin\\package.bat" , .os = "win" }, .cmd = { {"echo package & bin\\package.bat" , .os = "win" },
{"echo package & bin/package.sh" , .os = "linux"}, {"echo package & bin/package-linux.sh", .os = "linux"},
{"echo package & bin/package.sh" , .os = "mac" }, }, }, {"echo package & bin/package-max.sh" , .os = "mac" }, }, },
{ .name = "run one time", { .name = "run one time",
.out = "*run*", .footer_panel = false, .save_dirty_files = false, .out = "*run*", .footer_panel = false, .save_dirty_files = false,