Skip to content

Commit

Permalink
refactor: put version string in WeaselConstants.h
Browse files Browse the repository at this point in the history
rearranged header files:

WeaselVersion.h -> WeaselConstants.h
WeaselCommon.h -> WeaselConstants.h, WeaselIPCData.h
  • Loading branch information
lotem committed Apr 28, 2024
1 parent 6102957 commit c787edd
Show file tree
Hide file tree
Showing 27 changed files with 74 additions and 85 deletions.
2 changes: 1 addition & 1 deletion RimeWithWeasel/RimeWithWeasel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#include <logging.h>
#include <RimeWithWeasel.h>
#include <StringAlgorithm.hpp>
#include <WeaselConstants.h>
#include <WeaselUtility.h>
#include <WeaselVersion.h>

#include <filesystem>
#include <map>
Expand Down
4 changes: 2 additions & 2 deletions WeaselDeployer/Configurator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
#include "UIStyleSettings.h"
#include "UIStyleSettingsDialog.h"
#include "DictManagementDialog.h"
#include <WeaselCommon.h>
#include <WeaselConstants.h>
#include <WeaselIPC.h>
#include <WeaselIPCData.h>
#include <WeaselUtility.h>
#include <WeaselVersion.h>
#pragma warning(disable : 4005)
#include <rime_api.h>
#include <rime_levers_api.h>
Expand Down
Binary file modified WeaselDeployer/WeaselDeployer.rc
Binary file not shown.
6 changes: 3 additions & 3 deletions WeaselIME/WeaselIME.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
//

#include "stdafx.h"
#include <algorithm>
#include <strsafe.h>
#include <StringAlgorithm.hpp>
#include <WeaselCommon.h>
#include <ResponseParser.h>
#include <StringAlgorithm.hpp>
#include <WeaselConstants.h>
#include "WeaselIME.h"
#include <algorithm>

// logging disabled
#define EZDBGONLYLOGGERVAR(...)
Expand Down
Binary file modified WeaselIME/WeaselIME.rc
Binary file not shown.
1 change: 1 addition & 0 deletions WeaselServer/WeaselTrayIcon.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "stdafx.h"
#include "WeaselTrayIcon.h"
#include <WeaselConstants.h>

// nasty
#include <resource.h>
Expand Down
Binary file modified WeaselSetup/WeaselSetup.rc
Binary file not shown.
4 changes: 2 additions & 2 deletions WeaselSetup/imesetup.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#include "stdafx.h"
#include <string>
#include <vector>
#include <StringAlgorithm.hpp>
#include <WeaselCommon.h>
#include <msctf.h>
#include <strsafe.h>
#include <StringAlgorithm.hpp>
#include <WeaselConstants.h>
#include <WeaselUtility.h>
#include "InstallOptionsDlg.h"

Expand Down
4 changes: 2 additions & 2 deletions WeaselTSF/Globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#pragma once

#include "stdafx.h"
#include <WeaselCommon.h>
#include <WeaselConstants.h>

#define TEXTSERVICE_LANGID_HANT \
MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_TRADITIONAL)
Expand All @@ -14,7 +14,7 @@
#define TEXTSERVICE_LANGID MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED)

#define TEXTSERVICE_DESC WEASEL_IME_NAME
#define TEXTSERVICE_DESC_A "Weasel"
#define TEXTSERVICE_DESC_A WEASEL_CODE_NAME
#define TEXTSERVICE_MODEL "Apartment"

#define TEXTSERVICE_ICON_INDEX 0
Expand Down
2 changes: 1 addition & 1 deletion WeaselTSF/WeaselTSF.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "stdafx.h"

#include <WeaselIPCData.h>
#include "WeaselTSF.h"
#include "WeaselCommon.h"
#include "CandidateList.h"
#include "LanguageBar.h"
#include "Compartment.h"
Expand Down
4 changes: 2 additions & 2 deletions WeaselTSF/WeaselTSF.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#pragma once

#include <WeaselCommon.h>
#include "Globals.h"
#include "WeaselIPC.h"
#include <WeaselIPC.h>
#include <WeaselIPCData.h>

