Skip to content

Commit

Permalink
Merge pull request #1036 from pbalcer/mako-map-file
Browse files Browse the repository at this point in the history
automatically generate linker version script for adapter libraries
  • Loading branch information
pbalcer authored Nov 6, 2023
2 parents 7f56cec + ff7a4d8 commit a62423d
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 6 deletions.
21 changes: 21 additions & 0 deletions scripts/generate_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,25 @@ def _mako_info_hpp(path, namespace, tags, version, specs, meta):
specs=specs,
meta=meta)

"""
Entry-point:
generates linker version scripts
"""
def _mako_linker_scripts(path, ext, namespace, tags, version, specs, meta):
name = "adapter"
filename = f"{name}.{ext}.in"
fin = os.path.join(templates_dir, f"{filename}.mako")
fout = os.path.join(path, filename)
print("Generating %s..." % fout)
return util.makoWrite(
fin, fout,
name=name,
ver=version,
namespace=namespace,
tags=tags,
specs=specs,
meta=meta)

"""
Entry-point:
generates lib code
Expand Down Expand Up @@ -349,6 +368,8 @@ def generate_adapters(path, section, namespace, tags, version, specs, meta):

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

"""
Expand Down
11 changes: 11 additions & 0 deletions scripts/templates/adapter.def.in.mako
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<%!
import re
from templates import helper as th
%><%
n=namespace
%>\
LIBRARY @TARGET_LIBNAME@
EXPORTS
%for tbl in th.get_pfntables(specs, meta, n, tags):
${tbl['export']['name']}
%endfor
14 changes: 14 additions & 0 deletions scripts/templates/adapter.map.in.mako
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<%!
import re
from templates import helper as th
%><%
n=namespace
%>\
@TARGET_LIBNAME@ {
global:
%for tbl in th.get_pfntables(specs, meta, n, tags):
${tbl['export']['name']};
%endfor
local:
*;
};
6 changes: 3 additions & 3 deletions source/adapters/adapter.def.in
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
LIBRARY @TARGET_LIBNAME@
EXPORTS
urGetGlobalProcAddrTable
urGetBindlessImagesExpProcAddrTable
urGetCommandBufferExpProcAddrTable
urGetContextProcAddrTable
urGetDeviceProcAddrTable
urGetEnqueueProcAddrTable
urGetEventProcAddrTable
urGetGlobalProcAddrTable
urGetKernelProcAddrTable
urGetMemProcAddrTable
urGetPhysicalMemProcAddrTable
urGetPlatformProcAddrTable
urGetProgramProcAddrTable
urGetQueueProcAddrTable
urGetSamplerProcAddrTable
urGetUSMProcAddrTable
urGetUSMExpProcAddrTable
urGetUsmP2PExpProcAddrTable
urGetUSMProcAddrTable
urGetVirtualMemProcAddrTable
urGetDeviceProcAddrTable
6 changes: 3 additions & 3 deletions source/adapters/adapter.map.in
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
@TARGET_LIBNAME@ {
global:
urGetGlobalProcAddrTable;
urGetBindlessImagesExpProcAddrTable;
urGetCommandBufferExpProcAddrTable;
urGetContextProcAddrTable;
urGetDeviceProcAddrTable;
urGetEnqueueProcAddrTable;
urGetEventProcAddrTable;
urGetGlobalProcAddrTable;
urGetKernelProcAddrTable;
urGetMemProcAddrTable;
urGetPhysicalMemProcAddrTable;
urGetPlatformProcAddrTable;
urGetProgramProcAddrTable;
urGetQueueProcAddrTable;
urGetSamplerProcAddrTable;
urGetUSMProcAddrTable;
urGetUSMExpProcAddrTable;
urGetUsmP2PExpProcAddrTable;
urGetUSMProcAddrTable;
urGetVirtualMemProcAddrTable;
urGetDeviceProcAddrTable;
local:
*;
};

0 comments on commit a62423d

Please sign in to comment.