Skip to content

Commit ff7a4d8

Browse files
committed
automatically generate linker version script for adapter libraries
1 parent be53fb3 commit ff7a4d8

File tree

5 files changed

+52
-6
lines changed

5 files changed

+52
-6
lines changed

scripts/generate_code.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,25 @@ def _mako_info_hpp(path, namespace, tags, version, specs, meta):
315315
specs=specs,
316316
meta=meta)
317317

318+
"""
319+
Entry-point:
320+
generates linker version scripts
321+
"""
322+
def _mako_linker_scripts(path, ext, namespace, tags, version, specs, meta):
323+
name = "adapter"
324+
filename = f"{name}.{ext}.in"
325+
fin = os.path.join(templates_dir, f"{filename}.mako")
326+
fout = os.path.join(path, filename)
327+
print("Generating %s..." % fout)
328+
return util.makoWrite(
329+
fin, fout,
330+
name=name,
331+
ver=version,
332+
namespace=namespace,
333+
tags=tags,
334+
specs=specs,
335+
meta=meta)
336+
318337
"""
319338
Entry-point:
320339
generates lib code
@@ -349,6 +368,8 @@ def generate_adapters(path, section, namespace, tags, version, specs, meta):
349368

350369
loc = 0
351370
loc += _mako_null_adapter_cpp(dstpath, namespace, tags, version, specs, meta)
371+
loc += _mako_linker_scripts(dstpath, "map", namespace, tags, version, specs, meta)
372+
loc += _mako_linker_scripts(dstpath, "def", namespace, tags, version, specs, meta)
352373
print("Generated %s lines of code.\n"%loc)
353374

354375
"""

scripts/templates/adapter.def.in.mako

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<%!
2+
import re
3+
from templates import helper as th
4+
%><%
5+
n=namespace
6+
%>\
7+
LIBRARY @TARGET_LIBNAME@
8+
EXPORTS
9+
%for tbl in th.get_pfntables(specs, meta, n, tags):
10+
${tbl['export']['name']}
11+
%endfor

scripts/templates/adapter.map.in.mako

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<%!
2+
import re
3+
from templates import helper as th
4+
%><%
5+
n=namespace
6+
%>\
7+
@TARGET_LIBNAME@ {
8+
global:
9+
%for tbl in th.get_pfntables(specs, meta, n, tags):
10+
${tbl['export']['name']};
11+
%endfor
12+
local:
13+
*;
14+
};

source/adapters/adapter.def.in

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
LIBRARY @TARGET_LIBNAME@
22
EXPORTS
3+
urGetGlobalProcAddrTable
34
urGetBindlessImagesExpProcAddrTable
45
urGetCommandBufferExpProcAddrTable
56
urGetContextProcAddrTable
6-
urGetDeviceProcAddrTable
77
urGetEnqueueProcAddrTable
88
urGetEventProcAddrTable
9-
urGetGlobalProcAddrTable
109
urGetKernelProcAddrTable
1110
urGetMemProcAddrTable
1211
urGetPhysicalMemProcAddrTable
1312
urGetPlatformProcAddrTable
1413
urGetProgramProcAddrTable
1514
urGetQueueProcAddrTable
1615
urGetSamplerProcAddrTable
16+
urGetUSMProcAddrTable
1717
urGetUSMExpProcAddrTable
1818
urGetUsmP2PExpProcAddrTable
19-
urGetUSMProcAddrTable
2019
urGetVirtualMemProcAddrTable
20+
urGetDeviceProcAddrTable

source/adapters/adapter.map.in

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
@TARGET_LIBNAME@ {
22
global:
3+
urGetGlobalProcAddrTable;
34
urGetBindlessImagesExpProcAddrTable;
45
urGetCommandBufferExpProcAddrTable;
56
urGetContextProcAddrTable;
6-
urGetDeviceProcAddrTable;
77
urGetEnqueueProcAddrTable;
88
urGetEventProcAddrTable;
9-
urGetGlobalProcAddrTable;
109
urGetKernelProcAddrTable;
1110
urGetMemProcAddrTable;
1211
urGetPhysicalMemProcAddrTable;
1312
urGetPlatformProcAddrTable;
1413
urGetProgramProcAddrTable;
1514
urGetQueueProcAddrTable;
1615
urGetSamplerProcAddrTable;
16+
urGetUSMProcAddrTable;
1717
urGetUSMExpProcAddrTable;
1818
urGetUsmP2PExpProcAddrTable;
19-
urGetUSMProcAddrTable;
2019
urGetVirtualMemProcAddrTable;
20+
urGetDeviceProcAddrTable;
2121
local:
2222
*;
2323
};

0 commit comments

Comments
 (0)