forked from Aeva/tangerine
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This change integrates the library "whereami" to determine the path of the running executable. See https://github.com/gpakosz/whereami for more details. This allows us to have consistent behavior across all build configurations. I also added a fallback case for when it fails on Linux, to add an additional hint if the proc filesystem is missing. This may be useful to help people attempting to run Tangerine from an improperly configured chroot environment without downgrading to behavior that might be less secure such as using argv 0 as a fallback.
- Loading branch information
Showing
31 changed files
with
2,572 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,3 +90,19 @@ if (ImGui::BeginTabItem("voxwriter")) | |
ImGui::EndTabItem(); | ||
} | ||
#endif | ||
|
||
#if 1 | ||
if (ImGui::BeginTabItem("whereami")) | ||
{ | ||
ImGui::TextUnformatted("MIT License\n\nCopyright Gregory Pakosz\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\nthe Software, and to permit persons to whom the Software is furnished to do so,\nsubject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\nFOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\nCOPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\nIN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n", nullptr); | ||
ImGui::EndTabItem(); | ||
} | ||
#endif | ||
|
||
#if 1 | ||
if (ImGui::BeginTabItem("whereami")) | ||
{ | ||
ImGui::TextUnformatted("--------------------------------------------------------------------------------\n DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE\n Version 2, December 2004\n\n Copyright (C) 2004 Sam Hocevar <[email protected]>\n\n Everyone is permitted to copy and distribute verbatim or modified\n copies of this license document, and changing it is allowed as long\n as the name is changed.\n\n DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE\n TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION\n\n 0. You just DO WHAT THE FUCK YOU WANT TO.\n 1. Bla bla bla\n 2. Montesqieu et camembert, vive la France, zut alors!\n\n--------------------------------------------------------------------------------\n\nWTFPLv2 is very permissive, see http://www.wtfpl.net/faq/\n\nHowever, if this WTFPLV2 is REALLY a blocker and is the reason you can't use\nthis project, contact me and I'll dual license it.\n\n--------------------------------------------------------------------------------\n", nullptr); | ||
ImGui::EndTabItem(); | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
MIT License | ||
|
||
Copyright Gregory Pakosz | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
this software and associated documentation files (the "Software"), to deal in | ||
the Software without restriction, including without limitation the rights to | ||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
the Software, and to permit persons to whom the Software is furnished to do so, | ||
subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
-------------------------------------------------------------------------------- | ||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | ||
Version 2, December 2004 | ||
|
||
Copyright (C) 2004 Sam Hocevar <[email protected]> | ||
|
||
Everyone is permitted to copy and distribute verbatim or modified | ||
copies of this license document, and changing it is allowed as long | ||
as the name is changed. | ||
|
||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | ||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION | ||
|
||
0. You just DO WHAT THE FUCK YOU WANT TO. | ||
1. Bla bla bla | ||
2. Montesqieu et camembert, vive la France, zut alors! | ||
|
||
-------------------------------------------------------------------------------- | ||
|
||
WTFPLv2 is very permissive, see http://www.wtfpl.net/faq/ | ||
|
||
However, if this WTFPLV2 is REALLY a blocker and is the reason you can't use | ||
this project, contact me and I'll dual license it. | ||
|
||
-------------------------------------------------------------------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
# Where Am I? | ||
|
||
A drop-in two files library to locate the current executable and the current | ||
module on the file system. | ||
|
||
Supported platforms: | ||
|
||
- Windows | ||
- Linux | ||
- Mac | ||
- iOS | ||
- Android | ||
- QNX Neutrino | ||
- FreeBSD | ||
- NetBSD | ||
- DragonFly BSD | ||
- SunOS | ||
- OpenBSD | ||
|
||
Just drop `whereami.h` and `whereami.c` into your build and get started. (see | ||
also [customizing compilation]) | ||
|
||
[customizing compilation]: #customizing-compilation | ||
|
||
-------------------------------------------------------------------------------- | ||
|
||
## Usage | ||
|
||
- `wai_getExecutablePath()` returns the path of the enclosing executable | ||
- `wai_getModulePath()` returns the path of the enclosing module | ||
|
||
Example usage: | ||
|
||
- first call `int length = wai_getExecutablePath(NULL, 0, NULL);` to retrieve | ||
the length of the path | ||
- allocate the destination buffer with `path = (char*)malloc(length + 1);` | ||
- call `wai_getExecutablePath(path, length, &dirname_length)` again to retrieve | ||
the path | ||
- add a terminal `NUL` character with `path[length] = '\0';` | ||
|
||
Here is the output of the example: | ||
|
||
$ make -j -C _gnu-make | ||
$ cp ./bin/mac-x86_64/library.dylib /tmp/ | ||
$ ./bin/mac-x86_64/executable --load-library=/tmp/library.dylib | ||
|
||
executable path: /Users/gregory/Projects/whereami/bin/mac-x86_64/executable | ||
dirname: /Users/gregory/Projects/whereami/bin/mac-x86_64 | ||
basename: executable | ||
module path: /Users/gregory/Projects/whereami/bin/mac-x86_64/executable | ||
dirname: /Users/gregory/Projects/whereami/bin/mac-x86_64 | ||
basename: executable | ||
|
||
library loaded | ||
executable path: /Users/gregory/Projects/whereami/bin/mac-x86_64/executable | ||
dirname: /Users/gregory/Projects/whereami/bin/mac-x86_64 | ||
basename: executable | ||
module path: /private/tmp/library.dylib | ||
dirname: /private/tmp | ||
basename: library.dylib | ||
library unloaded | ||
|
||
-------------------------------------------------------------------------------- | ||
|
||
## Customizing compilation | ||
|
||
You can customize the library's behavior by defining the following macros: | ||
|
||
- `WAI_FUNCSPEC` | ||
- `WAI_PREFIX` | ||
- `WAI_MALLOC` | ||
- `WAI_REALLOC` | ||
- `WAI_FREE` | ||
|
||
## Compiling for Windows | ||
|
||
There is a Visual Studio 2015 solution in the `_win-vs14/` folder. | ||
|
||
## Compiling for Linux or Mac | ||
|
||
There is a GNU Make 3.81 `MakeFile` in the `_gnu-make/` folder: | ||
|
||
$ make -j -C _gnu-make/ | ||
|
||
## Compiling for Mac | ||
|
||
See above if you want to compile from command line. Otherwise there is an Xcode | ||
project located in the `_mac-xcode/` folder. | ||
|
||
## Compiling for iOS | ||
|
||
There is an Xcode project located in the `_ios-xcode/` folder. | ||
|
||
If you prefer compiling from command line and deploying to a jailbroken device | ||
through SSH, use: | ||
|
||
$ make -j -C _gnu-make/ binsubdir=ios CC="$(xcrun --sdk iphoneos --find clang) -isysroot $(xcrun --sdk iphoneos --show-sdk-path) -arch armv7 -arch armv7s -arch arm64" postbuild="codesign -s 'iPhone Developer'" | ||
|
||
## Compiling for Android | ||
|
||
You will have to install the Android NDK, and point the `$NDK_ROOT` environment | ||
variable to the NDK path: e.g. `export NDK_ROOT=/opt/android-ndk` (without a | ||
trailing `/` character). | ||
|
||
Next, the easy way is to make a standalone Android toolchain with the following | ||
command: | ||
|
||
$ $NDK_ROOT/build/tools/make_standalone_toolchain.py --arch=arm64 --api 21 --install-dir=/tmp/android-toolchain | ||
|
||
Now you can compile the example by running: | ||
|
||
$ make -j -C _gnu-make/ platform=android architecture=arm64 CC=/tmp/android-toolchain/bin/aarch64-linux-android-gcc CXX=/tmp/android-toolchain/bin/aarch64-linux-android-g++ | ||
|
||
Loading page aligned library straight from APKs is supported. To test, use the | ||
following: | ||
|
||
$ zip -Z store app bin/android/library.so | ||
$ zipalign -v -f -p 4 ./app.zip ./app.apk | ||
|
||
Then copy `bin/android/executable` and `app.apk` to your Android device and | ||
there launch: | ||
|
||
$ ./executable --load-library=$PWD/app.apk!/bin/android/library.so |
Oops, something went wrong.