building in the bin dir now

This commit is contained in:
FelixBrendel
2019-06-28 12:34:00 +02:00
parent 6da1530d0f
commit d576e7324f
17 changed files with 145 additions and 147 deletions
+1 -1
View File
@@ -1,5 +1,4 @@
/vs/*/* /vs/*/*
/build
*.ilk *.ilk
*.aux *.aux
*.fls *.fls
@@ -7,6 +6,7 @@
*.toc *.toc
*.fdb_latexmk *.fdb_latexmk
*.pdb *.pdb
*.obj
*.exe *.exe
*.user *.user
*.psess *.psess
-1
View File
@@ -1 +0,0 @@
(define-syntax (e x) `(+ 1 ,x))
-6
View File
@@ -1,6 +0,0 @@
(import "a.slime")
(define (f) (e 2))
(show f)
(f)
(show f)
-3
View File
@@ -1,3 +0,0 @@
(import "b.slime")
(printf (e 3))
+3 -7
View File
@@ -3,27 +3,23 @@
pushd %~dp0 pushd %~dp0
set exeName=slime.exe set exeName=slime.exe
set binDir=bin
mkdir build 2>nul pushd bin
pushd build
taskkill /F /IM %exeName% > NUL 2> NUL taskkill /F /IM %exeName% > NUL 2> NUL
echo ---------- Compiling ---------- echo ---------- Compiling ----------
call timecmd cl ../src/main.cpp /std:c++latest /Fe%exeName% /W3 /Zi /nologo /EHsc /link /NODEFAULTLIB:libucrt libucrtd.lib call timecmd cl ../src/main.cpp /std:c++latest /Fe%exeName% /W3 /Zi /nologo /EHsc /link /NODEFAULTLIB:libucrt libucrtd.lib
popd
if %errorlevel% == 0 ( if %errorlevel% == 0 (
echo. echo.
echo Done echo Done
echo. echo.
pushd ..\bin call timecmd bin\slime.exe --run-tests
call timecmd ..\build\slime.exe --run-tests
popd
) else ( ) else (
echo. echo.
echo Fuckin' ell echo Fuckin' ell
) )
popd popd
popd
Binary file not shown.
Binary file not shown.
+2 -2
View File
@@ -41,14 +41,14 @@ proc built_in_load(String* file_name, Environment* env) -> Lisp_Object* {
// save the current working directory // save the current working directory
// get the direction of the exe // get the direction of the exe
char* exe_path = exe_dir(); char* exe_path = get_exe_dir();
defer { defer {
free(exe_path); free(exe_path);
}; };
fullpath[0] = '\0'; fullpath[0] = '\0';
sprintf(fullpath, "%s%s", exe_path, Memory::get_c_str(file_name)); sprintf(fullpath, "%s%s", exe_path, Memory::get_c_str(file_name));
// printf("Fullpath: %s\n", fullpath); printf("Fullpath: %s\n", fullpath);
file_content = read_entire_file(fullpath); file_content = read_entire_file(fullpath);
if (!file_content) { if (!file_content) {
-1
View File
@@ -14,7 +14,6 @@ constexpr bool is_debug_build = false;
# define if_linux if constexpr (0) # define if_linux if constexpr (0)
# define debug_break() if_debug __debugbreak() # define debug_break() if_debug __debugbreak()
#else #else
# include <signal.h>
# define debug_break() if_debug raise(SIGTRAP) # define debug_break() if_debug raise(SIGTRAP)
# define if_windows if (0) # define if_windows if (0)
# define if_linux if (1) # define if_linux if (1)
+1 -1
View File
@@ -2,7 +2,7 @@ proc generate_docs(Environment* env, String* path) -> void {
// save the current working directory // save the current working directory
char* cwd = get_cwd(); char* cwd = get_cwd();
// get the direction of the exe // get the direction of the exe
char* exe_path = exe_dir(); char* exe_path = get_exe_dir();
change_cwd(exe_path); change_cwd(exe_path);
defer { defer {
+1 -1
View File
@@ -12,7 +12,7 @@ proc load_built_ins_into_environment(Environment*) -> void;
proc parse_argument_list(Lisp_Object*, Function*) -> void; proc parse_argument_list(Lisp_Object*, Function*) -> void;
proc print_environment(Environment*) -> void; proc print_environment(Environment*) -> void;
proc exe_dir() -> char*; // proc get_exe_dir() -> char*;
proc Lisp_Object_Type_to_string(Lisp_Object_Type type) -> const char*; proc Lisp_Object_Type_to_string(Lisp_Object_Type type) -> const char*;
-101
View File
@@ -387,104 +387,3 @@ proc log_error() -> void {
puts(console_normal); puts(console_normal);
} }
proc exe_dir() -> char* {
if_linux {
size_t size = 512, i, n;
char *path, *temp;
while (1) {
size_t used;
path = (char*)malloc(size);
if (!path) {
errno = ENOMEM;
return NULL;
}
used = readlink("/proc/self/exe", path, size);
if (used == -1) {
const int saved_errno = errno;
free(path);
errno = saved_errno;
return NULL;
} else
if (used < 1) {
free(path);
errno = EIO;
return NULL;
}
if ((size_t)used >= size) {
free(path);
size = (size | 2047) + 2049;
continue;
}
size = (size_t)used;
break;
}
/* Find final slash. */
n = 0;
for (i = 0; i < size; i++)
if (path[i] == '/')
n = i;
/* Optimize allocated size,
ensuring there is room for
a final slash and a
string-terminating '\0', */
temp = path;
path = (char*)realloc(temp, n + 2);
if (!path) {
free(temp);
errno = ENOMEM;
return NULL;
}
/* and properly trim and terminate the path string. */
path[n+0] = '/';
path[n+1] = '\0';
return path;
}
if_windows {
DWORD last_error;
DWORD result;
DWORD path_size = 1024;
char* path = (char*)malloc(1024);
while (true) {
memset(path, 0, path_size);
result = GetModuleFileName(0, path, path_size - 1);
last_error = GetLastError();
if (0 == result) {
free(path);
path = 0;
break;
}
else if (result == path_size - 1) {
free(path);
/* May need to also check for ERROR_SUCCESS here if XP/2K */
if (ERROR_INSUFFICIENT_BUFFER != last_error) {
path = 0;
break;
}
path_size = path_size * 2;
path = (char*)malloc(path_size);
}
else
break;
}
if (!path) {
fprintf(stderr, "Failure: %d\n", last_error);
return "";
}
else
return path;
}
}
+1 -1
View File
@@ -363,7 +363,7 @@ namespace Memory {
}; };
// get the direction of the exe // get the direction of the exe
char* exe_path = exe_dir(); char* exe_path = get_exe_dir();
change_cwd(exe_path); change_cwd(exe_path);
free(exe_path); free(exe_path);
+120 -8
View File
@@ -2,22 +2,134 @@ inline proc get_cwd() -> char* {
const int buf_size = 2048; const int buf_size = 2048;
char* res = (char*)malloc(buf_size * sizeof(char)); char* res = (char*)malloc(buf_size * sizeof(char));
if_linux { #ifdef _MSC_VER
getcwd(res, buf_size);
}
if_windows {
_getcwd(res, buf_size); _getcwd(res, buf_size);
} #else
getcwd(res, buf_size);
#endif
return res; return res;
} }
inline proc change_cwd(char* dir) -> void { inline proc change_cwd(char* dir) -> void {
if_linux { #ifdef _MSC_VER
_chdir(dir);
#else
chdir(dir); chdir(dir);
#endif
}
proc get_exe_dir() -> char* {
#ifdef _MSC_VER
DWORD last_error;
DWORD result;
DWORD path_size = 1024;
char* path = (char*)malloc(1024);
while (true) {
memset(path, 0, path_size);
result = GetModuleFileName(0, path, path_size - 1);
last_error = GetLastError();
if (0 == result) {
free(path);
path = 0;
break;
}
else if (result == path_size - 1) {
free(path);
/* May need to also check for ERROR_SUCCESS here if XP/2K */
if (ERROR_INSUFFICIENT_BUFFER != last_error) {
path = 0;
break;
}
path_size = path_size * 2;
path = (char*)malloc(path_size);
}
else
break;
} }
if_windows { if (!path) {
_chdir(dir); fprintf(stderr, "Failure: %d\n", last_error);
return "";
} }
else {
// remove the exe name, so we are only left with the path
int index_in_path = -1;
int last_backslash = -1;
char c;
while ((c = path[++index_in_path]) != '\0') {
if (c == '\\')
last_backslash = index_in_path;
}
// we are assuming there are some backslashes
path[last_backslash+1] = '\0';
return path;
}
#else
ssize_t size = 512, i, n;
char *path, *temp;
while (1) {
size_t used;
path = (char*)malloc(size);
if (!path) {
errno = ENOMEM;
return NULL;
}
used = readlink("/proc/self/exe", path, size);
if (used == -1) {
const int saved_errno = errno;
free(path);
errno = saved_errno;
return NULL;
} else
if (used < 1) {
free(path);
errno = EIO;
return NULL;
}
if ((size_t)used >= size) {
free(path);
size = (size | 2047) + 2049;
continue;
}
size = (size_t)used;
break;
}
/* Find final slash. */
n = 0;
for (i = 0; i < size; i++)
if (path[i] == '/')
n = i;
/* Optimize allocated size,
ensuring there is room for
a final slash and a
string-terminating '\0', */
temp = path;
path = (char*)realloc(temp, n + 2);
if (!path) {
free(temp);
errno = ENOMEM;
return NULL;
}
/* and properly trim and terminate the path string. */
path[n+0] = '/';
path[n+1] = '\0';
return path;
#endif
} }
+11 -9
View File
@@ -2,15 +2,8 @@
#define _CRT_SECURE_NO_WARNINGS #define _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_DEPRECATE #define _CRT_SECURE_NO_DEPRECATE
#include <stdlib.h>
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) #include <stdlib.h>
# include <direct.h>
# include <windows.h>
size_t readlink(char*, char*, size_t);
#else
# include <unistd.h>
#endif
#include <stdio.h> #include <stdio.h>
#include <time.h> #include <time.h>
#include <string.h> #include <string.h>
@@ -19,14 +12,23 @@ size_t readlink(char*, char*, size_t);
#include <stdarg.h> #include <stdarg.h>
#include <functional> #include <functional>
#ifdef _MSC_VER
# include <direct.h>
# include <windows.h>
#else
# include <unistd.h>
# include <signal.h>
#endif
#undef _CRT_SECURE_NO_DEPRECATE #undef _CRT_SECURE_NO_DEPRECATE
#undef _CRT_SECURE_NO_WARNINGS #undef _CRT_SECURE_NO_WARNINGS
namespace Slime { namespace Slime {
# include "./defines.cpp" # include "./defines.cpp"
# include "./platform.cpp"
# include "./structs.cpp" # include "./structs.cpp"
# include "./forward_decls.cpp" # include "./forward_decls.cpp"
# include "./platform.cpp"
# include "./memory.cpp" # include "./memory.cpp"
# include "./lisp_object.cpp" # include "./lisp_object.cpp"
# include "./error.cpp" # include "./error.cpp"
+1 -1
View File
@@ -593,7 +593,7 @@ proc run_all_tests() -> bool {
Memory::init(4096 * 2000, 1024 * 32, 4096 * 16 * 10); Memory::init(4096 * 2000, 1024 * 32, 4096 * 16 * 10);
// get the direction of the exe // get the direction of the exe
char* exe_path = exe_dir(); char* exe_path = get_exe_dir();
// switch to the exe directory for loading pre.slime // switch to the exe directory for loading pre.slime
change_cwd(exe_path); change_cwd(exe_path);
+2 -2
View File
@@ -4,15 +4,15 @@ proc visualize_lisp_machine() -> void {
char* cwd = get_cwd(); char* cwd = get_cwd();
// get the direction of the exe // get the direction of the exe
char* exe_path = exe_dir(); char* exe_path = get_exe_dir();
// switch to the exe directory for loading pre.slime // switch to the exe directory for loading pre.slime
change_cwd(exe_path); change_cwd(exe_path);
free(exe_path);
defer { defer {
// switch back to the users directory // switch back to the users directory
change_cwd(cwd); change_cwd(cwd);
free(cwd); free(cwd);
free(exe_path);
}; };
struct Drawn_Area { struct Drawn_Area {