增加批处理编译参数onlytwain,只更改twain工程
This commit is contained in:
parent
99771a68c3
commit
6712499fee
34
build.bat
34
build.bat
|
@ -1,12 +1,15 @@
|
|||
echo off
|
||||
echo "build.bat [hw | lsc] [x86 | x64] [0x100 | 0x...]"
|
||||
echo "build.bat [hw | lsc] [x86 | x64] [0x100 | 0x...] [onlytwain]"
|
||||
|
||||
set OEM=hg
|
||||
set CPU=x86
|
||||
set PID=0x100
|
||||
set COMPILE_RANGE=""
|
||||
|
||||
set VAL=%1
|
||||
if "%1"=="hw" (
|
||||
if "%1"=="onlytwain" (
|
||||
set COMPILE_RANGE="-only-twain"
|
||||
) else if "%1"=="hw" (
|
||||
set OEM=%1
|
||||
)else if "%1"=="lsc" (
|
||||
set OEM=%1
|
||||
|
@ -21,7 +24,9 @@ set OEM=%1
|
|||
)
|
||||
|
||||
set VAL=%2
|
||||
if "%2"=="hw" (
|
||||
if "%2"=="onlytwain" (
|
||||
set COMPILE_RANGE="-only-twain"
|
||||
) else if "%2"=="hw" (
|
||||
set OEM=%2
|
||||
)else if "%2"=="lsc" (
|
||||
set OEM=%2
|
||||
|
@ -36,7 +41,9 @@ set OEM=%2
|
|||
)
|
||||
|
||||
set VAL=%3
|
||||
if "%3"=="hw" (
|
||||
if "%3"=="onlytwain" (
|
||||
set COMPILE_RANGE="-only-twain"
|
||||
) else if "%3"=="hw" (
|
||||
set OEM=%3
|
||||
)else if "%3"=="lsc" (
|
||||
set OEM=%3
|
||||
|
@ -50,10 +57,27 @@ set OEM=%3
|
|||
)
|
||||
)
|
||||
|
||||
set VAL=%4
|
||||
if "%4"=="onlytwain" (
|
||||
set COMPILE_RANGE="-only-twain"
|
||||
) else if "%4"=="hw" (
|
||||
set OEM=%4
|
||||
)else if "%4"=="lsc" (
|
||||
set OEM=%4
|
||||
) else (
|
||||
if "%4"=="x64" (
|
||||
set CPU=%4
|
||||
) else if "%4"=="x86" (
|
||||
set CPU=%4
|
||||
) else if "%VAL:~0,2%"=="0x" (
|
||||
set PID=%VAL%
|
||||
)
|
||||
)
|
||||
|
||||
echo oem=%OEM%
|
||||
echo cpu=%CPU%
|
||||
echo pid=%PID%
|
||||
"%~dp0\sln\release\hgsetver.exe" "%~dp0\twain\brand.h" -oem %OEM% -cpu %CPU% -pid %PID%
|
||||
"%~dp0\sln\release\hgsetver.exe" "%~dp0\twain\brand.h" -oem %OEM% -cpu %CPU% -pid %PID% %COMPILE_RANGE%
|
||||
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\MSBuild.exe" "%~dp0\device\scanner.vcxproj" /p:Configuration=Release /p:Platform=x86
|
||||
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\MSBuild.exe" "%~dp0\sane\sane.vcxproj" /p:Configuration=Release /p:Platform=x86
|
||||
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\MSBuild.exe" "%~dp0\twain\twain.vcxproj" /p:Configuration=Release /p:Platform=x86
|
||||
|
|
Binary file not shown.
|
@ -21,7 +21,7 @@ enum oem
|
|||
#define GET_ENUM_VALUE_W(e, v) \
|
||||
if(L###e == v) return e;
|
||||
|
||||
static bool set_ver(const wchar_t* file, oem vendor, bool x86, int pid, int main = 0);
|
||||
static bool set_ver(const wchar_t* file, oem vendor, bool x86, int pid, int main = 0, bool twain_only = false);
|
||||
|
||||
int main()
|
||||
{
|
||||
|
@ -37,7 +37,7 @@ int main()
|
|||
if (pos != std::wstring::npos)
|
||||
pe.erase(pos);
|
||||
|
||||
std::wcout << L"Usage: " << pe.c_str() << L"<path-file> [-pid product_id lead with '0x'] [-main main-ver, all version will be omitted if this was not given or be ZERO] [-cpu x86|x64] [-oem hw|lsc]\r\n";
|
||||
std::wcout << L"Usage: " << pe.c_str() << L"<path-file> [-pid product_id lead with '0x'] [-main main-ver, all version will be omitted if this was not given or be ZERO] [-cpu x86|x64] [-oem hw|lsc] [-only-twain change twain project only]\r\n";
|
||||
cmd->release();
|
||||
|
||||
DWORD pid = process_util::get_parent_process(GetCurrentProcessId());
|
||||
|
@ -54,7 +54,7 @@ int main()
|
|||
}
|
||||
|
||||
oem vendor = OEM_NONE;
|
||||
bool x86 = true;
|
||||
bool x86 = true, twain_only = cmd->has(L"-only-twain");
|
||||
int main = 0, pid = 0x100;
|
||||
|
||||
if (cmd->parameter(L"-main"))
|
||||
|
@ -85,7 +85,7 @@ int main()
|
|||
std::wstring file(cmd->parameter(1));
|
||||
|
||||
STR_TO_ABSOLUTE_PATH(file);
|
||||
set_ver(file.c_str(), vendor, x86, pid, main);
|
||||
set_ver(file.c_str(), vendor, x86, pid, main, twain_only);
|
||||
cmd->release();
|
||||
|
||||
return 0;
|
||||
|
@ -308,6 +308,11 @@ static bool change_product_id(std::wstring& brand, int pid)
|
|||
}
|
||||
namespace rc
|
||||
{
|
||||
typedef struct _change_param
|
||||
{
|
||||
oem o;
|
||||
int product_id;
|
||||
}CHGPARAM, *LPCHGPARAM;
|
||||
static std::wstring load_file(const wchar_t* file, bom* bm)
|
||||
{
|
||||
std::string cont("");
|
||||
|
@ -568,11 +573,11 @@ namespace rc
|
|||
}
|
||||
} while (end);
|
||||
}
|
||||
static bool change_file(const wchar_t* file, oem o, bool(__stdcall* modify)(std::wstring& cont, oem o))
|
||||
static bool change_file(const wchar_t* file, LPCHGPARAM param, bool(__stdcall* modify)(std::wstring& cont, LPCHGPARAM param))
|
||||
{
|
||||
bom bm = BOM_UTF8;
|
||||
std::wstring cont(load_file(file, &bm));
|
||||
bool ret = modify(cont, o);
|
||||
bool ret = modify(cont, param);
|
||||
|
||||
if (ret)
|
||||
{
|
||||
|
@ -790,9 +795,10 @@ namespace rc
|
|||
return true;
|
||||
}
|
||||
|
||||
bool __stdcall change_sane_def(std::wstring& cont, oem o)
|
||||
bool __stdcall change_sane_def(std::wstring& cont, LPCHGPARAM param)
|
||||
{
|
||||
std::wstring backend(L"sane_"), prev(L"_hgsane_");
|
||||
oem o = param->o;
|
||||
|
||||
if (o == OEM_HANWANG)
|
||||
backend.insert(0, L"_hw");
|
||||
|
@ -825,9 +831,10 @@ namespace rc
|
|||
|
||||
return true;
|
||||
}
|
||||
bool __stdcall change_device_def(std::wstring& cont, oem o)
|
||||
bool __stdcall change_device_def(std::wstring& cont, LPCHGPARAM param)
|
||||
{
|
||||
std::wstring backend(L"_scanner_"), prev(L"hg_scanner_");
|
||||
oem o = param->o;
|
||||
|
||||
if (o == OEM_HANWANG)
|
||||
backend.insert(0, L"hw");
|
||||
|
@ -860,10 +867,37 @@ namespace rc
|
|||
|
||||
return true;
|
||||
}
|
||||
bool __stdcall change_output(std::wstring& cont, LPCHGPARAM param)
|
||||
{
|
||||
std::wstring target(L"huagao"), first(L"<TargetName>"), last(L"</TargetName>");
|
||||
wchar_t tail[40] = { 0 };
|
||||
size_t bgn = 0, end = -1;
|
||||
bool ok = false;
|
||||
|
||||
swprintf_s(tail, _countof(tail) - 1, L"twain%x.ds", param->product_id);
|
||||
if (param->o == OEM_HANWANG)
|
||||
target = L"hanvon";
|
||||
else if (param->o == OEM_LISICHENG)
|
||||
target = L"lanxum";
|
||||
target += tail;
|
||||
|
||||
while ((bgn = cont.find(first, bgn)) != std::wstring::npos)
|
||||
{
|
||||
bgn += first.length();
|
||||
end = cont.find(last, bgn);
|
||||
if (end != std::wstring::npos)
|
||||
{
|
||||
ok = true;
|
||||
cont.replace(bgn, end - bgn, target);
|
||||
bgn += target.length() + last.length();
|
||||
}
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
};
|
||||
|
||||
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, bool twain_only)
|
||||
{
|
||||
bool ret = false;
|
||||
bom bm = BOM_UTF8;
|
||||
|
@ -890,6 +924,8 @@ static bool set_ver(const wchar_t* file, oem vendor, bool x86, int pid, int main
|
|||
patch += 1;
|
||||
|
||||
while (change_oem(unic, vendor))
|
||||
{
|
||||
if (!twain_only)
|
||||
{
|
||||
if (main && !change_main(unic, main))
|
||||
break;
|
||||
|
@ -899,6 +935,7 @@ static bool set_ver(const wchar_t* file, oem vendor, bool x86, int pid, int main
|
|||
break;
|
||||
if (!change_patch(unic, patch))
|
||||
break;
|
||||
}
|
||||
if (!change_product_id(unic, pid))
|
||||
break;
|
||||
|
||||
|
@ -922,9 +959,14 @@ static bool set_ver(const wchar_t* file, oem vendor, bool x86, int pid, int main
|
|||
file_util::save_2_file(cont.c_str(), cont.length(), file);
|
||||
|
||||
std::wstring cn(L""), scn(L""), vs(L""), base(file), rcf(L"");
|
||||
rc::CHGPARAM param;
|
||||
|
||||
param.o = vendor;
|
||||
param.product_id = pid;
|
||||
STR_PARENT_FOLDER(base);
|
||||
if (rc::get_version_from_file(file, &main, &sub, &build, &patch, &cn, &scn, &vs))
|
||||
{
|
||||
if (!twain_only)
|
||||
{
|
||||
rcf = base + L"\\..\\sane\\sane.vcxproj";
|
||||
STR_SIMPLIFY_PATH(rcf);
|
||||
|
@ -938,7 +980,7 @@ static bool set_ver(const wchar_t* file, oem vendor, bool x86, int pid, int main
|
|||
|
||||
rcf = base + L"\\..\\sane\\sane.def";
|
||||
STR_SIMPLIFY_PATH(rcf);
|
||||
if(!rc::change_file(rcf.c_str(), vendor, rc::change_sane_def))
|
||||
if (!rc::change_file(rcf.c_str(), ¶m, rc::change_sane_def))
|
||||
std::wcout << "change exporting-definition failed: " << rcf.c_str() << std::endl;
|
||||
|
||||
rcf = base + L"\\..\\device\\scanner.vcxproj";
|
||||
|
@ -953,9 +995,18 @@ static bool set_ver(const wchar_t* file, oem vendor, bool x86, int pid, int main
|
|||
|
||||
rcf = base + L"\\..\\device\\device.def";
|
||||
STR_SIMPLIFY_PATH(rcf);
|
||||
if(!rc::change_file(rcf.c_str(), vendor, rc::change_device_def))
|
||||
if (!rc::change_file(rcf.c_str(), ¶m, rc::change_device_def))
|
||||
std::wcout << "change exporting-definition failed: " << rcf.c_str() << std::endl;
|
||||
}
|
||||
|
||||
rcf = base + L"\\..\\twain\\twain.vcxproj";
|
||||
STR_SIMPLIFY_PATH(rcf);
|
||||
if (!rc::change_file(rcf.c_str(), ¶m, rc::change_output))
|
||||
{
|
||||
std::wcout << "change exporting-definition failed: " << rcf.c_str() << std::endl;
|
||||
ret = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::wcout << L"get version info failed\r\n";
|
||||
|
|
|
@ -49,6 +49,7 @@
|
|||
<OutDir>$(SolutionDir)..\..\release\win\$(PlatformTarget)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)..\..\tmp\$(PlatformTarget)\$(Configuration)\$(ProjectName)\</IntDir>
|
||||
<LibraryPath>$(LibraryPath)</LibraryPath>
|
||||
<TargetName>huagaotwain100.ds</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
|
@ -56,6 +57,7 @@
|
|||
<OutDir>$(SolutionDir)..\..\release\win\$(PlatformTarget)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)..\..\tmp\$(PlatformTarget)\$(Configuration)\$(ProjectName)\</IntDir>
|
||||
<LibraryPath>$(LibraryPath)</LibraryPath>
|
||||
<TargetName>huagaotwain100.ds</TargetName>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
|
@ -77,10 +79,11 @@
|
|||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>mkdir $(SolutionDir)..\..\sdk\lib\win\$(PlatformTarget)\$(Configuration)
|
||||
move /Y "$(OutDirFullPath)$(ProjectName).exp" "$(SolutionDir)..\..\sdk\lib\win\$(PlatformTarget)\$(Configuration)"
|
||||
move /Y "$(OutDirFullPath)$(ProjectName).lib" "$(SolutionDir)..\..\sdk\lib\win\$(PlatformTarget)\$(Configuration)"
|
||||
move /Y "$(OutDirFullPath)$(ProjectName).pdb" "$(SolutionDir)..\..\sdk\lib\win\$(PlatformTarget)\$(Configuration)"
|
||||
copy $(TargetPath) $(WinDir)\twain_32\HuaGoScan\huagaotwain.ds /y</Command>
|
||||
move /Y "$(OutDirFullPath)$(TargetName).exp" "$(SolutionDir)..\..\sdk\lib\win\$(PlatformTarget)\$(Configuration)"
|
||||
move /Y "$(OutDirFullPath)$(TargetName).lib" "$(SolutionDir)..\..\sdk\lib\win\$(PlatformTarget)\$(Configuration)"
|
||||
move /Y "$(OutDirFullPath)$(TargetName).pdb" "$(SolutionDir)..\..\sdk\lib\win\$(PlatformTarget)\$(Configuration)"
|
||||
move /Y "$(TargetPath)" "$(OutDirFullPath)$(TargetName)"
|
||||
copy "$(OutDirFullPath)$(TargetName)" "$(WinDir)\twain_32\HuaGoScan" /y</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
|
@ -106,10 +109,10 @@ copy $(TargetPath) $(WinDir)\twain_32\HuaGoScan\huagaotwain.ds /y</Command>
|
|||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>mkdir $(SolutionDir)..\..\sdk\lib\win\$(PlatformTarget)\$(Configuration)
|
||||
move /Y "$(OutDirFullPath)$(ProjectName).exp" "$(SolutionDir)..\..\sdk\lib\win\$(PlatformTarget)\$(Configuration)"
|
||||
move /Y "$(OutDirFullPath)$(ProjectName).lib" "$(SolutionDir)..\..\sdk\lib\win\$(PlatformTarget)\$(Configuration)"
|
||||
move /Y "$(OutDirFullPath)$(ProjectName).pdb" "$(SolutionDir)..\..\sdk\lib\win\$(PlatformTarget)\$(Configuration)"
|
||||
copy $(TargetPath) $(WinDir)\twain_32\HuaGoScan\$(ProjectName).ds /y</Command>
|
||||
move /Y "$(OutDirFullPath)$(TargetName).exp" "$(SolutionDir)..\..\sdk\lib\win\$(PlatformTarget)\$(Configuration)"
|
||||
move /Y "$(OutDirFullPath)$(TargetName).lib" "$(SolutionDir)..\..\sdk\lib\win\$(PlatformTarget)\$(Configuration)"
|
||||
move /Y "$(OutDirFullPath)$(TargetName).pdb" "$(SolutionDir)..\..\sdk\lib\win\$(PlatformTarget)\$(Configuration)"
|
||||
move /Y "$(TargetPath)" "$(OutDirFullPath)$(TargetName)"</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
|
|
Loading…
Reference in New Issue