Fixed GC static library

This commit is contained in:
Victor Olin 2023-03-21 13:09:14 +01:00
parent bba6afeff8
commit 75fb24e369
6 changed files with 27 additions and 8 deletions

4
.gitignore vendored
View file

@ -11,4 +11,6 @@ llvm.ll
src/GC/lib/*.o
src/GC/lib/*.so
src/GC/tests/*.out
src/GC/lib/*.a
src/GC/tests/*.out
src/GC/tests/logs

View file

@ -43,9 +43,26 @@ game:
$(CC) $(WFLAGS) $(STDFLAGS) $(LIB_INCL) tests/game.cpp lib/heap.cpp lib/profiler.cpp lib/event.cpp -o tests/game.out
extern_lib:
# remove old files
rm -f lib/heap.o lib/libheap.so tests/extern_lib.out
# compile heap to object file
$(CC) $(STDFLAGS) -c -fPIC -o lib/heap.o lib/heap.cpp
$(CC) $(STDFLAGS) -shared -o lib/libheap.so lib/heap.o
$(CC) $(STDFLAGS) $(WFLAGS) $(LIB_INCL) -v tests/extern_lib.cpp lib/heap.cpp -o tests/extern_lib.out
$(CC) $(STDFLAGS) $(LIB_INCL) $(LIB_SO) -v -Wall -o tests/extern_lib.out tests/extern_lib.cpp -lheap
LD_LIBRARY_PATH=$(LIB_LINK) tests/extern_lib.out
LD_LIBRARY_PATH=$(LIB_LINK) tests/extern_lib.out
static_lib:
# remove old files
rm -f lib/event.o lib/profiler.o lib/heap.o lib/gcoll.a tests/extern_lib.out
# compile object files
$(CC) $(STDFLAGS) $(WFLAGS) $(LIB_INCL) -c -o lib/event.o lib/event.cpp -fPIC
$(CC) $(STDFLAGS) $(WFLAGS) $(LIB_INCL) -c -o lib/profiler.o lib/profiler.cpp -fPIC
$(CC) $(STDFLAGS) $(WFLAGS) $(LIB_INCL) -c -o lib/heap.o lib/heap.cpp -fPIC
# create static library
ar r lib/gcoll.a lib/event.o lib/profiler.o lib/heap.o
# create test program
static_lib_test: static_lib
$(CC) $(STDFLAGS) $(WFLAGS) $(LIB_INCL) -o tests/extern_lib.out tests/extern_lib.cpp lib/gcoll.a

View file

@ -4,7 +4,6 @@
#include "chunk.hpp"
#include "event.hpp"
#include "heap.hpp"
namespace GC {

View file

@ -4,7 +4,6 @@
#include "chunk.hpp"
#include "event.hpp"
#include "heap.hpp"
namespace GC
{

View file

@ -9,7 +9,6 @@
#include "chunk.hpp"
#include "event.hpp"
#include "heap.hpp"
#include "profiler.hpp"
namespace GC
@ -69,7 +68,7 @@ namespace GC
<< "\n Size: " << chunk->size
<< "\n Mark: " << chunk->marked;
}
fstr << "--------------------------------\n" << std::endl;
fstr << "\n--------------------------------" << std::endl;
}
}
@ -101,7 +100,7 @@ namespace GC
return fstr;
}
std::string get_log_folder()
std::string Profiler::get_log_folder()
{
char buffer[1024];
// chars read from path
@ -122,6 +121,6 @@ namespace GC
size_t last_slash = path.find_last_of('/');
std::string folder = path.substr(0, last_slash);
return folder;
return folder + "/logs";
}
}

View file

@ -14,6 +14,8 @@ int main() {
init_gc(heap);
frame_test(heap);
heap->dispose();
return 0;
}
@ -52,6 +54,7 @@ void init_gc(GC::Heap *heap){
std::cout << "\n\n INITIALIZING THE HEAP" << std::endl;
std::cout << "===========================" << std::endl;
heap->init();
heap->set_profiler(true);
std::cout << "===========================" << std::endl;
}