Skip to content

Commit

Permalink
[flatbuffers] Initial commit of v1.6.0. Fixes #35.
Browse files Browse the repository at this point in the history
  • Loading branch information
ras0219-msft committed Mar 1, 2017
1 parent b2cf02b commit 9e43dbb
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ports/flatbuffers/CONTROL
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Source: flatbuffers
Version: 1.6.0
Description: Memory Efficient Serialization Library http://google.github.io/flatbuffers/
FlatBuffers is an efficient cross platform serialization library for games and other memory constrained apps. It allows you to directly access serialized data without unpacking/parsing it first, while still having great forwards/backwards compatibility.
65 changes: 65 additions & 0 deletions ports/flatbuffers/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Common Ambient Variables:
# VCPKG_ROOT_DIR = <C:\path\to\current\vcpkg>
# TARGET_TRIPLET is the current triplet (x86-windows, etc)
# PORT is the current port name (zlib, etc)
# CURRENT_BUILDTREES_DIR = ${VCPKG_ROOT_DIR}\buildtrees\${PORT}
# CURRENT_PACKAGES_DIR = ${VCPKG_ROOT_DIR}\packages\${PORT}_${TARGET_TRIPLET}
#

if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
message("Building DLLs not supported. Building static instead.")
set(VCPKG_LIBRARY_LINKAGE static)
endif()


include(vcpkg_common_functions)
set(SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/flatbuffers-1.6.0)
vcpkg_download_distfile(ARCHIVE
URLS "https://github.com/google/flatbuffers/archive/v1.6.0.zip"
FILENAME "flatbuffers-1.6.0.zip"
SHA512 c23043a54d7055f4e0a0164fdafd3f1d60292e57d62d20d30f641c9da90935d14da847f86239a19f777e68b707cfb25452da9192607a3a399ab25ce06b31c282
)
vcpkg_extract_source_archive(${ARCHIVE})

set(OPTIONS)
if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")

This comment has been minimized.

Copy link
@aardappel

aardappel Mar 1, 2017

Why is this still in there if dynamic linking is disabled early on? Maybe better to remove this?

This comment has been minimized.

Copy link
@ras0219-msft

ras0219-msft Mar 2, 2017

Author Contributor

That's part of the reason I needed you to review this: I noticed that the build produced DLLs without exports. I wasn't sure if this was intended, so I left in the DLL support code I already wrote in hopes that dynamic builds could be enabled with little effort in the future.

Are dynamic/shared builds supported on any platforms? If your supported dynamic build is "export all the symbols" -- the default behavior on Linux -- then we can do that.

This comment has been minimized.

Copy link
@aardappel

aardappel Mar 2, 2017

Ok, that is maybe unintentional in FlatBuffers.. it was never intended to be used from a .dll (or .so), and never tested, so yes, that is likely not to work at all. I suggest to just always link statically.

list(APPEND OPTIONS -DFLATBUFFERS_BUILD_SHAREDLIB=ON)
endif()

vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA # Disable this option if project cannot be built with Ninja
OPTIONS
-DFLATBUFFERS_BUILD_TESTS=OFF
-DFLATBUFFERS_BUILD_GRPCTEST=OFF
${OPTIONS}
# OPTIONS_RELEASE -DOPTIMIZE=1
# OPTIONS_DEBUG -DDEBUGGABLE=1
)

vcpkg_install_cmake()

if(EXISTS ${CURRENT_PACKAGES_DIR}/debug/bin)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/bin)
endif()
if(EXISTS ${CURRENT_PACKAGES_DIR}/bin/flatc.exe)
make_directory(${CURRENT_PACKAGES_DIR}/tools/flatbuffers)
file(RENAME ${CURRENT_PACKAGES_DIR}/bin/flatc.exe ${CURRENT_PACKAGES_DIR}/tools/flatbuffers/flatc.exe)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/bin)
endif()
if(EXISTS ${CURRENT_PACKAGES_DIR}/lib/flatbuffers.dll)

This comment has been minimized.

Copy link
@aardappel

aardappel Mar 1, 2017

Similarly, there should be no flatbuffers.dll, so remove these lines?

make_directory(${CURRENT_PACKAGES_DIR}/bin)
file(RENAME ${CURRENT_PACKAGES_DIR}/lib/flatbuffers.dll ${CURRENT_PACKAGES_DIR}/bin/flatbuffers.dll)
endif()
if(EXISTS ${CURRENT_PACKAGES_DIR}/debug/lib/flatbuffers.dll)
make_directory(${CURRENT_PACKAGES_DIR}/debug/bin)
file(RENAME ${CURRENT_PACKAGES_DIR}/debug/lib/flatbuffers.dll ${CURRENT_PACKAGES_DIR}/debug/bin/flatbuffers.dll)
endif()

vcpkg_copy_tool_dependencies(${CURRENT_PACKAGES_DIR}/tools/flatbuffers)

file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)

# Handle copyright
file(COPY ${SOURCE_PATH}/LICENSE.txt DESTINATION ${CURRENT_PACKAGES_DIR}/share/flatbuffers)
file(RENAME ${CURRENT_PACKAGES_DIR}/share/flatbuffers/LICENSE.txt ${CURRENT_PACKAGES_DIR}/share/flatbuffers/copyright)

0 comments on commit 9e43dbb

Please sign in to comment.