Skip to content

Commit

Permalink
FreeBSD fixes, part 1
Browse files Browse the repository at this point in the history
  • Loading branch information
saper committed Oct 21, 2019
1 parent 2a1152a commit c3b69cb
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 11 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ if (BUILD_TESTING)
endfunction ()
endif ()

add_compile_options(-Wno-delete-non-virtual-dtor)
set(YAML_CPP_BUILD_TESTS FALSE)
set(YAML_CPP_BUILD_TOOLS FALSE)
add_subdirectory(ThirdParty/yaml-cpp)
Expand Down
1 change: 1 addition & 0 deletions src/libcar/Sources/AttributeList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

#include <car/AttributeList.h>
#include <cstdio>

using car::AttributeList;

Expand Down
10 changes: 5 additions & 5 deletions src/libutil/Sources/DefaultFilesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include <libgen.h>
#include <dirent.h>
#include <sys/stat.h>
#if defined(__APPLE__) || defined(__FreeBSD__)
#if defined(__APPLE__)
#include <copyfile.h>
#endif
#endif
Expand Down Expand Up @@ -358,7 +358,7 @@ writeSymbolicLinkPermissions(std::string const &path, Permissions::Operation ope
#if _WIN32
// TODO: Support file permssions on Windows.
return true;
#elif defined(__APPLE__) || defined(__FreeBSD__)
#elif defined(__APPLE__)
ext::optional<Permissions> updated = this->readSymbolicLinkPermissions(path);
if (!updated) {
return false;
Expand Down Expand Up @@ -626,7 +626,7 @@ copyFile(std::string const &from, std::string const &to)
}

return true;
#elif defined(__APPLE__) || defined(__FreeBSD__)
#elif defined(__APPLE__)
ext::optional<Type> fromType = this->type(from);
if (fromType != Type::File && fromType != Type::SymbolicLink) {
return false;
Expand Down Expand Up @@ -850,7 +850,7 @@ copySymbolicLink(std::string const &from, std::string const &to)
}

return true;
#elif defined(__APPLE__) || defined(__FreeBSD__)
#elif defined(__APPLE__)
if (this->type(from) != Type::SymbolicLink) {
return false;
}
Expand Down Expand Up @@ -1057,7 +1057,7 @@ readDirectory(std::string const &path, bool recursive, std::function<void(std::s
bool DefaultFilesystem::
copyDirectory(std::string const &from, std::string const &to, bool recursive)
{
#if defined(__APPLE__) || defined(__FreeBSD__)
#if defined(__APPLE__)
if (this->type(from) != Type::Directory) {
return false;
}
Expand Down
15 changes: 9 additions & 6 deletions src/process/Sources/DefaultContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ currentDirectory() const
return *directory;
}

#if defined(__linux__)
#if defined(__linux__) || defined(__FreeBSD__)
static char initialWorkingDirectory[PATH_MAX] = { 0 };
__attribute__((constructor))
static void InitializeInitialWorkingDirectory()
Expand All @@ -134,7 +134,7 @@ static void InitializeInitialWorkingDirectory()
}
}

#if !(__GLIBC__ >= 2 && __GLIBC_MINOR__ >= 16)
#if defined(__FreeBSD__) || !(__GLIBC__ >= 2 && __GLIBC_MINOR__ >= 16)
static char initialExecutablePath[PATH_MAX] = { 0 };
__attribute__((constructor))
static void InitialExecutablePathInitialize(int argc, char **argv)
Expand Down Expand Up @@ -183,7 +183,7 @@ executablePath() const
abort();
}
#elif defined(__linux__)
#if __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 16
#if __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 16)
char const *path = reinterpret_cast<char const *>(getauxval(AT_EXECFN));
if (path == NULL) {
abort();
Expand All @@ -194,6 +194,9 @@ executablePath() const
#error Requires glibc on Linux.
#endif
absolutePath = FSUtil::ResolveRelativePath(std::string(path), std::string(initialWorkingDirectory));
#elif defined(__FreeBSD__)
char const *path = reinterpret_cast<char const *>(initialExecutablePath);
absolutePath = FSUtil::ResolveRelativePath(std::string(path), std::string(initialWorkingDirectory));
#else
#error Unsupported platform.
#endif
Expand All @@ -204,11 +207,11 @@ executablePath() const
return *executablePath;
}

#if defined(__APPLE__) || defined(__linux__)
#if defined(__APPLE__) || defined(__linux__) || defined(__FreeBSD__)
static int commandLineArgumentCount = 0;
static char **commandLineArgumentValues = NULL;

#if defined(__APPLE__)
#if defined(__APPLE__) || defined(__FreeBSD__)
__attribute__((constructor))
#endif
static void CommandLineArgumentsInitialize(int argc, char **argv)
Expand Down Expand Up @@ -246,7 +249,7 @@ commandLineArguments() const
arguments = new std::vector<std::string>(args);

LocalFree(commandLineArgumentValues);
#elif defined(__APPLE__) || defined(__linux__)
#elif defined(__APPLE__) || defined(__linux__) || defined(__FreeBSD__)
arguments = new std::vector<std::string>(commandLineArgumentValues + 1, commandLineArgumentValues + commandLineArgumentCount);
#else
#error Unsupported platform.
Expand Down
11 changes: 11 additions & 0 deletions src/xcassets/Sources/Slot/SystemVersion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@

#include <sstream>

/*
* for legacy reasons, the GNU C Library might define major & minor,
* breaking the compilation unless we undefine them.
*/
#ifdef major
# undef major
#endif
#ifdef minor
# undef minor
#endif

using xcassets::Slot::SystemVersion;

SystemVersion::
Expand Down

0 comments on commit c3b69cb

Please sign in to comment.