Skip to content

Commit

Permalink
cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
tristanisham committed May 29, 2024
1 parent 9759afa commit 76eab84
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
12 changes: 10 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
include_directories("include/")
include_directories("vendor/")


# CMark
link_directories("vendor/cmark")

Expand All @@ -30,8 +31,8 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
########################

# Add back: fsanitize=leak
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fasynchronous-unwind-tables -ggdb3 -Wall -fsanitize=leak -fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer -flto=auto")
set(CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fsanitize=leak -fsanitize=address -fsanitize=undefined -no-pie -Wall -fno-omit-frame-pointer")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=address,leak,undefined -fno-omit-frame-pointer -fasynchronous-unwind-tables -no-pie -ggdb3 -Wall -flto=auto")
set(CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fsanitize=address,leak,undefined -fno-omit-frame-pointer -no-pie -Wall -fno-omit-frame-pointer")

########################
# RELEASE #
Expand All @@ -57,10 +58,17 @@ else ()
# Executable
add_executable(fan ${SRC_FILES})

# Link libasan only for debug builds
# if(CMAKE_BUILD_TYPE MATCHES Debug)
# target_link_libraries(fan PRIVATE asan)
# endif()


# Final Build
target_link_libraries(fan-dev PRIVATE ${CMAKE_CXX_STANDARD_LIBRARIES} pthread ${CURL_LIBRARIES} cmark) #leveldb
target_link_libraries(fan PRIVATE ${CMAKE_CXX_STANDARD_LIBRARIES} fan-dev)


endif()

# Static Lib
Expand Down
8 changes: 4 additions & 4 deletions src/vm/std/os.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void lib::os::getEnv(WrenVM* vm) {
const char* key = wrenGetSlotString(vm, 1);
auto val = std::getenv(key);
wrenEnsureSlots(vm, 1);
if (val == NULL) {
if (val == nullptr) {
wrenSetSlotNull(vm, 0);
} else {
wrenSetSlotString(vm, 0, val);
Expand Down Expand Up @@ -103,7 +103,7 @@ double getParentProcessId() {
return 0; // Parent process not found.
#else
pid_t ppid = getppid();
double dPpid = static_cast<double>(ppid);
auto dPpid = static_cast<double>(ppid);
return dPpid;
#endif
}
Expand Down Expand Up @@ -155,7 +155,7 @@ constexpr std::string_view vm::getPlatformArchitecture() {
void lib::os::runtimeOS(WrenVM* vm) {
wrenEnsureSlots(vm, 1);
auto os = vm::getOperatingSystem();
if (os != "uknown") {
if (os != "unknown") {
wrenSetSlotString(vm, 0, os.data());
} else {
wrenSetSlotNull(vm, 0);
Expand Down Expand Up @@ -183,7 +183,7 @@ void lib::os::processExec(WrenVM* vm) {
for (int i = 0; i < argsLen; i++) {
wrenGetListElement(vm, 2, i, 4);
auto arg = wrenGetSlotString(vm, 4);
args.push_back(arg);
args.emplace_back(arg);
}

std::string parsedArgs = boost::algorithm::join(args, " ");
Expand Down
5 changes: 5 additions & 0 deletions tests/std/exec.fan
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import "std/os" for Process

var out = Process.exec("eval", ["echo", "-n", "hi, there", "|", "sha256sum"])

System.print(out)
8 changes: 5 additions & 3 deletions valgrind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@
# Check for the existence of the fan executable in different directories
if [[ -x "./build/debug/fan" ]]; then
FAN_EXEC="./build/debug/fan"
elif [[ -x "./build/release/fan" ]]; then
FAN_EXEC="./build/release/fan"
#elif [[ -x "./build/release/fan" ]]; then
# FAN_EXEC="./build/release/fan"
else
FAN_EXEC="./build/fan"
fi

export LD_PRELOAD="/usr/lib/x86_64-linux-gnu/libasan.so.6:$LD_PRELOAD"

FAN_LIB=./lang valgrind --leak-check=full \
--show-leak-kinds=all \
--track-origins=yes \
--verbose \
--leak-check=full \
--log-file=build/valgrind-out.txt \
$(FAN_EXEC) $@
$FAN_EXEC $@

0 comments on commit 76eab84

Please sign in to comment.