Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
**/build-*/
**/cmake-build-*/
Testing

# Auto generated files
/include/scale/definitions.hpp
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

empty line

26 changes: 18 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

cmake_minimum_required(VERSION 3.12)

if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.27")
if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.27")
cmake_policy(SET CMP0144 NEW)
endif()
endif ()

include(${CMAKE_CURRENT_LIST_DIR}/cmake/HunterGate.cmake)

Expand Down Expand Up @@ -36,11 +36,21 @@ find_package(Boost CONFIG REQUIRED)
hunter_add_package(qtils)
find_package(qtils CONFIG REQUIRED)

if (JAM_COMPATIBLE)
add_compile_definitions(JAM_COMPATIBILITY_ENABLED)
endif ()
if (CUSTOM_CONFIG_SUPPORT)
add_compile_definitions(CUSTOM_CONFIG_ENABLED)
set(DEFINITION_PATH "${CMAKE_CURRENT_SOURCE_DIR}/include/scale/definitions.hpp")
if (NOT EXISTS "${CMAKE_BINARY_DIR}/definition.d" OR NOT EXISTS "${DEFINITION_PATH}")
get_filename_component(LABEL "${CMAKE_BINARY_DIR}" NAME)
file(WRITE "${DEFINITION_PATH}.${LABEL}"
"// This header was generated by cmake (${LABEL})\n"
"// IMPORTANT: Dont modify this file manually!\n")
if (JAM_COMPATIBLE)
file(APPEND "${DEFINITION_PATH}.${LABEL}" "#define JAM_COMPATIBILITY_ENABLED\n")
endif ()
if (CUSTOM_CONFIG_SUPPORT)
file(APPEND "${DEFINITION_PATH}.${LABEL}" "#define CUSTOM_CONFIG_ENABLED\n")
endif ()
file(RENAME "${DEFINITION_PATH}.${LABEL}" "${DEFINITION_PATH}")
message(STATUS "include/scale/definitions.hpp has generated")
file(WRITE "${CMAKE_BINARY_DIR}/definition.d" "include/scale/definitions.hpp has generated")
endif ()

add_subdirectory(src)
Expand All @@ -63,7 +73,7 @@ install(TARGETS scale EXPORT scaleConfig
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FRAMEWORK DESTINATION ${CMAKE_INSTALL_PREFIX}
)
)

install(
DIRECTORY ${CMAKE_SOURCE_DIR}/include/scale
Expand Down
3 changes: 2 additions & 1 deletion include/scale/configurable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#pragma once

#include <scale/definitions.hpp>
#ifdef CUSTOM_CONFIG_ENABLED
#include <any>
#endif
Expand Down Expand Up @@ -68,4 +69,4 @@ namespace scale {
#endif
};

} // namespace scale
} // namespace scale
1 change: 1 addition & 0 deletions include/scale/scale_decoder_stream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <boost/variant.hpp>

#include <scale/bitvec.hpp>
#include <scale/definitions.hpp>
#include <scale/detail/fixed_width_integer.hpp>
#ifdef JAM_COMPATIBILITY_ENABLED
#include <scale/detail/jam_compact_integer.hpp>
Expand Down
1 change: 1 addition & 0 deletions include/scale/scale_encoder_stream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <boost/variant.hpp>

#include <scale/bitvec.hpp>
#include <scale/definitions.hpp>
#include <scale/detail/fixed_width_integer.hpp>
#ifdef JAM_COMPATIBILITY_ENABLED
#include <scale/detail/jam_compact_integer.hpp>
Expand Down
9 changes: 4 additions & 5 deletions test/scale_tune_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
* SPDX-License-Identifier: Apache-2.0
*/

#include <gtest/gtest.h>
#include <scale/scale.hpp>

#ifndef CUSTOM_CONFIG_ENABLED
#error \
"This file should not be compiled, because custom config support is not enabed"
"This file should not be compiled, because custom config support is not enabed"
#endif

#include <gtest/gtest.h>

#include <scale/scale.hpp>

using scale::ByteArray;
using scale::CompactInteger;
using scale::decode;
Expand Down
Loading