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); 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

View File

@ -17,6 +17,6 @@ flags="--fix-permissions --userversion=$vr"
dir=../distributions dir=../distributions
butler push $flags $dir/demo_x64/4coder-$fv-demo-mac-x64.zip 4coder/4coder:mac-x64-demo 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 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 COMPILER_CL
#if _MSC_VER <= 1800 # if _MSC_VER <= 1800
# define snprintf _snprintf # define snprintf _snprintf
#endif # endif
#if (_MSC_VER <= 1500) # if (_MSC_VER <= 1500)
#define JUST_GUESS_INTS # define JUST_GUESS_INTS
#endif # endif
#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
@ -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_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) \ #define zdll_remove_NP_(f,l,n,next,prev) \
((l==n)?(zdll_remove_back_NP_(f,l,next,prev)) \ ((l==n)?(zdll_remove_back_NP_(f,l,next,prev)) \
:(f==n)?(zdll_remove_back_NP_(l,f,prev,next)) \ :(f==n)?(zdll_remove_back_NP_(l,f,prev,next)) \
: (dll_remove_NP_(n,n,next,prev))) : (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_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) #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 <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){
fprintf(stdout, "clearing folder %s\n", folder); if (fm__show_details_for_file_operations()){
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){
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); 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){
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); 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){
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); 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){
fprintf(stdout, "clearing folder %s\n", folder); if (fm__show_details_for_file_operations()){
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){
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); 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

@ -15,16 +15,16 @@ internal void
system_error_box(char *msg, b32 shutdown = true){ system_error_box(char *msg, b32 shutdown = true){
fprintf(stderr, "Fatal Error: %s\n", msg); fprintf(stderr, "Fatal Error: %s\n", msg);
//LOGF("Fatal Error: %s\n", msg); //LOGF("Fatal Error: %s\n", msg);
Display *dpy = XOpenDisplay(0); Display *dpy = XOpenDisplay(0);
if (!dpy){ if (!dpy){
exit(1); exit(1);
} }
const int num_cols = 50; const int num_cols = 50;
int win_w = (num_cols + 10) * 9; int win_w = (num_cols + 10) * 9;
int win_h = 140; int win_h = 140;
{ {
const char *start_p = msg, *space_p = NULL; const char *start_p = msg, *space_p = NULL;
for(const char* p = msg; *p; ++p){ for(const char* p = msg; *p; ++p){
@ -36,86 +36,86 @@ system_error_box(char *msg, b32 shutdown = true){
} }
} }
} }
Window w = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 0, 0, win_w, win_h, 0, 0, 0x227A3B); Window w = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 0, 0, win_w, win_h, 0, 0, 0x227A3B);
XStoreName(dpy, w, "4coder Error"); XStoreName(dpy, w, "4coder Error");
XSizeHints* sh = XAllocSizeHints(); XSizeHints* sh = XAllocSizeHints();
sh->flags = PMinSize; sh->flags = PMinSize;
sh->min_width = win_w; sh->min_width = win_w;
sh->min_height = win_h; sh->min_height = win_h;
XSetWMNormalHints(dpy, w, sh); XSetWMNormalHints(dpy, w, sh);
Atom type = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DIALOG", False); Atom type = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DIALOG", False);
XChangeProperty(dpy, w, XInternAtom(dpy, "_NET_WM_WINDOW_TYPE", False), XA_ATOM, 32, PropModeReplace, (unsigned char*) &type, 1); XChangeProperty(dpy, w, XInternAtom(dpy, "_NET_WM_WINDOW_TYPE", False), XA_ATOM, 32, PropModeReplace, (unsigned char*) &type, 1);
Atom WM_DELETE_WINDOW = XInternAtom(dpy, "WM_DELETE_WINDOW", False); Atom WM_DELETE_WINDOW = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
XSetWMProtocols(dpy, w, &WM_DELETE_WINDOW, 1); XSetWMProtocols(dpy, w, &WM_DELETE_WINDOW, 1);
linux_set_icon(dpy, w); linux_set_icon(dpy, w);
XMapRaised(dpy, w); XMapRaised(dpy, w);
XSync(dpy, False); XSync(dpy, False);
XSelectInput(dpy, w, ExposureMask | StructureNotifyMask | PointerMotionMask | ButtonPressMask | ButtonReleaseMask | KeyPressMask); XSelectInput(dpy, w, ExposureMask | StructureNotifyMask | PointerMotionMask | ButtonPressMask | ButtonReleaseMask | KeyPressMask);
XFontStruct* font = XLoadQueryFont(dpy, "-*-fixed-bold-*-*-*-*-140-*-*-*-*-iso8859-1"); XFontStruct* font = XLoadQueryFont(dpy, "-*-fixed-bold-*-*-*-*-140-*-*-*-*-iso8859-1");
if (!font){ if (!font){
exit(1); exit(1);
} }
XGCValues gcv; XGCValues gcv;
gcv.foreground = WhitePixel(dpy, 0); gcv.foreground = WhitePixel(dpy, 0);
gcv.line_width = 2; gcv.line_width = 2;
gcv.font = font->fid; gcv.font = font->fid;
GC gc1 = XCreateGC(dpy, w, GCForeground | GCFont | GCLineWidth, &gcv); GC gc1 = XCreateGC(dpy, w, GCForeground | GCFont | GCLineWidth, &gcv);
gcv.foreground = BlackPixel(dpy, 0); gcv.foreground = BlackPixel(dpy, 0);
GC gc2 = XCreateGC(dpy, w, GCForeground | GCFont | GCLineWidth, &gcv); GC gc2 = XCreateGC(dpy, w, GCForeground | GCFont | GCLineWidth, &gcv);
int button_trigger = 0; int button_trigger = 0;
int button_hi = 0; int button_hi = 0;
int redraw = 1; int redraw = 1;
XEvent ev; XEvent ev;
while (1){ while (1){
XNextEvent(dpy, &ev); XNextEvent(dpy, &ev);
if (ev.type == Expose) redraw = 1; if (ev.type == Expose) redraw = 1;
if (ev.type == ConfigureNotify){ if (ev.type == ConfigureNotify){
redraw = 1; redraw = 1;
win_w = ev.xconfigure.width; win_w = ev.xconfigure.width;
win_h = ev.xconfigure.height; win_h = ev.xconfigure.height;
} }
XRectangle button_rect = { (short)(win_w/2-40), (short)(win_h*0.8f), 80, 20 }; XRectangle button_rect = { (short)(win_w/2-40), (short)(win_h*0.8f), 80, 20 };
if (ev.type == MotionNotify){ if (ev.type == MotionNotify){
int new_hi = (ev.xmotion.x > button_rect.x && int new_hi = (ev.xmotion.x > button_rect.x &&
ev.xmotion.y > button_rect.y && ev.xmotion.y > button_rect.y &&
ev.xmotion.x < button_rect.x + button_rect.width && ev.xmotion.x < button_rect.x + button_rect.width &&
ev.xmotion.y < button_rect.y + button_rect.height); ev.xmotion.y < button_rect.y + button_rect.height);
if (new_hi != button_hi){ if (new_hi != button_hi){
button_hi = new_hi; button_hi = new_hi;
redraw = 1; redraw = 1;
} }
} }
if (ev.type == KeyPress){ if (ev.type == KeyPress){
KeySym sym = XLookupKeysym(&ev.xkey, 0); KeySym sym = XLookupKeysym(&ev.xkey, 0);
if (sym == XK_Escape || sym == XK_Return){ if (sym == XK_Escape || sym == XK_Return){
exit(1); exit(1);
} }
} }
if (ev.type == ButtonPress && ev.xbutton.button == Button1){ if (ev.type == ButtonPress && ev.xbutton.button == Button1){
if (button_hi) button_trigger = 1; if (button_hi) button_trigger = 1;
redraw = 1; redraw = 1;
} }
if (ev.type == ButtonRelease && ev.xbutton.button == Button1){ if (ev.type == ButtonRelease && ev.xbutton.button == Button1){
if (button_trigger){ if (button_trigger){
if (button_hi){ if (button_hi){
@ -126,61 +126,61 @@ system_error_box(char *msg, b32 shutdown = true){
} }
redraw = 1; redraw = 1;
} }
if (ev.type == ClientMessage && ev.xclient.window == w && (Atom)ev.xclient.data.l[0] == WM_DELETE_WINDOW){ if (ev.type == ClientMessage && ev.xclient.window == w && (Atom)ev.xclient.data.l[0] == WM_DELETE_WINDOW){
exit(1); exit(1);
} }
#define DRAW_STR(x, y, str, len) \ #define DRAW_STR(x, y, str, len) \
XDrawString(dpy, w, gc2, (x)+1, (y)+1, (str), (len)); \ XDrawString(dpy, w, gc2, (x)+1, (y)+1, (str), (len)); \
XDrawString(dpy, w, gc1, (x) , (y) , (str), (len)) XDrawString(dpy, w, gc1, (x) , (y) , (str), (len))
if (redraw){ if (redraw){
redraw = 0; redraw = 0;
XClearWindow(dpy, w); XClearWindow(dpy, w);
const char* line_start = msg; const char* line_start = msg;
const char* last_space = NULL; const char* last_space = NULL;
int y = 30; int y = 30;
{ {
const char title[] = "4coder - Fatal Error"; const char title[] = "4coder - Fatal Error";
int width = XTextWidth(font, title, sizeof(title)-1); int width = XTextWidth(font, title, sizeof(title)-1);
int x = (win_w/2) - (width/2); int x = (win_w/2) - (width/2);
DRAW_STR(x, y, title, sizeof(title)-1); DRAW_STR(x, y, title, sizeof(title)-1);
} }
y += 36; y += 36;
int width = XTextWidth(font, "x", 1) * num_cols; int width = XTextWidth(font, "x", 1) * num_cols;
int x = (win_w/2) - (width/2); int x = (win_w/2) - (width/2);
for(const char* p = line_start; *p; ++p){ for(const char* p = line_start; *p; ++p){
if (*p == ' ') last_space = p; if (*p == ' ') last_space = p;
if (p - line_start > num_cols || *p == '\n' || !p[1]){ if (p - line_start > num_cols || *p == '\n' || !p[1]){
const char* new_line_start = last_space + 1; const char* new_line_start = last_space + 1;
if (!last_space || *p == '\n' || !p[1]){ if (!last_space || *p == '\n' || !p[1]){
new_line_start = last_space = (p + !p[1]); new_line_start = last_space = (p + !p[1]);
} }
DRAW_STR(x, y, line_start, last_space - line_start); DRAW_STR(x, y, line_start, last_space - line_start);
line_start = new_line_start; line_start = new_line_start;
last_space = NULL; last_space = NULL;
y += 18; y += 18;
} }
} }
XDrawRectangles(dpy, w, gc1, &button_rect, 1); XDrawRectangles(dpy, w, gc1, &button_rect, 1);
if (button_hi || button_trigger){ if (button_hi || button_trigger){
XDrawRectangle(dpy, w, gc2, button_rect.x+1, button_rect.y+1, button_rect.width-2, button_rect.height-2); XDrawRectangle(dpy, w, gc2, button_rect.x+1, button_rect.y+1, button_rect.width-2, button_rect.height-2);
} }
DRAW_STR(button_rect.x + 20, button_rect.y + 15, "Drat!", 5); DRAW_STR(button_rect.x + 20, button_rect.y + 15, "Drat!", 5);
} }
} }
#undef DRAW_STR #undef DRAW_STR
if (shutdown){ if (shutdown){
exit(1); exit(1);
} }

View File

@ -46,9 +46,9 @@ 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,