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 build fix #5

Merged
merged 1 commit into from
Dec 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ Makefile
project/msvc/.vs/
project/msvc/bin/
project/msvc/intermediate/
libfaad/win32_ver.h
2 changes: 1 addition & 1 deletion frontend/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1349,7 +1349,7 @@ static int faad_main(int argc, char *argv[])

int main(int argc, char *argv[])
{
#ifdef _WIN32
#if defined WIN32 || defined _WIN32 || defined WIN64 || defined _WIN64
int argc_utf8, exit_code;
char **argv_utf8;
init_console_utf8(stderr);
Expand Down
4 changes: 4 additions & 0 deletions libfaad/decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@
uint16_t dbg_count;
#endif

#if defined WIN32 || defined _WIN32 || defined WIN64 || defined _WIN64
#include "win32_ver.h"
#endif

/* static function declarations */
static void* aac_frame_decode(NeAACDecStruct *hDecoder,
NeAACDecFrameInfo *hInfo,
Expand Down
6 changes: 3 additions & 3 deletions project/msvc/aacinfo.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{FE985E4D-79DB-4DD3-BFED-824B4677A161}</ProjectGuid>
<WindowsTargetPlatformVersion>10.0.10240.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
Expand Down Expand Up @@ -59,7 +59,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;WIN32;_CONSOLE;TEST;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_DEBUG;WIN32;_CONSOLE;TEST;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PrecompiledHeader />
Expand All @@ -80,7 +80,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<PreprocessorDefinitions>NDEBUG;WIN32;_CONSOLE;TEST;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;NDEBUG;WIN32;_CONSOLE;TEST;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
Expand Down
9 changes: 4 additions & 5 deletions project/msvc/faad.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>../../include;../../common/mp4ff;../../frontend;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader />
Expand All @@ -85,7 +85,7 @@
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<AdditionalIncludeDirectories>../../include;../../common/mp4ff;../../frontend;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
Expand All @@ -104,14 +104,13 @@
<ClCompile Include="..\..\frontend\audio.c" />
<ClCompile Include="..\..\frontend\main.c" />
<ClCompile Include="..\..\frontend\mp4read.c" />
<ClCompile Include="..\..\frontend\unicode_support.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\frontend\getopt.h" />
<ClInclude Include="..\..\common\mp4v2\mp4.h" />
<ClInclude Include="..\..\common\mp4v2\mpeg4ip.h" />
<ClInclude Include="..\..\common\mp4v2\systems.h" />
<ClInclude Include="..\..\common\mp4v2\win32_ver.h" />
<ClInclude Include="..\..\frontend\mp4read.h" />
<ClInclude Include="..\..\frontend\unicode_support.h" />
<ClInclude Include="..\..\include\neaacdec.h" />
<ClInclude Include="..\..\frontend\audio.h" />
</ItemGroup>
Expand Down
15 changes: 6 additions & 9 deletions project/msvc/faad.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
<ClCompile Include="..\..\frontend\mp4read.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\frontend\unicode_support.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\frontend\audio.h">
Expand All @@ -28,23 +31,17 @@
<ClInclude Include="..\..\frontend\getopt.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\common\mp4v2\mp4.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\common\mp4v2\mpeg4ip.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\include\neaacdec.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\common\mp4v2\systems.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\common\mp4v2\win32_ver.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\frontend\mp4read.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\frontend\unicode_support.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>
16 changes: 14 additions & 2 deletions project/msvc/libfaad.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<Optimization>MaxSpeed</Optimization>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>NDEBUG;WIN32;_LIB;HAVE_LRINTF;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;NDEBUG;WIN32;_LIB;HAVE_LRINTF;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
Expand All @@ -67,12 +67,18 @@
<Culture>0x0413</Culture>
</ResourceCompile>
<Lib />
<PreBuildEvent>
<Command>"$(SolutionDir)..\..\utils\win32\ac2ver.exe" "faad2" "$(SolutionDir)..\..\configure.ac" &gt; "$(SolutionDir)..\..\libfaad\win32_ver.h"</Command>
</PreBuildEvent>
<PreBuildEvent>
<Message>Retrieving package version...</Message>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_DEBUG;WIN32;_LIB;HAVE_LRINTF;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_DEBUG;WIN32;_LIB;HAVE_LRINTF;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader />
Expand All @@ -84,6 +90,12 @@
<Culture>0x0413</Culture>
</ResourceCompile>
<Lib />
<PreBuildEvent>
<Command>"$(SolutionDir)..\..\utils\win32\ac2ver.exe" "faad2" "$(SolutionDir)..\..\configure.ac" &gt; "$(SolutionDir)..\..\libfaad\win32_ver.h"</Command>
</PreBuildEvent>
<PreBuildEvent>
<Message>Retrieving package version...</Message>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\libfaad\bits.c" />
Expand Down
4 changes: 2 additions & 2 deletions project/msvc/libfaad2_dll.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;HAVE_LRINTF;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_WINDOWS;_USRDLL;HAVE_LRINTF;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader />
Expand Down Expand Up @@ -92,7 +92,7 @@
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;HAVE_LRINTF;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_WINDOWS;_USRDLL;HAVE_LRINTF;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
Expand Down
103 changes: 103 additions & 0 deletions utils/win32/ac2ver.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/*
** AC2VER - extract version number from AC_INIT macro (configure.ac)
** Copyright (C) 2017 LoRd_MuldeR <mulder2@GMX.de>
**
** This software is released under the CC0 1.0 Universal [CC0 1.0] licence!
** https://creativecommons.org/publicdomain/zero/1.0/legalcode
**/

#define BUFF_SIZE 4096
#define _CRT_SECURE_NO_WARNINGS 1

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>

static int clean_string(char *const str)
{
size_t i = 0, j = 0;
while(str[i])
{
if(isalnum(str[i]) || strchr("._-", str[i]))
{
if(i != j)
{
str[j] = str[i];
}
++j;
}
++i;
}
str[j] = '\0';
return !!j;
}

static int parse_version(FILE *const input, const char *const format, char *const version)
{
char buffer[BUFF_SIZE];

while(!(feof(input) || ferror(input)))
{
const char *line = fgets(buffer, BUFF_SIZE, input);
if(line)
{
while((*line) && (isspace(*line)))
{
++line; /*skip space*/
}
if(sscanf(line, format, version) == 1)
{
if(clean_string(version))
{
return 1; /*found!*/
}
}
}
}

version[0] = '\0';
return 0;
}

static int get_version(const wchar_t *const lib_name, const wchar_t *const file_name)
{
char format[128], version[BUFF_SIZE];

FILE *const input = _wfopen(file_name, L"r");
if(!input)
{
fprintf(stderr, "Error: Failed to open input file!\n%S\n\n", file_name);
return 0;
}

_snprintf(format, 128, "AC_INIT ( %S , %%s", lib_name);
//printf("<%s>\n", format);

if(parse_version(input, format, version))
{
printf("#define PACKAGE_VERSION \"%s\"\n", version);
fclose(input);
return 1;
}
else
{
fprintf(stderr, "Error: Version string could not be found!\n\n");
fclose(input);
return 0;
}
}

int wmain(int argc, wchar_t* argv[])
{
if((argc != 3) || (!argv[1][0]) || (!argv[2][0]))
{
wchar_t file_name[_MAX_FNAME], file_ext[_MAX_EXT];
_wsplitpath(argv[0], NULL, NULL, file_name, file_ext);
fprintf(stderr, "AC2VER [%s]\n\n", __DATE__);
fprintf(stderr, "Usage: %S%S <lib_name> <path/to/configure.ac>\n\n", file_name, file_ext);
return EXIT_FAILURE;
}

return get_version(argv[1], argv[2]) ? EXIT_SUCCESS : EXIT_FAILURE;
}
Binary file added utils/win32/ac2ver.exe
Binary file not shown.