Build PythonAPI
Add BuildPythonAPI.bat Build all the libraries in static, the way we are totaly independent of the operating system
This commit is contained in:
parent
f0971ab2d6
commit
4d928ee5c0
|
@ -32,6 +32,20 @@ def get_libcarla_extensions():
|
|||
include_dirs += ['/usr/lib/gcc/x86_64-linux-gnu/7/include']
|
||||
library_dirs += ['/usr/lib/gcc/x86_64-linux-gnu/7']
|
||||
extra_link_args += ['/usr/lib/gcc/x86_64-linux-gnu/7/libstdc++.a']
|
||||
else:
|
||||
libraries += ["boost_python"]
|
||||
elif os.name == "nt":
|
||||
pwd = os.path.dirname(os.path.realpath(__file__))
|
||||
pylib = "libboost_python%d%d-vc141-mt-s-x64-1_68.lib" % (sys.version_info.major, sys.version_info.minor)
|
||||
|
||||
extra_link_args = [
|
||||
'shlwapi.lib',
|
||||
os.path.join(pwd, 'dependencies/lib/rpc.lib'),
|
||||
os.path.join(pwd, 'dependencies/lib', pylib)]
|
||||
|
||||
# https://docs.microsoft.com/es-es/cpp/porting/modifying-winver-and-win32-winnt
|
||||
extra_compile_args = ['/DPYTHON3X', '/MT', '/DBOOST_PYTHON_STATIC_LIB','/DBOOST_ERROR_CODE_HEADER_ONLY', '/D_WIN32_WINNT=0x0501' ]
|
||||
extra_link_args += []
|
||||
else:
|
||||
raise NotImplementedError
|
||||
|
||||
|
@ -44,6 +58,7 @@ def get_libcarla_extensions():
|
|||
depends += [x for x in walk('dependencies')]
|
||||
|
||||
def make_extension(name, sources):
|
||||
|
||||
return Extension(
|
||||
name,
|
||||
sources=sources,
|
||||
|
|
|
@ -68,7 +68,14 @@ void export_actor() {
|
|||
})
|
||||
.add_property("fov", &cc::Image::GetFOV)
|
||||
.add_property("raw_data", +[](cc::Image &self) {
|
||||
|
||||
#if PYTHON3X
|
||||
//NOTE(Andrei): python37
|
||||
auto *ptr = PyMemoryView_FromMemory(reinterpret_cast<char *>(self.GetData()), self.GetSize(), PyBUF_READ);
|
||||
#else
|
||||
//NOTE(Andrei): python2.7
|
||||
auto *ptr = PyBuffer_FromMemory(self.GetData(), self.GetSize());
|
||||
#endif
|
||||
return object(handle<>(ptr));
|
||||
})
|
||||
;
|
||||
|
@ -114,8 +121,8 @@ void export_actor() {
|
|||
|
||||
GILLockGuard gil_lock;
|
||||
try {
|
||||
call<void>(callback.ptr(), object(image));
|
||||
} catch (const error_already_set &e) {
|
||||
boost::python::call<void>(callback.ptr(), boost::python::object(image));
|
||||
} catch (const boost::python::error_already_set &e) {
|
||||
PyErr_Print();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -10,7 +10,6 @@ rem -- Parse arguments ---------------------------------------------------------
|
|||
rem ============================================================================
|
||||
|
||||
set DOC_STRING=Build LibCarla.
|
||||
|
||||
set "USAGE_STRING=Usage: %FILE_N% [-h^|--help] [--rebuild] [--server] [--client] [--clean]"
|
||||
|
||||
set REMOVE_INTERMEDIATE=false
|
||||
|
@ -67,7 +66,7 @@ rem
|
|||
set LIBCARLA_VSPROJECT_PATH=%INSTALLATION_DIR%libcarla-visualstudio
|
||||
|
||||
set LIBCARLA_SERVER_INSTALL_PATH=%ROOT_PATH%Unreal\CarlaUE4\Plugins\Carla\CarlaDependencies
|
||||
set LIBCARLA_CLIENT_INSTALL_PATH=%INSTALLATION_DIR%libcarla-client-install
|
||||
set LIBCARLA_CLIENT_INSTALL_PATH=%ROOT_PATH%PythonAPI\dependencies
|
||||
|
||||
if %REMOVE_INTERMEDIATE% == true (
|
||||
echo %FILE_N% cleaning build folder
|
||||
|
@ -76,31 +75,18 @@ if %REMOVE_INTERMEDIATE% == true (
|
|||
)
|
||||
|
||||
if not exist "%LIBCARLA_VSPROJECT_PATH%" mkdir "%LIBCARLA_VSPROJECT_PATH%"
|
||||
pushd "%LIBCARLA_VSPROJECT_PATH%"
|
||||
cd "%LIBCARLA_VSPROJECT_PATH%"
|
||||
|
||||
rem Build libcarla server
|
||||
rem
|
||||
if %BUILD_SERVER% == true (
|
||||
if exist "%LIBCARLA_SERVER_INSTALL_PATH%" (
|
||||
goto :eof
|
||||
)
|
||||
|
||||
cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_BUILD_TYPE=Server -DCMAKE_CXX_FLAGS_RELEASE=/MD^ -DCMAKE_INSTALL_PREFIX="%LIBCARLA_SERVER_INSTALL_PATH%" "%ROOT_PATH%"
|
||||
if %BUILD_SERVER% == true if not exist "%LIBCARLA_SERVER_INSTALL_PATH%" (
|
||||
cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_BUILD_TYPE=Server -DCMAKE_CXX_FLAGS_RELEASE=/MT -DCMAKE_INSTALL_PREFIX=%LIBCARLA_SERVER_INSTALL_PATH% %ROOT_PATH%
|
||||
cmake --build . --config Release --target install
|
||||
)
|
||||
|
||||
rem Build libcarla client
|
||||
rem
|
||||
if %BUILD_CLIENT% == true (
|
||||
if exist "%LIBCARLA_CLIENT_INSTALL_PATH%" (
|
||||
goto :eof
|
||||
)
|
||||
|
||||
cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_BUILD_TYPE=Client -DCMAKE_CXX_FLAGS_RELEASE=/MD^ -DCMAKE_INSTALL_PREFIX="%LIBCARLA_CLIENT_INSTALL_PATH%" "%ROOT_PATH%"
|
||||
if %BUILD_CLIENT% == true if not exist "%LIBCARLA_CLIENT_INSTALL_PATH%" (
|
||||
cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_BUILD_TYPE=Client -DCMAKE_CXX_FLAGS_RELEASE=/MT -DCMAKE_INSTALL_PREFIX=%LIBCARLA_CLIENT_INSTALL_PATH% %ROOT_PATH%
|
||||
cmake --build . --config Release --target install
|
||||
)
|
||||
|
||||
goto :eof
|
||||
|
||||
rem TO DELTE
|
||||
echo DEBUG: LAST LINE
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
@echo off
|
||||
|
||||
setlocal
|
||||
|
||||
set LOCAL_PATH=%~dp0
|
||||
set "FILE_N= -[%~n0]:"
|
||||
|
||||
set DOC_STRING=Build and package CARLA Python API.
|
||||
set "USAGE_STRING=Usage: %FILE_N% [-h^|--help] [--rebuild] [--clean]"
|
||||
|
||||
set REMOVE_INTERMEDIATE=false
|
||||
set BUILD_FOR_PYTHON2=false
|
||||
set BUILD_FOR_PYTHON3=false
|
||||
|
||||
:arg-parse
|
||||
if not "%1"=="" (
|
||||
if "%1"=="--rebuild" (
|
||||
set REMOVE_INTERMEDIATE=true
|
||||
set BUILD_FOR_PYTHON2=true
|
||||
set BUILD_FOR_PYTHON3=true
|
||||
)
|
||||
|
||||
if "%1"=="--py2" (
|
||||
set BUILD_FOR_PYTHON2=true
|
||||
)
|
||||
|
||||
if "%1"=="--py3" (
|
||||
set BUILD_FOR_PYTHON3=true
|
||||
)
|
||||
|
||||
|
||||
if "%1"=="--clean" (
|
||||
set REMOVE_INTERMEDIATE=true
|
||||
)
|
||||
|
||||
if "%1"=="-h" (
|
||||
echo %DOC_STRING%
|
||||
echo %USAGE_STRING%
|
||||
GOTO :eof
|
||||
)
|
||||
|
||||
if "%1"=="--help" (
|
||||
echo %DOC_STRING%
|
||||
echo %USAGE_STRING%
|
||||
GOTO :eof
|
||||
)
|
||||
|
||||
shift
|
||||
goto :arg-parse
|
||||
)
|
||||
|
||||
set PYTHON_LIB_PATH=%ROOT_PATH%PythonAPI\
|
||||
set PYTHON_LIB_BUILD=%PYTHON_LIB_PATH%build
|
||||
set PYTHON_LIB_DEPENDENCIES=%PYTHON_LIB_PATH%dependencies
|
||||
|
||||
if %REMOVE_INTERMEDIATE% == false (
|
||||
if %BUILD_FOR_PYTHON3% == false (
|
||||
if %BUILD_FOR_PYTHON2% == false (
|
||||
echo Nothing selected to be done.
|
||||
goto :eof
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
cd "%PYTHON_LIB_PATH%"
|
||||
|
||||
if %REMOVE_INTERMEDIATE% == true (
|
||||
echo %FILE_N% cleaning build folder
|
||||
if exist "%PYTHON_LIB_BUILD%" rmdir /S /Q "%PYTHON_LIB_BUILD%"
|
||||
if exist "%PYTHON_LIB_DEPENDENCIES%" rmdir /S /Q "%PYTHON_LIB_DEPENDENCIES%"
|
||||
)
|
||||
|
||||
if %BUILD_FOR_PYTHON2%==true (
|
||||
echo Building Python API for Python 2.
|
||||
call py -2 setup.py bdist_egg
|
||||
)
|
||||
|
||||
if %BUILD_FOR_PYTHON3%==true (
|
||||
echo Building Python API for Python 3.
|
||||
call py -3 setup.py bdist_egg
|
||||
)
|
||||
|
|
@ -42,7 +42,7 @@ CarlaUE4Editor: LibCarla
|
|||
|
||||
.PHONY: PythonAPI
|
||||
PythonAPI: LibCarla
|
||||
@echo "Not implemented!"
|
||||
@${CARLA_BUILD_TOOLS_FOLDER}/BuildPythonAPI.bat --py3
|
||||
|
||||
.PHONY: LibCarla
|
||||
LibCarla: setup
|
||||
|
|
|
@ -6,6 +6,9 @@ rem Just put it in `Util/Build` and run it.
|
|||
|
||||
setlocal
|
||||
|
||||
set LOCAL_PATH=%~dp0
|
||||
set "FILE_N= -[%~n0]:"
|
||||
|
||||
:arg-parse
|
||||
if not "%1"=="" (
|
||||
if "%1"=="-j" (
|
||||
|
@ -28,9 +31,6 @@ if [%BUILD_DIR%] == [] set BUILD_DIR=.
|
|||
if [%B_TOOLSET%] == [] set B_TOOLSET=msvc-14.1
|
||||
if [%NUMBER_OF_ASYNC_JOBS%] == [] set NUMBER_OF_ASYNC_JOBS=1
|
||||
|
||||
set LOCAL_PATH=%~dp0
|
||||
set FILE_N=---%~n0%~x0:
|
||||
|
||||
set B_VERSION=boost-1.67.0
|
||||
set B_SRC=boost-src
|
||||
set B_SRC_DIR=%BUILD_DIR%%B_SRC%
|
||||
|
@ -46,9 +46,11 @@ if not exist "%B_SRC_DIR%" (
|
|||
echo %FILE_N% Cloning Boost - version "%B_VERSION%"...
|
||||
echo.
|
||||
|
||||
call git clone --depth=1 -b %B_VERSION% --recurse-submodules -j8 https://github.com/boostorg/boost.git %B_SRC_DIR%
|
||||
rem call git clone --depth=1 -b %B_VERSION% --recurse-submodules -j8 https://github.com/boostorg/boost.git %B_SRC_DIR%
|
||||
rem clone master as there is bug in 1.67 related to python boost (https://github.com/boostorg/python/issues/193)
|
||||
|
||||
call git clone --depth=1 --recurse-submodules -j8 https://github.com/boostorg/boost.git %B_SRC_DIR%
|
||||
if errorlevel 1 goto error_git
|
||||
echo.
|
||||
) else (
|
||||
echo %FILE_N% Not cloning boost because already exists a folder called "%B_SRC%".
|
||||
)
|
||||
|
@ -62,7 +64,7 @@ if not exist "b2.exe" (
|
|||
if errorlevel 1 goto error_bootstrap
|
||||
|
||||
echo %FILE_N% Packing headers...
|
||||
b2 headers
|
||||
b2 headers link=static
|
||||
|
||||
echo %FILE_N% Building...
|
||||
b2 -j8^
|
||||
|
@ -74,6 +76,7 @@ b2 -j8^
|
|||
toolset=%B_TOOLSET%^
|
||||
variant=release^
|
||||
link=static^
|
||||
runtime-link=static^
|
||||
threading=multi^
|
||||
--prefix="%B_INSTALL_DIR%"^
|
||||
--libdir="%B_LIB_DIR%"^
|
||||
|
|
|
@ -59,7 +59,7 @@ cd "%GT_BUILD_DIR%"
|
|||
echo %FILE_N% Generating build...
|
||||
cmake .. -G "Visual Studio 15 2017 Win64"^
|
||||
-DCMAKE_BUILD_TYPE=Release^
|
||||
-DCMAKE_CXX_FLAGS_RELEASE=/MD^
|
||||
-DCMAKE_CXX_FLAGS_RELEASE=/MT^
|
||||
-DCMAKE_INSTALL_PREFIX=%GT_INSTALL_DIR%^
|
||||
-DCMAKE_CXX_FLAGS=/D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING^
|
||||
%GT_SRC_DIR%
|
||||
|
|
|
@ -60,7 +60,7 @@ echo %FILE_N% Generating build...
|
|||
cmake .. -G "Visual Studio 15 2017 Win64"^
|
||||
-DCMAKE_BUILD_TYPE=Release^
|
||||
-RPCLIB_BUILD_EXAMPLES=OFF^
|
||||
-DCMAKE_CXX_FLAGS_RELEASE=/MD^
|
||||
-DCMAKE_CXX_FLAGS_RELEASE=/MT^
|
||||
-DCMAKE_INSTALL_PREFIX=%RPC_INSTALL_DIR%^
|
||||
%RPC_SRC_DIR%
|
||||
if errorlevel 1 goto error_cmake
|
||||
|
|
Loading…
Reference in New Issue