adamreeve commented on code in PR #41721: URL: https://github.com/apache/arrow/pull/41721#discussion_r1607259582
########## c_glib/tools/gen-version-header.py: ########## @@ -0,0 +1,150 @@ +#!/usr/bin/env python3 + +# 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. + + +import argparse +from io import TextIOBase +from pathlib import Path + + +def main(): + parser = argparse.ArgumentParser( + description="Generate C header with version macros") + parser.add_argument( + "--library", + required=True, + help="The library name to use in macro prefixes") + parser.add_argument( + "--version", + required=True, + help="The library version number") + parser.add_argument( + "--input", + type=Path, + required=True, + help="Path to the input template file") + parser.add_argument( + "--output", + type=Path, + required=True, + help="Path to the output file to generate") + parser.add_argument( + "--version-library", Review Comment: For gandiva-glib and arrow-glib this is the same as `--library`, but for the other libraries this is set to `GARROW`, as these make use of `GARROW_VERSION_MIN_REQUIRED`, `GARROW_VERSION_MAX_ALLOWED`, and `GARROW_DISABLE_DEPRECATION_WARNINGS`. Eg. the generated headers have macros like: ```c #if GARROW_VERSION_MIN_REQUIRED >= GARROW_VERSION_16_0 # define GAFLIGHT_DEPRECATED_IN_16_0 GAFLIGHT_DEPRECATED # define GAFLIGHT_DEPRECATED_IN_16_0_FOR(function) GAFLIGHT_DEPRECATED_FOR(function) #else # define GAFLIGHT_DEPRECATED_IN_16_0 # define GAFLIGHT_DEPRECATED_IN_16_0_FOR(function) #endif #if GARROW_VERSION_MAX_ALLOWED < GARROW_VERSION_16_0 # define GAFLIGHT_AVAILABLE_IN_16_0 GAFLIGHT_UNAVAILABLE(16, 0) #else # define GAFLIGHT_AVAILABLE_IN_16_0 #endif ``` This is also why they have `#include <arrow-glib/version.h>`. I didn't want to break compatibility with the existing `GARROW_VERSION_MIN_REQUIRED`, `GARROW_VERSION_MAX_ALLOWED`, and `GARROW_DISABLE_DEPRECATION_WARNINGS` macros. Although I'm not sure how important that is, none of the libraries other than arrow-glib contain deprecated methods. So it might be simpler to change this so that each library has its own `_VERSION_MAJOR` macro and `_VERSION_MIN_REQUIRED` etc? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
