forked from mesonbuild/meson
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add metadata support in shared library version
Some projects use metadata when versioning, such as the OBS build system. When trying to pass a version from such projects to the meson build script and use it as a dynamic library version, an error is thrown that the version should look like X.Y.Z. However, Semantic Versioning 2.0 assumes the use of metadata in the version, see: https://semver.org/#spec-item-10 This commit adds support for metadata in dynamic library versions. Fixes an issue: mesonbuild#10565
- Loading branch information
Showing
17 changed files
with
146 additions
and
3 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
docs/markdown/snippets/metadata-in-shared-library-version.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Metadata support in shared library version | ||
|
||
The shared library version now may contain build metadata specified | ||
by adding `+` and a series of dot-separated identifiers after the | ||
version string. | ||
|
||
For example: | ||
```meson | ||
lib = shared_library('example', 'main.c', version : '1.1.0+master.g21a338e') | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#if defined _WIN32 || defined __CYGWIN__ | ||
#define DLL_PUBLIC __declspec(dllexport) | ||
#else | ||
#if defined __GNUC__ | ||
#define DLL_PUBLIC __attribute__ ((visibility("default"))) | ||
#else | ||
#pragma message ("Compiler does not support symbol visibility.") | ||
#define DLL_PUBLIC | ||
#endif | ||
#endif | ||
|
||
int DLL_PUBLIC libfunc(void) { | ||
return 3; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
int libfunc(void); | ||
|
||
int main() { | ||
if (libfunc() != 3) | ||
return 1; | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
project('shared version meta', 'c') | ||
|
||
lib = shared_library('mylib', 'libfile.c', version: '1.0.0+master.b88bec0') | ||
exe = executable('prog', 'main.c', link_with: lib) | ||
|
||
test('test', exe) |
14 changes: 14 additions & 0 deletions
14
test cases/failing/128 shared version meta no plus/libfile.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#if defined _WIN32 || defined __CYGWIN__ | ||
#define DLL_PUBLIC __declspec(dllexport) | ||
#else | ||
#if defined __GNUC__ | ||
#define DLL_PUBLIC __attribute__ ((visibility("default"))) | ||
#else | ||
#pragma message ("Compiler does not support symbol visibility.") | ||
#define DLL_PUBLIC | ||
#endif | ||
#endif | ||
|
||
int DLL_PUBLIC libfunc(void) { | ||
return 3; | ||
} |
3 changes: 3 additions & 0 deletions
3
test cases/failing/128 shared version meta no plus/meson.build
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
project('shared version meta no plus', 'c') | ||
|
||
lib = shared_library('mylib', 'libfile.c', version: '1.0.0master.b88bec0') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"stdout": [ | ||
{ | ||
"line": "test cases/failing/128 shared version meta no plus/meson.build:3:0: ERROR: Invalid Shared library version \"1.0.0master.b88bec0\". Must be of the form X[.Y[.Z]][+META] where X, Y, Z are numbers" | ||
} | ||
] | ||
} |
14 changes: 14 additions & 0 deletions
14
test cases/failing/129 shared version meta only plus/libfile.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#if defined _WIN32 || defined __CYGWIN__ | ||
#define DLL_PUBLIC __declspec(dllexport) | ||
#else | ||
#if defined __GNUC__ | ||
#define DLL_PUBLIC __attribute__ ((visibility("default"))) | ||
#else | ||
#pragma message ("Compiler does not support symbol visibility.") | ||
#define DLL_PUBLIC | ||
#endif | ||
#endif | ||
|
||
int DLL_PUBLIC libfunc(void) { | ||
return 3; | ||
} |
3 changes: 3 additions & 0 deletions
3
test cases/failing/129 shared version meta only plus/meson.build
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
project('shared version meta no plus', 'c') | ||
|
||
lib = shared_library('mylib', 'libfile.c', version: '1.0.0+') |
7 changes: 7 additions & 0 deletions
7
test cases/failing/129 shared version meta only plus/test.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"stdout": [ | ||
{ | ||
"line": "test cases/failing/129 shared version meta only plus/meson.build:3:0: ERROR: Invalid Shared library version \"1.0.0+\". Must be of the form X[.Y[.Z]][+META] where X, Y, Z are numbers" | ||
} | ||
] | ||
} |
14 changes: 14 additions & 0 deletions
14
test cases/failing/130 shared version meta unexpected characters/libfile.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#if defined _WIN32 || defined __CYGWIN__ | ||
#define DLL_PUBLIC __declspec(dllexport) | ||
#else | ||
#if defined __GNUC__ | ||
#define DLL_PUBLIC __attribute__ ((visibility("default"))) | ||
#else | ||
#pragma message ("Compiler does not support symbol visibility.") | ||
#define DLL_PUBLIC | ||
#endif | ||
#endif | ||
|
||
int DLL_PUBLIC libfunc(void) { | ||
return 3; | ||
} |
3 changes: 3 additions & 0 deletions
3
test cases/failing/130 shared version meta unexpected characters/meson.build
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
project('shared version meta unexpected characters', 'c') | ||
|
||
lib = shared_library('mylib', 'libfile.c', version: '1.0.0+master%b88bec0') |
7 changes: 7 additions & 0 deletions
7
test cases/failing/130 shared version meta unexpected characters/test.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"stdout": [ | ||
{ | ||
"line": "test cases/failing/130 shared version meta unexpected characters/meson.build:3:0: ERROR: Invalid Shared library version \"1.0.0+master%b88bec0\". Must be of the form X[.Y[.Z]][+META] where X, Y, Z are numbers" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters