# HG changeset patch # User Sebastien Jodogne # Date 1591728620 -7200 # Node ID 100fbe9707622ad4c352b1e46e691a9d451d1ff0 # Parent 156fece692e329e600181635ff2a41e3e6c60147 DANGEROUS commit: removing HAS_EMBEDDED_RESOURCES diff -r 156fece692e3 -r 100fbe970762 CMakeLists.txt --- a/CMakeLists.txt Tue Jun 09 16:40:43 2020 +0200 +++ b/CMakeLists.txt Tue Jun 09 20:50:20 2020 +0200 @@ -26,8 +26,6 @@ set(ENABLE_WEB_SERVER ON) set(ENABLE_ZLIB ON) -set(HAS_EMBEDDED_RESOURCES ON) - ##################################################################### ## CMake parameters tunable at the command line to configure the @@ -35,6 +33,7 @@ ##################################################################### # Parameters of the build +set(STANDALONE_BUILD ON CACHE BOOL "Standalone build (all the resources are embedded, necessary for releases)") SET(BUILD_MODALITY_WORKLISTS ON CACHE BOOL "Whether to build the sample plugin to serve modality worklists") SET(BUILD_RECOVER_COMPRESSED_FILE ON CACHE BOOL "Whether to build the companion tool to recover files compressed using Orthanc") SET(BUILD_SERVE_FOLDERS ON CACHE BOOL "Whether to build the ServeFolders plugin") @@ -196,8 +195,12 @@ if (STANDALONE_BUILD) # We embed all the resources in the binaries for standalone builds - add_definitions(-DORTHANC_STANDALONE=1) + add_definitions( + -DORTHANC_HAS_EMBEDDED_RESOURCES=1 + -DORTHANC_STANDALONE=1 + ) EmbedResources( + --target=OrthancEmbeddedResources ${ORTHANC_EMBEDDED_FILES} ORTHANC_EXPLORER ${CMAKE_CURRENT_SOURCE_DIR}/OrthancExplorer ${DCMTK_DICTIONARIES} @@ -205,10 +208,12 @@ ) else() add_definitions( + -DORTHANC_HAS_EMBEDDED_RESOURCES=1 + -DORTHANC_PATH=\"${CMAKE_SOURCE_DIR}\" -DORTHANC_STANDALONE=0 - -DORTHANC_PATH=\"${CMAKE_SOURCE_DIR}\" ) EmbedResources( + --target=OrthancEmbeddedResources ${ORTHANC_EMBEDDED_FILES} ${LIBICU_RESOURCES} ) diff -r 156fece692e3 -r 100fbe970762 Core/DicomParsing/FromDcmtkBridge.cpp --- a/Core/DicomParsing/FromDcmtkBridge.cpp Tue Jun 09 16:40:43 2020 +0200 +++ b/Core/DicomParsing/FromDcmtkBridge.cpp Tue Jun 09 20:50:20 2020 +0200 @@ -103,7 +103,7 @@ #endif #if DCMTK_USE_EMBEDDED_DICTIONARIES == 1 -# include +# include #endif #if ORTHANC_ENABLE_DCMTK_JPEG == 1 @@ -171,7 +171,7 @@ namespace { - class DictionaryLocker + class DictionaryLocker : public boost::noncopyable { private: DcmDataDictionary& dictionary_; diff -r 156fece692e3 -r 100fbe970762 Core/HttpServer/EmbeddedResourceHttpHandler.h --- a/Core/HttpServer/EmbeddedResourceHttpHandler.h Tue Jun 09 16:40:43 2020 +0200 +++ b/Core/HttpServer/EmbeddedResourceHttpHandler.h Tue Jun 09 20:50:20 2020 +0200 @@ -35,7 +35,7 @@ #include "IHttpHandler.h" -#include // Autogenerated file +#include // Autogenerated file #include namespace Orthanc diff -r 156fece692e3 -r 100fbe970762 Core/Images/Font.h --- a/Core/Images/Font.h Tue Jun 09 16:40:43 2020 +0200 +++ b/Core/Images/Font.h Tue Jun 09 20:50:20 2020 +0200 @@ -41,7 +41,7 @@ #endif #if ORTHANC_HAS_EMBEDDED_RESOURCES == 1 -# include // Autogenerated file +# include // Autogenerated file #endif #include "ImageAccessor.h" diff -r 156fece692e3 -r 100fbe970762 Core/Images/FontRegistry.h --- a/Core/Images/FontRegistry.h Tue Jun 09 16:40:43 2020 +0200 +++ b/Core/Images/FontRegistry.h Tue Jun 09 20:50:20 2020 +0200 @@ -40,7 +40,7 @@ #endif #if ORTHANC_HAS_EMBEDDED_RESOURCES == 1 -# include // Autogenerated file +# include // Autogenerated file #endif namespace Orthanc diff -r 156fece692e3 -r 100fbe970762 Core/Lua/LuaContext.h --- a/Core/Lua/LuaContext.h Tue Jun 09 16:40:43 2020 +0200 +++ b/Core/Lua/LuaContext.h Tue Jun 09 20:50:20 2020 +0200 @@ -53,7 +53,7 @@ #endif #if ORTHANC_HAS_EMBEDDED_RESOURCES == 1 -# include // Autogenerated file +# include // Autogenerated file #endif #if ORTHANC_ENABLE_CURL == 1 diff -r 156fece692e3 -r 100fbe970762 Core/OrthancFramework.cpp --- a/Core/OrthancFramework.cpp Tue Jun 09 16:40:43 2020 +0200 +++ b/Core/OrthancFramework.cpp Tue Jun 09 20:50:20 2020 +0200 @@ -72,7 +72,7 @@ { Logging::Initialize(); -#if !defined(__EMSCRIPTEN__) // No global locale in wasm/asm.js +#if (ORTHANC_ENABLE_LOCALE == 1) && !defined(__EMSCRIPTEN__) // No global locale in wasm/asm.js if (locale.empty()) { Toolbox::InitializeGlobalLocale(NULL); @@ -113,7 +113,11 @@ #endif Toolbox::FinalizeOpenSsl(); + +#if (ORTHANC_ENABLE_LOCALE == 1) && !defined(__EMSCRIPTEN__) Toolbox::FinalizeGlobalLocale(); +#endif + Logging::Finalize(); } } diff -r 156fece692e3 -r 100fbe970762 Core/Toolbox.cpp --- a/Core/Toolbox.cpp Tue Jun 09 16:40:43 2020 +0200 +++ b/Core/Toolbox.cpp Tue Jun 09 20:50:20 2020 +0200 @@ -118,7 +118,7 @@ #if defined(ORTHANC_STATIC_ICU) # if (ORTHANC_STATIC_ICU == 1 && ORTHANC_ENABLE_LOCALE == 1) -# include +# include # include # include # include "Compression/GzipCompressor.h" diff -r 156fece692e3 -r 100fbe970762 OrthancServer/Database/SQLiteDatabaseWrapper.cpp --- a/OrthancServer/Database/SQLiteDatabaseWrapper.cpp Tue Jun 09 16:40:43 2020 +0200 +++ b/OrthancServer/Database/SQLiteDatabaseWrapper.cpp Tue Jun 09 20:50:20 2020 +0200 @@ -40,7 +40,7 @@ #include "../Search/ISqlLookupFormatter.h" #include "../ServerToolbox.h" -#include +#include #include #include diff -r 156fece692e3 -r 100fbe970762 OrthancServer/LuaScripting.cpp --- a/OrthancServer/LuaScripting.cpp Tue Jun 09 16:40:43 2020 +0200 +++ b/OrthancServer/LuaScripting.cpp Tue Jun 09 20:50:20 2020 +0200 @@ -42,7 +42,7 @@ #include "../Core/Logging.h" #include "../Core/Lua/LuaFunctionCall.h" -#include +#include namespace Orthanc diff -r 156fece692e3 -r 100fbe970762 OrthancServer/OrthancConfiguration.h --- a/OrthancServer/OrthancConfiguration.h Tue Jun 09 16:40:43 2020 +0200 +++ b/OrthancServer/OrthancConfiguration.h Tue Jun 09 20:50:20 2020 +0200 @@ -37,7 +37,7 @@ #include "../Core/WebServiceParameters.h" #include "../Core/DicomNetworking/RemoteModalityParameters.h" -#include +#include #include #include diff -r 156fece692e3 -r 100fbe970762 OrthancServer/ServerContext.cpp --- a/OrthancServer/ServerContext.cpp Tue Jun 09 16:40:43 2020 +0200 +++ b/OrthancServer/ServerContext.cpp Tue Jun 09 20:50:20 2020 +0200 @@ -53,7 +53,7 @@ #include "ServerToolbox.h" #include "StorageCommitmentReports.h" -#include +#include #include diff -r 156fece692e3 -r 100fbe970762 OrthancServer/ServerIndex.cpp --- a/OrthancServer/ServerIndex.cpp Tue Jun 09 16:40:43 2020 +0200 +++ b/OrthancServer/ServerIndex.cpp Tue Jun 09 20:50:20 2020 +0200 @@ -46,7 +46,7 @@ #include "Database/ResourcesContent.h" #include "DicomInstanceToStore.h" -#include "EmbeddedResources.h" +#include "OrthancEmbeddedResources.h" #include "OrthancConfiguration.h" #include "Search/DatabaseLookup.h" #include "Search/DicomTagConstraint.h" diff -r 156fece692e3 -r 100fbe970762 Resources/CMake/AutoGeneratedCode.cmake --- a/Resources/CMake/AutoGeneratedCode.cmake Tue Jun 09 16:40:43 2020 +0200 +++ b/Resources/CMake/AutoGeneratedCode.cmake Tue Jun 09 20:50:20 2020 +0200 @@ -11,6 +11,8 @@ set(DEPENDENCIES) set(IS_PATH_NAME false) + set(TARGET_BASE "${AUTOGENERATED_DIR}/EmbeddedResources") + # Loop over the arguments of the function foreach(arg ${ARGN}) # Extract the first character of the argument @@ -18,7 +20,13 @@ if (${FIRST_CHAR} STREQUAL "-") # If the argument starts with a dash "-", this is an option to # EmbedResources.py - list(APPEND SCRIPT_OPTIONS ${arg}) + if (${arg} MATCHES "--target=.*") + # Does the argument starts with "--target="? + string(SUBSTRING "${arg}" 9 -1 TARGET) # 9 is the length of "--target=" + set(TARGET_BASE "${AUTOGENERATED_DIR}/${TARGET}") + else() + list(APPEND SCRIPT_OPTIONS ${arg}) + endif() else() if (${IS_PATH_NAME}) list(APPEND SCRIPT_ARGUMENTS "${arg}") @@ -31,7 +39,6 @@ endif() endforeach() - set(TARGET_BASE "${AUTOGENERATED_DIR}/EmbeddedResources") add_custom_command( OUTPUT "${TARGET_BASE}.h" @@ -40,7 +47,7 @@ ${PYTHON_EXECUTABLE} "${ORTHANC_ROOT}/Resources/EmbedResources.py" ${SCRIPT_OPTIONS} - "${AUTOGENERATED_DIR}/EmbeddedResources" + "${TARGET_BASE}" ${SCRIPT_ARGUMENTS} DEPENDS "${ORTHANC_ROOT}/Resources/EmbedResources.py" @@ -48,6 +55,6 @@ ) list(APPEND AUTOGENERATED_SOURCES - "${AUTOGENERATED_DIR}/EmbeddedResources.cpp" + "${TARGET_BASE}.cpp" ) endmacro() diff -r 156fece692e3 -r 100fbe970762 Resources/CMake/OrthancFrameworkConfiguration.cmake --- a/Resources/CMake/OrthancFrameworkConfiguration.cmake Tue Jun 09 16:40:43 2020 +0200 +++ b/Resources/CMake/OrthancFrameworkConfiguration.cmake Tue Jun 09 20:50:20 2020 +0200 @@ -604,36 +604,6 @@ add_definitions(-DORTHANC_ENABLE_LOGGING_STDIO=0) endif() - -if (HAS_EMBEDDED_RESOURCES) - add_definitions(-DORTHANC_HAS_EMBEDDED_RESOURCES=1) - - if (ENABLE_WEB_SERVER) - list(APPEND ORTHANC_CORE_SOURCES_INTERNAL - ${ORTHANC_ROOT}/Core/HttpServer/EmbeddedResourceHttpHandler.cpp - ) - endif() - -elseif (STANDALONE_BUILD) - # No embedded resources are provided by the external project, but - # some are required by the Orthanc framework (DCMTK and ICU) - add_definitions(-DORTHANC_HAS_EMBEDDED_RESOURCES=1) - - EmbedResources( - ${DCMTK_DICTIONARIES} - ${LIBICU_RESOURCES} - ) - - list(APPEND ORTHANC_DICOM_SOURCES_DEPENDENCIES - ${AUTOGENERATED_SOURCES} - ) - -else() - # Neither the external project, nor the Orthanc framework have to - # embed external resources - add_definitions(-DORTHANC_HAS_EMBEDDED_RESOURCES=0) -endif() - ##################################################################### @@ -706,6 +676,13 @@ endif() +if (NOT ORTHANC_BUILDING_FRAMEWORK_LIBRARY) + list(APPEND ORTHANC_CORE_SOURCES_INTERNAL + ${ORTHANC_ROOT}/Core/HttpServer/EmbeddedResourceHttpHandler.cpp + ) +endif() + + set(ORTHANC_CORE_SOURCES ${ORTHANC_CORE_SOURCES_INTERNAL} ${ORTHANC_CORE_SOURCES_DEPENDENCIES} diff -r 156fece692e3 -r 100fbe970762 Resources/CMake/OrthancFrameworkParameters.cmake --- a/Resources/CMake/OrthancFrameworkParameters.cmake Tue Jun 09 16:40:43 2020 +0200 +++ b/Resources/CMake/OrthancFrameworkParameters.cmake Tue Jun 09 20:50:20 2020 +0200 @@ -27,7 +27,6 @@ # Support of static compilation set(ALLOW_DOWNLOADS OFF CACHE BOOL "Allow CMake to download packages") set(STATIC_BUILD OFF CACHE BOOL "Static build of the third-party libraries (necessary for Windows)") -set(STANDALONE_BUILD ON CACHE BOOL "Standalone build (all the resources are embedded, necessary for releases)") # Generic parameters of the build set(ENABLE_CIVETWEB ON CACHE BOOL "Use Civetweb instead of Mongoose (Mongoose was the default embedded HTTP server in Orthanc <= 1.5.1)") @@ -106,9 +105,6 @@ set(ENABLE_DCMTK_TRANSCODING OFF CACHE INTERNAL "Enable DICOM transcoding in DCMTK") set(ENABLE_OPENSSL_ENGINES OFF CACHE INTERNAL "Enable support of engines in OpenSSL") -set(HAS_EMBEDDED_RESOURCES OFF CACHE INTERNAL - "Whether resources are auto-generated using EmbedResources.py") - set(ORTHANC_SANDBOXED OFF CACHE INTERNAL "Whether Orthanc runs inside a sandboxed environment (such as Google NaCl or WebAssembly)") diff -r 156fece692e3 -r 100fbe970762 Resources/EmbedResources.py --- a/Resources/EmbedResources.py Tue Jun 09 16:40:43 2020 +0200 +++ b/Resources/EmbedResources.py Tue Jun 09 20:50:20 2020 +0200 @@ -42,7 +42,7 @@ EXCEPTION_CLASS = 'OrthancException' OUT_OF_RANGE_EXCEPTION = '::Orthanc::OrthancException(::Orthanc::ErrorCode_ParameterOutOfRange)' INEXISTENT_PATH_EXCEPTION = '::Orthanc::OrthancException(::Orthanc::ErrorCode_InexistentItem)' -NAMESPACE = 'Orthanc' +NAMESPACE = 'Orthanc.EmbeddedResources' ARGS = [] for i in range(len(sys.argv)): @@ -166,13 +166,17 @@ # pragma warning(disable: 4065) // "Switch statement contains 'default' but no 'case' labels" #endif -namespace %s -{ - namespace EmbeddedResources - { +""") + + +for ns in NAMESPACE.split('.'): + header.write('namespace %s {\n' % ns) + + +header.write(""" enum FileResourceId { -""" % NAMESPACE) +""") isFirst = True for name in resources: @@ -211,9 +215,13 @@ void GetDirectoryResource(std::string& result, DirectoryResourceId id, const char* path); void ListResources(std::list& result, DirectoryResourceId id); - } -} + """) + + +for ns in NAMESPACE.split('.'): + header.write('}\n') + header.close() @@ -279,11 +287,10 @@ #include #include -namespace %s -{ - namespace EmbeddedResources - { -""" % NAMESPACE) +""") + +for ns in NAMESPACE.split('.'): + cpp.write('namespace %s {\n' % ns) for name in resources: @@ -434,7 +441,10 @@ if (size > 0) memcpy(&result[0], GetDirectoryResourceBuffer(id, path), size); } - } -} """) + + +for ns in NAMESPACE.split('.'): + cpp.write('}\n') + cpp.close()