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

MSVC tool doesn't work #57

Open
Makogan opened this issue Jan 18, 2022 · 3 comments
Open

MSVC tool doesn't work #57

Makogan opened this issue Jan 18, 2022 · 3 comments

Comments

@Makogan
Copy link

Makogan commented Jan 18, 2022

I compiled the incbin.c file and made an executable if I run it with help I get:

 ./a.exe phong_lighting.glsl  -I../../Src/Engine/EmbeddedShaders/ -o ../../buildvs/data.c  -help
C:\Users\Makogan\Documents\neverengine\libraries\incbin\a.exe [-help] [-Ipath...] | <sourcefiles> | [-o output] | [-p prefix]
   -o         - output file [default is "data.c"]
   -p         - specify a prefix for symbol names (default is "g")
   -S<style>  - specify a style for symbol generation (default is "camelcase")
   -I<path>   - specify an include path for the tool to use
   -help      - this
example:
   C:\Users\Makogan\Documents\neverengine\libraries\incbin\a.exe source.c other_source.cpp -o file.c
styles (for -S):
   camelcase
   snakecase

If I try to run it normally (without the help flag) this is the data.c file that gets generated:

/* File automatically generated by incbin */
#include "incbin.h"

#ifdef __cplusplus
extern "C" {
#endif


#ifdef __cplusplus
}
#endif

No errors or warnings are thrown by the tool.

I am on windows 10

@Makogan Makogan changed the title MSVC tool doesn.t work MSVC tool doesn't work Jan 18, 2022
@graphitemaster
Copy link
Owner

You need to list the source files which use INCBIN you want preprocessed by this tool, you don't list the data files, those are read from the INCBIN macro in the source file which are found via -I. So for instance you'd have:

// source.c
INCBIN(data, "phong_lighting.glsl");

Then you'd run the tool with ./incbin.exe source.c -I../../Src/Engine/EmbeddedShaders/ -o ../../buildvs/data.c
Which would emit a data.c file containing the phong shader source code as a byte array named data, now in source.c you can use data to refer to that embedded GLSL.

If you have multiple source files which use INCBIN you'd specify them all on the command line here.

@ctalech
Copy link

ctalech commented Jan 20, 2022

Ah I see, I was confused, thank you!

@darealshinji
Copy link

I was confused too. I think the description of how to use it should be clearer. I didn't understand that source.c was suppossed to be the source file that contains the INCBIN macros.

Maybe you should add a little counter so it's easier to understand that nothing was found?

diff --git a/incbin.c b/incbin.c
index fd1e72b..ca6abe4 100644
--- a/incbin.c
+++ b/incbin.c
@@ -104,7 +104,7 @@ static const char *styled(int style, int ident) {
 }
 
 int main(int argc, char **argv) {
-    int ret = 0, i, paths, files = 0, style = kCamel;
+    int ret = 0, i, paths, files = 0, style = kCamel, written = 0;
     char outfile[FILENAME_MAX] = "data.c";
     char search_paths[SEARCH_PATHS_MAX][PATH_MAX];
     char prefix[FILENAME_MAX] = "g";
@@ -263,6 +263,7 @@ usage:
                     fprintf(out, i != size - 1 ? "0x%02X, " : "0x%02X", data[i]);
                     count++;
                 }
+                written++;
                 free(data);
                 fclose(f);
             }
@@ -282,6 +283,7 @@ end:
         fprintf(out, "#endif\n");
         fclose(out);
         printf("generated `%s'\n", outfile);
+        printf("number of files included: %d\n", written);
         return 0;
     }
 

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