Skip to content

Commit 6a0b2e9

Browse files
committed
Update build action
1 parent e015237 commit 6a0b2e9

File tree

5 files changed

+74
-70
lines changed

5 files changed

+74
-70
lines changed

.github/workflows/build.yml

Lines changed: 52 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build
1+
name: build
22

33
on:
44
push:
@@ -7,86 +7,91 @@ on:
77
pull_request:
88
branches:
99
- '**'
10-
11-
env:
12-
FPC_VER: release_3_2_2
13-
LAZ_VER: lazarus_2_2_4
1410

1511
jobs:
1612
build:
1713
name: ${{ matrix.config.name }}
18-
runs-on: ${{ matrix.config.os }}
14+
runs-on: ${{ matrix.config.runs-on }}
15+
defaults:
16+
run:
17+
shell: bash
1918
strategy:
2019
fail-fast: false
21-
matrix:
22-
config:
20+
matrix:
21+
config:
2322
- name: Windows 64
24-
os: windows-latest
23+
runs-on: windows-latest
2524
build-mode: WIN64
2625
binary: libsimpleocr64.dll
2726

2827
- name: Windows 32
29-
os: windows-latest
28+
runs-on: windows-latest
3029
build-mode: WIN32
3130
binary: libsimpleocr32.dll
3231

3332
- name: Linux 64
34-
os: ubuntu-latest
33+
runs-on: ubuntu-22.04
3534
build-mode: LINUX64
3635
binary: libsimpleocr64.so
37-
38-
- name: Linux AArch64
39-
os: ubuntu-latest
40-
build-mode: LINUX-AARCH64
41-
binary: libsimpleocr64.so.aarch64
4236

4337
- name: MacOS 64
44-
os: macos-latest
38+
runs-on: macos-13
4539
build-mode: MACOS
4640
binary: libsimpleocr64.dylib
4741

4842
- name: MacOS AArch64
49-
os: macos-latest
43+
runs-on: macos-13
5044
build-mode: MACOS-AARCH64
5145
binary: libsimpleocr64.dylib.aarch64
5246

5347
steps:
54-
- uses: actions/[email protected]
55-
56-
- name: Install Lazarus
57-
uses: ollydev/[email protected]
48+
- uses: actions/[email protected]
49+
with:
50+
submodules: true
51+
52+
- name: Install Lazarus (MacOS)
53+
if: startsWith(matrix.config.name, 'MacOS') == true
54+
uses: ollydev/[email protected]
5855
with:
59-
laz: ${{ env.LAZ_VER }}
60-
fpc: ${{ env.FPC_VER }}
61-
62-
- name: Build SimpleOCR
63-
run: |
64-
lazbuild --build-mode=${{ matrix.config.build-mode }} SimpleOCR.lpi
56+
laz-url: https://sourceforge.net/projects/lazarus/files/Lazarus%20macOS%20x86-64/Lazarus%203.6/Lazarus-3.6-macosx-x86_64.pkg
57+
fpc-url: |
58+
https://sourceforge.net/projects/lazarus/files/Lazarus%20macOS%20x86-64/Lazarus%203.6/fpc-3.2.2.intelarm64-macosx.dmg
59+
https://sourceforge.net/projects/lazarus/files/Lazarus%20macOS%20x86-64/Lazarus%203.6/fpc-src-3.2.2-20210709-macosx.dmg
6560
66-
- name: Upload Binary
67-
uses: actions/[email protected]
61+
- name: Install Lazarus (Linux)
62+
if: startsWith(matrix.config.name, 'Linux') == true
63+
uses: ollydev/[email protected]
6864
with:
69-
name: ${{ matrix.config.binary }}
70-
path: ${{ matrix.config.binary }}
65+
laz-url: https://sourceforge.net/projects/lazarus/files/Lazarus%20Linux%20amd64%20DEB/Lazarus%203.6/lazarus-project_3.6.0-0_amd64.deb
66+
fpc-url: |
67+
https://sourceforge.net/projects/lazarus/files/Lazarus%20Linux%20amd64%20DEB/Lazarus%203.6/fpc-laz_3.2.2-210709_amd64.deb
68+
https://sourceforge.net/projects/lazarus/files/Lazarus%20Linux%20amd64%20DEB/Lazarus%203.6/fpc-src_3.2.2-210709_amd64.deb
7169
72-
testing:
73-
runs-on: windows-latest
74-
needs: build
75-
steps:
76-
- uses: actions/[email protected]
70+
- name: Install Lazarus (Windows 32)
71+
if: startsWith(matrix.config.name, 'Windows 32') == true
72+
uses: ollydev/[email protected]
73+
with:
74+
laz-url: https://sourceforge.net/projects/lazarus/files/Lazarus%20Windows%2032%20bits/Lazarus%203.6/lazarus-3.6-fpc-3.2.2-win32.exe
7775

