修复OEM厂商编译时,环境变量配置不完全的BUG

This commit is contained in:
gb 2022-07-08 14:12:21 +08:00
parent b5491bcb01
commit 99771a68c3
8 changed files with 204 additions and 29 deletions

View File

@ -51,8 +51,8 @@ END
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 4,1015,2022,7061 FILEVERSION 4,1015,2022,7081
PRODUCTVERSION 4,1015,2022,7061 PRODUCTVERSION 4,1015,2022,7081
FILEFLAGSMASK 0x3fL FILEFLAGSMASK 0x3fL
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@ -69,12 +69,12 @@ BEGIN
BEGIN BEGIN
VALUE "CompanyName", "宁波华高信息科技有限公司" VALUE "CompanyName", "宁波华高信息科技有限公司"
VALUE "FileDescription", "华高扫描仪应用程序" VALUE "FileDescription", "华高扫描仪应用程序"
VALUE "FileVersion", "4.1015.2022.7061" VALUE "FileVersion", "4.1015.2022.7081"
VALUE "InternalName", "scanner.dll" VALUE "InternalName", "scanner.dll"
VALUE "LegalCopyright", "Copyright (C) 2022" VALUE "LegalCopyright", "Copyright (C) 2022"
VALUE "OriginalFilename", "scanner.dll" VALUE "OriginalFilename", "scanner.dll"
VALUE "ProductName", "HUAGOScan" VALUE "ProductName", "HUAGOScan"
VALUE "ProductVersion", "4.1015.2022.7061" VALUE "ProductVersion", "4.1015.2022.7081"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"

View File

@ -102,7 +102,7 @@
<ClCompile> <ClCompile>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck> <SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;HGSCANNER_EXPORT;CUSTOM_USBVIEW;BACKEND_NAME=hgdriver;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;HGSCANNER_EXPORT;CUSTOM_USBVIEW;OEM_NONE;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode> <ConformanceMode>true</ConformanceMode>
<DisableSpecificWarnings>4996</DisableSpecificWarnings> <DisableSpecificWarnings>4996</DisableSpecificWarnings>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
@ -132,7 +132,7 @@ move /Y "$(OutDirFullPath)$(ProjectName).pdb" "$(SolutionDir)..\..\sdk\lib\win\$
<FunctionLevelLinking>true</FunctionLevelLinking> <FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions> <IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck> <SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;HGSCANNER_EXPORT;CUSTOM_USBVIEW;BACKEND_NAME=hgdriver;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;HGSCANNER_EXPORT;CUSTOM_USBVIEW;OEM_NONE;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode> <ConformanceMode>true</ConformanceMode>
<DisableSpecificWarnings>4996</DisableSpecificWarnings> <DisableSpecificWarnings>4996</DisableSpecificWarnings>
<LanguageStandard>stdcpp17</LanguageStandard> <LanguageStandard>stdcpp17</LanguageStandard>
@ -313,10 +313,9 @@ move /Y "$(OutDirFullPath)$(ProjectName).pdb" "$(SolutionDir)..\..\sdk\lib\win\$
<ClInclude Include="..\..\code_device\hgdriver\ImageProcess\imgprocdefs.h" /> <ClInclude Include="..\..\code_device\hgdriver\ImageProcess\imgprocdefs.h" />
<ClInclude Include="..\..\code_device\hgdriver\ImageProcess\IMulti.h" /> <ClInclude Include="..\..\code_device\hgdriver\ImageProcess\IMulti.h" />
<ClInclude Include="..\..\code_device\hgdriver\ImageProcess\MatEx.h" /> <ClInclude Include="..\..\code_device\hgdriver\ImageProcess\MatEx.h" />
<ClInclude Include="..\..\code_device\hgdriver\wrapper\hg_log.h" />
<ClInclude Include="..\..\code_device\hgdriver\wrapper\ini_file.h" /> <ClInclude Include="..\..\code_device\hgdriver\wrapper\ini_file.h" />
<ClInclude Include="..\..\sdk\hginclude\hgscanner_error.h" /> <ClInclude Include="..\..\code_device\sdk\hginclude\huagaoxxx_warraper_ex.h" />
<ClInclude Include="..\..\sdk\hginclude\hg_log.h" />
<ClInclude Include="..\..\sdk\hginclude\huagaoxxx_warraper_ex.h" />
<ClInclude Include="..\..\sdk\include\sane\sane.h" /> <ClInclude Include="..\..\sdk\include\sane\sane.h" />
<ClInclude Include="..\..\sdk\include\sane\sanei.h" /> <ClInclude Include="..\..\sdk\include\sane\sanei.h" />
<ClInclude Include="..\..\sdk\include\sane\sanei_backend.h" /> <ClInclude Include="..\..\sdk\include\sane\sanei_backend.h" />