class CCandidateList;
class CLangBarItemButton;
Expand Down
Binary file modified WeaselTSF/WeaselTSF.rc
Binary file not shown.
2 changes: 1 addition & 1 deletion WeaselUI/Layout.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include <WeaselCommon.h>
#include <WeaselIPCData.h>
#include <WeaselUI.h>
#include <gdiplus.h>

Expand Down
8 changes: 5 additions & 3 deletions WeaselUI/WeaselPanel.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#include "stdafx.h"
#include <utility>
#include "WeaselPanel.h"
#include <WeaselCommon.h>

#include <utility>
#include <ShellScalingApi.h>
#include "VersionHelpers.hpp"
#include <VersionHelpers.hpp>
#include <WeaselIPCData.h>

#include "VerticalLayout.h"
#include "HorizontalLayout.h"
#include "FullScreenLayout.h"
Expand Down
2 changes: 1 addition & 1 deletion WeaselUI/WeaselPanel.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#pragma once
#include <WeaselCommon.h>
#include <WeaselIPCData.h>
#include <WeaselUI.h>
#include "StandardLayout.h"
#include "Layout.h"
Expand Down
3 changes: 1 addition & 2 deletions WeaselUI/WeaselUI.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,6 @@
<ClInclude Include="StandardLayout.h" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
<ClInclude Include="..\include\WeaselCommon.h" />
<ClInclude Include="VerticalLayout.h" />
<ClInclude Include="VHorizontalLayout.h" />
<ClInclude Include="WeaselPanel.h" />
Expand All @@ -527,4 +526,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
5 changes: 1 addition & 4 deletions WeaselUI/WeaselUI.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@
<ClInclude Include="targetver.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\include\WeaselCommon.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="WeaselPanel.h">
<Filter>Header Files</Filter>
</ClInclude>
Expand Down Expand Up @@ -96,4 +93,4 @@
<ItemGroup>
<None Include="ReadMe.txt" />
</ItemGroup>
</Project>
</Project>
55 changes: 25 additions & 30 deletions build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -6,43 +6,34 @@ if not exist env.bat copy env.bat.template env.bat

if exist env.bat call env.bat

if not defined WEASEL_BUILD set WEASEL_BUILD=0
if not defined WEASEL_ROOT set WEASEL_ROOT=%CD%

if not defined VERSION_MAJOR set VERSION_MAJOR=0
if not defined VERSION_MINOR set VERSION_MINOR=15
if not defined VERSION_PATCH set VERSION_PATCH=0
if not defined WEASEL_VERSION set WEASEL_VERSION=%VERSION_MAJOR%.%VERSION_MINOR%.%VERSION_PATCH%

rem check if git is installed and available, then get the short commit id of head
git --version >nul 2>&1
if not errorlevel 1 (
rem get short commmit id of head
for /F %%i in ('git rev-parse --short HEAD') do (set commitid=%%i)
)
if not defined WEASEL_VERSION set WEASEL_VERSION=%VERSION_MAJOR%.%VERSION_MINOR%.%VERSION_PATCH%
if not defined WEASEL_BUILD set WEASEL_BUILD=0

