Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[c++] Define and expose PULSAR_VERSION macro #12769

Merged
merged 2 commits into from
Nov 26, 2021

Conversation

massakam
Copy link
Contributor

@massakam massakam commented Nov 12, 2021

Motivation

Pulsar Node.js client library is a wrapping of the C++ client library. If we add a new feature to the Node.js client that uses a recently implemented C function, users will be forced to upgrade the C++ client, even if they don't use that feature. Otherwise, a compile error will occur when installing the Node.js client.

Modifications

To solve the above issue, define and expose a macro named PULSAR_VERSION in the C++ client. The value of PULSAR_VERSION is an integer determined by the following calculation:

PULSAR_VERSION = <MAJOR_VERSION> * 10^6 + <MINOR_VERSION> * 10^3 + <PATCH_VERSION>

For example, if the version of Pulsar is 2.8.1, PULSAR_VERSION is 2008001.

On the Node.js client side, we will no longer have to force users to upgrade the C++ client by using this macro as follows:

#include <pulsar/c/version.h>

#if PULSAR_VERSION >= 2008001
/* Some processing using a C function implemented in Pulsar 2.8.1 or later */
#else
/* Alternative processing */
#endif

Verifying this change

  • Make sure that the change passes the CI checks.

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): (no)
  • The public API: (no)
  • The schema: (no)
  • The default values of configurations: (no)
  • The wire protocol: (no)
  • The rest endpoints: (no)
  • The admin cli options: (no)
  • Anything that affects deployment: (no)

Documentation

  • no-need-doc

