Skip to content

Commit

Permalink
apacheGH-41681: [GLib] Generate separate version macros for each GLib…
Browse files Browse the repository at this point in the history
… library (apache#41721)

### Rationale for this change

This is to support later using the `*_AVAILABLE_IN_*` macros to add `dllexport/dllimport` attributes required for building these libraries with MSVC (apache#41134)

### What changes are included in this PR?

* Add a Python script that generates `DEPRECATED_IN` and `AVAILABLE_IN` macros for each GLib library
* Add missing `AVAILABLE_IN` annotations to some methods in the GLib libraries (except the main arrow-glib library as this is being done in apache#41599)

### Are these changes tested?

This doesn't include any behaviour change that can be unit tested.

### Are there any user-facing changes?

No
* GitHub Issue: apache#41681

Lead-authored-by: Adam Reeve <adreeve@gmail.com>
Co-authored-by: Sutou Kouhei <kou@cozmixng.org>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
  • Loading branch information
adamreeve and kou authored May 22, 2024
1 parent 8169d6e commit 37e5240
Show file tree
Hide file tree
Showing 49 changed files with 1,492 additions and 812 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ repos:
hooks:
- id: flake8
name: Python Format
files: ^(python|dev|integration)/
files: ^(python|dev|c_glib|integration)/
types:
- file
- python
Expand Down
2 changes: 2 additions & 0 deletions c_glib/arrow-cuda-glib/arrow-cuda-glib.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@

#include <arrow-glib/arrow-glib.h>

#include <arrow-cuda-glib/version.h>

#include <arrow-cuda-glib/cuda.h>
38 changes: 38 additions & 0 deletions c_glib/arrow-cuda-glib/cuda.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@

#include <arrow-glib/arrow-glib.h>

#include <arrow-cuda-glib/version.h>

G_BEGIN_DECLS

#define GARROW_CUDA_TYPE_DEVICE_MANAGER (garrow_cuda_device_manager_get_type())
GARROW_CUDA_AVAILABLE_IN_0_12
G_DECLARE_DERIVABLE_TYPE(GArrowCUDADeviceManager,
garrow_cuda_device_manager,
GARROW_CUDA,
Expand All @@ -35,6 +38,7 @@ struct _GArrowCUDADeviceManagerClass
};

#define GARROW_CUDA_TYPE_CONTEXT (garrow_cuda_context_get_type())
GARROW_CUDA_AVAILABLE_IN_0_12
G_DECLARE_DERIVABLE_TYPE(
GArrowCUDAContext, garrow_cuda_context, GARROW_CUDA, CONTEXT, GObject)
struct _GArrowCUDAContextClass
Expand All @@ -43,6 +47,7 @@ struct _GArrowCUDAContextClass
};

#define GARROW_CUDA_TYPE_BUFFER (garrow_cuda_buffer_get_type())
GARROW_CUDA_AVAILABLE_IN_0_12
G_DECLARE_DERIVABLE_TYPE(
GArrowCUDABuffer, garrow_cuda_buffer, GARROW_CUDA, BUFFER, GArrowBuffer)
struct _GArrowCUDABufferClass
Expand All @@ -51,6 +56,7 @@ struct _GArrowCUDABufferClass
};

#define GARROW_CUDA_TYPE_HOST_BUFFER (garrow_cuda_host_buffer_get_type())
GARROW_CUDA_AVAILABLE_IN_0_12
G_DECLARE_DERIVABLE_TYPE(GArrowCUDAHostBuffer,
garrow_cuda_host_buffer,
GARROW_CUDA,
Expand All @@ -62,6 +68,7 @@ struct _GArrowCUDAHostBufferClass
};

#define GARROW_CUDA_TYPE_IPC_MEMORY_HANDLE (garrow_cuda_ipc_memory_handle_get_type())
GARROW_CUDA_AVAILABLE_IN_0_12
G_DECLARE_DERIVABLE_TYPE(GArrowCUDAIPCMemoryHandle,
garrow_cuda_ipc_memory_handle,
GARROW_CUDA,
Expand All @@ -73,6 +80,7 @@ struct _GArrowCUDAIPCMemoryHandleClass
};

#define GARROW_CUDA_TYPE_BUFFER_INPUT_STREAM (garrow_cuda_buffer_input_stream_get_type())
GARROW_CUDA_AVAILABLE_IN_0_12
G_DECLARE_DERIVABLE_TYPE(GArrowCUDABufferInputStream,
garrow_cuda_buffer_input_stream,
GARROW_CUDA,
Expand All @@ -85,6 +93,7 @@ struct _GArrowCUDABufferInputStreamClass

#define GARROW_CUDA_TYPE_BUFFER_OUTPUT_STREAM \
(garrow_cuda_buffer_output_stream_get_type())
GARROW_CUDA_AVAILABLE_IN_0_12
G_DECLARE_DERIVABLE_TYPE(GArrowCUDABufferOutputStream,
garrow_cuda_buffer_output_stream,
GARROW_CUDA,
Expand All @@ -95,71 +104,100 @@ struct _GArrowCUDABufferOutputStreamClass
GArrowOutputStreamClass parent_class;
};

GARROW_CUDA_AVAILABLE_IN_0_12
GArrowCUDADeviceManager *
garrow_cuda_device_manager_new(GError **error);

GARROW_CUDA_AVAILABLE_IN_0_12
GArrowCUDAContext *
garrow_cuda_device_manager_get_context(GArrowCUDADeviceManager *manager,
gint gpu_number,
GError **error);

GARROW_CUDA_AVAILABLE_IN_0_12
gsize
garrow_cuda_device_manager_get_n_devices(GArrowCUDADeviceManager *manager);

GARROW_CUDA_AVAILABLE_IN_0_12
gint64
garrow_cuda_context_get_allocated_size(GArrowCUDAContext *context);

GARROW_CUDA_AVAILABLE_IN_0_12
GArrowCUDABuffer *
garrow_cuda_buffer_new(GArrowCUDAContext *context, gint64 size, GError **error);

GARROW_CUDA_AVAILABLE_IN_0_12
GArrowCUDABuffer *
garrow_cuda_buffer_new_ipc(GArrowCUDAContext *context,
GArrowCUDAIPCMemoryHandle *handle,
GError **error);

GARROW_CUDA_AVAILABLE_IN_0_12
GArrowCUDABuffer *
garrow_cuda_buffer_new_record_batch(GArrowCUDAContext *context,
GArrowRecordBatch *record_batch,
GError **error);

GARROW_CUDA_AVAILABLE_IN_0_12
GBytes *
garrow_cuda_buffer_copy_to_host(GArrowCUDABuffer *buffer,
gint64 position,
gint64 size,
GError **error);

GARROW_CUDA_AVAILABLE_IN_0_12
gboolean
garrow_cuda_buffer_copy_from_host(GArrowCUDABuffer *buffer,
const guint8 *data,
gint64 size,
GError **error);

GARROW_CUDA_AVAILABLE_IN_0_12
GArrowCUDAIPCMemoryHandle *
garrow_cuda_buffer_export(GArrowCUDABuffer *buffer, GError **error);

GARROW_CUDA_AVAILABLE_IN_0_12
GArrowCUDAContext *
garrow_cuda_buffer_get_context(GArrowCUDABuffer *buffer);

GARROW_CUDA_AVAILABLE_IN_0_12
GArrowRecordBatch *
garrow_cuda_buffer_read_record_batch(GArrowCUDABuffer *buffer,
GArrowSchema *schema,
GArrowReadOptions *options,
GError **error);

GARROW_CUDA_AVAILABLE_IN_0_12
GArrowCUDAHostBuffer *
garrow_cuda_host_buffer_new(gint gpu_number, gint64 size, GError **error);

GARROW_CUDA_AVAILABLE_IN_0_12
GArrowCUDAIPCMemoryHandle *
garrow_cuda_ipc_memory_handle_new(const guint8 *data, gsize size, GError **error);

GARROW_CUDA_AVAILABLE_IN_0_12
GArrowBuffer *
garrow_cuda_ipc_memory_handle_serialize(GArrowCUDAIPCMemoryHandle *handle,
GError **error);

GARROW_CUDA_AVAILABLE_IN_0_12
GArrowCUDABufferInputStream *
garrow_cuda_buffer_input_stream_new(GArrowCUDABuffer *buffer);

GARROW_CUDA_AVAILABLE_IN_0_12
GArrowCUDABufferOutputStream *
garrow_cuda_buffer_output_stream_new(GArrowCUDABuffer *buffer);

GARROW_CUDA_AVAILABLE_IN_0_12
gboolean
garrow_cuda_buffer_output_stream_set_buffer_size(GArrowCUDABufferOutputStream *stream,
gint64 size,
GError **error);
GARROW_CUDA_AVAILABLE_IN_0_12
gint64
garrow_cuda_buffer_output_stream_get_buffer_size(GArrowCUDABufferOutputStream *stream);

GARROW_CUDA_AVAILABLE_IN_0_12
gint64
garrow_cuda_buffer_output_stream_get_buffered_size(GArrowCUDABufferOutputStream *stream);

Expand Down
9 changes: 8 additions & 1 deletion c_glib/arrow-cuda-glib/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,17 @@ cpp_headers = files(
'cuda.hpp',
)

version_h = configure_file(
input: 'version.h.in',
output: 'version.h',
command: [python3, generate_version_header_py, '--library', 'GARROW_CUDA', '--version', version, '--input', '@INPUT@', '--output', '@OUTPUT@'],
)

c_headers += version_h

headers = c_headers + cpp_headers
install_headers(headers, subdir: 'arrow-cuda-glib')


dependencies = [
arrow_cuda,
arrow_glib,
Expand Down
157 changes: 157 additions & 0 deletions c_glib/arrow-cuda-glib/version.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
/*
* 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 <arrow-glib/version.h>

/**
* SECTION: version
* @section_id: version-macros
* @title: Version related macros
* @include: arrow-cuda-glib/arrow-cuda-glib.h
*
* Apache Arrow CUDA GLib provides macros that can be used by C pre-processor.
* They are useful to check version related things at compile time.
*/

/**
* GARROW_CUDA_VERSION_MAJOR:
*
* The major version.
*
* Since: 17.0.0
*/
#define GARROW_CUDA_VERSION_MAJOR (@VERSION_MAJOR@)

/**
* GARROW_CUDA_VERSION_MINOR:
*
* The minor version.
*
* Since: 17.0.0
*/
#define GARROW_CUDA_VERSION_MINOR (@VERSION_MINOR@)

/**
* GARROW_CUDA_VERSION_MICRO:
*
* The micro version.
*
* Since: 17.0.0
*/
#define GARROW_CUDA_VERSION_MICRO (@VERSION_MICRO@)

/**
* GARROW_CUDA_VERSION_TAG:
*
* The version tag. Normally, it's an empty string. It's "SNAPSHOT"
* for snapshot version.
*
* Since: 17.0.0
*/
#define GARROW_CUDA_VERSION_TAG "@VERSION_TAG@"

/**
* GARROW_CUDA_VERSION_CHECK:
* @major: A major version to check for.
* @minor: A minor version to check for.
* @micro: A micro version to check for.
*
* You can use this macro in C pre-processor.
*
* Returns: %TRUE if the compile time Apache Arrow GLib version is the
* same as or newer than the passed version, %FALSE otherwise.
*
* Since: 17.0.0
*/
#define GARROW_CUDA_VERSION_CHECK(major, minor, micro) \
(GARROW_CUDA_VERSION_MAJOR > (major) || \
(GARROW_CUDA_VERSION_MAJOR == (major) && \
GARROW_CUDA_VERSION_MINOR > (minor)) || \
(GARROW_CUDA_VERSION_MAJOR == (major) && \
GARROW_CUDA_VERSION_MINOR == (minor) && \
GARROW_CUDA_VERSION_MICRO >= (micro)))

/**
* GARROW_CUDA_DISABLE_DEPRECATION_WARNINGS:
*
* If this macro is defined, no deprecated warnings are produced.
*
* You must define this macro before including the
* arrow-glib/arrow-glib.h header.
*
* Since: 17.0.0
*/

#ifdef GARROW_CUDA_DISABLE_DEPRECATION_WARNINGS
# define GARROW_CUDA_DEPRECATED
# define GARROW_CUDA_DEPRECATED_FOR(function)
# define GARROW_CUDA_UNAVAILABLE(major, minor)
#else
# define GARROW_CUDA_DEPRECATED G_DEPRECATED
# define GARROW_CUDA_DEPRECATED_FOR(function) G_DEPRECATED_FOR(function)
# define GARROW_CUDA_UNAVAILABLE(major, minor) G_UNAVAILABLE(major, minor)
#endif

@ENCODED_VERSIONS@

/**
* GARROW_CUDA_VERSION_MIN_REQUIRED:
*
* You can use this macro for compile time API version check.
*
* This macro value must be one of the predefined version macros such
* as %GARROW_CUDA_VERSION_0_10.
*
* If you use any functions that is defined by newer version than
* %GARROW_CUDA_VERSION_MIN_REQUIRED, deprecated warnings are produced at
* compile time.
*
* You must define this macro before including the
* arrow-cuda-glib/arrow-cuda-glib.h header.
*
* Since: 17.0.0
*/
#ifndef GARROW_CUDA_VERSION_MIN_REQUIRED
# define GARROW_CUDA_VERSION_MIN_REQUIRED GARROW_VERSION_MIN_REQUIRED
#endif

/**
* GARROW_CUDA_VERSION_MAX_ALLOWED:
*
* You can use this macro for compile time API version check.
*
* This macro value must be one of the predefined version macros such
* as %GARROW_CUDA_VERSION_0_10.
*
* If you use any functions that is defined by newer version than
* %GARROW_CUDA_VERSION_MAX_ALLOWED, deprecated warnings are produced at
* compile time.
*
* You must define this macro before including the
* arrow-cuda-glib/arrow-cuda-glib.h header.
*
* Since: 17.0.0
*/
#ifndef GARROW_CUDA_VERSION_MAX_ALLOWED
# define GARROW_CUDA_VERSION_MAX_ALLOWED GARROW_VERSION_MAX_ALLOWED
#endif

@AVAILABILITY_MACROS@
2 changes: 2 additions & 0 deletions c_glib/arrow-dataset-glib/arrow-dataset-glib.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

#include <arrow-glib/arrow-glib.h>

#include <arrow-dataset-glib/version.h>

#include <arrow-dataset-glib/dataset-factory.h>
#include <arrow-dataset-glib/dataset.h>
#include <arrow-dataset-glib/enums.h>
Expand Down
3 changes: 3 additions & 0 deletions c_glib/arrow-dataset-glib/dataset-definition.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@

#include <arrow-glib/arrow-glib.h>

#include <arrow-dataset-glib/version.h>

G_BEGIN_DECLS

#define GADATASET_TYPE_DATASET (gadataset_dataset_get_type())
GADATASET_AVAILABLE_IN_5_0
G_DECLARE_DERIVABLE_TYPE(GADatasetDataset, gadataset_dataset, GADATASET, DATASET, GObject)
struct _GADatasetDatasetClass
{
Expand Down
Loading

0 comments on commit 37e5240

Please sign in to comment.