-
Notifications
You must be signed in to change notification settings - Fork 84
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
Win32: allow generating funcs.h and help.c without posix tools #446
Conversation
@Konstantin-Glukhov I recall you didn't have a way to build a git snapshot due to missing Can you please try it out and report back if this solves the msvc makefile issue to build a git snapshot? |
Pushed a minor no-op readability improvements at |
Previously the mscv Makefile.wnm didn't have rules to generate funcs.h and help.c, meaning that it could only be used to build release tarballs (which already have these files), but not git snapshots. Now we have a new independent rule "generated" (not part of "all"), which generates them. Because typical msvc setups do't have the tools which are used elsewhere to generate these files, this commit adds buildgen.c which, when compiled, can be used instead. It's not part of "all" because when cross compiling, e.g. an arm binary on Windows 64, buildgen.exe should be native and not arm, so this allows making "generated" with a native toolchain, and then "all" using the arm toolchain.
... and removed a stray space... |
For what it's worth, I'm OK with pushing it as-is now, and addressing later any feedback which comes up, though I don't expecty many issues, if at all. |
nmake -f .\Makefile.wnm Microsoft (R) Program Maintenance Utility Version 14.37.32822.0
NMAKE : fatal error U1073: don't know how to make 'funcs.h' |
|
@Konstantin-Glukhov note this is not yet merged. To try it out, you need to:
|
@Konstantin-Glukhov |
Why don't you want to do commit? |
I tested the patch and it seems like it successfully generated help.c and funcs.h. Building the targets with the generated files was also successful. |
One comment, why does it need to be a separate target: "generated". Can't you just make it as default build? |
The reason is explained both at the commit message and at the patch. I'm open to other suggestions which will still solve the described issue. |
For what it's worth, to make it generate The first is mentioned at the commit message, and that's cross compiling, e.g. to arm. The problem is that And so, if However, this can actually be solved, by splitting the generated section into two parts: funcs.h help.c:
buildgen.exe help < less.hlp > help.c
type *.c 2>NUL | buildgen.exe funcs > funcs.h
buildgen.exe: buildgen.c
$(CC) buildgen.c So in a native compile env, this would suffice: And for cross compiling, we'd need to first use a native environment for buildgen: And because buildgen.exe was already built natively, and it's newer than The second problem is that we still want the build to be incremental. Currently it is incremental, and changing one c file and then But if we add The mingw makefile solves it by generating a new funcs.h, then comparing it with the old one, and then copy the new over the old only if they differ. So if they're the same, the date of But this doesn't work with So I couldn't solve this problem. For reference, that's my best attempt, which still rebuilds all C files whenever one C file changes (the rest or Makefile.wnm is unmodified, because it already depends on help.c and funcs,h): help.c: buildgen.exe less.hlp
buildgen.exe help < less.hlp > help.c
funcs.h: buildgen.exe *.c
type *.c 2>NUL | buildgen.exe funcs > funcs.h.tmp
comp /M funcs.h.tmp funcs.h || move funcs.h.tmp funcs.h
buildgen.exe: buildgen.c
$(CC) buildgen.c But overall, the instructions are fairly clear, and it's not hard to run That's also not unlike on *nix where So I think this solution should be acceptable, and most importantly, it does cover the needs. @gwsw thoughts? reasons for not commenting (or merging) so far? |
We already have buildgen.c which can be used to generate funcs.h and help.c without grep/sed/perl/sh/etc, which can be useful in mingw setups on Windows which don't bring the whole posix arsenal with them. The default is still the posix tools, but now adding WINGEN=1 will use buildgen.c instead of the posix tools. The compiler which is used with buildgen.c is the same compiler used at the rest of Makefile.wng, so it should be native (not cross build).
Updated a comment at the mingw makefile about cross compiling without posix tools. |
The first commit is for MSVC build, which, so far, didn't have a way to generate
funcs.h
andhelp.c
.Now it can generate them, by building a small C program which is then used instead of the posix tools:
Since we already have this C program, the 2nd commit adds support also for the mingw makefile, which allows building on windows even in environments without posix tools - like several mingw distributions, e.g. llvm-mingw or winlibs, by adding
WINGEN=1
to themake
invocation.