Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
14 changes: 9 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,25 @@ jobs:
shell: bash
run: ci/scripts/build_example.sh $(pwd)/example
windows:
name: AMD64 Windows 2019
runs-on: windows-2019
name: AMD64 Windows 2022
runs-on: windows-2022
timeout-minutes: 30
steps:
- name: Checkout iceberg-cpp
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- name: Install ZLIB
shell: cmd
run: |
vcpkg install zlib:x64-windows
- name: Build Iceberg
shell: cmd
run: |
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64
bash -c "ci/scripts/build_iceberg.sh $(pwd)
call "C:\Program Files (x86)\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64
bash -c "ci/scripts/build_iceberg_windows.sh $(pwd)
- name: Build Example
shell: cmd
run: |
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64
call "C:\Program Files (x86)\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64
bash -c "ci/scripts/build_example.sh $(pwd)/example
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ option(ICEBERG_BUILD_STATIC "Build static library" ON)
option(ICEBERG_BUILD_SHARED "Build shared library" OFF)
option(ICEBERG_BUILD_TESTS "Build tests" ON)
option(ICEBERG_ARROW "Build Arrow" ON)
option(ICEBERG_AVRO "Build Avro" ON)

include(GNUInstallDirs)
include(FetchContent)
Expand Down
40 changes: 40 additions & 0 deletions ci/scripts/build_iceberg_windows.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env bash
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

set -eux

source_dir=${1}
build_dir=${1}/build

mkdir ${build_dir}
pushd ${build_dir}

cmake \
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX:-${ICEBERG_HOME}} \
-DICEBERG_BUILD_STATIC=ON \
-DICEBERG_BUILD_SHARED=ON \
-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake \
${source_dir}
cmake --build . --target install
ctest --output-on-failure -C Debug

popd

# clean up between builds
rm -rf ${build_dir}
65 changes: 65 additions & 0 deletions cmake_modules/IcebergThirdpartyToolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,68 @@ endfunction()
if(ICEBERG_ARROW)
resolve_arrow_dependency()
endif()

# ----------------------------------------------------------------------
# Apache Avro

function(resolve_avro_dependency)
prepare_fetchcontent()

set(AVRO_USE_BOOST
OFF
CACHE BOOL "" FORCE)

set(AVRO_BUILD_EXECUTABLES
OFF
CACHE BOOL "" FORCE)

set(AVRO_BUILD_TESTS
OFF
CACHE BOOL "" FORCE)

fetchcontent_declare(Avro
${FC_DECLARE_COMMON_OPTIONS}
GIT_REPOSITORY https://github.com/apache/avro.git
GIT_TAG 1144cb7322bab4cd1c8bf330a9c504a0d4252b56
SOURCE_SUBDIR
lang/c++
FIND_PACKAGE_ARGS
NAMES
Avro
CONFIG)

fetchcontent_makeavailable(Avro)

if(avro_SOURCE_DIR)
if(NOT TARGET Avro::avro_static)
add_library(Avro::avro_static INTERFACE IMPORTED)
target_link_libraries(Avro::avro_static INTERFACE avrocpp_s)
set_target_properties(avrocpp_s PROPERTIES OUTPUT_NAME "iceberg_vendored_avro")
endif()

if(NOT TARGET Avro::avro_shared)
add_library(Avro::avro_shared INTERFACE IMPORTED)
target_link_libraries(Avro::avro_shared INTERFACE avrocpp)
set_target_properties(avrocpp PROPERTIES OUTPUT_NAME "iceberg_vendored_avro")
endif()

if(ICEBERG_BUILD_STATIC)
install(TARGETS avrocpp_s
EXPORT iceberg_targets
RUNTIME DESTINATION "${ICEBERG_INSTALL_BINDIR}"
ARCHIVE DESTINATION "${ICEBERG_INSTALL_LIBDIR}"
LIBRARY DESTINATION "${ICEBERG_INSTALL_LIBDIR}")
endif()
if(ICEBERG_BUILD_SHARED)
install(TARGETS avrocpp
EXPORT iceberg_targets
RUNTIME DESTINATION "${ICEBERG_INSTALL_BINDIR}"
ARCHIVE DESTINATION "${ICEBERG_INSTALL_LIBDIR}"
LIBRARY DESTINATION "${ICEBERG_INSTALL_LIBDIR}")
endif()
endif()
endfunction()

if(ICEBERG_AVRO)
resolve_avro_dependency()
endif()
1 change: 1 addition & 0 deletions src/iceberg/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/iceberg_export.h
DESTINATION ${ICEBERG_INSTALL_INCLUDEDIR}/iceberg)

add_subdirectory(arrow)
add_subdirectory(avro)
add_subdirectory(puffin)

iceberg_install_cmake_package(Iceberg iceberg_targets)
34 changes: 34 additions & 0 deletions src/iceberg/avro.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

#pragma once

#include <string>

#include "iceberg/iceberg_export.h"

namespace iceberg {

class ICEBERG_EXPORT Avro {
public:
virtual ~Avro() = default;
virtual std::string print() const = 0;
};

} // namespace iceberg
66 changes: 66 additions & 0 deletions src/iceberg/avro/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

