Skip to content

Commit

Permalink
Windows port
Browse files Browse the repository at this point in the history
  • Loading branch information
mathisloge authored and sopyer committed Jul 13, 2021
1 parent 92c5688 commit 8f16c53
Show file tree
Hide file tree
Showing 33 changed files with 570 additions and 98 deletions.
19 changes: 19 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# Created by http://www.gitignore.io

### Windows ###
.vscode/
.vs/
ipch/
build/
out/

CMakeSettings.json
*.suo
*.user
*.userosscache
*.sln.docstates
*.ncb
*.opendb
*.opensdf
*.sdf
*.VC.db
*.vspx

### OSX ###
.DS_Store
.AppleDouble
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.2)
cmake_minimum_required(VERSION 3.10)

project(tangram)

Expand All @@ -19,7 +19,7 @@ option(TANGRAM_DEV_MODE "For developers only: Don't omit the frame pointer" OFF)
message(STATUS "Build type configuration: ${CMAKE_BUILD_TYPE}")

# Check that submodules are present.
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/core/deps/harfbuzz-icu-freetype/harfbuzz/README")
if(NOT (WIN32 OR EXISTS "${PROJECT_SOURCE_DIR}/core/deps/harfbuzz-icu-freetype/harfbuzz/README"))
message(SEND_ERROR "Missing submodules - Please run:\n 'git submodule update --init'")
return()
endif()
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ For more information about building Tangram ES or using it in your project, see
- [Mac OS X](platforms/osx)
- [Ubuntu Linux](platforms/linux)
- [Raspberry Pi](platforms/rpi)
- [Windows](platforms/windows)

## Support

Expand Down
7 changes: 6 additions & 1 deletion cmake/utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ function(check_unsupported_compiler_version)
set(MIN_GCC 4.9)
set(MIN_CLANG 3.4)
set(MIN_APPLECLANG 6.0)
set(MIN_MSVC 19.0)

if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${MIN_GCC})
Expand All @@ -16,8 +17,12 @@ function(check_unsupported_compiler_version)
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${MIN_APPLECLANG})
message(FATAL_ERROR "Your Xcode version does not support C++14, please install version ${MIN_APPLECLANG} or higher")
endif()
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${MIN_MSVC})
message(FATAL_ERROR "Your MSVC version does not support C++14, please install version ${MIN_MSVC} or higher")
endif()
else()
message(WARNING "Compilation has only been tested with Clang, AppleClang, and GCC")
message(WARNING "Compilation has only been tested with Clang, AppleClang, GCC and MSVC")
endif()

endfunction(check_unsupported_compiler_version)
Expand Down
14 changes: 13 additions & 1 deletion core/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
project(tangram-core)

# Build core library dependencies.
if (WIN32)
find_package(yaml-cpp CONFIG REQUIRED)
find_package(ZLIB REQUIRED)
endif()

add_subdirectory(deps)

