summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2018-06-02 20:51:23 +0800
committerJohn Hodge <tpg@mutabah.net>2018-06-03 08:44:27 +0800
commit2dcdcf9dec83505dde64d21ff7b35ac16c1cccce (patch)
tree92778218c5e99808bf01f32b32a0030c505a8749 /tools
parent8225decdd04b7bae20ad82b20059f0fd6da2abd4 (diff)
downloadmrust-2dcdcf9dec83505dde64d21ff7b35ac16c1cccce.tar.gz
minicargo - Rough OSX support
Diffstat (limited to 'tools')
-rw-r--r--tools/minicargo/build.cpp33
1 files changed, 29 insertions, 4 deletions
diff --git a/tools/minicargo/build.cpp b/tools/minicargo/build.cpp
index 79a3dcff..21d8d809 100644
--- a/tools/minicargo/build.cpp
+++ b/tools/minicargo/build.cpp
@@ -42,9 +42,16 @@ extern int _putenv_s(const char*, const char*);
# include <sys/wait.h>
# include <fcntl.h>
#endif
+#ifdef __APPLE__
+# include <mach-o/dyld.h>
+#endif
#ifdef _WIN32
# define EXESUF ".exe"
+#else
+# define EXESUF ""
+#endif
+#ifdef _WIN32
# ifdef _MSC_VER
# define HOST_TARGET "x86_64-windows-msvc"
# elif defined(__MINGW32__)
@@ -52,10 +59,8 @@ extern int _putenv_s(const char*, const char*);
# else
# endif
#elif defined(__NetBSD__)
-# define EXESUF ""
# define HOST_TARGET "x86_64-unknown-netbsd"
#else
-# define EXESUF ""
# define HOST_TARGET "x86_64-unknown-linux-gnu"
#endif
@@ -549,12 +554,32 @@ Builder::Builder(BuildOptions opts):
#ifdef __MINGW32__
m_compiler_path = (minicargo_path / "..\\..\\bin\\mrustc.exe").normalise();
#else
+ // MSVC, minicargo and mrustc are in the same dir
m_compiler_path = minicargo_path / "mrustc.exe";
#endif
#else
char buf[1024];
- size_t s = readlink("/proc/self/exe", buf, sizeof(buf)-1);
- buf[s] = 0;
+# ifdef __linux__
+ ssize_t s = readlink("/proc/self/exe", buf, sizeof(buf)-1);
+ if(s >= 0)
+ {
+ buf[s] = 0;
+ }
+ else
+#elif defined(__APPLE__)
+ uint32_t s = sizeof(buf);
+ if( _NSGetExecutablePath(buf, &s) == 0 )
+ {
+ // Buffer populated
+ }
+ else
+ // TODO: Buffer too small
+#else
+# warning "Can't runtime determine path to minicargo"
+#endif
+ {
+ strcpy(buf, "tools/bin/minicargo");
+ }
::helpers::path minicargo_path { buf };
minicargo_path.pop_component();