View File

@ -185,15 +185,6 @@
</ClCompile> </ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\..\sdk\hginclude\hg_log.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="..\..\sdk\hginclude\hgscanner_error.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="..\..\sdk\hginclude\huagaoxxx_warraper_ex.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="..\..\code_device\hgdriver\ImageProcess\ImageApply.h"> <ClInclude Include="..\..\code_device\hgdriver\ImageProcess\ImageApply.h">
<Filter>image</Filter> <Filter>image</Filter>
</ClInclude> </ClInclude>
@ -395,6 +386,12 @@
<ClInclude Include="resource.h"> <ClInclude Include="resource.h">
<Filter>头文件</Filter> <Filter>头文件</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\code_device\sdk\hginclude\huagaoxxx_warraper_ex.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="..\..\code_device\hgdriver\wrapper\hg_log.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="device.def"> <None Include="device.def">

View File

@ -248,8 +248,8 @@ END
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 4,1015,2022,7061 FILEVERSION 4,1015,2022,7081
PRODUCTVERSION 4,1015,2022,7061 PRODUCTVERSION 4,1015,2022,7081
FILEFLAGSMASK 0x3fL FILEFLAGSMASK 0x3fL
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@ -266,12 +266,12 @@ BEGIN
BEGIN BEGIN
VALUE "CompanyName", "宁波华高信息科技有限公司" VALUE "CompanyName", "宁波华高信息科技有限公司"
VALUE "FileDescription", "华高扫描仪应用程序" VALUE "FileDescription", "华高扫描仪应用程序"
VALUE "FileVersion", "4.1015.2022.7061" VALUE "FileVersion", "4.1015.2022.7081"
VALUE "InternalName", "sane.dll" VALUE "InternalName", "sane.dll"
VALUE "LegalCopyright", "Copyright (C) 2022" VALUE "LegalCopyright", "Copyright (C) 2022"
VALUE "OriginalFilename", "sane.dll" VALUE "OriginalFilename", "sane.dll"
VALUE "ProductName", "HUAGOScan" VALUE "ProductName", "HUAGOScan"
VALUE "ProductVersion", "4.1015.2022.7061" VALUE "ProductVersion", "4.1015.2022.7081"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"

View File

@ -103,7 +103,7 @@
<ClCompile> <ClCompile>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck> <SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>BACKEND_NAME=hgsane;TWPP_IS_DS;EXPORT_SANE_API;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>BACKEND_NAME=hgsane;TWPP_IS_DS;EXPORT_SANE_API;WIN32;OEM_NONE;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode> <ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp17</LanguageStandard> <LanguageStandard>stdcpp17</LanguageStandard>
<DisableSpecificWarnings>4996</DisableSpecificWarnings> <DisableSpecificWarnings>4996</DisableSpecificWarnings>
@ -128,7 +128,7 @@ move /Y "$(OutDirFullPath)$(ProjectName).pdb" "$(SolutionDir)..\..\sdk\lib\win\$
<FunctionLevelLinking>true</FunctionLevelLinking> <FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions> <IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck> <SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>BACKEND_NAME=hgsane;TWPP_IS_DS;EXPORT_SANE_API;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>BACKEND_NAME=hgsane;TWPP_IS_DS;EXPORT_SANE_API;WIN32;OEM_NONE;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode> <ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp17</LanguageStandard> <LanguageStandard>stdcpp17</LanguageStandard>
<DisableSpecificWarnings>4996</DisableSpecificWarnings> <DisableSpecificWarnings>4996</DisableSpecificWarnings>

Binary file not shown.

View File

