Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FreeBSD code updates in order to get core module compiling under it #660

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ASCOfficeXlsFile2/source/XlsFormat/Auxiliary/HelpFunc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ const std::wstring unescape_ST_Xstring(const std::wstring& wstr)
while(true)
{

#if defined(__linux__) || defined(_MAC) || defined(_IOS)
#if defined(__linux__) || defined(__FreeBSD__) || defined(_MAC) || defined(_IOS)
const auto it_range = boost::make_iterator_range(x_pos_noncopied, wstr_end);
x_pos_next = boost::algorithm::find_first(it_range, L"_x").begin();
#else
Expand Down
2 changes: 1 addition & 1 deletion ASCOfficeXlsFile2/source/XlsFormat/Crypt/rtl/cipher.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

#include <stddef.h>

#ifdef __linux__
#if defined(__linux__) || defined(__FreeBSD__)
#include <inttypes.h>
#endif

Expand Down
2 changes: 1 addition & 1 deletion ASCOfficeXlsFile2/source/XlsFormat/Crypt/rtl/digest.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
*/
#pragma once

#ifdef __linux__
#if defined(__linux__) || defined(__FreeBSD__)
#include <inttypes.h>
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
*/
#pragma once

#ifdef __linux__
#if defined(__linux__) || defined(__FreeBSD__)
#include <inttypes.h>
#endif

Expand Down
10 changes: 8 additions & 2 deletions Common/3dParty/boost/boost.pri
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
INCLUDEPATH += $$PWD/build/$$CORE_BUILDS_PLATFORM_PREFIX/include
CORE_BOOST_LIBS = $$PWD/build/$$CORE_BUILDS_PLATFORM_PREFIX/lib
!core_freebsd {
INCLUDEPATH += $$PWD/build/$$CORE_BUILDS_PLATFORM_PREFIX/include
CORE_BOOST_LIBS = $$PWD/build/$$CORE_BUILDS_PLATFORM_PREFIX/lib
}
core_freebsd {
INCLUDEPATH += /usr/local/include
CORE_BOOST_LIBS = /usr/local/lib
}

core_android {
INCLUDEPATH += $$PWD/build/android/include
Expand Down
13 changes: 10 additions & 3 deletions Common/3dParty/icu/icu.pri
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,17 @@ core_windows {
}

core_linux {
INCLUDEPATH += $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/usr/local/include
!core_freebsd {
INCLUDEPATH += $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/usr/local/include

LIBS += $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/build/libicuuc.so.$$ICU_MAJOR_VER
LIBS += $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/build/libicudata.so.$$ICU_MAJOR_VER
}
core_freebsd {
INCLUDEPATH += /usr/local/include
LIBS += -licuuc -l icudata
}

LIBS += $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/build/libicuuc.so.$$ICU_MAJOR_VER
LIBS += $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/build/libicudata.so.$$ICU_MAJOR_VER
}

core_mac {
Expand Down
15 changes: 11 additions & 4 deletions Common/3dParty/v8/v8.pri
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,23 @@ core_linux {
use_v8_monolith {
LIBS += -L$$CORE_V8_PATH_LIBS -lv8_monolith
} else {
SNAPSHOT_LIB=v8_snapshot
!exists($$CORE_V8_PATH_LIBS/libv8_snapshot.a) {
SNAPSHOT_LIB=v8_nosnapshot
}
!core_freebsd {
SNAPSHOT_LIB=v8_snapshot
!exists($$CORE_V8_PATH_LIBS/libv8_snapshot.a) {
SNAPSHOT_LIB=v8_nosnapshot
}

LIBS += -L$$CORE_V8_PATH_LIBS -lv8_base -lv8_libplatform -lv8_libbase -l$$SNAPSHOT_LIB -lv8_libsampler
LIBS += -L$$CORE_V8_PATH_LIBS/third_party/icu -licui18n -licuuc
}
core_freebsd {
INCLUDEPATH += /usr/local/include/node
LIBS += -lnode
}
}
}


core_mac {

use_v8_monolith {
Expand Down
2 changes: 1 addition & 1 deletion Common/DocxFormat/Source/Base/Types_32.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
typedef unsigned __int16 _UINT16;
typedef unsigned __int32 _UINT32;
typedef unsigned __int64 _UINT64;
#elif __linux__
#elif defined(__linux__) || defined(__FreeBSD__)
typedef int16_t _INT16;
typedef int32_t _INT32;
typedef int64_t _INT64;
Expand Down
5 changes: 5 additions & 0 deletions Common/DocxFormat/Source/XlsxFormat/Common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ char* gcvt(double x, int n, char* b)
#define _gcvt gcvt
#endif

#ifdef __FreeBSD__
#define _gcvt(x,n,b) sprintf(b, "%.17g", x)
#endif


#define DBL_MAX 15
#define DBL_MAXDIG10 17

Expand Down
7 changes: 7 additions & 0 deletions Common/base.pri
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@ linux-g++:contains(DST_ARCH, arm): {
}
}

freebsd-clang {
message("freebsd-clang")
CONFIG += core_linux
CONFIG += core_linux_64
CONFIG += core_freebsd
}

linux-g++-64 {
message("linux-64")
CONFIG += core_linux
Expand Down
4 changes: 4 additions & 0 deletions DesktopEditor/AllFontsGen/AllFontsGen.pro
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,8 @@ core_linux {
QMAKE_LFLAGS += -Wl,--rpath=./
}

core_freebsd {
LIBS += -liconv
}

SOURCES += main.cpp
2 changes: 1 addition & 1 deletion DesktopEditor/agg-2.4/include/agg_math.h
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ namespace agg
}
}

#if defined(_LINUX) || defined(__APPLE__)
#if defined(_LINUX) || defined(__APPLE__) || defined(__FreeBSD__)
inline double _hypot(const double& x, const double& y)
{
return sqrt(x * x + y * y);
Expand Down
2 changes: 1 addition & 1 deletion DesktopEditor/agg-2.4/include/agg_span_gradient.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

namespace agg
{
#if !defined(_LINUX) && !(defined(_WIN32) || defined (_WIN64)) && !defined(__APPLE__)
#if !defined(_LINUX) && !defined(__FreeBSD__) && !(defined(_WIN32) || defined (_WIN64)) && !defined(__APPLE__)
double _hypot(double x, double y)
{
return sqrt(x*x + y*y);
Expand Down
5 changes: 5 additions & 0 deletions DesktopEditor/allthemesgen/allthemesgen.pro
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,9 @@ core_linux {
QMAKE_LFLAGS += -Wl,--rpath=./
}

core_freebsd {
LIBS += -liconv
}


SOURCES += main.cpp
10 changes: 5 additions & 5 deletions DesktopEditor/common/Directory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include "windef.h"
#include <shlobj.h>
#include <Rpc.h>
#elif __linux__
#elif defined(__linux__) || defined(__FreeBSD__)
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
Expand Down Expand Up @@ -120,7 +120,7 @@ namespace NSDirectory
FindClose( hRes );
#endif

#ifdef __linux__
#if defined(__linux__) || defined(__FreeBSD__)
BYTE* pUtf8 = NULL;
LONG lLen = 0;
NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strDirectory.c_str(), strDirectory.length(), pUtf8, lLen, false);
Expand Down Expand Up @@ -233,7 +233,7 @@ namespace NSDirectory
}
} while( FindNextFileW( hRes, &oFD ) );
FindClose( hRes );
#elif __linux__
#elif defined(__linux__) || defined(__FreeBSD__)
BYTE* pUtf8 = NULL;
LONG lLen = 0;
NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strDirectory.c_str(), strDirectory.length(), pUtf8, lLen, false);
Expand Down Expand Up @@ -297,7 +297,7 @@ namespace NSDirectory
#if defined(_WIN32) || defined (_WIN64)
DWORD dwAttrib = ::GetFileAttributesW(strDirectory.c_str());
return (dwAttrib != INVALID_FILE_ATTRIBUTES && 0 != (dwAttrib & FILE_ATTRIBUTE_DIRECTORY));
#elif __linux__
#elif defined(__linux__) || defined(__FreeBSD__)
BYTE* pUtf8 = NULL;
LONG lLen = 0;
NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strDirectory.c_str(), strDirectory.length(), pUtf8, lLen, false);
Expand Down Expand Up @@ -491,7 +491,7 @@ namespace NSDirectory
}
#if defined(_WIN32) || defined (_WIN64)
if (deleteRoot) RemoveDirectoryW(strDirectory.c_str());
#elif __linux__
#elif defined(__linux__) || defined(__FreeBSD__)
BYTE* pUtf8 = NULL;
LONG lLen = 0;
NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strDirectory.c_str(), strDirectory.length(), pUtf8, lLen, false);
Expand Down
22 changes: 21 additions & 1 deletion DesktopEditor/common/File.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,14 @@
#include <windows.h>
#endif