78-
- name: Install Lazarus
79-
uses: ollydev/[email protected]
76+
- name: Install Lazarus (Windows 64)
77+
if: startsWith(matrix.config.name, 'Windows 64') == true
78+
uses: ollydev/[email protected]
8079
with:
81-
laz: ${{ env.LAZ_VER }}
82-
fpc: ${{ env.FPC_VER }}
80+
laz-url: https://sourceforge.net/projects/lazarus/files/Lazarus%20Windows%2064%20bits/Lazarus%203.6/lazarus-3.6-fpc-3.2.2-win64.exe
81+
82+
- name: Build SimpleOCR
83+
run: lazbuild --build-mode=${{ matrix.config.build-mode }} SimpleOCR.lpi
8384

8485
- name: Build Tester
85-
run: |
86-
cd tester
87-
lazbuild tester.lpi
86+
working-directory: tester
87+
run: lazbuild tester.lpi
8888

8989
- name: Run Tests
90-
run: |
91-
cd tester
92-
./tester.exe
90+
working-directory: tester
91+
run: ./tester
92+
93+
- name: Upload Binary
94+
uses: actions/[email protected]
95+
with:
96+
name: ${{ matrix.config.binary }}
97+
path: ${{ matrix.config.binary }}

SimpleOCR.lpi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
<Linking>
4848
<Debugging>
4949
<GenerateDebugInfo Value="False"/>
50-
<UseLineInfoUnit Value="False"/>
5150
<StripSymbols Value="True"/>
5251
</Debugging>
5352
<LinkSmart Value="True"/>

