Skip to content

Commit

Permalink
Merge 044f020 into f3c3958
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinEady committed Mar 9, 2024
2 parents f3c3958 + 044f020 commit 0dd603d
Show file tree
Hide file tree
Showing 14 changed files with 726 additions and 99 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ Makefile
/CMakeSettings.json
__pycache__
gen/
build/
build/
.vscode
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ include(cmake/Boost.cmake)
include(cmake/Benchmark.cmake)
include(cmake/Cppdap.cmake)
include(cmake/Curl.cmake)
include(cmake/Efsw.cmake)
include(cmake/EscriptGrammarLib.cmake)
include(cmake/escript_grammar.cmake)
include(cmake/Fmt.cmake)
Expand Down
1 change: 1 addition & 0 deletions bin-build/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ ipch
module_defs
coretest
fmt
efsw
60 changes: 32 additions & 28 deletions cmake/Antlr.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,35 @@ else()
set(ANTLR_LIB "${ANTLR_INSTALL_DIR}/lib/antlr4-runtime-static.lib")
endif()

ExternalProject_Add(libantlr_ext
SOURCE_DIR ${ANTLR_SOURCE_DIR}
PREFIX antlr
LIST_SEPARATOR |
CMAKE_ARGS
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_INSTALL_PREFIX=${ANTLR_INSTALL_DIR}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DWITH_LIBCXX=Off
-DANTLR_BUILD_SHARED=Off
-DANTLR_BUILD_CPP_TESTS=Off
-DCMAKE_OSX_ARCHITECTURES=${PIPED_OSX_ARCHITECTURES}
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
BINARY_DIR ${ANTLR_SOURCE_DIR}/build
BUILD_COMMAND ${CMAKE_COMMAND} --build . --config Release
INSTALL_COMMAND ${CMAKE_COMMAND} --build . --config Release --target install

BUILD_BYPRODUCTS ${ANTLR_LIB}
LOG_DOWNLOAD 1
LOG_CONFIGURE 1
LOG_BUILD 1
LOG_INSTALL 1
LOG_OUTPUT_ON_FAILURE 1
EXCLUDE_FROM_ALL 1
)
if (NOT EXISTS ${ANTLR_LIB})
file(MAKE_DIRECTORY ${ANTLR_INCLUDE_DIR}) #directory has to exist during configure
ExternalProject_Add(libantlr_ext
SOURCE_DIR ${ANTLR_SOURCE_DIR}
PREFIX antlr
LIST_SEPARATOR |
CMAKE_ARGS
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_INSTALL_PREFIX=${ANTLR_INSTALL_DIR}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DWITH_LIBCXX=Off
-DANTLR_BUILD_SHARED=Off
-DANTLR_BUILD_CPP_TESTS=Off
-DCMAKE_OSX_ARCHITECTURES=${PIPED_OSX_ARCHITECTURES}
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
BINARY_DIR ${ANTLR_SOURCE_DIR}/build
BUILD_COMMAND ${CMAKE_COMMAND} --build . --config Release
INSTALL_COMMAND ${CMAKE_COMMAND} --build . --config Release --target install

BUILD_BYPRODUCTS ${ANTLR_LIB}
LOG_DOWNLOAD 1
LOG_CONFIGURE 1
LOG_BUILD 1
LOG_INSTALL 1
LOG_OUTPUT_ON_FAILURE 1
EXCLUDE_FROM_ALL 1
)
else()
message(" - already built")
endif()

# imported target to add include/lib dir and additional dependencies
Expand All @@ -53,4 +54,7 @@ set_target_properties(libantlr PROPERTIES
INTERFACE_COMPILE_DEFINITIONS ANTLR4CPP_STATIC
FOLDER 3rdParty
)
add_dependencies(libantlr libantlr_ext)
if (NOT EXISTS ${ANTLR_LIB})
file(MAKE_DIRECTORY ${ANTLR_INCLUDE_DIR}) #directory has to exist during configure
add_dependencies(libantlr libantlr_ext)
endif()
71 changes: 71 additions & 0 deletions cmake/Efsw.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
message("* libefsw")

set (EFSW_REPOSITORY "https://github.com/SpartanJ/efsw.git")
set (EFSW_VERSION_REF "3419347")

set (EFSW_SOURCE_DIR "${POL_EXT_LIB_DIR}/efsw-${EFSW_VERSION_REF}")
set (EFSW_INSTALL_DIR "${EFSW_SOURCE_DIR}/build")

if (${windows})
set (EFSW_LIB "${EFSW_INSTALL_DIR}/lib/efsw-static.lib" )
else()
set (EFSW_LIB "${EFSW_INSTALL_DIR}/lib/libefsw-static.a" )
endif()