@ -568,6 +568,33 @@ namespace rc
} }
} while (end); } while (end);
} }
static bool change_file(const wchar_t* file, oem o, bool(__stdcall* modify)(std::wstring& cont, oem o))
{
bom bm = BOM_UTF8;
std::wstring cont(load_file(file, &bm));
bool ret = modify(cont, o);
if (ret)
{
std::string bomstr("");
if (bm == BOM_UNICODE)
coding_util::bom::from_unicode(cont.c_str(), cont.length() * 2, got_str, &bomstr);
else if (bm == BOM_UTF8)
{
std::string utf8("");
coding_util::unicode_2_utf8(cont.c_str(), got_str, &utf8);
coding_util::bom::from_utf8(utf8.c_str(), utf8.length(), got_str, &bomstr);
}
else
coding_util::unicode_2_ansi(cont.c_str(), got_str, &bomstr);
file_util::save_2_file(bomstr.c_str(), bomstr.length(), file);
}
return ret;
}
bool set_rc_ver(const wchar_t* file, int v_1, int v_2, int v_3, int v_4, const wchar_t* company_name, const wchar_t* short_company_name, const wchar_t* vender) bool set_rc_ver(const wchar_t* file, int v_1, int v_2, int v_3, int v_4, const wchar_t* company_name, const wchar_t* short_company_name, const wchar_t* vender)
{ {
bom bm = BOM_UTF8; bom bm = BOM_UTF8;
@ -702,6 +729,138 @@ namespace rc
return true; return true;
} }
bool change_vcxproj_predefine(const wchar_t* file, oem o)
{
bom bm = BOM_UTF8;
std::wstring cont(load_file(file, &bm)), backend(L""), lead(L"BACKEND_NAME=");
size_t pos = cont.find(lead), end = 0;
//if (pos == std::wstring::npos)
// return false;
if (cont.length() < 1000)
return false;
if (o == OEM_HANWANG)
backend = L"hw";
else if (o == OEM_LISICHENG)
backend = L"lsc";
else
backend = L"hg";
backend += L"sane";
while (pos != std::wstring::npos)
{
pos += lead.length();
end = pos;
while (cont[end] != L';' && cont[end] != L'<')
end++;
cont.replace(pos, end - pos, backend);
pos += backend.length();
pos = cont.find(lead, pos);
}
pos = cont.find(L"OEM_");
while (pos != std::wstring::npos)
{
end = pos + 4;
while (cont[end] != L';' && cont[end] != L'<')
end++;
if (from_str(cont.substr(pos, end - pos).c_str()) != OEM_NOT)
{
cont.replace(pos, end - pos, oem_str(o));
end = pos + oem_str(o).length();
}
pos = cont.find(L"OEM_", end);
}
std::string bomstr("");
if (bm == BOM_UNICODE)
coding_util::bom::from_unicode(cont.c_str(), cont.length() * 2, got_str, &bomstr);
else if (bm == BOM_UTF8)
{
std::string utf8("");
coding_util::unicode_2_utf8(cont.c_str(), got_str, &utf8);
coding_util::bom::from_utf8(utf8.c_str(), utf8.length(), got_str, &bomstr);
}
else
coding_util::unicode_2_ansi(cont.c_str(), got_str, &bomstr);
file_util::save_2_file(bomstr.c_str(), bomstr.length(), file);
return true;
}
bool __stdcall change_sane_def(std::wstring& cont, oem o)
{
std::wstring backend(L"sane_"), prev(L"_hgsane_");
if (o == OEM_HANWANG)
backend.insert(0, L"_hw");
else if (o == OEM_LISICHENG)
backend.insert(0, L"_lsc");
else
backend.insert(0, L"_hg");
if (cont.find(backend) != std::wstring::npos)
return true;
if (cont.find(prev) == std::wstring::npos)
{
prev = L"_hwsane_";
if (cont.find(prev) == std::wstring::npos)
{
prev = L"_lscsane_";
if (cont.find(prev) == std::wstring::npos)
return false;
}
}
size_t pos = cont.find(prev);
while (pos != std::wstring::npos)
{
cont.replace(pos, prev.length(), backend);
pos += backend.length();
pos = cont.find(prev, pos);
}
return true;
}
bool __stdcall change_device_def(std::wstring& cont, oem o)
{
std::wstring backend(L"_scanner_"), prev(L"hg_scanner_");
if (o == OEM_HANWANG)
backend.insert(0, L"hw");
else if (o == OEM_LISICHENG)
backend.insert(0, L"lsc");
else
backend.insert(0, L"hg");
if (cont.find(backend) != std::wstring::npos)
return true;
if (cont.find(prev) == std::wstring::npos)
{
prev = L"hw_scanner_";
if (cont.find(prev) == std::wstring::npos)
{
prev = L"lsc_scanner_";
if (cont.find(prev) == std::wstring::npos)
return false;
}
}
size_t pos = cont.find(prev);
while (pos != std::wstring::npos)
{
cont.replace(pos, prev.length(), backend);
pos += backend.length();
pos = cont.find(prev, pos);
}
return true;
}
}; };
static bool set_ver(const wchar_t* file, oem vendor, bool x86, int pid, int main) static bool set_ver(const wchar_t* file, oem vendor, bool x86, int pid, int main)
@ -762,20 +921,40 @@ static bool set_ver(const wchar_t* file, oem vendor, bool x86, int pid, int main
coding_util::unicode_2_ansi(unic.c_str(), got_str, &cont); coding_util::unicode_2_ansi(unic.c_str(), got_str, &cont);
file_util::save_2_file(cont.c_str(), cont.length(), file); file_util::save_2_file(cont.c_str(), cont.length(), file);
std::wstring cn(L""), scn(L""), vendor(L""), base(file), rcf(L""); std::wstring cn(L""), scn(L""), vs(L""), base(file), rcf(L"");
STR_PARENT_FOLDER(base); STR_PARENT_FOLDER(base);
if (rc::get_version_from_file(file, &main, &sub, &build, &patch, &cn, &scn, &vendor)) if (rc::get_version_from_file(file, &main, &sub, &build, &patch, &cn, &scn, &vs))
{ {
rcf = base + L"\\..\\sane\\sane.vcxproj";
STR_SIMPLIFY_PATH(rcf);
if(!rc::change_vcxproj_predefine(rcf.c_str(), vendor))
std::wcout << "change predefines failed: " << rcf.c_str() << std::endl;
rcf = base + L"\\..\\sane\\sane.rc"; rcf = base + L"\\..\\sane\\sane.rc";
STR_SIMPLIFY_PATH(rcf); STR_SIMPLIFY_PATH(rcf);
if (!rc::set_rc_ver(rcf.c_str(), main, sub, build, patch, cn.c_str(), scn.c_str(), vendor.c_str())) if (!rc::set_rc_ver(rcf.c_str(), main, sub, build, patch, cn.c_str(), scn.c_str(), vs.c_str()))
std::wcout << "change version failed: " << rcf.c_str() << std::endl; std::wcout << "change version failed: " << rcf.c_str() << std::endl;
rcf = base + L"\\..\\sane\\sane.def";
STR_SIMPLIFY_PATH(rcf);
if(!rc::change_file(rcf.c_str(), vendor, rc::change_sane_def))
std::wcout << "change exporting-definition failed: " << rcf.c_str() << std::endl;
rcf = base + L"\\..\\device\\scanner.vcxproj";
STR_SIMPLIFY_PATH(rcf);
if(!rc::change_vcxproj_predefine(rcf.c_str(), vendor))
std::wcout << "change predefines failed: " << rcf.c_str() << std::endl;
rcf = base + L"\\..\\device\\scanner.rc"; rcf = base + L"\\..\\device\\scanner.rc";
STR_SIMPLIFY_PATH(rcf); STR_SIMPLIFY_PATH(rcf);
if (!rc::set_rc_ver(rcf.c_str(), main, sub, build, patch, cn.c_str(), scn.c_str(), vendor.c_str())) if (!rc::set_rc_ver(rcf.c_str(), main, sub, build, patch, cn.c_str(), scn.c_str(), vs.c_str()))
std::wcout << "change version failed: " << rcf.c_str() << std::endl; std::wcout << "change version failed: " << rcf.c_str() << std::endl;
rcf = base + L"\\..\\device\\device.def";
STR_SIMPLIFY_PATH(rcf);
if(!rc::change_file(rcf.c_str(), vendor, rc::change_device_def))
std::wcout << "change exporting-definition failed: " << rcf.c_str() << std::endl;
} }
else else
{ {

View File

@ -8,7 +8,7 @@
#define VERSION_MAIN 4 #define VERSION_MAIN 4
#define VERSION_SUB 1015 #define VERSION_SUB 1015
#define VERSION_BUILD 2022 #define VERSION_BUILD 2022
#define VERSION_PATCH 7061 #define VERSION_PATCH 7081
#define TO_STR(a) #a #define TO_STR(a) #a
#define TO_VER_STR(vs) TO_STR(v##vs) #define TO_VER_STR(vs) TO_STR(v##vs)