mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-26 01:21:57 +00:00
Support FreeBSD
This commit fixes issue on cquery's side. Its dependencies loguru and sparsepp should also be ported to FreeBSD: * https://github.com/emilk/loguru/pull/46 * sysinfo(2) called by sparsepp https://github.com/greg7mdp/sparsepp/blob/master/sparsepp/spp_memory.h#L32
This commit is contained in:
parent
0045e4817c
commit
2fb135e10a
@ -1,4 +1,4 @@
|
||||
#if defined(__linux__) || defined(__APPLE__)
|
||||
#if defined(__unix__) || defined(__APPLE__)
|
||||
#include "platform.h"
|
||||
|
||||
#include "utils.h"
|
||||
@ -32,12 +32,12 @@
|
||||
#include <semaphore.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
#ifndef __APPLE__
|
||||
#include <sys/prctl.h>
|
||||
#endif
|
||||
|
||||
#if defined(__linux__)
|
||||
#if defined(__FreeBSD__)
|
||||
# include <sys/param.h> // MAXPATHLEN
|
||||
# include <sys/sysctl.h> // sysctl
|
||||
#elif defined(__linux__)
|
||||
# include <malloc.h>
|
||||
# include <sys/prctl.h>
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
@ -216,11 +216,7 @@ extern "C" int _NSGetExecutablePath(char* buf,uint32_t* bufsize);
|
||||
|
||||
// See https://stackoverflow.com/questions/143174/how-do-i-get-the-directory-that-a-program-is-running-from
|
||||
std::string GetExecutablePath() {
|
||||
#ifndef __APPLE__
|
||||
char buffer[PATH_MAX+1] = {0};
|
||||
readlink("/proc/self/exe", buffer, PATH_MAX);
|
||||
return std::string(buffer);
|
||||
#else
|
||||
#ifdef __APPLE__
|
||||
uint32_t size = 0;
|
||||
_NSGetExecutablePath(nullptr, &size);
|
||||
char *buffer = new char[size];
|
||||
@ -228,6 +224,19 @@ std::string GetExecutablePath() {
|
||||
std::string result(buffer);
|
||||
delete[] buffer;
|
||||
return result;
|
||||
#elif defined(__FreeBSD__)
|
||||
static const int name[] = {
|
||||
CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1,
|
||||
};
|
||||
char path[MAXPATHLEN];
|
||||
size_t len = sizeof(path);
|
||||
path[0] = '\0';
|
||||
(void)sysctl(name, 4, path, &len, NULL, 0);
|
||||
return std::string(path);
|
||||
#else
|
||||
char buffer[PATH_MAX] = {0};
|
||||
readlink("/proc/self/exe", buffer, PATH_MAX);
|
||||
return std::string(buffer);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -256,7 +265,7 @@ bool TryMakeDirectory(const std::string& absolute_path) {
|
||||
|
||||
void SetCurrentThreadName(const std::string& thread_name) {
|
||||
loguru::set_thread_name(thread_name.c_str());
|
||||
#ifndef __APPLE__
|
||||
#ifdef __linux__
|
||||
prctl(PR_SET_NAME, thread_name.c_str(), 0, 0, 0);
|
||||
#endif
|
||||
}
|
12
wscript
12
wscript
@ -79,7 +79,7 @@ def options(opt):
|
||||
grp.add_option('--use-system-clang', dest='use_system_clang', default=False, action='store_true',
|
||||
help='enable use of clang from the system')
|
||||
grp.add_option('--bundled-clang', dest='bundled_clang', default='4.0.0',
|
||||
help='bundled clang version, downloaded from http://releases.llvm.org/ , e.g. 4.0.0 5.0.0')
|
||||
help='bundled clang version, downloaded from https://releases.llvm.org/ , e.g. 4.0.0 5.0.0')
|
||||
grp.add_option('--llvm-config', dest='llvm_config', default='llvm-config',
|
||||
help='specify path to llvm-config for automatic configuration [default: %default]')
|
||||
grp.add_option('--clang-prefix', dest='clang_prefix', default='',
|
||||
@ -178,6 +178,8 @@ def configure(ctx):
|
||||
CLANG_TARBALL_EXT = '.tar.xz'
|
||||
if sys.platform == 'darwin':
|
||||
CLANG_TARBALL_NAME = 'clang+llvm-$version-x86_64-apple-darwin'
|
||||
elif sys.platform.startswith('freebsd'):
|
||||
CLANG_TARBALL_NAME = 'clang+llvm-$version-amd64-unknown-freebsd10'
|
||||
elif sys.platform.startswith('linux'):
|
||||
# These executable depend on libtinfo.so.5
|
||||
CLANG_TARBALL_NAME = 'clang+llvm-$version-x86_64-linux-gnu-ubuntu-14.04'
|
||||
@ -185,7 +187,7 @@ def configure(ctx):
|
||||
CLANG_TARBALL_NAME = 'LLVM-$version-win64'
|
||||
CLANG_TARBALL_EXT = '.exe'
|
||||
else:
|
||||
sys.stderr.write('ERROR: Unknown platform {0}\n'.format(sys.platform))
|
||||
sys.stderr.write('ERROR: releases.llvm.org does not provide pre-built binaries for your platform {0}\n'.format(sys.platform))
|
||||
sys.exit(1)
|
||||
|
||||
CLANG_TARBALL_NAME = string.Template(CLANG_TARBALL_NAME).substitute(version=ctx.options.bundled_clang)
|
||||
@ -227,6 +229,12 @@ def build(bld):
|
||||
lib.append('rt')
|
||||
lib.append('pthread')
|
||||
lib.append('dl')
|
||||
elif sys.platform.startswith('freebsd'):
|
||||
# loguru::stacktrace_as_stdstring calls backtrace_symbols
|
||||
lib.append('execinfo')
|
||||
|
||||
lib.append('pthread')
|
||||
lib.append('thr')
|
||||
elif sys.platform == 'darwin':
|
||||
lib.append('pthread')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user