set (EFSW_ARGS ${EFSW_FLAGS}
-DCMAKE_INSTALL_PREFIX=${EFSW_INSTALL_DIR}
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_OSX_ARCHITECTURES=${PIPED_OSX_ARCHITECTURES}
-DBUILD_TEST_APP=OFF
-DBUILD_SHARED_LIBS=ON # The -static file isn't installed unless this is enabled?
-DBUILD_STATIC_LIBS=ON
-DCMAKE_USER_MAKE_RULES_OVERRIDE_CXX=${CMAKE_CURRENT_LIST_DIR}/cxx_flag_overrides.cmake
-DCMAKE_USER_MAKE_RULES_OVERRIDE=${CMAKE_CURRENT_LIST_DIR}/c_flag_overrides.cmake
-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded
)

if(NOT EXISTS ${EFSW_LIB})
ExternalProject_Add(libefsw_ext
GIT_REPOSITORY ${EFSW_REPOSITORY}
GIT_TAG ${EFSW_VERSION_REF}
GIT_SHALLOW TRUE
PREFIX efsw
LIST_SEPARATOR |
CMAKE_ARGS ${EFSW_ARGS}
SOURCE_DIR "${EFSW_SOURCE_DIR}"
BUILD_IN_SOURCE 1
BUILD_COMMAND ${CMAKE_COMMAND} --build . --config Release
INSTALL_COMMAND ${CMAKE_COMMAND} --build . --config Release --target install
BUILD_BYPRODUCTS ${EFSW_LIB}
EXCLUDE_FROM_ALL 1
LOG_DOWNLOAD 1
LOG_CONFIGURE 1
LOG_BUILD 1
LOG_INSTALL 1
LOG_OUTPUT_ON_FAILURE 1
)
else()
message(" - already built")
endif()

add_library(libefsw STATIC IMPORTED)
set_target_properties(libefsw PROPERTIES
IMPORTED_LOCATION ${EFSW_LIB}
IMPORTED_IMPLIB ${EFSW_LIB}
INTERFACE_INCLUDE_DIRECTORIES ${EFSW_INSTALL_DIR}/include
FOLDER 3rdParty
)
if(APPLE)
find_library(CoreFoundation_Library CoreFoundation)
find_library(CoreServices_Library CoreServices)
set_property(TARGET libefsw APPEND
PROPERTY INTERFACE_LINK_LIBRARIES
${CoreFoundation_Library} ${CoreServices_Library})
endif()

if(NOT EXISTS ${EFSW_LIB})
file(MAKE_DIRECTORY ${EFSW_INSTALL_DIR}/include) #directory has to exist during configure
add_dependencies(libefsw libefsw_ext)
endif()
1 change: 1 addition & 0 deletions lib/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ curl-*
boost_*
zlib-*
cppdap-*
efsw-*
4 changes: 2 additions & 2 deletions pol-core/bscript/compiler/astbuilder/SourceFileProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ void SourceFileProcessor::use_module( const std::string& module_name,
SourceLocation& including_location,
long long* micros_counted )
{
std::string pathname = compilercfg.ModuleDirectory + module_name + ".em";

std::string pathname =
Clib::FullPath( ( compilercfg.ModuleDirectory + module_name + ".em" ).c_str() );
if ( workspace.source_files.find( pathname ) != workspace.source_files.end() )
return;

Expand Down
11 changes: 11 additions & 0 deletions pol-core/bscript/compiler/file/SourceFileCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,15 @@ void SourceFileCache::keep_some()
profile.prune_cache_delete_micros += delete_timer.ellapsed().count();
}

void SourceFileCache::clear()
{
std::unique_lock<std::mutex> lock( mutex, std::try_to_lock_t() );
if ( !lock.owns_lock() )
return;

Pol::Tools::HighPerfTimer delete_timer;
files.clear();
profile.prune_cache_delete_micros += delete_timer.ellapsed().count();
}

} // namespace Pol::Bscript::Compiler
1 change: 1 addition & 0 deletions pol-core/bscript/compiler/file/SourceFileCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class SourceFileCache
std::shared_ptr<SourceFile> load( const SourceFileIdentifier&, Report& report );

void keep_some();
void clear();

private:
unsigned keep;
Expand Down
7 changes: 4 additions & 3 deletions pol-core/ecompile/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@ include(CMakeSources.cmake)

add_executable(${ex_name}
${${ex_name}_sources}
)
)

set_compile_flags(${ex_name} 1)
warning_suppression(${ex_name})

target_link_libraries(${ex_name} PUBLIC
bscript
clib
plib
libefsw
plib
)
dist(${ex_name} scripts)

Expand Down
4 changes: 3 additions & 1 deletion pol-core/ecompile/CMakeSources.cmake
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
set (ecompile_sources # sorted !
CMakeSources.cmake
CMakeSources.cmake
ECompileMain.cpp
ECompileMain.h
ecompile.ico
ecompile.rc
EfswFileWatchListener.cpp
EfswFileWatchListener.h
resource.h
)

0 comments on commit 0dd603d

Please sign in to comment.