Added zlib and libpng to Win setup, PythonAPI now compiles on Win
This commit is contained in:
parent
35dc936c91
commit
1e5d87878e
|
@ -68,11 +68,11 @@ install(FILES ${libcarla_carla_opendrive_parser_pugixml} DESTINATION include/car
|
|||
install(DIRECTORY "${BOOST_INCLUDE_PATH}/boost" DESTINATION include)
|
||||
|
||||
if(WIN32)
|
||||
file(GLOB boostlib_date_time "${BOOST_LIB_PATH}/libboost_date_time-*-mt-*.lib")
|
||||
install(FILES ${boostlib_date_time} DESTINATION lib)
|
||||
|
||||
file(GLOB boostlib_system "${BOOST_LIB_PATH}/libboost_system-*-mt-*.lib")
|
||||
install(FILES ${boostlib_system} DESTINATION lib)
|
||||
file(GLOB boostlibs
|
||||
"${BOOST_LIB_PATH}/libboost_date_time-*-mt-*.lib"
|
||||
"${BOOST_LIB_PATH}/libboost_system-*-mt-*.lib"
|
||||
"${BOOST_LIB_PATH}/libboost_filesystem-*-mt-*.lib")
|
||||
install(FILES ${boostlibs} DESTINATION lib)
|
||||
endif()
|
||||
|
||||
# carla_server library.
|
||||
|
|
|
@ -31,12 +31,12 @@ static auto MakeTestImage(size_t width, size_t height) {
|
|||
return TestImage<decltype(view), PixelT>{std::move(data), view};
|
||||
}
|
||||
|
||||
TEST(image, support) {
|
||||
using namespace carla::image::io;
|
||||
carla::logging::log("PNG support =", has_png_support());
|
||||
carla::logging::log("JPEG support =", has_jpeg_support());
|
||||
carla::logging::log("TIFF support =", has_tiff_support());
|
||||
}
|
||||
// TEST(image, support) {
|
||||
// using namespace carla::image::io;
|
||||
// carla::logging::log("PNG support =", has_png_support());
|
||||
// carla::logging::log("JPEG support =", has_jpeg_support());
|
||||
// carla::logging::log("TIFF support =", has_tiff_support());
|
||||
// }
|
||||
|
||||
TEST(image, depth) {
|
||||
#ifndef NDEBUG
|
||||
|
|
|
@ -53,26 +53,36 @@ def get_libcarla_extensions():
|
|||
else:
|
||||
raise NotImplementedError
|
||||
elif os.name == "nt":
|
||||
sources += [x for x in walk('dependencies/include/carla', '*.cpp')]
|
||||
sources += [x for x in walk('dependencies\\include\\carla', '*.cpp')]
|
||||
|
||||
pwd = os.path.dirname(os.path.realpath(__file__))
|
||||
pylib = "libboost_python%d%d-vc141-mt-x64-1_69.lib" % (
|
||||
pylib = 'libboost_python%d%d' % (
|
||||
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)]
|
||||
|
||||
extra_link_args = ['shlwapi.lib']
|
||||
|
||||
required_libs = [
|
||||
pylib, 'libboost_filesystem',
|
||||
'rpc.lib', 'carla_client.lib',
|
||||
'libpng.lib', 'zlib.lib']
|
||||
|
||||
# Search for files in 'PythonAPI\dependencies\lib' that contains
|
||||
# the names listed in required_libs in it's file name
|
||||
libs = [x for x in os.listdir('dependencies\\lib') if any(d in x for d in required_libs)]
|
||||
|
||||
for lib in libs:
|
||||
extra_link_args.append(os.path.join(pwd, 'dependencies\\lib', lib))
|
||||
|
||||
# https://docs.microsoft.com/es-es/cpp/porting/modifying-winver-and-win32-winnt
|
||||
extra_compile_args = [
|
||||
'/DBOOST_ALL_NO_LIB', '/DBOOST_PYTHON_STATIC_LIB',
|
||||
'/DBOOST_ERROR_CODE_HEADER_ONLY', '/D_WIN32_WINNT=0x0501',
|
||||
'/DLIBCARLA_WITH_PYTHON_SUPPORT']
|
||||
'/DLIBCARLA_WITH_PYTHON_SUPPORT', '-DLIBCARLA_IMAGE_WITH_PNG_SUPPORT=true']
|
||||
else:
|
||||
raise NotImplementedError
|
||||
|
||||
depends = [x for x in walk('source/libcarla')]
|
||||
depends = [x for x in walk('source\\libcarla')]
|
||||
depends += [x for x in walk('dependencies')]
|
||||
|
||||
def make_extension(name, sources):
|
||||
|
|
|
@ -28,7 +28,9 @@ namespace client {
|
|||
|
||||
static auto GetSemanticTags(const carla::client::Actor &self) {
|
||||
const auto &tags = self.GetSemanticTags();
|
||||
return std::vector<int>(tags.begin(), tags.end());
|
||||
boost::python::object get_iter = boost::python::iterator<std::vector<int>>();
|
||||
boost::python::object iter = get_iter(tags);
|
||||
return boost::python::list(iter);
|
||||
}
|
||||
|
||||
void export_actor() {
|
||||
|
@ -42,19 +44,19 @@ void export_actor() {
|
|||
;
|
||||
|
||||
class_<cc::Actor, boost::noncopyable, boost::shared_ptr<cc::Actor>>("Actor", no_init)
|
||||
// work-around, force return copy to resolve Actor instead of ActorState.
|
||||
// work-around, force return copy to resolve Actor instead of ActorState.
|
||||
.add_property("id", CALL_RETURNING_COPY(cc::Actor, GetId))
|
||||
.add_property("type_id", CALL_RETURNING_COPY(cc::Actor, GetTypeId))
|
||||
.add_property("parent", CALL_RETURNING_COPY(cc::Actor, GetParent))
|
||||
.add_property("semantic_tags", &GetSemanticTags)
|
||||
.add_property("is_alive", CALL_RETURNING_COPY(cc::Actor, IsAlive))
|
||||
.add_property("attributes", +[] (const cc::Actor &self) {
|
||||
boost::python::dict atttribute_dict;
|
||||
for (auto &&attribute_value : self.GetAttributes()) {
|
||||
atttribute_dict[attribute_value.GetId()] = attribute_value.GetValue();
|
||||
}
|
||||
return atttribute_dict;
|
||||
})
|
||||
boost::python::dict atttribute_dict;
|
||||
for (auto &&attribute_value : self.GetAttributes()) {
|
||||
atttribute_dict[attribute_value.GetId()] = attribute_value.GetValue();
|
||||
}
|
||||
return atttribute_dict;
|
||||
})
|
||||
.def("get_world", CALL_RETURNING_COPY(cc::Actor, GetWorld))
|
||||
.def("get_location", &cc::Actor::GetLocation)
|
||||
.def("get_transform", &cc::Actor::GetTransform)
|
||||
|
|
|
@ -97,33 +97,33 @@ void export_blueprint() {
|
|||
.def(self_ns::str(self_ns::self))
|
||||
;
|
||||
|
||||
class_<std::vector<std::string>>("vector_of_strings")
|
||||
.def(vector_indexing_suite<std::vector<std::string>>())
|
||||
.def(self_ns::str(self_ns::self))
|
||||
;
|
||||
// class_<std::vector<std::string>>("vector_of_strings")
|
||||
// .def(vector_indexing_suite<std::vector<std::string>>())
|
||||
// .def(self_ns::str(self_ns::self))
|
||||
// ;
|
||||
|
||||
class_<cc::ActorAttribute>("ActorAttribute", no_init)
|
||||
.add_property("id", CALL_RETURNING_COPY(cc::ActorAttribute, GetId))
|
||||
.add_property("type", &cc::ActorAttribute::GetType)
|
||||
.add_property("recommended_values", CALL_RETURNING_COPY(cc::ActorAttribute, GetRecommendedValues))
|
||||
.add_property("recommended_values", CALL_RETURNING_LIST(cc::ActorAttribute, GetRecommendedValues))
|
||||
.add_property("is_modifiable", &cc::ActorAttribute::IsModifiable)
|
||||
.def("as_bool", &cc::ActorAttribute::As<bool>)
|
||||
.def("as_int", &cc::ActorAttribute::As<int>)
|
||||
.def("as_float", &cc::ActorAttribute::As<float>)
|
||||
.def("as_str", &cc::ActorAttribute::As<std::string>)
|
||||
.def("as_color", &cc::ActorAttribute::As<csd::Color>)
|
||||
.def("__eq__", &cc::ActorAttribute::operator==<bool>)
|
||||
.def("__eq__", &cc::ActorAttribute::operator==<int>)
|
||||
.def("__eq__", &cc::ActorAttribute::operator==<float>)
|
||||
.def("__eq__", &cc::ActorAttribute::operator==<std::string>)
|
||||
.def("__eq__", &cc::ActorAttribute::operator==<csd::Color>)
|
||||
.def("__eq__", &cc::ActorAttribute::operator==<cc::ActorAttribute>)
|
||||
.def("__ne__", &cc::ActorAttribute::operator!=<bool>)
|
||||
.def("__ne__", &cc::ActorAttribute::operator!=<int>)
|
||||
.def("__ne__", &cc::ActorAttribute::operator!=<float>)
|
||||
.def("__ne__", &cc::ActorAttribute::operator!=<std::string>)
|
||||
.def("__ne__", &cc::ActorAttribute::operator!=<csd::Color>)
|
||||
.def("__ne__", &cc::ActorAttribute::operator!=<cc::ActorAttribute>)
|
||||
// .def("__eq__", &cc::ActorAttribute::operator==<bool>)
|
||||
// .def("__eq__", &cc::ActorAttribute::operator==<int>)
|
||||
// .def("__eq__", &cc::ActorAttribute::operator==<float>)
|
||||
// .def("__eq__", &cc::ActorAttribute::operator==<std::string>)
|
||||
// .def("__eq__", &cc::ActorAttribute::operator==<csd::Color>)
|
||||
// .def("__eq__", &cc::ActorAttribute::operator==<cc::ActorAttribute>)
|
||||
// .def("__ne__", &cc::ActorAttribute::operator!=<bool>)
|
||||
// .def("__ne__", &cc::ActorAttribute::operator!=<int>)
|
||||
// .def("__ne__", &cc::ActorAttribute::operator!=<float>)
|
||||
// .def("__ne__", &cc::ActorAttribute::operator!=<std::string>)
|
||||
// .def("__ne__", &cc::ActorAttribute::operator!=<csd::Color>)
|
||||
// .def("__ne__", &cc::ActorAttribute::operator!=<cc::ActorAttribute>)
|
||||
.def("__nonzero__", &cc::ActorAttribute::As<bool>)
|
||||
.def("__bool__", &cc::ActorAttribute::As<bool>)
|
||||
.def("__int__", &cc::ActorAttribute::As<int>)
|
||||
|
@ -134,7 +134,7 @@ void export_blueprint() {
|
|||
|
||||
class_<cc::ActorBlueprint>("ActorBlueprint", no_init)
|
||||
.add_property("id", CALL_RETURNING_COPY(cc::ActorBlueprint, GetId))
|
||||
.add_property("tags", &cc::ActorBlueprint::GetTags)
|
||||
.add_property("tags", CALL_RETURNING_LIST(cc::ActorBlueprint, GetTags)) // ------------
|
||||
.def("has_tag", &cc::ActorBlueprint::ContainsTag)
|
||||
.def("match_tags", &cc::ActorBlueprint::MatchTags)
|
||||
.def("has_attribute", &cc::ActorBlueprint::ContainsAttribute)
|
||||
|
|
|
@ -221,13 +221,14 @@ void export_sensor_data() {
|
|||
.value("Solid", cre::LaneMarking::Solid)
|
||||
;
|
||||
|
||||
class_<std::vector<cre::LaneMarking>>("vector_of_lane_markings")
|
||||
.def(vector_indexing_suite<std::vector<cre::LaneMarking>>())
|
||||
;
|
||||
// class_<std::vector<cre::LaneMarking>>("vector_of_lane_markings")
|
||||
// .def(vector_indexing_suite<std::vector<cre::LaneMarking>>())
|
||||
// ;
|
||||
|
||||
class_<csd::LaneInvasionEvent, bases<cs::SensorData>, boost::noncopyable, boost::shared_ptr<csd::LaneInvasionEvent>>("LaneInvasionEvent", no_init)
|
||||
.add_property("actor", &csd::LaneInvasionEvent::GetActor)
|
||||
.add_property("crossed_lane_markings", CALL_RETURNING_COPY(csd::LaneInvasionEvent, GetCrossedLaneMarkings))
|
||||
// .add_property("crossed_lane_markings", CALL_RETURNING_COPY(csd::LaneInvasionEvent, GetCrossedLaneMarkings))
|
||||
.add_property("crossed_lane_markings", CALL_RETURNING_LIST(csd::LaneInvasionEvent, GetCrossedLaneMarkings))
|
||||
.def(self_ns::str(self_ns::self))
|
||||
;
|
||||
|
||||
|
|
|
@ -113,7 +113,8 @@ static auto MakeCallback(boost::python::object callback) {
|
|||
carla::PythonUtil::AcquireGIL lock;
|
||||
try {
|
||||
py::call<void>(callback->ptr(), py::object(message));
|
||||
} catch (const py::error_already_set &e) {
|
||||
// } catch (const py::error_already_set &e) {
|
||||
} catch (const py::error_already_set &) {
|
||||
PyErr_Print();
|
||||
}
|
||||
};
|
||||
|
|
|
@ -51,24 +51,31 @@ pushd "%UE4_PROJECT_FOLDER%"
|
|||
rem Clear binaries and intermediates generated by the build system
|
||||
rem
|
||||
if %REMOVE_INTERMEDIATE% == true (
|
||||
rem Remove directories
|
||||
for %%G in (
|
||||
"%UE4_PROJECT_FOLDER%Binaries",
|
||||
"%UE4_PROJECT_FOLDER%Build",
|
||||
"%UE4_PROJECT_FOLDER%Saved",
|
||||
"%UE4_PROJECT_FOLDER%Intermediate",
|
||||
"%UE4_PROJECT_FOLDER%Plugins\Carla\Binaries",
|
||||
"%UE4_PROJECT_FOLDER%Plugins\Carla\Intermediate",
|
||||
"%UE4_PROJECT_FOLDER%.vs",
|
||||
"%UE4_PROJECT_FOLDER%CarlaUE4.sln"
|
||||
"%UE4_PROJECT_FOLDER:/=\%Binaries",
|
||||
"%UE4_PROJECT_FOLDER:/=\%Build",
|
||||
"%UE4_PROJECT_FOLDER:/=\%Saved",
|
||||
"%UE4_PROJECT_FOLDER:/=\%Intermediate",
|
||||
"%UE4_PROJECT_FOLDER:/=\%Plugins\Carla\Binaries",
|
||||
"%UE4_PROJECT_FOLDER:/=\%Plugins\Carla\Intermediate",
|
||||
"%UE4_PROJECT_FOLDER:/=\%.vs"
|
||||
) do (
|
||||
if exist %%G (
|
||||
echo %FILE_N% Deleting: %%G
|
||||
echo %FILE_N% Cleaning %%G
|
||||
rmdir /s/q %%G
|
||||
)
|
||||
)
|
||||
rem If this folders are not available can not generate the VS solution
|
||||
mkdir "%UE4_PROJECT_FOLDER%Saved"
|
||||
mkdir "%UE4_PROJECT_FOLDER%Saved\Logs"
|
||||
|
||||
rem Remove files
|
||||
for %%G in (
|
||||
"%UE4_PROJECT_FOLDER:/=\%CarlaUE4.sln"
|
||||
) do (
|
||||
if exist %%G (
|
||||
echo %FILE_N% Cleaning %%G
|
||||
del %%G
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
rem Launch Carla Editor
|
||||
|
|
|
@ -72,14 +72,17 @@ if %REMOVE_INTERMEDIATE% == false (
|
|||
)
|
||||
|
||||
if %REMOVE_INTERMEDIATE% == true (
|
||||
echo %FILE_N% Cleaning "%PYTHON_LIB_BUILD%"
|
||||
if exist "%PYTHON_LIB_BUILD%" rmdir /S /Q "%PYTHON_LIB_BUILD%"
|
||||
|
||||
echo %FILE_N% Cleaning "%PYTHON_LIB_DEPENDENCIES%"
|
||||
if exist "%PYTHON_LIB_DEPENDENCIES%" rmdir /S /Q "%PYTHON_LIB_DEPENDENCIES%"
|
||||
|
||||
echo %FILE_N% Cleaning "%PYTHON_LIB_PATH%dist"
|
||||
if exist "%PYTHON_LIB_PATH%dist" rmdir /S /Q "%PYTHON_LIB_PATH%dist"
|
||||
for %%G in (
|
||||
"%PYTHON_LIB_BUILD:/=\%",
|
||||
"%PYTHON_LIB_DEPENDENCIES:/=\%",
|
||||
"%PYTHON_LIB_PATH:/=\%dist",
|
||||
) do (
|
||||
if exist %%G (
|
||||
echo %FILE_N% Cleaning %%G
|
||||
rmdir /s/q %%G
|
||||
)
|
||||
)
|
||||
goto good_exit
|
||||
)
|
||||
|
||||
cd "%PYTHON_LIB_PATH%"
|
||||
|
@ -102,7 +105,7 @@ rem Build for Python 2
|
|||
rem
|
||||
if %BUILD_FOR_PYTHON3%==true (
|
||||
echo Building Python API for Python 3.
|
||||
call py -3 setup.py bdist_egg
|
||||
py -3 setup.py bdist_egg
|
||||
if %errorlevel% neq 0 goto error_build_egg
|
||||
)
|
||||
|
||||
|
|
|
@ -71,6 +71,37 @@ if not exist "%INSTALLATION_DIR%" (
|
|||
mkdir "%INSTALLATION_DIR%"
|
||||
)
|
||||
|
||||
rem ============================================================================
|
||||
rem -- Download and install zlib -----------------------------------------------
|
||||
rem ============================================================================
|
||||
|
||||
echo %FILE_N% Installing zlib...
|
||||
call "%INSTALLERS_DIR%install_zlib.bat"^
|
||||
--build-dir "%INSTALLATION_DIR%"
|
||||
|
||||
if %errorlevel% neq 0 goto failed
|
||||
|
||||
if not defined install_zlib (
|
||||
echo %FILE_N% Failed while installing zlib.
|
||||
goto failed
|
||||
)
|
||||
|
||||
rem ============================================================================
|
||||
rem -- Download and install libpng -----------------------------------------------
|
||||
rem ============================================================================
|
||||
|
||||
echo %FILE_N% Installing libpng...
|
||||
call "%INSTALLERS_DIR%install_libpng.bat"^
|
||||
--build-dir "%INSTALLATION_DIR%"^
|
||||
--zlib-install-dir "%INSTALLATION_DIR%\zlib-install"
|
||||
|
||||
if %errorlevel% neq 0 goto failed
|
||||
|
||||
if not defined install_libpng (
|
||||
echo %FILE_N% Failed while installing libpng.
|
||||
goto failed
|
||||
)
|
||||
|
||||
rem ============================================================================
|
||||
rem -- Download and install rpclib ---------------------------------------------
|
||||
rem ============================================================================
|
||||
|
|
|
@ -3,7 +3,6 @@ setlocal
|
|||
|
||||
rem BAT script that downloads and installs a ready to use
|
||||
rem boost build for CARLA (carla.org).
|
||||
rem Just put it in `Util/Build` and run it.
|
||||
|
||||
set LOCAL_PATH=%~dp0
|
||||
set "FILE_N= -[%~n0]:"
|
||||
|
@ -48,7 +47,7 @@ if [%BOOST_VERSION%] == [] (
|
|||
)
|
||||
|
||||
rem If not set set the build dir to the current dir
|
||||
if [%BUILD_DIR%] == [] set BUILD_DIR=.
|
||||
if [%BUILD_DIR%] == [] set BUILD_DIR=%~dp0
|
||||
|
||||
rem If not defined, use Visual Studio 2017 as tool set
|
||||
if [%TOOLSET%] == [] set TOOLSET=msvc-14.1
|
||||
|
@ -111,6 +110,7 @@ b2 -j%NUMBER_OF_ASYNC_JOBS%^
|
|||
headers^
|
||||
--layout=versioned^
|
||||
--build-dir=.\build^
|
||||
--with-system^
|
||||
--with-filesystem^
|
||||
--with-python^
|
||||
--with-date_time^
|
||||
|
|
|
@ -0,0 +1,200 @@
|
|||
@echo off
|
||||
setlocal
|
||||
|
||||
rem BAT script that downloads and installs a ready to use
|
||||
rem x64 libpng build for CARLA (carla.org).
|
||||
rem Run it through a cmd with the x64 Visual C++ Toolset enabled.
|
||||
|
||||
set LOCAL_PATH=%~dp0
|
||||
set "FILE_N= -[%~n0]:"
|
||||
|
||||
rem Print batch params (debug purpose)
|
||||
echo %FILE_N% [Batch params]: %*
|
||||
|
||||
rem ============================================================================
|
||||
rem -- Parse arguments ---------------------------------------------------------
|
||||
rem ============================================================================
|
||||
|
||||
:arg-parse
|
||||
if not "%1"=="" (
|
||||
if "%1"=="--build-dir" (
|
||||
set BUILD_DIR=%~2
|
||||
)
|
||||
if "%1"=="--zlib-install-dir" (
|
||||
set ZLIB_INST_DIR=%~2
|
||||
)
|
||||
if "%1"=="-h" (
|
||||
goto help
|
||||
)
|
||||
if "%1"=="--help" (
|
||||
goto help
|
||||
)
|
||||
shift
|
||||
goto :arg-parse
|
||||
)
|
||||
|
||||
if [%ZLIB_INST_DIR%] == [] (
|
||||
echo %FILE_N% You must specify a zlib install directory using [--zlib-install-dir]
|
||||
goto bad_exit
|
||||
)
|
||||
set ZLIB_INST_DIR=%ZLIB_INST_DIR:/=\%
|
||||
|
||||
rem If not set set the build dir to the current dir
|
||||
if [%BUILD_DIR%] == [] set BUILD_DIR=%~dp0
|
||||
set BUILD_DIR=%BUILD_DIR:/=\%
|
||||
|
||||
rem ============================================================================
|
||||
rem -- Local Variables ---------------------------------------------------------
|
||||
rem ============================================================================
|
||||
|
||||
set LIBPNG_BASENAME=libpng
|
||||
set LIBPNG_VERSION=1.2.37
|
||||
|
||||
rem libpng-x.x.x
|
||||
set LIBPNG_TEMP_FOLDER=%LIBPNG_BASENAME%-%LIBPNG_VERSION%
|
||||
rem libpng-x.x.x-src.zip
|
||||
set LIBPNG_TEMP_FILE=%LIBPNG_TEMP_FOLDER%-src.zip
|
||||
rem ../libpng-x.x.x-src.zip
|
||||
set LIBPNG_TEMP_FILE_DIR=%BUILD_DIR%%LIBPNG_TEMP_FILE%
|
||||
|
||||
set LIBPNG_REPO=http://downloads.sourceforge.net/gnuwin32/libpng-%LIBPNG_VERSION%-src.zip
|
||||
|
||||
rem ../libpng-x.x.x-source/
|
||||
set LIBPNG_SRC_DIR=%BUILD_DIR%%LIBPNG_BASENAME%-%LIBPNG_VERSION%-source
|
||||
rem ../libpng-x.x.x-install/
|
||||
set LIBPNG_INSTALL_DIR=%BUILD_DIR%%LIBPNG_BASENAME%-%LIBPNG_VERSION%-install
|
||||
|
||||
rem ============================================================================
|
||||
rem -- Get libpng --------------------------------------------------------------
|
||||
rem ============================================================================
|
||||
|
||||
if exist "%LIBPNG_INSTALL_DIR%" (
|
||||
goto already_build
|
||||
)
|
||||
|
||||
if not exist "%LIBPNG_SRC_DIR%" (
|
||||
if not exist "%LIBPNG_TEMP_FILE_DIR%" (
|
||||
echo %FILE_N% Retrieving %LIBPNG_BASENAME%.
|
||||
powershell -Command "Start-BitsTransfer -Source '%LIBPNG_REPO%' -Destination '%LIBPNG_TEMP_FILE_DIR%'"
|
||||
if %errorlevel% neq 0 goto error_download
|
||||
)
|
||||
rem Extract the downloaded library
|
||||
echo %FILE_N% Extracting libpng from "%LIBPNG_TEMP_FILE%".
|
||||
powershell -Command "Expand-Archive '%LIBPNG_TEMP_FILE_DIR%' -DestinationPath '%BUILD_DIR%'"
|
||||
if %errorlevel% neq 0 goto error_extracting
|
||||
|
||||
rem Remove unnecessary files and folders
|
||||
echo %FILE_N% Removing "%LIBPNG_TEMP_FILE%"
|
||||
del "%LIBPNG_TEMP_FILE_DIR:/=\%"
|
||||
echo %FILE_N% Removing dir "%BUILD_DIR:/=\%manifest"
|
||||
rmdir /s/q "%BUILD_DIR:/=\%manifest"
|
||||
|
||||
rename "%BUILD_DIR:/=\%src" "%LIBPNG_BASENAME%-%LIBPNG_VERSION%-source"
|
||||
) else (
|
||||
echo %FILE_N% Not downloading libpng because already exists the folder "%LIBPNG_SRC_DIR%".
|
||||
)
|
||||
|
||||
rem ============================================================================
|
||||
rem -- Compile libpng ----------------------------------------------------------
|
||||
rem ============================================================================
|
||||
|
||||
set LIBPNG_SOURCE_DIR=%LIBPNG_SRC_DIR%\libpng\%LIBPNG_VERSION%\libpng-%LIBPNG_VERSION%-src\
|
||||
|
||||
if not exist "%LIBPNG_SRC_DIR%\build" (
|
||||
echo %FILE_N% Creating "%LIBPNG_SRC_DIR%\build"
|
||||
mkdir "%LIBPNG_SRC_DIR%\build"
|
||||
)
|
||||
|
||||
cd "%LIBPNG_SRC_DIR%\build"
|
||||
|
||||
cl /nologo /c /O2 /MD /Z7 /EHsc /MP /W2 /TP /GR /Gm-^
|
||||
-DWIN32 -DNDEBUG -D_CRT_SECURE_NO_WARNINGS -DPNG_NO_MMX_CODE^
|
||||
/I"%ZLIB_INST_DIR%\include"^
|
||||
"%LIBPNG_SOURCE_DIR:/=\%\*.c"
|
||||
|
||||
if not exist "%LIBPNG_INSTALL_DIR%\lib" (
|
||||
echo %FILE_N% Creating "%LIBPNG_INSTALL_DIR%\lib"
|
||||
mkdir "%LIBPNG_INSTALL_DIR%\lib"
|
||||
)
|
||||
|
||||
if not exist "%LIBPNG_INSTALL_DIR%\include" (
|
||||
echo %FILE_N% Creating "%LIBPNG_INSTALL_DIR%\include"
|
||||
mkdir "%LIBPNG_INSTALL_DIR%\include"
|
||||
)
|
||||
|
||||
lib /nologo /MACHINE:X64 /LTCG /OUT:"%LIBPNG_INSTALL_DIR%\lib\libpng.lib" /LIBPATH:"%ZLIB_INST_DIR%\lib" "*.obj" "zlib.lib"
|
||||
|
||||
copy "%LIBPNG_SOURCE_DIR%\png.h" "%LIBPNG_INSTALL_DIR%\include\png.h"
|
||||
copy "%LIBPNG_SOURCE_DIR%\pngconf.h" "%LIBPNG_INSTALL_DIR%\include\pngconf.h"
|
||||
|
||||
goto success
|
||||
|
||||
rem ============================================================================
|
||||
rem -- Messages and Errors -----------------------------------------------------
|
||||
rem ============================================================================
|
||||
|
||||
:help
|
||||
echo %FILE_N% Download and install a libpng.
|
||||
echo "Usage: %FILE_N% [-h^|--help] [--build-dir] [--zlib-install-dir]"
|
||||
goto eof
|
||||
|
||||
:success
|
||||
echo.
|
||||
echo %FILE_N% libpng has been successfully installed in "%LIBPNG_INSTALL_DIR%"!
|
||||
goto good_exit
|
||||
|
||||
:already_build
|
||||
echo %FILE_N% A libpng installation already exists.
|
||||
echo %FILE_N% Delete "%LIBPNG_INSTALL_DIR%" if you want to force a rebuild.
|
||||
goto good_exit
|
||||
|
||||
:error_download
|
||||
echo.
|
||||
echo %FILE_N% [DOWNLOAD ERROR] An error ocurred while downloading libpng.
|
||||
echo %FILE_N% [DOWNLOAD ERROR] Possible causes:
|
||||
echo %FILE_N% - Make sure that the following url is valid:
|
||||
echo %FILE_N% "%LIBPNG_REPO%"
|
||||
echo %FILE_N% [DOWNLOAD ERROR] Workaround:
|
||||
echo %FILE_N% - Download the libpng's source code and
|
||||
echo %FILE_N% extract the content in
|
||||
echo %FILE_N% "%LIBPNG_SRC_DIR%"
|
||||
echo %FILE_N% And re-run the setup script.
|
||||
goto bad_exit
|
||||
|
||||
:error_extracting
|
||||
echo.
|
||||
echo %FILE_N% [EXTRACTING ERROR] An error ocurred while extracting the zip.
|
||||
echo %FILE_N% [EXTRACTING ERROR] Workaround:
|
||||
echo %FILE_N% - Download the libpng's source code and
|
||||
echo %FILE_N% extract the content manually in
|
||||
echo %FILE_N% "%LIBPNG_SRC_DIR%"
|
||||
echo %FILE_N% And re-run the setup script.
|
||||
goto bad_exit
|
||||
|
||||
:error_compiling
|
||||
echo.
|
||||
echo %FILE_N% [COMPILING ERROR] An error ocurred while compiling with cl.exe.
|
||||
echo %FILE_N% Possible causes:
|
||||
echo %FILE_N% - Make sure you have Visual Studio installed.
|
||||
echo %FILE_N% - Make sure you have the "x64 Visual C++ Toolset" in your path.
|
||||
echo %FILE_N% For example, using the "Visual Studio x64 Native Tools Command Prompt",
|
||||
echo %FILE_N% or the "vcvarsall.bat".
|
||||
goto bad_exit
|
||||
|
||||
:error_generating_lib
|
||||
echo.
|
||||
echo %FILE_N% [NMAKE ERROR] An error ocurred while compiling and installing using nmake.
|
||||
goto bad_exit
|
||||
|
||||
:good_exit
|
||||
echo %FILE_N% Exiting...
|
||||
endlocal
|
||||
rem A return value used for checking for errors
|
||||
set install_libpng=done
|
||||
exit /b 0
|
||||
|
||||
:bad_exit
|
||||
if exist "%LIBPNG_INSTALL_DIR%" rd /s /q "%LIBPNG_INSTALL_DIR%"
|
||||
echo %FILE_N% Exiting with error...
|
||||
endlocal
|
||||
exit /b %errorlevel%
|
|
@ -27,7 +27,7 @@ if not "%1"=="" (
|
|||
goto :arg-parse
|
||||
)
|
||||
|
||||
if [%BUILD_DIR%] == [] set BUILD_DIR=.
|
||||
if [%BUILD_DIR%] == [] set BUILD_DIR=%~dp0
|
||||
if [%NUMBER_OF_ASYNC_JOBS%] == [] set NUMBER_OF_ASYNC_JOBS=1
|
||||
|
||||
set LOCAL_PATH=%~dp0
|
||||
|
|
|
@ -0,0 +1,175 @@
|
|||
@echo off
|
||||
setlocal
|
||||
|
||||
rem BAT script that downloads and installs a ready to use
|
||||
rem x64 zlib build for CARLA (carla.org).
|
||||
rem Run it through a cmd with the x64 Visual C++ Toolset enabled.
|
||||
|
||||
set LOCAL_PATH=%~dp0
|
||||
set "FILE_N= -[%~n0]:"
|
||||
|
||||
rem Print batch params (debug purpose)
|
||||
echo %FILE_N% [Batch params]: %*
|
||||
|
||||
rem ============================================================================
|
||||
rem -- Parse arguments ---------------------------------------------------------
|
||||
rem ============================================================================
|
||||
|
||||
:arg-parse
|
||||
if not "%1"=="" (
|
||||
if "%1"=="--build-dir" (
|
||||
set BUILD_DIR=%~2
|
||||
)
|
||||
if "%1"=="--toolset" (
|
||||
set TOOLSET=%~2
|
||||
)
|
||||
if "%1"=="-h" (
|
||||
goto help
|
||||
)
|
||||
if "%1"=="--help" (
|
||||
goto help
|
||||
)
|
||||
shift
|
||||
goto :arg-parse
|
||||
)
|
||||
|
||||
rem If not set set the build dir to the current dir
|
||||
if [%BUILD_DIR%] == [] set BUILD_DIR=%~dp0
|
||||
|
||||
rem If not defined, use Visual Studio 2017 as tool set
|
||||
if [%TOOLSET%] == [] set TOOLSET=""
|
||||
|
||||
rem ============================================================================
|
||||
rem -- Local Variables ---------------------------------------------------------
|
||||
rem ============================================================================
|
||||
|
||||
set ZLIB_BASENAME=zlib
|
||||
set ZLIB_VERSION=1.2.11
|
||||
|
||||
set ZLIB_TEMP_FOLDER=%ZLIB_BASENAME%-%ZLIB_VERSION%
|
||||
set ZLIB_TEMP_FILE=%ZLIB_TEMP_FOLDER%.zip
|
||||
set ZLIB_TEMP_FILE_DIR=%BUILD_DIR%%ZLIB_TEMP_FILE%
|
||||
|
||||
set ZLIB_REPO=http://www.zlib.net/zlib%ZLIB_VERSION:.=%.zip
|
||||
|
||||
set ZLIB_SRC_DIR=%BUILD_DIR%%ZLIB_BASENAME%-source
|
||||
set ZLIB_INSTALL_DIR=%BUILD_DIR%%ZLIB_BASENAME%-install
|
||||
|
||||
rem ============================================================================
|
||||
rem -- Get zlib ---------------------------------------------------------------
|
||||
rem ============================================================================
|
||||
|
||||
if exist "%ZLIB_INSTALL_DIR%" (
|
||||
goto already_build
|
||||
)
|
||||
|
||||
if not exist "%ZLIB_SRC_DIR%" (
|
||||
if not exist "%ZLIB_TEMP_FILE_DIR%" (
|
||||
echo %FILE_N% Retrieving %ZLIB_BASENAME%.
|
||||
powershell -Command "Start-BitsTransfer -Source '%ZLIB_REPO%' -Destination '%ZLIB_TEMP_FILE_DIR%'"
|
||||
if %errorlevel% neq 0 goto error_download
|
||||
)
|
||||
rem Extract the downloaded library
|
||||
echo %FILE_N% Extracting zlib from "%ZLIB_TEMP_FILE%".
|
||||
powershell -Command "Expand-Archive '%ZLIB_TEMP_FILE_DIR%' -DestinationPath '%BUILD_DIR%'"
|
||||
if %errorlevel% neq 0 goto error_extracting
|
||||
|
||||
rem Remove the no longer needed downloaded file
|
||||
echo %FILE_N% Removing "%ZLIB_TEMP_FILE%"
|
||||
del "%ZLIB_TEMP_FILE_DIR:/=\%"
|
||||
rename "%BUILD_DIR%%ZLIB_TEMP_FOLDER%" "%ZLIB_BASENAME%-source"
|
||||
) else (
|
||||
echo %FILE_N% Not downloading zlib because already exists the folder "%ZLIB_SRC_DIR%".
|
||||
)
|
||||
|
||||
if not exist "%ZLIB_SRC_DIR%\build" (
|
||||
echo %FILE_N% Creating "%ZLIB_SRC_DIR%\build"
|
||||
mkdir "%ZLIB_SRC_DIR%\build"
|
||||
)
|
||||
|
||||
cd "%ZLIB_SRC_DIR%\build"
|
||||
|
||||
rem -DCMAKE_BUILD_TYPE=Release^
|
||||
rem -DCMAKE_CONFIGURATION_TYPES=Release^
|
||||
cmake -G "NMake Makefiles"^
|
||||
-DCMAKE_INSTALL_PREFIX="%ZLIB_INSTALL_DIR%"^
|
||||
-DCMAKE_BUILD_TYPE=Release^
|
||||
"%ZLIB_SRC_DIR%"
|
||||
if %errorlevel% neq 0 goto error_cmake
|
||||
|
||||
rem https://stackoverflow.com/questions/601970/how-do-i-utilise-all-the-cores-for-nmake
|
||||
set CL=/MP
|
||||
|
||||
nmake install
|
||||
if %errorlevel% neq 0 goto error_install
|
||||
|
||||
goto success
|
||||
|
||||
rem ============================================================================
|
||||
rem -- Messages and Errors -----------------------------------------------------
|
||||
rem ============================================================================
|
||||
|
||||
:help
|
||||
echo %FILE_N% Download and install a zlib.
|
||||
echo "Usage: %FILE_N% [-h^|--help] [--toolset] [--build-dir]"
|
||||
goto eof
|
||||
|
||||
:success
|
||||
echo.
|
||||
echo %FILE_N% zlib has been successfully installed in "%ZLIB_INSTALL_DIR%"!
|
||||
goto good_exit
|
||||
|
||||
:already_build
|
||||
echo %FILE_N% A zlib installation already exists.
|
||||
echo %FILE_N% Delete "%ZLIB_INSTALL_DIR%" if you want to force a rebuild.
|
||||
goto good_exit
|
||||
|
||||
:error_download
|
||||
echo.
|
||||
echo %FILE_N% [DOWNLOAD ERROR] An error ocurred while downloading zlib.
|
||||
echo %FILE_N% [DOWNLOAD ERROR] Possible causes:
|
||||
echo %FILE_N% - Make sure that the following url is valid:
|
||||
echo %FILE_N% "%ZLIB_REPO%"
|
||||
echo %FILE_N% [DOWNLOAD ERROR] Workaround:
|
||||
echo %FILE_N% - Download the zlib's source code and
|
||||
echo %FILE_N% extract the content in
|
||||
echo %FILE_N% "%ZLIB_SRC_DIR%"
|
||||
echo %FILE_N% And re-run the setup script.
|
||||
goto bad_exit
|
||||
|
||||
:error_extracting
|
||||
echo.
|
||||
echo %FILE_N% [EXTRACTING ERROR] An error ocurred while extracting the zip.
|
||||
echo %FILE_N% [EXTRACTING ERROR] Workaround:
|
||||
echo %FILE_N% - Download the libpng's source code and
|
||||
echo %FILE_N% extract the content manually in
|
||||
echo %FILE_N% "%ZLIB_SRC_DIR%"
|
||||
echo %FILE_N% And re-run the setup script.
|
||||
goto bad_exit
|
||||
|
||||
:error_cmake
|
||||
echo.
|
||||
echo %FILE_N% [CMAKE ERROR] An error ocurred while executing cmake command.
|
||||
echo %FILE_N% [CMAKE ERROR] Possible causes:
|
||||
echo %FILE_N% - Make sure "CMake" is installed.
|
||||
echo %FILE_N% - Make sure it is available on your Windows "path".
|
||||
echo %FILE_N% - Make sure you have cmake 3.12.4 or higher installed.
|
||||
goto bad_exit
|
||||
|
||||
:error_install
|
||||
echo.
|
||||
echo %FILE_N% [NMAKE ERROR] An error ocurred while compiling and installing using nmake.
|
||||
goto bad_exit
|
||||
|
||||
:good_exit
|
||||
echo %FILE_N% Exiting...
|
||||
endlocal
|
||||
rem A return value used for checking for errors
|
||||
set install_zlib=done
|
||||
exit /b 0
|
||||
|
||||
:bad_exit
|
||||
if exist "%ZLIB_INSTALL_DIR%" rd /s /q "%ZLIB_INSTALL_DIR%"
|
||||
echo %FILE_N% Exiting with error...
|
||||
endlocal
|
||||
exit /b %errorlevel%
|
Loading…
Reference in New Issue