Structure: Python module is now standalone (setup.py generated by cmake). Better directory hierarchy
This commit is contained in:
@@ -17,17 +17,42 @@ if(CUDA_FOUND)
|
|||||||
include_directories(${CUDA_INCLUDE_DIRS})
|
include_directories(${CUDA_INCLUDE_DIRS})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
ADD_DEFINITIONS(-Wno-sign-compare -D__CL_ENABLE_EXCEPTIONS ${BACKEND_DEFINES} -Wall -Wextra -pedantic -std=c++11)
|
add_definitions(-Wno-sign-compare -D__CL_ENABLE_EXCEPTIONS ${BACKEND_DEFINES} -Wall -Wextra -pedantic -std=c++11)
|
||||||
ADD_EXECUTABLE(bin2cpp ${CMAKE_MODULE_PATH}/bin2cpp.cpp)
|
add_executable(bin2cpp ${CMAKE_MODULE_PATH}/helpers/bin2cpp.cpp)
|
||||||
|
|
||||||
include(CTest)
|
|
||||||
|
|
||||||
file(GLOB_RECURSE LIBISAAC_SRC lib/*.cpp)
|
file(GLOB_RECURSE LIBISAAC_SRC lib/*.cpp)
|
||||||
|
|
||||||
|
#Python wrapper
|
||||||
|
set(SETUP_PY_IN "${CMAKE_MODULE_PATH}/python/setup.py")
|
||||||
|
set(SETUP_PY "${CMAKE_SOURCE_DIR}/python/setup.py")
|
||||||
|
|
||||||
|
set(LIBISAAC_SRC_STR)
|
||||||
|
foreach(FILE ${LIBISAAC_SRC})
|
||||||
|
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}" "src" _TMP ${FILE})
|
||||||
|
set(LIBISAAC_SRC_STR "${_TMP} ${LIBISAAC_SRC_STR}")
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
set(INCLUDE_DIRECTORIES_STR)
|
||||||
|
get_property(INCLUDE_DIRECTORIES_LST DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)
|
||||||
|
set(INCLUDE_DIRECTORIES_STR)
|
||||||
|
foreach(FILE ${INCLUDE_DIRECTORIES_LST})
|
||||||
|
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}" "src" _TMP ${FILE})
|
||||||
|
set(INCLUDE_DIRECTORIES "${INCLUDE_DIRECTORIES} ${_TMP}")
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
configure_file(${SETUP_PY_IN} ${SETUP_PY})
|
||||||
|
add_custom_command(OUTPUT "${CMAKE_BINARY_DIR}/build/timestamp"
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_SOURCE_DIR}/python/src/lib
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_SOURCE_DIR}/python/src/include
|
||||||
|
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/lib ${CMAKE_SOURCE_DIR}/python/src/lib
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/python/src/include)
|
||||||
|
add_custom_target(package-python ALL DEPENDS "${CMAKE_BINARY_DIR}/build/timestamp")
|
||||||
|
|
||||||
|
|
||||||
|
#Isaac
|
||||||
|
include(CTest)
|
||||||
|
|
||||||
add_subdirectory(lib)
|
add_subdirectory(lib)
|
||||||
add_subdirectory(tests)
|
add_subdirectory(tests)
|
||||||
add_subdirectory(bench)
|
add_subdirectory(bench)
|
||||||
find_program(PYTHON "python")
|
|
||||||
if(PYTHON)
|
|
||||||
add_subdirectory(python)
|
|
||||||
#add_subdirectory(tune)
|
|
||||||
endif()
|
|
||||||
|
259
cmake/apk.cmake
259
cmake/apk.cmake
@@ -1,259 +0,0 @@
|
|||||||
#*********************************************************#
|
|
||||||
#* File: Apk.cmake *
|
|
||||||
#* Android apk tools
|
|
||||||
#*
|
|
||||||
#* Copyright (C) 2002-2013 The PixelLight Team (http://www.pixellight.org/)
|
|
||||||
#*
|
|
||||||
#* This file is part of PixelLight.
|
|
||||||
#*
|
|
||||||
#* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
|
||||||
#* and associated documentation files (the "Software"), to deal in the Software without
|
|
||||||
#* restriction, including without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
#* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
|
|
||||||
#* Software is furnished to do so, subject to the following conditions:
|
|
||||||
#*
|
|
||||||
#* The above copyright notice and this permission notice shall be included in all copies or
|
|
||||||
#* substantial portions of the Software.
|
|
||||||
#*
|
|
||||||
#* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
|
|
||||||
#* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
#* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
||||||
#* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
#* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
#*********************************************************#
|
|
||||||
|
|
||||||
|
|
||||||
##################################################
|
|
||||||
## Options
|
|
||||||
##################################################
|
|
||||||
set(ANDROID_APK_CREATE "1" CACHE BOOL "Create apk file?")
|
|
||||||
set(ANDROID_APK_INSTALL "1" CACHE BOOL "Install created apk file on the device automatically?")
|
|
||||||
set(ANDROID_APK_RUN "1" CACHE BOOL "Run created apk file on the device automatically? (installs it automatically as well, \"ANDROID_APK_INSTALL\"-option is ignored)")
|
|
||||||
set(ANDROID_APK_TOP_LEVEL_DOMAIN "org" CACHE STRING "Top level domain name of the organization (follow the package naming conventions (http://en.wikipedia.org/wiki/Java_package#Package_naming_conventions))")
|
|
||||||
set(ANDROID_APK_DOMAIN "pixellight" CACHE STRING "Organization's domain (follow the package naming conventions (http://en.wikipedia.org/wiki/Java_package#Package_naming_conventions))")
|
|
||||||
set(ANDROID_APK_SUBDOMAIN "test" CACHE STRING "Any subdomains (follow the package naming conventions (http://en.wikipedia.org/wiki/Java_package#Package_naming_conventions))")
|
|
||||||
set(ANDROID_APK_FULLSCREEN "1" CACHE BOOL "Run the application in fullscreen? (no status/title bar)")
|
|
||||||
set(ANDROID_APK_RELEASE "0" CACHE BOOL "Create apk file ready for release? (signed, you have to enter a password during build, do also setup \"ANDROID_APK_SIGNER_KEYSTORE\" and \"ANDROID_APK_SIGNER_ALIAS\")")
|
|
||||||
set(ANDROID_APK_SIGNER_KEYSTORE "~/my-release-key.keystore" CACHE STRING "Keystore for signing the apk file (only required for release apk)")
|
|
||||||
set(ANDROID_APK_SIGNER_ALIAS "myalias" CACHE STRING "Alias for signing the apk file (only required for release apk)")
|
|
||||||
|
|
||||||
|
|
||||||
##################################################
|
|
||||||
## Variables
|
|
||||||
##################################################
|
|
||||||
set(ANDROID_THIS_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}) # Directory this CMake file is in
|
|
||||||
|
|
||||||
|
|
||||||
##################################################
|
|
||||||
## MACRO: android_create_apk
|
|
||||||
##
|
|
||||||
## Create/copy Android apk related files
|
|
||||||
##
|
|
||||||
## @param name
|
|
||||||
## Name of the project (e.g. "MyProject"), this will also be the name of the created apk file
|
|
||||||
## @param apk_directory
|
|
||||||
## Directory were to construct the apk file in (e.g. "${CMAKE_BINARY_DIR}/apk")
|
|
||||||
## @param shared_libraries
|
|
||||||
## List of shared libraries (absolute filenames) this application is using, these libraries are copied into the apk file and will be loaded automatically within a generated Java file - Lookout! The order is important due to shared library dependencies!
|
|
||||||
## @param assets
|
|
||||||
## List of assets to copy into the apk file (absolute filenames, wildcards like "*.*" are allowed)
|
|
||||||
## @param data_directory
|
|
||||||
## Subdirectory within the apk asset directory to copy the "assets"-files into (e.g. "Data")
|
|
||||||
##
|
|
||||||
## @remarks
|
|
||||||
## Requires the following tools to be found automatically
|
|
||||||
## - "android" (part of the Android SDK)
|
|
||||||
## - "adb" (part of the Android SDK)
|
|
||||||
## - "ant" (type e.g. "sudo apt-get install ant" on your Linux system to install Ant)
|
|
||||||
## - "jarsigner" (part of the JDK)
|
|
||||||
## - "zipalign" (part of the Android SDK)
|
|
||||||
##################################################
|
|
||||||
macro(android_create_apk name apk_directory shared_libraries assets data_directory)
|
|
||||||
if(ANDROID_APK_CREATE)
|
|
||||||
# Construct the current package name and theme
|
|
||||||
set(ANDROID_APK_PACKAGE "${ANDROID_APK_TOP_LEVEL_DOMAIN}.${ANDROID_APK_DOMAIN}.${ANDROID_APK_SUBDOMAIN}")
|
|
||||||
if(ANDROID_APK_FULLSCREEN)
|
|
||||||
set(ANDROID_APK_THEME "android:theme=\"@android:style/Theme.NoTitleBar.Fullscreen\"")
|
|
||||||
else()
|
|
||||||
set(ANDROID_APK_THEME "")
|
|
||||||
endif()
|
|
||||||
set(ANDROID_NAME ${name})
|
|
||||||
if(CMAKE_BUILD_TYPE MATCHES Debug)
|
|
||||||
set(ANDROID_APK_DEBUGGABLE "true")
|
|
||||||
set(ANDROID_APK_RELEASE_LOCAL "0")
|
|
||||||
else()
|
|
||||||
set(ANDROID_APK_DEBUGGABLE "false")
|
|
||||||
set(ANDROID_APK_RELEASE_LOCAL ${ANDROID_APK_RELEASE})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Create "AndroidManifest.xml"
|
|
||||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/android/AndroidManifest.xml.in" "${apk_directory}/AndroidManifest.xml")
|
|
||||||
|
|
||||||
# Create "res/values/strings.xml"
|
|
||||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/android/strings.xml.in" "${apk_directory}/res/values/strings.xml")
|
|
||||||
|
|
||||||
# Get a list of libraries to load in (e.g. "PLCore;PLMath" etc.)
|
|
||||||
set(ANDROID_SHARED_LIBRARIES_TO_LOAD "")
|
|
||||||
foreach(value ${shared_libraries})
|
|
||||||
# "value" is e.g. "/home/cofenberg/pl_ndk/Bin-Linux-ndk/Runtime/armeabi/libPLCore.so"
|
|
||||||
get_filename_component(shared_library_filename ${value} NAME_WE)
|
|
||||||
|
|
||||||
# "shared_library_filename" is e.g. "libPLCore", but we need "PLCore"
|
|
||||||
string(LENGTH ${shared_library_filename} shared_library_filename_length)
|
|
||||||
math(EXPR shared_library_filename_length ${shared_library_filename_length}-3)
|
|
||||||
string(SUBSTRING ${shared_library_filename} 3 ${shared_library_filename_length} shared_library_filename)
|
|
||||||
|
|
||||||
# "shared_library_filename" is now e.g. "PLCore", this is what we want -> Add it to the list
|
|
||||||
set(ANDROID_SHARED_LIBRARIES_TO_LOAD ${ANDROID_SHARED_LIBRARIES_TO_LOAD} ${shared_library_filename})
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
# Create Java file which is responsible for loading in the required shared libraries (the content of "ANDROID_SHARED_LIBRARIES_TO_LOAD" is used for this)
|
|
||||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/android/LoadLibraries.java.in" "${apk_directory}/src/${ANDROID_APK_TOP_LEVEL_DOMAIN}/${ANDROID_APK_DOMAIN}/${ANDROID_APK_SUBDOMAIN}/LoadLibraries.java")
|
|
||||||
|
|
||||||
# Create the directory for the libraries
|
|
||||||
add_custom_command(TARGET ${ANDROID_NAME}
|
|
||||||
PRE_BUILD
|
|
||||||
COMMAND ${CMAKE_COMMAND} -E remove_directory "${apk_directory}/libs"
|
|
||||||
)
|
|
||||||
add_custom_command(TARGET ${ANDROID_NAME}
|
|
||||||
PRE_BUILD
|
|
||||||
COMMAND ${CMAKE_COMMAND} -E make_directory "${apk_directory}/libs/${ARM_TARGET}"
|
|
||||||
)
|
|
||||||
|
|
||||||
# Copy the used shared libraries
|
|
||||||
foreach(value ${shared_libraries})
|
|
||||||
add_custom_command(TARGET ${ANDROID_NAME}
|
|
||||||
POST_BUILD
|
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy ${value} "${apk_directory}/libs/${ARM_TARGET}"
|
|
||||||
)
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
# Create "build.xml", "default.properties", "local.properties" and "proguard.cfg" files
|
|
||||||
add_custom_command(TARGET ${ANDROID_NAME}
|
|
||||||
COMMAND android update project -t android-${ANDROID_API_LEVEL} --name ${ANDROID_NAME} --path "${apk_directory}"
|
|
||||||
)
|
|
||||||
|
|
||||||
# Copy assets
|
|
||||||
add_custom_command(TARGET ${ANDROID_NAME}
|
|
||||||
PRE_BUILD
|
|
||||||
COMMAND ${CMAKE_COMMAND} -E remove_directory "${apk_directory}/assets"
|
|
||||||
)
|
|
||||||
add_custom_command(TARGET ${ANDROID_NAME}
|
|
||||||
PRE_BUILD
|
|
||||||
COMMAND ${CMAKE_COMMAND} -E make_directory "${apk_directory}/assets/${data_directory}"
|
|
||||||
)
|
|
||||||
#foreach(value ${assets})
|
|
||||||
# android_copy_files(${value} "${apk_directory}/assets/${data_directory}")
|
|
||||||
#endforeach()
|
|
||||||
|
|
||||||
# In case of debug build, do also copy gdbserver
|
|
||||||
#if(CMAKE_BUILD_TYPE MATCHES Debug)
|
|
||||||
# add_custom_command(TARGET ${ANDROID_NAME}
|
|
||||||
# POST_BUILD
|
|
||||||
# COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_GDBSERVER} "${apk_directory}/libs/${ARM_TARGET}"
|
|
||||||
# )
|
|
||||||
#endif()
|
|
||||||
|
|
||||||
# Uninstall previous version from the device/emulator (else we may get e.g. signature conflicts)
|
|
||||||
add_custom_command(TARGET ${ANDROID_NAME}
|
|
||||||
COMMAND adb uninstall ${ANDROID_APK_PACKAGE}
|
|
||||||
)
|
|
||||||
|
|
||||||
# Build the apk file
|
|
||||||
if(ANDROID_APK_RELEASE_LOCAL)
|
|
||||||
# Let Ant create the unsigned apk file
|
|
||||||
add_custom_command(TARGET ${ANDROID_NAME}
|
|
||||||
COMMAND ant release
|
|
||||||
WORKING_DIRECTORY "${apk_directory}"
|
|
||||||
)
|
|
||||||
|
|
||||||
# Sign the apk file
|
|
||||||
add_custom_command(TARGET ${ANDROID_NAME}
|
|
||||||
COMMAND jarsigner -verbose -keystore ${ANDROID_APK_SIGNER_KEYSTORE} bin/${ANDROID_NAME}-unsigned.apk ${ANDROID_APK_SIGNER_ALIAS}
|
|
||||||
WORKING_DIRECTORY "${apk_directory}"
|
|
||||||
)
|
|
||||||
|
|
||||||
# Align the apk file
|
|
||||||
add_custom_command(TARGET ${ANDROID_NAME}
|
|
||||||
COMMAND zipalign -v -f 4 bin/${ANDROID_NAME}-unsigned.apk bin/${ANDROID_NAME}.apk
|
|
||||||
WORKING_DIRECTORY "${apk_directory}"
|
|
||||||
)
|
|
||||||
|
|
||||||
# Install current version on the device/emulator
|
|
||||||
if(ANDROID_APK_INSTALL OR ANDROID_APK_RUN)
|
|
||||||
add_custom_command(TARGET ${ANDROID_NAME}
|
|
||||||
COMMAND adb install -r bin/${ANDROID_NAME}.apk
|
|
||||||
WORKING_DIRECTORY "${apk_directory}"
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
else()
|
|
||||||
# Let Ant create the unsigned apk file
|
|
||||||
add_custom_command(TARGET ${ANDROID_NAME}
|
|
||||||
COMMAND ant debug
|
|
||||||
WORKING_DIRECTORY "${apk_directory}"
|
|
||||||
)
|
|
||||||
|
|
||||||
# Install current version on the device/emulator
|
|
||||||
if(ANDROID_APK_INSTALL OR ANDROID_APK_RUN)
|
|
||||||
add_custom_command(TARGET ${ANDROID_NAME}
|
|
||||||
COMMAND adb install -r bin/${ANDROID_NAME}-debug.apk
|
|
||||||
WORKING_DIRECTORY "${apk_directory}"
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Start the application
|
|
||||||
if(ANDROID_APK_RUN)
|
|
||||||
add_custom_command(TARGET ${ANDROID_NAME}
|
|
||||||
COMMAND adb shell am start -n ${ANDROID_APK_PACKAGE}/${ANDROID_APK_PACKAGE}.LoadLibraries
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
endmacro(android_create_apk name apk_directory shared_libraries assets data_directory)
|
|
||||||
|
|
||||||
##################################################
|
|
||||||
## MACRO: android_copy_files
|
|
||||||
##
|
|
||||||
## Copy files from one place to another using wildcards
|
|
||||||
##################################################
|
|
||||||
macro(android_copy_files src dest)
|
|
||||||
# Get path
|
|
||||||
get_filename_component(path ${src} PATH)
|
|
||||||
|
|
||||||
# Get exclude option
|
|
||||||
set(exclude)
|
|
||||||
if("${ARGV2}" STREQUAL "EXCLUDE")
|
|
||||||
set(exclude ${ARGV3})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Find files
|
|
||||||
file(GLOB_RECURSE files RELATIVE ${path} ${src})
|
|
||||||
|
|
||||||
# Find files
|
|
||||||
foreach(file ${files})
|
|
||||||
# Get source and destination file
|
|
||||||
set(src_file ${path}/${file})
|
|
||||||
set(dst_file ${dest}/${file})
|
|
||||||
|
|
||||||
# Check exclude expression
|
|
||||||
set(copy 1)
|
|
||||||
if(exclude)
|
|
||||||
if(file MATCHES ${exclude})
|
|
||||||
set(copy 0)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Process file
|
|
||||||
if(copy EQUAL 1)
|
|
||||||
# Create output directory
|
|
||||||
get_filename_component(dst_path ${dst_file} PATH)
|
|
||||||
file(MAKE_DIRECTORY ${dst_path})
|
|
||||||
|
|
||||||
# Copy file
|
|
||||||
add_custom_command(TARGET ${ANDROID_NAME}
|
|
||||||
PRE_BUILD
|
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy ${src_file} ${dst_file} VERBATIM
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
endforeach(file ${files})
|
|
||||||
endmacro(android_copy_files src dest)
|
|
@@ -54,17 +54,12 @@ def main():
|
|||||||
cvars["LDFLAGS"] = '-Wl,--no-as-needed ' + cvars["LDFLAGS"]
|
cvars["LDFLAGS"] = '-Wl,--no-as-needed ' + cvars["LDFLAGS"]
|
||||||
|
|
||||||
#Includes
|
#Includes
|
||||||
include ='${INCLUDE_DIRECTORIES_STR}'.split() +\
|
include ='${INCLUDE_DIRECTORIES_STR}'.split() + ['external/boost/include', os.path.join(find_module("numpy")[1], "core", "include")]
|
||||||
['${CMAKE_CURRENT_SOURCE_DIR}/external/boost/include',
|
|
||||||
os.path.join(find_module("numpy")[1], "core", "include")]
|
|
||||||
|
|
||||||
#Sources
|
#Sources
|
||||||
src = '${LIBISAAC_SRC_STR}'.split() +\
|
src = '${LIBISAAC_SRC_STR}'.split() + [os.path.join('src', 'wrap', sf) for sf in ['_isaac.cpp', 'core.cpp', 'driver.cpp', 'model.cpp', 'exceptions.cpp']]
|
||||||
[os.path.join('${CMAKE_CURRENT_SOURCE_DIR}', 'src', sf) \
|
boostsrc = 'external/boost/libs/'
|
||||||
for sf in ['_isaac.cpp', 'core.cpp', 'driver.cpp', 'model.cpp', 'exceptions.cpp']]
|
|
||||||
boostsrc = '${CMAKE_CURRENT_SOURCE_DIR}/external/boost/libs/'
|
|
||||||
for s in ['numpy','python','smart_ptr','system','thread']:
|
for s in ['numpy','python','smart_ptr','system','thread']:
|
||||||
src = src + [x for x in recursive_glob('${CMAKE_CURRENT_SOURCE_DIR}/external/boost/libs/' + s + '/src/','.cpp') if 'win32' not in x and 'pthread' not in x]
|
src = src + [x for x in recursive_glob('external/boost/libs/' + s + '/src/','.cpp') if 'win32' not in x and 'pthread' not in x]
|
||||||
# make sure next line succeeds even on Windows
|
# make sure next line succeeds even on Windows
|
||||||
src = [f.replace("\\", "/") for f in src]
|
src = [f.replace("\\", "/") for f in src]
|
||||||
if sys.platform == "win32":
|
if sys.platform == "win32":
|
||||||
@@ -83,7 +78,6 @@ def main():
|
|||||||
author_email='ptillet@g.harvard.edu',
|
author_email='ptillet@g.harvard.edu',
|
||||||
license='MPL 2.0',
|
license='MPL 2.0',
|
||||||
packages=["isaac"],
|
packages=["isaac"],
|
||||||
package_dir={ '': '${CMAKE_CURRENT_BINARY_DIR}' },
|
|
||||||
ext_package="isaac",
|
ext_package="isaac",
|
||||||
ext_modules=[Extension(
|
ext_modules=[Extension(
|
||||||
'_isaac',src,
|
'_isaac',src,
|
@@ -2,13 +2,13 @@ file( GLOB_RECURSE PYTHON_SRC *.cpp)
|
|||||||
file( GLOB_RECURSE PYTHON_PYSRC *.py)
|
file( GLOB_RECURSE PYTHON_PYSRC *.py)
|
||||||
add_custom_target( MAKE_PYTHON_SRC_VISIBLE SOURCES ${PYTHON_SRC} ${PYTHON_PYSRC})
|
add_custom_target( MAKE_PYTHON_SRC_VISIBLE SOURCES ${PYTHON_SRC} ${PYTHON_PYSRC})
|
||||||
|
|
||||||
set(SETUP_PY_IN "${CMAKE_CURRENT_SOURCE_DIR}/external/cmake/setup.py")
|
set(SETUP_PY_IN "${CMAKE_MODULES_PATH}/python/setup.py")
|
||||||
set(SETUP_PY "${CMAKE_CURRENT_SOURCE_DIR}/setup.py")
|
set(SETUP_PY "${CMAKE_CURRENT_SOURCE_DIR}/setup.py")
|
||||||
set(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/build")
|
set(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/build")
|
||||||
|
|
||||||
function(JOIN VALUES GLUE OUTPUT)
|
function(JOIN VALUES GLUE OUTPUT)
|
||||||
string (REGEX REPLACE "([^\\]|^);" "\\1${GLUE}" _TMP_STR "${VALUES}")
|
string (REGEX REPLACE "([^\\]|^);" "\\1${GLUE}" _TMP_STR "${VALUES}")
|
||||||
string (REGEX REPLACE "[\\](.)" "\\1" _TMP_STR "${_TMP_STR}") #fixes escaping
|
string (REGEX REPLACE "[\\](.)" "\\1" _TMP_STR "${_TMP_STR}")
|
||||||
set (${OUTPUT} "${_TMP_STR}" PARENT_SCOPE)
|
set (${OUTPUT} "${_TMP_STR}" PARENT_SCOPE)
|
||||||
endfunction()
|
endfunction()
|
||||||
join("${LIBISAAC_SRC}" " " LIBISAAC_SRC_STR)
|
join("${LIBISAAC_SRC}" " " LIBISAAC_SRC_STR)
|
||||||
|
110
python/setup.py
Normal file
110
python/setup.py
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
#Thanks to Andreas Knoeckler for providing stand-alone boost.python
|
||||||
|
#through PyOpenCL and PyCUDA
|
||||||
|
|
||||||
|
import os, sys
|
||||||
|
from distutils.command.build_ext import build_ext
|
||||||
|
from distutils.command.build_py import build_py
|
||||||
|
from distutils.core import setup, Extension
|
||||||
|
from distutils.sysconfig import get_python_inc
|
||||||
|
from distutils import sysconfig
|
||||||
|
from imp import find_module
|
||||||
|
from glob import glob
|
||||||
|
|
||||||
|
platform_cflags = {}
|
||||||
|
platform_ldflags = {}
|
||||||
|
platform_libs = {}
|
||||||
|
|
||||||
|
class build_ext_subclass(build_ext):
|
||||||
|
def build_extensions(self):
|
||||||
|
c = self.compiler.compiler_type
|
||||||
|
if c in platform_cflags.keys():
|
||||||
|
for e in self.extensions:
|
||||||
|
e.extra_compile_args = platform_cflags[c]
|
||||||
|
if c in platform_ldflags.keys():
|
||||||
|
for e in self.extensions:
|
||||||
|
e.extra_link_args = platform_ldflags[c]
|
||||||
|
if c in platform_libs.keys():
|
||||||
|
for e in self.extensions:
|
||||||
|
try:
|
||||||
|
e.libraries += platform_libs[c]
|
||||||
|
except:
|
||||||
|
e.libraries = platform_libs[c]
|
||||||
|
build_ext.build_extensions(self)
|
||||||
|
|
||||||
|
def main():
|
||||||
|
|
||||||
|
def recursive_glob(rootdir='.', suffix=''):
|
||||||
|
return [os.path.join(looproot, filename)
|
||||||
|
for looproot, _, filenames in os.walk(rootdir)
|
||||||
|
for filename in filenames if filename.endswith(suffix)]
|
||||||
|
|
||||||
|
def remove_prefixes(optlist, bad_prefixes):
|
||||||
|
for bad_prefix in bad_prefixes:
|
||||||
|
for i, flag in enumerate(optlist):
|
||||||
|
if flag.startswith(bad_prefix):
|
||||||
|
optlist.pop(i)
|
||||||
|
break
|
||||||
|
return optlist
|
||||||
|
|
||||||
|
#Compiler options
|
||||||
|
cvars = sysconfig.get_config_vars()
|
||||||
|
cvars['BASECFLAGS'] = "-D__CL_ENABLE_EXCEPTIONS -fPIC -Wno-sign-compare -Wall -Wextra -pedantic -Wno-ignored-qualifiers -std=c++11 "
|
||||||
|
cvars['OPT'] = str.join(' ', remove_prefixes(cvars['OPT'].split(), ['-g', '-Wstrict-prototypes']))
|
||||||
|
cvars["CFLAGS"] = cvars["BASECFLAGS"] + " " + cvars["OPT"]
|
||||||
|
cvars["LDFLAGS"] = '-Wl,--no-as-needed ' + cvars["LDFLAGS"]
|
||||||
|
|
||||||
|
#Includes
|
||||||
|
include =''.split() + ['external/boost/include', os.path.join(find_module("numpy")[1], "core", "include")]
|
||||||
|
#Sources
|
||||||
|
src = 'src/lib/exception/unknown_datatype.cpp src/lib/exception/operation_not_supported.cpp src/lib/array.cpp src/lib/backend/parse.cpp src/lib/backend/templates/mreduction.cpp src/lib/backend/templates/maxpy.cpp src/lib/backend/templates/mproduct.cpp src/lib/backend/templates/reduction.cpp src/lib/backend/templates/vaxpy.cpp src/lib/backend/templates/base.cpp src/lib/backend/keywords.cpp src/lib/backend/stream.cpp src/lib/backend/binder.cpp src/lib/backend/mapped_object.cpp src/lib/model/model.cpp src/lib/model/predictors/random_forest.cpp src/lib/value_scalar.cpp src/lib/driver/check.cpp src/lib/driver/program.cpp src/lib/driver/platform.cpp src/lib/driver/kernel.cpp src/lib/driver/ndrange.cpp src/lib/driver/event.cpp src/lib/driver/command_queue.cpp src/lib/driver/backend.cpp src/lib/driver/context.cpp src/lib/driver/handle.cpp src/lib/driver/buffer.cpp src/lib/driver/device.cpp src/lib/symbolic/execute.cpp src/lib/symbolic/io.cpp src/lib/symbolic/detect.cpp src/lib/symbolic/expression.cpp '.split() + [os.path.join('src', 'wrap', sf) for sf in ['_isaac.cpp', 'core.cpp', 'driver.cpp', 'model.cpp', 'exceptions.cpp']]
|
||||||
|
boostsrc = 'external/boost/libs/'
|
||||||
|
for s in ['numpy','python','smart_ptr','system','thread']:
|
||||||
|
src = src + [x for x in recursive_glob('external/boost/libs/' + s + '/src/','.cpp') if 'win32' not in x and 'pthread' not in x]
|
||||||
|
# make sure next line succeeds even on Windows
|
||||||
|
src = [f.replace("\\", "/") for f in src]
|
||||||
|
if sys.platform == "win32":
|
||||||
|
src += glob(boostsrc + "/thread/src/win32/*.cpp")
|
||||||
|
src += glob(boostsrc + "/thread/src/tss_null.cpp")
|
||||||
|
else:
|
||||||
|
src += glob(boostsrc + "/thread/src/pthread/*.cpp")
|
||||||
|
src= [f for f in src if not f.endswith("once_atomic.cpp")]
|
||||||
|
|
||||||
|
|
||||||
|
setup(
|
||||||
|
name='isaac',
|
||||||
|
version='1.0',
|
||||||
|
description="Input-specific architecture-aware computations",
|
||||||
|
author='Philippe Tillet',
|
||||||
|
author_email='ptillet@g.harvard.edu',
|
||||||
|
license='MPL 2.0',
|
||||||
|
packages=["isaac"],
|
||||||
|
ext_package="isaac",
|
||||||
|
ext_modules=[Extension(
|
||||||
|
'_isaac',src,
|
||||||
|
extra_compile_args= ['-Wno-unused-function', '-Wno-unused-local-typedefs'],
|
||||||
|
extra_link_args=['-Wl,-soname=_isaac.so'],
|
||||||
|
undef_macros=[],
|
||||||
|
include_dirs=include,
|
||||||
|
libraries=['OpenCL', 'isaac']
|
||||||
|
)],
|
||||||
|
cmdclass={'build_py': build_py, 'build_ext': build_ext_subclass},
|
||||||
|
classifiers=[
|
||||||
|
'Environment :: Console',
|
||||||
|
'Development Status :: 1 - Experimental',
|
||||||
|
'Intended Audience :: Developers',
|
||||||
|
'Intended Audience :: Other Audience',
|
||||||
|
'Intended Audience :: Science/Research',
|
||||||
|
'License :: OSI Approved :: MIT License',
|
||||||
|
'Natural Language :: English',
|
||||||
|
'Programming Language :: C++',
|
||||||
|
'Programming Language :: Python',
|
||||||
|
'Programming Language :: Python :: 3',
|
||||||
|
'Topic :: Scientific/Engineering',
|
||||||
|
'Topic :: Scientific/Engineering :: Mathematics',
|
||||||
|
'Topic :: Scientific/Engineering :: Physics',
|
||||||
|
'Topic :: Scientific/Engineering :: Machine Learning',
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
@@ -1,4 +1,4 @@
|
|||||||
include("${CMAKE_MODULE_PATH}/android.apk.cmake" REQUIRED)
|
include("${CMAKE_MODULE_PATH}/android/apk.cmake" REQUIRED)
|
||||||
|
|
||||||
# Sources
|
# Sources
|
||||||
include_directories(${CMAKE_SOURCE_DIR}/include)
|
include_directories(${CMAKE_SOURCE_DIR}/include)
|
||||||
|
Reference in New Issue
Block a user