Update:Allow custom path of release
This commit is contained in:
parent
117ecf438b
commit
feb85700c9
|
@ -24,6 +24,27 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "(gdb) 启动(win32)",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/builddir_win32/XeRelease.exe",
|
||||
"args": [],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "${fileDirname}",
|
||||
"environment": [],
|
||||
"externalConsole": false,
|
||||
"preLaunchTask": "Meson: Build target",
|
||||
"MIMode": "gdb",
|
||||
"setupCommands": [
|
||||
{
|
||||
"description": "为 gdb 启用整齐打印",
|
||||
"text": "-enable-pretty-printing",
|
||||
"ignoreFailures": true
|
||||
}
|
||||
],
|
||||
"miDebuggerPath": "D:/msys64/mingw64/bin/gdb.exe"
|
||||
},
|
||||
{
|
||||
"name": "(lldb) 启动",
|
||||
"type": "cppdbg",
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"tasks": [
|
||||
{
|
||||
"type": "meson",
|
||||
"target": "XeRelease",
|
||||
//"target": "XeRelease",
|
||||
"mode": "build",
|
||||
"group": "build",
|
||||
"problemMatcher": [],
|
||||
|
|
|
@ -15,6 +15,19 @@
|
|||
<object class="GtkButtonBox">
|
||||
<property name="can-focus">False</property>
|
||||
<property name="layout-style">end</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="btnpath">
|
||||
<property name="label" translatable="yes">Custom Path</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="btn_ok">
|
||||
<property name="label" translatable="yes">OK</property>
|
||||
|
@ -25,7 +38,7 @@
|
|||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
|
@ -38,7 +51,7 @@
|
|||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
|
@ -72,7 +85,7 @@
|
|||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<!-- n-columns=2 n-rows=3 -->
|
||||
<!-- n-columns=2 n-rows=4 -->
|
||||
<object class="GtkGrid">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
|
@ -157,6 +170,29 @@
|
|||
<property name="top-attach">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="halign">end</property>
|
||||
<property name="label" translatable="yes">Path:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkEntry" id="entry_path">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="text" translatable="yes">./</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
|
|
|
@ -11,6 +11,9 @@ ref_Glade(ref_builder)
|
|||
ref_builder->get_widget("entry_lts",entry_lts);
|
||||
ref_builder->get_widget("entry_stable",entry_stable);
|
||||
ref_builder->get_widget("entry_dev",entry_dev);
|
||||
ref_builder->get_widget("entry_path",entry_path);
|
||||
ref_builder->get_widget("btnpath",btnpath);
|
||||
|
||||
//Read Configs
|
||||
std::string config;
|
||||
if(readCfgFile("xe_config","Longterm",config)){
|
||||
|
@ -22,6 +25,18 @@ ref_Glade(ref_builder)
|
|||
if(readCfgFile("xe_config","Develop",config)){
|
||||
entry_dev->set_text(config);
|
||||
}
|
||||
readCfgFile("xe_config","Release_Path_Unix",config_unix);
|
||||
readCfgFile("xe_config","Release_Path_Win32",config_win32);
|
||||
|
||||
//Use different path for Linux filesystem and Windows
|
||||
if(unix_file_system_detected()){
|
||||
entry_path->set_text(config_unix);
|
||||
}else{
|
||||
entry_path->set_text(config_win32);
|
||||
}
|
||||
|
||||
//Connect Signal
|
||||
btnpath->signal_clicked().connect(sigc::mem_fun(*this,&MyDialog::btnpath_clicked));
|
||||
}
|
||||
|
||||
void MyDialog::on_response(int response_id){
|
||||
|
@ -29,7 +44,22 @@ void MyDialog::on_response(int response_id){
|
|||
if(response_id == Gtk::RESPONSE_OK){
|
||||
Glib::ustring config;
|
||||
std::fstream outfile;
|
||||
//Initalize Config for path
|
||||
if(unix_file_system_detected()){
|
||||
config_unix = entry_path->get_text();
|
||||
}else{
|
||||
config_win32 = entry_path->get_text();
|
||||
}
|
||||
//Open the config file
|
||||
outfile.open("xe_config",std::ios_base::out);
|
||||
/*OutPut contents to the file
|
||||
Simple Contents of xe_config:
|
||||
Longterm=x.x
|
||||
Stable=x.x
|
||||
Develop=x.x
|
||||
Release_Path_Unix=/xxx/xxx
|
||||
Release_Path_Win32=X:\xxx\xxx
|
||||
*/
|
||||
if(outfile.is_open()){
|
||||
outfile<<"This is the config file of Xe Release"<<std::endl;
|
||||
outfile<<"See more on github.com/daleclack/Xe-Release"<<std::endl;
|
||||
|
@ -40,6 +70,8 @@ void MyDialog::on_response(int response_id){
|
|||
outfile<<"Stable="<<config<<std::endl;
|
||||
config=entry_dev->get_text();
|
||||
outfile<<"Develop="<<config<<std::endl;
|
||||
outfile<<"Release_Path_Unix="<<config_unix<<std::endl;
|
||||
outfile<<"Release_Path_Win32="<<config_win32<<std::endl;
|
||||
}
|
||||
outfile.close();
|
||||
}
|
||||
|
@ -57,6 +89,24 @@ MyDialog * MyDialog::create(Gtk::Window& parent){
|
|||
return dialog;
|
||||
}
|
||||
|
||||
void MyDialog::btnpath_clicked(){
|
||||
//Create a Dialog
|
||||
dialog = Gtk::FileChooserNative::create("Select a folder",*this,
|
||||
Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER,"OK","Cancel");
|
||||
|
||||
dialog->signal_response().connect(sigc::mem_fun(*this,&MyDialog::dialog_response));
|
||||
|
||||
dialog->show();
|
||||
}
|
||||
|
||||
void MyDialog::dialog_response(int response_id){
|
||||
if(response_id == Gtk::RESPONSE_ACCEPT){
|
||||
Glib::ustring path = dialog->get_filename();
|
||||
entry_path->set_text(path);
|
||||
}
|
||||
dialog.reset();
|
||||
}
|
||||
|
||||
MsgBox::MsgBox(Gtk::Window &parent)
|
||||
:hbox(Gtk::ORIENTATION_HORIZONTAL,5)
|
||||
{
|
||||
|
|
|
@ -12,7 +12,17 @@ protected:
|
|||
void on_response(int response_id) override;
|
||||
private:
|
||||
Glib::RefPtr<Gtk::Builder> ref_Glade;
|
||||
Gtk::Entry * entry_lts,* entry_stable,* entry_dev;
|
||||
//Child widgets
|
||||
Gtk::Entry * entry_lts,* entry_stable,* entry_dev,* entry_path;
|
||||
Gtk::Button * btnpath;
|
||||
|
||||
//Strings to store path on Windows and Unix-Like systems
|
||||
std::string config_win32,config_unix;
|
||||
|
||||
//Signal Handlers
|
||||
Glib::RefPtr<Gtk::FileChooserNative> dialog;
|
||||
void btnpath_clicked();
|
||||
void dialog_response(int response_id);
|
||||
};
|
||||
|
||||
class MsgBox : public Gtk::Dialog{
|
||||
|
@ -28,3 +38,11 @@ private:
|
|||
Gtk::Label msg_label;
|
||||
Gtk::Box *vbox,hbox;
|
||||
};
|
||||
|
||||
static inline bool unix_file_system_detected(){
|
||||
#ifdef _WIN32
|
||||
return false;
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ msg_dialog(*this)
|
|||
|
||||
void MyWin::titlebar_init(){
|
||||
//Add HeaderBar
|
||||
header.set_title("Xe Release 13");
|
||||
header.set_title("Xe Release 14");
|
||||
header.set_show_close_button();
|
||||
header.set_decoration_layout("close,minimize:menu");
|
||||
set_titlebar(header);
|
||||
|
@ -162,7 +162,7 @@ void MyWin::main_releases(){
|
|||
|
||||
void MyWin::about_dialog(){
|
||||
char *version;
|
||||
version=g_strdup_printf("13.0\nRunning Against Gtkmm %d.%d.%d",
|
||||
version=g_strdup_printf("14.0\nRunning Against Gtkmm %d.%d.%d",
|
||||
GTKMM_MAJOR_VERSION,
|
||||
GTKMM_MINOR_VERSION,
|
||||
GTKMM_MICRO_VERSION);
|
||||
|
|
|
@ -1,103 +1,164 @@
|
|||
#include<cstdio>
|
||||
#include<ctime>
|
||||
#include<cstring>
|
||||
#include<cstdlib>
|
||||
#include"xeapi.hh"
|
||||
#include <cstdio>
|
||||
#include <ctime>
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
#include "xerelease.hh"
|
||||
#include "xeapi.hh"
|
||||
#include "cfgfile2/cfgfile.hh"
|
||||
|
||||
//typedef void(*LP)(struct tm *local);//define a pointer function
|
||||
// typedef void(*LP)(struct tm *local);//define a pointer function
|
||||
|
||||
int total_day(int year,int month,int day)
|
||||
int total_day(int year, int month, int day)
|
||||
{
|
||||
//Calculate day of 1 year
|
||||
int sum=0;
|
||||
switch(month){
|
||||
// Calculate day of 1 year
|
||||
int sum = 0;
|
||||
switch (month)
|
||||
{
|
||||
case 1:
|
||||
sum=day;break;
|
||||
sum = day;
|
||||
break;
|
||||
case 2:
|
||||
sum=day+31;break;
|
||||
sum = day + 31;
|
||||
break;
|
||||
case 3:
|
||||
sum=day+59;break;
|
||||
sum = day + 59;
|
||||
break;
|
||||
case 4:
|
||||
sum=day+90;break;
|
||||
sum = day + 90;
|
||||
break;
|
||||
case 5:
|
||||
sum=day+120;break;
|
||||
sum = day + 120;
|
||||
break;
|
||||
case 6:
|
||||
sum=day+151;break;
|
||||
sum = day + 151;
|
||||
break;
|
||||
case 7:
|
||||
sum=day+181;break;
|
||||
sum = day + 181;
|
||||
break;
|
||||
case 8:
|
||||
sum=day+212;break;
|
||||
sum = day + 212;
|
||||
break;
|
||||
case 9:
|
||||
sum=day+243;break;
|
||||
sum = day + 243;
|
||||
break;
|
||||
case 10:
|
||||
sum=day+273;break;
|
||||
sum = day + 273;
|
||||
break;
|
||||
case 11:
|
||||
sum=day+304;break;
|
||||
sum = day + 304;
|
||||
break;
|
||||
case 12:
|
||||
sum=day+334;break;
|
||||
sum = day + 334;
|
||||
break;
|
||||
default:
|
||||
printf("Date Wrong!");
|
||||
}
|
||||
if(year%4==0&&year%100!=0) sum=sum+1;
|
||||
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;
|
||||
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)
|
||||
{
|
||||
// Just combine the release file path and filename
|
||||
std::string path;
|
||||
if (rel_unix_file_system_detected())
|
||||
{
|
||||
if(readCfgFile("xe_config","Release_Path_Unix",path)){
|
||||
sprintf(result, "%s/xe-%c.x", path.c_str(), version[0]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(readCfgFile("xe_config","Release_Path_Win32",path)){
|
||||
sprintf(result, "%s\\xe-%c.x", path.c_str(), version[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void dale(struct tm *local)
|
||||
{
|
||||
printf("xeinit release maker by dale\n");
|
||||
}
|
||||
|
||||
void longterm(struct tm *local,const char * lts,char *str)
|
||||
void longterm(struct tm *local, const char *lts, char *str)
|
||||
{
|
||||
// Print Version of longterm release in the file
|
||||
char filename[57];
|
||||
sprintf(filename,"xe-%c.x",lts[0]);
|
||||
int lts_ver=0;//release version
|
||||
int year1=2019,month1=1,day1=11,year2=local->tm_year+1900,month2=local->tm_mon+1,day2=local->tm_mday;
|
||||
lts_ver=total_year_day(year1,year2)-total_day(year1,month1,day1)+total_day(year2,month2,day2);//get release version
|
||||
sprintf(str,"Xeinit LTS version:%s.%d\n",lts,lts_ver);
|
||||
freopen(filename,"a",stdout);//put all output in xe-release file
|
||||
printf("%4d-%02d-%02d ",local->tm_year+1900,local->tm_mon+1,local->tm_mday);//output:release branch time in xe-release
|
||||
printf("%s.%d Api:%d\n",lts,lts_ver,xeapi1(local));
|
||||
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
|
||||
sprintf(str, "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 ;
|
||||
return;
|
||||
}
|
||||
|
||||
void stable(struct tm *local,const char * rel,char *str)
|
||||
void stable(struct tm *local, const char *rel, char *str)
|
||||
{
|
||||
// Print Version of stable release in the file
|
||||
char filename[57];
|
||||
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;
|
||||
devel1=total_year_day(year1,year2)-total_day(year1,month1,day1)+total_day(year2,month2,day2);//get release version
|
||||
sprintf(str,"Xeinit stable Version:%s.%d\n",rel,devel1);
|
||||
freopen(filename,"a",stdout);
|
||||
printf("%4d-%02d-%02d ",local->tm_year+1900,local->tm_mon+1,local->tm_mday);//output:development branch time in xe-release
|
||||
printf("%s.%d build:%d\n",rel,devel1,xeapi1(local));
|
||||
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);
|
||||
sprintf(str, "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 ;
|
||||
return;
|
||||
}
|
||||
|
||||
void develop(struct tm *local,const char * devel,char *str){
|
||||
void develop(struct tm *local, const char *devel, char *str)
|
||||
{
|
||||
// Print Version of develop release in the file
|
||||
char filename[57];
|
||||
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;
|
||||
devel1=total_year_day(year1,year2)-total_day(year1,month1,day1)+total_day(year2,month2,day2);//get release version
|
||||
sprintf(str,"Xeinit devel Version:%s.%d\n",devel,devel1);
|
||||
freopen(filename,"a",stdout);
|
||||
printf("%4d-%02d-%02d ",local->tm_year+1900,local->tm_mon+1,local->tm_mday);//output:development branch time in xe-release
|
||||
printf("%s.%d build:%d\n",devel,devel1,xeapi1(local));
|
||||
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);
|
||||
sprintf(str, "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 ;
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -13,4 +13,12 @@ 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