Commit 3b04e3d1 authored by sm's avatar sm

New version 0.5

- add arch PKGBUILD
- make GameDiskFiles more testable
- avoid throwing because of missing theme resources when parsing model
parent 09a73681
stmm-games (0.5) unstable; urgency=low
* Make GameDiskFiles more testable
* Avoid throwing because of missing theme resources when parsing model
* Add arch PKGBUILD
* Increase minor version
-- Stefano Marsili <efanomars@gmx.ch> Wed, 13 Mar 2019 19:29:39 +0100
stmm-games (0.4) unstable; urgency=low
* Add NPoint hash function
......
......@@ -20,33 +20,34 @@
# MINOR is REVISION (implementation of interface)
# AGE is always 0
set(STMM_GAMES_FAKE_MAJOR_VERSION 0)
set(STMM_GAMES_FAKE_MINOR_VERSION 4)
set(STMM_GAMES_FAKE_MINOR_VERSION 5)
set(STMM_GAMES_FAKE_VERSION "${STMM_GAMES_FAKE_MAJOR_VERSION}.${STMM_GAMES_FAKE_MINOR_VERSION}.0")
# required stmm-games version
set(STMM_GAMES_FAKE_REQ_STMM_GAMES_MAJOR_VERSION 0)
set(STMM_GAMES_FAKE_REQ_STMM_GAMES_MINOR_VERSION 4)
set(STMM_GAMES_FAKE_REQ_STMM_GAMES_MINOR_VERSION 5)
set(STMM_GAMES_FAKE_REQ_STMM_GAMES_VERSION "${STMM_GAMES_FAKE_REQ_STMM_GAMES_MAJOR_VERSION}.${STMM_GAMES_FAKE_REQ_STMM_GAMES_MINOR_VERSION}")
include("${PROJECT_SOURCE_DIR}/../libstmm-games/stmm-games-defs.cmake")
# include dirs
set(STMMGAMESFAKE_EXTRA_INCLUDE_SDIRS "")
set( STMMGAMESFAKE_EXTRA_INCLUDE_SDIRS "")
list(APPEND STMMGAMESFAKE_EXTRA_INCLUDE_SDIRS "${STMMGAMES_INCLUDE_SDIRS}")
set(STMMGAMESFAKE_EXTRA_INCLUDE_DIRS "")
set( STMMGAMESFAKE_EXTRA_INCLUDE_DIRS "")
list(APPEND STMMGAMESFAKE_EXTRA_INCLUDE_DIRS "${STMMGAMES_INCLUDE_DIRS}")
set(STMMI_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/../libstmm-games-fake/include")
set(STMMI_HEADERS_DIR "${STMMI_INCLUDE_DIR}/stmm-games-fake")
set(STMMGAMESFAKE_INCLUDE_DIRS "")
set( STMMGAMESFAKE_INCLUDE_DIRS "")
list(APPEND STMMGAMESFAKE_INCLUDE_DIRS "${STMMGAMESFAKE_EXTRA_INCLUDE_DIRS}")
list(APPEND STMMGAMESFAKE_INCLUDE_DIRS "${STMMI_INCLUDE_DIR}")
list(APPEND STMMGAMESFAKE_INCLUDE_DIRS "${STMMI_HEADERS_DIR}")
set(STMMGAMESFAKE_INCLUDE_SDIRS "")
set( STMMGAMESFAKE_INCLUDE_SDIRS "")
list(APPEND STMMGAMESFAKE_INCLUDE_SDIRS "${STMMGAMESFAKE_EXTRA_INCLUDE_SDIRS}")
# libs
set( STMMGAMESFAKE_EXTRA_LIBRARIES "")
list(APPEND STMMGAMESFAKE_EXTRA_LIBRARIES "${STMMGAMES_LIBRARIES}")
if (BUILD_SHARED_LIBS)
......@@ -55,6 +56,7 @@ else()
set(STMMI_LIB_FILE "${PROJECT_SOURCE_DIR}/../libstmm-games-fake/build/libstmm-games-fake.a")
endif()
set( STMMGAMESFAKE_LIBRARIES "")
list(APPEND STMMGAMESFAKE_LIBRARIES "${STMMGAMESFAKE_EXTRA_LIBRARIES}")
list(APPEND STMMGAMESFAKE_LIBRARIES "${STMMI_LIB_FILE}")
......
......@@ -20,11 +20,11 @@
# MINOR is REVISION (implementation of interface)
# AGE is always 0
set(STMM_GAMES_GTK_MAJOR_VERSION 0)
set(STMM_GAMES_GTK_MINOR_VERSION 4)
set(STMM_GAMES_GTK_MINOR_VERSION 5)
set(STMM_GAMES_GTK_VERSION "${STMM_GAMES_GTK_MAJOR_VERSION}.${STMM_GAMES_GTK_MINOR_VERSION}.0")
set(STMM_GAMES_GTK_REQ_STMM_GAMES_MAJOR_VERSION 0)
set(STMM_GAMES_GTK_REQ_STMM_GAMES_MINOR_VERSION 4)
set(STMM_GAMES_GTK_REQ_STMM_GAMES_MINOR_VERSION 5)
set(STMM_GAMES_GTK_REQ_STMM_GAMES_VERSION "${STMM_GAMES_GTK_REQ_STMM_GAMES_MAJOR_VERSION}.${STMM_GAMES_GTK_REQ_STMM_GAMES_MINOR_VERSION}")
set(STMM_GAMES_GTK_REQ_STMM_INPUT_GTK_MAJOR_VERSION 0)
......@@ -49,10 +49,10 @@ endif()
include("${PROJECT_SOURCE_DIR}/../libstmm-games/stmm-games-defs.cmake")
# include dirs
set(STMMGAMESGTK_EXTRA_INCLUDE_DIRS "")
set( STMMGAMESGTK_EXTRA_INCLUDE_DIRS "")
list(APPEND STMMGAMESGTK_EXTRA_INCLUDE_DIRS "${STMMGAMES_INCLUDE_DIRS}")
set(STMMGAMESGTK_EXTRA_INCLUDE_SDIRS "")
list(APPEND STMMGAMESGTK_EXTRA_INCLUDE_DIRS "${STMMGAMES_INCLUDE_SDIRS}")
set( STMMGAMESGTK_EXTRA_INCLUDE_SDIRS "")
list(APPEND STMMGAMESGTK_EXTRA_INCLUDE_SDIRS "${STMMGAMES_INCLUDE_SDIRS}")
list(APPEND STMMGAMESGTK_EXTRA_INCLUDE_SDIRS "${STMMINPUTGTK_INCLUDE_DIRS}")
list(APPEND STMMGAMESGTK_EXTRA_INCLUDE_SDIRS "${GTKMM_INCLUDE_DIRS}")
list(APPEND STMMGAMESGTK_EXTRA_INCLUDE_SDIRS "${LIBRSVG_INCLUDE_DIRS}")
......@@ -60,14 +60,15 @@ list(APPEND STMMGAMESGTK_EXTRA_INCLUDE_SDIRS "${LIBRSVG_INCLUDE_DIRS}")
set(STMMI_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/../libstmm-games-gtk/include")
set(STMMI_HEADERS_DIR "${STMMI_INCLUDE_DIR}/stmm-games-gtk")
set(STMMGAMESGTK_INCLUDE_DIRS "")
set( STMMGAMESGTK_INCLUDE_DIRS "")
list(APPEND STMMGAMESGTK_INCLUDE_DIRS "${STMMGAMESGTK_EXTRA_INCLUDE_DIRS}")
list(APPEND STMMGAMESGTK_INCLUDE_DIRS "${STMMI_INCLUDE_DIR}")
list(APPEND STMMGAMESGTK_INCLUDE_DIRS "${STMMI_HEADERS_DIR}")
set(STMMGAMESGTK_INCLUDE_SDIRS "")
set( STMMGAMESGTK_INCLUDE_SDIRS "")
list(APPEND STMMGAMESGTK_INCLUDE_SDIRS "${STMMGAMESGTK_EXTRA_INCLUDE_SDIRS}")
# libs
set( STMMGAMESGTK_EXTRA_LIBRARIES "")
list(APPEND STMMGAMESGTK_EXTRA_LIBRARIES "${STMMGAMES_LIBRARIES}")
list(APPEND STMMGAMESGTK_EXTRA_LIBRARIES "${STMMINPUTGTK_LIBRARIES}")
list(APPEND STMMGAMESGTK_EXTRA_LIBRARIES "${GTKMM_LIBRARIES}")
......@@ -79,6 +80,7 @@ else()
set(STMMI_LIB_FILE "${PROJECT_SOURCE_DIR}/../libstmm-games-gtk/build/libstmm-games-gtk.a")
endif()
set( STMMGAMESGTK_LIBRARIES "")
list(APPEND STMMGAMESGTK_LIBRARIES "${STMMGAMESGTK_EXTRA_LIBRARIES}")
list(APPEND STMMGAMESGTK_LIBRARIES "${STMMI_LIB_FILE}")
......
......@@ -39,6 +39,16 @@ public:
* @param sAppName The app's name. Cannot be empty.
*/
GameDiskFiles(const std::string& sAppName);
/** Non standard location constructor.
* @param sAppName The app's name. Cannot be empty.
* @param aGameFiles The game files. Can be empty. All files must be defined and not buffered.
* @param aThemeFiles The theme files. Can be empty. All files must be defined and not buffered.
* @param sIconFile The icon file. If not empty must exist.
* @param sHighscoresDir The highscores directory. If not empty, must exist.
* @param sPreferencesFile The preferences file. Can be empty.
*/
GameDiskFiles(const std::string& sAppName, std::vector< File >&& aGameFiles, std::vector< File >&& aThemeFiles
, const std::string& sIconFile, const std::string& sHighscoresDir, const std::string& sPreferencesFile);
/** The game files for the app.
* @return The game files. Are all defined.
*/
......@@ -62,7 +72,7 @@ public:
/** Returns the full highscore file given the game name.
* Example: if sGameName is 'Classic' the returned file
* might have path '~/.local/share/stmm-games/highscores/jointris/Classic.scores'.
* @param sGameName The game name.
* @param sGameName The game name. Cannot be empty.
* @return The highscores file or an undefined File if not supported.
*/
File getHighscoreFile(const std::string& sGameName);
......@@ -164,10 +174,21 @@ private:
bool m_bThemeFilesLoaded;
std::vector< File > m_aThemeFiles;
bool m_bHighscoresDirLoaded;
std::string m_sHighscoresDir;
bool m_bIconFileLoaded;
File m_oAppIconFile;
bool m_bPreferencesFileLoaded;
File m_oPreferencesFile;
// Key: Game name xxx (ex. "Classic", that has a file ".../classic.xml")
// Value: size 1 vector containing the highscores
std::map<std::string, ResourceFileData> m_oGameHighscoreData;
// Key: Game xxx.xml full path (utf8, not file system encoding)
// Value: size 1 vector containing the thumbnail file
std::map<std::string, ResourceFileData> m_oGameThumbnailData;
// Key: Game xxx.thm/theme.xml full path (utf8, not file system encoding)
// Key: Theme xxx.thm/theme.xml full path (utf8, not file system encoding)
// Value: size 1 vector containing the thumbnail file
std::map<std::string, ResourceFileData> m_oThemeThumbnailData;
......
......@@ -63,10 +63,36 @@ GameDiskFiles::GameDiskFiles(const std::string& sAppName)
: m_sAppName(sAppName)
, m_bGameFilesLoaded(false)
, m_bThemeFilesLoaded(false)
, m_bHighscoresDirLoaded(false)
, m_bIconFileLoaded(false)
, m_bPreferencesFileLoaded(false)
{
assert(!m_sAppName.empty());
}
GameDiskFiles::GameDiskFiles(const std::string& sAppName, std::vector< File >&& aGameFiles, std::vector< File >&& aThemeFiles
, const std::string& sIconFile, const std::string& sHighscoresDir, const std::string& sPreferencesFile)
: m_sAppName(sAppName)
, m_bGameFilesLoaded(true)
, m_aGameFiles(std::move(aGameFiles))
, m_bThemeFilesLoaded(true)
, m_aThemeFiles(std::move(aThemeFiles))
, m_bHighscoresDirLoaded(true)
, m_sHighscoresDir(sHighscoresDir)
, m_bIconFileLoaded(true)
, m_oAppIconFile((sIconFile.empty()) ? File{} : File{sIconFile})
, m_bPreferencesFileLoaded(true)
, m_oPreferencesFile((sPreferencesFile.empty()) ? File{} : File{sPreferencesFile})
{
assert(!m_sAppName.empty());
#ifndef NDEBUG
for (const File& oFile : m_aGameFiles) {
assert(oFile.isDefined() && ! oFile.isBuffered());
}
for (const File& oFile : m_aThemeFiles) {
assert(oFile.isDefined() && ! oFile.isBuffered());
}
#endif //NDEBUG
}
const std::vector< File >& GameDiskFiles::getGameFiles()
{
//std::cout << "GameDiskFiles::getGameFiles() ---------------------------" << '\n';
......@@ -170,42 +196,54 @@ const File& GameDiskFiles::getThemeThumbnailFile(const File& oThemeFile)
File GameDiskFiles::getIconFile()
{
//std::cout << "GameDiskFiles::getIconFile() ---------------------------" << '\n';
const auto& aDataDirs = getReadOnlyDataDirs();
for (const auto& sDataDir : aDataDirs) {
const std::string sFolder = sDataDir + "/" + s_sGamesFolder;
std::vector<std::string> aNames;
getDirSubTreeFiles(sFolder, false, false, true, "", aNames);
removeNonImageFiles(aNames);
std::vector<std::string> aPaths;
getAbsPathFromBaseAndRel(sFolder, aNames, aPaths);
for (auto& sImgPath : aPaths) {
const std::string sImgName = Glib::path_get_basename(sImgPath);
auto nLastDotIdx = sImgName.find_last_of('.');
if (nLastDotIdx == std::string::npos) {
assert(false); // all images have a file type (ex. ".png")
continue; // for sImgPath
}
if (sImgName.substr(0, nLastDotIdx) == m_sAppName) {
return File(sImgPath); //---------------------------------------
if (! m_bIconFileLoaded) {
const auto& aDataDirs = getReadOnlyDataDirs();
for (const auto& sDataDir : aDataDirs) {
const std::string sFolder = sDataDir + "/" + s_sGamesFolder;
std::vector<std::string> aNames;
getDirSubTreeFiles(sFolder, false, false, true, "", aNames);
removeNonImageFiles(aNames);
std::vector<std::string> aPaths;
getAbsPathFromBaseAndRel(sFolder, aNames, aPaths);
for (auto& sImgPath : aPaths) {
const std::string sImgName = Glib::path_get_basename(sImgPath);
auto nLastDotIdx = sImgName.find_last_of('.');
if (nLastDotIdx == std::string::npos) {
assert(false); // all images have a file type (ex. ".png")
continue; // for sImgPath
}
if (sImgName.substr(0, nLastDotIdx) == m_sAppName) {
m_oAppIconFile = File(sImgPath);
m_bIconFileLoaded= true;
return m_oAppIconFile; //-----------------------------------
}
}
}
m_bIconFileLoaded = true;
}
return File{};
return m_oAppIconFile;
}
File GameDiskFiles::getHighscoreFile(const std::string& sGameName)
{
//std::cout << "GameDiskFiles::getHighscoreFile() " << sGameName << " ---------------------------" << '\n';
std::string sFolder = GameDiskFiles::getUserPkgDataDir();
sFolder = sFolder + "/" + s_sHighscoresFolder + "/" + m_sAppName;
return File(sFolder + "/" + sGameName + s_sHighscoresXmlExt);
assert(! sGameName.empty());
if (! m_bHighscoresDirLoaded) {
std::string sFolder = GameDiskFiles::getUserPkgDataDir();
m_sHighscoresDir = sFolder + "/" + s_sHighscoresFolder + "/" + m_sAppName;
m_bHighscoresDirLoaded = true;
}
return File(m_sHighscoresDir + "/" + sGameName + s_sHighscoresXmlExt);
}
File GameDiskFiles::getPreferencesFile()
{
//std::cout << "GameDiskFiles::getPreferencesFile() ---------------------------" << '\n';
std::string sFolder = GameDiskFiles::getUserPkgDataDir();
sFolder = sFolder + "/" + s_sPreferencesFolder + "/" + m_sAppName;
return File(sFolder + "/" + s_sPreferencesXmlName + s_sPreferencesXmlExt);
if (! m_bPreferencesFileLoaded) {
std::string sFolder = GameDiskFiles::getUserPkgDataDir();
sFolder = sFolder + "/" + s_sPreferencesFolder + "/" + m_sAppName;
m_oPreferencesFile = File(sFolder + "/" + s_sPreferencesXmlName + s_sPreferencesXmlExt);
m_bPreferencesFileLoaded = true;
}
return m_oPreferencesFile;
}
const std::vector< File >& GameDiskFiles::getThemeFiles()
{
......@@ -258,13 +296,13 @@ void GameDiskFiles::getFilesWithExt(const std::string& sTheDir, bool bDoSubdirs,
}
});
}
GameDiskFiles::ResourceFileData& GameDiskFiles::getResourceData(const std::string& sResource, std::map<std::string, ResourceFileData>& oThemeResourceData)
GameDiskFiles::ResourceFileData& GameDiskFiles::getResourceData(const std::string& sResource, std::map<std::string, ResourceFileData>& oResourceData)
{
//std::cout << "GameDiskFiles::getResourceData() sResource=" << sResource << '\n';
auto itFD = oThemeResourceData.find(sResource);
if (itFD == oThemeResourceData.end()) {
oThemeResourceData[sResource] = ResourceFileData(); //TODO own method
itFD = oThemeResourceData.find(sResource);
auto itFD = oResourceData.find(sResource);
if (itFD == oResourceData.end()) {
oResourceData[sResource] = ResourceFileData(); //TODO own method
itFD = oResourceData.find(sResource);
}
return itFD->second;
}
......
......@@ -54,7 +54,8 @@ shared_ptr<GameWidget> XmlActionWidgetParser::parseGameWidget(LayoutCtx& oCtx, c
if (! sImage.empty()) {
oInit.m_nImgId = oCtx.named().images().getIndex(sImage);
if (oInit.m_nImgId < 0) {
throw XmlCommonErrors::error(oCtx, p0WidgetElement, s_sGameActionWidgetImgIdAttr, Util::stringCompose("Image name not found"));
oInit.m_nImgId = oCtx.named().images().addName(sImage);
std::cout << "Warning! ActionWidget: : image '" << sImage << "' not defined!" << '\n';
}
}
}
......
......@@ -50,7 +50,8 @@ shared_ptr<GameWidget> XmlBackgroundWidgetParser::parseGameWidget(LayoutCtx& oCt
if (! sImage.empty()) {
oInit.m_nImgId = oCtx.named().images().getIndex(sImage);
if (oInit.m_nImgId < 0) {
throw XmlCommonErrors::error(oCtx, p0WidgetElement, s_sGameBackgroundWidgetImageAttr, Util::stringCompose("Image name not found"));
oInit.m_nImgId = oCtx.named().images().addName(sImage);
std::cout << "Warning! BackgroundWidget: : image '" << sImage << "' not defined!" << '\n';
}
}
}
......
......@@ -156,6 +156,10 @@ std::pair<shared_ptr<Game>, bool> XmlGameLoader::getNewGame(const std::string& s
assert(refAppPreferences);
assert(refAppPreferences->getAppConfig() == m_refAppConfig);
if (!m_bInfosLoaded) {
loadGameInfos();
}
assert(!m_aGameNames.empty());
const std::string& sName = (sGameName.empty() ? m_aGameNames[0] : sGameName);
......
......@@ -20,12 +20,12 @@
# MINOR is REVISION (implementation of interface)
# AGE is always 0
set(STMM_GAMES_XML_MAJOR_VERSION 0)
set(STMM_GAMES_XML_MINOR_VERSION 4)
set(STMM_GAMES_XML_MINOR_VERSION 5)
set(STMM_GAMES_XML_VERSION "${STMM_GAMES_XML_MAJOR_VERSION}.${STMM_GAMES_XML_MINOR_VERSION}.0")
# required stmm-games-gtk version
set(STMM_GAMES_XML_REQ_STMM_GAMES_GTK_MAJOR_VERSION 0)
set(STMM_GAMES_XML_REQ_STMM_GAMES_GTK_MINOR_VERSION 4)
set(STMM_GAMES_XML_REQ_STMM_GAMES_GTK_MINOR_VERSION 5)
set(STMM_GAMES_XML_REQ_STMM_GAMES_GTK_VERSION "${STMM_GAMES_XML_REQ_STMM_GAMES_GTK_MAJOR_VERSION}.${STMM_GAMES_XML_REQ_STMM_GAMES_GTK_MINOR_VERSION}")
# required libxml++-2.6 version
......@@ -43,23 +43,24 @@ endif()
include("${PROJECT_SOURCE_DIR}/../libstmm-games-gtk/stmm-games-gtk-defs.cmake")
# include dirs
set(STMMGAMESXML_EXTRA_INCLUDE_DIRS "")
set( STMMGAMESXML_EXTRA_INCLUDE_DIRS "")
list(APPEND STMMGAMESXML_EXTRA_INCLUDE_DIRS "${STMMGAMESGTK_INCLUDE_DIRS}")
set(STMMGAMESXML_EXTRA_INCLUDE_SDIRS "")
set( STMMGAMESXML_EXTRA_INCLUDE_SDIRS "")
list(APPEND STMMGAMESXML_EXTRA_INCLUDE_SDIRS "${STMMGAMESGTK_INCLUDE_SDIRS}")
list(APPEND STMMGAMESXML_EXTRA_INCLUDE_SDIRS "${LIBXMLPP_INCLUDE_DIRS}")
set(STMMI_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/../libstmm-games-xml/include")
set(STMMI_HEADERS_DIR "${STMMI_INCLUDE_DIR}/stmm-games-xml")
set(STMMGAMESXML_INCLUDE_DIRS "")
set( STMMGAMESXML_INCLUDE_DIRS "")
list(APPEND STMMGAMESXML_INCLUDE_DIRS "${STMMGAMESXML_EXTRA_INCLUDE_DIRS}")
list(APPEND STMMGAMESXML_INCLUDE_DIRS "${STMMI_INCLUDE_DIR}")
list(APPEND STMMGAMESXML_INCLUDE_DIRS "${STMMI_HEADERS_DIR}")
set(STMMGAMESXML_INCLUDE_SDIRS "")
set( STMMGAMESXML_INCLUDE_SDIRS "")
list(APPEND STMMGAMESXML_INCLUDE_SDIRS "${STMMGAMESXML_EXTRA_INCLUDE_SDIRS}")
# libs
set( STMMGAMESXML_EXTRA_LIBRARIES "")
list(APPEND STMMGAMESXML_EXTRA_LIBRARIES "${STMMGAMESGTK_LIBRARIES}")
list(APPEND STMMGAMESXML_EXTRA_LIBRARIES "${LIBXMLPP_LIBRARIES}")
......@@ -69,6 +70,7 @@ else()
set(STMMI_LIB_FILE "${PROJECT_SOURCE_DIR}/../libstmm-games-xml/build/libstmm-games-xml.a")
endif()
set( STMMGAMESXML_LIBRARIES "")
list(APPEND STMMGAMESXML_LIBRARIES "${STMMGAMESXML_EXTRA_LIBRARIES}")
list(APPEND STMMGAMESXML_LIBRARIES "${STMMI_LIB_FILE}")
......
......@@ -73,6 +73,7 @@ void RandomTiles::createRandomTiles(TileBuffer& oTileBuffer, int32_t nEmpty)
int32_t nRow = 0;
// find the empty tile
for ( ; nCol < nW; ++nCol) {
nRow = 0;
for ( ; nRow < nH; ++nRow) {
if (oTileBuffer.get({nCol, nRow}).isEmpty()) {
if (nFreePos == 0) {
......@@ -84,7 +85,6 @@ void RandomTiles::createRandomTiles(TileBuffer& oTileBuffer, int32_t nEmpty)
if (nRow < nH) {
break; // for nCol ------
}
nRow = 0;
}
assert(nCol < nW);
// fill the position with non empty random tile
......
......@@ -20,7 +20,7 @@
# MINOR is REVISION (implementation of interface)
# AGE is always 0
set(STMM_GAMES_MAJOR_VERSION 0)
set(STMM_GAMES_MINOR_VERSION 4)
set(STMM_GAMES_MINOR_VERSION 5)
set(STMM_GAMES_VERSION "${STMM_GAMES_MAJOR_VERSION}.${STMM_GAMES_MINOR_VERSION}.0")
# required stmm-input-ev version
......@@ -38,21 +38,22 @@ if ("${CMAKE_SCRIPT_MODE_FILE}" STREQUAL "")
endif()
# include dirs
set(STMMGAMES_EXTRA_INCLUDE_SDIRS "")
set(STMMGAMES_EXTRA_INCLUDE_DIRS "")
list(APPEND STMMGAMES_EXTRA_INCLUDE_DIRS "${STMMINPUTEV_INCLUDE_DIRS}")
set( STMMGAMES_EXTRA_INCLUDE_SDIRS "")
set( STMMGAMES_EXTRA_INCLUDE_DIRS "")
list(APPEND STMMGAMES_EXTRA_INCLUDE_DIRS "${STMMINPUTEV_INCLUDE_DIRS}")
set(STMMI_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/../libstmm-games/include")
set(STMMI_HEADERS_DIR "${STMMI_INCLUDE_DIR}/stmm-games")
set(STMMGAMES_INCLUDE_SDIRS "")
set( STMMGAMES_INCLUDE_SDIRS "")
list(APPEND STMMGAMES_INCLUDE_SDIRS "${STMMGAMES_EXTRA_INCLUDE_SDIRS}")
set(STMMGAMES_INCLUDE_DIRS "")
list(APPEND STMMGAMES_INCLUDE_DIRS "${STMMGAMES_EXTRA_INCLUDE_DIRS}")
list(APPEND STMMGAMES_INCLUDE_DIRS "${STMMI_INCLUDE_DIR}")
list(APPEND STMMGAMES_INCLUDE_DIRS "${STMMI_HEADERS_DIR}")
set( STMMGAMES_INCLUDE_DIRS "")
list(APPEND STMMGAMES_INCLUDE_DIRS "${STMMGAMES_EXTRA_INCLUDE_DIRS}")
list(APPEND STMMGAMES_INCLUDE_DIRS "${STMMI_INCLUDE_DIR}")
list(APPEND STMMGAMES_INCLUDE_DIRS "${STMMI_HEADERS_DIR}")
# libs
set( STMMGAMES_EXTRA_LIBRARIES "")
list(APPEND STMMGAMES_EXTRA_LIBRARIES "${STMMINPUTEV_LIBRARIES}")
if (BUILD_SHARED_LIBS)
......@@ -61,6 +62,7 @@ else()
set(STMMI_LIB_FILE "${PROJECT_SOURCE_DIR}/../libstmm-games/build/libstmm-games.a")
endif()
set( STMMGAMES_LIBRARIES "")
list(APPEND STMMGAMES_LIBRARIES "${STMMGAMES_EXTRA_LIBRARIES}")
list(APPEND STMMGAMES_LIBRARIES "${STMMI_LIB_FILE}")
......
#!/usr/bin/env python3
# Copyright © 2019 Stefano Marsili, <stemars@gmx.ch>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with this program; if not, see <http://www.gnu.org/licenses/>
# File: arch_create.py
# Creates arch PKGBUILD, then used to create binary package.
g_sSourceProjectName = "stmm-games"
g_sSubPrj = "libstmm-games"
import os
g_sScriptDirPath = os.path.dirname(os.path.abspath(__file__))
sTempX1X2X3 = g_sScriptDirPath + "/../share/python/frag_arch_create.py"
exec(compile(source=open(sTempX1X2X3).read(), filename=sTempX1X2X3, mode="exec"))
pkgname=stmm-games
pkgver=@STMMI_DEBIAN_SRC_VERSION@
pkgrel=@STMMI_DEBIAN_REVISION@
pkgdesc="C++ 2D games library"
url='https://www.efanomars.com/libraries/stmm-games/'
packager=@STMMI_PACKAGER_FULLNAME@
arch=('x86_64')
license=('GPL3')
depends=('stmm-input' 'gtkmm' 'librsvg2' 'libxml++')
makedepends=('cmake' 'gcc' 'doxygen' 'graphviz' 'python')
optdepends=()
_name=stmm-games
source=('git+https://gitlab.com/efanomars/stmm-games.git')
sha512sums=('SKIP')
build() {
cd "${srcdir}/${_name}"
./scripts/install_stmm-games-all.py -b=Release -s=Off -t=Off -d=Off --installdir="/usr" --no-install --no-sudo
}
package() {
cd "${srcdir}/${_name}"
./scripts/priv/dd_install_stmm-games-all.py -b=Release -s=Off -t=Off -d=Off --installdir="/usr" --destdir="${pkgdir}" --no-configure --no-make --no-sudo
}
#!/usr/bin/env python3
# Copyright © 2019 Stefano Marsili, <stemars@gmx.ch>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with this program; if not, see <http://www.gnu.org/licenses/>
# File: frag_arch_create.py
# Creates arch PKGBUILD.
import sys
import os
import stat
import shutil
import subprocess
from datetime import date
import re
from tempfile import mkdtemp
from tempfile import mkstemp
import datetime
import email
import email.utils
# Expects following global variables being defined (example stmm-input):
# g_sSourceProjectName = "stmm-input"
# g_sSubPrj = "libstmm-input"
#
# g_sScriptDirPath = os.path.dirname(os.path.abspath(__file__))
# and being executed with:
# import os
#
# sTempX1X2X3 = g_sScriptDirPath + "/../share/python/frag_arch_create.py"
#
# exec(compile(source=open(sTempX1X2X3).read(), filename=sTempX1X2X3, mode="exec"))
g_aMonthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
g_sMonthNames = ""
for sMonthName in g_aMonthNames:
g_sMonthNames = g_sMonthNames + sMonthName + "|"
g_sMonthNames = g_sMonthNames[:-1]
#
g_aWeekDayAbbrs = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
g_sWeekDayAbbrs = ""
for sWeekDayAbbr in g_aWeekDayAbbrs:
g_sWeekDayAbbrs = g_sWeekDayAbbrs + sWeekDayAbbr + "|"
g_sWeekDayAbbrs = g_sWeekDayAbbrs[:-1]
#
# Example: Wed, 07 Nov 2018 07:23:39 +0100
g_sDateCommonRegex = "(" + g_sWeekDayAbbrs + "),"\
" ([0-3][0-9]) (" + g_sMonthNames + ") ([0-9][0-9][0-9][0-9])"\
" ([0-2][0-9]:[0-5][0-9]:[0-5][0-9]) ([\+-][0-9][0-9][0-9][0-9])"
# Example: 1.3.2
g_sVersionCommonRegex = "([0-9]+\.)+[0-9]+"
g_sVersionRegex = "^" + g_sVersionCommonRegex + "$"
g_oVersionPatt = re.compile(g_sVersionRegex)
g_sDateRegex = "^" + g_sDateCommonRegex + "$"
g_oDatePatt = re.compile(g_sDateRegex)
g_sChangeDateRegex = "^ -- (.*) <(.*)> (" + g_sDateCommonRegex + ")[ ]*$"
g_oChangeDatePatt = re.compile(g_sChangeDateRegex)
g_sDefaultPackagerFullName = "Stefano Marsili"
g_sDefaultPackagerEMail = "efanomars@gmx.ch"
try:
g_sPackagerFullName = os.environ["DEBFULLNAME"]
except KeyError:
#raise RuntimeError("Couldn't get environment variable DEBFULLNAME")
g_sPackagerFullName = g_sDefaultPackagerFullName
try:
os.environ["DEBFULLNAME"] = g_sPackagerFullName
except KeyError:
raise RuntimeError("Couldn't set environment variable DEBFULLNAME to: " + g_sPackagerFullName)
try:
g_sPackagerEMail = os.environ["DEBEMAIL"]
except KeyError:
#raise RuntimeError("Couldn't get environment variable DEBEMAIL")
g_sPackagerEMail = g_sDefaultPackagerEMail
try:
os.environ["DEBEMAIL"] = g_sPackagerEMail
except KeyError:
raise RuntimeError("Couldn't set environment variable DEBEMAIL to: " + g_sPackagerEMail)
#==============================================================================
# sSubPrjPath: any of the subproject directories
def transformFile(sFileName, sSourceFileDir, sDestFileDir, sPrivScriptDirPath, sSubPrjPath\
, sDebSrcVersion, nDebRevision, sChangelogDate
, sAuthorFullName, sAuthorEMail):
bDoFileName = ("@" in sFileName)
if bDoFileName:
(oFd1, sTmpPath1) = mkstemp(prefix=g_sSourceProjectName + "_1", text=True)
(oFd2, sTmpPath2) = mkstemp(prefix=g_sSourceProjectName + "_2", text=True)
else:
sTmpPath1 = ""
sTmpPath2 = ""
sParams = '-D STMMI_DEBIAN_SRC_FILENAME="' + sFileName + '"'
sParams = sParams + ' -D STMMI_DEBIAN_SRC_FROM_DIR="' + sSourceFileDir + '"'
sParams = sParams + ' -D STMMI_DEBIAN_SRC_TO_DIR="' + sDestFileDir + '"'
sParams = sParams + ' -D STMMI_DEBIAN_SRC_TMP_1="' + sTmpPath1 + '"'
sParams = sParams + ' -D STMMI_DEBIAN_SRC_TMP_2="' + sTmpPath2 + '"'
sParams = sParams + ' -D STMMI_PROJECT_SOURCE_DIR="' + sSubPrjPath + '"'
sParams = sParams + ' -D STMMI_DEBIAN_SRC_VERSION="' + sDebSrcVersion + '"'
sParams = sParams + ' -D STMMI_DEBIAN_REVISION="' + str(nDebRevision) + '"'
sParams = sParams + ' -D STMMI_DEBIAN_CHANGELOG_DATE="' + sChangelogDate + '"'
sParams = sParams + ' -D STMMI_PACKAGER_FULLNAME="' + g_sPackagerFullName + '"'
sParams = sParams + ' -D STMMI_PACKAGER_EMAIL="' + g_sPackagerEMail + '"'
sParams = sParams + ' -D STMMI_AUTHOR_FULLNAME="' + sAuthorFullName + '"'
sParams = sParams + ' -D STMMI_AUTHOR_EMAIL="' + sAuthorEMail + '"'
subprocess.check_call("cmake " + sParams + " -P " + sPrivScriptDirPath + "/debian_src_versions.cmake", shell=True)
if bDoFileName:
os.close(oFd1)
os.close(oFd2)
os.remove(sTmpPath1)
os.remove(sTmpPath2)
#==============================================================================
# sPrjName: ex. stmm-input or libstmm-input-gtk
# returns (sLastVersion, oDate, sText, sAuthorFullName, sAuthorEMail)
def getLastVersionAndDateFromChanged(sPrjName, sChangedFilePath, nSkip):
sChangeEntryRegex = "^" + sPrjName + " \((" + g_sVersionCommonRegex + ")\) .*$"
oChangeEntryPatt = re.compile(sChangeEntryRegex)
sLastVersion = ""
oDate = datetime.datetime.now()
try:
oF = open(sChangedFilePath, 'r')
except PermissionError:
return ("", oDate, "", "", "") #---------------
sText = ""
bWithinEntry = False
for sLine in oF:
oMatch = oChangeEntryPatt.search(sLine)
if oMatch:
if nSkip < 0:
raise RuntimeError("Changes file '" + sChangedFilePath + "' faulty: entry start without end")
sLastVersion = oMatch.group(1);
bWithinEntry = True
else:
oMatch = g_oChangeDatePatt.search(sLine)
if oMatch:
if not bWithinEntry:
raise RuntimeError("Changes file '" + sChangedFilePath + "' faulty: entry end without start")
bWithinEntry = False
nSkip = nSkip -1
#
sAuthorFullName = oMatch.group(1)
sAuthorEMail = oMatch.group(2)
sDateTimeTz = oMatch.group(3)
#print("sAuthorFullName=" + sAuthorFullName)
#print("sAuthorEMail=" + sAuthorEMail)
#print("sDateTimeTz=" + sDateTimeTz)
try:
oDate = email.utils.parsedate_to_datetime(sDateTimeTz)
except:
raise RuntimeError("Changes file '" + sChangedFilePath + "' faulty: date and time incorrect")
#
if nSkip < 0:
break
if bWithinEntry:
if sText != "":
sText = sText + "\n"
sText = sText + sLine
else:
if bWithinEntry:
raise RuntimeError("Changes file '" + sChangedFilePath + "' faulty: entry start without end")
return ("", oDate, "", "" , "") #---------------
return (sLastVersion, oDate, sText, sAuthorFullName, sAuthorEMail)
#==============================================================================
def main():
import argparse
oParser = argparse.ArgumentParser(description="Create ARCH PKGBUILD.\n"
" If not defined environment variable DEBFULLNAME is set to '"
+ g_sDefaultPackagerFullName + "',\n"
" and DEBEMAIL is set to '" + g_sDefaultPackagerEMail + "'"
, formatter_class=argparse.RawDescriptionHelpFormatter)