Skip to content

Commit

Permalink
resolving more MacOS edgecases
Browse files Browse the repository at this point in the history
* Finally fixes app bundle include path resolution on the command line!

* NVGT now changes to the current directory of the script when the open command is invoked as well.

* Shared libraries in the MacOS app bundle are now located for copying properly.

This rereleases 0.89.1-beta.
  • Loading branch information
samtupy committed Oct 10, 2024
1 parent 29f62ba commit a49d9bd
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
3 changes: 2 additions & 1 deletion doc/src/appendix/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ This document lists all major changes that have taken place in NVGT since we sta

## New in 0.89.1-beta (10/09/2024):
* Fixes copying of shared libraries while bundling on MacOS which was resulting in an assertion violation from Poco.
* Fixes MacOS not changing to the directory of scripts launched from finder.
* Fixes MacOS not changing to the directory of scripts launched from finder or the open command.
* Hopefully we've finally resolved all of the MacOS includes resolution issues, there should be no more manually adding include paths to your scripts or command line invocations!
* Fixes the enter key not pressing the default button in audio form lists.
* Linux cross compilation should work again, the Linux build script was pulling down the wrong version of Angelscript.
* `#pragma platform` has been deprecated, you should use the command line / menu options / UI to specify platforms instead.
Expand Down
2 changes: 1 addition & 1 deletion doc/src/manual/compiling your project for distribution.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ When compiling on a non-windows platform, the executable permission bitt on the
* Now run /path/to/nvgt -c scriptname.nvgt where scriptname.nvgt should of course be replaced with the name of your script file. You can select a platform with the -p argument E. -pwindows.
* On Mac OS, it's best to just click on the NVGT application directly.
* After launching NVGT you can select compile a script in release/debug mode, choose a platform, and browse to your script file.
* If, however, you wish to build on MacOS using the command line, cd to the directory containing a .nvgt script and run the convoluted and to be improved command /applications/nvgt.app/Contents/MacOS/nvgt ``pwd``/scriptname.nvgt -I/applications/nvgt.app/Contents/Resources/include
* If, however, you wish to build on MacOS using the command line, cd to the directory containing a .nvgt script and run the command /applications/nvgt.app/Contents/MacOS/nvgt -c scriptname.nvgt, or alternatively open -a nvgt --args -c \`pwd\`/scriptname.nvgt

You will receive a popup or STDOut print letting you know how long the compilation took. You should find a new file in the same folder you just compiled that has the same name it does but with a different extension e.g. when compiling my_game.nvgt you'll have my_game.exe. Distribute this along with the necessary libraries in what ever form is required. You can set it all up with an installer, such as Inno Setup, or if your game will be portable you can just zip it up, etc.

Expand Down
9 changes: 6 additions & 3 deletions src/nvgt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,11 @@ class nvgt_application : public Poco::Util::Application {
config().setString("application.gui", "");
#ifdef NVGT_STUB
ChDir(resources_dir);
#else
g_IncludeDirs.push_back(Path(resources_dir).pushDirectory("include").toString());
#endif
}
#ifndef NVGT_STUB
if (File(resources_dir).exists()) g_IncludeDirs.push_back(Path(resources_dir).pushDirectory("include").toString());
#endif
#elif defined(__ANDROID__)
config().setString("application.gui", "");
#endif
Expand Down Expand Up @@ -210,7 +211,6 @@ class nvgt_application : public Poco::Util::Application {
string scriptfile = "";
#if defined(__APPLE__) || defined(__ANDROID__)
scriptfile = event_requested_file(); // Files opened from external apps on MacOS, IOS, and Android do not use command line arguments.
if (!scriptfile.empty()) ChDir(Path(scriptfile).makeParent().toString());
#endif
if (scriptfile.empty() && args.size() > 0) scriptfile = args[0];
if (scriptfile.empty() && config().hasOption("application.gui")) scriptfile = UILauncher();
Expand All @@ -227,6 +227,9 @@ class nvgt_application : public Poco::Util::Application {
message("error, no input files.\nType " + commandName() + " --help for usage instructions\n", commandName());
return Application::EXIT_USAGE;
}
#ifdef __APPLE__ // When run from an app bundle
if (!scriptfile.empty() && Path::current() == "/") ChDir(Path(scriptfile).makeParent().toString());
#endif
#ifndef __ANDROID__ // for now the following code would be highly unstable on android due to it's content URIs.
try {
// Parse the provided script path to insure it is valid and check if it is a file.
Expand Down
5 changes: 3 additions & 2 deletions src/xplatform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,15 @@ void xplatform_correct_path_to_stubs(Poco::Path& stubpath) {
std::string get_nvgt_lib_directory(const std::string& platform) {
// The directory containing the libraries for the NVGT currently running is usually just called lib, while all other directories are lib_platform. In any case try to return an absolute path to the libraries given a platform.
std::string dir;
bool apple_bundle = File(Path(Path::self()).makeParent().makeParent().pushDirectory("Frameworks").toString()).exists();
if (platform == "windows") dir = Poco::Environment::isWindows()? "lib" : "lib_windows";
else if (platform == "mac") dir = Environment::os() == POCO_OS_MAC_OS_X? (Environment::has("MACOS_BUNDLED_APP")? "Frameworks" : "lib") : "lib_mac";
else if (platform == "mac") dir = Environment::os() == POCO_OS_MAC_OS_X? (apple_bundle? "Frameworks" : "lib") : "lib_mac";
else if (platform == "linux") dir = Poco::Environment::os() == POCO_OS_LINUX? "lib" : "lib_linux";
else return ""; // libs not applicable for this platform.
Path result(Path::self());
result.makeParent();
#ifdef __APPLE__
if (Environment::has("MACOS_BUNDLED_APP")) {
if (apple_bundle) {
result.makeParent();
if (platform != "mac") result.append("Resources");
}
Expand Down

0 comments on commit a49d9bd

Please sign in to comment.