Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a CustomBuildStep #65

Open
kelleyma49 opened this issue Aug 2, 2019 · 2 comments
Open

Adding a CustomBuildStep #65

kelleyma49 opened this issue Aug 2, 2019 · 2 comments

Comments

@kelleyma49
Copy link

I'm trying to add a custom build steps to compile my shader files, but the custom build properties are empty.

I derive from Project.Configuration.CustomFileBuildStep and fill in the properties of the class:

public class ShaderCompileBuildStep : Project.Configuration.CustomFileBuildStep
 {
     ShaderCompileBuildStep(string sourceFileName)
      {
          // fill in KeyInput, Executable, etc.
      }

I add the extension to the project's supported extensions:

SourceFilesExtensions.Add(".fx");

I then override Project.ExcludeOutputFiles():

protected override void ExcludeOutputFiles()
{
    base.ExcludeOutputFiles();
    GenerateShaderCustomBuildSteps();
}

In GenerateShaderCustomBuildSteps(), I add the custom build steps to the project configuration:

 private void GenerateShaderCustomBuildSteps()
 {
     foreach (var f in ResolvedSourceFiles.Where(f => System.IO.Path.GetExtension(f).ToLower() == ".fx"))
    {
        foreach (Project.Configuration conf in Configurations)
        {
            conf.CustomFileBuildSteps.Add(new ShaderCompileBuildStep(f));
         }
    }
}

In Visual Studio, my .fx files have the proper "Item Type" of "Custom Build Tool", but all of the properties in "Custom Build Tool" are empty.

What am I doing wrong?

@sammyfreg
Copy link

I managed to add support for hlsl files and included a link to it, hoping it can help other help people.
https://github.com/sammyfreg/netImgui/blob/master/Build/netImgui.sharpmake.cs

I have tweaked mine to generate a c header file with the compiled shader, but can easily be adapted to other needs, by looking up the fxc commandline compile options.

@Linkeragon59
Copy link

@sammyfreg That's a really useful example, thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@kelleyma49 @sammyfreg @Linkeragon59 and others