Got custom and app layers building on Mac

master
Allen Webster 2017-06-26 22:47:00 -04:00
parent f9153fa2a5
commit 982dca7e5e
14 changed files with 121 additions and 194 deletions

View File

@ -119,9 +119,9 @@ execute_standard_build_search(Application_Links *app, View_Summary *view,
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
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];

View File

@ -1,5 +1,5 @@
/*
4coder_string.h - Version 1.0.74
4coder_string.h - Version 1.0.80
no warranty implied; use at your own risk
This software is in the public domain. Where that dedication is not
@ -12,7 +12,37 @@ To use in C mode: #define FSTRING_C
// TOP
// 4tech_standard_preamble.h
#if !defined(FTECH_INTEGERS)
#define FTECH_INTEGERS
#include <stdint.h>
typedef int8_t i8_4tech;
typedef int16_t i16_4tech;
typedef int32_t i32_4tech;
typedef int64_t i64_4tech;
typedef uint8_t u8_4tech;
typedef uint16_t u16_4tech;
typedef uint32_t u32_4tech;
typedef uint64_t u64_4tech;
#if defined(FTECH_32_BIT)
typedef u32_4tech umem_4tech;
#else
typedef u64_4tech umem_4tech;
#endif
typedef float f32_4tech;
typedef double f64_4tech;
typedef int8_t b8_4tech;
typedef int32_t b32_4tech;
#endif
#if !defined(Assert)
# define Assert(n) do{ if (!(n)) *(int*)0 = 0xA11E; }while(0)
#endif
// standard preamble end
#if !defined(FSTRING_LINK)
# define FSTRING_LINK static
@ -285,7 +315,7 @@ char_is_upper(char c)
FSTRING_INLINE b32_4tech
char_is_upper_utf8(char c)
{
return (c >= 'A' && c <= 'Z' || (unsigned char)c >= 128);
return ((c >= 'A' && c <= 'Z') || (unsigned char)c >= 128);
}
#endif
@ -301,7 +331,7 @@ char_is_lower(char c)
FSTRING_INLINE b32_4tech
char_is_lower_utf8(u8_4tech c)
{
return (c >= 'a' && c <= 'z' || (unsigned char)c >= 128);
return ((c >= 'a' && c <= 'z') || (unsigned char)c >= 128);
}
#endif
@ -333,7 +363,7 @@ char_is_whitespace(char c)
FSTRING_INLINE b32_4tech
char_is_alpha_numeric(char c)
{
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 == '_');
}
#endif
@ -341,7 +371,7 @@ char_is_alpha_numeric(char c)
FSTRING_INLINE b32_4tech
char_is_alpha_numeric_utf8(u8_4tech c)
{
return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= '0' && c <= '9' || c == '_' || (unsigned char)c >= 128);
return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_' || (unsigned char)c >= 128);
}
#endif
@ -349,7 +379,7 @@ char_is_alpha_numeric_utf8(u8_4tech c)
FSTRING_INLINE b32_4tech
char_is_alpha_numeric_true(char c)
{
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'));
}
#endif
@ -357,7 +387,7 @@ char_is_alpha_numeric_true(char c)
FSTRING_INLINE b32_4tech
char_is_alpha_numeric_true_utf8(u8_4tech c)
{
return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= '0' && c <= '9' || (unsigned char)c >= 128);
return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || (unsigned char)c >= 128);
}
#endif
@ -365,7 +395,7 @@ char_is_alpha_numeric_true_utf8(u8_4tech c)
FSTRING_INLINE b32_4tech
char_is_alpha(char c)
{
return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c == '_');
return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_');
}
#endif
@ -373,7 +403,7 @@ char_is_alpha(char c)
FSTRING_INLINE b32_4tech
char_is_alpha_utf8(u8_4tech c)
{
return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c == '_' || (unsigned char)c >= 128);
return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_' || (unsigned char)c >= 128);
}
#endif
@ -381,7 +411,7 @@ char_is_alpha_utf8(u8_4tech c)
FSTRING_INLINE b32_4tech
char_is_alpha_true(char c)
{
return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z');
return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'));
}
#endif
@ -389,7 +419,7 @@ char_is_alpha_true(char c)
FSTRING_INLINE b32_4tech
char_is_alpha_true_utf8(u8_4tech c)
{
return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || (unsigned char)c >= 128);
return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (unsigned char)c >= 128);
}
#endif
@ -397,7 +427,7 @@ char_is_alpha_true_utf8(u8_4tech c)
FSTRING_INLINE b32_4tech
char_is_hex(char c)
{
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'));
}
#endif
@ -405,7 +435,7 @@ char_is_hex(char c)
FSTRING_INLINE b32_4tech
char_is_hex_utf8(u8_4tech c)
{
return (c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f' || (unsigned char)c >= 128);
return ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f') || (unsigned char)c >= 128);
}
#endif
@ -421,7 +451,7 @@ char_is_numeric(char c)
FSTRING_INLINE b32_4tech
char_is_numeric_utf8(u8_4tech c)
{
return (c >= '0' && c <= '9' || (unsigned char)c >= 128);
return ((c >= '0' && c <= '9') || (unsigned char)c >= 128);
}
#endif

View File

@ -252,11 +252,13 @@ load_project_from_config_data(Application_Links *app, Partition *part, char *con
{
#if defined(_WIN32)
#define FKEY_COMMAND "fkey_command_win"
# define FKEY_COMMAND "fkey_command_win"
#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
#error no project configuration names for this platform
# error no project configuration names for this platform
#endif
int32_t index = 0;

View File

@ -1,19 +1,43 @@
#!/bin/bash
# NOTE(allen): This code here is pulled from stack exchange, it could totally be wrong
# 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.
SCRIPT_FILE=$(readlink -f "$0")
echo "Building custom_4coders.so from $SOURCE ..."
# Find the code home folder
# 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")
# Find the most reasonable candidate build file
SOURCE="$1"
if [ -z "$SOURCE" ]; then
SOURCE="$CODE_HOME/4coder_default_bindings.cpp"
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")
g++ -I"$CODE_HOME" -Wno-write-strings -std=gnu++0x "$SOURCE" -shared -o custom_4coder.so -fPIC
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

View File

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

View File

@ -216,8 +216,7 @@ make_folder_if_missing(char *dir, char *folder){
static void
clear_folder(char *folder){
systemf("del /S /Q /F %s\\* & rmdir /S /Q %s & mkdir %s",
folder, folder, folder);
systemf("del /S /Q /F %s\\* & rmdir /S /Q %s & mkdir %s", folder, folder, folder);
}
static void
@ -276,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);
}
#elif defined(IS_LINUX)
#elif defined(IS_LINUX) || defined(IS_MAC)
#include <time.h>
#include <unistd.h>
@ -413,142 +412,6 @@ zip(char *parent, char *folder, char *file){
popdir(temp);
}
#elif defined(IS_MAC)
#include <time.h>
#include <unistd.h>
static Temp_Dir
pushdir(char *dir){
Temp_Dir temp;
char *result = getcwd(temp.dir, sizeof(temp.dir));
int32_t chresult = chdir(dir);
if (result == 0 || chresult != 0){
printf("trying pushdir %s\n", dir);
Assert(result != 0);
Assert(chresult == 0);
}
return(temp);
}
static void
popdir(Temp_Dir temp){
chdir(temp.dir);
}
static void
init_time_system(){
// NOTE(allen): do nothing
}
static uint64_t
get_time(){
struct timespec spec;
uint64_t result;
clock_gettime(CLOCK_MONOTONIC, &spec);
result = (spec.tv_sec * (uint64_t)(1000000)) + (spec.tv_nsec / (uint64_t)(1000));
return(result);
}
static int32_t
get_current_directory(char *buffer, int32_t max){
int32_t result = 0;
char *d = getcwd(buffer, max);
if (d == buffer){
result = strlen(buffer);
}
return(result);
}
static void
execute_in_dir(char *dir, char *str, char *args){
if (dir){
if (args){
Temp_Dir temp = pushdir(dir);
systemf("%s %s", str, args);
popdir(temp);
}
else{
Temp_Dir temp = pushdir(dir);
systemf("%s", str);
popdir(temp);
}
}
else{
if (args){
systemf("%s %s", str, args);
}
else{
systemf("%s", str);
}
}
}
static void
slash_fix(char *path){}
static void
make_folder_if_missing(char *dir, char *folder){
if (folder){
systemf("mkdir -p %s/%s", dir, folder);
}
else{
systemf("mkdir -p %s", dir);
}
}
static void
clear_folder(char *folder){
systemf("rm -rf %s*", folder);
}
static void
delete_file(char *file){
systemf("rm %s", file);
}
static void
copy_file(char *path, char *file, char *folder1, char *folder2, char *newname){
if (!newname){
newname = file;
}
if (path){
if (folder2){
systemf("cp %s/%s %s/%s/%s", path, file, folder1, folder2, newname);
}
else{
systemf("cp %s/%s %s/%s", path, file, folder1, newname);
}
}
else{
if (folder2){
systemf("cp %s %s/%s/%s", file, folder1, folder2, newname);
}
else{
systemf("cp %s %s/%s", file, folder1, newname);
}
}
}
static void
copy_all(char *source, char *tag, char *folder){
if (source){
systemf("cp -f %s/%s %s", source, tag, folder);
}
else{
systemf("cp -f %s %s", tag, folder);
}
}
static void
zip(char *parent, char *folder, char *file){
Temp_Dir temp = pushdir(parent);
printf("PARENT DIR: %s\n", parent);
systemf("zip -r %s %s", file, folder);
popdir(temp);
}
#else
#error This OS is not supported yet
#endif

View File

@ -32,7 +32,7 @@
#if defined(IS_WINDOWS)
#define EXE ".exe"
#elif defined(IS_LINUX)
#elif defined(IS_LINUX) || defined(IS_MAC)
#define EXE ""
#else
#error No EXE format specified for this OS
@ -40,26 +40,26 @@
#if defined(IS_WINDOWS)
#define PDB ".pdb"
#elif defined(IS_LINUX)
#elif defined(IS_LINUX) || defined(IS_MAC)
#define PDB ""
#else
#error No EXE format specified for this OS
#error No PDB format specified for this OS
#endif
#if defined(IS_WINDOWS)
#define DLL ".dll"
#elif defined(IS_LINUX)
#elif defined(IS_LINUX) || defined(IS_MAC)
#define DLL ".so"
#else
#error No EXE format specified for this OS
#error No DLL format specified for this OS
#endif
#if defined(IS_WINDOWS)
#define BAT ".bat"
#elif defined(IS_LINUX)
#elif defined(IS_LINUX) || defined(IS_MAC)
#define BAT ".sh"
#else
#error No EXE format specified for this OS
#error No BAT format specified for this OS
#endif
static void
@ -246,8 +246,10 @@ build_cl(u32 flags, char *code_path, char *code_file, char *out_path, char *out_
}
#define GCC_OPTS \
"-Wno-write-strings -D_GNU_SOURCE -fPIC " \
#define GCC_OPTS \
"-Wno-write-strings -Wno-comment -Wno-switch " \
"-Wno-null-dereference " \
"-D_GNU_SOURCE -fPIC " \
"-fno-threadsafe-statics -pthread"
#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, "%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){
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"
#elif defined(IS_LINUX)
#define PLAT_LAYER "linux_4ed.cpp"
#elif defined(IS_MAC)
#define PLAT_LAYER "mac_4ed.m"
#else
#error No platform layer defined for this OS.
#endif
@ -560,6 +565,8 @@ get_4coder_dist_name(String *zip_file, b32 OS_specific, char *folder, char *tier
append_sc(zip_file, "-win");
#elif defined(IS_LINUX) && defined(IS_64BIT)
append_sc(zip_file, "-linux");
#elif defined(IS_MAC) && defined(IS_64BIT)
append_sc(zip_file, "-mac");
#else
#error No OS string for zips on this OS
#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:
{
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){
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
0
76
86

View File

@ -8,3 +8,4 @@ g++ $WARNINGS $FLAGS ../code/string/string_builder.cpp -g -o ../build/string_bui
pushd string
../../build/string_builder
popd

View File

@ -66,7 +66,7 @@ char_is_upper(char c)
API_EXPORT_INLINE FSTRING_INLINE b32_4tech
char_is_upper_utf8(char c)
/* DOC(If c is an uppercase letter this call returns true.) */{
return (c >= 'A' && c <= 'Z' || (unsigned char)c >= 128);
return ((c >= 'A' && c <= 'Z') || (unsigned char)c >= 128);
}
API_EXPORT_INLINE FSTRING_INLINE b32_4tech
@ -78,7 +78,7 @@ char_is_lower(char c)
API_EXPORT_INLINE FSTRING_INLINE b32_4tech
char_is_lower_utf8(u8_4tech c)
/* DOC(If c is a lower letter this call returns true.) */{
return (c >= 'a' && c <= 'z' || (unsigned char)c >= 128);
return ((c >= 'a' && c <= 'z') || (unsigned char)c >= 128);
}
API_EXPORT_INLINE FSTRING_INLINE char
@ -102,61 +102,61 @@ char_is_whitespace(char c)
API_EXPORT_INLINE FSTRING_INLINE b32_4tech
char_is_alpha_numeric(char c)
/* 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
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.) */{
return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= '0' && c <= '9' || c == '_' || (unsigned char)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
char_is_alpha_numeric_true(char c)
/* 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
char_is_alpha_numeric_true_utf8(u8_4tech c)
/* 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' || (unsigned char)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
char_is_alpha(char c)
/* 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
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.) */{
return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c == '_' || (unsigned char)c >= 128);
return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_' || (unsigned char)c >= 128);
}
API_EXPORT_INLINE FSTRING_INLINE b32_4tech
char_is_alpha_true(char c)
/* 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
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.) */{
return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || (unsigned char)c >= 128);
return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (unsigned char)c >= 128);
}
API_EXPORT_INLINE FSTRING_INLINE b32_4tech
char_is_hex(char c)
/* 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
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.) */{
return (c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f' || (unsigned char)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
@ -168,7 +168,7 @@ char_is_numeric(char c)
API_EXPORT_INLINE FSTRING_INLINE b32_4tech
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.) */{
return (c >= '0' && c <= '9' || (unsigned char)c >= 128);
return ((c >= '0' && c <= '9') || (unsigned char)c >= 128);
}

View File

@ -425,9 +425,8 @@ int main(){
else if (token->type == CPP_PP_INCLUDE){
token = get_next_token(&pcontext);
if (token && token->type == CPP_PP_INCLUDE_FILE){
lexeme = get_lexeme(*token, pcontext.data);;
lexeme = get_lexeme(*token, pcontext.data);
lexeme.size -= 2;
lexeme.str += 1;