Skip to content

Commit

Permalink
Merge pull request #2 from Railway-Op-Sim/artemis-beta/use-11zip
Browse files Browse the repository at this point in the history
Use 11Zip for Archiving
  • Loading branch information
artemis-beta authored Jan 5, 2022
2 parents 86b7b11 + fc5e75f commit 653f1b8
Show file tree
Hide file tree
Showing 11 changed files with 460 additions and 183 deletions.
68 changes: 48 additions & 20 deletions .github/workflows/build_packager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ jobs:
CC: gcc-11
CXX: g++-11
run: |
cmake -Bbuild
cmake -Bbuildout_dir_
sudo cmake --build build/ --target install
working-directory: rostools/cpp
- name: Install Qt
uses: jurplel/install-qt-action@v2
with:
version: '5.15.2'
with:
version: '6.2.2'
setup-python: false
- name: Build ROSPackageManager
env:
Expand All @@ -46,8 +46,43 @@ jobs:
working-directory: rospkgmanager
- uses: actions/upload-artifact@v1
with:
name: unix_rospkg
name: ubuntu_rospkg
path: rospkgmanager/build/ROSPkgManager
build-test-macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
path: rospkgmanager
- name: Setup cmake
uses: jwlawson/actions-setup-cmake@v1.9
with:
cmake-version: '3.20.x'
- uses: actions/checkout@v2
with:
repository: Railway-Op-Sim/rostools
ref: v0.4.0
path: rostools
- name: Install ROSTools
run: |
cmake -Bbuild
sudo cmake --build build/ --target install
working-directory: rostools/cpp
- name: Install Qt
uses: jurplel/install-qt-action@v2
with:
version: '6.2.2'
setup-python: false
- name: Build ROSPackageManager
run: |
cmake -Bbuildout_dir_
cmake --build build
working-directory: rospkgmanager
- uses: actions/upload-artifact@v1
with:
name: darwin_rospkg
path: rospkgmanager/build/ROSPkgManager.app
build-test-windows:
runs-on: windows-latest
steps:
Expand All @@ -62,32 +97,25 @@ jobs:
path: rostools
- name: Install ZLIB
run: powershell -Command "(Invoke-WebRequest -Uri https://git.io/JnHTY -OutFile install_zlib.bat)"; ./install_zlib.bat; del install_zlib.bat
- name: Set up Cygwin
uses: egor-tensin/setup-cygwin@v3
- name: Install Qt
uses: jurplel/install-qt-action@v2
with:
platform: x64
packages: cmake gcc-g++
- name: Set up MinGW
uses: egor-tensin/setup-mingw@v2
version: '6.2.2'
setup-python: false
- name: Setup cmake
uses: jwlawson/actions-setup-cmake@v1.9
with:
platform: x64
cygwin: 1
cc: 1
cmake-version: '3.20.x'
- name: Install ROSTools
run: |
mkdir install
cmake -Bbuild
cmake -Bbuildout_dir_
cmake --build build/ --target install
working-directory: rostools/cpp
- name: Install Qt
uses: jurplel/install-qt-action@v2
with:
version: '5.15.2'
setup-python: false
- name: Build ROSPackageManager
run: |
cmake -Bbuild
cmake --build build
cmake --build build --config Release
working-directory: rospkgmanager
- uses: actions/upload-artifact@v1
with:
Expand Down
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "external/AbZip"]
path = external/AbZip
url = https://github.com/artemis-beta/AbZip.git
[submodule "external/11Zip"]
path = external/11Zip
url = https://github.com/artemis-beta/11Zip.git
21 changes: 3 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,19 @@ find_package( Qt${QT_VERSION_MAJOR} COMPONENTS Widgets LinguistTools Core Gui RE
set( MAIN_SRC ${CMAKE_SOURCE_DIR}/application.cxx )
set( EXTERNAL_SOURCES ${CMAKE_SOURCE_DIR}/external )

# ------------------------- AbZip ---------------------------- #
file( GLOB_RECURSE ABZIP_SRCS ${EXTERNAL_SOURCES}/AbZip/*.cpp )
file( GLOB_RECURSE ABZIP_HEADERS ${EXTERNAL_SOURCES}/AbZip/*.h )
find_package( ZLIB REQUIRED )
set( ABZIP abzip )
set( ABZIP_INCLUDE_DIR ${EXTERNAL_SOURCES}/AbZip )
add_library( ${ABZIP} ${ABZIP_SRCS} ${ABZIP_HEADERS} )
target_include_directories( ${ABZIP} PRIVATE ${ABZIP_INCLUDE_DIR} )
target_include_directories( ${ABZIP} PRIVATE ${ABZIP_INCLUDE_DIR}/Compressors )
target_include_directories( ${ABZIP} PRIVATE ${ABZIP_INCLUDE_DIR}/Encryption )
target_link_libraries( ${ABZIP} PRIVATE ${ZLIB_LIBRARIES} )
target_link_libraries( ${ABZIP} PUBLIC Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui )

# ------------------------------------------------------------ #

file( GLOB SRC_FILES ${CMAKE_SOURCE_DIR}/src/*.cxx )
file( GLOB TS_FILES ${CMAKE_SOURCE_DIR}/lang/*.ts )

# Important to add headers so MOC can process them for Q_OBJECT macro
file( GLOB HEADERS ${CMAKE_SOURCE_DIR}/include/*.hxx )

set( DIGESTPP digestpp )

set( 11ZIP elzip )
set( ROSTOOLS rostools )
find_package( ${ROSTOOLS} 0.4.0 REQUIRED )

add_library( ${LIBRARY_NAME} STATIC ${SRC_FILES} ${HEADERS} )
add_subdirectory( ${CMAKE_SOURCE_DIR}/external/11Zip )

include(FetchContent)
FetchContent_Declare(
Expand All @@ -50,10 +36,9 @@ FetchContent_Declare(
)
FetchContent_MakeAvailable( ${DIGESTPP} )

target_link_libraries( ${LIBRARY_NAME} PUBLIC Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui ${ABZIP} ${ROSTOOLS_LIBRARIES} )
target_link_libraries( ${LIBRARY_NAME} PUBLIC Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui ${ROSTOOLS_LIBRARIES} ${11ZIP} )
target_include_directories( ${LIBRARY_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/include )
target_include_directories( ${LIBRARY_NAME} PUBLIC ${tomlplusplus_SOURCE_DIR} )
target_include_directories( ${LIBRARY_NAME} PUBLIC ${EXTERNAL_SOURCES} )
target_link_libraries( ${LIBRARY_NAME} PUBLIC ${ROSTOOLS} )
target_include_directories( ${LIBRARY_NAME} PUBLIC ${digestpp_SOURCE_DIR} )

Expand Down
1 change: 1 addition & 0 deletions external/11Zip
Submodule 11Zip added at 5b9e01
1 change: 0 additions & 1 deletion external/AbZip
Submodule AbZip deleted from 0d2eed
200 changes: 162 additions & 38 deletions include/ros_packager.hxx
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
/*! **************************************************************************
* @file ros_packager.hxx
* @author K. Zarebski
* @date 2022-01-05
* @brief File containing method related to ROS package creation
*
* This file contains the Packager class used for handling and creating
* packages for Railway Operation Simulator. A package is defined as a single
* route simulation consisting of:
*
* - A single railway definition (.rly) file
* - One or more program timetable files (.ttb)
* - Optionally, session files (.ssn)
* - Documentation files (.pdf, .md)
* - A metadata definition file (.toml)
*
* A metadata file following the standard is created and used as a package
* definition file.
*
****************************************************************************/
#ifndef __ROSPACKAGER_HXX__
#define __ROSPACKAGER_HXX__

Expand All @@ -6,52 +26,156 @@
#include <QTemporaryDir>
#include <QWidget>
#include <QtCore>

#include <QFile>
#include <QTextStream>
#include <QMessageBox>
#include <QStandardPaths>
#include <QList>

#include "AbZip/AbZip.h"
#include "elzip.hpp"

namespace ROSPkg {
class Packager {
private:
QWidget* parent_ = nullptr;
const QDir output_dir_{QStandardPaths::writableLocation(QStandardPaths::CacheLocation)};
const QString package_name_ = "";
const QString ros_loc_ = "";
QString display_name_ = "";
QString author_ = "Unknown";
QList<QString> contributors_ = {};
QString version_ = "";
QString description_ = "";
int year_ = -1;
QString factual_ = "false";
QString country_code_ = "UN";
QString rly_file_ = "";
QList<QString> ssn_files_;
QList<QString> doc_files_;
QList<QString> ttb_files_;
QString toml_file_ = "";
public:
Packager(QWidget* parent, const QString& ros_loc, const QString& package_name) :
parent_(parent), ros_loc_(ros_loc), package_name_(package_name) {}
void setRLYFile(const QString& rly_path) {rly_file_ = rly_path;}
void addTTBFile(const QString& ttb_path) {ttb_files_.push_back(ttb_path);}
void addSSNFile(const QString& ssn_path) {ssn_files_.push_back(ssn_path);}
void addDocFile(const QString& doc_path) {doc_files_.push_back(doc_path);}
void addContributor(const QString& contributor) {contributors_.push_back(contributor);}
void setAuthor(const QString& author) {author_ = author;}
void setDescription(const QString& description) {description_ = description;}
void setFactual(bool is_true) {factual_ = (is_true) ? "true" : "false";}
void setYear(int year) {year_ = year;}
void setVersion(const QString& version) {version_ = version;}
void setCountryCode(const QString& country_code) {country_code_ = country_code;}
void setDisplayName(const QString& display_name) {display_name_ = display_name;}
QString buildTOML();
void packageFailure();
QString createPackage();
/*! **********************************************************************
* @class Packager
* @brief Performs assembly of files into a single package directory
*
* Files are assembled into a single directory and metadata obtained.
* A metadata TOML file is automatically generated for the given file
* set and information provided by the user.
* **********************************************************************/
class Packager {
private:
QWidget* parent_ = nullptr;
const QDir output_dir_{QStandardPaths::writableLocation(QStandardPaths::CacheLocation)};
const QString package_name_ = "";
const QString ros_loc_ = "";
QString display_name_ = "";
QString author_ = "Unknown";
QList<QString> contributors_ = {};
QString version_ = "";
QString description_ = "";
int year_ = -1;
QString factual_ = "false";
QString country_code_ = "UN";
QString rly_file_ = "";
QList<QString> ssn_files_;
QList<QString> doc_files_;
QList<QString> ttb_files_;
QString toml_file_ = "";
public:
/*! **************************************************************************
* @brief Initialise a new packager for a given parent widget
*
* @param parent pointer of parent widget for application
* @param ros_loc full path to directory containing railway.exe
* @param package_name name to give final package
* **************************************************************************/
Packager(QWidget* parent, const QString& ros_loc, const QString& package_name) :
parent_(parent), ros_loc_(ros_loc), package_name_(package_name) {}

/*! *************************************************************************
* @brief set main railway definition (.rly) file for package
*
* @param rly_path full path to the RLY file
* *************************************************************************/
void setRLYFile(const QString& rly_path) {rly_file_ = rly_path;}

/*! *************************************************************************
* @brief append a program timetable file (.ttb) to the package
*
* @param ttb_path full path to the TTB file
* *************************************************************************/
void addTTBFile(const QString& ttb_path) {ttb_files_.push_back(ttb_path);}

/*! *************************************************************************
* @brief append a session file (.ssn) to the package
*
* @param ssn_path full path to the SSN file
* *************************************************************************/
void addSSNFile(const QString& ssn_path) {ssn_files_.push_back(ssn_path);}

/*! *************************************************************************
* @brief append a documentation file (.pdf, .md) to the package
*
* @param doc_path full path to the documentation file
* *************************************************************************/
void addDocFile(const QString& doc_path) {doc_files_.push_back(doc_path);}

/*! *************************************************************************
* @brief add a contributor to the package, this is an additional author.
*
* @param contributor name of contributor
* *************************************************************************/
void addContributor(const QString& contributor) {contributors_.push_back(contributor);}

/*! *************************************************************************
* @brief set name of package author
*
* @param author name of package author
* *************************************************************************/
void setAuthor(const QString& author) {author_ = author;}

/*! *************************************************************************
* @brief set package description
*
* @param description package description
* *************************************************************************/
void setDescription(const QString& description) {description_ = description;}

/*! *************************************************************************
* @brief set whether package contains a factual or fictional simulation
*
* @param is_true if simulation is factual
* *************************************************************************/
void setFactual(bool is_true) {factual_ = (is_true) ? "true" : "false";}

/*! *************************************************************************
* @brief set the year the simulation in the package is set
*
* @param year year of simulation (if fictional this can be any positive int)
* *************************************************************************/
void setYear(int year) {year_ = year;}

/*! *************************************************************************
* @brief set semantic version for package in the form MAJOR.MINOR.PATCH
*
* @param version semantic version
* *************************************************************************/
void setVersion(const QString& version) {version_ = version;}

/*! *************************************************************************
* @brief set the two letter ISO country code for the represented region
*
* @param country_code ISO code
* *************************************************************************/
void setCountryCode(const QString& country_code) {country_code_ = country_code;}

/*! *************************************************************************
* @brief set package display name
*
* @param author name of package as to be displayed
* *************************************************************************/
void setDisplayName(const QString& display_name) {display_name_ = display_name;}

/*! *************************************************************************
* @brief construct a TOML metadata file for the package
*
* @return full path of created TOML file
* *************************************************************************/
QString buildTOML();

/*! *************************************************************************
* @brief display package assembly failure dialog
* *************************************************************************/
void packageFailure();

/*! *************************************************************************
* @brief create the directory for the package and then an archive
*
* @return the full path of the created ZIP file
* *************************************************************************/
QString createPackage();
};
};

Expand Down
Loading

0 comments on commit 653f1b8

Please sign in to comment.