Skip to content

Commit 13114ec

Browse files
committed
protobuf: do not use symlinks
1 parent 1336edb commit 13114ec

File tree

5 files changed

+75
-43
lines changed

5 files changed

+75
-43
lines changed

releases.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3231,6 +3231,7 @@
32313231
"protoc"
32323232
],
32333233
"versions": [
3234+
"25.2-3",
32343235
"25.2-2",
32353236
"25.2-1",
32363237
"3.21.12-5",

subprojects/packagefiles/protobuf/src/meson.build

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22
python = find_program('python3')
33
proto_includes_link = custom_target(
44
'proto_includes_link',
5-
input: files('symlink.py'),
65
output: 'include', # directory adjacent to protoc binary
7-
command: [python, '@INPUT@', meson.current_source_dir(), '@OUTPUT@'],
6+
command: [
7+
python,
8+
files('symlink_or_copy.py'),
9+
meson.current_source_dir(),
10+
'@OUTPUT@',
11+
],
812
)
913
proto_includes_link_dep = declare_dependency(
1014
sources: proto_includes_link,

subprojects/packagefiles/protobuf/src/symlink.py

Lines changed: 0 additions & 40 deletions
This file was deleted.
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/usr/bin/env python3
2+
3+
"""
4+
Helper-script, a replacement to unix
5+
`ln -s [source] [destination] || cp -r [source] [destination]` command
6+
should work everywhere where meson does
7+
"""
8+
9+
import argparse
10+
import os
11+
import platform
12+
import shutil
13+
import sys
14+
from pathlib import Path
15+
16+
17+
def main() -> int:
18+
"""Your script main entry point"""
19+
20+
parser = argparse.ArgumentParser()
21+
parser.add_argument("source")
22+
parser.add_argument("destination")
23+
args = parser.parse_args()
24+
25+
source = Path(args.source)
26+
destination = Path(args.destination)
27+
destination_parent = destination.absolute().parent
28+
29+
if not source.exists():
30+
print("Source not found at:", source.absolute())
31+
return -2
32+
if not destination_parent.exists():
33+
print("Destination directory not found at:", destination_parent)
34+
return -3
35+
36+
relative_target = Path(os.path.relpath(source.absolute(), destination_parent))
37+
print(f"creating symlink {destination} -> {relative_target}")
38+
if destination.is_symlink():
39+
destination.unlink()
40+
try:
41+
destination.symlink_to(relative_target, target_is_directory=source.is_dir())
42+
except OSError as exc:
43+
# 1314: A required privilege is not held by the client.
44+
# Windows raises these errors when the script doesn't have
45+
# sufficient (administrator) priviledges and Developer mode
46+
# is not enabled (which enables regular users to create
47+
# symlinks).
48+
if platform.system() == "Windows" and exc.winerror == 1314:
49+
if destination.is_dir():
50+
shutil.rmtree(destination)
51+
try:
52+
shutil.copytree(source, destination)
53+
except (FileNotFoundError, NotADirectoryError, PermissionError) as exc:
54+
print(exc, file=sys.stderr)
55+
return -4
56+
else:
57+
print(exc, file=sys.stderr)
58+
return -4
59+
except (FileNotFoundError, PermissionError) as exc:
60+
print(exc, file=sys.stderr)
61+
return -4
62+
63+
return 0
64+
65+
66+
if __name__ == "__main__":
67+
sys.exit(main())

tools/sanity_checks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
'pcreposix.def'
107107
],
108108
'protobuf': [
109-
'symlink.py',
109+
'symlink_or_copy.py',
110110
],
111111
'sdl2': [
112112
'find-dylib-name.py'

0 commit comments

Comments
 (0)