From 098aecd638c01902209a9afb700c4ad52639ff47 Mon Sep 17 00:00:00 2001 From: Timo Heister Date: Wed, 2 Sep 2015 18:39:37 -0400 Subject: [PATCH] Implement .inst splitting in make_instantiations --- cmake/scripts/expand_instantiations.cc | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/cmake/scripts/expand_instantiations.cc b/cmake/scripts/expand_instantiations.cc index bb08ddc9f1..fdfa9a9520 100644 --- a/cmake/scripts/expand_instantiations.cc +++ b/cmake/scripts/expand_instantiations.cc @@ -376,14 +376,31 @@ void substitute (const std::string &text, expansion = expansion_lists[pattern].begin(); expansion != expansion_lists[pattern].end(); ++expansion) - std::cout << substitute_tokens (text, name, *expansion) - << std::endl; + { + // surround each block in the for loop with an if-def hack + // that allows us to split instantiation files into several + // chunks to be used in different .cc files (to reduce + // compiler memory usage). + // Just define SPLIT_INSTANTIATIONS_COUNT to a positive number (number of sections) + // to split the definitions into and SPLIT_INSTANTIATIONS_INDEX as a number + // between 0 and SPLIT_INSTANTIATIONS_COUNT-1 to get the instantiations of that + // particular chunk. + static unsigned int counter = 0; + std::cout << "#if !defined(SPLIT_INSTANTIATIONS_COUNT) || (" + << counter++ + << " % SPLIT_INSTANTIATIONS_COUNT == SPLIT_INSTANTIATIONS_INDEX)" << std::endl; + std::cout << substitute_tokens (text, name, *expansion) + << std::endl; + std::cout << "#endif" << std::endl; + } + } else { std::cout << text << std::endl; } + } -- 2.39.5