Skip to content

Commit

Permalink
Split up STL compilation (#158)
Browse files Browse the repository at this point in the history
* Split up STL compilation

Avoid error on mingw32 i686 and speed up compilation

* Version 0.12.5

* Fix macOS version symlink
  • Loading branch information
barche authored Jun 4, 2024
1 parent 1e26ca8 commit 93768c1
Show file tree
Hide file tree
Showing 14 changed files with 182 additions and 25 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/test-linux-mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ jobs:
mkdir build && cd build
cmake -DCMAKE_INSTALL_PREFIX=$HOME/install -DAPPEND_OVERRIDES_TOML=ON -DCMAKE_BUILD_TYPE=Debug ..
VERBOSE=ON cmake --build . --config Debug --target install
wget https://github.com/JuliaBinaryWrappers/libcxxwrap_julia_jll.jl/raw/main/Project.toml
jllversion=$(grep "version" Project.toml | sed -r 's/.* = "(.*)\+.*/\1/')
cd lib
if [ ! -f libcxxwrap_julia.${jllversion}.dylib ]; then
ln -s libcxxwrap_julia.*.*.*.* libcxxwrap_julia.${jllversion}.dylib
fi
cd ..
ls -al lib
julia -e "using Pkg; pkg\"add ${package}\"; using CxxWrap"
ctest -V
- name: Build testlib
Expand Down
24 changes: 9 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,15 @@ set(JLCXX_STL_HEADERS

set(JLCXX_STL_SOURCES
${JLCXX_SOURCE_DIR}/stl.cpp
${JLCXX_SOURCE_DIR}/stl_vector.cpp
${JLCXX_SOURCE_DIR}/stl_valarray.cpp
${JLCXX_SOURCE_DIR}/stl_deque.cpp
${JLCXX_SOURCE_DIR}/stl_queue.cpp
${JLCXX_SOURCE_DIR}/stl_set.cpp
${JLCXX_SOURCE_DIR}/stl_multiset.cpp
${JLCXX_SOURCE_DIR}/stl_shared_ptr.cpp
${JLCXX_SOURCE_DIR}/stl_unique_ptr.cpp
${JLCXX_SOURCE_DIR}/stl_weak_ptr.cpp
)

set(JLCXX_SOURCES
Expand All @@ -105,28 +114,13 @@ set(JLCXX_SOURCES
# Versioning
# ==========

option(OVERRIDE_VERSION_TO_JLL "Override the version info to match the installed JLL, so the filenames match for the Overrides.toml" OFF)

file(STRINGS "${JLCXX_INCLUDE_DIR}/jlcxx/jlcxx_config.hpp" jlcxx_version_defines
REGEX "#define JLCXX_VERSION_(MAJOR|MINOR|PATCH)")
foreach(ver ${jlcxx_version_defines})
if(ver MATCHES "#define JLCXX_VERSION_(MAJOR|MINOR|PATCH) +([^ ]+)$")
set(JLCXX_VERSION_${CMAKE_MATCH_1} "${CMAKE_MATCH_2}" CACHE INTERNAL "")
endif()
endforeach()
if(OVERRIDE_VERSION_TO_JLL)
execute_process(
COMMAND git describe --tags --abbrev=0
OUTPUT_VARIABLE _JLL_VERSION
)
string(STRIP "${_JLL_VERSION}" _JLL_VERSION)
message(STATUS "git version: ${_JLL_VERSION}")
string(REGEX REPLACE "v" "" _JLL_VERSION "${_JLL_VERSION}")
string(REPLACE "." ";" _jlcxx_VERSION_LIST "${_JLL_VERSION}")
list(GET _jlcxx_VERSION_LIST 0 JLCXX_VERSION_MAJOR)
list(GET _jlcxx_VERSION_LIST 1 JLCXX_VERSION_MINOR)
list(GET _jlcxx_VERSION_LIST 2 JLCXX_VERSION_PATCH)
endif()
set(${PROJECT_NAME}_VERSION
${JLCXX_VERSION_MAJOR}.${JLCXX_VERSION_MINOR}.${JLCXX_VERSION_PATCH})
message(STATUS "${PROJECT_NAME} version: v${${PROJECT_NAME}_VERSION}")
Expand Down
2 changes: 1 addition & 1 deletion include/jlcxx/jlcxx_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#define JLCXX_VERSION_MAJOR 0
#define JLCXX_VERSION_MINOR 12
#define JLCXX_VERSION_PATCH 4
#define JLCXX_VERSION_PATCH 5

// From https://stackoverflow.com/questions/5459868/concatenate-int-to-string-using-c-preprocessor
#define __JLCXX_STR_HELPER(x) #x
Expand Down
11 changes: 11 additions & 0 deletions include/jlcxx/stl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,17 @@ class JLCXX_API StlWrappers
}
};

// Separate per-container functions to split up the compilation over multiple C++ files
void apply_vector(TypeWrapper1& vector);
void apply_valarray(TypeWrapper1& valarray);
void apply_deque(TypeWrapper1& deque);
void apply_queue(TypeWrapper1& queue);
void apply_set(TypeWrapper1& set);
void apply_multiset(TypeWrapper1& multiset);
void apply_shared_ptr();
void apply_weak_ptr();
void apply_unique_ptr();

JLCXX_API StlWrappers& wrappers();

using stltypes = remove_duplicates<combine_parameterlists<combine_parameterlists<ParameterList
Expand Down
18 changes: 9 additions & 9 deletions src/stl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ JLCXX_API std::unique_ptr<StlWrappers> StlWrappers::m_instance = std::unique_ptr
JLCXX_API void StlWrappers::instantiate(Module& mod)
{
m_instance.reset(new StlWrappers(mod));
m_instance->vector.apply_combination<std::vector, stltypes>(stl::WrapVector());
m_instance->valarray.apply_combination<std::valarray, stltypes>(stl::WrapValArray());
m_instance->deque.apply_combination<std::deque, stltypes>(stl::WrapDeque());
m_instance->queue.apply_combination<std::queue, stltypes>(stl::WrapQueue());
m_instance->set.apply_combination<std::set, stltypes>(stl::WrapSet());
m_instance->multiset.apply_combination<std::multiset, stltypes>(stl::WrapMultiset());
smartptr::apply_smart_combination<std::shared_ptr, stltypes>();
smartptr::apply_smart_combination<std::weak_ptr, stltypes>();
smartptr::apply_smart_combination<std::unique_ptr, stltypes>();
apply_vector(m_instance->vector);
apply_valarray(m_instance->valarray);
apply_deque(m_instance->deque);
apply_queue(m_instance->queue);
apply_set(m_instance->set);
apply_multiset(m_instance->multiset);
apply_shared_ptr();
apply_weak_ptr();
apply_unique_ptr();
}

JLCXX_API StlWrappers& StlWrappers::instance()
Expand Down
16 changes: 16 additions & 0 deletions src/stl_deque.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include "jlcxx/stl.hpp"

namespace jlcxx
{

namespace stl
{

void apply_deque(TypeWrapper1& deque)
{
deque.apply_combination<std::deque, stltypes>(stl::WrapDeque());
}

}

}
16 changes: 16 additions & 0 deletions src/stl_multiset.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include "jlcxx/stl.hpp"

namespace jlcxx
{

namespace stl
{

void apply_multiset(TypeWrapper1& multiset)
{
multiset.apply_combination<std::multiset, stltypes>(stl::WrapMultiset());
}

}

}
16 changes: 16 additions & 0 deletions src/stl_queue.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include "jlcxx/stl.hpp"

namespace jlcxx
{

namespace stl
{

void apply_queue(TypeWrapper1& queue)
{
queue.apply_combination<std::queue, stltypes>(stl::WrapQueue());
}

}

}
16 changes: 16 additions & 0 deletions src/stl_set.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include "jlcxx/stl.hpp"

namespace jlcxx
{

namespace stl
{

void apply_set(TypeWrapper1& set)
{
set.apply_combination<std::set, stltypes>(stl::WrapSet());
}

}

}
16 changes: 16 additions & 0 deletions src/stl_shared_ptr.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include "jlcxx/stl.hpp"

namespace jlcxx
{

namespace stl
{

void apply_shared_ptr()
{
smartptr::apply_smart_combination<std::shared_ptr, stltypes>();
}

}

}
16 changes: 16 additions & 0 deletions src/stl_unique_ptr.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include "jlcxx/stl.hpp"

namespace jlcxx
{

namespace stl
{

void apply_unique_ptr()
{
smartptr::apply_smart_combination<std::unique_ptr, stltypes>();
}

}

}
16 changes: 16 additions & 0 deletions src/stl_valarray.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include "jlcxx/stl.hpp"

namespace jlcxx
{

namespace stl
{

void apply_valarray(TypeWrapper1& valarray)
{
valarray.apply_combination<std::valarray, stltypes>(stl::WrapValArray());
}

}

}
16 changes: 16 additions & 0 deletions src/stl_vector.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include "jlcxx/stl.hpp"

namespace jlcxx
{

namespace stl
{

void apply_vector(TypeWrapper1& vector)
{
vector.apply_combination<std::vector, stltypes>(stl::WrapVector());
}

}

}
16 changes: 16 additions & 0 deletions src/stl_weak_ptr.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include "jlcxx/stl.hpp"

namespace jlcxx
{

namespace stl
{

void apply_weak_ptr()
{
smartptr::apply_smart_combination<std::weak_ptr, stltypes>();
}

}

}

0 comments on commit 93768c1

Please sign in to comment.