#ifdef _LINUX
#if defined(_LINUX) || defined(__FreeBSD__)
#include <unistd.h>
#include <string.h>
#include <sys/stat.h>
#if defined(__FreeBSD__)
#include <sys/types.h>
#include <sys/sysctl.h>
#endif
#endif

#ifdef _IOS
Expand Down Expand Up @@ -1618,6 +1622,22 @@ namespace NSFile
return sRet;
#endif

#if defined(__FreeBSD__)
int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1};
char buf[NS_FILE_MAX_PATH];
size_t size = NS_FILE_MAX_PATH;

memset(buf, 0, NS_FILE_MAX_PATH);
if (sysctl(mib, 4, &buf, &size, NULL, 0) != 0) {
size = readlink("/proc/curproc/file", buf, size - 1);
if (size < 0)
return L"";
}
std::string sUTF8(buf);
std::wstring sRet = CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)sUTF8.c_str(), sUTF8.length());
return sRet;
#endif

return L"";
}

Expand Down
6 changes: 3 additions & 3 deletions DesktopEditor/common/Path.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

#if defined(_WIN32) || defined (_WIN64)
#include <tchar.h>
#elif __linux__ || MAC
#elif __linux__ || __FreeBSD__ || MAC
#include <libgen.h>
#endif

Expand All @@ -53,7 +53,7 @@ namespace NSSystemPath
sRes.append(tFolder);
if(sRes.length() > 0)
sRes.erase(sRes.length()-1);
#elif __linux__ || MAC
#elif __linux__ || __FreeBSD__ || MAC
BYTE* pUtf8 = NULL;
LONG lLen = 0;
NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strFileName.c_str(), strFileName.length(), pUtf8, lLen, false);
Expand All @@ -73,7 +73,7 @@ namespace NSSystemPath
sRes.append(tFilename);
sRes.append(tExt);
return sRes;
#elif __linux__ || MAC
#elif __linux__ || __FreeBSD__ || MAC
BYTE* pUtf8 = NULL;
LONG lLen = 0;
NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strFileName.c_str(), strFileName.length(), pUtf8, lLen, false);
Expand Down
2 changes: 1 addition & 1 deletion DesktopEditor/common/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ typedef int INT;
typedef unsigned int UINT, *PUINT;
typedef wchar_t WCHAR;

#ifdef __linux__
#if defined(__linux__) || defined(__FreeBSD__)
#include <inttypes.h>
typedef int64_t T_LONG64;
typedef uint64_t T_ULONG64;
Expand Down
2 changes: 1 addition & 1 deletion DesktopEditor/cximage/CxImage/ximage.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
#pragma once
#endif

#ifdef _LINUX
#if defined(_LINUX) || defined(__FreeBSD__)
#define _XOPEN_SOURCE
#include <unistd.h>
#include <arpa/inet.h>
Expand Down
2 changes: 1 addition & 1 deletion DesktopEditor/cximage/CxImage/ximagif.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ namespace NSGeneratePalette

if ( ( X + Width ) > SrcWidth || ( Y + Height ) > SrcHeigth || NULL == pSrc )
{
return NULL;
return false;
}

(*pImage) = new CImage8bit ();
Expand Down
2 changes: 1 addition & 1 deletion DesktopEditor/cximage/CxImage/ximainfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#include "ximage.h"

#if defined(_LINUX) || defined(__APPLE__)
#if defined(_LINUX) || defined(__APPLE__) || defined(__FreeBSD__)
#ifdef UNICODE
#define _tcsnicmp(a,b,c) wcscasecmp(a,b)
#else
Expand Down
2 changes: 1 addition & 1 deletion DesktopEditor/cximage/CxImage/ximajas.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#if CXIMAGE_SUPPORT_JASPER

#ifdef _LINUX
#if defined(_LINUX) || defined(__FreeBSD__)
#include <jasper/jasper.h>
#else
#include "../jasper/include/jasper/jasper.h"
Expand Down
2 changes: 1 addition & 1 deletion DesktopEditor/cximage/CxImage/ximajpg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#if CXIMAGE_SUPPORT_JPG

#ifdef _LINUX
#if defined(_LINUX) || defined(__FreeBSD__)
#include <jmorecfg.h>
#else
#include "../jpeg/jmorecfg.h"
Expand Down
2 changes: 1 addition & 1 deletion DesktopEditor/cximage/CxImage/ximajpg.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#define CXIMAGEJPG_SUPPORT_EXIF CXIMAGE_SUPPORT_EXIF

extern "C" {
#ifdef _LINUX
#if defined(_LINUX) || defined(__FreeBSD__)
#include <jpeglib.h>
#include <jerror.h>
#else
Expand Down
2 changes: 1 addition & 1 deletion DesktopEditor/cximage/CxImage/ximapng.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#if CXIMAGE_SUPPORT_PNG

extern "C" {
#ifdef _LINUX
#if defined(_LINUX) || defined(__FreeBSD__)
#undef _DLL
#include <png.h>
#include <pngstruct.h>
Expand Down
2 changes: 1 addition & 1 deletion DesktopEditor/cximage/CxImage/ximaraw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ bool CxImageRAW::Decode(CxFile *hFile)
for (c=0; c < dcr.colors; c++) ppm2[col*dcr.colors+c] = dcr.image[soff][c];
}
if (dcr.opt.output_bps == 16 && !dcr.opt.output_tiff && htons(0x55aa) != 0x55aa)
#if defined(_LINUX) || defined(__APPLE__)
#if defined(_LINUX) || defined(__APPLE__) || defined(__FreeBSD__)
swab ((char*)ppm2, (char*)ppm2, dcr.width*dcr.colors*2);
#else
_swab ((char*)ppm2, (char*)ppm2, dcr.width*dcr.colors*2);
Expand Down
2 changes: 1 addition & 1 deletion DesktopEditor/cximage/raw/libdcr.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#include <sys/types.h>
#endif

#if defined(_LINUX) || defined(__APPLE__)
#if defined(_LINUX) || defined(__APPLE__) || defined(__FreeBSD__)
#include <setjmp.h>
#include <sys/types.h>
#define _getcwd getcwd
Expand Down
Loading