Skip to content

Commit

Permalink
Merge pull request #81 from jberlin/master
Browse files Browse the repository at this point in the history
update for multiple internal build and bug fixes
  • Loading branch information
jberlin authored Jan 25, 2018
2 parents db4cfca + 8ef62bb commit 5e09e1e
Show file tree
Hide file tree
Showing 57 changed files with 535 additions and 382 deletions.
30 changes: 24 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ set(LLVM_LIB "")
if (ENABLE_LLVM_BACKEND)
set(LLVM_DIR /usr/share/llvm/cmake CACHE PATH "Where to search for LLVM i.e. ")

find_package(LLVM CONFIG NAMES LLVM CONFIGS LLVMConfig.cmake)
find_package(LLVM CONFIG NAMES LLVM CONFIGS LLVM-Config.cmake LLVMConfig.cmake)
if (LLVM_FOUND)
set(SEEXPR_ENABLE_LLVM_BACKEND 1)
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
Expand Down Expand Up @@ -176,9 +176,27 @@ if (NOT CMAKE_BUILD_TYPE)
FORCE)
endif()

find_package(Qt4 COMPONENTS QtCore QtGui QtOpenGL)
if (QT4_FOUND)
include_directories(${QT_INCLUDE_DIR})
if (ENABLE_QT5)
find_package(Qt5 COMPONENTS Core Gui OpenGL)
if (Qt5_FOUND)
message(STATUS "Qt5 Enabled")
message(STATUS "Qt5Core_INCLUDE_DIRS = ${Qt5Core_INCLUDE_DIRS}")
message(STATUS "Qt5Gui_INCLUDE_DIRS = ${Qt5Gui_INCLUDE_DIRS}")
message(STATUS "Qt5OpenGL_INCLUDE_DIRS = ${Qt5OpenGL_INCLUDE_DIRS}")
include_directories(${Qt5Core_INCLUDE_DIRS})
include_directories(${Qt5Gui_INCLUDE_DIRS})
include_directories(${Qt5OpenGL_INCLUDE_DIRS})
endif()
else()
find_package(Qt4 COMPONENTS QtCore QtGui QtOpenGL)
if (QT4_FOUND)
message(STATUS "Qt4 Enabled")
message(STATUS "QT_INCLUDE_DIR = ${QT_INCLUDE_DIR}")
include_directories(${QT_INCLUDE_DIR}
${QT_INCLUDE_DIR}/QtCore
${QT_INCLUDE_DIR}/QtGui
${QT_INCLUDE_DIR}/QtOpenGL)
endif()
endif()

if (DEFINED ANIMLIB_DIR)
Expand Down Expand Up @@ -220,13 +238,13 @@ set(SEEXPR_EDITOR_LIBRARIES SeExpr2Editor)
include_directories(BEFORE ${CMAKE_BINARY_DIR}/include)
include_directories(BEFORE ${CMAKE_BINARY_DIR}/src/SeExpr)
include_directories(BEFORE ${CMAKE_SOURCE_DIR}/src/SeExpr)
include_directories(BEFORE ${CMAKE_SOURCE_DIR}/src/EditorUI)
include_directories(BEFORE ${CMAKE_SOURCE_DIR}/src/ui)

## Traverse subdirectories
add_subdirectory(src/SeExpr)
add_subdirectory(src/ui)
add_subdirectory(src/tests)
add_subdirectory(src/py)
add_subdirectory(src/utils)
add_subdirectory(src/demos)
add_subdirectory(src/doc)
add_subdirectory(src/tests)
23 changes: 21 additions & 2 deletions Makefile.config.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,19 @@ uname_S := $(shell uname -s)
# Example Linux config
ifeq ($(uname_S),Linux)

EXTRA_CMAKE_ARGS += -DGTEST_DIR=/usr
ifdef RP_gtest
EXTRA_CMAKE_ARGS += -DGTEST_DIR=$(RP_gtest)
else
EXTRA_CMAKE_ARGS += -DGTEST_DIR=/usr
endif