SimpleOCR.lpr

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ procedure _LapeSimpleOCR_RecognizeLines(const Params: PParamArray; const Result:
6161

6262
initialization
6363
addGlobalType(
64-
'record ' + LineEnding +
64+
'packed record ' + LineEnding +
6565
' ImageWidth, ImageHeight: Integer; ' + LineEnding +
6666
' Width, Height: Integer; ' + LineEnding +
6767
' CharacterBounds: TBox; ' + LineEnding +
@@ -74,7 +74,7 @@ initialization
7474
'TFontGlyph');
7575

7676
addGlobalType(
77-
'record ' + LineEnding +
77+
'packed record ' + LineEnding +
7878
' Name: String; ' + LineEnding +
7979
' SpaceWidth: Integer; ' + LineEnding +
8080
' Glyphs: array of TFontGlyph; ' + LineEnding +
@@ -83,27 +83,28 @@ initialization
8383
'end;',
8484
'TFontSet');
8585

86+
8687
addGlobalType(
87-
'record ' + LineEnding +
88+
'packed record ' + LineEnding +
8889
' FilterType: Integer; ' + LineEnding +
8990
' ' + LineEnding +
90-
' AnyColorFilter: record ' + LineEnding +
91+
' AnyColorFilter: packed record ' + LineEnding +
9192
' MaxShadowValue: Integer; ' + LineEnding +
9293
' Tolerance: Single; ' + LineEnding +
9394
' end; ' + LineEnding +
9495
' ' + LineEnding +
95-
' ColorFilter: record ' + LineEnding +
96+
' ColorFilter: packed record ' + LineEnding +
9697
' Colors: TIntegerArray; ' + LineEnding +
9798
' Tolerances: TSingleArray; ' + LineEnding +
9899
' Invert: Boolean; ' + LineEnding +
99100
' end; ' + LineEnding +
100101
' ' + LineEnding +
101-
' ThresholdFilter: record ' + LineEnding +
102+
' ThresholdFilter: packed record ' + LineEnding +
102103
' Invert: Boolean; ' + LineEnding +
103104
' C: Integer; ' + LineEnding +
104105
' end; ' + LineEnding +
105106
' ' + LineEnding +
106-
' ShadowFilter: record ' + LineEnding +
107+
' ShadowFilter: packed record ' + LineEnding +
107108
' MaxShadowValue: Integer; ' + LineEnding +
108109
' Tolerance: Single; ' + LineEnding +
109110
' end; ' + LineEnding +
@@ -113,7 +114,7 @@ initialization
113114
'TOCRFilter');
114115

115116
addGlobalType(
116-
'record ' + LineEnding +
117+
'packed record ' + LineEnding +
117118
' Text: String; ' + LineEnding +
118119
' Bounds: TBox; ' + LineEnding +
119120
' Hits: Integer; ' + LineEnding +

simpleocr.engine.pas

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ interface
1515
simpleocr.base, simpleocr.filters;
1616

1717
type
18-
TFontGlyph = record
18+
TFontGlyph = packed record
1919
ImageWidth, ImageHeight: Integer;
2020
Width, Height: Integer;
2121
CharacterBounds: TBox;
@@ -27,7 +27,7 @@ TFontGlyph = record
2727
end;
2828
TFontGlyphArray = array of TFontGlyph;
2929

30-
TFontSet = record
30+
TFontSet = packed record
3131
public
3232
Name: String;
3333
SpaceWidth: Integer;
@@ -43,7 +43,7 @@ TFontSet = record
4343
class function Create(FontPath: String; Space: Integer = 4): TFontSet; static;
4444
end;
4545

46-
TOCRMatch = record
46+
TOCRMatch = packed record
4747
Text: String;
4848
Bounds: TBox;
4949
Hits: Integer;
@@ -52,7 +52,7 @@ TOCRMatch = record
5252

5353
TOCRTarget = TColorRGBAMatrix;
5454

55-
TSimpleOCR = record
55+
TSimpleOCR = packed record
5656
private
5757
FClient: TOCRTarget;
5858
FMatches: TOCRMatchArray;
@@ -67,7 +67,7 @@ TSimpleOCR = record
6767
FMaxShadowValue: Integer;
6868
FTolerance: Single;
6969

70-
function Init(Target: TOCRTarget;constref FontSet: TFontSet; Filter: TOCRFilter; Static: Boolean): Boolean;
70+
function Init(Target: TOCRTarget; constref FontSet: TFontSet; Filter: TOCRFilter; Static: Boolean): Boolean;
7171

7272
function getGlpyhIndices(Blacklist: String): TIntegerArray;
7373
function addMatch(Match: TOCRMatch): String;
@@ -648,13 +648,12 @@ function TSimpleOCR.RecognizeLines(Target: TOCRTarget; Filter: TOCRFilter; const
648648
begin
649649
Result := [];
650650

651-
Indices := getGlpyhIndices(Filter.Blacklist);
652-
IndicesNoSmall := getGlpyhIndices(Filter.Blacklist + '~^;`_-:.,'+#39+#34);
653-
654651
if Self.Init(Target, FontSet, Filter, False) then
655652
begin
656-
SearchBox := FSearchArea;
653+
Indices := getGlpyhIndices(Filter.Blacklist);
654+
IndicesNoSmall := getGlpyhIndices(Filter.Blacklist + '~^;`_-:.,'+#39+#34);
657655

656+
SearchBox := FSearchArea;
658657
while (SearchBox.Y1 + (FFontSet^.MaxGlyphHeight div 2) < FSearchArea.Y2) do
659658
begin
660659
if RecognizeSomething(SearchBox, Match) then

simpleocr.filters.pas

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,26 +23,26 @@ interface
2323
INVERT_COLOR
2424
);
2525

26-
TOCRFilter = record
26+
TOCRFilter = packed record
2727
FilterType: EOCRFilterType;
2828

29-
AnyColorFilter: record
29+
AnyColorFilter: packed record
3030
MaxShadowValue: Integer;
3131
Tolerance: Single;
3232
end;
3333

34-
ColorRule: record
34+
ColorRule: packed record
3535
Colors: TIntegerArray;
3636
Tolerances: TSingleArray;
3737
Invert: Boolean;
3838
end;
3939

40-
ThresholdRule: record
40+
ThresholdRule: packed record
4141
Invert: Boolean;
4242
C: Integer;
4343
end;
4444

45-
ShadowRule: record
45+
ShadowRule: packed record
4646
MaxShadowValue: Integer;
4747
Tolerance: Single;
4848
end;

0 commit comments

Comments
 (0)