Remove hardcoded version numbers from vulkan layer json, set in build

* In CMake this is easy as we're already passing it through sed, but
  in msbuild it's a little more complex as we need to write a little
  in-line C# code to read out the version number and replace the
* We also update the JSON generation for layer registration on linux.
This commit is contained in:
baldurk
2017-04-28 16:48:44 +01:00
parent 8580b7b2c7
commit 58050e89ef
4 changed files with 63 additions and 10 deletions
+1 -1
View File
@@ -65,7 +65,7 @@ elseif(UNIX)
set(json_in ${CMAKE_CURRENT_SOURCE_DIR}/renderdoc.json)
set(json_out ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/renderdoc_capture.json)
add_custom_command(OUTPUT ${json_out}
COMMAND sed '{s%...renderdoc.dll%${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/librenderdoc.so%}' < ${json_in} > ${json_out}
COMMAND sed '{s%\\[MAJOR\\]%${RENDERDOC_VERSION_MAJOR}%\; s%\\[MINOR\\]%${RENDERDOC_VERSION_MINOR}%\; s%...renderdoc.dll%${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/librenderdoc.so%}' < ${json_in} > ${json_out}
DEPENDS ${json_in})
add_custom_target(generate-json ALL DEPENDS ${json_out})
+2 -2
View File
@@ -5,7 +5,7 @@
"type": "GLOBAL",
"library_path": ".\\renderdoc.dll",
"api_version": "1.0.0",
"implementation_version": "34",
"implementation_version": "[MINOR]",
"description": "Debugging capture layer for RenderDoc",
"functions": {
"vkGetInstanceProcAddr": "VK_LAYER_RENDERDOC_CaptureGetInstanceProcAddr",
@@ -28,7 +28,7 @@
"ENABLE_VULKAN_RENDERDOC_CAPTURE": "1"
},
"disable_environment": {
"DISABLE_VULKAN_RENDERDOC_CAPTURE_0_34": "1"
"DISABLE_VULKAN_RENDERDOC_CAPTURE_[MAJOR]_[MINOR]": "1"
}
}
}
@@ -162,12 +162,40 @@
<ItemGroup>
<None Include="renderdoc.json" />
</ItemGroup>
<ItemGroup>
<Content Include="renderdoc.json">
<Link>renderdoc.json</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Target Name="_jsonProcess" BeforeTargets="PrepareForBuild">
<!-- Read the version.h -->
<PropertyGroup>
<VersionFile>$([System.IO.File]::ReadAllText('$(SolutionDir)renderdoc/api/replay/version.h').Trim())</VersionFile>
</PropertyGroup>
<!-- Extract the major and minor lines -->
<PropertyGroup>
<!-- Find the start of the line -->
<MajorVersionStart>$(VersionFile.IndexOf('#define RENDERDOC_VERSION_MAJOR'))</MajorVersionStart>
<!-- Take the rest of the file and split it by newline to get an array of lines,
Take the first line and split it by space
Take the third item. This is #define MAJOR foo
0 1 2
-->
<MajorVersion>$(VersionFile.Substring($(MajorVersionStart)).Split('
')[0].Split(' ')[2])</MajorVersion>
<MinorVersionStart>$(VersionFile.IndexOf('#define RENDERDOC_VERSION_MINOR'))</MinorVersionStart>
<MinorVersion>$(VersionFile.Substring($(MinorVersionStart)).Split('
')[0].Split(' ')[2])</MinorVersion>
</PropertyGroup>
<Message Text="Processing layer JSON file for RenderDoc $(MajorVersion).$(MinorVersion)" Importance="High"/>
<!-- Read the template json, replace the major/minor versions -->
<PropertyGroup>
<JSONContents>$([System.IO.File]::ReadAllText('$(ProjectDir)renderdoc.json').Replace('[MAJOR]', '$(MajorVersion)').Replace('[MINOR]', '$(MinorVersion)'))</JSONContents>
</PropertyGroup>
<!-- Write it out to the output directory -->
<WriteLinesToFile File="$(OutDir)renderdoc.json" Lines="$(JSONContents)" Overwrite="true"/>
</Target>
<ItemGroup>
<ProjectReference Include="..\shaders\spirv\renderdoc_spirv.vcxproj">
<Project>{0aae0ad1-371b-4a36-9ed1-80e10e960605}</Project>
+26 -1
View File
@@ -23,6 +23,7 @@
******************************************************************************/
#include "api/replay/renderdoc_replay.h"
#include "api/replay/version.h"
#include "serialise/string_utils.h"
#include <errno.h>
@@ -157,7 +158,31 @@ static std::string GenerateJSON(const std::string &sopath)
size_t idx = json.find(dllPathString);
return json.substr(0, idx) + sopath + json.substr(idx + sizeof(dllPathString) - 1);
json = json.substr(0, idx) + sopath + json.substr(idx + sizeof(dllPathString) - 1);
const char majorString[] = "[MAJOR]";
idx = json.find(majorString);
while(idx != string::npos)
{
json = json.substr(0, idx) + STRINGIZE(RENDERDOC_VERSION_MAJOR) +
json.substr(idx + sizeof(majorString) - 1);
idx = json.find(majorString);
}
const char minorString[] = "[MINOR]";
idx = json.find(minorString);
while(idx != string::npos)
{
json = json.substr(0, idx) + STRINGIZE(RENDERDOC_VERSION_MINOR) +
json.substr(idx + sizeof(minorString) - 1);
idx = json.find(minorString);
}
return json;
}
static bool FileExists(const std::string &path)