diff --git a/.gitignore b/.gitignore index 83ce8ae..882b457 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,8 @@ doc/mockups/* data/pieces/*.bin data/config/*.bin data/config/keybinds/*.bin + +# flatpak files +flatpak/.flatpak-builder +flatpak/builddir +flatpak/repo diff --git a/flatpak/FlatpakLaunch.sh b/flatpak/FlatpakLaunch.sh new file mode 100644 index 0000000..8fe4e97 --- /dev/null +++ b/flatpak/FlatpakLaunch.sh @@ -0,0 +1,2 @@ +#!/bin/sh +JMINOS_DATA="/app/share" JMINOS_CONFIG=$XDG_CONFIG_HOME /app/bin/graph \ No newline at end of file diff --git a/flatpak/org.zulianc.jminos.desktop b/flatpak/org.zulianc.jminos.desktop new file mode 100644 index 0000000..7eed97a --- /dev/null +++ b/flatpak/org.zulianc.jminos.desktop @@ -0,0 +1,9 @@ +[Desktop Entry] +Type=Application +Version=1.0 +Name=Jminos +Exec=/usr/bin/graph +Icon=org.zulianc.jminos +Terminal=false +Categories=Game; +Comment=Amazing stacker game by the J \ No newline at end of file diff --git a/flatpak/org.zulianc.jminos.ico b/flatpak/org.zulianc.jminos.ico new file mode 100644 index 0000000..52079c1 Binary files /dev/null and b/flatpak/org.zulianc.jminos.ico differ diff --git a/flatpak/org.zulianc.jminos.metainfo.xml b/flatpak/org.zulianc.jminos.metainfo.xml new file mode 100644 index 0000000..88ec0be --- /dev/null +++ b/flatpak/org.zulianc.jminos.metainfo.xml @@ -0,0 +1,71 @@ + + + org.zulianc.jminos + org.zulianc.jminos.desktop + jminos + Zulianc + Amazing stacker game by the J + + https://git.ale-pri.com/TetrisNerd/jminos + +

+ Modern stacker game with every polyominoes from size 1 to 15, made in C++ with SFML 3! +

+

Features

+ +

Available gamemodes

+ +
+ + + org.zulianc.jminos.desktop + + + Game + + + + Big piece + https://git.ale-pri.com/TetrisNerd/jminos/raw/branch/main/doc/readme/big_piece.png + + + Pieces selection + https://git.ale-pri.com/TetrisNerd/jminos/media/branch/main/doc/readme/pieces_selection.png + + + Rotations + https://git.ale-pri.com/TetrisNerd/jminos/media/branch/main/doc/readme/rotations.gif + + + Rotation_0 + https://git.ale-pri.com/TetrisNerd/jminos/media/branch/main/doc/readme/rotation_0.gif + + + + + https://git.ale-pri.com/TetrisNerd/jminos/src/tag/v1.0/ + + Inital release + + + + +
\ No newline at end of file diff --git a/flatpak/org.zulianc.jminos.png b/flatpak/org.zulianc.jminos.png new file mode 100644 index 0000000..f07208d Binary files /dev/null and b/flatpak/org.zulianc.jminos.png differ diff --git a/flatpak/org.zulianc.jminos.yml b/flatpak/org.zulianc.jminos.yml new file mode 100644 index 0000000..caad499 --- /dev/null +++ b/flatpak/org.zulianc.jminos.yml @@ -0,0 +1,31 @@ +app-id: org.zulianc.jminos +runtime: org.freedesktop.Platform +runtime-version: "24.08" +sdk: org.freedesktop.Sdk +command: FlatpakLaunch.sh + +finish-args: + - --socket=x11 + - --device=dri + +modules: + - xmake.yml + + - name: jminos + buildsystem: simple + build-options: + build-args: + - --share=network + build-commands: + - xmake f --policies=package.install_locally --external_build=y -m release -y + - xmake + - xmake install -o output + - install -D output/bin/* /app/bin + - cp -r output/data /app/share + - install -D flatpak/FlatpakLaunch.sh /app/bin + - install -D -t /app/share/applications flatpak/${FLATPAK_ID}.desktop + - install -Dm644 flatpak/${FLATPAK_ID}.metainfo.xml /app/share/metainfo/${FLATPAK_ID}.metainfo.xml + - install -D flatpak/${FLATPAK_ID}.png /app/share/icons/hicolor/512x512/apps/${FLATPAK_ID}.png + sources: + - type: dir + path: .. diff --git a/flatpak/xmake.yml b/flatpak/xmake.yml new file mode 100644 index 0000000..b9797cf --- /dev/null +++ b/flatpak/xmake.yml @@ -0,0 +1,12 @@ +name: xmake +buildsystem: simple +no-autogen: true +cleanup: ['*'] +build-commands: + - ./configure --prefix=/app + - make -j $(FLATPAK_BUILDER_N_JOBS) + - prefix=/app ./scripts/get.sh __local__ __install_only__ +sources: + - type: git + url: https://github.com/xmake-io/xmake.git + tag: v3.0.1 diff --git a/src/GraphicalUI/AppMenus/AppMenu.cpp b/src/GraphicalUI/AppMenus/AppMenu.cpp index b927da6..20e0eb5 100644 --- a/src/GraphicalUI/AppMenus/AppMenu.cpp +++ b/src/GraphicalUI/AppMenus/AppMenu.cpp @@ -15,9 +15,7 @@ AppMenu::AppMenu(std::shared_ptr menuStack, std::shared_ptr settings(settings), renderWindow(renderWindow) { - const Asset& file = getResource(AssetName::data_fonts_pressstart_prstartk_ttf); - - this->pressStartFont = sf::Font(file.data, file.size); + this->pressStartFont = sf::Font(AssetManager::getResourcePath("data/fonts/pressstart/prstart.ttf")); } void AppMenu::updateMetaBinds() { diff --git a/src/GraphicalUI/AppMenus/SettingsKeybindsAppMenu.cpp b/src/GraphicalUI/AppMenus/SettingsKeybindsAppMenu.cpp index 95bec2c..f308f16 100644 --- a/src/GraphicalUI/AppMenus/SettingsKeybindsAppMenu.cpp +++ b/src/GraphicalUI/AppMenus/SettingsKeybindsAppMenu.cpp @@ -23,9 +23,7 @@ SettingsKeybindsAppMenu::SettingsKeybindsAppMenu(std::shared_ptr menu std::string textureName = ACTION_NAMES[action]; textureName = std::regex_replace(textureName, std::regex(" "), ""); - const Asset& textureData = getResource("data/images/keybinds/" + textureName + ".png"); - - this->iconTextures[action] = sf::Texture(textureData.data, textureData.size, false, {{0, 0}, {16, 16}}); + this->iconTextures[action] = sf::Texture(AssetManager::getResourcePath("data/images/keybinds/" + textureName + ".png"), false, {{0, 0}, {16, 16}}); } } diff --git a/src/GraphicalUI/Keybinds.cpp b/src/GraphicalUI/Keybinds.cpp index f4a1c67..bb70708 100644 --- a/src/GraphicalUI/Keybinds.cpp +++ b/src/GraphicalUI/Keybinds.cpp @@ -6,6 +6,7 @@ #include #include #include +#include "../Utils/AssetManager.h" Keybinds::Keybinds(int layoutNumber) : @@ -20,7 +21,7 @@ Keybinds::Keybinds(int layoutNumber) : } void Keybinds::loadKeybindsFromFile() { - std::ifstream layoutFile("data/config/keybinds/layout" + std::to_string(this->layoutNumber) + ".bin", std::ios::binary); + std::ifstream layoutFile(AssetManager::getConfigPath("data/config/keybinds/layout" + std::to_string(this->layoutNumber) + ".bin"), std::ios::binary); for (Action action : ACTION_LIST_IN_ORDER) { this->keybinds.at(action).clear(); @@ -47,7 +48,7 @@ void Keybinds::loadKeybindsFromFile() { void Keybinds::saveKeybindsToFile() const { if (!this->modifiable) return; - std::ofstream layoutFile("data/config/keybinds/layout" + std::to_string(this->layoutNumber) + ".bin", std::ios::trunc | std::ios::binary); + std::ofstream layoutFile(AssetManager::getConfigPath("data/config/keybinds/layout" + std::to_string(this->layoutNumber) + ".bin"), std::ios::trunc | std::ios::binary); char byte; for (Action action : ACTION_LIST_IN_ORDER) { diff --git a/src/GraphicalUI/Settings.cpp b/src/GraphicalUI/Settings.cpp index 0c84bac..13a2185 100644 --- a/src/GraphicalUI/Settings.cpp +++ b/src/GraphicalUI/Settings.cpp @@ -3,6 +3,7 @@ #include "../Core/Menu.h" #include "Keybinds.h" #include "PiecesType.h" +#include "../Utils/AssetManager.h" #include #include @@ -49,7 +50,7 @@ void Settings::loadPieces(int loadablePiecesSizeRequest) { } void Settings::loadSettingsFromFile(bool loadPieces, std::optional loadablePiecesSizeRequest) { - std::ifstream settingsFile("data/config/settings.bin", std::ios::binary); + std::ifstream settingsFile(AssetManager::getConfigPath("data/config/settings.bin"), std::ios::binary); char byte; // file format version @@ -158,7 +159,7 @@ void Settings::saveSettingsToFile() const { this->keybinds.at(CUSTOMIZABLE_KEYBINDS).saveKeybindsToFile(); - std::ofstream settingsFile("data/config/settings.bin", std::ios::trunc | std::ios::binary); + std::ofstream settingsFile(AssetManager::getConfigPath("data/config/settings.bin"), std::ios::trunc | std::ios::binary); char byte; // file format version diff --git a/src/GraphicalUI/main.cpp b/src/GraphicalUI/main.cpp index a625522..9a3c417 100644 --- a/src/GraphicalUI/main.cpp +++ b/src/GraphicalUI/main.cpp @@ -4,11 +4,13 @@ #include #include +#include "../Utils/AssetManager.h" + [[nodiscard]] bool resetSettingsFile(); [[nodiscard]] bool resetKeybindFile(int layout); -int main() { +int main(int arc, char** args) { std::srand(std::time(NULL)); bool everythingIsOK = true; @@ -18,7 +20,7 @@ int main() { PiecesFiles pf; bool warned = false; for (int i = 1; i <= MAXIMUM_PIECES_SIZE; i++) { - if (!std::filesystem::exists("data/pieces/" + std::to_string(i) + "minos.bin")) { + if (!std::filesystem::exists(AssetManager::getResourcePath("data/pieces/" + std::to_string(i) + "minos.bin"))) { #ifndef DEBUG if (!warned && i > DEBUG_PIECES_SIZE) { std::cout << "IMPORTANT: You are currently in release mode, if you do not wish to generate big pieces (can take several minutes), type 'xmake f -m debug'." << std::endl; @@ -36,7 +38,7 @@ int main() { bool releasePiecesGenerated = true; for (int i = DEBUG_PIECES_SIZE + 1; i <= RELEASE_PIECES_SIZE; i++) { - if (!std::filesystem::exists("data/pieces/" + std::to_string(i) + "minos.bin")) { + if (!std::filesystem::exists(AssetManager::getResourcePath("data/pieces/" + std::to_string(i) + "minos.bin"))) { releasePiecesGenerated = false; } } @@ -47,29 +49,29 @@ int main() { bool everythingGenerated = true; for (int i = 1; i <= MAXIMUM_PIECES_SIZE; i++) { - std::string filePath = "data/pieces/" + std::to_string(i) + "minos.bin"; + auto filePath = AssetManager::getResourcePath("data/pieces/" + std::to_string(i) + "minos.bin"); if (!std::filesystem::exists(filePath)) { - std::cout << "ERROR: Could not open file " + filePath << std::endl; + std::cout << "ERROR: Could not open file " << filePath << std::endl; everythingIsOK &= false; } } // CHECK CONFIG FILES - if (!std::filesystem::exists("data/config/settings.bin")) { + if (!std::filesystem::exists(AssetManager::getConfigPath("data/config/settings.bin"))) { std::cout << "INFO: Settings file not found, generating..." << std::endl; everythingIsOK &= resetSettingsFile(); for (int i = 0; i < NUMBER_OF_KEYBINDS; i++) { - if (!std::filesystem::exists("data/config/keybinds/layout" + std::to_string(i) + ".bin")) { + if (!std::filesystem::exists(AssetManager::getConfigPath("data/config/keybinds/layout" + std::to_string(i) + ".bin"))) { std::cout << "INFO: Keybind file number " << (i + 1) << "/" << NUMBER_OF_KEYBINDS << " not found, generating..." << std::endl; everythingIsOK &= resetKeybindFile(i); } } } else { - std::ifstream settingsFile("data/config/settings.bin", std::ios::binary); + std::ifstream settingsFile(AssetManager::getConfigPath("data/config/settings.bin"), std::ios::binary); char byte; settingsFile.get(byte); @@ -99,14 +101,14 @@ int main() { bool resetSettingsFile() { - if (!std::filesystem::exists("data/config")) { - std::filesystem::create_directories("data/config"); + if (!std::filesystem::exists(AssetManager::getConfigPath("data/config"))) { + std::filesystem::create_directories(AssetManager::getConfigPath("data/config")); } - std::string filePath ="data/config/settings.bin"; + auto filePath = AssetManager::getConfigPath("data/config/settings.bin"); std::ofstream settingsFile(filePath, std::ios::trunc | std::ios::binary); if (!settingsFile.good()) { - std::cerr << "ERROR: Could not open file " + filePath << std::endl; + std::cerr << "ERROR: Could not open file " << filePath << std::endl; return false; } @@ -180,14 +182,14 @@ bool resetKeybindFile(int layout) { return false; } - if (!std::filesystem::exists("data/config/keybinds")) { - std::filesystem::create_directories("data/config/keybinds"); + if (!std::filesystem::exists(AssetManager::getConfigPath("data/config/keybinds"))) { + std::filesystem::create_directories(AssetManager::getConfigPath("data/config/keybinds")); } - std::string filePath = "data/config/keybinds/layout" + std::to_string(layout) + ".bin"; + auto filePath = AssetManager::getConfigPath("data/config/keybinds/layout" + std::to_string(layout) + ".bin"); std::ofstream layoutFile(filePath, std::ios::trunc | std::ios::binary); if (!layoutFile.good()) { - std::cerr << "ERROR: Could not open file " + filePath << std::endl; + std::cerr << "ERROR: Could not open file " << filePath << std::endl; return false; } diff --git a/src/Pieces/PiecesFiles.cpp b/src/Pieces/PiecesFiles.cpp index 6500f41..da491d4 100644 --- a/src/Pieces/PiecesFiles.cpp +++ b/src/Pieces/PiecesFiles.cpp @@ -11,6 +11,7 @@ #include #include "../Common/Compression.h" +#include "../Utils/AssetManager.h" PiecesFiles::PiecesFiles() { @@ -140,7 +141,7 @@ bool PiecesFiles::loadPieces(int polyominoSize, std::vector& pieces, std: } bool PiecesFiles::getFilePath(int polyominoSize, std::string& filePath) const { - std::string dataFolderPath = "data/pieces/"; + auto dataFolderPath = AssetManager::getResourcePath("data/pieces"); if (!std::filesystem::exists(dataFolderPath)) { std::filesystem::create_directories(dataFolderPath); @@ -150,6 +151,6 @@ bool PiecesFiles::getFilePath(int polyominoSize, std::string& filePath) const { return false; } - filePath = dataFolderPath + std::to_string(polyominoSize) + "minos.bin"; + filePath = (dataFolderPath / (std::to_string(polyominoSize) + "minos.bin")).string(); return true; } diff --git a/src/TextUI/main.cpp b/src/TextUI/main.cpp index 6634373..2a360d8 100644 --- a/src/TextUI/main.cpp +++ b/src/TextUI/main.cpp @@ -1,6 +1,7 @@ #include "../Pieces/Generator.h" #include "../Pieces/PiecesFiles.h" #include "TextApp.h" +#include "../Utils/AssetManager.h" #include #include @@ -22,7 +23,7 @@ int main(int argc, char** argv) { PiecesFiles pf; bool warned = false; for (int i = 1; i <= MAXIMUM_PIECES_SIZE; i++) { - if (!std::filesystem::exists("data/pieces/" + std::to_string(i) + "minos.bin")) { + if (!std::filesystem::exists(AssetManager::getResourcePath("data/pieces/" + std::to_string(i) + "minos.bin"))) { if (!warned) { std::cout << "INFO: Pieces files for size " << i << " not found, generating..." << std::endl; warned = true; diff --git a/src/Utils/AssetManager.cpp b/src/Utils/AssetManager.cpp index 75b2c5d..3baf127 100644 --- a/src/Utils/AssetManager.cpp +++ b/src/Utils/AssetManager.cpp @@ -1,97 +1,42 @@ -#include "./AssetManager.h" +#include "AssetManager.h" -#include +#ifdef _WIN32 +#include //GetModuleFileNameW +#else +#include +#include //readlink +#endif -static const unsigned char data_fonts_pressstart_prstart_ttf[] = { - #include -}; +namespace fs = std::filesystem; -static const unsigned char data_fonts_pressstart_prstartk_ttf[] = { - #include -}; - -static const unsigned char data_images_keybinds_Rotate180_png[] = { - #include -}; - -static const unsigned char data_images_keybinds_Rotate0_png[] = { - #include -}; - -static const unsigned char data_images_keybinds_RotateCCW_png[] = { - #include -}; - -static const unsigned char data_images_keybinds_Retry_png[] = { - #include -}; - -static const unsigned char data_images_keybinds_RotateCW_png[] = { - #include -}; - -static const unsigned char data_images_keybinds_Moveright_png[] = { - #include -}; - -static const unsigned char data_images_keybinds_Harddrop_png[] = { - #include -}; - -static const unsigned char data_images_keybinds_Moveleft_png[] = { - #include -}; - -static const unsigned char data_images_keybinds_Hold_png[] = { - #include -}; - -static const unsigned char data_images_keybinds_Softdrop_png[] = { - #include -}; - -static const unsigned char data_images_keybinds_Pause_png[] = { - #include -}; - -static const Asset assets[] = { - {data_fonts_pressstart_prstart_ttf, sizeof(data_fonts_pressstart_prstart_ttf)}, - {data_fonts_pressstart_prstartk_ttf, sizeof(data_fonts_pressstart_prstartk_ttf)}, - {data_images_keybinds_Rotate180_png, sizeof(data_images_keybinds_Rotate180_png)}, - {data_images_keybinds_Rotate0_png, sizeof(data_images_keybinds_Rotate0_png)}, - {data_images_keybinds_RotateCCW_png, sizeof(data_images_keybinds_RotateCCW_png)}, - {data_images_keybinds_Retry_png, sizeof(data_images_keybinds_Retry_png)}, - {data_images_keybinds_RotateCW_png, sizeof(data_images_keybinds_RotateCW_png)}, - {data_images_keybinds_Moveright_png, sizeof(data_images_keybinds_Moveright_png)}, - {data_images_keybinds_Harddrop_png, sizeof(data_images_keybinds_Harddrop_png)}, - {data_images_keybinds_Moveleft_png, sizeof(data_images_keybinds_Moveleft_png)}, - {data_images_keybinds_Hold_png, sizeof(data_images_keybinds_Hold_png)}, - {data_images_keybinds_Softdrop_png, sizeof(data_images_keybinds_Softdrop_png)}, - {data_images_keybinds_Pause_png, sizeof(data_images_keybinds_Pause_png)}, - -}; - -static const std::map assetMap = { - {"data/fonts/pressstart/prstart.ttf", AssetName::data_fonts_pressstart_prstart_ttf}, - {"data/fonts/pressstart/prstartk.ttf", AssetName::data_fonts_pressstart_prstartk_ttf}, - {"data/images/keybinds/Rotate180.png", AssetName::data_images_keybinds_Rotate180_png}, - {"data/images/keybinds/Rotate0.png", AssetName::data_images_keybinds_Rotate0_png}, - {"data/images/keybinds/RotateCCW.png", AssetName::data_images_keybinds_RotateCCW_png}, - {"data/images/keybinds/Retry.png", AssetName::data_images_keybinds_Retry_png}, - {"data/images/keybinds/RotateCW.png", AssetName::data_images_keybinds_RotateCW_png}, - {"data/images/keybinds/Moveright.png", AssetName::data_images_keybinds_Moveright_png}, - {"data/images/keybinds/Harddrop.png", AssetName::data_images_keybinds_Harddrop_png}, - {"data/images/keybinds/Moveleft.png", AssetName::data_images_keybinds_Moveleft_png}, - {"data/images/keybinds/Hold.png", AssetName::data_images_keybinds_Hold_png}, - {"data/images/keybinds/Softdrop.png", AssetName::data_images_keybinds_Softdrop_png}, - {"data/images/keybinds/Pause.png", AssetName::data_images_keybinds_Pause_png}, - -}; - -const Asset& getResource(AssetName fileName) { - return assets[static_cast(fileName)]; +static fs::path getExeDirectory(){ + #ifdef _WIN32 + wchar_t path[MAX_PATH] = { 0 }; + GetModuleFileNameW(NULL, path, MAX_PATH); + return path; +#else + char result[PATH_MAX]; + ssize_t count = readlink("/proc/self/exe", result, PATH_MAX); + return std::string(result, (count > 0) ? count : 0); +#endif } -const Asset& getResource(const std::string& fileName) { - return getResource(assetMap.at(fileName)); + + +static fs::path getEnv(const std::string& var) { + char* env = std::getenv(var.c_str()); + return env ? env : +#ifdef JMINOS_IGNORE_WORKDIR + getExeDirectory().parent_path().parent_path(); +#else + ""; +#endif } + +fs::path AssetManager::getResourcePath(const std::string& resource) { + return fs::path{getEnv("JMINOS_DATA")} / resource; +} + +fs::path AssetManager::getConfigPath(const std::string& resource) { + return fs::path{getEnv("JMINOS_CONFIG")} / resource; +} \ No newline at end of file diff --git a/src/Utils/AssetManager.h b/src/Utils/AssetManager.h index e4eacae..ab36e94 100644 --- a/src/Utils/AssetManager.h +++ b/src/Utils/AssetManager.h @@ -2,29 +2,17 @@ #include #include +#include -struct Asset { - const unsigned char* data; - std::size_t size; -}; +class AssetManager { + public: + /** + * @brief Used to load things (might be read-only) + */ + static std::filesystem::path getResourcePath(const std::string& resource); -enum class AssetName { - data_fonts_pressstart_prstart_ttf, - data_fonts_pressstart_prstartk_ttf, - data_images_keybinds_Rotate180_png, - data_images_keybinds_Rotate0_png, - data_images_keybinds_RotateCCW_png, - data_images_keybinds_Retry_png, - data_images_keybinds_RotateCW_png, - data_images_keybinds_Moveright_png, - data_images_keybinds_Harddrop_png, - data_images_keybinds_Moveleft_png, - data_images_keybinds_Hold_png, - data_images_keybinds_Softdrop_png, - data_images_keybinds_Pause_png, - -}; - -const Asset& getResource(AssetName fileName); - -const Asset& getResource(const std::string& fileName); + /** + * @brief Used to save things + */ + static std::filesystem::path getConfigPath(const std::string& resource); +}; \ No newline at end of file diff --git a/xmake.lua b/xmake.lua index d579661..3d4c59a 100644 --- a/xmake.lua +++ b/xmake.lua @@ -1,8 +1,20 @@ add_rules("mode.debug", "mode.release") -includes("xmake/bin2c.lua") +set_version("1.0.0") +set_project("org.zulianc.jminos") -add_requires("sfml 3.0.0", "zlib") +includes("@builtin/xpack") + +option("external_build") + set_default(false) +option_end() + +if has_config("external_build") then + add_requires("sfml 3.0.0", "zlib", {system = false}) + add_defines("JMINOS_IGNORE_WORKDIR") +else + add_requires("sfml 3.0.0", "zlib") +end set_languages("c++20") @@ -10,7 +22,7 @@ set_rundir(".") target("core") set_kind("$(kind)") - add_files("src/Pieces/*.cpp", "src/Core/*.cpp", "src/Common/*.cpp") + add_files("src/Pieces/*.cpp", "src/Core/*.cpp", "src/Common/*.cpp", "src/Utils/*.cpp") add_packages("zlib") target("text") @@ -27,16 +39,11 @@ target("bmark") target("graph") set_default(true) - add_rules("bin2c", { - extensions = {".png", ".ttf"}, - outputSource = {"src/Utils/AssetManager.cpp"}, - outputHeader = {"src/Utils/AssetManager.h"} - }) set_kind("binary") add_files("./src/GraphicalUI/**.cpp") - add_files("data/fonts/**.ttf", "data/images/**.png") add_deps("core") add_packages("sfml") + add_installfiles("(data/**)") if is_mode("debug") then add_defines("DEBUG") @@ -46,6 +53,7 @@ if is_plat("mingw") then add_ldflags("-static-libstdc++", "-static") end +includes("xmake/xpack.lua") -- -- If you want to known more usage about xmake, please see https://xmake.io diff --git a/xmake/xpack.lua b/xmake/xpack.lua new file mode 100644 index 0000000..6f824c1 --- /dev/null +++ b/xmake/xpack.lua @@ -0,0 +1,36 @@ +if is_os("linux") then + +xpack("jminos") + set_formats("flatpak") + set_extension("flatpak") + set_title("jminos") + set_author("zulianc") + set_description("A test installer.") + set_homepage("https://git.ale-pri.com/TetrisNerd/jminos") + set_company("org.zulianc") + on_package(function (package) + os.cd("flatpak") + os.exec("flatpak install org.flatpak.Builder --user -y") + os.exec("flatpak run org.flatpak.Builder --force-clean --user --install-deps-from=flathub --repo=repo --install builddir org.zulianc.jminos.yml") + os.exec("flatpak build-bundle repo jminos.flatpak org.zulianc.jminos --runtime-repo=https://flathub.org/repo/flathub.flatpakrepo") + os.mv("jminos.flatpak", package:outputdir()) + end) + on_load(function (package) + package:set("basename", package:name() .. "-v" .. package:version() .. "-" .. package:arch()) + end) + +else + +xpack("jminos") + set_formats("zip", "nsis") + add_targets("graph") + add_installfiles("(data/**.png)") + set_iconfile("../flatpak/org.zulianc.jminos.ico") + on_load(function (package) + package:set("basename", package:name() .. "-v" .. package:version() .. "-" .. package:arch()) + end) + after_installcmd(function (package, batchcmds) + batchcmds:rm(package:installdir("**/.gitkeep")) + end) + +end