Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Windows build of habitat-sim #84

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def is_pip():
class CMakeExtension(Extension):
def __init__(self, name, sourcedir=""):
Extension.__init__(self, name, sources=[])
self.sourcedir = os.path.abspath(sourcedir)
self.sourcedir = os.path.abspath(sourcedir).replace("\\", "/")


# populated in CMakeBuild.build_extension()
Expand Down Expand Up @@ -207,8 +207,8 @@ def build_extension(self, ext):

cmake_args = [
"-DBUILD_PYTHON_BINDINGS=ON",
"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=" + extdir,
"-DPYTHON_EXECUTABLE=" + sys.executable,
"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=" + extdir.replace("\\", "/"),
"-DPYTHON_EXECUTABLE=" + sys.executable.replace("\\", "/"),
"-DCMAKE_EXPORT_COMPILE_COMMANDS={}".format("OFF" if is_pip() else "ON"),
]
cmake_args += shlex.split(args.cmake_args)
Expand All @@ -226,8 +226,9 @@ def build_extension(self, ext):
# doesn't require a number (but builds sequentially by default), so we
# add the argument only when it's not ninja or the number of jobs is
# specified.
if not has_ninja() or self.parallel:
build_args += ["-j{}".format(self.parallel) if self.parallel else "-j"]
if sys.platform != "win32":
if not has_ninja() or self.parallel:
build_args += ["-j{}".format(self.parallel) if self.parallel else "-j"]

cmake_args += [
"-DBUILD_GUI_VIEWERS={}".format("ON" if not args.headless else "OFF")
Expand All @@ -247,13 +248,18 @@ def build_extension(self, ext):

if self.run_cmake(cmake_args):
subprocess.check_call(
shlex.split("cmake -H{} -B{}".format(ext.sourcedir, self.build_temp))
shlex.split(
"cmake -H{} -B{}".format(
ext.sourcedir, self.build_temp.replace("\\", "/")
)
)
+ cmake_args,
env=env,
)

subprocess.check_call(
shlex.split("cmake --build {}".format(self.build_temp)) + build_args
shlex.split("cmake --build {}".format(self.build_temp.replace("\\", "/")))
+ build_args
)
print() # Add an empty line for cleaner output

Expand Down
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ cmake_minimum_required(VERSION 3.10)
project(esp)

if(MSVC)
add_definitions(/DNOMINMAX)
add_definitions(/DNOMINMAX /DEIGEN_DONT_ALIGN_STATICALLY)
endif()

find_program(CCACHE_FOUND ccache)
Expand Down
5 changes: 5 additions & 0 deletions src/esp/assets/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ endif()

add_library(assets STATIC ${assets_SOURCES})

if(MSVC)
# Define common math constants if we compile with MSVC. This is needed because of Sophus.
target_compile_definitions(assets PUBLIC _USE_MATH_DEFINES)
endif (MSVC)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just endif(), repeating the condition is considered a bad practice nowadays.

Same in the other two cases.


target_link_libraries(assets
PUBLIC
core
Expand Down
2 changes: 0 additions & 2 deletions src/esp/assets/FRLInstanceMeshData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
#include <Magnum/Trade/Trade.h>

#include <fcntl.h>
#include <sys/mman.h>
#include <tinyply.h>
#include <unistd.h>
#include <fstream>
#include <sophus/so3.hpp>
#include <sstream>
Expand Down
2 changes: 0 additions & 2 deletions src/esp/assets/GenericInstanceMeshData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
#include <Magnum/Trade/Trade.h>

#include <fcntl.h>
#include <sys/mman.h>
#include <tinyply.h>
#include <unistd.h>
#include <fstream>
#include <sophus/so3.hpp>
#include <sstream>
Expand Down
6 changes: 3 additions & 3 deletions src/esp/assets/PTexMeshData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ std::vector<PTexMeshData::MeshData> splitMesh(

// calculate vertex grid position and code
#pragma omp parallel for
for (size_t i = 0; i < mesh.vbo.size(); i++) {
for (int32_t i = 0; i < mesh.vbo.size(); i++) {
const vec3f p = mesh.vbo[i].head<3>();
vec3f pi = (p - boundingBox.min()) / splitSize;
verts[i] = EncodeMorton3(pi.cast<int>());
Expand All @@ -109,7 +109,7 @@ std::vector<PTexMeshData::MeshData> splitMesh(
faces.resize(numFaces);

#pragma omp parallel for
for (size_t i = 0; i < numFaces; i++) {
for (int32_t i = 0; i < numFaces; i++) {
faces[i].originalFace = i;
faces[i].code = std::numeric_limits<uint32_t>::max();
for (int j = 0; j < 4; j++) {
Expand Down Expand Up @@ -155,7 +155,7 @@ std::vector<PTexMeshData::MeshData> splitMesh(
}

#pragma omp parallel for
for (size_t i = 0; i < numChunks; i++) {
for (int32_t i = 0; i < numChunks; i++) {
uint32_t chunkSize = chunkStart[i + 1] - chunkStart[i];

std::vector<uint32_t> refdVerts;
Expand Down
5 changes: 5 additions & 0 deletions src/esp/gfx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ target_include_directories(gfx
"${DEPS_DIR}/glad/include"
)

if(MSVC)
# Define common math constants if we compile with MSVC. This is needed because of Sophus.
target_compile_definitions(gfx PUBLIC _USE_MATH_DEFINES)
endif (MSVC)

target_link_libraries(gfx
PUBLIC
assets
Expand Down
1 change: 0 additions & 1 deletion src/esp/gfx/PTexMeshShader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "PTexMeshShader.h"

#include <fcntl.h>
#include <sys/mman.h>
#include <iostream>

#include <Corrade/Containers/Reference.h>
Expand Down
5 changes: 5 additions & 0 deletions src/esp/nav/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ target_include_directories(nav
"${DEPS_DIR}/recastnavigation/Recast/Include"
)

if(MSVC)
# Define common math constants if we compile with MSVC. This is needed because of Sophus.
target_compile_definitions(nav PUBLIC _USE_MATH_DEFINES)
endif (MSVC)

target_link_libraries(nav
PUBLIC
core
Expand Down
2 changes: 1 addition & 1 deletion src/esp/nav/PathFinder.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class dtQueryPathState;
namespace esp {
// forward declaration
namespace assets {
class MeshData;
struct MeshData;
}
namespace nav {

Expand Down