xpack install #7

Open
Persson-dev wants to merge 12 commits from xpack into main
6 changed files with 32 additions and 10 deletions
Showing only changes of commit 7977fb976b - Show all commits

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@@ -10,11 +10,13 @@
[[nodiscard]] bool resetKeybindFile(int layout);
int main() {
int main(int arc, char** args) {
std::srand(std::time(NULL));
bool everythingIsOK = true;
AssetManager::setExePath(args[0]);
// CHECK PIECES FILES
PiecesFiles pf;

View File

@@ -2,9 +2,20 @@
namespace fs = std::filesystem;
static std::string getEnv(const std::string& var) {
static fs::path EXE_DIRECTORY;
void AssetManager::setExePath(const std::string& arg0) {
EXE_DIRECTORY = fs::path(arg0).parent_path();
}
static fs::path getEnv(const std::string& var) {
char* env = std::getenv(var.c_str());
return env ? env : "";
return env ? env :
#ifdef JMINOS_IGNORE_WORKDIR
EXE_DIRECTORY.parent_path();
#else
"";
#endif
}
fs::path AssetManager::getResourcePath(const std::string& resource) {

View File

@@ -15,4 +15,9 @@ class AssetManager {
* @brief Used to save things
*/
static std::filesystem::path getConfigPath(const std::string& resource);
/**
* @brief Set the current path of the executable
*/
static void setExePath(const std::string& arg0);
};

View File

@@ -11,6 +11,7 @@ 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
@@ -52,7 +53,7 @@ if is_plat("mingw") then
add_ldflags("-static-libstdc++", "-static")
end
includes("./xpack.lua")
includes("xmake/xpack.lua")
--
-- If you want to known more usage about xmake, please see https://xmake.io

View File

@@ -10,24 +10,27 @@ xpack("jminos")
set_company("org.zulianc")
on_package(function (package)
os.cd("flatpak")
os.exec("flatpak-builder --force-clean --user --install-deps-from=flathub --repo=repo --install builddir org.zulianc.jminos.yml")
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")
set_formats("zip", "nsis")
add_targets("graph")
add_installfiles("(data/**.png)")
on_load(function (package)
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:mv(path.join(package:installdir("bin"), "*"), package:installdir())
batchcmds:rm(package:installdir("bin"))
batchcmds:rm(package:installdir("**/.gitkeep"))
end)
end
end