Skip to content

Commit 403881b

Browse files
authored
Resolve typemap files relative to their respective src file. (#91)
xsubpp resolves typemaps relative to the .xs source file rather than the CWD when executed.
1 parent 96c62f8 commit 403881b

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

perl/private/perl_xs.bzl

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,20 +72,24 @@ def _perl_xs_implementation(ctx):
7272

7373
gen = []
7474
cc_infos = []
75-
args_typemaps = []
76-
77-
for typemap in ctx.files.typemaps:
78-
args_typemaps += ["-typemap", typemap.short_path]
7975

8076
for src in ctx.files.srcs:
8177
c_execpath = paths.replace_extension(src.path, ".c")
8278
o_packagepath = paths.join("_objs/execroot/", c_execpath)
8379
out = ctx.actions.declare_file(o_packagepath)
8480

81+
# typemap paths are resolved relative to their src.
82+
src_dir = paths.dirname(src.path)
83+
args_typemaps_relative = []
84+
for typemap in ctx.files.typemaps:
85+
# Calculate the relative path from the src directory to the typemap path
86+
relative_typemap_path = paths.relativize(typemap.path, src_dir)
87+
args_typemaps_relative += ["-typemap", relative_typemap_path]
88+
8589
ctx.actions.run(
8690
outputs = [out],
8791
inputs = [src] + ctx.files.typemaps,
88-
arguments = args_typemaps + ["-output", out.path, src.path],
92+
arguments = args_typemaps_relative + ["-output", out.path, src.path],
8993
progress_message = "Translitterating %s to %s" % (src.short_path, out.short_path),
9094
executable = xsubpp,
9195
tools = toolchain_files,

0 commit comments

Comments
 (0)