add_library(tangram-core
Expand Down Expand Up @@ -222,6 +227,13 @@ target_include_directories(tangram-core
deps/double-conversion/include
)

if (WIN32)
set(ZLIB_NAME ZLIB::ZLIB)
target_compile_definitions(tangram-core PUBLIC _USE_MATH_DEFINES)
else()
set(ZLIB_NAME z)
endif()

# Link core library dependencies.
target_link_libraries(tangram-core
PRIVATE
Expand All @@ -231,7 +243,7 @@ target_link_libraries(tangram-core
alfons
double-conversion
miniz
z
${ZLIB_NAME}
)

# Add JavaScript implementation.
Expand Down
33 changes: 21 additions & 12 deletions core/deps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ target_compile_definitions(glm INTERFACE GLM_FORCE_CTOR_INIT)

## yaml-cpp ##
##############
set(YAML_CPP_BUILD_TESTS OFF CACHE BOOL "")
set(YAML_CPP_BUILD_TOOLS OFF CACHE BOOL "")
set(YAML_CPP_BUILD_CONTRIB OFF CACHE BOOL "")
set(YAML_CPP_INSTALL OFF CACHE BOOL "")
add_subdirectory(yaml-cpp)

target_include_directories(yaml-cpp PUBLIC yaml-cpp/include)
if (NOT WIN32)
set(YAML_CPP_BUILD_TESTS OFF CACHE BOOL "")
set(YAML_CPP_BUILD_TOOLS OFF CACHE BOOL "")
set(YAML_CPP_BUILD_CONTRIB OFF CACHE BOOL "")
set(YAML_CPP_INSTALL OFF CACHE BOOL "")
add_subdirectory(yaml-cpp)

target_include_directories(yaml-cpp PUBLIC yaml-cpp/include)
endif()

## css-color-parser-cpp ##
##########################
Expand Down Expand Up @@ -48,14 +50,21 @@ target_include_directories(miniz
if(NOT TANGRAM_USE_SYSTEM_FONT_LIBS)
## Harfbuzz - ICU-Common - Freetype2 ##
#######################################
set(HARFBUZZ_BUILD_ICU ON CACHE BOOL "Enable building of ICU")
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/harfbuzz-icu-freetype)

message(STATUS "harfbuzz" ${HARFBUZZ_LIBRARIES})
if(WIN32)
#find_package(ICU REQUIRED COMPONENTS common)
find_package(harfbuzz CONFIG REQUIRED)
set(HARFBUZZ_LIB_NAME harfbuzz::harfbuzz)
else()
set(HARFBUZZ_BUILD_ICU ON CACHE BOOL "Enable building of ICU")
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/harfbuzz-icu-freetype)

message(STATUS "harfbuzz" ${HARFBUZZ_LIBRARIES})
set(HARFBUZZ_LIB_NAME harfbuzz ${HARFBUZZ_LIBRARIES})
endif()

set(ALFONS_DEPS_LIBRARIES
${ALFONS_DEPS_LIBRARIES}
harfbuzz ${HARFBUZZ_LIBRARIES}
${HARFBUZZ_LIB_NAME}
CACHE INTERNAL "alfons-libs" FORCE)
endif()

Expand Down
6 changes: 5 additions & 1 deletion core/deps/pbf/pbf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,13 @@
#endif

namespace protobuf {

#if defined(__GNUC__)
#define FORCEINLINE inline __attribute__((always_inline))
#define NOINLINE __attribute__((noinline))
#else
#define FORCEINLINE inline
#define NOINLINE
#endif
#define PBF_INLINE FORCEINLINE

class message {
Expand Down
4 changes: 4 additions & 0 deletions core/include/tangram/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ static constexpr const char * past_last_slash(const char * const str) {
return past_last_slash(str, str);
}

#ifdef TANGRAM_WINDOWS
#define __FILENAME__ __FILE__
#else
#define __FILENAME__ ({constexpr const char * const sf__ {past_last_slash(__FILE__)}; sf__;})
#endif

#define TANGRAM_MAX_BUFFER_LOG_SIZE 99999

Expand Down
1 change: 1 addition & 0 deletions core/include/tangram/tile/tileID.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <cassert>
#include <cstdint>
#include <string>
#include <algorithm>

/* An immutable identifier for a map tile
*
Expand Down
10 changes: 9 additions & 1 deletion core/include/tangram/util/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,15 @@ using Value = variant<none_type, double, std::string>;

class Value : public detail::Value {
using Base = detail::Value;
using Base::Base;

public:
Value(): Base() {}

template<typename T>
Value(const T& val): Base(val) {}

template<typename T>
Value(T&& val): Base(val) {}
};

const static Value NOT_A_VALUE(none_type{});
Expand Down
2 changes: 1 addition & 1 deletion core/src/data/rasterSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ std::shared_ptr<Texture> RasterSource::cacheTexture(const TileID& _tileId, std::
}

texture = std::shared_ptr<Texture>(_texture.release(),
[c = std::weak_ptr<Cache>(m_textures), id](auto t) {
[c = std::weak_ptr<Cache>(m_textures), id](auto* t) {
if (auto cache = c.lock()) {
cache->erase(id);
LOGD("%d - remove %s", cache->size(), id.toString().c_str());
Expand Down
2 changes: 1 addition & 1 deletion core/src/debug/textDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void TextDisplay::draw(RenderState& rs, const std::string& _text, int _posx, int
std::vector<glm::vec2> vertices;
int nquads;

nquads = stb_easy_font_print(_posx, _posy, _text.c_str(), NULL, m_vertexBuffer, VERTEX_BUFFER_SIZE);
nquads = stb_easy_font_print(_posx, _posy, const_cast<char*>(_text.c_str()), NULL, m_vertexBuffer, VERTEX_BUFFER_SIZE);

float* data = reinterpret_cast<float*>(m_vertexBuffer);

Expand Down
2 changes: 1 addition & 1 deletion core/src/gl/framebuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ void FrameBuffer::init(RenderState& _rs) {
}

GLenum status = GL::checkFramebufferStatus(GL_FRAMEBUFFER);
GL_CHECK();
GL_CHECK({});

if (status != GL_FRAMEBUFFER_COMPLETE) {
LOGE("Framebuffer status is incomplete:");
Expand Down
4 changes: 4 additions & 0 deletions core/src/scene/importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,11 @@ void Importer::addSceneYaml(const Url& sceneUrl, const char* sceneYaml, size_t l
auto& sceneNode = m_sceneNodes[sceneUrl];

try {
#ifdef TANGRAM_WINDOWS
sceneNode.yaml = YAML::Load(sceneYaml);
#else
sceneNode.yaml = YAML::Load(sceneYaml, length);
#endif
} catch (const YAML::ParserException& e) {
LOGE("Parsing scene config '%s'", e.what());
return;
Expand Down
30 changes: 15 additions & 15 deletions core/src/scene/sceneLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ void SceneLoader::applyScene(const Node& _node, Color& backgroundColor,
Stops& backgroundStops, Scene::animate& animated) {
if (!_node) { return; }
if (!_node.IsMap()) {
LOGNode("Invalid 'scene' section", _node);
LOGNode("Invalid 'scene' section", _node, "");
return;
}

Expand Down Expand Up @@ -302,7 +302,7 @@ Scene::Lights SceneLoader::applyLights(const Node& _node) {
}
}
} else if (_node) {
LOGNode("Invalid 'lights'", _node);
LOGNode("Invalid 'lights'", _node, "");
}

if (lights.empty()) {
Expand Down Expand Up @@ -436,14 +436,14 @@ void SceneLoader::parseLightPosition(const Node& _positionNode, PointLight& _lig
}
_light.setPosition(positionResult);
} else {
LOGNode("Invalid light position parameter:", _positionNode);
LOGNode("Invalid light position parameter:", _positionNode, "");
}
}

void SceneLoader::applyTextures(const Node& _node, SceneTextures& _textures) {
if (!_node) { return; }
if (!_node.IsMap()) {
LOGNode("Invalid 'textures' section", _node);
LOGNode("Invalid 'textures' section", _node, "");
return;
}

Expand Down Expand Up @@ -543,7 +543,7 @@ bool SceneLoader::parseTexFiltering(const Node& _filteringNode, TextureOptions&
void SceneLoader::applyFonts(const Node& _node, SceneFonts& _fonts) {
if (!_node) { return; }
if (!_node.IsMap()) {
LOGNode("Invalid 'fonts' section", _node);
LOGNode("Invalid 'fonts' section", _node, "");
return;
}

Expand All @@ -570,7 +570,7 @@ void SceneLoader::applyFonts(const Node& _node, SceneFonts& _fonts) {
void SceneLoader::loadFontDescription(const Node& _node, const std::string& _family, SceneFonts& _fonts) {
if (!_node) { return; }
if (!_node.IsMap()) {
LOGNode("Invalid 'font' section", _node);
LOGNode("Invalid 'font' section", _node, "");
return;
}

Expand Down Expand Up @@ -634,18 +634,18 @@ Scene::TileSources SceneLoader::applySources(const Node& _config, const SceneOpt

if (const Node& rasters = source.second["rasters"]) {
if (!rasters.IsSequence()) {
LOGNode("Invalid 'rasters'", rasters);
LOGNode("Invalid 'rasters'", rasters, "");
continue;
}
for (const auto& raster : rasters) {
if (!raster.IsScalar()) {
LOGNode("Invalid 'raster'", raster);
LOGNode("Invalid 'raster'", raster, "");
continue;
}
if (auto rasterSource = getTileSource(raster.Scalar())) {
tileSource->addRasterSource(rasterSource);
} else {
LOGNode("Missing raster source", raster);
LOGNode("Missing raster source", raster, "");
}
}
}
Expand Down Expand Up @@ -676,7 +676,7 @@ Scene::TileSources SceneLoader::applySources(const Node& _config, const SceneOpt
if (!data_source) { continue;}

if (!data_source.IsScalar()) {
LOGNode("Invalid 'source", data);
LOGNode("Invalid 'source", data, "");
continue;
}
auto source = data_source.Scalar();
Expand Down Expand Up @@ -875,7 +875,7 @@ Scene::Styles SceneLoader::applyStyles(const Node& _node, SceneTextures& _textur

if (!_node) { return styles; }
if (!_node.IsMap()) {
LOGNode("Invalid 'styles' section", _node);
LOGNode("Invalid 'styles' section", _node, "");
return styles;
}

Expand Down Expand Up @@ -1256,7 +1256,7 @@ void SceneLoader::loadShaderConfig(const Node& _shaders, Style& _style, SceneTex

_style.styleUniforms().emplace_back(name, styleUniform.value);
} else {
LOGNode("Style uniform parsing failure", uniform.second);
LOGNode("Style uniform parsing failure", uniform.second, "");
}
}
}
Expand Down Expand Up @@ -1387,7 +1387,7 @@ void SceneLoader::loadMaterial(const Node& _matNode, Material& _material, Style&
// Handled as texture
break;
default:
LOGNode("Invalid 'material'", prop);
LOGNode("Invalid 'material'", prop, "");
break;
}
return glm::vec4(0.0);
Expand Down Expand Up @@ -1441,7 +1441,7 @@ MaterialTexture SceneLoader::loadMaterialTexture(const Node& _matCompNode, Style

Node textureNode = _matCompNode["texture"];
if (!textureNode) {
LOGNode("Expected a 'texture' parameter", _matCompNode);
LOGNode("Expected a 'texture' parameter", _matCompNode, "");

return MaterialTexture{};
}
Expand Down Expand Up @@ -1501,7 +1501,7 @@ std::vector<DataLayer> SceneLoader::applyLayers(const Node& _node, SceneFunctio
SceneStops& _stops, DrawRuleNames& _ruleNames) {
if (!_node) { return {}; }
if (!_node.IsMap()) {
LOGNode("Invalid 'layers' section", _node);
LOGNode("Invalid 'layers' section", _node, "");
return {};
}

Expand Down
Loading

0 comments on commit 8f16c53

Please sign in to comment.