Skip to content

Commit

Permalink
fixup! fable: Fix excessive compilation duration
Browse files Browse the repository at this point in the history
  • Loading branch information
cassava committed Jan 10, 2024
1 parent f6aa6f5 commit 7753ea5
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
1 change: 1 addition & 0 deletions fable/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ add_library(${target}
src/fable/confable.cpp
src/fable/json.cpp
src/fable/schema.cpp
src/fable/make_schema.cpp
src/fable/schema/boolean.cpp
src/fable/schema/number.cpp
src/fable/schema/struct.cpp
Expand Down
20 changes: 20 additions & 0 deletions fable/include/fable/make_schema.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,24 @@ auto make_schema(T* ptr, P proto, std::string&& desc) {
return details::make_schema_wrapper2<T, P>::make_schema(ptr, std::move(proto), std::move(desc));
}

// Pre-Instantiate above templates for relevant datatypes

#define FABLE_TYPES() \
FABLE_TYPES_X(bool) \
FABLE_TYPES_X(int8_t) \
FABLE_TYPES_X(uint8_t) \
FABLE_TYPES_X(int16_t) \
FABLE_TYPES_X(uint16_t) \
FABLE_TYPES_X(int32_t) \
FABLE_TYPES_X(uint32_t) \
FABLE_TYPES_X(int64_t) \
FABLE_TYPES_X(uint64_t) \
FABLE_TYPES_X(float) \
FABLE_TYPES_X(double)

#define FABLE_TYPES_X(TYPE) \
extern template struct ::fable::schema::details::make_schema_wrapper1<TYPE>;

FABLE_TYPES()

} // namespace fable::schema
27 changes: 27 additions & 0 deletions fable/src/fable/make_schema.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright 2023 Robert Bosch GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <fable/make_schema.hpp>

namespace fable::schema {

#define extern
FABLE_TYPES()
#undef extern

}

0 comments on commit 7753ea5

Please sign in to comment.