Generate "win32_ver.h" from "configure.h" as a pre-build event + some clean-up of project files.
LoRd_MuldeR
6 years ago
15 | 15 | project/msvc/.vs/ |
16 | 16 | project/msvc/bin/ |
17 | 17 | project/msvc/intermediate/ |
18 | libfaad/win32_ver.h |
1348 | 1348 | |
1349 | 1349 | int main(int argc, char *argv[]) |
1350 | 1350 | { |
1351 | #ifdef _WIN32 | |
1351 | #if defined WIN32 || defined _WIN32 || defined WIN64 || defined _WIN64 | |
1352 | 1352 | int argc_utf8, exit_code; |
1353 | 1353 | char **argv_utf8; |
1354 | 1354 | init_console_utf8(stderr); |
50 | 50 | |
51 | 51 | #ifdef ANALYSIS |
52 | 52 | uint16_t dbg_count; |
53 | #endif | |
54 | ||
55 | #if defined WIN32 || defined _WIN32 || defined WIN64 || defined _WIN64 | |
56 | #include "win32_ver.h" | |
53 | 57 | #endif |
54 | 58 | |
55 | 59 | /* static function declarations */ |
11 | 11 | </ItemGroup> |
12 | 12 | <PropertyGroup Label="Globals"> |
13 | 13 | <ProjectGuid>{FE985E4D-79DB-4DD3-BFED-824B4677A161}</ProjectGuid> |
14 | <WindowsTargetPlatformVersion>10.0.10240.0</WindowsTargetPlatformVersion> | |
14 | <WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion> | |
15 | 15 | </PropertyGroup> |
16 | 16 | <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> |
17 | 17 | <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> |
58 | 58 | <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> |
59 | 59 | <ClCompile> |
60 | 60 | <Optimization>Disabled</Optimization> |
61 | <PreprocessorDefinitions>_DEBUG;WIN32;_CONSOLE;TEST;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> | |
61 | <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_DEBUG;WIN32;_CONSOLE;TEST;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> | |
62 | 62 | <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> |
63 | 63 | <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> |
64 | 64 | <PrecompiledHeader /> |
79 | 79 | <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> |
80 | 80 | <ClCompile> |
81 | 81 | <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion> |
82 | <PreprocessorDefinitions>NDEBUG;WIN32;_CONSOLE;TEST;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> | |
82 | <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;NDEBUG;WIN32;_CONSOLE;TEST;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> | |
83 | 83 | <StringPooling>true</StringPooling> |
84 | 84 | <RuntimeLibrary>MultiThreaded</RuntimeLibrary> |
85 | 85 | <FunctionLevelLinking>true</FunctionLevelLinking> |
58 | 58 | <ClCompile> |
59 | 59 | <Optimization>Disabled</Optimization> |
60 | 60 | <AdditionalIncludeDirectories>../../include;../../common/mp4ff;../../frontend;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> |
61 | <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> | |
61 | <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> | |
62 | 62 | <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> |
63 | 63 | <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> |
64 | 64 | <PrecompiledHeader /> |
84 | 84 | <IntrinsicFunctions>true</IntrinsicFunctions> |
85 | 85 | <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed> |
86 | 86 | <AdditionalIncludeDirectories>../../include;../../common/mp4ff;../../frontend;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> |
87 | <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> | |
87 | <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> | |
88 | 88 | <StringPooling>true</StringPooling> |
89 | 89 | <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> |
90 | 90 | <FunctionLevelLinking>true</FunctionLevelLinking> |
103 | 103 | <ClCompile Include="..\..\frontend\audio.c" /> |
104 | 104 | <ClCompile Include="..\..\frontend\main.c" /> |
105 | 105 | <ClCompile Include="..\..\frontend\mp4read.c" /> |
106 | <ClCompile Include="..\..\frontend\unicode_support.c" /> | |
106 | 107 | </ItemGroup> |
107 | 108 | <ItemGroup> |
108 | 109 | <ClInclude Include="..\..\frontend\getopt.h" /> |
109 | <ClInclude Include="..\..\common\mp4v2\mp4.h" /> | |
110 | <ClInclude Include="..\..\common\mp4v2\mpeg4ip.h" /> | |
111 | <ClInclude Include="..\..\common\mp4v2\systems.h" /> | |
112 | 110 | <ClInclude Include="..\..\common\mp4v2\win32_ver.h" /> |
113 | 111 | <ClInclude Include="..\..\frontend\mp4read.h" /> |
112 | <ClInclude Include="..\..\frontend\unicode_support.h" /> | |
114 | 113 | <ClInclude Include="..\..\include\neaacdec.h" /> |
115 | 114 | <ClInclude Include="..\..\frontend\audio.h" /> |
116 | 115 | </ItemGroup> |
19 | 19 | <ClCompile Include="..\..\frontend\mp4read.c"> |
20 | 20 | <Filter>Source Files</Filter> |
21 | 21 | </ClCompile> |
22 | <ClCompile Include="..\..\frontend\unicode_support.c"> | |
23 | <Filter>Source Files</Filter> | |
24 | </ClCompile> | |
22 | 25 | </ItemGroup> |
23 | 26 | <ItemGroup> |
24 | 27 | <ClInclude Include="..\..\frontend\audio.h"> |
27 | 30 | <ClInclude Include="..\..\frontend\getopt.h"> |
28 | 31 | <Filter>Header Files</Filter> |
29 | 32 | </ClInclude> |
30 | <ClInclude Include="..\..\common\mp4v2\mp4.h"> | |
31 | <Filter>Header Files</Filter> | |
32 | </ClInclude> | |
33 | <ClInclude Include="..\..\common\mp4v2\mpeg4ip.h"> | |
34 | <Filter>Header Files</Filter> | |
35 | </ClInclude> | |
36 | 33 | <ClInclude Include="..\..\include\neaacdec.h"> |
37 | <Filter>Header Files</Filter> | |
38 | </ClInclude> | |
39 | <ClInclude Include="..\..\common\mp4v2\systems.h"> | |
40 | 34 | <Filter>Header Files</Filter> |
41 | 35 | </ClInclude> |
42 | 36 | <ClInclude Include="..\..\common\mp4v2\win32_ver.h"> |
45 | 39 | <ClInclude Include="..\..\frontend\mp4read.h"> |
46 | 40 | <Filter>Header Files</Filter> |
47 | 41 | </ClInclude> |
42 | <ClInclude Include="..\..\frontend\unicode_support.h"> | |
43 | <Filter>Header Files</Filter> | |
44 | </ClInclude> | |
48 | 45 | </ItemGroup> |
49 | 46 | </Project>⏎ |
54 | 54 | <Optimization>MaxSpeed</Optimization> |
55 | 55 | <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion> |
56 | 56 | <AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> |
57 | <PreprocessorDefinitions>NDEBUG;WIN32;_LIB;HAVE_LRINTF;%(PreprocessorDefinitions)</PreprocessorDefinitions> | |
57 | <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;NDEBUG;WIN32;_LIB;HAVE_LRINTF;%(PreprocessorDefinitions)</PreprocessorDefinitions> | |
58 | 58 | <StringPooling>true</StringPooling> |
59 | 59 | <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> |
60 | 60 | <FunctionLevelLinking>true</FunctionLevelLinking> |
66 | 66 | <Culture>0x0413</Culture> |
67 | 67 | </ResourceCompile> |
68 | 68 | <Lib /> |
69 | <PreBuildEvent> | |
70 | <Command>"$(SolutionDir)..\..\utils\win32\ac2ver.exe" "faad2" "$(SolutionDir)..\..\configure.ac" > "$(SolutionDir)..\..\libfaad\win32_ver.h"</Command> | |
71 | </PreBuildEvent> | |
72 | <PreBuildEvent> | |
73 | <Message>Retrieving package version...</Message> | |
74 | </PreBuildEvent> | |
69 | 75 | </ItemDefinitionGroup> |
70 | 76 | <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> |
71 | 77 | <ClCompile> |
72 | 78 | <Optimization>Disabled</Optimization> |
73 | 79 | <AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> |
74 | <PreprocessorDefinitions>_DEBUG;WIN32;_LIB;HAVE_LRINTF;%(PreprocessorDefinitions)</PreprocessorDefinitions> | |
80 | <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_DEBUG;WIN32;_LIB;HAVE_LRINTF;%(PreprocessorDefinitions)</PreprocessorDefinitions> | |
75 | 81 | <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> |
76 | 82 | <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> |
77 | 83 | <PrecompiledHeader /> |
83 | 89 | <Culture>0x0413</Culture> |
84 | 90 | </ResourceCompile> |
85 | 91 | <Lib /> |
92 | <PreBuildEvent> | |
93 | <Command>"$(SolutionDir)..\..\utils\win32\ac2ver.exe" "faad2" "$(SolutionDir)..\..\configure.ac" > "$(SolutionDir)..\..\libfaad\win32_ver.h"</Command> | |
94 | </PreBuildEvent> | |
95 | <PreBuildEvent> | |
96 | <Message>Retrieving package version...</Message> | |
97 | </PreBuildEvent> | |
86 | 98 | </ItemDefinitionGroup> |
87 | 99 | <ItemGroup> |
88 | 100 | <ClCompile Include="..\..\libfaad\bits.c" /> |
62 | 62 | <ClCompile> |
63 | 63 | <Optimization>Disabled</Optimization> |
64 | 64 | <AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> |
65 | <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;HAVE_LRINTF;%(PreprocessorDefinitions)</PreprocessorDefinitions> | |
65 | <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_WINDOWS;_USRDLL;HAVE_LRINTF;%(PreprocessorDefinitions)</PreprocessorDefinitions> | |
66 | 66 | <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> |
67 | 67 | <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> |
68 | 68 | <PrecompiledHeader /> |
91 | 91 | <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion> |
92 | 92 | <IntrinsicFunctions>true</IntrinsicFunctions> |
93 | 93 | <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed> |
94 | <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;HAVE_LRINTF;%(PreprocessorDefinitions)</PreprocessorDefinitions> | |
94 | <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_WINDOWS;_USRDLL;HAVE_LRINTF;%(PreprocessorDefinitions)</PreprocessorDefinitions> | |
95 | 95 | <StringPooling>true</StringPooling> |
96 | 96 | <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> |
97 | 97 | <FunctionLevelLinking>true</FunctionLevelLinking> |
0 | /* | |
1 | ** AC2VER - extract version number from AC_INIT macro (configure.ac) | |
2 | ** Copyright (C) 2017 LoRd_MuldeR <mulder2@GMX.de> | |
3 | ** | |
4 | ** This software is released under the CC0 1.0 Universal [CC0 1.0] licence! | |
5 | ** https://creativecommons.org/publicdomain/zero/1.0/legalcode | |
6 | **/ | |
7 | ||
8 | #define BUFF_SIZE 4096 | |
9 | #define _CRT_SECURE_NO_WARNINGS 1 | |
10 | ||
11 | #include <stdlib.h> | |
12 | #include <stdio.h> | |
13 | #include <string.h> | |
14 | #include <ctype.h> | |
15 | ||
16 | static int clean_string(char *const str) | |
17 | { | |
18 | size_t i = 0, j = 0; | |
19 | while(str[i]) | |
20 | { | |
21 | if(isalnum(str[i]) || strchr("._-", str[i])) | |
22 | { | |
23 | if(i != j) | |
24 | { | |
25 | str[j] = str[i]; | |
26 | } | |
27 | ++j; | |
28 | } | |
29 | ++i; | |
30 | } | |
31 | str[j] = '\0'; | |
32 | return !!j; | |
33 | } | |
34 | ||
35 | static int parse_version(FILE *const input, const char *const format, char *const version) | |
36 | { | |
37 | char buffer[BUFF_SIZE]; | |
38 | ||
39 | while(!(feof(input) || ferror(input))) | |
40 | { | |
41 | const char *line = fgets(buffer, BUFF_SIZE, input); | |
42 | if(line) | |
43 | { | |
44 | while((*line) && (isspace(*line))) | |
45 | { | |
46 | ++line; /*skip space*/ | |
47 | } | |
48 | if(sscanf(line, format, version) == 1) | |
49 | { | |
50 | if(clean_string(version)) | |
51 | { | |
52 | return 1; /*found!*/ | |
53 | } | |
54 | } | |
55 | } | |
56 | } | |
57 | ||
58 | version[0] = '\0'; | |
59 | return 0; | |
60 | } | |
61 | ||
62 | static int get_version(const wchar_t *const lib_name, const wchar_t *const file_name) | |
63 | { | |
64 | char format[128], version[BUFF_SIZE]; | |
65 | ||
66 | FILE *const input = _wfopen(file_name, L"r"); | |
67 | if(!input) | |
68 | { | |
69 | fprintf(stderr, "Error: Failed to open input file!\n%S\n\n", file_name); | |
70 | return 0; | |
71 | } | |
72 | ||
73 | _snprintf(format, 128, "AC_INIT ( %S , %%s", lib_name); | |
74 | //printf("<%s>\n", format); | |
75 | ||
76 | if(parse_version(input, format, version)) | |
77 | { | |
78 | printf("#define PACKAGE_VERSION \"%s\"\n", version); | |
79 | fclose(input); | |
80 | return 1; | |
81 | } | |
82 | else | |
83 | { | |
84 | fprintf(stderr, "Error: Version string could not be found!\n\n"); | |
85 | fclose(input); | |
86 | return 0; | |
87 | } | |
88 | } | |
89 | ||
90 | int wmain(int argc, wchar_t* argv[]) | |
91 | { | |
92 | if((argc != 3) || (!argv[1][0]) || (!argv[2][0])) | |
93 | { | |
94 | wchar_t file_name[_MAX_FNAME], file_ext[_MAX_EXT]; | |
95 | _wsplitpath(argv[0], NULL, NULL, file_name, file_ext); | |
96 | fprintf(stderr, "AC2VER [%s]\n\n", __DATE__); | |
97 | fprintf(stderr, "Usage: %S%S <lib_name> <path/to/configure.ac>\n\n", file_name, file_ext); | |
98 | return EXIT_FAILURE; | |
99 | } | |
100 | ||
101 | return get_version(argv[1], argv[2]) ? EXIT_SUCCESS : EXIT_FAILURE; | |
102 | } |
Binary diff not shown