diff --git a/.vscode/settings.json b/.vscode/settings.json index 3a700b20..5f8fe263 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,4 @@ { - "cmake.configureOnOpen": true + "cmake.configureOnOpen": true, + "files.eol": "\n" } diff --git a/CMakeLists.txt b/CMakeLists.txt index 2dd9dd63..10dd5f17 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,13 +30,13 @@ 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") + 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") ######################## # RELEASE # ######################## - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fPIE -D_FORTIFY_SOURCE=2 -fexceptions -Wall -O2 -flto -funroll-loops") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fPIE -D_FORTIFY_SOURCE=2 -fexceptions -Wall -O2 -flto=auto -funroll-loops") set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_LINKER_FLAGS_RELEASE} -fPIE -s") # -static -static-libgcc -static-libstdc++ elseif(MSVC) diff --git a/README.md b/README.md index de08fcf1..d5a4add9 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,8 @@ # Fan -Fan is a dynamically-typed programmign language based on -[Wren](https://wren.io). Fan's aim is to be _statically compilable_, portable, +Fan is a dynamically-typed programming language. It is based on +[Wren](https://wren.io), but features significant customizations to its runtime. Fan's aim is to be _statically compilable_, portable, and come with batteries-included. ```sh diff --git a/fan.sh b/fan.sh index 90698010..7e34507b 100755 --- a/fan.sh +++ b/fan.sh @@ -1,3 +1,14 @@ #!/usr/bin/env bash -FAN_LIB=./lang build/debug/fan "$@" + +# 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" +else + FAN_EXEC="./build/fan" +fi + +# Execute the fan command with the given arguments +FAN_LIB=./lang $FAN_EXEC "$@" \ No newline at end of file diff --git a/include/lib.hpp b/include/lib.hpp index f50078ab..192bc747 100644 --- a/include/lib.hpp +++ b/include/lib.hpp @@ -271,4 +271,6 @@ namespace encoding { void md_to_html(WrenVM* vm); } + + } // namespace lib diff --git a/tests/encoding.fan b/tests/encoding.fan deleted file mode 100644 index 2ae73ab4..00000000 --- a/tests/encoding.fan +++ /dev/null @@ -1,7 +0,0 @@ -import "std/encoding" for Base64 - -var value = Base64.encode("abcdefg") -System.print("Encode %(value)") - -var decode = Base64.decode(value) -System.print("Decode %(decode)") \ No newline at end of file diff --git a/tests/env.fan b/tests/env.fan deleted file mode 100644 index 10fdabad..00000000 --- a/tests/env.fan +++ /dev/null @@ -1,55 +0,0 @@ - -// System.print("std/fs Dir test") -// import "std/fs" for Dir - -// var dir = Dir.cwd() -// System.print(Dir.cwd()) - -System.print("std/os test") -import "std/os" for Env, Process, Runtime - -// var home = Env.get("HOME") -// if (home != null) { -// System.print(home) -// } else { -// System.print("Null") -// } - -// System.print("Setting ENV TEST:") -// Env.set("TEST", "YES") -// System.print("Getting ENV TEST:") -// System.print(Env.get("TEST")) -// System.print("Unsetting ENV TEST:") -// Env.set("TEST", null) -// System.print("Getting ENV TEST (after unset)") -// var test = Env.get("TEST") - -// if (test == null) { -// System.print("Value TEST: %(test). (Should be null)") -// } - -// System.print("Testing postfix and Prefix\nSetting TEST to 1") -// var testFail = Fiber.new { -// Env.set("TEST", 1) -// } -// var error = testFail.try() -// System.print("This was meant to fail: %(error)") - -// Env["TEST"] = "true" - -// System.print("%(Env["TEST"]) == true") -// // .env file support -// System.print("loadDotEnv test") -// Env.loadDotEnv("./tests/.env") -// if (Env.get("DOTENV") != null) { -// System.print("success") -// } else { -// System.print("fail") -// } -System.print("-------------------------------------------") -System.print("Logging process args: %(Process.args.count)") -System.print("%(Runtime.os): %(Runtime.arch)") - -for (arg in Process.args) { - System.print(arg) -} diff --git a/tests/fmt.fan b/tests/fmt.fan deleted file mode 100644 index 2e56adf8..00000000 --- a/tests/fmt.fan +++ /dev/null @@ -1,7 +0,0 @@ -import "std/fmt" for Fmt, Color - -var test = "apple" - - -var result = Fmt.reverse(test) -System.print("%(Color.green())%(result)%(Color.reset())") \ No newline at end of file diff --git a/tests/fs_cwd.fan b/tests/fs_cwd.fan deleted file mode 100644 index 87dc7547..00000000 --- a/tests/fs_cwd.fan +++ /dev/null @@ -1,5 +0,0 @@ -import "std/fs" for File - -var file = File.open("fan.sh", "r+") -System.print(file.read()) -file.close() \ No newline at end of file diff --git a/tests/fs_test.fan b/tests/fs_test.fan deleted file mode 100644 index 12609f8f..00000000 --- a/tests/fs_test.fan +++ /dev/null @@ -1,8 +0,0 @@ -// import "std/fs" for File - -// var file = File.open("fan.sh", "r+") -// System.print(file.read()) -// file.close() - -import "std/fs" for Fs - diff --git a/tests/http_test.fan b/tests/http_test.fan deleted file mode 100644 index 4079421c..00000000 --- a/tests/http_test.fan +++ /dev/null @@ -1,5 +0,0 @@ -import "std/net/http" for Request - -var client = Request.new("https://example.com") -var body = client.send() -System.write(body) diff --git a/tests/md_test.fan b/tests/md_test.fan deleted file mode 100644 index 7c11358f..00000000 --- a/tests/md_test.fan +++ /dev/null @@ -1,7 +0,0 @@ -import "std/encoding" for Markdown -var testDoc = "This is a test *comment*. -This is an **emboldened** comment." - -var text = Markdown.toHTML(testDoc) -System.print(text) - diff --git a/tests/open_file.fan b/tests/open_file.fan deleted file mode 100644 index 4914a130..00000000 --- a/tests/open_file.fan +++ /dev/null @@ -1,5 +0,0 @@ -import "std/fs" for File - -var file = File.open("void.sh", "r+") -System.print(file.read()) -file.close() \ No newline at end of file diff --git a/tests/proc.fan b/tests/proc.fan deleted file mode 100644 index 1aad9f06..00000000 --- a/tests/proc.fan +++ /dev/null @@ -1,6 +0,0 @@ -import "std/os" for Process - -System.print("Process test:") -var result = Process.exec("date", ["+\%Y-\%m-\%d"]) -System.print("The current date is: %(result)") -System.print(Process.args) \ No newline at end of file diff --git a/tests/recursive_cb.fan b/tests/recursive_cb.fan deleted file mode 100644 index 216bd8aa..00000000 --- a/tests/recursive_cb.fan +++ /dev/null @@ -1,33 +0,0 @@ -import "std/fs" for Fs, Path -import "std/os" for Process - -var args = Process.args() -var cwd = Fs.cwd() - -var bundler = Fiber.new { - var target = Path.from(args[0]) - if (target.isDirectory()) { - var all = Fs.listAll(target.toString()) - for (file in all) { - var stat = Path.from(file) - if (stat.isDirectory()) { - continue - } - - var buffer = Process.exec("zip", "-r - %(file)") - Fs.remove(file) - if (Fs.write(stat.join([args[1], file.split(Path.seperator())[-1]])) == null) { - System.print("This buffer wasn't saved") - } - - } - } else { - System.print("This isn't a directory") - Process.exit(1) - } -} - -var err = bundler.try() -if (err != null) { - System.print(err) -} diff --git a/tests/std/env_tests b/tests/std/env_tests new file mode 100644 index 00000000..e69de29b diff --git a/tests/std/markdown.fan b/tests/std/markdown.fan new file mode 100644 index 00000000..b5da350e --- /dev/null +++ b/tests/std/markdown.fan @@ -0,0 +1,16 @@ +import "std/encoding" for Markdown +import "std/fs" for Fs, Path + +var files = Fs.listAllRecursive(Fs.cwd()) + +// List of markdown files in the directory +var mdFiles = [] + +for (i in files) { + if (Path.ext(i) == "md") { + System.print(i) + mdFiles.add(i) + } +} + +System.print(mdFiles.count) diff --git a/valgrind.sh b/valgrind.sh index e6c3b149..d81d2271 100755 --- a/valgrind.sh +++ b/valgrind.sh @@ -1,9 +1,18 @@ #!/usr/bin/env bash +# 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" +else + FAN_EXEC="./build/fan" +fi + FAN_LIB=./lang valgrind --leak-check=full \ --show-leak-kinds=all \ --track-origins=yes \ --verbose \ --leak-check=full \ --log-file=build/valgrind-out.txt \ - ./build/fan $@ + $(FAN_EXEC) $@