summaryrefslogtreecommitdiff
path: root/tools/minicargo/build.cpp
diff options
context:
space:
mode:
authorJohn Hodge (Mutabah) <acessdev@gmail.com>2018-06-30 09:22:50 +0800
committerGitHub <noreply@github.com>2018-06-30 09:22:50 +0800
commite7fa373946f2da1a67a5f74d92191da1a13f7841 (patch)
tree0dc1a5b54254cbece789de86e6223cc09d25b255 /tools/minicargo/build.cpp
parentb03d61ed130dad6fa88a3beb4c32e48f86fdf84e (diff)
parent44262d8ce69f28c3b691131c4fb5e8824563053e (diff)
downloadmrust-e7fa373946f2da1a67a5f74d92191da1a13f7841.tar.gz
Merge pull request #79 from myfreeweb/master
Add FreeBSD and DragonFly support
Diffstat (limited to 'tools/minicargo/build.cpp')
-rw-r--r--tools/minicargo/build.cpp25
1 files changed, 18 insertions, 7 deletions
diff --git a/tools/minicargo/build.cpp b/tools/minicargo/build.cpp
index 42e19552..ea93a793 100644
--- a/tools/minicargo/build.cpp
+++ b/tools/minicargo/build.cpp
@@ -45,6 +45,9 @@ extern int _putenv_s(const char*, const char*);
#ifdef __APPLE__
# include <mach-o/dyld.h>
#endif
+#if defined(__FreeBSD__) || defined(__DragonFly__) || (defined(__NetBSD__) && defined(KERN_PROC_PATHNAME)) // NetBSD 8.0+
+# include <sys/sysctl.h>
+#endif
#ifdef _WIN32
# define EXESUF ".exe"
@@ -541,12 +544,12 @@ Builder::Builder(BuildOptions opts):
::helpers::path minicargo_path { buf };
minicargo_path.pop_component();
-#ifdef __MINGW32__
+# ifdef __MINGW32__
m_compiler_path = (minicargo_path / "..\\..\\bin\\mrustc.exe").normalise();
-#else
+# else
// MSVC, minicargo and mrustc are in the same dir
m_compiler_path = minicargo_path / "mrustc.exe";
-#endif
+# endif
#else
char buf[1024];
# ifdef __linux__
@@ -556,7 +559,7 @@ Builder::Builder(BuildOptions opts):
buf[s] = 0;
}
else
-#elif defined(__APPLE__)
+# elif defined(__APPLE__)
uint32_t s = sizeof(buf);
if( _NSGetExecutablePath(buf, &s) == 0 )
{
@@ -564,9 +567,17 @@ Builder::Builder(BuildOptions opts):
}
else
// TODO: Buffer too small
-#else
-# warning "Can't runtime determine path to minicargo"
-#endif
+# elif defined(__FreeBSD__) || defined(__DragonFly__) || (defined(__NetBSD__) && defined(KERN_PROC_PATHNAME)) // NetBSD 8.0+
+ int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 };
+ size_t s = sizeof(buf);
+ if ( sysctl(mib, 4, buf, &s, NULL, 0) == 0 )
+ {
+ // Buffer populated
+ }
+ else
+# else
+# warning "Can't runtime determine path to minicargo"
+# endif
{
strcpy(buf, "tools/bin/minicargo");
}