Cleaning up package script output

master
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);
BEGIN_TIME_SECTION();
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){
char *cmd = fm_str(arena, dir, "/", name);
BEGIN_TIME_SECTION();
fm_execute_in_dir(cdir, cmd, 0);
END_TIME_SECTION(fm_str(arena, "run ", name));
}
}
internal void
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));
char *build_script_postfix = "";
@ -536,7 +532,6 @@ buildsuper(Arena *arena, char *cdir, char *file, u32 arch){
systemf("%s", build_command);
fm_popdir(temp);
END_TIME_SECTION("build custom");
fflush(stdout);
}
@ -550,26 +545,20 @@ build_main(Arena *arena, char *cdir, b32 update_local_theme, u32 flags, u32 arch
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);
END_TIME_SECTION("build 4ed_app");
}
{
BEGIN_TIME_SECTION();
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);
END_TIME_SECTION("build 4ed");
}
if (update_local_theme){
BEGIN_TIME_SECTION();
char *themes_folder = fm_str(arena, "../build/themes");
char *source_themes_folder = fm_str(arena, "ship_files/themes");
fm_clear_folder(themes_folder);
fm_make_folder_if_missing(arena, themes_folder);
fm_copy_all(source_themes_folder, themes_folder);
END_TIME_SECTION("move files");
}
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 *zip_dir = fm_str(arena, pack_dir, SLASH, tier_name, "_", arch_name);
printf("\nbuild: %s_%s\n", tier_name, arch_name);
printf("parent_dir: %s\n", parent_dir);
printf("dir: %s\n", dir);
printf("zip_dir: %s\n", zip_dir);
printf("\nBUILD: %s_%s\n", tier_name, arch_name);
printf(" parent_dir = %s;\n", parent_dir);
printf(" dir = %s;\n", dir);
printf(" zip_dir = %s;\n", zip_dir);
fflush(stdout);
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){
char *custom_src_dir = fm_str(arena, cdir, 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_copy_all(custom_src_dir, custom_dst_dir);
}
@ -693,13 +679,11 @@ package(Arena *arena, char *cdir){
}
int main(int argc, char **argv){
Arena arena = fm_init_system();
Arena arena = fm_init_system(DetailLevel_FileOperations);
char cdir[256];
BEGIN_TIME_SECTION();
i32 n = fm_get_current_directory(cdir, sizeof(cdir));
Assert(n < sizeof(cdir));
END_TIME_SECTION("current directory");
u32 flags = SUPER;
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

View File

@ -17,6 +17,6 @@ flags="--fix-permissions --userversion=$vr"
dir=../distributions
butler push $flags $dir/demo_x64/4coder-$fv-demo-mac-x64.zip 4coder/4coder:mac-x64-demo
butler push $flags $dir/super_x64/4coder-$fv-super-mac-x64.zip 4coder/4coder:mac-x64
butler push $flags $dir/super_x64/4coder-$fv-super-mac-x64.zip 4coder/4coder:mac-x64
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

@ -135,17 +135,17 @@
////////////////////////////////
#if COMPILER_CL
#if _MSC_VER <= 1800
# define snprintf _snprintf
#endif
# if _MSC_VER <= 1800
# define snprintf _snprintf
# endif
#if (_MSC_VER <= 1500)
#define JUST_GUESS_INTS
#endif
# if (_MSC_VER <= 1500)
# define JUST_GUESS_INTS
# endif
#endif
// 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
#else
# define CALL_CONVENTION
@ -527,8 +527,8 @@ union SNode{
#define zdll_remove_back_NP_(f,l,next,prev) ((f==l)?(f=l=0):(l->prev->next=0,l=l->prev))
#define zdll_remove_NP_(f,l,n,next,prev) \
((l==n)?(zdll_remove_back_NP_(f,l,next,prev)) \
:(f==n)?(zdll_remove_back_NP_(l,f,prev,next)) \
: (dll_remove_NP_(n,n,next,prev)))
:(f==n)?(zdll_remove_back_NP_(l,f,prev,next)) \
: (dll_remove_NP_(n,n,next,prev)))
#define zdll_push_back(f,l,n) zdll_push_back_NP_((f),(l),(n),next,prev)
#define zdll_push_front(f,l,n) zdll_push_back_NP_((l),(f),(n),prev,next)

View File

@ -17,10 +17,6 @@
#include <stdarg.h>
#include <string.h>
//
// API
//
// System commands
static char SF_CMD[4096];
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);
// 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
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
internal void fm_make_folder_if_missing(Arena *arena, char *dir);
internal void fm_clear_folder(char *folder);
@ -183,6 +182,16 @@ fm__init_memory(void){
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
//
@ -266,7 +275,8 @@ extern "C"{
global u64 perf_frequency;
internal Arena
fm_init_system(void){
fm_init_system(i32 det){
detail_level = det;
LARGE_INTEGER lint;
if (QueryPerformanceFrequency(&lint)){
perf_frequency = lint.QuadPart;
@ -351,7 +361,9 @@ fm_make_folder_if_missing(Arena *arena, char *dir){
internal void
fm_clear_folder(char *folder){
fprintf(stdout, "clearing folder %s\n", folder);
if (fm__show_details_for_file_operations()){
fprintf(stdout, "clearing folder %s\n", folder);
}
fflush(stdout);
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
fm_copy_file(char *file, char *newname){
printf("copy %s to %s\n", file, newname);
if (fm__show_details_for_file_operations()){
printf("copy %s to %s\n", file, newname);
}
fflush(stdout);
CopyFileA(file, newname, 0);
}
internal void
fm_copy_all(char *source, char *folder){
fprintf(stdout, "copy %s to %s\n", source, folder);
if (fm__show_details_for_file_operations()){
fprintf(stdout, "copy %s to %s\n", source, folder);
}
fflush(stdout);
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
fm_zip(char *parent, char *folder, char *dest){
printf("zipping %s\\%s to %s\n", parent, folder, dest);
if (fm__show_details_for_file_operations()){
printf("zipping %s\\%s to %s\n", parent, folder, dest);
}
fflush(stdout);
char cdir[512];
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);
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);
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
fm_init_system(){
fm_init_system(i32 det){
detail_level = det;
return(fm__init_memory());
}
@ -492,7 +519,9 @@ fm_make_folder_if_missing(Arena *arena, char *dir){
internal void
fm_clear_folder(char *folder){
fprintf(stdout, "clearing folder %s\n", folder);
if (fm__show_details_for_file_operations()){
fprintf(stdout, "clearing folder %s\n", folder);
}
fflush(stdout);
systemf("rm -rf %s* > /dev/null", folder);
}
@ -504,12 +533,19 @@ fm_delete_file(char *file){
internal void
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);
}
internal void
fm_copy_all(char *source, char *folder){
fprintf(stdout, "copy %s to %s\n", source, folder);
if (fm__show_details_for_file_operations()){
fprintf(stdout, "copy %s to %s\n", source, folder);
}
fflush(stdout);
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
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);
printf("PARENT DIR: %s\n", parent);
systemf("zip -r %s %s", file, folder);
systemf("zip -r %s %s%s", file, folder, output_rule);
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
# Store the real CWD
REAL_PWD="$PWD"
# If any command errors, stop the script
set -e
# Find the code home folder
TARGET_FILE="$0"
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`
SCRIPT_FILE=$PHYS_DIR/$TARGET_FILE
code_home=$(dirname "$SCRIPT_FILE")
# Store the real CWD
ME="$(readlink -f "$0")"
LOCATION="$(dirname "$ME")"
CODE_HOME="$(dirname "$LOCATION")"
# Find the most reasonable candidate build file
SOURCE="$1"
if [ -z "$SOURCE" ]; then
SOURCE="$code_home/4coder_default_bindings.cpp"
SOURCE="$(readlink -f "$CODE_HOME/4coder_default_bindings.cpp")"
fi
TARGET_FILE="$SOURCE"
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"
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"
arch=-m32
cd "$REAL_PWD"
preproc_file=4coder_command_metadata.i
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" $opts $debug -std=gnu++0x "$code_home/4coder_metadata_generator.cpp" -o metadata_generator
./metadata_generator -R "$code_home" "$PWD/$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=c++11 "$CODE_HOME/4coder_metadata_generator.cpp" -o "$CODE_HOME/metadata_generator"
"$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

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 signed char GLbyte;
typedef unsigned short GLushort;
#if !OS_LINUX
typedef ptrdiff_t GLsizeiptr;
typedef ptrdiff_t GLintptr;
#endif
#if OS_LINUX
typedef void GL_Debug_Function(GLenum src,
GLenum type,
GLuint id,
GLenum severity,
GLsizei length,
#ifdef OS_LINUX
const GLchar* message,
const void *user_data
const void *user_data);
#else
typedef void GL_Debug_Function(GLenum src,
GLenum type,
GLuint id,
GLenum severity,
GLsizei length,
GLchar *message,
void *user_data
void *user_data);
#endif
);
typedef GL_Debug_Function *GLDEBUGPROC;
#endif

View File

@ -534,6 +534,12 @@ linux_set_icon(Display* d, Window w){
#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"

View File

@ -132,8 +132,8 @@ system_error_box(char *msg, b32 shutdown = true){
}
#define DRAW_STR(x, y, str, len) \
XDrawString(dpy, w, gc2, (x)+1, (y)+1, (str), (len)); \
XDrawString(dpy, w, gc1, (x) , (y) , (str), (len))
XDrawString(dpy, w, gc2, (x)+1, (y)+1, (str), (len)); \
XDrawString(dpy, w, gc1, (x) , (y) , (str), (len))
if (redraw){
redraw = 0;

View File

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