Skip to content

Commit 121638e

Browse files
authored
testing: for CI only, trim PWD from the oslc -M output (#1924)
I think this stems from libclang (doing the C preprocessing step for us) giving us relative paths on all platforms but Windows, where it gives absolute paths -- with backslaches and C:\ and all. I'm going to be conservative and not switch to relative paths accross the board on Windows, but for now just restrict it to the builds we do for CI, in order to make the related tests pass for Windows on our CI (where we obviously don't want to have the reference output need to bake in absolute paths of the place they may happen to execute on the GHA runners). Signed-off-by: Larry Gritz <[email protected]>
1 parent 669bea1 commit 121638e

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/liboslcomp/oslcomp.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,14 +590,24 @@ OSLCompilerImpl::write_dependency_file(string_view filename)
590590
: OIIO::Filesystem::fopen(m_deps_filename, "w"));
591591
if (depfile) {
592592
OSL::print(depfile, "{}: {}", target, filename);
593-
for (const auto& dep : m_file_dependencies) {
593+
for (ustring dep : m_file_dependencies) {
594594
if (OIIO::Strutil::ends_with(dep, "stdosl.h")
595595
&& !m_generate_system_deps)
596596
continue; // skip system headers if so instructed
597597
if (OIIO::Strutil::starts_with(dep, "<"))
598598
continue; // skip pseudo files
599599
if (dep == filename)
600600
continue; // skip this file, since we already put it first
601+
#if defined(_WIN32) && defined(OSL_CI)
602+
// Special behavior for CI on Windows: remove the directory paths
603+
// for the dependencies, or else it won't match the reference
604+
// output.
605+
using OIIO::Strutil::replace;
606+
std::string cwd = replace(OIIO::Filesystem::current_path() + "/",
607+
"/", "\\", true);
608+
auto d = replace(dep, "\\\\", "\\", true);
609+
dep = ustring(replace(d, cwd, ""));
610+
#endif
601611
OSL::print(depfile, " \\\n {}", dep);
602612
}
603613
OSL::print(depfile, "\n");

0 commit comments

Comments
 (0)