|
18 | 18 | resourcesFile = sys.argv[3]
|
19 | 19 | resourcesNamespace = sys.argv[4]
|
20 | 20 | guardSuffix = sys.argv[5]
|
| 21 | + isSharedLibrary = sys.argv[6] |
21 | 22 |
|
22 | 23 | file = open(resourcesFile, 'r')
|
23 | 24 | resourcePaths = file.readlines()
|
|
32 | 33 | outp.write("#include <string>\n")
|
33 | 34 | outp.write("#include <unordered_map>\n")
|
34 | 35 | outp.write("#include <utility>\n#include <nbl/core/string/StringLiteral.h>\n\n")
|
| 36 | + |
| 37 | + if isSharedLibrary: |
| 38 | + outp.write("#if defined(__NBL_BUILDING_TARGET__) // currently compiling the target, this define is passed through the commandline\n") |
| 39 | + outp.write("#if defined(_MSC_VER)\n") |
| 40 | + outp.write("#define NBL_API2 __declspec(dllexport)\n") |
| 41 | + outp.write("#elif defined(__GNUC__)\n") |
| 42 | + outp.write('#define NBL_API2 __attribute__ ((visibility ("default")))' + "\n") |
| 43 | + outp.write("#endif\n") |
| 44 | + outp.write("#else\n") |
| 45 | + outp.write("#if defined(_MSC_VER)\n") |
| 46 | + outp.write("#define NBL_API2 __declspec(dllimport)\n") |
| 47 | + outp.write("#else\n") |
| 48 | + outp.write("#define NBL_API2\n") |
| 49 | + outp.write("#endif\n") |
| 50 | + outp.write("#endif\n\n") |
| 51 | + |
35 | 52 | outp.write("namespace " + resourcesNamespace + " { \n")
|
36 | 53 | outp.write("\t\ttemplate<nbl::core::StringLiteral Path>\n")
|
37 | 54 | outp.write("\t\tconst std::pair<const uint8_t*, size_t> get_resource();\n")
|
|
41 | 58 | itemData = z.split(',')
|
42 | 59 | x = itemData[0].rstrip()
|
43 | 60 |
|
44 |
| - outp.write('\n\t\ttemplate<> const std::pair<const uint8_t*, size_t> get_resource<NBL_CORE_UNIQUE_STRING_LITERAL_TYPE("%s")>();' % x) |
| 61 | + if isSharedLibrary: |
| 62 | + outp.write('\n\t\ttemplate<> NBL_API2 const std::pair<const uint8_t*, size_t> get_resource<NBL_CORE_UNIQUE_STRING_LITERAL_TYPE("%s")>();' % x) |
| 63 | + else: |
| 64 | + outp.write('\n\t\ttemplate<> const std::pair<const uint8_t*, size_t> get_resource<NBL_CORE_UNIQUE_STRING_LITERAL_TYPE("%s")>();' % x) |
45 | 65 |
|
46 | 66 | if len(itemData) > 1:
|
47 | 67 | for i in range(1, len(itemData)):
|
48 |
| - outp.write('\n\t\ttemplate<> const std::pair<const uint8_t*, size_t> get_resource<NBL_CORE_UNIQUE_STRING_LITERAL_TYPE("%s")>();' % itemData[i].rstrip()) |
| 68 | + if isSharedLibrary: |
| 69 | + outp.write('\n\t\ttemplate<> NBL_API2 const std::pair<const uint8_t*, size_t> get_resource<NBL_CORE_UNIQUE_STRING_LITERAL_TYPE("%s")>();' % itemData[i].rstrip()) |
| 70 | + else: |
| 71 | + outp.write('\n\t\ttemplate<> const std::pair<const uint8_t*, size_t> get_resource<NBL_CORE_UNIQUE_STRING_LITERAL_TYPE("%s")>();' % itemData[i].rstrip()) |
49 | 72 |
|
50 | 73 | outp.write("\n\t}")
|
51 | 74 | outp.write("\n#endif // _" + guardSuffix + "_BUILTINRESOURCEDATA_H_")
|
|
0 commit comments