Skip to content

Commit

Permalink
fix: We now move stdlib to .lesma directory in $HOME
Browse files Browse the repository at this point in the history
  • Loading branch information
alinalihassan committed Aug 29, 2022
1 parent 19be9ef commit ff20761
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ CPMAddPackage(
get_filename_component(ROOT_DIR ${CMAKE_SOURCE_DIR} ABSOLUTE)
get_filename_component(SRC_DIR ${ROOT_DIR}/src ABSOLUTE)
get_filename_component(LIB_DIR ${ROOT_DIR}/lib ABSOLUTE)
get_filename_component(STDLIB_DIR ${SRC_DIR}/stdlib ABSOLUTE)
get_filename_component(BUILD_DIR ${CMAKE_BINARY_DIR} ABSOLUTE)

# Version configuration
Expand Down Expand Up @@ -86,6 +87,9 @@ set(COMMON_SOURCES
set(CLI_SOURCES src/cli/main.cpp)
set(TEST_SOURCES tests/test.cpp)

# Move Standard Library
file(COPY ${STDLIB_DIR} DESTINATION $ENV{HOME}/.lesma/)

# Libraries required for the compiler itself
set(COMMON_LIBS ${LLVM_LIBS} ${CLANG_LIBS} fmt nameof)

Expand Down Expand Up @@ -113,7 +117,9 @@ include(InstallRequiredSystemLibraries)
install(TARGETS ${CLI_NAME} RUNTIME DESTINATION bin)
install(DIRECTORY ${SRC_DIR}/stdlib DESTINATION .)

set(CPACK_GENERATOR "STGZ;TGZ")
# TODO: Should move stdlib when a user installs

set(CPACK_GENERATOR "STGZ")
set(CPACK_PACKAGE_VENDOR Lesma)
set(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR})
Expand Down
3 changes: 2 additions & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@
## Features
- [x] Add parenthesis support
- [ ] Add analyzer phase (add tree walker interface?)
- [ ] Add optional parameters in function declarations
- [x] Add type inference
- [ ] Add operator overloading
- [x] Add varargs
- [x] Add pointers/references?
- [x] Add strings
- [ ] Add generics
- [ ] Add lists
- [ ] Add tuples
- [ ] Add ranges (1..4 style)
Expand All @@ -46,7 +48,6 @@
- [x] Add unit tests
- [x] Add module system
- [x] Add python-style syntax
- [ ] Add generics
- [ ] Add inheritance (or traits)
- [ ] Add string interpolation
- [x] Add standard library (things like print, input, etc)
Expand Down
10 changes: 8 additions & 2 deletions src/liblesma/Common/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,13 @@ namespace lesma {
}

std::string getStdDir() {
std::string file_path = __FILE__;
return file_path.substr(0, file_path.rfind("src") + 3) + "/stdlib/";
std::string homedir;

if(getenv("HOME"))
homedir = getenv("HOME");
else
homedir = getpwuid(getuid())->pw_dir;

return homedir + "/.lesma/stdlib/";
}
}// namespace lesma
2 changes: 2 additions & 0 deletions src/liblesma/Common/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include <cmath>
#include <fstream>
#include <sstream>
#include <pwd.h>
#include <unistd.h>

#include "llvm/Support/SMLoc.h"
#include "llvm/Support/SourceMgr.h"
Expand Down

0 comments on commit ff20761

Please sign in to comment.