ifdef RP_animlib
# only build animlib if soure directory exists and env var set
CE_dir = $(wildcard "src/ui/CE")
ifneq ("$(CE_dir)", "")
ifdef RP_animlib
EXTRA_CMAKE_ARGS += -DANIMLIB_DIR=$(RP_animlib)
endif
endif

ifdef RP_boost_disney
EXTRA_CMAKE_ARGS += -DBOOST_DIR=$(RP_boost_disney)
Expand Down Expand Up @@ -37,6 +45,17 @@ ifeq ($(uname_S),Linux)
EXTRA_CMAKE_ARGS += -DQDGUI_DIR=$(RP_qdgui)
endif

ifdef RP_qt5
EXTRA_CMAKE_ARGS += -DENABLE_QT5=true
endif

ifdef RP_pyqt5
EXTRA_CMAKE_ARGS += -DPYQT_SIP_DIR=$(RP_pyqt5)/share/sip/PyQt5
endif

ifdef RP_pyqt4
EXTRA_CMAKE_ARGS += -DPYQT_SIP_DIR=$(RP_pyqt4)/share/sip
endif
endif


Expand Down
24 changes: 15 additions & 9 deletions src/SeExpr/ExprFunc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ FuncTable* Functions = 0;

namespace SeExpr2 {

std::vector<void*> ExprFunc::dynlib;

static SeExprInternal2::Mutex mutex;

void ExprFunc::init() {
Expand All @@ -116,6 +118,13 @@ void ExprFunc::cleanup() {
SeExprInternal2::AutoMutex locker(mutex);
delete Functions;
Functions = nullptr;
#ifdef SEEXPR_WIN32
#else
for(size_t i=0; i<dynlib.size(); i++){
dlclose(dynlib[i]);
}
#endif

}

const ExprFunc* ExprFunc::lookup(const std::string& name) {
Expand Down Expand Up @@ -255,18 +264,15 @@ void ExprFunc::loadPlugin(const char* path) {
typedef void (*initfn_v3)(ExprFunc::Define3);
initfn_v3 init_v3 = (initfn_v3)dlsym(handle, "SeExpr2PluginInit");

if (init_v3)
if (init_v3) {
init_v3(defineInternal3);
else {
void* init_v2 = dlsym(handle, "SeExprPluginInitV2");
void* init_v1 = dlsym(handle, "SeExprPluginInit");
if (!init_v1 && !init_v2) {
std::cerr << "Error reading expression plugin: " << path << std::endl;
std::cerr << "No functions named SeExprPluginInit and SeExprPluginInitV2 called" << std::endl;
}
dynlib.push_back(handle);
} else {
std::cerr << "Error reading expression plugin: " << path << std::endl;
std::cerr << "No function named SeExpr2PluginInit defined" << std::endl;
dlclose(handle);
return;
}
return;
#endif
}
}
1 change: 1 addition & 0 deletions src/SeExpr/ExprFunc.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ class ExprFunc {
ExprFuncX* _func;
int _minargs;
int _maxargs;
static std::vector<void*> dynlib;
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/SeExpr/ExprLLVMCodeGeneration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1111,7 +1111,7 @@ struct VarCodeGeneration {
varRef->type().isLifetimeUniform() ? baseMemory : Builder.CreateInBoundsGEP(baseMemory, indirectIndex);
return Builder.CreateLoad(variablePointer);
} else {
std::vector<Value *> loadedValues(3);
std::vector<Value *> loadedValues(dim);
for (int component = 0; component < dim; component++) {
Value *componentIndex = ConstantInt::get(Type::getInt32Ty(llvmContext), component);
/// If we are uniform always assume indirectIndex is 0 (there's only one value)
Expand Down
24 changes: 13 additions & 11 deletions src/SeExpr/ExprNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,9 @@ ExprType ExprModuleNode::prep(bool wantScalar, ExprVarEnvBuilder& envBuilder) {
}

ExprType ExprPrototypeNode::prep(bool wantScalar, ExprVarEnvBuilder& envBuilder) {
// TODO: implement prototype
bool error = false;
checkCondition(false, "Prototypes are currently not supported", error);
return ExprType().Error();
#if 0
bool error = false;

#if 0 // TODO: implement prototype
if (_retTypeSet) checkCondition(returnType().isValid(), "Function has bad return type", error);

_argTypes.clear();
Expand All @@ -155,14 +151,15 @@ ExprType ExprPrototypeNode::prep(bool wantScalar, ExprVarEnvBuilder& envBuilder)
std::cerr << "after create localvar phi " << localVar->getPhi() << std::endl;
child(c)->prep(wantScalar, envBuilder);
}

#else
checkCondition(false, "Prototypes are currently not supported", error);
#endif
if (error)
setType(ExprType().Error());
else
setType(ExprType().None().Varying());

return _type;
#endif
}

void ExprPrototypeNode::addArgTypes(ExprNode* surrogate) {
Expand All @@ -188,9 +185,10 @@ void ExprPrototypeNode::addArgs(ExprNode* surrogate) {
}

ExprType ExprLocalFunctionNode::prep(bool wantScalar, ExprVarEnvBuilder& envBuilder) {
#if 0 // TODO: no local functions for now
bool error = false;

#if 0 // TODO: no local functions for now

// prep prototype and check for errors
ExprPrototypeNode* prototype = (ExprPrototypeNode*)child(0);
ExprVarEnv functionEnv;
Expand Down Expand Up @@ -223,12 +221,16 @@ ExprType ExprLocalFunctionNode::prep(bool wantScalar, ExprVarEnvBuilder& envBuil
checkCondition(false, "Invalid type for blockType is " + blockType.toString(), error);
error = true;
}
return _type = error ? ExprType().Error() : ExprType().None().Varying();
#else
bool error = false;
checkCondition(false, "Local functions are currently not supported.", error);
return ExprType().Error();
#endif

if (error)
setType(ExprType().Error());
else
setType(ExprType().None().Varying());

return _type;
}

// TODO: write buildInterpreter for local function node
Expand Down
4 changes: 2 additions & 2 deletions src/SeExpr/ExprParser.y
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,11 @@ typeListOptional:
typeList:
typeDeclare { $$ = NODE(@$.first_column, @$.last_column, Node);
SeExpr2::ExprType type = SeExpr2::ExprType($1.type, $1.dim, $1.lifetime);
SeExpr2::ExprNode* varNode = NODE2(@$.first_column, @$.last_column, VarNode, 0, type);
SeExpr2::ExprNode* varNode = NODE2(@$.first_column, @$.last_column, VarNode, "", type);
$$->addChild(varNode); }
| typeList ',' typeDeclare { $$ = $1;
SeExpr2::ExprType type = SeExpr2::ExprType($3.type, $3.dim, $3.lifetime);
SeExpr2::ExprNode* varNode = NODE2(@3.first_column, @3.last_column, VarNode, 0, type);
SeExpr2::ExprNode* varNode = NODE2(@3.first_column, @3.last_column, VarNode, "", type);
$$->addChild(varNode); }
;

Expand Down
11 changes: 11 additions & 0 deletions src/build/build-info
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def main():
('python-site', python_site),
('python-inc', python_inc),
('pyqt4-sip', pyqt4_sip),
('pyqt-sip-flags', pyqt_sip_flags),
('sip-inc', sip_inc),
)

Expand Down Expand Up @@ -60,6 +61,16 @@ def pyqt4_sip(args):
return pkg_cfg['pyqt_sip_dir']


def pyqt_sip_flags(args):
try:
import PyQt5.Qt
return PyQt5.Qt.PYQT_CONFIGURATION['sip_flags']
except ImportError:
from PyQt4 import pyqtconfig
pkg_cfg = pyqtconfig._pkg_config
return pkg_cfg['pyqt_sip_flags']


def sip_inc(args):
pkg_cfg = sipconfig._pkg_config
return pkg_cfg['sip_inc_dir']
Expand Down
32 changes: 29 additions & 3 deletions src/demos/imageEditor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,52 @@
# Set application root dir for use inside the source code.
add_definitions(-DIMAGE_EDITOR_ROOT="${CMAKE_INSTALL_PREFIX}")

find_package(Qt4 COMPONENTS QtCore QtGui)
if (ENABLE_QT5)
find_package(Qt5 COMPONENTS Core Gui Widgets) # find and setup Qt5 for this project
include_directories(${Qt5Core_INCLUDE_DIRS}
${Qt5Gui_INCLUDE_DIRS}
${Qt5OpenGL_INCLUDE_DIRS})
else()
find_package(Qt4 COMPONENTS QtCore QtGui)
include_directories(${QT_INCLUDE_DIR}
${QT_INCLUDE_DIR}/QtCore
${QT_INCLUDE_DIR}/QtGui)
endif()

find_package(PNG)

if (QT4_FOUND AND PNG_FOUND)
if(Qt5_FOUND OR QT4_FOUND)
if(PNG_FOUND)
set(imageEditor_MOC_HDRS ImageEditorDialog.h)
set(imageEditor_CPPS imageEditor.cpp)

if (ENABLE_QT5)
qt5_wrap_cpp(imageEditor_MOC_SRCS ${imageEditor_MOC_HDRS})
else()
qt4_wrap_cpp(imageEditor_MOC_SRCS ${imageEditor_MOC_HDRS})
endif()

add_executable(imageEditor2 ${imageEditor_CPPS} ${imageEditor_MOC_SRCS})
include_directories(${QT_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${SEEXPR_EDITOR_INCLUDES})

if (ENABLE_QT5)
target_link_libraries(imageEditor2 Qt5::Core)
target_link_libraries(imageEditor2 Qt5::Gui)
target_link_libraries(imageEditor2 Qt5::Widgets)
else()
target_link_libraries(imageEditor2 ${QT_QTCORE_LIBRARY})
target_link_libraries(imageEditor2 ${QT_QTGUI_LIBRARY})
endif()

target_link_libraries(imageEditor2 ${SEEXPR_LIBRARIES})
target_link_libraries(imageEditor2 ${SEEXPR_EDITOR_LIBRARIES})

include_directories(SYSTEM ${PNG_INCLUDE_DIR})
target_link_libraries(imageEditor2 ${PNG_LIBRARIES})
install(TARGETS imageEditor2 DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
endif()

install(FILES fbm.se noisecolor1.se noisecolor2.se noise.se raytrace.se sinc.se
DESTINATION share/SeExpr2/expressions)
2 changes: 1 addition & 1 deletion src/demos/imageEditor/ImageEditorDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
@file ImageEditorDialog.h
*/

#include <QtGui/QDialog>
#include <QDialog>

class QLabel;
class ExprEditor;
Expand Down
26 changes: 13 additions & 13 deletions src/demos/imageEditor/imageEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@
#include <string>
#include <png.h>

#include <QtGui/QApplication>
#include <QtGui/QDialog>
#include <QtGui/QVBoxLayout>
#include <QtGui/QScrollArea>
#include <QtGui/QLabel>
#include <QtGui/QImage>
#include <QtGui/QPushButton>
#include <QtGui/QMessageBox>

#include <SeExpr2/UI/ExprControlCollection.h>
#include <SeExpr2/UI/ExprEditor.h>
#include <SeExpr2/UI/ExprBrowser.h>
#include <SeExpr2/Expression.h>
#include <QApplication>
#include <QDialog>
#include <QVBoxLayout>
#include <QScrollArea>
#include <QLabel>
#include <QImage>
#include <QPushButton>
#include <QMessageBox>

#include <ExprControlCollection.h>
#include <ExprEditor.h>
#include <ExprBrowser.h>
#include <Expression.h>

#include "ImageEditorDialog.h"

Expand Down
2 changes: 1 addition & 1 deletion src/demos/segraph/segraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*/
#include <QtGui/QApplication>
#include <QApplication>
#include "GraphWindow.h"
#include <cmath>
#include <cfloat>
Expand Down
Loading

0 comments on commit 5e09e1e

Please sign in to comment.