Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
codemercenary committed Nov 12, 2014
2 parents b6e3192 + 16ea83b commit 0842b44
Show file tree
Hide file tree
Showing 35 changed files with 353 additions and 107 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -36,4 +36,5 @@ autowiring/AutowiringConfig.h
*.nupkg
lib/*.*
autowiring-*-*.zip
_CPack_Packages
_CPack_Packages
win64/Autowiring.nuspec
4 changes: 2 additions & 2 deletions .travis.yml
Expand Up @@ -47,7 +47,7 @@ install:
before_script:
- export CPATH=/usr/include/c++/4.8:/usr/include/x86_64-linux-gnu/c++/4.8/:$CPATH
- export LD_LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/4.8:$LD_LIBRARY_PATH
- cmake . -DCMAKE_BUILD_TYPE=Release
- cmake . -DCMAKE_BUILD_TYPE=Release -Dautowiring_ARCHITECTURE=x64

script:
# Build Autowriring, run unit tests, and install
Expand All @@ -60,7 +60,7 @@ script:

# Build examples from installed Autowiring
- cd examples
&& cmake .
&& cmake . -Dautowiring_ARCHITECTURE=x64
&& make
&& cd ..

Expand Down
2 changes: 1 addition & 1 deletion Autowiring.nuspec → Autowiring.nuspec.in
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>autowiring</id>
<version>0.2.5</version>
<version>@autowiring_VERSION@</version>
<authors>Leap Motion</authors>
<owners>Leap Motion</owners>
<projectUrl>http://autowiring.io</projectUrl>
Expand Down
4 changes: 2 additions & 2 deletions AutowiringConfig.h.in
Expand Up @@ -9,8 +9,8 @@
#cmakedefine01 AUTOWIRING_BUILD_AUTONET

// Are we linking with C++11 STL?
#cmakedefine01 USE_LIBCXX
#if USE_LIBCXX
#cmakedefine01 autowiring_USE_LIBCXX
#if autowiring_USE_LIBCXX
#define AUTOWIRING_USE_LIBCXX 1
#else
#define AUTOWIRING_USE_LIBCXX 0
Expand Down
120 changes: 86 additions & 34 deletions CMakeLists.txt
@@ -1,13 +1,28 @@
cmake_minimum_required(VERSION 3.0)
include(version.cmake)
project(autowiring VERSION ${autowiring_VERSION})

include(CTest)
include(CheckTypeSize)

# Need to classify the architecture before we run anything else
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm")
set(autowiring_ARCHITECTURE "arm")
set(autowiring_BUILD_64 OFF)
elseif(CMAKE_SIZEOF_VOID_P STREQUAL 4)
set(autowiring_ARCHITECTURE "x86")
set(autowiring_BUILD_64 OFF)
else()
set(autowiring_ARCHITECTURE "x64")
set(autowiring_BUILD_64 ON)
endif()
message(STATUS "Using architecture: ${autowiring_ARCHITECTURE}")

# Determine whether Autowiring has been embedded in another project
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
set(AUTOWIRING_IS_EMBEDDED)
set(AUTOWIRING_IS_EMBEDDED OFF)
else()
set(AUTOWIRING_IS_EMBEDDED "TRUE")
set(AUTOWIRING_IS_EMBEDDED ON)
endif()

# If there's an external libraries directory path, use it as a search prefix
Expand All @@ -16,43 +31,71 @@ if(EXTERNAL_LIBRARY_DIR)
list(APPEND CMAKE_INCLUDE_PATH ${EXTERNAL_LIBRARY_DIR})
endif()

# Offer option for autowiring_USE_LIBCXX only if not defined by enclosing project
# Check for existing definition of autowiring_USE_LIBCXX
if(NOT DEFINED autowiring_USE_LIBCXX)
option(autowiring_USE_LIBCXX "Build Autowiring using c++11" ON)
if(APPLE)
# Offer option for autowiring_USE_LIBCXX
# Check for existing definition of autowiring_USE_LIBCXX
if(NOT DEFINED autowiring_USE_LIBCXX)
option(autowiring_USE_LIBCXX "Build Autowiring using c++11" ON)
else()
if(NOT autowiring_USE_LIBCXX)
message("Parent project has set autowiring_USE_LIBCXX = OFF -> Build Autowiring using c++98")
endif()
endif()
else()
if(NOT autowiring_USE_LIBCXX)
message("Parent project has set autowiring_USE_LIBCXX = OFF -> Build Autowiring using c++98")
# Always use libc++ on other platforms
set(autowiring_USE_LIBCXX ON)
endif()

if(CMAKE_COMPILER_IS_GNUCC)
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.8")
message(FATAL_ERROR "GCC version 4.8 minimum is required to build Autowiring")
endif()
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "18.0")
message(FATAL_ERROR "MSVC 2013 minimum is required to build Autowiring")
endif()
endif()

message("Version number ${CMAKE_CXX_COMPILER_VERSION}")

# Always use c++11 compiler
if(NOT WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libstdc++")
endif()
if(autowiring_USE_LIBCXX)
# Clang needs special additional flags to build with C++11
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
# Apple needs us to tell it that we're using libc++, or it will try to use libstdc++ instead

# Clang needs special additional flags to build with C++11
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
# Apple needs us to tell it that we're using libc++, or it will try to use libstdc++ instead
if(autowiring_USE_LIBCXX)
message("AppleClang C++11")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
message("Clang C++11")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lstdc++")
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
message("GCC C++11")
endif()

# Also need position-independent code to make things work correctly on certain 64-bit machines
if(${CMAKE_SIZEOF_VOID_P} STREQUAL 8)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
else()
message("AppleClang C++11 with libstdc++")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libstdc++")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libstdc++")
endif()
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
message("Clang C++11")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lstdc++")
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
message("GCC C++11")
endif()

# Also need position-independent code to make things work correctly on certain 64-bit machines
if(NOT WIN32 AND autowiring_BUILD_64)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
endif()

set_property(GLOBAL PROPERTY USE_FOLDERS ON)
include(CMakeModules/pch.cmake)
set(AUTOWIRING_BUILD_AUTONET_DEFAULT ON)

if(autowiring_ARCHITECTURE STREQUAL "arm")
# Currently cannot build Autonet for ARM, so default this off on that platform
set(AUTOWIRING_BUILD_AUTONET_DEFAULT OFF)
else()
set(AUTOWIRING_BUILD_AUTONET_DEFAULT ON)
endif()

# We don't build tests unless we're being built by ourselves in our own source tree
# When we're embedded in someone else's subtree, it's not likely that they will want
Expand Down Expand Up @@ -80,10 +123,23 @@ else()
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/lib)
endif()

# 64-bit installations should suffix with 64
if(${CMAKE_SIZEOF_VOID_P} STREQUAL 8)
set(CMAKE_DEBUG_POSTFIX "64")
set(CMAKE_RELEASE_POSTFIX "64")
# ARM installations should have "arm" as the suffix for the generated libraries and should be
# position-independent
if(autowiring_ARCHITECTURE STREQUAL "arm")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")

foreach(config IN LISTS CMAKE_CONFIGURATION_TYPES)
string(TOUPPER ${config} config)
string(CONCAT CMAKE_${config}_POSTFIX "${CMAKE_${config}_POSTFIX}" "64")
endforeach()
endif()

# 64-bit installations should suffix with 64 regardless of the CPU type (arm or intel)
if(autowiring_BUILD_64)
foreach(config IN LISTS CMAKE_CONFIGURATION_TYPES)
string(TOUPPER ${config} config)
string(CONCAT CMAKE_${config}_POSTFIX "${CMAKE_${config}_POSTFIX}" "64")
endforeach()
endif()

# Postfix on all debug libraries should be "d"
Expand Down Expand Up @@ -123,14 +179,10 @@ include_directories(
)

# CMake configurations
if(${CMAKE_SIZEOF_VOID_P} STREQUAL 8)
set(autowiring_ARCHITECTURE "64")
else()
set(autowiring_ARCHITECTURE "32")
endif()
configure_file(autowiring-config.cmake.in autowiring-config.cmake @ONLY)
configure_file(autowiring-configVersion.cmake.in autowiring-configVersion.cmake @ONLY)
configure_file(AutowiringConfig.h.in ${PROJECT_SOURCE_DIR}/autowiring/AutowiringConfig.h @ONLY)
configure_file(Autowiring.nuspec.in ${PROJECT_BINARY_DIR}/Autowiring.nuspec @ONLY)

# Recurse through source directories
add_subdirectory(src)
Expand Down Expand Up @@ -160,7 +212,7 @@ if(NOT AUTOWIRING_IS_EMBEDDED)
install(EXPORT AutowiringTargets FILE AutowiringTargets.cmake COMPONENT autowiring NAMESPACE Autowiring:: DESTINATION cmake CONFIGURATIONS ${CMAKE_CONFIGURATION_TYPES})

# 64-bit installations get a different upgrade GUID
if(CMAKE_SIZEOF_VOID_P STREQUAL 8)
if(autowiring_BUILD_64)
set(autowiring_GUID_LAST_CHAR E)
else()
set(autowiring_GUID_LAST_CHAR D)
Expand Down
19 changes: 19 additions & 0 deletions README.md
Expand Up @@ -31,6 +31,10 @@ CentOS systems use yum. The major apparent difference to the user will be that
make test
sudo make install

If you want to build for 32-bit Linux, run the following CMake command instead:

cmake . -DCMAKE_CXX_FLAGS=-m32 -DCMAKE_C_FLAGS=-m32

### Windows

Unfortunately, Windows doesn't have any sort of nifty package manager, and this requires that you download and install the boost dependency by hand. Once
Expand All @@ -47,6 +51,21 @@ At this point, you'll have a solution file in your root directory called "Autowi
target then Autowiring will be installed on your system. As with the other platforms, CMake will be able to find autowiring when it's installed this way
via the [find_package](http://www.cmake.org/cmake/help/v3.0/command/find_package.html) command.

### Arm-linux

Building on Android requires the use of a toolchain file. You will need to use an alternate prefix path if you are trying to cross-compile, the prefix path
should contain your version of the Boost libraries built for Android. To configure, use the following invocation:

cmake . -DCMAKE_TOOLCHAIN_FILE=toolchain-arm.cmake -DCMAKE_PREFIX_PATH:PATH=/your/lib/path

### Android

Similar requirements to Arm-linux, you must specify a toolchain file. You must also specify the path to your Android toolchain directory. Make sure you update
/opt/android-standalone-toolchain to point to your actual Android standalone toolchain directory. If you aren't cross-compiling, then simply run cmake with
no options.

cmake . -DCMAKE_TOOLCHAIN_FILE=toolchain-android.cmake -DLLVM_ANDROID_TOOLCHAIN_DIR=/opt/android-standalone-toolchain

# Install

Autowiring uses CPack, which knows how to use rpm/deb/wix/dragndrop, and will target the correct version depending on which system you're on. To build
Expand Down
58 changes: 56 additions & 2 deletions autowiring-configVersion.cmake.in
@@ -1,9 +1,63 @@
set(PACKAGE_VERSION "@autowiring_VERSION@")

# Verify that we have a bit depth matching the bit depth desired by the customer
if(NOT ${CMAKE_SIZEOF_VOID_P} STREQUAL @CMAKE_SIZEOF_VOID_P@)
if(autowiring_DEBUG)
message(STATUS "Debug mode on")
message(STATUS "Installed autowiring_VERSION: @autowiring_VERSION@")

message(STATUS "Installed autowiring_ARCHITECTURE: @autowiring_ARCHITECTURE@")
message(STATUS "Configured autowiring_ARCHITECTURE: ${autowiring_ARCHITECTURE}")

message(STATUS "Installed CMAKE_SIZEOF_VOID_P: @CMAKE_SIZEOF_VOID_P@")
message(STATUS "Configured CMAKE_SIZEOF_VOID_P: ${CMAKE_SIZEOF_VOID_P}")

message(STATUS "Installed using autowiring_USE_LIBCXX: @autowiring_USE_LIBCXX@")
message(STATUS "Configured using autowiring_USE_LIBCXX: ${autowiring_USE_LIBCXX}")
endif()

# If the customer has an override architecture requirement, use that
if(DEFINED autowiring_ARCHITECTURE)
string(REGEX MATCH "amd64|x86_64|x64" autowiring_is_x64 ${autowiring_ARCHITECTURE})
string(REGEX MATCH "i386|x86" autowiring_is_x86 ${autowiring_ARCHITECTURE})
string(REGEX MATCH "arm" autowiring_is_arm ${autowiring_ARCHITECTURE})

# Clear the autowiring_ARCHITECTURE variable so we can tell if something went wrong
set(autowiring_ARCHITECTURE)

# Classify
if(autowiring_is_x86)
set(autowiring_ARCHITECTURE x86)
elseif(autowiring_is_x64)
set(autowiring_ARCHITECTURE x64)
elseif(autowiring_is_arm)
set(autowiring_ARCHITECTURE arm)
endif()

if(NOT DEFINED autowiring_ARCHITECTURE)
message(WARNING "Unrecognized architecture ${autowiring_ARCHITECTURE}")
set(autowiring_WORD_WIDTH -1)
endif()
else()
# Try to infer what the user wants
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm")
set(autowiring_ARCHITECTURE arm)
elseif(CMAKE_SIZEOF_VOID_P EQUAL "8")
set(autowiring_ARCHITECTURE x64)
else()
set(autowiring_ARCHITECTURE x86)
endif()
endif()

if(autowiring_DEBUG)
message(STATUS "autowiring_ARCHITECTURE: ${autowiring_ARCHITECTURE}")
endif()

# Verify that we have a word width matching the bit depth desired by the customer
if(NOT autowiring_ARCHITECTURE STREQUAL "@autowiring_ARCHITECTURE@")
set(PACKAGE_VERSION_COMPATIBLE FALSE)
set(PACKAGE_VERSION_UNSUITABLE TRUE)
if(autowiring_DEBUG)
message(STATUS "Requested architecture of ${autowiring_ARCHITECTURE} not compatible with @autowiring_ARCHITECTURE@")
endif()
return()
endif()

Expand Down
10 changes: 6 additions & 4 deletions autowiring/AutoPacket.h
Expand Up @@ -2,15 +2,15 @@
#pragma once
#include "AnySharedPointer.h"
#include "at_exit.h"
#include "DataFlow.h"
#include "AutoCheckout.h"
#include "DataFlow.h"
#include "DecorationDisposition.h"
#include "demangle.h"
#include "is_shared_ptr.h"
#include "ObjectPool.h"
#include "hash_tuple.h"
#include "is_any.h"
#include "is_shared_ptr.h"
#include "MicroAutoFilter.h"
#include "hash_tuple.h"
#include "ObjectPool.h"
#include <list>
#include <sstream>
#include <typeinfo>
Expand Down Expand Up @@ -199,6 +199,8 @@ class AutoPacket:
/// </summary>
template<class T>
const T& Get(const std::type_info& source = typeid(void)) const {
static_assert(!std::is_same<T, AnySharedPointer>::value, "Oops!");

const T* retVal;
if(!Get(retVal, source)) {
std::stringstream ss;
Expand Down
12 changes: 5 additions & 7 deletions autowiring/AutoPacketFactory.h
Expand Up @@ -13,6 +13,7 @@
#include STL_UNORDERED_SET

struct AdjacencyEntry;
class AutoPacketFactory;
class Deferred;
class DispatchQueue;

Expand Down Expand Up @@ -210,12 +211,7 @@ class AutoPacketFactory:
void PipeOneData(const std::type_info* nodeOutType, const std::type_info* nodeInType, const std::type_info* dataType, bool enable);
void PipeAllData(const std::type_info* nodeOutType, const std::type_info* nodeInType, bool enable);

static bool IsAutoPacketType(const std::type_info& dataType) {
return
dataType == typeid(AutoPacket) ||
dataType == typeid(auto_arg<AutoPacket&>::id_type) ||
dataType == typeid(auto_arg<const AutoPacket&>::id_type);
}
static bool IsAutoPacketType(const std::type_info& dataType);

public:
/// <summary>
Expand All @@ -225,11 +221,13 @@ class AutoPacketFactory:
std::shared_ptr<AutoPacket> NewPacket(void);

/// <returns>the number of outstanding AutoPackets</returns>
size_t GetOutstanding(void) const { return m_packets.GetOutstanding(); }
size_t GetOutstanding(void) const;
};

// Extern explicit template instantiation declarations added to prevent
// exterior instantation of internally used template instances
extern template class ObjectPool<AutoPacket>;
extern template class RegType<AutoPacketFactory>;
extern template struct SlotInformationStump<AutoPacketFactory, false>;
extern template const std::shared_ptr<AutoPacketFactory>& SharedPointerSlot::as<AutoPacketFactory>(void) const;
extern template std::shared_ptr<AutoPacketFactory> autowiring::fast_pointer_cast<AutoPacketFactory, Object>(const std::shared_ptr<Object>& Other);

0 comments on commit 0842b44

Please sign in to comment.