if(NOT ICEBERG_AVRO)
return()
endif()

set(ICEBERG_AVRO_SOURCES demo_avro.cc)
set(ICEBERG_AVRO_INCLUDES "${ICEBERG_INCLUDES}")

# Libraries to link with exported libiceberg_avro.{so,a}.
set(ICEBERG_AVRO_STATIC_BUILD_INTERFACE_LIBS)
set(ICEBERG_AVRO_SHARED_BUILD_INTERFACE_LIBS)
set(ICEBERG_AVRO_STATIC_INSTALL_INTERFACE_LIBS)
set(ICEBERG_AVRO_SHARED_INSTALL_INTERFACE_LIBS)

list(APPEND ICEBERG_AVRO_STATIC_BUILD_INTERFACE_LIBS
"$<IF:$<TARGET_EXISTS:iceberg_static>,iceberg_static,iceberg_shared>"
Avro::avro_static)
list(APPEND ICEBERG_AVRO_SHARED_BUILD_INTERFACE_LIBS
"$<IF:$<TARGET_EXISTS:iceberg_shared>,iceberg_shared,iceberg_static>"
Avro::avro_shared)
list(APPEND ICEBERG_AVRO_STATIC_INSTALL_INTERFACE_LIBS Iceberg::avro_static)
list(APPEND ICEBERG_AVRO_SHARED_INSTALL_INTERFACE_LIBS Iceberg::avro_shared)

list(APPEND
ICEBERG_AVRO_STATIC_INSTALL_INTERFACE_LIBS
"$<IF:$<TARGET_EXISTS:Iceberg::iceberg_static>,Iceberg::iceberg_static,Iceberg::iceberg_shared>"
)
list(APPEND
ICEBERG_AVRO_SHARED_INSTALL_INTERFACE_LIBS
"$<IF:$<TARGET_EXISTS:Iceberg::iceberg_shared>,Iceberg::iceberg_shared,Iceberg::iceberg_static>"
)

add_iceberg_lib(iceberg_avro
SOURCES
${ICEBERG_AVRO_SOURCES}
PRIVATE_INCLUDES
${ICEBERG_AVRO_INCLUDES}
SHARED_LINK_LIBS
${ICEBERG_AVRO_SHARED_BUILD_INTERFACE_LIBS}
STATIC_LINK_LIBS
${ICEBERG_AVRO_STATIC_BUILD_INTERFACE_LIBS}
STATIC_INSTALL_INTERFACE_LIBS
${ICEBERG_AVRO_STATIC_INSTALL_INTERFACE_LIBS}
SHARED_INSTALL_INTERFACE_LIBS
${ICEBERG_AVRO_SHARED_INSTALL_INTERFACE_LIBS})

iceberg_install_all_headers(iceberg/avro)

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/iceberg_avro_export.h
DESTINATION ${ICEBERG_INSTALL_INCLUDEDIR}/iceberg/avro)
52 changes: 52 additions & 0 deletions src/iceberg/avro/demo_avro.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

#include "iceberg/avro/demo_avro.h"

#include <sstream>

#include "avro/Compiler.hh"
#include "avro/ValidSchema.hh"
#include "iceberg/demo_table.h"

namespace iceberg {

std::string DemoAvro::print() const {
std::string input =
"{\n\
\"type\": \"record\",\n\
\"name\": \"testrecord\",\n\
\"fields\": [\n\
{\n\
\"name\": \"testbytes\",\n\
\"type\": \"bytes\",\n\
\"default\": \"\"\n\
}\n\
]\n\
}\n\
";

avro::ValidSchema schema = avro::compileJsonSchemaFromString(input);
std::ostringstream actual;
schema.toJson(actual);

return actual.str();
}

} // namespace iceberg
36 changes: 36 additions & 0 deletions src/iceberg/avro/demo_avro.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

#pragma once

#include <string>

#include "iceberg/avro.h"
#include "iceberg/avro/iceberg_avro_export.h"

namespace iceberg {

class ICEBERG_AVRO_EXPORT DemoAvro : public Avro {
public:
DemoAvro() = default;
~DemoAvro() override = default;
std::string print() const override;
};

} // namespace iceberg
8 changes: 8 additions & 0 deletions test/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,11 @@ target_sources(core_unittest PRIVATE core_unittest.cc)
target_link_libraries(core_unittest PRIVATE iceberg_static GTest::gtest_main)
target_include_directories(core_unittest PRIVATE "${ICEBERG_INCLUDES}")
add_test(NAME core_unittest COMMAND core_unittest)

if(ICEBERG_AVRO)
add_executable(avro_unittest)
target_sources(avro_unittest PRIVATE avro_unittest.cc)
target_link_libraries(avro_unittest PRIVATE iceberg_avro_static GTest::gtest_main)
target_include_directories(avro_unittest PRIVATE "${ICEBERG_INCLUDES}")
add_test(NAME avro_unittest COMMAND avro_unittest)
endif()
Loading