This is an automated email from the ASF dual-hosted git repository.

kou pushed a commit to branch main
in repository 
https://gitbox.apache.org/repos/asf/arrow-flight-sql-postgresql.git


The following commit(s) were added to refs/heads/main by this push:
     new 120383f  Use Meson instead of CMake (#77)
120383f is described below

commit 120383f759563c2172d17bdba6f8ebf9a7beb777
Author: Sutou Kouhei <[email protected]>
AuthorDate: Thu Aug 24 15:08:13 2023 +0900

    Use Meson instead of CMake (#77)
    
    Because PostgreSQL uses Meson.
---
 .editorconfig                                      |   2 +-
 .github/workflows/test.yaml                        |  13 +--
 .pre-commit-config.yaml                            |   4 -
 CMakeLists.txt                                     | 106 ---------------------
 .cmake-format.py => benchmark/integer/meson.build  |   4 +-
 meson.build                                        |  73 ++++++++++++++
 .../integer/CMakeLists.txt => meson_options.txt    |  11 ++-
 src/afs.cc                                         |  23 +++--
 8 files changed, 107 insertions(+), 129 deletions(-)

diff --git a/.editorconfig b/.editorconfig
index 4075833..3ec850a 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -25,7 +25,7 @@ indent_style = tab
 insert_final_newline = true
 trim_trailing_whitespace = true
 
-[*.sh]
+[{*.sh,meson.build,meson_options.txt}]
 
 end_of_line = lf
 indent_size = 2
diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml
index 74ab677..aa5233b 100644
--- a/.github/workflows/test.yaml
+++ b/.github/workflows/test.yaml
@@ -50,6 +50,7 @@ jobs:
           sudo apt update
           sudo apt install -y -V \
             libarrow-flight-sql-glib-dev \
+            meson \
             ninja-build
       - name: Install PostgreSQL
         run: |
@@ -66,12 +67,12 @@ jobs:
             postgresql-server-dev-${{ matrix.postgresql-version }}
       - name: Install Apache Arrow Flight SQL adapter
         run: |
-          cmake \
-            -S . \
-            -B build \
-            -DCMAKE_INSTALL_PREFIX=/usr \
-            -DCMAKE_BUILD_TYPE=Debug \
-            -GNinja
+          meson \
+            setup \
+            --prefix=/tmp/local \
+            -Dbenchmark=true \
+            -Dpostgresql_dir=$(pg_config --binddir)/.. \
+            build
           ninja -C build
           sudo ninja -C build install
       - uses: ruby/setup-ruby@v1
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 8f98c48..3b5e536 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -20,7 +20,3 @@ repos:
     rev: "v15.0.7"
     hooks:
       - id: clang-format
-  - repo: https://github.com/cheshirekow/cmake-format-precommit
-    rev: v0.6.13
-    hooks:
-      - id: cmake-format
diff --git a/CMakeLists.txt b/CMakeLists.txt
deleted file mode 100644
index 9baee7c..0000000
--- a/CMakeLists.txt
+++ /dev/null
@@ -1,106 +0,0 @@
-# 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.
-
-cmake_minimum_required(VERSION 3.19)
-message(STATUS "Building using CMake version: ${CMAKE_VERSION}")
-
-project(
-  arrow-flight-sql
-  DESCRIPTION "Apache Arrow Flight SQL adapter"
-  HOMEPAGE_URL https://arrow.apache.org/flight-sql-postgresql
-  LANGUAGES C CXX
-  VERSION 0.1.0)
-
-include(GNUInstallDirs)
-
-set(AFS_SOURCES src/afs.cc)
-
-set(AFS_POSTGRESQL_DIR
-    "${CMAKE_INSTALL_PREFIX}"
-    CACHE PATH "PostgreSQL binary directory")
-
-find_program(AFS_PG_CONFIG "pg_config" HINTS "${AFS_POSTGRESQL_DIR}/bin")
-if(NOT AFS_PG_CONFIG)
-  message(FATAL_ERROR "pg_config isn't found")
-endif()
-add_executable(pg_config IMPORTED)
-set_target_properties(pg_config PROPERTIES IMPORTED_LOCATION ${AFS_PG_CONFIG})
-
-add_library(postgresql INTERFACE IMPORTED)
-execute_process(
-  COMMAND pg_config "--includedir-server"
-  OUTPUT_VARIABLE AFS_PG_INCLUDE_DIR
-  OUTPUT_STRIP_TRAILING_WHITESPACE ECHO_OUTPUT_VARIABLE COMMAND_ERROR_IS_FATAL
-  ANY)
-target_include_directories(postgresql INTERFACE ${AFS_PG_INCLUDE_DIR})
-execute_process(
-  COMMAND pg_config "--cflags_sl"
-  OUTPUT_VARIABLE AFS_PG_CFLAGS
-  OUTPUT_STRIP_TRAILING_WHITESPACE ECHO_OUTPUT_VARIABLE COMMAND_ERROR_IS_FATAL
-  ANY)
-separate_arguments(AFS_PG_COMPILE_OPTIONS NATIVE_COMMAND PROGRAM
-                   SEPARATE_ARGS ${AFS_PG_CFLAGS})
-target_compile_options(postgresql INTERFACE ${AFS_PG_COMPILE_OPTIONS})
-execute_process(
-  COMMAND pg_config "--libdir"
-  OUTPUT_VARIABLE AFS_PG_LIB_DIR
-  OUTPUT_STRIP_TRAILING_WHITESPACE ECHO_OUTPUT_VARIABLE COMMAND_ERROR_IS_FATAL
-  ANY)
-target_link_directories(postgresql INTERFACE ${AFS_PG_LIB_DIR})
-
-add_library(libpq SHARED IMPORTED)
-execute_process(
-  COMMAND pg_config "--includedir"
-  OUTPUT_VARIABLE AFS_LIBPG_INCLUDE_DIR
-  OUTPUT_STRIP_TRAILING_WHITESPACE ECHO_OUTPUT_VARIABLE COMMAND_ERROR_IS_FATAL
-  ANY)
-target_include_directories(libpq INTERFACE ${AFS_LIBPG_INCLUDE_DIR})
-execute_process(
-  COMMAND pg_config "--cflags"
-  OUTPUT_VARIABLE AFS_LIBPQ_CFLAGS
-  OUTPUT_STRIP_TRAILING_WHITESPACE ECHO_OUTPUT_VARIABLE COMMAND_ERROR_IS_FATAL
-  ANY)
-separate_arguments(AFS_LIBPQ_COMPILE_OPTIONS NATIVE_COMMAND PROGRAM
-                   SEPARATE_ARGS ${AFS_LIBPQ_CFLAGS})
-target_compile_options(libpq INTERFACE ${AFS_LIBPQ_COMPILE_OPTIONS})
-execute_process(
-  COMMAND pg_config "--libdir"
-  OUTPUT_VARIABLE AFS_LIBPQ_LIB_DIR
-  OUTPUT_STRIP_TRAILING_WHITESPACE ECHO_OUTPUT_VARIABLE COMMAND_ERROR_IS_FATAL
-  ANY)
-find_library(AFS_LIBPQ_SHARED_LIBRARY pq PATHS ${AFS_LIBPQ_LIB_DIR})
-set_target_properties(libpq PROPERTIES IMPORTED_LOCATION
-                                       ${AFS_LIBPQ_SHARED_LIBRARY})
-
-find_package(ArrowFlightSql REQUIRED)
-
-add_library(arrow_flight_sql MODULE ${AFS_SOURCES})
-set_target_properties(arrow_flight_sql PROPERTIES PREFIX "")
-target_compile_definitions(arrow_flight_sql
-                           PRIVATE "$<$<CONFIG:Debug>:AFS_DEBUG>")
-target_link_libraries(arrow_flight_sql postgresql
-                      ArrowFlightSql::arrow_flight_sql_shared)
-execute_process(
-  COMMAND pg_config "--pkglibdir"
-  OUTPUT_VARIABLE AFS_PG_EXTENSION_DIR
-  OUTPUT_STRIP_TRAILING_WHITESPACE ECHO_OUTPUT_VARIABLE COMMAND_ERROR_IS_FATAL
-  ANY)
-install(TARGETS arrow_flight_sql DESTINATION "${AFS_PG_EXTENSION_DIR}")
-
-install(FILES LICENSE.txt NOTICE.txt DESTINATION "${CMAKE_INSTALL_DOCDIR}")
-
-add_subdirectory(benchmark/integer)
diff --git a/.cmake-format.py b/benchmark/integer/meson.build
similarity index 90%
rename from .cmake-format.py
rename to benchmark/integer/meson.build
index 7b0413c..93561b2 100644
--- a/.cmake-format.py
+++ b/benchmark/integer/meson.build
@@ -15,5 +15,5 @@
 # specific language governing permissions and limitations
 # under the License.
 
-with section("markup"):
-  first_comment_is_literal = True
+libpq = dependency('libpq')
+executable('select', 'select.c', dependencies: [libpq])
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..da8a4fa
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,73 @@
+# 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.
+
+project('arrow-flight-sql-postgresql', 'c', 'cpp',
+        default_options: [
+          'buildtype=debug',
+          'cpp_std=c++17',
+        ],
+        license: 'Apache-2.0',
+        # Meson 1.1.0 or later is required.
+        # license_files: ['LICENSE.txt', 'NOTICE.txt'],
+        version: '0.1.0')
+
+prefix = get_option('prefix')
+data_dir = prefix / get_option('datadir')
+doc_dir = data_dir / 'doc'
+project_doc_dir = doc_dir / meson.project_name()
+
+postgresql_dir = get_option('postgresql_dir')
+pg_config_names = []
+if postgresql_dir != ''
+  pg_config_names += [postgresql_dir / 'bin' / 'pg_config']
+endif
+pg_config_names += ['pg_config']
+pg_config = find_program(pg_config_names)
+
+arrow_flight_sql = dependency(
+  'ArrowFlightSql',
+  method: 'cmake',
+  modules: ['ArrowFlightSql::arrow_flight_sql_shared']
+)
+postgresql = declare_dependency(
+  compile_args: run_command(pg_config,
+                            '--cflags_sl',
+                            check: true).stdout().strip(),
+  include_directories: run_command(pg_config,
+                                   '--includedir-server',
+                                   check: true).stdout().strip(),
+)
+install_dir = run_command(pg_config, '--pkglibdir', check: 
true).stdout().strip()
+arrow_flight_sql = shared_module(
+  'arrow_flight_sql',
+  'src/afs.cc',
+  dependencies: [arrow_flight_sql, postgresql],
+  name_prefix: '',
+  install: true,
+  install_dir: install_dir,
+)
+
+install_data(
+  'LICENSE.txt',
+  'NOTICE.txt',
+  # 'README.md',
+  install_dir: project_doc_dir
+)
+
+if get_option('benchmark')
+  subdir('benchmark/integer')
+endif
diff --git a/benchmark/integer/CMakeLists.txt b/meson_options.txt
similarity index 77%
rename from benchmark/integer/CMakeLists.txt
rename to meson_options.txt
index 8b1c29d..fd63af1 100644
--- a/benchmark/integer/CMakeLists.txt
+++ b/meson_options.txt
@@ -15,5 +15,12 @@
 # specific language governing permissions and limitations
 # under the License.
 
-add_executable(select select.c)
-target_link_libraries(select libpq)
+option('benchmark',
+       type: 'boolean',
+       value: false,
+       description: 'Build benchmark programs')
+
+option('postgresql_dir',
+       type: 'string',
+       value: '',
+       description: 'PostgreSQL binary directory')
diff --git a/src/afs.cc b/src/afs.cc
index f977f52..bfb6776 100644
--- a/src/afs.cc
+++ b/src/afs.cc
@@ -1201,7 +1201,7 @@ class Executor : public WorkerProcessor {
                                case Action::UpdatePreparedStatement:
                                        update_prepared_statement();
                                        break;
-                               deafult:
+                               default:
                                        Processor::signaled();
                                        break;
                        }
@@ -1516,7 +1516,7 @@ class Executor : public WorkerProcessor {
                          tag_,
                          iTuple,
                          SPI_processed);
-                       for (uint64_t iAttribute = 0; iAttribute < 
SPI_tuptable->tupdesc->natts;
+                       for (int iAttribute = 0; iAttribute < 
SPI_tuptable->tupdesc->natts;
                             ++iAttribute)
                        {
                                P("%s: %s: write: data: record batch: %d/%d: 
%d/%d",
@@ -1784,7 +1784,7 @@ SharedRingBufferOutputStream::Write(const void* data, 
int64_t nBytes)
        }
        if (ARROW_PREDICT_TRUE(nBytes > 0))
        {
-               auto buffer = 
std::move(processor_->create_shared_ring_buffer(session_));
+               auto buffer = processor_->create_shared_ring_buffer(session_);
                size_t rest = static_cast<size_t>(nBytes);
                while (true)
                {
@@ -1886,11 +1886,10 @@ class Proxy : public WorkerProcessor {
                        kill(session->executorPID, SIGUSR1);
                }
                {
-                       auto buffer = 
std::move(create_shared_ring_buffer(session));
+                       auto buffer = create_shared_ring_buffer(session);
                        std::unique_lock<std::mutex> lock(mutex_);
                        conditionVariable_.wait(lock, [&] {
                                P("%s: %s: %s: wait", Tag, tag_, tag);
-                               pid_t pid = 0;
                                return DsaPointerIsValid(session->errorMessage) 
|| buffer.size() > 0;
                        });
                }
@@ -1901,12 +1900,14 @@ class Proxy : public WorkerProcessor {
                P("%s: %s: %s: open", Tag, tag_, tag);
                auto schema = read_schema(session, tag);
                P("%s: %s: %s: schema", Tag, tag_, tag);
-               return std::move(schema);
+               return schema;
        }
 
        arrow::Result<int64_t> update(uint64_t sessionID, const std::string& 
query)
        {
+#ifdef AFS_DEBUG
                const char* tag = "update";
+#endif
                auto session = find_session(sessionID);
                SessionReleaser sessionReleaser(sessions_, session);
                lock_acquire();
@@ -1947,7 +1948,9 @@ class Proxy : public WorkerProcessor {
        arrow::Result<arrow::flight::sql::ActionCreatePreparedStatementResult> 
prepare(
                uint64_t sessionID, const std::string& query)
        {
+#ifdef AFS_DEBUG
                const char* tag = "prepare";
+#endif
                auto session = find_session(sessionID);
                SessionReleaser sessionReleaser(sessions_, session);
                lock_acquire();
@@ -1980,12 +1983,14 @@ class Proxy : public WorkerProcessor {
                        std::move(handle),
                };
                P("%s: %s: %s: done", Tag, tag_, tag);
-               return std::move(result);
+               return result;
        }
 
        arrow::Status close_prepared_statement(uint64_t sessionID, const 
std::string& handle)
        {
+#ifdef AFS_DEBUG
                const char* tag = "close prepared statement";
+#endif
                auto session = find_session(sessionID);
                SessionReleaser sessionReleaser(sessions_, session);
                lock_acquire();
@@ -2018,7 +2023,9 @@ class Proxy : public WorkerProcessor {
                const std::string& handle,
                arrow::flight::FlightMessageReader* reader)
        {
+#ifdef AFS_DEBUG
                const char* tag = "update prepared statement";
+#endif
                auto session = find_session(sessionID);
                SessionReleaser sessionReleaser(sessions_, session);
                lock_acquire();
@@ -2155,7 +2162,7 @@ SharedRingBufferInputStream::Read(int64_t nBytes, void* 
out)
                return arrow::Status::IOError(std::string(Tag) + ": " + 
processor_->tag() +
                                              ": SharedRingBufferInputStream is 
closed");
        }
-       auto buffer = 
std::move(processor_->create_shared_ring_buffer(session_));
+       auto buffer = processor_->create_shared_ring_buffer(session_);
        size_t rest = static_cast<size_t>(nBytes);
        while (true)
        {

Reply via email to