gcontini
2019-11-10 1c18dbea1cbd759aaf42a7e78afe0d8781065a50
improvements for issue #42
8个文件已修改
1个文件已添加
1 文件已重命名
57 ■■■■■ 已修改文件
.gitignore 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.travis.yml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
CMakeLists.txt 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cmake/Findolm.cmake 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
projects/.gitkeep 补丁 | 查看 | 原始文档 | blame | 历史
src/library/LicenseReader.cpp 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/library/base/CMakeLists.txt 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/library/locate/ApplicationFolder.cpp 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/library/os/os.c 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/public_key.inja 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.gitignore
@@ -28,6 +28,6 @@
*.out
/Default/
product/*
!product/.gitkeep
projects/*
!projects/.gitkeep
.travis.yml
@@ -104,7 +104,7 @@
        - ./bootstrap.sh
        - travis_wait 30 ./b2 toolset=gcc-mingw target-os=windows address-model=64 --with-date_time --with-test --with-filesystem --with-program_options --with-regex --with-serialization --with-system runtime-link=static --prefix=./dist release install
        - cd ..
        - cmake -DCMAKE_TOOLCHAIN_FILE=../modules/toolchain-ubuntu-mingw64.cmake -DCMAKE_INSTALL_PREFIX=../../install -DBOOST_ROOT=$PWD/boost_1_71_0/dist  ..
        - cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchain-ubuntu-mingw64.cmake -DCMAKE_INSTALL_PREFIX=../../install -DBOOST_ROOT=$PWD/boost_1_71_0/dist  ..
   - os: windows
     name: "Widnows server 1803 - Visual Studio 15 2017 Win64 - (/MD)"
     before_script:
CMakeLists.txt
@@ -11,16 +11,16 @@
SET(CMAKE_DISABLE_SOURCE_CHANGES OFF) #keys are generated in the source tree by default
SET(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
IF(NOT LCC_PRODUCT_NAME)
    message(WARNING "You should define a variable LCC_PRODUCT_NAME containing the name of the software you want to add a license to."
IF(NOT LCC_PROJECT_NAME)
    message(WARNING "You should define a variable LCC_PROJECT_NAME containing the name of the software you want to add a license to."
        "A mock product named DEFAULT has been added for you.")
    set(LCC_PRODUCT_NAME "DEFAULT")
ENDIF(NOT LCC_PRODUCT_NAME)
    set(LCC_PROJECT_NAME "DEFAULT")
ENDIF(NOT LCC_PROJECT_NAME)
#base folder where product names are stored (/projects)
IF(NOT LCC_PRODUCTS_BASE_DIR)
    set(LCC_PRODUCTS_BASE_DIR "${CMAKE_SOURCE_DIR}/product")
ENDIF(NOT LCC_PRODUCTS_BASE_DIR)
#base folder where projects are stored (/projects)
IF(NOT LCC_PROJECTS_BASE_DIR)
    set(LCC_PROJECTS_BASE_DIR "${CMAKE_SOURCE_DIR}/projects")
ENDIF(NOT LCC_PROJECTS_BASE_DIR)
project (licensecc C CXX )
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
@@ -30,17 +30,24 @@
find_package(olm REQUIRED) 
#load the current project from files or find it from environment variables or create a default one
set(LCC_PROJECT_PUBLIC_KEY "${LCC_PRODUCTS_BASE_DIR}/${LCC_PRODUCT_NAME}/include/${PROJECT_NAME}/${LCC_PRODUCT_NAME}/public_key.h" )
set(LCC_PROJECT_PRIVATE_KEY "${LCC_PRODUCTS_BASE_DIR}/${LCC_PRODUCT_NAME}/private_key.rsa" )
set(LCC_INCLUDE_DIR "${LCC_PROJECTS_BASE_DIR}/${LCC_PROJECT_NAME}/include/${PROJECT_NAME}/${LCC_PROJECT_NAME}" )
set(LCC_PROJECT_PUBLIC_KEY "${LCC_INCLUDE_DIR}/public_key.h" )
set(LCC_PROJECT_PRIVATE_KEY "${LCC_PROJECTS_BASE_DIR}/${LCC_PROJECT_NAME}/private_key.rsa" )
add_custom_command(
  OUTPUT "${LCC_PROJECT_PUBLIC_KEY}" "${LCC_PROJECT_PRIVATE_KEY}"
  COMMAND license_generator::olm project initialize -s "${PROJECT_SOURCE_DIR}" -n "${LCC_PRODUCT_NAME}" -p "${LCC_PRODUCTS_BASE_DIR}"
  COMMAND license_generator::olm project initialize -s "${PROJECT_SOURCE_DIR}/src" -n "${LCC_PROJECT_NAME}" -p "${LCC_PROJECTS_BASE_DIR}"
  COMMENT "generating ${LCC_PROJECT_PUBLIC_KEY}"
  USES_TERMINAL
)
add_custom_target(product_initialize DEPENDS "${LCC_PROJECT_PUBLIC_KEY}" "${LCC_PROJECT_PRIVATE_KEY}")
add_custom_target(project_initialize DEPENDS "${LCC_PROJECT_PUBLIC_KEY}" "${LCC_PROJECT_PRIVATE_KEY}")
configure_file (
    "src/templates/build_properties.h.in"
    "${LCC_INCLUDE_DIR}/build_properties.h"
)
include_directories( ${LCC_INCLUDE_DIR} )
message( STATUS "C compiler        : " ${CMAKE_C_COMPILER})
message( STATUS "C compiler flags  : " ${CMAKE_C_FLAGS})
@@ -52,7 +59,8 @@
  message( STATUS "Build type        : " ${CMAKE_BUILD_TYPE})
endif(CMAKE_BUILD_TYPE)
message( STATUS "Install prefix    : " ${CMAKE_INSTALL_PREFIX})
message( STATUS "olm executable    : " ${OLM_VERSION})
message( STATUS "Project name      : " ${LCC_PROJECT_NAME} )
message( STATUS "Project base dir  : " ${LCC_PROJECTS_BASE_DIR}/${LCC_PROJECT_NAME} )
#boost is required only for tests
#bug in cmake win32 - can't find boost compiled with mingw 
@@ -70,6 +78,7 @@
SET( Boost_USE_STATIC_LIBS ON )
find_package(Boost REQUIRED COMPONENTS date_time unit_test_framework program_options system filesystem)
#set below in case of dynamic linking in debug.
#set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Debug>:BOOST_TEST_DYN_LINK>)
@@ -81,6 +90,7 @@
        MARK_AS_ADVANCED(BUILDNAME)
        add_definitions(-DBOOST_ALL_NO_LIB) #Disable Boost Microsoft magic, all dependencies are handled by cmake
        add_definitions(-DBOOST_LIB_DIAGNOSTIC) #Check it is really disabled
        include_directories(${Boost_INCLUDE_DIRS})
#        add_subdirectory(test)
    ENDIF(BUILD_TESTING)
ELSE(Boost_FOUND)
cmake/Findolm.cmake
@@ -57,6 +57,7 @@
    set_property(TARGET license_generator::olm PROPERTY IMPORTED_LOCATION ${OLM_EXECUTABLE})  
ELSE(OLM_LOCATION)
    find_package(olm REQUIRED NO_CMAKE_PATH) #try to find it without looping on this module
    message(STATUS ${olm_FOUND})
    IF(NOT olm_FOUND)     
        find_package(Git QUIET)
        if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
projects/.gitkeep
src/library/LicenseReader.cpp
@@ -22,9 +22,10 @@
#include <stdlib.h>
#include <math.h>
#include <public_key.h>
#include "pc-identifiers.h"
#include "build_properties.h"
#include "public-key.h"
#include "LicenseReader.hpp"
#include "base/StringUtils.h"
#include "base/logger.h"
@@ -207,8 +208,7 @@
string FullLicenseInfo::printForSign() const {
    ostringstream oss;
    oss << toupper_copy(trim_copy(this->product));
    oss << SHARED_RANDOM
    ;
    //oss << SHARED_RANDOM;
    if (has_client_sig) {
        oss << trim_copy(this->client_signature);
    }
src/library/base/CMakeLists.txt
@@ -6,6 +6,6 @@
    base64.c
)
add_dependencies( base product_initialize )
add_dependencies( base project_initialize )
install(TARGETS base ARCHIVE DESTINATION lib)
src/library/locate/ApplicationFolder.cpp
@@ -8,7 +8,7 @@
#include <sstream>
#include <string>
#include <build_properties.h>
//B#include <build_properties.h>
#include "../base/logger.h"
#include "../api/datatypes.h"
src/library/os/os.c
@@ -1,6 +1,6 @@
#include "os.h"
#include "../base/logger.h"
#include "public-key.h"
#include <public_key.h>
#include <stdio.h>
#ifdef __linux__
src/templates/public_key.inja
New file
@@ -0,0 +1,2 @@
#define PRODUCT_NAME {{ product_name }}
#define PUBLIC_KEY {1,2,3}