-
Notifications
You must be signed in to change notification settings - Fork 5
Language settings autoupdate #63
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
base: main
Are you sure you want to change the base?
Changes from 10 commits
d7a37e8
be29fa1
c840b7d
f695a26
1eb084e
75993c7
7bf3523
90868ce
8931e31
2798b44
e45599d
c9ea647
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| #include <Windows.h> | ||
|
|
||
| /* UTF-8 */ | ||
| #pragma code_page(65001) | ||
|
|
||
|
|
||
| 18000 STRS | ||
| BEGIN | ||
| 3 + 1, /* VERSION_APPENDIX length */ | ||
| 0 | ||
| "@addOnLanguage@" "\0" /* Version appendix for localized data */ | ||
| END | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,9 @@ | |
| import zipfile | ||
| import tarfile | ||
|
|
||
| from LocalizationMappingTable import FillLocalizationMappingTable | ||
|
|
||
|
|
||
| def ParseArguments (): | ||
| parser = argparse.ArgumentParser () | ||
| parser.add_argument ('-c', '--configFile', dest = 'configFile', required = True, help = 'JSON Configuration file') | ||
|
|
@@ -206,16 +209,22 @@ def GetProjectGenerationParams (args, workspaceRootFolder, buildPath, platformNa | |
| '-B', str (buildPath) | ||
| ] | ||
|
|
||
| devkitDir = devKitFolder / "Support" | ||
| if platformName == 'WIN': | ||
| projGenParams.extend ([ | ||
| '-G', GetInstalledVisualStudioGenerator (), | ||
| '-T', GetToolset (int (version)), | ||
| ]) | ||
| localizationMappingTable = FillLocalizationMappingTable (devkitDir) | ||
| winLangCharsetStr = '040904b0' | ||
vmihalyi-graphisoft marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if languageCode != 'INT': | ||
| winLangCharsetStr = localizationMappingTable.get (languageCode, winLangCharsetStr) | ||
| projGenParams.append (f'-DAC_WIN_LANGCHARSET_STR={winLangCharsetStr}') | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know it comes from the header, but I don't like this |
||
| elif platformName == 'MAC': | ||
| projGenParams.append ('-GXcode') | ||
|
|
||
| projGenParams.append (f'-DAC_VERSION={version}') | ||
| projGenParams.append (f'-DAC_API_DEVKIT_DIR={str (devKitFolder / "Support")}') | ||
| projGenParams.append (f'-DAC_API_DEVKIT_DIR={str (devkitDir)}') | ||
| projGenParams.append (f'-DAC_ADDON_LANGUAGE={languageCode}') | ||
|
|
||
| if release: | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -126,7 +126,7 @@ function (parse_version inValue outList) | |||||||||||||||||||
| endif () | ||||||||||||||||||||
| endfunction () | ||||||||||||||||||||
|
|
||||||||||||||||||||
| function (generate_add_on_version_info outSemver) | ||||||||||||||||||||
| function (generate_add_on_version_info outSemver addOnLanguage) | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since the function is internal I almost feel like this parameter can be omitted, since it's present in the calling context anyway. Either that or move it before the out parameter. |
||||||||||||||||||||
| parse_version ("${addOnVersion}" vers) | ||||||||||||||||||||
| if (NOT DEFINED vers) | ||||||||||||||||||||
| message (FATAL_ERROR "'${addOnVersion}' does not follow the '123' or '1.23' or '1.2.3' version format.") | ||||||||||||||||||||
|
|
@@ -149,9 +149,21 @@ function (generate_add_on_version_info outSemver) | |||||||||||||||||||
|
|
||||||||||||||||||||
| string (REGEX REPLACE [[(\\|")]] [[\\\1]] addOnDescription "${addOnDescription}") | ||||||||||||||||||||
|
|
||||||||||||||||||||
| if (autoupdate STREQUAL "1") | ||||||||||||||||||||
| set (autoupdate "\n\t\t\tVALUE \"Autoupdate\", \"1\"") | ||||||||||||||||||||
| else () | ||||||||||||||||||||
| set (autoupdate "") | ||||||||||||||||||||
| endif () | ||||||||||||||||||||
|
Comment on lines
+152
to
+156
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
In the other places as well. |
||||||||||||||||||||
|
|
||||||||||||||||||||
| set (winLangCharsetStr "${AC_WIN_LANGCHARSET_STR}") | ||||||||||||||||||||
|
|
||||||||||||||||||||
| set (out "${CMAKE_CURRENT_BINARY_DIR}/${target}-VersionInfo.rc") | ||||||||||||||||||||
| configure_file ("${CMAKE_CURRENT_FUNCTION_LIST_DIR}/VersionInfo.rc.in" "${out}" @ONLY) | ||||||||||||||||||||
| target_sources ("${target}" PRIVATE "${out}") | ||||||||||||||||||||
|
|
||||||||||||||||||||
| set (addOnRes "${CMAKE_CURRENT_BINARY_DIR}/${target}-AddOn.rc") | ||||||||||||||||||||
| configure_file ("${CMAKE_CURRENT_FUNCTION_LIST_DIR}/AddOn.rc.in" "${addOnRes}" @ONLY) | ||||||||||||||||||||
|
|
||||||||||||||||||||
| target_sources ("${target}" PRIVATE "${out}" "${addOnRes}") | ||||||||||||||||||||
|
Comment on lines
160
to
+166
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Turn this into a loop with |
||||||||||||||||||||
| else () | ||||||||||||||||||||
| # BE on the safe side; load the info from an existing framework | ||||||||||||||||||||
| file (READ "${devKitDir}/Frameworks/GSRoot.framework/Versions/A/Resources/Info.plist" plist_content NEWLINE_CONSUME) | ||||||||||||||||||||
|
|
@@ -172,11 +184,19 @@ function (generate_add_on_version_info outSemver) | |||||||||||||||||||
| string (REPLACE ' &apos\; addOnDescription "${addOnDescription}") | ||||||||||||||||||||
| string (REPLACE \" "\; addOnDescription "${addOnDescription}") | ||||||||||||||||||||
|
|
||||||||||||||||||||
| set (languageCode "${addOnLanguage}") | ||||||||||||||||||||
|
|
||||||||||||||||||||
| set (privateBuild "\n\t\t<key>GSPrivateBuild</key>\n\t\t<string>1</string>") | ||||||||||||||||||||
| if (NOT AC_ADDON_FOR_DISTRIBUTION) | ||||||||||||||||||||
| set (privateBuild "") | ||||||||||||||||||||
| endif () | ||||||||||||||||||||
|
|
||||||||||||||||||||
| if (autoupdate STREQUAL "1") | ||||||||||||||||||||
| set (autoupdate "\n\t\t<key>autoupdate</key>\n\t\t<string>1</string>") | ||||||||||||||||||||
| else () | ||||||||||||||||||||
| set (autoupdate "") | ||||||||||||||||||||
| endif () | ||||||||||||||||||||
|
|
||||||||||||||||||||
| string (TOLOWER "${addOnName}" lowerAddOnName) | ||||||||||||||||||||
| string (REGEX REPLACE "[ _]" "-" addOnNameIdentifier "${lowerAddOnName}") | ||||||||||||||||||||
| set (bundleIdentifier "com.graphisoft.${addOnNameIdentifier}") | ||||||||||||||||||||
|
|
@@ -347,7 +367,7 @@ function (GenerateAddOnProject target acVersion devKitDir addOnSourcesFolder add | |||||||||||||||||||
| ) | ||||||||||||||||||||
| endif () | ||||||||||||||||||||
| endif () | ||||||||||||||||||||
| generate_add_on_version_info (semver) | ||||||||||||||||||||
| generate_add_on_version_info (semver ${addOnLanguage}) | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer |
||||||||||||||||||||
| target_compile_definitions ( | ||||||||||||||||||||
| "${target}" PRIVATE | ||||||||||||||||||||
| "ADDON_VERSION=\"${semver}\"" | ||||||||||||||||||||
|
|
@@ -416,9 +436,9 @@ function (ReadConfigJson) | |||||||||||||||||||
| set ("${out}" "${${out}}" PARENT_SCOPE) | ||||||||||||||||||||
| endforeach () | ||||||||||||||||||||
|
|
||||||||||||||||||||
| # optional members (macOS code signing for start) | ||||||||||||||||||||
| set (optionalMembers codesignIdentity developmentTeamId) | ||||||||||||||||||||
| set (returnAs codesignIdentity developmentTeamId) | ||||||||||||||||||||
| # optional members (macOS code signing for start, autoupdate next) | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove the comment here and below for the language list. |
||||||||||||||||||||
| set (optionalMembers codesignIdentity developmentTeamId autoupdate) | ||||||||||||||||||||
| set (returnAs codesignIdentity developmentTeamId autoupdate) | ||||||||||||||||||||
| foreach (out members IN ZIP_LISTS returnAs optionalMembers) | ||||||||||||||||||||
| string (JSON "${out}" ERROR_VARIABLE error GET "${json}" ${members}) | ||||||||||||||||||||
| if (error) | ||||||||||||||||||||
|
|
||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import platform | ||
| import re | ||
|
|
||
|
|
||
| def FillLocalizationMappingTable (devKitPath) -> str: | ||
|
||
| # Dynamically generate a mapping table from GSLocalization.h | ||
| pattern = None | ||
| system = platform.system () | ||
| if system == 'Windows': | ||
| pattern = r'#define\s+VERSION_APPENDIX\s+"([A-Z]+)"[\s\S]*?#define\s+WIN_LANGCHARSET_STR\s+"([^"]+)"' | ||
| elif system == 'Darwin': | ||
| pattern = r'#define\s+VERSION_APPENDIX\s+"([A-Z]+)"[\s\S]*?#define\s+MAC_REGION_NAME\s+"([^"]+)"' | ||
|
|
||
| assert pattern, 'Platform is not supported' | ||
|
|
||
| gsLocalizationPath = devKitPath / 'Inc' / 'GSLocalization.h' | ||
| with open(gsLocalizationPath, 'r', encoding='utf-8') as f: | ||
| gsLocalizationContent = f.read () | ||
|
|
||
| if not pattern: | ||
|
||
| return {} | ||
|
|
||
| patternRegex = re.compile (pattern, re.MULTILINE) | ||
| return { m.group(1): m.group(2) for m in patternRegex.finditer (gsLocalizationContent) } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer 4 spaces to be in line with
VersionInfo.rc.in.That stray
0looks odd. Doesn't look like anything in the documentation https://learn.microsoft.com/en-us/windows/win32/menurc/user-defined-resourcePrefer to do the length calculation for the string in CMake.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.