bx
bx copied to clipboard
Building/linking bx source files without relying on bx's build scripts
I was trying to find out if bx can be easily built by dropping the .cpp/.h file (or amalgated.cpp) into any MSVC project, and it looks like it would be possible with little changes.
How do you feel about making those changes? Would you want to support this way of building or do you think this is going to be a hassle-dead-end?
Changes I made:
- os.cpp calls _GetProcessMemoryInfo() which requires linking
psapi
.
#ifdef _MSC_VER
#pragma comment(lib, "psapi")
#endif
- To remove CRT warnings, threads.cpp and file.cpp can add at the top
#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS)
#define _CRT_SECURE_NO_WARNINGS
#endif
-
debug.cpp needs to
#define __STDC_FORMAT_MACROS
(see #146) -
This code in file.h gives me a warning:
private:
BX_ALIGN_DECL(16, uint8_t) m_internal[sizeof(FilePath)+sizeof(FileInfo)+16];
};
file.h(119): warning C4324: 'bx::DirectoryReader': structure was padded due to alignment specifier
Which can be fixed with a pragma in that structure.
- Stuff like redirection of
alloca.h
could be done in bx.h instead of relying on an include path (#225)
If you think this is suitable I can make a PR for those.
Thanks!
Technically I have only issue about this:
#ifdef _MSC_VER
#pragma comment(lib, "psapi")
#endif
The rest is doable to move everything from toolchain into source. Compatibility headers served different purpose before when bx was all headers. Now that it can be CRT replacement those headers could be in included directly in .cpp files and ifdef'd there.
I don't like pragma comment lib feature. And I would much more prefer, loading .dll manually, and obtaining functions from .dll. But the issue with bx is that it doesn't have init
call anywhere, so this would need to go into some static constructor so that .dlls get loaded before everything else.