Cleaning up package script output
This commit is contained in:
parent
2ee9d05bd2
commit
3a27541ceb
|
@ -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;
|
||||
|
|
|
@ -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
|
|
@ -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
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
#!/bin/bash
|
||||
|
||||
chmod 777 bin/build-linux.sh
|
||||
bin/build-linux.sh "-DPACKAGE"
|
|
@ -1,4 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
chmod 777 build.sh
|
||||
./build.sh "-DPACKAGE"
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -15,16 +15,16 @@ internal void
|
|||
system_error_box(char *msg, b32 shutdown = true){
|
||||
fprintf(stderr, "Fatal Error: %s\n", msg);
|
||||
//LOGF("Fatal Error: %s\n", msg);
|
||||
|
||||
|
||||
Display *dpy = XOpenDisplay(0);
|
||||
if (!dpy){
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
const int num_cols = 50;
|
||||
int win_w = (num_cols + 10) * 9;
|
||||
int win_h = 140;
|
||||
|
||||
|
||||
{
|
||||
const char *start_p = msg, *space_p = NULL;
|
||||
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);
|
||||
XStoreName(dpy, w, "4coder Error");
|
||||
|
||||
|
||||
XSizeHints* sh = XAllocSizeHints();
|
||||
sh->flags = PMinSize;
|
||||
sh->min_width = win_w;
|
||||
sh->min_height = win_h;
|
||||
XSetWMNormalHints(dpy, w, sh);
|
||||
|
||||
|
||||
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);
|
||||
|
||||
|
||||
Atom WM_DELETE_WINDOW = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
|
||||
XSetWMProtocols(dpy, w, &WM_DELETE_WINDOW, 1);
|
||||
|
||||
|
||||
linux_set_icon(dpy, w);
|
||||
|
||||
|
||||
XMapRaised(dpy, w);
|
||||
XSync(dpy, False);
|
||||
|
||||
|
||||
XSelectInput(dpy, w, ExposureMask | StructureNotifyMask | PointerMotionMask | ButtonPressMask | ButtonReleaseMask | KeyPressMask);
|
||||
|
||||
|
||||
XFontStruct* font = XLoadQueryFont(dpy, "-*-fixed-bold-*-*-*-*-140-*-*-*-*-iso8859-1");
|
||||
if (!font){
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
XGCValues gcv;
|
||||
gcv.foreground = WhitePixel(dpy, 0);
|
||||
gcv.line_width = 2;
|
||||
gcv.font = font->fid;
|
||||
|
||||
|
||||
GC gc1 = XCreateGC(dpy, w, GCForeground | GCFont | GCLineWidth, &gcv);
|
||||
gcv.foreground = BlackPixel(dpy, 0);
|
||||
GC gc2 = XCreateGC(dpy, w, GCForeground | GCFont | GCLineWidth, &gcv);
|
||||
|
||||
|
||||
int button_trigger = 0;
|
||||
int button_hi = 0;
|
||||
int redraw = 1;
|
||||
|
||||
|
||||
XEvent ev;
|
||||
while (1){
|
||||
XNextEvent(dpy, &ev);
|
||||
|
||||
|
||||
if (ev.type == Expose) redraw = 1;
|
||||
|
||||
|
||||
if (ev.type == ConfigureNotify){
|
||||
redraw = 1;
|
||||
win_w = ev.xconfigure.width;
|
||||
win_h = ev.xconfigure.height;
|
||||
}
|
||||
|
||||
|
||||
XRectangle button_rect = { (short)(win_w/2-40), (short)(win_h*0.8f), 80, 20 };
|
||||
|
||||
|
||||
if (ev.type == MotionNotify){
|
||||
int new_hi = (ev.xmotion.x > button_rect.x &&
|
||||
ev.xmotion.y > button_rect.y &&
|
||||
ev.xmotion.x < button_rect.x + button_rect.width &&
|
||||
ev.xmotion.y < button_rect.y + button_rect.height);
|
||||
|
||||
|
||||
if (new_hi != button_hi){
|
||||
button_hi = new_hi;
|
||||
redraw = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (ev.type == KeyPress){
|
||||
KeySym sym = XLookupKeysym(&ev.xkey, 0);
|
||||
if (sym == XK_Escape || sym == XK_Return){
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (ev.type == ButtonPress && ev.xbutton.button == Button1){
|
||||
if (button_hi) button_trigger = 1;
|
||||
redraw = 1;
|
||||
}
|
||||
|
||||
|
||||
if (ev.type == ButtonRelease && ev.xbutton.button == Button1){
|
||||
if (button_trigger){
|
||||
if (button_hi){
|
||||
|
@ -126,61 +126,61 @@ system_error_box(char *msg, b32 shutdown = true){
|
|||
}
|
||||
redraw = 1;
|
||||
}
|
||||
|
||||
|
||||
if (ev.type == ClientMessage && ev.xclient.window == w && (Atom)ev.xclient.data.l[0] == WM_DELETE_WINDOW){
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
#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;
|
||||
XClearWindow(dpy, w);
|
||||
|
||||
|
||||
const char* line_start = msg;
|
||||
const char* last_space = NULL;
|
||||
int y = 30;
|
||||
|
||||
|
||||
{
|
||||
const char title[] = "4coder - Fatal Error";
|
||||
int width = XTextWidth(font, title, sizeof(title)-1);
|
||||
int x = (win_w/2) - (width/2);
|
||||
DRAW_STR(x, y, title, sizeof(title)-1);
|
||||
}
|
||||
|
||||
|
||||
y += 36;
|
||||
int width = XTextWidth(font, "x", 1) * num_cols;
|
||||
int x = (win_w/2) - (width/2);
|
||||
|
||||
|
||||
for(const char* p = line_start; *p; ++p){
|
||||
if (*p == ' ') last_space = p;
|
||||
if (p - line_start > num_cols || *p == '\n' || !p[1]){
|
||||
|
||||
|
||||
const char* new_line_start = last_space + 1;
|
||||
if (!last_space || *p == '\n' || !p[1]){
|
||||
new_line_start = last_space = (p + !p[1]);
|
||||
}
|
||||
|
||||
|
||||
DRAW_STR(x, y, line_start, last_space - line_start);
|
||||
|
||||
|
||||
line_start = new_line_start;
|
||||
last_space = NULL;
|
||||
y += 18;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
XDrawRectangles(dpy, w, gc1, &button_rect, 1);
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
DRAW_STR(button_rect.x + 20, button_rect.y + 15, "Drat!", 5);
|
||||
}
|
||||
}
|
||||
#undef DRAW_STR
|
||||
|
||||
|
||||
if (shutdown){
|
||||
exit(1);
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue