Skip to content

Commit

Permalink
Merge pull request #69 from springcomp/strict_compliance
Browse files Browse the repository at this point in the history
Strict compliance
  • Loading branch information
springcomp authored Jun 15, 2019
2 parents 722c55e + 20a3150 commit 4e36676
Show file tree
Hide file tree
Showing 9 changed files with 1,116 additions and 71 deletions.
939 changes: 939 additions & 0 deletions KBFRZ71N.klc

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ before_build:

build_script:
- ps: Set-Content -Path ".\src\KBFRZ71.klc" -Encoding Unicode -Value (Get-Content -Path ".\KBFRZ71.klc" -Raw -Encoding UTF8)
- ps: Set-Content -Path ".\src\KBFRZ71N.klc" -Encoding Unicode -Value (Get-Content -Path ".\KBFRZ71N.klc" -Raw -Encoding UTF8)
- ps: |
docker run `
--rm `
Expand Down
191 changes: 134 additions & 57 deletions context/Make-KeyboardLayout.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,139 @@ BEGIN {
Write-Output $result
}

Function Build-Layout {
param(
[string] $name
)

BEGIN {

Function Compile-Layout {
param(
[string] $name,
[string] $option,
[string] $target,
[switch] $quiet = $false
)

$expression = "C:\MSKLC\bin\i386\kbdutool.exe -v -w -u $option `"$name.klc`""
Invoke-Expression -Command $expression | ? {
-not $_.Contains("can't open for write.")
} | % {
if (-not $quiet.IsPresent) {
Write-Host $_
}
}

New-Item -Path $target -ItemType Directory -EA SilentlyContinue | Out-Null
Move-Item -Path "$name.DLL" -Destination $target -Force
}

Function Make-Readonly {
param(
[string] $name,
[switch] $readwrite = $false
)
if ($readwrite.IsPresent) {
attrib -R "$name.C"
attrib -R "$name.H"
attrib -R "$name.RC"
attrib -R "$name.DEF"
}
else {
attrib +R "$name.C"
attrib +R "$name.H"
attrib +R "$name.RC"
attrib +R "$name.DEF"
}
}

$x86 = ".\Package_x86\bin\"
$x64 = ".\Package_x64\bin\"
}

PROCESS {

## Protect the files to prevent kbdutool from overwriting them

Make-ReadOnly -Name $name

## Only the last group of commands report
## warnings an errors feedback in the output

Compile-Layout -Name $name -Option "-x" -Target $x86 -Quiet
Compile-Layout -Name $name -Option "-m" -Target $x64

Make-Readonly -Name $name -ReadWrite
}
}

Function Fix-Encoding {
param(
[string] $name
)

PROCESS {

Set-Content -Path "$name.C" -Encoding UTF8 -Value `
(Get-Content `
-Path "$name.C" `
-Encoding UTF8 `
-Raw).Replace(
"", "é"
).Replace(
"échap", "Échap"
)

}
}

Function Patch-Version {
param(
[string] $name,
[string] $version
)

BEGIN {

$defaultVersion = "1.0.3.40"
$defCommas = Make-Version -Number $defaultVersion
$defSpaces = Make-Version -Number $defaultVersion -Spaces

$requestedVersion = $version
$reqCommas = Make-Version -Number $requestedVersion
$reqSpaces = Make-Version -Number $requestedVersion -Spaces

}

PROCESS {

Set-Content -Path "$name.RC" -Encoding Unicode -Value `
(Get-Content `
-Path "$name.RC" `
-Encoding Unicode `
-Raw).Replace(
" (3.40)", ""
).Replace(
$defCommas, $reqCommas
).Replace(
$defSpaces, $reqSpaces
)
}
}

## This scripts accepts an argument
## for testing purposes
## When launched from a Docker container
## via AppVeyor, we use an environment
## variable to specify our requested version number.

if ($version = "1.0.3.40"){
if ($version -eq "1.0.3.40") {
$version = $Env:KBFRZ71_VERSION
if (-not $version){
if (-not $version) {
$version = "1.0.3.40"
}
}

}

PROCESS {
Expand All @@ -50,70 +170,27 @@ PROCESS {
## First create C source file

C:\MSKLC\bin\i386\kbdutool.exe -u -s KBFRZ71.klc | Out-Null
C:\MSKLC\bin\i386\kbdutool.exe -u -s KBFRZ71N.klc | Out-Null

## Restore corrupted accented characters

Set-Content -Path KBFRZ71.C -Encoding UTF8 -Value `
(Get-Content `
-Path KBFRZ71.C `
-Encoding UTF8 `
-Raw).Replace(
"", "é"
).Replace(
"échap", "Échap"
)
Fix-Encoding -Name KBFRZ71
Fix-Encoding -Name KBFRZ71N

## Update version in RC source file
## MSKLC creates a DLL with version fixed to 1.0.3.40.
## We need to patch the file to update our version

$defaultVersion = "1.0.3.40"
$defCommas = Make-Version -Number $defaultVersion
$defSpaces = Make-Version -Number $defaultVersion -Spaces

$requestedVersion = $version
$reqCommas = Make-Version -Number $requestedVersion
$reqSpaces = Make-Version -Number $requestedVersion -Spaces

Set-Content -Path KBFRZ71.RC -Encoding Unicode -Value `
(Get-Content `
-Path .\KBFRZ71.RC `
-Encoding Unicode `
-Raw).Replace(
"kbfrz71 (3.40)", "kbfrz71"
).Replace(
$defCommas, $reqCommas
).Replace(
$defSpaces, $reqSpaces
)

## Protect the files to prevent kbdutool from overwriting them
Patch-Version -Name KBFRZ71 -Version $version
Patch-Version -Name KBFRZ71N -Version $version

attrib +R KBFRZ71.C
attrib +R KBFRZ71.H
attrib +R KBFRZ71.RC
attrib +R KBFRZ71.DEF
Build-Layout -Name KBFRZ71
Build-Layout -Name KBFRZ71N

## Only the last group of commands report
## warnings an errors feedback in the output

C:\MSKLC\bin\i386\kbdutool.exe -v -w -u -x KBFRZ71.klc | ? { -not $_.Contains("can't open for write.") } | Out-Null
New-Item -Path Package_x86\bin -ItemType Directory | Out-Null
Move-Item -Path KBFRZ71.DLL -Destination Package_x86\bin -Force

C:\MSKLC\bin\i386\kbdutool.exe -v -w -u -m KBFRZ71.klc | ? { -not $_.Contains("can't open for write.") }
New-Item -Path Package_x64\bin -ItemType Directory | Out-Null
Move-Item -Path KBFRZ71.DLL -Destination Package_x64\bin -Force

attrib -R KBFRZ71.C
attrib -R KBFRZ71.H
attrib -R KBFRZ71.RC
attrib -R KBFRZ71.DEF

Remove-Item -Path KBFRZ71.C
Remove-Item -Path KBFRZ71.H
Remove-Item -Path KBFRZ71.RC
Remove-Item -Path KBFRZ71.DEF
##Remove-Item -Path KBFRZ71.C
##Remove-Item -Path KBFRZ71.H
##Remove-Item -Path KBFRZ71.RC
##Remove-Item -Path KBFRZ71.DEF

## Copy MSKLC KbdMsi.dll used as Windows Installer custom actions
## in the resulting .MSI packages
Expand Down
2 changes: 1 addition & 1 deletion src/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
*.C
*.H
*.DEF
*.RES
*.RC
4 changes: 4 additions & 0 deletions src/Package_x86/Components_x64.wxi
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@
<File Id="File.x64.KBFRZ71.dll" Source="$(var.Setup.ProjectDir)..\Package_x64\bin\KBFRZ71.dll" KeyPath="yes" />
</Component>

<Component Id="Component.x64.KBFRZ71" Guid="F6822B98-F9A6-4CC5-B9D6-6B8BEB1A7A9C" Win64="yes">
<File Id="File.x64.KBFRZ71N.dll" Source="$(var.Setup.ProjectDir)..\Package_x64\bin\KBFRZ71N.dll" KeyPath="yes" />
</Component>

</Include>
5 changes: 5 additions & 0 deletions src/Package_x86/Components_x86.wxi
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,9 @@
<File Id="File.x86.KBFRZ71.dll" Source="$(var.Setup.ProjectDir)..\Package_x86\bin\KBFRZ71.dll" KeyPath="yes" />
</Component>

<Component Id="Component.x86.KBFRZ71" Guid="16194ADD-6F99-4CB6-B6D2-5233D8549BFF" Win64="no">
<Condition><![CDATA[ 1 = 1 ]]></Condition>
<File Id="File.x86.KBFRZ71N.dll" Source="$(var.Setup.ProjectDir)..\Package_x86\bin\KBFRZ71N.dll" KeyPath="yes" />
</Component>

</Include>
10 changes: 8 additions & 2 deletions src/Package_x86/CustomAction.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,24 @@

<?if $(var.Platform) = x64 ?>

<CustomAction Id="SetFilePath.x64" Property="RegisterKeyboard" Value="[#File.x64.KBFRZ71.dll]|[LCIDValue]" Execute="immediate" />
<CustomAction Id="SetFilePath.x64_caps" Property="RegisterKeyboard_caps" Value="[#File.x64.KBFRZ71.dll]|[LCIDValue]" Execute="immediate" />
<CustomAction Id="SetFilePath.x64" Property="RegisterKeyboard" Value="[#File.x64.KBFRZ71N.dll]|[LCIDValue]" Execute="immediate" />

<?else?>

<CustomAction Id="SetFilePath.x86" Property="RegisterKeyboard" Value="[#File.x86.KBFRZ71.dll]|[LCIDValue]" Execute="immediate" />
<CustomAction Id="SetFilePath.x86_caps" Property="RegisterKeyboard_caps" Value="[#File.x86.KBFRZ71.dll]|[LCIDValue]" Execute="immediate" />
<CustomAction Id="SetFilePath.x86" Property="RegisterKeyboard" Value="[#File.x86.KBFRZ71N.dll]|[LCIDValue]" Execute="immediate" />

<?endif?>

<CustomAction Id="RegisterKeyboard_caps" BinaryKey="KbdMsi" DllEntry="CA01" Execute="deferred" Impersonate="no" Return="check" />
<CustomAction Id="RegisterKeyboard" BinaryKey="KbdMsi" DllEntry="CA01" Execute="deferred" Impersonate="no" Return="check" />
<CustomAction Id="UnregisterKeyboard_caps" BinaryKey="KbdMsi" DllEntry="CA02" Execute="deferred" Impersonate="no" Return="check" />
<CustomAction Id="UnregisterKeyboard" BinaryKey="KbdMsi" DllEntry="CA02" Execute="deferred" Impersonate="no" Return="check" />

<CustomAction Id="AddKeyboardToLangBar_caps" BinaryKey="KbdMsi" DllEntry="CA03" Execute="deferred" Return="check" />
<CustomAction Id="AddKeyboardToLangBar" BinaryKey="KbdMsi" DllEntry="CA03" Execute="deferred" Return="check" />
<CustomAction Id="RemoveKeyboardFromLangBar_caps" BinaryKey="KbdMsi" DllEntry="CA04" Execute="deferred" Return="check" />
<CustomAction Id="RemoveKeyboardFromLangBar" BinaryKey="KbdMsi" DllEntry="CA04" Execute="deferred" Return="check" />

<Binary Id="KbdMsi" SourceFile="$(var.Setup.ProjectDir)..\Package_x86\bin\KbdMsi.dll" />
Expand Down
3 changes: 3 additions & 0 deletions src/Package_x86/Features.wxi
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@
<Feature Id="F_CA8158D1_4371_4866_B39E_8A199A62131F" Title="AZERTY NF Z71-300 (SGCaps)" Level="1" TypicalDefault="install" InstallDefault="local" AllowAdvertise="no" Absent="disallow">
<ComponentRef Id="Component.x86.KBFRZ71_caps" />
<ComponentRef Id="Component.x64.KBFRZ71_caps" />
<ComponentRef Id="Component.x86.KBFRZ71" />
<ComponentRef Id="Component.x64.KBFRZ71" />
</Feature>

<?else?>

<Feature Id="F_CA8158D1_4371_4866_B39E_8A199A62131F" Title="AZERTY NF Z71-300 (SGCaps)" Level="1" TypicalDefault="install" InstallDefault="local" AllowAdvertise="no" Absent="disallow">
<ComponentRef Id="Component.x86.KBFRZ71_caps" />
<ComponentRef Id="Component.x86.KBFRZ71" />
</Feature>

<?endif?>
Expand Down
32 changes: 21 additions & 11 deletions src/Package_x86/InstallExecuteSequence.wxi
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,33 @@
<?if $(var.Platform) = x64 ?>

<InstallExecuteSequence>
<Custom Action="SetFilePath.x64" Sequence="4030"> <![CDATA[ 1 = 1 ]]></Custom>

<Custom Action="RemoveKeyboardFromLangBar" Sequence="4040"><![CDATA[ $Component.x64.KBFRZ71_caps = 2 ]]></Custom>
<Custom Action="UnregisterKeyboard" Sequence="4060"><![CDATA[ $Component.x64.KBFRZ71_caps = 2 ]]></Custom>
<Custom Action="RegisterKeyboard" Sequence="4050"><![CDATA[ $Component.x64.KBFRZ71_caps > 2 ]]></Custom>
<Custom Action="AddKeyboardToLangBar" Sequence="4065"><![CDATA[ $Component.x64.KBFRZ71_caps > 2 ]]></Custom>
<Custom Action="SetFilePath.x64_caps" Sequence="4030"> <![CDATA[ 1 = 1 ]]></Custom>
<Custom Action="SetFilePath.x64" Sequence="4031"> <![CDATA[ 1 = 1 ]]></Custom>

<Custom Action="RemoveKeyboardFromLangBar_caps" Sequence="4040"><![CDATA[ $Component.x64.KBFRZ71_caps = 2 ]]></Custom>
<Custom Action="RemoveKeyboardFromLangBar" Sequence="4041"><![CDATA[ $Component.x64.KBFRZ71 = 2 ]]></Custom>
<Custom Action="UnregisterKeyboard_caps" Sequence="4060"><![CDATA[ $Component.x64.KBFRZ71_caps = 2 ]]></Custom>
<Custom Action="UnregisterKeyboard" Sequence="4061"><![CDATA[ $Component.x64.KBFRZ71 = 2 ]]></Custom>
<Custom Action="RegisterKeyboard_caps" Sequence="4050"><![CDATA[ $Component.x64.KBFRZ71_caps > 2 ]]></Custom>
<Custom Action="RegisterKeyboard" Sequence="4051"><![CDATA[ $Component.x64.KBFRZ71 > 2 ]]></Custom>
<Custom Action="AddKeyboardToLangBar_caps" Sequence="4065"><![CDATA[ $Component.x64.KBFRZ71_caps > 2 ]]></Custom>
<Custom Action="AddKeyboardToLangBar" Sequence="4066"><![CDATA[ $Component.x64.KBFRZ71 > 2 ]]></Custom>
</InstallExecuteSequence>

<?else?>

<InstallExecuteSequence>
<Custom Action="SetFilePath.x86" Sequence="4030"> <![CDATA[ 1 = 1 ]]></Custom>

<Custom Action="RemoveKeyboardFromLangBar" Sequence="4040"><![CDATA[ $Component.x86.KBFRZ71_caps = 2 ]]></Custom>
<Custom Action="UnregisterKeyboard" Sequence="4060"><![CDATA[ $Component.x86.KBFRZ71_caps = 2 ]]></Custom>
<Custom Action="RegisterKeyboard" Sequence="4050"><![CDATA[ $Component.x86.KBFRZ71_caps > 2 ]]></Custom>
<Custom Action="AddKeyboardToLangBar" Sequence="4065"><![CDATA[ $Component.x86.KBFRZ71_caps > 2 ]]></Custom>
<Custom Action="SetFilePath.x86_caps" Sequence="4031"> <![CDATA[ 1 = 1 ]]></Custom>

<Custom Action="RemoveKeyboardFromLangBar_caps" Sequence="4040"><![CDATA[ $Component.x86.KBFRZ71_caps = 2 ]]></Custom>
<Custom Action="RemoveKeyboardFromLangBar" Sequence="4041"><![CDATA[ $Component.x86.KBFRZ71 = 2 ]]></Custom>
<Custom Action="UnregisterKeyboard_caps" Sequence="4060"><![CDATA[ $Component.x86.KBFRZ71_caps = 2 ]]></Custom>
<Custom Action="UnregisterKeyboard" Sequence="4062"><![CDATA[ $Component.x86.KBFRZ71 = 2 ]]></Custom>
<Custom Action="RegisterKeyboard_caps" Sequence="4050"><![CDATA[ $Component.x86.KBFRZ71_caps > 2 ]]></Custom>
<Custom Action="RegisterKeyboard" Sequence="4051"><![CDATA[ $Component.x86.KBFRZ71 > 2 ]]></Custom>
<Custom Action="AddKeyboardToLangBar_caps" Sequence="4065"><![CDATA[ $Component.x86.KBFRZ71_caps > 2 ]]></Custom>
<Custom Action="AddKeyboardToLangBar" Sequence="4066"><![CDATA[ $Component.x86.KBFRZ71 > 2 ]]></Custom>
</InstallExecuteSequence>

<?endif?>
Expand Down

0 comments on commit 4e36676

Please sign in to comment.