if not defined RELEASE_BUILD (
if defined commitid (
rem if git is available and RELEASE_BUILD is not defined, then use commitid in the PROCDUCT_VERSION
rem for local build with git installed, when RELASE_BUILD usually not defined during local build
rem or github action nightly build/commit ci build, when RELEASE_BUILD is not defined, and git installed
if not defined PRODUCT_VERSION set PRODUCT_VERSION="%VERSION_MAJOR%.%VERSION_MINOR%.%VERSION_PATCH%-%commitid%"
) else (
rem if git is not available, then use pure number in the PRODUCT_VERSION
rem for local build without git, when RELEASE_BUILD usually not defined during local build
if not defined PRODUCT_VERSION set PRODUCT_VERSION="%VERSION_MAJOR%.%VERSION_MINOR%.%VERSION_PATCH%.%WEASEL_BUILD%"
if not defined PRODUCT_VERSION (
rem use numeric build version for release build
set PRODUCT_VERSION=%WEASEL_VERSION%.%WEASEL_BUILD%
rem for non-release build, try to use git commit hash as product build version
if not defined RELEASE_BUILD (
rem check if git is installed and available, then get the short commit id of head
git --version >nul 2>&1
if not errorlevel 1 (
rem get short commmit id of head
for /F %%i in ('git rev-parse --short HEAD') do (set PRODUCT_VERSION=%WEASEL_VERSION%-%%i)
)
)
) else (
rem if RELEASE_BUILD is defined, then use pure number in the PRODUCT_VERSION
rem this usually happens in github action release build
if not defined PRODUCT_VERSION set PRODUCT_VERSION="%VERSION_MAJOR%.%VERSION_MINOR%.%VERSION_PATCH%.%WEASEL_BUILD%"
)
rem set FILE_VERSION always to the same as PRODUCT_VERSION when RELEASE_BUILD
if not defined FILE_VERSION set FILE_VERSION=%VERSION_MAJOR%.%VERSION_MINOR%.%VERSION_PATCH%.%WEASEL_BUILD%

echo WEASEL_VERSION=%WEASEL_VERSION%
echo FILE_VERSION=%FILE_VERSION%
rem FILE_VERSION is always 4 numbers; same as PRODUCT_VERSION in release build
if not defined FILE_VERSION set FILE_VERSION=%WEASEL_VERSION%.%WEASEL_BUILD%

echo PRODUCT_VERSION=%PRODUCT_VERSION%
echo WEASEL_VERSION=%WEASEL_VERSION%
echo WEASEL_BUILD=%WEASEL_BUILD%
echo WEASEL_ROOT=%WEASEL_ROOT%
echo WEASEL_BUNDLED_RECIPES=%WEASEL_BUNDLED_RECIPES%
Expand Down Expand Up @@ -185,11 +176,15 @@ if %build_weasel% == 0 goto end

cd /d %WEASEL_ROOT%

set WEASEL_PROJECT_PROPERTIES=BOOST_ROOT PLATFORM_TOOLSET
set WEASEL_PROJECT_PROPERTIES=BOOST_ROOT^
PLATFORM_TOOLSET^
VERSION_MAJOR^
VERSION_MINOR^
VERSION_PATCH^
PRODUCT_VERSION^
FILE_VERSION

if not exist weasel.props (
cscript.exe render.js weasel.props %WEASEL_PROJECT_PROPERTIES%
)
cscript.exe render.js weasel.props %WEASEL_PROJECT_PROPERTIES%

del msbuild*.log

Expand Down
2 changes: 1 addition & 1 deletion include/ResponseParser.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#pragma once
#include <WeaselCommon.h>
#include <WeaselIPCData.h>
#include <windows.h>
#include <map>
#include <memory>
Expand Down
10 changes: 10 additions & 0 deletions include/WeaselConstants.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#pragma once

#define WEASEL_CODE_NAME "Weasel"
#define WEASEL_IME_NAME L"小狼毫"
#define WEASEL_REG_KEY L"Software\\Rime\\Weasel"
#define RIME_REG_KEY L"Software\\Rime"

#define STRINGIZE(x) #x
#define VERSION_STR(x) STRINGIZE(x)
#define WEASEL_VERSION VERSION_STR(VERSION_MAJOR.VERSION_MINOR.VERSION_PATCH)
2 changes: 1 addition & 1 deletion include/WeaselIPC.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#pragma once
#include <WeaselCommon.h>
#include <WeaselIPCData.h>
#include <WeaselUtility.h>
#include <windows.h>
#include <functional>
Expand Down
11 changes: 2 additions & 9 deletions include/WeaselCommon.h → include/WeaselIPCData.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
#pragma once

// #include <string>
// #include <vector>
#include <string>
#include <vector>
#include <boost/serialization/vector.hpp>
#include <boost/serialization/string.hpp>

#define WEASEL_IME_NAME L"小狼毫"
#define WEASEL_REG_KEY L"Software\\Rime\\Weasel"
#define RIME_REG_KEY L"Software\\Rime"

// #define USE_SHARP_COLOR_CODE

// #define _DEBUG_
namespace weasel {

enum TextAttributeType { NONE = 0, HIGHLIGHTED, LAST_TYPE };
Expand Down
2 changes: 1 addition & 1 deletion include/WeaselUI.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include <WeaselCommon.h>
#include <WeaselIPCData.h>
#include <vector>
#include <regex>
#include <iterator>
Expand Down
7 changes: 0 additions & 7 deletions include/WeaselVersion.h

This file was deleted.

2 changes: 1 addition & 1 deletion output/install.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Unicode true
; General

!ifndef WEASEL_VERSION
!define WEASEL_VERSION 1.0.0
!define WEASEL_VERSION 0.1.0
!endif

!ifndef WEASEL_BUILD
Expand Down
17 changes: 8 additions & 9 deletions weasel.props.template
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,11 @@
<PropertyGroup Label="UserMacros">
<BOOST_ROOT>$BOOST_ROOT</BOOST_ROOT>
<PLATFORM_TOOLSET>$PLATFORM_TOOLSET</PLATFORM_TOOLSET>
</PropertyGroup>
<PropertyGroup>
<_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>
<_PropertySheetDisplayName>Weasel Project Properties</_PropertySheetDisplayName>
<VERSION_MAJOR Condition="'$(VERSION_MAJOR)' == ''">0</VERSION_MAJOR>
<VERSION_MINOR Condition="'$(VERSION_MINOR)' == ''">15</VERSION_MINOR>
<VERSION_PATCH Condition="'$(VERSION_PATCH)' == ''">0</VERSION_PATCH>
<PRODUCT_VERSION Condition="'$(PRODUCT_VERSION)' == ''">0.15.0.0</PRODUCT_VERSION>
<FILE_VERSION Condition="'$(FILE_VERSION)' == ''">0.15.0.0</FILE_VERSION>
<VERSION_MAJOR>$VERSION_MAJOR</VERSION_MAJOR>
<VERSION_MINOR>$VERSION_MINOR</VERSION_MINOR>
<VERSION_PATCH>$VERSION_PATCH</VERSION_PATCH>
<PRODUCT_VERSION>$PRODUCT_VERSION</PRODUCT_VERSION>
<FILE_VERSION>$FILE_VERSION</FILE_VERSION>
</PropertyGroup>
<ItemGroup>
<BuildMacro Include="BOOST_ROOT">
Expand All @@ -24,6 +20,9 @@
</BuildMacro>
</ItemGroup>
<ItemDefinitionGroup>
<ClCompile>
<PreprocessorDefinitions>$(PreprocessorDefinitions);VERSION_MAJOR=$(VERSION_MAJOR);VERSION_MINOR=$(VERSION_MINOR);VERSION_PATCH=$(VERSION_PATCH);</PreprocessorDefinitions>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>$(PreprocessorDefinitions);VERSION_MAJOR=$(VERSION_MAJOR);VERSION_MINOR=$(VERSION_MINOR);VERSION_PATCH=$(VERSION_PATCH);PRODUCT_VERSION=$(PRODUCT_VERSION);FILE_VERSION=$(FILE_VERSION);</PreprocessorDefinitions>
</ResourceCompile>
Expand Down
4 changes: 2 additions & 2 deletions weasel.sln
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
include\RimeWithWeasel.h = include\RimeWithWeasel.h
include\StringAlgorithm.hpp = include\StringAlgorithm.hpp
include\VersionHelpers.hpp = include\VersionHelpers.hpp
include\WeaselCommon.h = include\WeaselCommon.h
include\WeaselConstants.h = include\WeaselConstants.h
include\WeaselIPC.h = include\WeaselIPC.h
include\WeaselIPCData.h = include\WeaselIPCData.h
include\WeaselUI.h = include\WeaselUI.h
include\WeaselUtility.h = include\WeaselUtility.h
include\WeaselVersion.h = include\WeaselVersion.h
include\winapifamily.h = include\winapifamily.h
include\winpackagefamily.h = include\winpackagefamily.h
EndProjectSection
Expand Down

0 comments on commit c787edd

Please sign in to comment.