Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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

27 changes: 20 additions & 7 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,24 @@ 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")
execute_process(
COMMAND sh -c "echo '/// This header was generated by cmake' > ${DEFINITION_PATH}"
COMMAND sh -c "echo '/// IMPORTANT: Dont modify this manually!' > ${DEFINITION_PATH}"
COMMAND_ERROR_IS_FATAL ANY)
if (JAM_COMPATIBLE)
execute_process(
COMMAND sh -c "echo '#define JAM_COMPATIBILITY_ENABLED' >> ${DEFINITION_PATH}"
COMMAND_ERROR_IS_FATAL ANY)
endif ()
if (CUSTOM_CONFIG_SUPPORT)
execute_process(
COMMAND sh -c "echo '#define CUSTOM_CONFIG_ENABLED' >> ${DEFINITION_PATH}"
COMMAND_ERROR_IS_FATAL ANY)
endif ()
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 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