@massakam massakam added component/c++ doc-not-needed Your PR changes do not impact docs labels Nov 12, 2021
@massakam massakam added this to the 2.10.0 milestone Nov 12, 2021
@massakam massakam self-assigned this Nov 12, 2021
@@ -20,7 +20,7 @@
file(GLOB PULSAR_SOURCES *.cc *.h lz4/*.cc lz4/*.h checksum/*.cc checksum/*.h stats/*.cc stats/*.h c/*.cc c/*.h auth/*.cc auth/*.h auth/athenz/*.cc auth/athenz/*.h)

execute_process(COMMAND python ${CMAKE_SOURCE_DIR}/../src/get-project-version.py OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE PV)
set (CMAKE_CXX_FLAGS " ${CMAKE_CXX_FLAGS} -D_PULSAR_VERSION_=\\\"${PV}\\\"")
set (CMAKE_CXX_FLAGS " ${CMAKE_CXX_FLAGS} -D_PULSAR_VERSION_INTERNAL_=\\\"${PV}\\\"")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I renamed this existing macro to avoid confusion with the macro added this time.

#define LIB_VERSION_INTERNAL_H_

#ifndef _PULSAR_VERSION_INTERNAL_
#define _PULSAR_VERSION_INTERNAL_ "1.17"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1.17 is a concrete (and very old) version. Should we instead use something link unknown or undefined instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@merlimat Changed the default value to unknown.

@nkurihar nkurihar merged commit 2dcf7e9 into apache:master Nov 26, 2021
@massakam massakam deleted the cpp-pulsar-version-macro branch November 26, 2021 02:43
eolivelli pushed a commit to eolivelli/pulsar that referenced this pull request Nov 29, 2021
* Define and expose PULSAR_VERSION macro

* Change default value of _PULSAR_VERSION_INTERNAL_ to unknown
@BewareMyPower
Copy link
Contributor

Add release/2.8.2 label because this PR is depended by #13112, which is labeled as release/2.8.2.

Ping @315157973 since you're the release manager of Pulsar 2.8.2.

BewareMyPower pushed a commit that referenced this pull request Dec 10, 2021
* Define and expose PULSAR_VERSION macro

* Change default value of _PULSAR_VERSION_INTERNAL_ to unknown
@315157973 315157973 added the cherry-picked/branch-2.8 Archived: 2.8 is end of life label Dec 10, 2021
BewareMyPower added a commit that referenced this pull request Dec 15, 2021
…3324)

### Motivation

When I build C++ tests on my local env, the following error happened.

```
tests/VersionTest.cc:19:10: fatal error: 'pulsar/Version.h' file not found
#include <pulsar/Version.h>
```

It's because I specified another directory as CMake directory.

```bash
mkdir _builds && cd _builds && cmake ..
```

After #12769, the `Version.h` is generated under `${CMAKE_BINARY_DIR}/include/pulsar` directory but it's not included in `CMakeLists.txt`. CI works well because it's built in the default CMake directory so that `CMAKE_BINARY_DIR` is the same with `CMAKE_SOURCE_DIR`, which is included.

### Modifications

Add the `${CMAKE_BINARY_DIR}/include` to `included_directories`.
fxbing pushed a commit to fxbing/pulsar that referenced this pull request Dec 19, 2021
* Define and expose PULSAR_VERSION macro

* Change default value of _PULSAR_VERSION_INTERNAL_ to unknown
fxbing pushed a commit to fxbing/pulsar that referenced this pull request Dec 19, 2021
…ache#13324)

### Motivation

When I build C++ tests on my local env, the following error happened.

```
tests/VersionTest.cc:19:10: fatal error: 'pulsar/Version.h' file not found
#include <pulsar/Version.h>
```

It's because I specified another directory as CMake directory.

```bash
mkdir _builds && cd _builds && cmake ..
```

After apache#12769, the `Version.h` is generated under `${CMAKE_BINARY_DIR}/include/pulsar` directory but it's not included in `CMakeLists.txt`. CI works well because it's built in the default CMake directory so that `CMAKE_BINARY_DIR` is the same with `CMAKE_SOURCE_DIR`, which is included.

### Modifications

Add the `${CMAKE_BINARY_DIR}/include` to `included_directories`.
codelipenghui pushed a commit that referenced this pull request Dec 21, 2021
* Define and expose PULSAR_VERSION macro

* Change default value of _PULSAR_VERSION_INTERNAL_ to unknown

(cherry picked from commit 2dcf7e9)
@codelipenghui codelipenghui added the cherry-picked/branch-2.9 Archived: 2.9 is end of life label Dec 21, 2021
codelipenghui pushed a commit that referenced this pull request Dec 21, 2021
…3324)

### Motivation

When I build C++ tests on my local env, the following error happened.

```
tests/VersionTest.cc:19:10: fatal error: 'pulsar/Version.h' file not found
#include <pulsar/Version.h>
```

It's because I specified another directory as CMake directory.

```bash
mkdir _builds && cd _builds && cmake ..
```

After #12769, the `Version.h` is generated under `${CMAKE_BINARY_DIR}/include/pulsar` directory but it's not included in `CMakeLists.txt`. CI works well because it's built in the default CMake directory so that `CMAKE_BINARY_DIR` is the same with `CMAKE_SOURCE_DIR`, which is included.

### Modifications

Add the `${CMAKE_BINARY_DIR}/include` to `included_directories`.

(cherry picked from commit ca37e67)
zymap pushed a commit that referenced this pull request Dec 23, 2021
…3324)

### Motivation

When I build C++ tests on my local env, the following error happened.

```
tests/VersionTest.cc:19:10: fatal error: 'pulsar/Version.h' file not found
#include <pulsar/Version.h>
```

It's because I specified another directory as CMake directory.

```bash
mkdir _builds && cd _builds && cmake ..
```

After #12769, the `Version.h` is generated under `${CMAKE_BINARY_DIR}/include/pulsar` directory but it's not included in `CMakeLists.txt`. CI works well because it's built in the default CMake directory so that `CMAKE_BINARY_DIR` is the same with `CMAKE_SOURCE_DIR`, which is included.

### Modifications

Add the `${CMAKE_BINARY_DIR}/include` to `included_directories`.

(cherry picked from commit ca37e67)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-picked/branch-2.8 Archived: 2.8 is end of life cherry-picked/branch-2.9 Archived: 2.9 is end of life doc-not-needed Your PR changes do not impact docs release/2.8.2 release/2.9.2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants