Verified Commit ff6bd43a authored by RobLoach's avatar RobLoach
Browse files

Add Semantic Versioining checks

parent 68f033e3
......@@ -4,10 +4,15 @@ All notable changes to [ChaiLove](https://github.com/RobLoach/ChaiLove) will be
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## 0.17.1 - Unreleased
## 0.18.0 - Unreleased
### Added
- [Semantic Versioning](https://semver.org/) checks
- Use `t.version = 0.18.0` in `def load(t) {}` to specify which ChaiLove version you're targeting
### Fixed
- Documentation
## 0.17.0 - 2018-03-18
### Added
- `love.system.getOS()` now returns actual operating system name
......
......@@ -9,6 +9,10 @@ SOURCES_CXX += $(wildcard \
test/native/*.cpp \
)
# semver
FLAGS += -Ivendor/semver
SOURCES_C += vendor/semver/semver.c
# random
FLAGS += -Ivendor/random/include
......
......@@ -23,7 +23,7 @@ PROJECT_NAME = "ChaiLove API"
# This could be handy for archiving the generated documentation or
# if some version control system is used.
PROJECT_NUMBER = "0.17.0"
PROJECT_NUMBER = "0.18.0"
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
# base path where the generated documentation will be put.
......
......@@ -45,6 +45,7 @@ bool ChaiLove::load(const std::string& file) {
// Initialize the scripting system.
script = new love::script(file);
script->conf(config);
system.load(config);
// Testing.
#ifdef __HAVE_TESTS__
......
......@@ -71,9 +71,9 @@
#define SRC_CHAILOVE_H_
#define CHAILOVE_VERSION_MAJOR 0
#define CHAILOVE_VERSION_MINOR 17
#define CHAILOVE_VERSION_MINOR 18
#define CHAILOVE_VERSION_PATCH 0
#define CHAILOVE_VERSION_STRING "0.17.0"
#define CHAILOVE_VERSION_STRING "0.18.0"
#include "SDL.h"
#include "libretro.h"
......
......@@ -2,6 +2,8 @@
#include "../ChaiLove.h"
#include <string>
#include <iostream>
#include "semver.h"
namespace love {
......@@ -52,4 +54,41 @@ std::string system::getVersionString() {
return CHAILOVE_VERSION_STRING;
}
bool system::load(config& t) {
semver_t current = {};
semver_t compare = {};
if (semver_parse(getVersionString().c_str(), &current)
|| semver_parse(t.version.c_str(), &compare)) {
std::cout << "[ChaiLove] [system] Error - Invalid version string: " << t.version << std::endl;
return false;
}
std::cout << "[ChaiLove] [system] Version desired: " << t.version << std::endl;
int resolution = semver_compare(compare, current);
if (resolution == 0) {
std::cout << "[ChaiLove] [system] Version " << t.version << " == " << getVersionString() << std::endl;
} else if (resolution == -1) {
std::cout << "[ChaiLove] [system] Version " << t.version << " < " << getVersionString() << std::endl;
} else {
std::cout << "[ChaiLove] [system] Version " << t.version << " > " << getVersionString() << std::endl;
}
resolution = semver_satisfies(compare, current, "~");
if (resolution == 1) {
std::cout << "[ChaiLove] [system] Version " << t.version << " ~= " << getVersionString() << std::endl;
} else {
std::cout << "[ChaiLove] [system] Version " << t.version << " !~= " << getVersionString() << std::endl;
}
resolution = semver_satisfies(compare, current, "^");
if (resolution == 1) {
std::cout << "[ChaiLove] [system] Version " << t.version << " ^= " << getVersionString() << std::endl;
} else {
std::cout << "[ChaiLove] [system] Version " << t.version << " !^= " << getVersionString() << std::endl;
}
return true;
}
} // namespace love
......@@ -3,6 +3,7 @@
#include <vector>
#include <string>
#include "config.h"
namespace love {
/**
......@@ -34,6 +35,8 @@ class system {
* @see love.system.getVersion
*/
std::string getVersionString();
bool load(config& t);
};
} // namespace love
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment