Skip to content

Commit

Permalink
Fix OS X build.
Browse files Browse the repository at this point in the history
Need to check Win32, Linux & TRIK OS builds
  • Loading branch information
iakov committed Dec 21, 2016
1 parent 4177915 commit 9233e70
Show file tree
Hide file tree
Showing 15 changed files with 225 additions and 30 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
moc_*.cpp
ui_*.h
qrc_*.cpp
Thumbs.db
Makefile*
*.pro.user*
bin/*
Expand All @@ -31,3 +32,4 @@ object_script.*.Release
# project-specific
**/.build
tests/minimalCppApp/*
.qmake.stash
116 changes: 93 additions & 23 deletions global.pri
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Copyright 2014 - 2016 CyberTech Co. Ltd., Yurii Litvinov.
# Copyright 2014 - 2016 CyberTech Co. Ltd., Yurii Litvinov, Iakov Kirilenko
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
Expand All @@ -20,7 +20,7 @@
#
# Uses environment variable INSTALL_ROOT as a root of a file structure for install rules.
#
# Uses CONFIG variable to control support for Google Sanitizers (in linux-x86 debug mode only):
# Uses CONFIG variable to control support for Google Sanitizers:
# - CONFIG+=sanitize-address will enable address sanitizer
# - CONFIG+=sanitize-undefined will enable undefined behavior sanitizer
# - CONFIG+=sanitize-thread will enable thread sanitizer
Expand All @@ -37,17 +37,23 @@ count(COMPILER_IS_ARM, 1) {

win32 {
PLATFORM = windows
} else {
}

unix:!macx {
PLATFORM = linux
}

macx {
PLATFORM = mac
}

CONFIG(debug, debug | release) {
CONFIGURATION = $$ARCHITECTURE-debug
CONFIGURATION_SUFFIX = -$$ARCHITECTURE-d
QMAKE_CXXFLAGS += -coverage
QMAKE_LFLAGS += -coverage
# Address sanitizer is on by default
!CONFIG(no-sanitizers) {
!CONFIG(nosanitizers) {
CONFIG += sanitize-address
}
} else {
Expand All @@ -64,28 +70,89 @@ DESTDIR = $$PWD/bin/$$CONFIGURATION
PROJECT_BASENAME = $$basename(_PRO_FILE_)
PROJECT_NAME = $$section(PROJECT_BASENAME, ".", 0, 0)

TARGET = $$PROJECT_NAME$$CONFIGURATION_SUFFIX
isEmpty(TARGET) {
TARGET = $$PROJECT_NAME$$CONFIGURATION_SUFFIX
} else {
TARGET = $$TARGET$$CONFIGURATION_SUFFIX
}

equals(TEMPLATE, app) {
!macx {
QMAKE_LFLAGS += -Wl,-O1,-rpath,.
unix:!macx {
QMAKE_LFLAGS += -Wl,-rpath-link,$$DESTDIR
!CONFIG(no_rpath) QMAKE_LFLAGS += -Wl,-O1,-rpath,.
}
}

macx-clang {
QMAKE_CXXFLAGS += -stdlib=libc++
QMAKE_LFLAGS_SONAME = -Wl,-install_name,@executable_path/../../../
}

unix:!CONFIG(nosanitizers) {

# seems like we want USan always, but are afraid of ....
!CONFIG(sanitize_address):!CONFIG(sanitize_thread):!CONFIG(sanitize_memory):!CONFIG(sanitize_kernel_address) {
# Ubsan is turned on by default
CONFIG += sanitizer sanitize_undefined
}

CONFIG(debug, debug | release):!CONFIG(sanitize_address):!macx-clang { CONFIG += sanitize_leak }

CONFIG(sanitize_leak) {
#LSan can be used without performance degrade even in release build
QMAKE_CFLAGS += -fsanitize=leak
QMAKE_CXXFLAGS += -fsanitize=leak
QMAKE_LFLAGS += -fsanitize=leak
}

CONFIG(sanitize_undefined):macx-clang {
# sometimes runtime is missing in clang. this hack allows to avoid runtime dependency.
QMAKE_SANITIZE_UNDEFINED_CFLAGS += -fsanitize-trap=undefined
QMAKE_SANITIZE_UNDEFINED_CXXFLAGS += -fsanitize-trap=undefined
QMAKE_SANITIZE_UNDEFINED_LFLAGS += -fsanitize-trap=undefined
}


!clang:gcc:*-g++*:system($$QMAKE_CXX --version | grep -oe \'\\<5\\.[0-9]\\+\\.\' ){
CONFIG(sanitize_undefined){
# Ubsan has (had at least) known issues with false errors about calls of methods of the base class.
# That must be disabled. Variables for confguring ubsan are taken from here:
# https://codereview.qt-project.org/#/c/43420/17/mkspecs/common/sanitize.conf
# They can change in some version of Qt, keep track of it.
# By the way, simply setting QMAKE_CFLAGS, QMAKE_CXXFLAGS and QMAKE_LFLAGS instead of those used below
# will not work due to arguments order ("-fsanitize=undefined" must be declared before "-fno-sanitize=vptr").
QMAKE_SANITIZE_UNDEFINED_CFLAGS += -fno-sanitize=vptr
QMAKE_SANITIZE_UNDEFINED_CXXFLAGS += -fno-sanitize=vptr
QMAKE_SANITIZE_UNDEFINED_LFLAGS += -fno-sanitize=vptr
}
}

CONFIG(release, debug | release){
!clang:gcc:*-g++*:system($$QMAKE_CXX --version | grep -oe \'\\<4\\.[0-9]\\+\\.\' ){
message("Too old compiler: $$QMAKE_CXX")
} else {
QMAKE_CFLAGS += -fsanitize-recover=all
QMAKE_CXXFLAGS += -fsanitize-recover=all
}
}

}

OBJECTS_DIR = .build/$$CONFIGURATION/.obj
MOC_DIR = .build/$$CONFIGURATION/.moc
RCC_DIR = .build/$$CONFIGURATION/.rcc
UI_DIR = .build/$$CONFIGURATION/.ui
OBJECTS_DIR = .build/$$CONFIGURATION/obj
MOC_DIR = .build/$$CONFIGURATION/moc
RCC_DIR = .build/$$CONFIGURATION/rcc
UI_DIR = .build/$$CONFIGURATION/ui

PRECOMPILED_HEADER = $$PWD/pch.h
CONFIG += precompile_header

INCLUDEPATH += $$_PRO_FILE_PWD_ \
$$_PRO_FILE_PWD_/include/$$PROJECT_NAME \

INCLUDEPATH += \
$$PWD/qslog \

PRECOMPILED_HEADER = $$PWD/pch.h
CONFIG += precompile_header


LIBS += -L$$DESTDIR

Expand All @@ -95,10 +162,12 @@ isEmpty(IS_QSLOG) {
LIBS += -lqslog$$CONFIGURATION_SUFFIX
}

QMAKE_CXXFLAGS += -fno-elide-constructors -pedantic-errors -ansi -std=c++11
CONFIG += c++11
QMAKE_CXXFLAGS += -fno-elide-constructors -pedantic-errors -Werror=pedantic -ansi -std=c++11
#I whant -Werror to be turned on, but Qt has problems
QMAKE_CXXFLAGS += -Wextra -Wcast-qual -Wwrite-strings -Wredundant-decls -Wunreachable-code -Wnon-virtual-dtor -Woverloaded-virtual -Wuninitialized -Winit-self
#-Wold-style-cast -Wmissing-declarations

GLOBAL_PWD = $$PWD

# Useful function to copy additional files to destination,
Expand All @@ -109,26 +178,26 @@ defineTest(copyToDestdir) {

for(FILE, FILES) {
DESTDIR_SUFFIX =
AFTER_SLASH = $$section(FILE, "/", -1, -1)
isEmpty(QMAKE_SH) {
# This ugly code is needed because xcopy requires to add source directory name to target directory name when copying directories
win32 {
AFTER_SLASH = $$section(FILE, "/", -1, -1)
BASE_NAME = $$section(FILE, "/", -2, -2)
equals(AFTER_SLASH, ""):DESTDIR_SUFFIX = /$$BASE_NAME

FILE ~= s,/$,,g

FILE ~= s,/,\,g
FILE ~= s,/,\\,g
}
DDIR = $$DESTDIR$$DESTDIR_SUFFIX/$$3
win32:DDIR ~= s,/,\,g
win32:DDIR ~= s,/,\\,g
} else {
DDIR = $$DESTDIR$$DESTDIR_SUFFIX/$$3
}

isEmpty(NOW) {
# In case this is directory add "*" to copy contents of a directory instead of directory itself under linux.
!win32:equals(AFTER_SLASH, ""):FILE = $$FILE*
!win32:equals(AFTER_SLASH, ""):FILE = $$FILE'.'
QMAKE_POST_LINK += $(COPY_DIR) $$quote($$FILE) $$quote($$DDIR) $$escape_expand(\\n\\t)
} else {
win32 {
Expand All @@ -142,7 +211,7 @@ defineTest(copyToDestdir) {
}

macx {
system("cp -R $$FILE $$DDIR/$$FILE")
system("cp -af $$FILE $$DDIR/")
}
}
}
Expand Down Expand Up @@ -249,20 +318,21 @@ defineTest(noPch) {
export(PRECOMPILED_HEADER)
}

#seems obsolete, atleast for qmake-qt5
unix:equals(ARCHITECTURE, "x86") {
CONFIG(debug) {
QMAKE_CXXFLAGS += -fno-omit-frame-pointer
CONFIG(sanitize-address) {
CONFIG(sanitize_address) {
QMAKE_CXXFLAGS += -fsanitize=address
QMAKE_LFLAGS += -fsanitize=address
}
CONFIG(sanitize-undefined) {
CONFIG(sanitize_undefined) {
# UBSan does not play well with precompiled headers for some reason.
noPch()
QMAKE_CXXFLAGS += -fsanitize=undefined
QMAKE_LFLAGS += -fsanitize=undefined
}
CONFIG(sanitize-thread) {
CONFIG(sanitize_thread) {
QMAKE_CXXFLAGS += -fsanitize=thread
QMAKE_LFLAGS += -fsanitize=thread
LIBS += -ltsan
Expand Down
5 changes: 4 additions & 1 deletion tests/common.pri
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ LIBS += -lgmock$$CONFIGURATION_SUFFIX

SOURCES = $$PWD/mainTest.cpp

QMAKE_CXXFLAGS += -Wno-unused-local-typedefs
QMAKE_CXXFLAGS += -Wno-unused-local-typedef -Wno-error=pedantic

DEFINES += GTEST_USE_OWN_TR1_TUPLE


OTHER_FILES += \
$$PWD/test-system-config.xml \
Expand Down
1 change: 1 addition & 0 deletions tests/trikScriptRunnerTests/trikScriptRunnerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "trikScriptRunnerTest.h"

#include <QtCore/QEventLoop>
#include <QtCore/QFile>

#include <trikControl/brickFactory.h>
#include <trikKernel/fileUtils.h>
Expand Down
2 changes: 1 addition & 1 deletion trikControl/src/analogSensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class AnalogSensor : public SensorInterface

public slots:
/// Returns current reading of a sensor.
int read();
int read() override;

/// Returns current raw reading of a sensor.
int readRawData() override;
Expand Down
1 change: 1 addition & 0 deletions trikControl/src/eventDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#pragma once

#include <QtCore/QSharedPointer>
#include <QThread>

#include "eventDeviceInterface.h"
#include "deviceState.h"
Expand Down
2 changes: 1 addition & 1 deletion trikControl/src/gyroSensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
using namespace trikControl;

static constexpr float GYRO_250DPS = 8.75;
static constexpr double pi() { return std::acos(-1); }
static constexpr double pi() { return 3.14159265358979323846;}
static constexpr float RAD_TO_MDEG = 1000 * 180 / pi();

GyroSensor::GyroSensor(const QString &deviceName, const trikKernel::Configurer &configurer
Expand Down
1 change: 1 addition & 0 deletions trikControl/src/vectorSensorWorker.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <QtCore/QVector>
#include <QtCore/QTimer>
#include <QtCore/QReadWriteLock>
#include <QtCore/QThread>

#include <trikHal/hardwareAbstractionInterface.h>

Expand Down
22 changes: 22 additions & 0 deletions trikGui/mac/powerLevel.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* Copyright 2016 CyberTech Labs Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License. */

#include "powerLevel.h"

using namespace trikGui;

PowerLevel::Level PowerLevel::currentLevel()
{
return Level::twelveVolt;
}
2 changes: 2 additions & 0 deletions trikGui/motorsWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include <QtWidgets/QScrollArea>
#endif

#include <QApplication>

#include "motorLever.h"

using namespace trikGui;
Expand Down
2 changes: 1 addition & 1 deletion trikGui/scriptHolder.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <QtCore/qglobal.h>

#include <QtCore/QString>

#include <QtCore/QStringList>
namespace trikGui {

/// Class which contains program from programming widget.
Expand Down
4 changes: 2 additions & 2 deletions trikHal/trikHal.pro
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ PUBLIC_HEADERS += \
$$PWD/include/trikHal/outputDeviceFileInterface.h \
$$PWD/include/trikHal/systemConsoleInterface.h \

!win32 {
!win32:!macx {
HEADERS += \
$$PWD/src/trik/trikHardwareAbstraction.h \
$$PWD/src/trik/trikMspI2c.h \
Expand All @@ -50,7 +50,7 @@ HEADERS += \
$$PWD/src/stub/stubOutputDeviceFile.h \
$$PWD/src/stub/stubFifo.h \

!win32 {
!win32:!macx {
SOURCES += \
$$PWD/src/trik/trikHardwareAbstraction.cpp \
$$PWD/src/trik/trikMspI2c.cpp \
Expand Down
2 changes: 1 addition & 1 deletion trikKernel/include/trikKernel/timeVal.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class TimeVal
/// It is a friend method for hiding default constructor.
friend void *qMetaTypeConstructHelper<TimeVal>(const TimeVal *t);
#else
friend class QtMetaTypePrivate::QMetaTypeFunctionHelper<TimeVal>;
friend struct QtMetaTypePrivate::QMetaTypeFunctionHelper<TimeVal>;
#endif

/// "Minus" operator is for computing time interval between two timestamps, returns value in microsends.
Expand Down
19 changes: 19 additions & 0 deletions trikKernel/src/mac/coreDumping.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* Copyright 2014 - 2015 CyberTech Labs Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License. */

#include "coreDumping.h"

void trikKernel::coreDumping::initCoreDumping()
{
}
Loading

0 comments on commit 9233e70

Please sign in to comment.