mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-10 01:48:00 +00:00
osxlaunch: bodge to let me test-build on Linux.
By default, the program still builds on Linux to a stub that just prints 'nothing to see here'. But if you compile with -DTEST_COMPILE_ON_LINUX, it compiles to a program that still doesn't do anything _actually_ useful, but goes through all the same motions that real osxlaunch would go through, until the final execv(2) fails because of course it's not _really_ living in an application bundle directory of the right shape. That allows me to run all the setup code under the debugging tools I'm most used to, in my preferred environment. (Same rationale as having puttyapp / ptermapp build for Linux too.)
This commit is contained in:
parent
faef0ea679
commit
eef8cac28e
@ -48,7 +48,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifndef __APPLE__
|
||||
#if !defined __APPLE__ && !defined TEST_COMPILE_ON_LINUX
|
||||
/* When we're not compiling for OS X, it's easier to just turn this
|
||||
* program into a trivial hello-world by ifdef in the source than it
|
||||
* is to remove it in the makefile edifice. */
|
||||
@ -61,7 +61,24 @@ int main(int argc, char **argv)
|
||||
|
||||
#include <unistd.h>
|
||||
#include <libgen.h>
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <mach-o/dyld.h>
|
||||
#else
|
||||
/* For Linux, a bodge to let as much of this code still run as
|
||||
* possible, so that you can run it under friendly debugging tools
|
||||
* like valgrind. */
|
||||
int _NSGetExecutablePath(char *out, uint32_t *outlen)
|
||||
{
|
||||
static const char toret[] = "/proc/self/exe";
|
||||
if (out != NULL && *outlen < sizeof(toret))
|
||||
return -1;
|
||||
*outlen = sizeof(toret);
|
||||
if (out)
|
||||
memcpy(out, toret, sizeof(toret));
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
* Find an alphabetic prefix unused by any environment variable name.
|
||||
|
Loading…
Reference in New Issue
Block a user