Add sources
This commit is contained in:
parent
53b0bad898
commit
27526eec80
|
@ -1,6 +1,6 @@
|
|||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
project(XeRelease_Qt5 VERSION 0.1 LANGUAGES CXX)
|
||||
project(XeRelease_Qt5 VERSION 17.0 LANGUAGES CXX)
|
||||
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
|
@ -13,10 +13,16 @@ find_package(QT NAMES Qt5 Qt6 REQUIRED COMPONENTS Widgets)
|
|||
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
|
||||
|
||||
set(PROJECT_SOURCES
|
||||
config.hh
|
||||
main.cpp
|
||||
mainwindow.cpp
|
||||
mainwindow.h
|
||||
mainwindow.ui
|
||||
xeapi.hh
|
||||
xeapi.cc
|
||||
xerelease.hh
|
||||
xerelease.cc
|
||||
json_nlohmann/json.hpp
|
||||
xe_resource.qrc
|
||||
)
|
||||
# qt_add_resources(PROJECT_SOURCES xe_resouce.qrc)
|
||||
|
@ -47,7 +53,7 @@ endif()
|
|||
target_link_libraries(XeRelease_Qt5 PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
|
||||
|
||||
set_target_properties(XeRelease_Qt5 PROPERTIES
|
||||
MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com
|
||||
MACOSX_BUNDLE_GUI_IDENTIFIER io.qt5.daleclack
|
||||
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
|
||||
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
|
||||
MACOSX_BUNDLE TRUE
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
// This header file is to get the platform and features enable/disable
|
||||
#pragma once
|
||||
|
||||
// Defining the OS
|
||||
enum class OS_Type{
|
||||
Linux,
|
||||
Darwin,
|
||||
Windows
|
||||
};
|
||||
|
||||
static inline OS_Type get_os_type(){
|
||||
#if defined(__linux__) || defined(__linux) || defined(linux) || defined(__gnu_linux__)
|
||||
// #define COMPILED_IN_LINUX
|
||||
return OS_Type::Linux;
|
||||
#elif defined(__APPLE__) && defined(__MACH__)
|
||||
// #define COMPILED_IN_Darwin
|
||||
return OS_Type::Darwin;
|
||||
#elif defined(_WIN32) || defined(_WIN64)
|
||||
// #define COMPILED_IN_WINDOWS
|
||||
return OS_Type::Windows;
|
||||
#endif
|
||||
}
|
||||
|
||||
// Enable/Disable longterm build
|
||||
// #define DISABLE_LONGTERM_BUILD
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,9 @@
|
|||
#include"xeapi.hh"
|
||||
int xeapi1(struct tm *local){
|
||||
int year1=2019,month1=6,apiver=0;
|
||||
int year2=local->tm_year+1900,month2=local->tm_mon+1;
|
||||
//printf("%d %d",year1,year2);
|
||||
apiver=(year2-year1)*12-month1+month2+22;
|
||||
//if(local->tm_mday<7) apiver--;
|
||||
return apiver;
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
#ifndef __XE_API_
|
||||
#define __XE_API_
|
||||
|
||||
#include<ctime>
|
||||
extern int xeapi1(struct tm *local);
|
||||
//This header defines a function to calculate the month from 2019.6 to now
|
||||
//The beginning is 2019.6,and the api version generated by this function >=20
|
||||
|
||||
#endif
|
|
@ -0,0 +1,190 @@
|
|||
#include <cstdio>
|
||||
#include <ctime>
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
#include "xerelease.hh"
|
||||
#include "xeapi.hh"
|
||||
|
||||
static json data1;
|
||||
|
||||
// typedef void(*LP)(struct tm *local);//define a pointer function
|
||||
|
||||
int total_day(int year, int month, int day)
|
||||
{
|
||||
// Calculate day of 1 year
|
||||
int sum = 0;
|
||||
switch (month)
|
||||
{
|
||||
case 1:
|
||||
sum = day;
|
||||
break;
|
||||
case 2:
|
||||
sum = day + 31;
|
||||
break;
|
||||
case 3:
|
||||
sum = day + 59;
|
||||
break;
|
||||
case 4:
|
||||
sum = day + 90;
|
||||
break;
|
||||
case 5:
|
||||
sum = day + 120;
|
||||
break;
|
||||
case 6:
|
||||
sum = day + 151;
|
||||
break;
|
||||
case 7:
|
||||
sum = day + 181;
|
||||
break;
|
||||
case 8:
|
||||
sum = day + 212;
|
||||
break;
|
||||
case 9:
|
||||
sum = day + 243;
|
||||
break;
|
||||
case 10:
|
||||
sum = day + 273;
|
||||
break;
|
||||
case 11:
|
||||
sum = day + 304;
|
||||
break;
|
||||
case 12:
|
||||
sum = day + 334;
|
||||
break;
|
||||
default:
|
||||
printf("Date Wrong!");
|
||||
}
|
||||
if (year % 4 == 0 && year % 100 != 0)
|
||||
sum = sum + 1;
|
||||
return sum;
|
||||
}
|
||||
|
||||
int total_year_day(int year1, int year2)
|
||||
{
|
||||
// Calculate day of years
|
||||
int sum = 0;
|
||||
sum = (year2 - year1) * 365;
|
||||
for (int i = year1; i < year2; i++)
|
||||
{
|
||||
if (i % 4 == 0 && i % 100 != 0)
|
||||
{
|
||||
sum = sum + 1;
|
||||
}
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
static void path_translate(char *result, const char *version)
|
||||
{
|
||||
if (!data1.empty())
|
||||
{
|
||||
// Just combine the release file path and filename
|
||||
std::string path;
|
||||
switch (get_os_type())
|
||||
{
|
||||
case OS_Type::Linux:
|
||||
path = data1["Release_Path_Unix"];
|
||||
snprintf(result, 57, "%s/xe-%c.x", path.c_str(), version[0]);
|
||||
break;
|
||||
case OS_Type::Darwin:
|
||||
path = data1["Release_Path_Darwin"];
|
||||
snprintf(result, 57, "%s/xe-%c.x", path.c_str(), version[0]);
|
||||
break;
|
||||
case OS_Type::Windows:
|
||||
path = data1["Release_Path_Win32"];
|
||||
snprintf(result, 57, "%s\\xe-%c.x", path.c_str(), version[0]);
|
||||
break;
|
||||
}
|
||||
// if (rel_unix_file_system_detected())
|
||||
// {
|
||||
// path = data1["Release_Path_Unix"];
|
||||
// sprintf(result, "%s/xe-%c.x", path.c_str(), version[0]);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// path = data1["Release_Path_Win32"];
|
||||
// sprintf(result, "%s\\xe-%c.x", path.c_str(), version[0]);
|
||||
// }
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf(result, 57, "./xe-%c.x", version[0]);
|
||||
}
|
||||
}
|
||||
|
||||
void dale(struct tm *local)
|
||||
{
|
||||
printf("xeinit release maker by dale\n");
|
||||
}
|
||||
|
||||
void longterm(struct tm *local, const char *lts, char *str)
|
||||
{
|
||||
// Print Version of longterm release in the file
|
||||
char filename[57];
|
||||
path_translate(filename, lts);
|
||||
// sprintf(filename, "xe-%c.x", lts[0]);
|
||||
int lts_ver = 0; // default release version
|
||||
int year1 = 2019, month1 = 1, day1 = 11, year2 = local->tm_year + 1900,
|
||||
month2 = local->tm_mon + 1, day2 = local->tm_mday;
|
||||
// get release version
|
||||
lts_ver = total_year_day(year1, year2) - total_day(year1, month1, day1) +
|
||||
total_day(year2, month2, day2);
|
||||
// For show in dialog or console
|
||||
snprintf(str, 57, "Xeinit LTS version:%s.%d\n", lts, lts_ver);
|
||||
freopen(filename, "a", stdout);
|
||||
// put all output in the release file
|
||||
// output:release branch time in xe-release
|
||||
printf("%4d-%02d-%02d ", local->tm_year + 1900, local->tm_mon + 1, local->tm_mday);
|
||||
printf("%s.%d Api:%d\n", lts, lts_ver, xeapi1(local));
|
||||
fclose(stdout);
|
||||
return;
|
||||
}
|
||||
|
||||
void stable(struct tm *local, const char *rel, char *str)
|
||||
{
|
||||
// Print Version of stable release in the file
|
||||
char filename[57];
|
||||
path_translate(filename, rel);
|
||||
// sprintf(filename, "xe-%c.x", rel[0]);
|
||||
int devel1; // stable release version
|
||||
int year1 = 2017, month1 = 5, day1 = 19, year2 = local->tm_year + 1900,
|
||||
month2 = local->tm_mon + 1, day2 = local->tm_mday;
|
||||
// get release version
|
||||
devel1 = total_year_day(year1, year2) - total_day(year1, month1, day1) +
|
||||
total_day(year2, month2, day2);
|
||||
snprintf(str, 57, "Xeinit stable Version:%s.%d\n", rel, devel1);
|
||||
freopen(filename, "a", stdout);
|
||||
// put all output in the release file
|
||||
// output:development branch time in xe-release
|
||||
printf("%4d-%02d-%02d ", local->tm_year + 1900, local->tm_mon + 1, local->tm_mday);
|
||||
printf("%s.%d build:%d\n", rel, devel1, xeapi1(local));
|
||||
fclose(stdout);
|
||||
return;
|
||||
}
|
||||
|
||||
void develop(struct tm *local, const char *devel, char *str)
|
||||
{
|
||||
// Print Version of develop release in the file
|
||||
char filename[57];
|
||||
path_translate(filename, devel);
|
||||
// sprintf(filename, "xe-%c.x", devel[0]);
|
||||
int devel1; // development version
|
||||
int year1 = 2017, month1 = 5, day1 = 19, year2 = local->tm_year + 1900,
|
||||
month2 = local->tm_mon + 1, day2 = local->tm_mday;
|
||||
// get release version
|
||||
devel1 = total_year_day(year1, year2) - total_day(year1, month1, day1) +
|
||||
total_day(year2, month2, day2);
|
||||
snprintf(str, 57, "Xeinit devel Version:%s.%d\n", devel, devel1);
|
||||
freopen(filename, "a", stdout);
|
||||
// put all output in the release file
|
||||
// output:development branch time in xe-release
|
||||
printf("%4d-%02d-%02d ", local->tm_year + 1900, local->tm_mon + 1, local->tm_mday);
|
||||
printf("%s.%d build:%d\n", devel, devel1, xeapi1(local));
|
||||
fclose(stdout);
|
||||
return;
|
||||
}
|
||||
|
||||
void json_config_init(json &user_data)
|
||||
{
|
||||
data1 = user_data;
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
#ifndef __XE_RELEASE_
|
||||
#define __XE_RELEASE_
|
||||
|
||||
#include "json_nlohmann/json.hpp"
|
||||
#include "config.hh"
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
int total_day(int year,int month,int day);
|
||||
|
||||
int total_year_day(int year1,int year2);
|
||||
|
||||
void dale(struct tm *local);
|
||||
|
||||
void json_config_init(json &user_data);
|
||||
|
||||
void longterm(struct tm *local,const char * lts,char *str);
|
||||
|
||||
void stable(struct tm *local,const char * rel,char *str);
|
||||
|
||||
void develop(struct tm *local,const char * devel,char *str);
|
||||
|
||||
// static inline bool rel_unix_file_system_detected(){
|
||||
// #ifdef _WIN32
|
||||
// return false;
|
||||
// #else
|
||||
// return true;
|
||||
// #endif
|
||||
// }
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue