Allen Webster 2017-06-27 12:02:41 -04:00
commit cbd60d136c
16 changed files with 253 additions and 213 deletions

View File

@ -119,9 +119,9 @@ execute_standard_build_search(Application_Links *app, View_Summary *view,
return(result); return(result);
} }
#elif defined(__linux__) #elif defined(__linux__) || (defined(__APPLE__) && defined(__MACH__))
// NOTE(allen): Build search rule for linux. // NOTE(allen): Build search rule for linux and mac.
static int32_t static int32_t
execute_standard_build_search(Application_Links *app, View_Summary *view, Buffer_Summary *active_buffer, String *dir, String *command, bool32 perform_backup){ execute_standard_build_search(Application_Links *app, View_Summary *view, Buffer_Summary *active_buffer, String *dir, String *command, bool32 perform_backup){
char dir_space[512]; char dir_space[512];

File diff suppressed because it is too large Load Diff

View File

@ -252,11 +252,13 @@ load_project_from_config_data(Application_Links *app, Partition *part, char *con
{ {
#if defined(_WIN32) #if defined(_WIN32)
#define FKEY_COMMAND "fkey_command_win" # define FKEY_COMMAND "fkey_command_win"
#elif defined(__linux__) #elif defined(__linux__)
#define FKEY_COMMAND "fkey_command_linux" # define FKEY_COMMAND "fkey_command_linux"
#elif defined(__APPLE__) && defined(__MACH__)
# define FKEY_COMMAND "fkey_command_mac"
#else #else
#error no project configuration names for this platform # error no project configuration names for this platform
#endif #endif
int32_t index = 0; int32_t index = 0;

View File

@ -34,7 +34,9 @@
# if defined(__gnu_linux__) # if defined(__gnu_linux__)
# define IS_LINUX # define IS_LINUX
# else # elif defined(__APPLE__) && defined(__MACH__)
# define IS_MAC
#else
# error This compiler/platform combo is not supported yet # error This compiler/platform combo is not supported yet
# endif # endif

View File

@ -5,7 +5,7 @@ if [ -z "$BUILD_MODE" ]; then
BUILD_MODE="-DDEV_BUILD" BUILD_MODE="-DDEV_BUILD"
fi fi
WARNINGS="-Wno-write-strings" WARNINGS="-Wno-write-strings -Wno-comment -Wno-logical-op-parentheses -Wno-null-dereference -Wno-switch"
FLAGS="-D_GNU_SOURCE -fPIC -fpermissive $BUILD_MODE" FLAGS="-D_GNU_SOURCE -fPIC -fpermissive $BUILD_MODE"
g++ $WARNINGS $FLAGS meta/build.cpp -g -o ../build/build g++ $WARNINGS $FLAGS meta/build.cpp -g -o ../build/build

View File

@ -1,19 +1,43 @@
#!/bin/bash #!/bin/bash
# NOTE(allen): This code here is pulled from stack exchange, it could totally be wrong echo "Building custom_4coders.so from $SOURCE ..."
# but I just don't know. The goal is to get the path to the buildsuper.sh script so that
# path can be used as an include path which allows a file in any folder to be built in place. # Find the code home folder
SCRIPT_FILE=$(readlink -f "$0")
# NOTE(allen): Copied from stack exchange, hope it's reasonable -- readlink doesn't work on mac
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") CODE_HOME=$(dirname "$SCRIPT_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="$CODE_HOME/4coder_default_bindings.cpp"
fi fi
echo "Building custom_4coders.so from $SOURCE ..." # NOTE(allen): Copied from stack exchange, hope it's reasonable -- readlink doesn't work on mac
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
SOURCE=$(readlink -f "$SOURCE") FLAGS="-Wno-write-strings -Wno-null-dereference -Wno-comment -Wno-switch -Wno-writable-strings"
g++ -I"$CODE_HOME" $FLAGS -std=gnu++0x "$SOURCE" -shared -o custom_4coder.so -fPIC
g++ -I"$CODE_HOME" -Wno-write-strings -std=gnu++0x "$SOURCE" -shared -o custom_4coder.so -fPIC

View File

@ -317,7 +317,6 @@ generate_style(){
////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////
// //
// Meta Parse Rules // Meta Parse Rules
// //

View File

@ -28,6 +28,13 @@ static char platform_correct_slash = '\\';
#define SLASH "/" #define SLASH "/"
static char platform_correct_slash = '/'; static char platform_correct_slash = '/';
#elif defined(IS_MAC)
# define ONLY_WINDOWS(x) (void)0
# define ONLY_LINUX(x) (void)0
#define SLASH "/"
static char platform_correct_slash = '/';
#else #else
# define ONLY_WINDOWS(x) (void)0 # define ONLY_WINDOWS(x) (void)0
# define ONLY_LINUX(x) (void)0 # define ONLY_LINUX(x) (void)0
@ -209,8 +216,7 @@ make_folder_if_missing(char *dir, char *folder){
static void static void
clear_folder(char *folder){ clear_folder(char *folder){
systemf("del /S /Q /F %s\\* & rmdir /S /Q %s & mkdir %s", systemf("del /S /Q /F %s\\* & rmdir /S /Q %s & mkdir %s", folder, folder, folder);
folder, folder, folder);
} }
static void static void
@ -269,7 +275,7 @@ zip(char *parent, char *folder, char *dest){
systemf("copy %s\\4tech_gobble.zip %s & del %s\\4tech_gobble.zip", cdir, dest, cdir); systemf("copy %s\\4tech_gobble.zip %s & del %s\\4tech_gobble.zip", cdir, dest, cdir);
} }
#elif defined(IS_LINUX) #elif defined(IS_LINUX) || defined(IS_MAC)
#include <time.h> #include <time.h>
#include <unistd.h> #include <unistd.h>
@ -281,8 +287,8 @@ pushdir(char *dir){
int32_t chresult = chdir(dir); int32_t chresult = chdir(dir);
if (result == 0 || chresult != 0){ if (result == 0 || chresult != 0){
printf("trying pushdir %s\n", dir); printf("trying pushdir %s\n", dir);
assert(result != 0); Assert(result != 0);
assert(chresult == 0); Assert(chresult == 0);
} }
return(temp); return(temp);
} }
@ -402,6 +408,7 @@ zip(char *parent, char *folder, char *file){
Temp_Dir temp = pushdir(parent); Temp_Dir temp = pushdir(parent);
printf("PARENT DIR: %s\n", parent); printf("PARENT DIR: %s\n", parent);
systemf("zip -r %s %s", file, folder); systemf("zip -r %s %s", file, folder);
popdir(temp); popdir(temp);
} }

View File

@ -32,7 +32,7 @@
#if defined(IS_WINDOWS) #if defined(IS_WINDOWS)
#define EXE ".exe" #define EXE ".exe"
#elif defined(IS_LINUX) #elif defined(IS_LINUX) || defined(IS_MAC)
#define EXE "" #define EXE ""
#else #else
#error No EXE format specified for this OS #error No EXE format specified for this OS
@ -40,26 +40,26 @@
#if defined(IS_WINDOWS) #if defined(IS_WINDOWS)
#define PDB ".pdb" #define PDB ".pdb"
#elif defined(IS_LINUX) #elif defined(IS_LINUX) || defined(IS_MAC)
#define PDB "" #define PDB ""
#else #else
#error No EXE format specified for this OS #error No PDB format specified for this OS
#endif #endif
#if defined(IS_WINDOWS) #if defined(IS_WINDOWS)
#define DLL ".dll" #define DLL ".dll"
#elif defined(IS_LINUX) #elif defined(IS_LINUX) || defined(IS_MAC)
#define DLL ".so" #define DLL ".so"
#else #else
#error No EXE format specified for this OS #error No DLL format specified for this OS
#endif #endif
#if defined(IS_WINDOWS) #if defined(IS_WINDOWS)
#define BAT ".bat" #define BAT ".bat"
#elif defined(IS_LINUX) #elif defined(IS_LINUX) || defined(IS_MAC)
#define BAT ".sh" #define BAT ".sh"
#else #else
#error No EXE format specified for this OS #error No BAT format specified for this OS
#endif #endif
static void static void
@ -246,8 +246,10 @@ build_cl(u32 flags, char *code_path, char *code_file, char *out_path, char *out_
} }
#define GCC_OPTS \ #define GCC_OPTS \
"-Wno-write-strings -D_GNU_SOURCE -fPIC " \ "-Wno-write-strings -Wno-comment -Wno-switch " \
"-Wno-null-dereference " \
"-D_GNU_SOURCE -fPIC " \
"-fno-threadsafe-statics -pthread" "-fno-threadsafe-statics -pthread"
#define GCC_X86 "-m32" #define GCC_X86 "-m32"
@ -327,7 +329,8 @@ build_gcc(u32 flags, char *code_path, char *code_file, char *out_path, char *out
build_ap(line, "-DFRED_KEEP_ASSERT"); build_ap(line, "-DFRED_KEEP_ASSERT");
} }
build_ap(line, "%s/%s", code_path, code_file); build_ap(line, "-I\"%s\"", code_path);
build_ap(line, "\"%s/%s\"", code_path, code_file);
if (flags & LIBS){ if (flags & LIBS){
build_ap(line, GCC_LIBS); build_ap(line, GCC_LIBS);
@ -380,6 +383,8 @@ buildsuper(char *code_path, char *out_path, char *filename, b32 x86_build){
#define PLAT_LAYER "win32_4ed.cpp" #define PLAT_LAYER "win32_4ed.cpp"
#elif defined(IS_LINUX) #elif defined(IS_LINUX)
#define PLAT_LAYER "linux_4ed.cpp" #define PLAT_LAYER "linux_4ed.cpp"
#elif defined(IS_MAC)
#define PLAT_LAYER "mac_4ed.m"
#else #else
#error No platform layer defined for this OS. #error No platform layer defined for this OS.
#endif #endif
@ -560,6 +565,8 @@ get_4coder_dist_name(String *zip_file, b32 OS_specific, char *folder, char *tier
append_sc(zip_file, "-win"); append_sc(zip_file, "-win");
#elif defined(IS_LINUX) && defined(IS_64BIT) #elif defined(IS_LINUX) && defined(IS_64BIT)
append_sc(zip_file, "-linux"); append_sc(zip_file, "-linux");
#elif defined(IS_MAC) && defined(IS_64BIT)
append_sc(zip_file, "-mac");
#else #else
#error No OS string for zips on this OS #error No OS string for zips on this OS
#endif #endif

View File

@ -572,7 +572,7 @@ main_fsm(Cpp_Lex_FSM fsm, uint8_t pp_state, uint8_t c, bool32 ignore_string_deli
case LS_hex: case LS_hex:
{ {
int is_hex = c >= '0' && c <= '9' || c >= 'a' && c <= 'f' || c >= 'A' && c <= 'F' || c >= 128; int is_hex = (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F') || c >= 128;
if (!is_hex){ if (!is_hex){
fsm.emit_token = true; fsm.emit_token = true;
} }

BIN
power/custom_4coder.so Executable file

Binary file not shown.

2
readlink_f_simulator.sh Executable file
View File

@ -0,0 +1,2 @@
#!/bin/sh

View File

@ -1,5 +1,5 @@
1 1
0 0
74 86

11
string/build.sh Executable file
View File

@ -0,0 +1,11 @@
#!/bin/bash
WARNINGS="-Wno-write-strings -Wno-comment -Wno-logical-op-parentheses -Wno-null-dereference -Wno-switch"
FLAGS="-D_GNU_SOURCE -fPIC -fpermissive"
g++ $WARNINGS $FLAGS ../code/string/string_builder.cpp -g -o ../build/string_builder
pushd string
../../build/string_builder
popd

View File

@ -66,7 +66,7 @@ char_is_upper(char c)
API_EXPORT_INLINE FSTRING_INLINE b32_4tech API_EXPORT_INLINE FSTRING_INLINE b32_4tech
char_is_upper_utf8(char c) char_is_upper_utf8(char c)
/* DOC(If c is an uppercase letter this call returns true.) */{ /* DOC(If c is an uppercase letter this call returns true.) */{
return (c >= 'A' && c <= 'Z' || c >= 128); return ((c >= 'A' && c <= 'Z') || (unsigned char)c >= 128);
} }
API_EXPORT_INLINE FSTRING_INLINE b32_4tech API_EXPORT_INLINE FSTRING_INLINE b32_4tech
@ -78,7 +78,7 @@ char_is_lower(char c)
API_EXPORT_INLINE FSTRING_INLINE b32_4tech API_EXPORT_INLINE FSTRING_INLINE b32_4tech
char_is_lower_utf8(u8_4tech c) char_is_lower_utf8(u8_4tech c)
/* DOC(If c is a lower letter this call returns true.) */{ /* DOC(If c is a lower letter this call returns true.) */{
return (c >= 'a' && c <= 'z' || c >= 128); return ((c >= 'a' && c <= 'z') || (unsigned char)c >= 128);
} }
API_EXPORT_INLINE FSTRING_INLINE char API_EXPORT_INLINE FSTRING_INLINE char
@ -102,61 +102,61 @@ char_is_whitespace(char c)
API_EXPORT_INLINE FSTRING_INLINE b32_4tech API_EXPORT_INLINE FSTRING_INLINE b32_4tech
char_is_alpha_numeric(char c) char_is_alpha_numeric(char c)
/* DOC(This call returns non-zero if c is any alphanumeric character including underscore.) */{ /* DOC(This call returns non-zero if c is any alphanumeric character including underscore.) */{
return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= '0' && c <= '9' || c == '_'); return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_');
} }
API_EXPORT_INLINE FSTRING_INLINE b32_4tech API_EXPORT_INLINE FSTRING_INLINE b32_4tech
char_is_alpha_numeric_utf8(u8_4tech c) char_is_alpha_numeric_utf8(u8_4tech c)
/* DOC(This call returns non-zero if c is any alphanumeric character including underscore, or is a part of a UTF8 sequence outside of ASCII.) */{ /* DOC(This call returns non-zero if c is any alphanumeric character including underscore, or is a part of a UTF8 sequence outside of ASCII.) */{
return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= '0' && c <= '9' || c == '_' || c >= 128); return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_' || (unsigned char)c >= 128);
} }
API_EXPORT_INLINE FSTRING_INLINE b32_4tech API_EXPORT_INLINE FSTRING_INLINE b32_4tech
char_is_alpha_numeric_true(char c) char_is_alpha_numeric_true(char c)
/* DOC(This call returns non-zero if c is any alphanumeric character no including underscore.) */{ /* DOC(This call returns non-zero if c is any alphanumeric character no including underscore.) */{
return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= '0' && c <= '9'); return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9'));
} }
API_EXPORT_INLINE FSTRING_INLINE b32_4tech API_EXPORT_INLINE FSTRING_INLINE b32_4tech
char_is_alpha_numeric_true_utf8(u8_4tech c) char_is_alpha_numeric_true_utf8(u8_4tech c)
/* DOC(This call returns non-zero if c is any alphanumeric character no including underscore.) */{ /* DOC(This call returns non-zero if c is any alphanumeric character no including underscore.) */{
return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= '0' && c <= '9' || c >= 128); return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || (unsigned char)c >= 128);
} }
API_EXPORT_INLINE FSTRING_INLINE b32_4tech API_EXPORT_INLINE FSTRING_INLINE b32_4tech
char_is_alpha(char c) char_is_alpha(char c)
/* DOC(This call returns non-zero if c is any alphabetic character including underscore.) */{ /* DOC(This call returns non-zero if c is any alphabetic character including underscore.) */{
return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c == '_'); return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_');
} }
API_EXPORT_INLINE FSTRING_INLINE b32_4tech API_EXPORT_INLINE FSTRING_INLINE b32_4tech
char_is_alpha_utf8(u8_4tech c) char_is_alpha_utf8(u8_4tech c)
/* DOC(This call returns non-zero if c is any alphabetic character including underscore, or is a part of a UTF8 sequence outside of ASCII.) */{ /* DOC(This call returns non-zero if c is any alphabetic character including underscore, or is a part of a UTF8 sequence outside of ASCII.) */{
return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c == '_' || c >= 128); return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_' || (unsigned char)c >= 128);
} }
API_EXPORT_INLINE FSTRING_INLINE b32_4tech API_EXPORT_INLINE FSTRING_INLINE b32_4tech
char_is_alpha_true(char c) char_is_alpha_true(char c)
/* DOC(This call returns non-zero if c is any alphabetic character.) */{ /* DOC(This call returns non-zero if c is any alphabetic character.) */{
return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z'); return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'));
} }
API_EXPORT_INLINE FSTRING_INLINE b32_4tech API_EXPORT_INLINE FSTRING_INLINE b32_4tech
char_is_alpha_true_utf8(u8_4tech c) char_is_alpha_true_utf8(u8_4tech c)
/* DOC(This call returns non-zero if c is any alphabetic character, or is a part of a UTF8 sequence outside of ASCII.) */{ /* DOC(This call returns non-zero if c is any alphabetic character, or is a part of a UTF8 sequence outside of ASCII.) */{
return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= 128); return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (unsigned char)c >= 128);
} }
API_EXPORT_INLINE FSTRING_INLINE b32_4tech API_EXPORT_INLINE FSTRING_INLINE b32_4tech
char_is_hex(char c) char_is_hex(char c)
/* DOC(This call returns non-zero if c is any valid hexadecimal digit.) */{ /* DOC(This call returns non-zero if c is any valid hexadecimal digit.) */{
return (c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f'); return ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f'));
} }
API_EXPORT_INLINE FSTRING_INLINE b32_4tech API_EXPORT_INLINE FSTRING_INLINE b32_4tech
char_is_hex_utf8(u8_4tech c) char_is_hex_utf8(u8_4tech c)
/* DOC(This call returns non-zero if c is any valid hexadecimal digit, or is a part of a UTF8 sequence outside of ASCII.) */{ /* DOC(This call returns non-zero if c is any valid hexadecimal digit, or is a part of a UTF8 sequence outside of ASCII.) */{
return (c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f' || c >= 128); return ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f') || (unsigned char)c >= 128);
} }
API_EXPORT_INLINE FSTRING_INLINE b32_4tech API_EXPORT_INLINE FSTRING_INLINE b32_4tech
@ -168,7 +168,7 @@ char_is_numeric(char c)
API_EXPORT_INLINE FSTRING_INLINE b32_4tech API_EXPORT_INLINE FSTRING_INLINE b32_4tech
char_is_numeric_utf8(u8_4tech c) char_is_numeric_utf8(u8_4tech c)
/* DOC(This call returns non-zero if c is any valid decimal digit, or is a part of a UTF8 sequence outside of ASCII.) */{ /* DOC(This call returns non-zero if c is any valid decimal digit, or is a part of a UTF8 sequence outside of ASCII.) */{
return (c >= '0' && c <= '9' || c >= 128); return ((c >= '0' && c <= '9') || (unsigned char)c >= 128);
} }
@ -1452,17 +1452,11 @@ space in dest this call returns non-zero.) */{
API_EXPORT FSTRING_LINK i32_4tech API_EXPORT FSTRING_LINK i32_4tech
u64_to_str_size(uint64_t x)/* u64_to_str_size(uint64_t x)/*
DOC(This call returns the number of bytes required to represent x as a string.) */{ DOC(This call returns the number of bytes required to represent x as a string.) */{
i32_4tech size; i32_4tech size = 1;
if (x < 0){ x /= 10;
size = 0; while (x != 0){
}
else{
size = 1;
x /= 10; x /= 10;
while (x != 0){ ++size;
x /= 10;
++size;
}
} }
return(size); return(size);
} }

View File

@ -425,9 +425,8 @@ int main(){
else if (token->type == CPP_PP_INCLUDE){ else if (token->type == CPP_PP_INCLUDE){
token = get_next_token(&pcontext); token = get_next_token(&pcontext);
if (token && token->type == CPP_PP_INCLUDE_FILE){ if (token && token->type == CPP_PP_INCLUDE_FILE){
lexeme = get_lexeme(*token, pcontext.data);; lexeme = get_lexeme(*token, pcontext.data);
lexeme.size -= 2; lexeme.size -= 2;
lexeme.str += 1; lexeme.str += 1;
@ -481,7 +480,7 @@ int main(){
} }
#define FTECH_FILE_MOVING_IMPLEMENTATION #define FTECH_FILE_MOVING_IMPLEMENTATION
#include "..\meta\4tech_file_moving.h" #include "../meta/4tech_file_moving.h"
// BOTTOM // BOTTOM