logic: Test License is valid on day 0

* License was invalid on expire date
* build script does not start app after failing build
* symlink on linux
This commit is contained in:
Andreas Stallinger
2016-03-30 15:49:08 +02:00
parent fe74dfb7cc
commit 03901e8173
19 changed files with 104 additions and 78 deletions
+1
View File
@@ -42,6 +42,7 @@
.ycm_extra_conf.pyc
compile_commands.json
Makefile
/__pycache__/
/deployment/windows/CoatiAppSetup/CoatiSetup/Debug
/deployment/windows/CoatiAppSetup/CoatiSetup/Release
+7 -2
View File
@@ -3,11 +3,16 @@
# Determine path to script
MY_PATH=`dirname "$0"`
# build target
$MY_PATH/buildonly.sh $@
if [ $? -ne 0 ]
then
exit 1;
fi
cd $MY_PATH/..
# Build and run target
# run target
if [ "$1" = "release" ] || [ "$1" = "r" ]
then
@@ -38,7 +43,7 @@ then
elif [ "$2" = "keygen" ]
then
#echo "debug keygen"
cd bin/license_generator && Debug/Coati_license_generator_d
cd bin/license_generator && Debug/Coati_license_generator
else
#echo "debug app"
cd bin/app && Debug/Coati
+5 -2
View File
@@ -55,8 +55,11 @@ if [ $PLATFORM == "Windows" ]; then
cmd //c 'mklink /d /j '.$MY_PATH.'\..\bin\app\Release\user '.$MY_PATH.'\..\bin\app\user' &
elif [ $PLATFORM == "Linux" ]; then
echo -e $INFO "create symbolic links for data"
ln -sr bin/app/data bin/app/Release/data
ln -sr bin/app/data bin/app/Debug/data
cd bin/app/Release
ln -s ../data data
cd ../Debug
ln -s ../data data
cd ../../..
fi
# Setup both Debug and Release configuration
+2 -7
View File
@@ -6,15 +6,10 @@ add_files(
utility/commandline/CommandLineParser.cpp
utility/commandline/CommandLineParser.h
utility/headerSearch/ClangDetector.cpp
utility/headerSearch/ClangDetector.h
utility/headerSearch/CompilerDetectorBase.cpp
utility/headerSearch/CompilerDetectorBase.h
utility/headerSearch/CompilerDetector.cpp
utility/headerSearch/CompilerDetector.h
utility/headerSearch/DetectorBase.cpp
utility/headerSearch/DetectorBase.h
utility/headerSearch/DetectorProxy.h
utility/headerSearch/GCCDetector.cpp
utility/headerSearch/GCCDetector.h
utility/headerSearch/StandardHeaderDetection.cpp
utility/headerSearch/StandardHeaderDetection.h
utility/headerSearch/VisualStudioDetector.cpp
@@ -1,7 +0,0 @@
#ifndef CLANG_DETECTOR_H
#define CLANG_DETECTOR_H
#endif /* end of include guard: CLANG_DETECTOR_H */
@@ -1,9 +1,18 @@
#include "utility/headerSearch/CompilerDetectorBase.h"
#include "utility/headerSearch/CompilerDetector.h"
#include "utility/utilityApp.h"
#include "utility/utilityString.h"
std::vector<FilePath> CompilerDetectorBase::getStandardHeaderPaths()
CompilerDetector::CompilerDetector(const std::string& name)
: DetectorBase(name)
{
}
CompilerDetector::~CompilerDetector()
{
}
std::vector<FilePath> CompilerDetector::getStandardHeaderPaths()
{
std::string command = m_name + " -x c++ -v -E /dev/null";
std::string clangOutput = utility::executeProcess(command.c_str());
@@ -0,0 +1,20 @@
#ifndef COMPILER_DETECTOR_H
#define COMPILER_DETECTOR_H
#include "utility/headerSearch/DetectorBase.h"
#include "utility/headerSearch/StandardHeaderDetection.h"
class CompilerDetector : public DetectorBase
{
public:
CompilerDetector(const std::string& name);
virtual ~CompilerDetector();
virtual std::vector<FilePath> getStandardHeaderPaths();
private:
};
static StandardHeaderDetection::Add<CompilerDetector> gcc("gcc");
static StandardHeaderDetection::Add<CompilerDetector> clang("clang");
static StandardHeaderDetection::Add<CompilerDetector> fakecomplier("fakecompiler");
#endif // COMPILER_DETECTOR_H
@@ -1,13 +0,0 @@
#ifndef COMPILER_DETECTOR_BASE_H
#define COMPILER_DETECTOR_BASE_H
#include "utility/headerSearch/DetectorBase.h"
class CompilerDetectorBase : public DetectorBase
{
public:
virtual std::vector<FilePath> getStandardHeaderPaths();
private:
};
#endif // COMPILER_DETECTOR_BASE_H
@@ -2,6 +2,11 @@
#include <iostream>
DetectorBase::DetectorBase(const std::string name)
{
setName(name);
}
bool DetectorBase::detect()
{
return !getStandardHeaderPaths().empty();
@@ -14,10 +19,8 @@ std::string DetectorBase::getName() const
void DetectorBase::setName(const std::string& name)
{
std::cout << "setName()" << std::endl;
if (!name.empty())
{
std::cout << "name set to " << name << std::endl;
m_name = name;
}
}
@@ -7,6 +7,7 @@
class DetectorBase
{
public:
DetectorBase(const std::string name);
virtual ~DetectorBase(){};
virtual bool detect();
virtual std::vector<FilePath> getStandardHeaderPaths() = 0;
@@ -1,16 +0,0 @@
#include "utility/headerSearch/GCCDetector.h"
#include "utility/headerSearch/StandardHeaderDetection.h"
GCCDetector::GCCDetector()
{
}
GCCDetector::~GCCDetector()
{
}
static StandardHeaderDetection::Add<GCCDetector> gcc("gcc");
static StandardHeaderDetection::Add<GCCDetector> clang("clang");
static StandardHeaderDetection::Add<GCCDetector> fakecomplier("fakecompiler");
@@ -1,15 +0,0 @@
#ifndef GCC_DETECTOR_H
#define GCC_DETECTOR_H
#include "utility/headerSearch/CompilerDetectorBase.h"
class GCCDetector : public CompilerDetectorBase
{
public:
GCCDetector ();
virtual ~GCCDetector ();
private:
};
#endif // GCC_DETECTOR_H
@@ -12,6 +12,13 @@
#include "utility/utilityApp.h"
#include "utility/utilityString.h"
#include "clang/Driver/ToolChain.h"
#include "clang/Driver/Options.h"
#include "clang/Driver/Tool.h"
#include "clang/Driver/DriverDiagnostic.h"
typedef std::pair<std::string, std::shared_ptr<DetectorBase>> DetectorPair;
DetectorMap* StandardHeaderDetection::s_availableDetectors;
StandardHeaderDetection::StandardHeaderDetection()
@@ -29,7 +36,7 @@ StandardHeaderDetection::~StandardHeaderDetection()
void StandardHeaderDetection::detectHeaders()
{
for ( std::pair<std::string, std::shared_ptr<DetectorBase>> detector : *s_availableDetectors)
for ( DetectorPair detector : *s_availableDetectors)
{
if ( detector.second->detect() )
{
@@ -41,7 +48,7 @@ void StandardHeaderDetection::detectHeaders()
std::vector<std::string> StandardHeaderDetection::getDetectedCompilers()
{
std::vector<std::string> v;
for ( std::pair<std::string, std::shared_ptr<DetectorBase>> detector : m_detectedCompilers)
for ( DetectorPair detector : m_detectedCompilers)
{
v.push_back(detector.first);
}
@@ -72,7 +79,7 @@ void StandardHeaderDetection::printAvailableDetectors()
{
std::cout << "printAvailableDetectors: " << std::endl;
for ( std::pair<std::string, std::shared_ptr<DetectorBase>> detector : *s_availableDetectors)
for ( DetectorPair detector : *s_availableDetectors)
{
std::cout << detector.first << std::endl;
}
@@ -33,11 +33,7 @@ public:
public:
Add(const std::string& name)
{
std::shared_ptr<DetectorBase> detector = std::shared_ptr<U>(new U());
if (!name.empty())
{
detector->setName(name);
}
std::shared_ptr<DetectorBase> detector = std::shared_ptr<U>(new U(name));
if (!s_availableDetectors)
{
s_availableDetectors = new DetectorMap();
@@ -7,11 +7,21 @@
#include "utility/logging/logging.h"
#include "utility/headerSearch/StandardHeaderDetection.h"
VisualStudioDetector::VisualStudioDetector(const std::string name)
: DetectorBase(name)
{
}
VisualStudioDetector::~VisualStudioDetector()
{
}
std::string VisualStudioDetector::getFullName()
{
}
std::vector<FilePath> VisualStudioDetector::getStandardHeaderPaths()
{
QSettings registry;
@@ -30,6 +40,24 @@ std::vector<FilePath> VisualStudioDetector::getStandardHeaderPaths()
return path;
}
std::string getInstallDir(const std::string RegistryKey)
{
return "";
}
bool searchForExpress()
{
return false;
}
bool searchForStandard()
{
return false;
}
// Add Visual Studio Version to the available detectors
static StandardHeaderDetection::Add<VisualStudioDetector> vs2015("VS140");
static StandardHeaderDetection::Add<VisualStudioDetector> vs2013("VS120");
@@ -9,8 +9,12 @@ class FilePath;
class VisualStudioDetector : public DetectorBase
{
public:
VisualStudioDetector(const std::string name = "VS140");
virtual ~VisualStudioDetector();
virtual std::vector<FilePath> getStandardHeaderPaths();
private:
std::string getFullName();
};
#endif // VISUAL_STUDIO_DETECTOR_H
+7 -3
View File
@@ -80,11 +80,11 @@ int License::getTimeLeft() const
);
boost::gregorian::date today = boost::gregorian::day_clock::local_day();
boost::gregorian::days daysLeft = expireDate - today;
return (daysLeft.days() < 0 ? 0 : daysLeft.days());
return (daysLeft.days() < 0 ? -1 : daysLeft.days());
}
else
{
return -1;
return -2;
}
}
@@ -231,6 +231,10 @@ bool License::isValid() const
}
const bool ok = verifier.check_signature(sig);
if (isExpired())
{
return false;
}
return ok;
}
catch(...)
@@ -242,7 +246,7 @@ bool License::isValid() const
bool License::isExpired() const
{
return !getTimeLeft();
return (getTimeLeft()==-1);
}
std::string License::getPublicKeyFilename() const
+2 -1
View File
@@ -28,7 +28,8 @@ public:
std::string getPublicKeyFilename() const;
std::string getVersion() const;
/// if Test License return >=0 else -1
/// if Test License return >=0 or -1 if expired
/// for non Test License -2
int getTimeLeft() const;
void create(