Skip to content

Commit 89d5e3a

Browse files
committed
Revise build files to use _build dir & new zip name
Various files that are invloved in the Makefile build process were updated to write output to _build/bin, _build/exe and _build/release directories instead of Bin, Exe & Release in repo root. CodeSnip.dproj was also update to ensure that builds using the IDE used the same _build/bin & _build/exe directories. Makefile was also updated to (a) increase use of macros for path names (b) name .zip files codesnip-exe and codesnip-portable-exe (c) append any version number in VERSION define to zip file base names Also fixed malformed quotes in a #define in CodeSnip.iss
1 parent dbaa6c3 commit 89d5e3a

File tree

5 files changed

+64
-48
lines changed

5 files changed

+64
-48
lines changed

Src/CodeSnip.cfg.tplt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@
3030
-M
3131
-$M16384,1048576
3232
-K$00400000
33-
-E"..\Exe"
34-
-N0"..\Bin"
35-
-U"..\Bin;3rdParty"
36-
-O"..\Bin;3rdParty"
37-
-I"..\Bin;3rdParty"
38-
-R"..\Bin;3rdParty"
33+
-E"..\_build\exe"
34+
-N0"..\_build\bin"
35+
-U"..\_build\bin;3rdParty"
36+
-O"..\_build\bin;3rdParty"
37+
-I"..\_build\bin;3rdParty"
38+
-R"..\_build\bin;3rdParty"
3939
-w-SYMBOL_PLATFORM
4040
-w+EXPLICIT_STRING_CAST_LOSS
4141
-w+CVT_WIDENING_STRING_LOST

Src/CodeSnip.dproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
<PropertyGroup Condition="'$(Base)'!=''">
1717
<DCC_UnitAlias>WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;$(DCC_UnitAlias)</DCC_UnitAlias>
1818
<DCC_SYMBOL_PLATFORM>false</DCC_SYMBOL_PLATFORM>
19-
<DCC_ExeOutput>..\Exe</DCC_ExeOutput>
20-
<DCC_UnitSearchPath>..\Bin;3rdParty;$(DCC_UnitSearchPath)</DCC_UnitSearchPath>
21-
<DCC_DependencyCheckOutputName>..\Exe\CodeSnip.exe</DCC_DependencyCheckOutputName>
19+
<DCC_ExeOutput>..\_build\exe</DCC_ExeOutput>
20+
<DCC_UnitSearchPath>..\_build\bin;3rdParty;$(DCC_UnitSearchPath)</DCC_UnitSearchPath>
21+
<DCC_DependencyCheckOutputName>..\_build\exe\CodeSnip.exe</DCC_DependencyCheckOutputName>
2222
<DCC_CVT_WIDENING_STRING_LOST>true</DCC_CVT_WIDENING_STRING_LOST>
2323
<DCC_CVT_ACHAR_TO_WCHAR>true</DCC_CVT_ACHAR_TO_WCHAR>
2424
<DCC_Platform>x86</DCC_Platform>
@@ -29,7 +29,7 @@
2929
<DCC_S>false</DCC_S>
3030
<DCC_F>false</DCC_F>
3131
<DCC_SymbolReferenceInfo>1</DCC_SymbolReferenceInfo>
32-
<DCC_DcuOutput>..\Bin</DCC_DcuOutput>
32+
<DCC_DcuOutput>..\_build\bin</DCC_DcuOutput>
3333
<DCC_E>false</DCC_E>
3434
</PropertyGroup>
3535
<ItemGroup>

Src/Help/CodeSnip.hhp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
[OPTIONS]
1010
Compatibility=1.1
11-
Compiled file=..\..\Exe\CodeSnip.chm
11+
Compiled file=..\..\_build\exe\CodeSnip.chm
1212
Contents file=TOC.hhc
1313
Default topic=HTML\welcome.htm
1414
Display compile progress=No

Src/Install/CodeSnip.iss

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
; v. 2.0. If a copy of the MPL was not distributed with this file, You can
33
; obtain one at https://mozilla.org/MPL/2.0/
44
;
5-
; Copyright (C) 2006-2021, Peter Johnson (gravatar.com/delphidabbler).
5+
; Copyright (C) 2006-2022, Peter Johnson (gravatar.com/delphidabbler).
66
;
77
; Install file generation script for use with Inno Setup.
88

@@ -25,10 +25,10 @@
2525
#define ReadMeFile "ReadMe.txt"
2626
#define LicenseFile "License.rtf"
2727
#define LicenseTextFile "License.html"
28-
#define OutDir SourcePath + "..\..\Exe"
28+
#define OutDir SourcePath + "..\..\_build\exe"
2929
#define SrcDocsPath SourcePath + "..\..\Docs\"
30-
#define SrcAssetsPath SourcePath + '\Assets\"
31-
#define SrcExePath SourcePath + "..\..\Exe\"
30+
#define SrcAssetsPath SourcePath + "\Assets\"
31+
#define SrcExePath SourcePath + "..\..\_build\exe\"
3232
#define ProgDataSubDir AppName + ".4"
3333
#define ExeProg SrcExePath + ExeFile
3434
#define AppVersion DeleteToVerStart(GetFileProductVersion(ExeProg))

Src/Makefile

Lines changed: 49 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,22 @@
22
# v. 2.0. If a copy of the MPL was not distributed with this file, You can
33
# obtain one at https://mozilla.org/MPL/2.0/
44
#
5-
# Copyright (C) 2009-2021, Peter Johnson (gravatar.com/delphidabbler).
5+
# Copyright (C) 2009-2022, Peter Johnson (gravatar.com/delphidabbler).
66
#
77
# Makefile for the CodeSnip project.
88

99

10-
# Define macros giving relative paths to other directories from location of
11-
# makefile
12-
BIN = ..\Bin
13-
EXE = ..\Exe
10+
# Define macros relative paths to various directories relative to the repo root
11+
BUILD_ROOT = _build
12+
BIN_ROOT = $(BUILD_ROOT)\bin
13+
EXE_ROOT = $(BUILD_ROOT)\exe
14+
RELEASE_ROOT = $(BUILD_ROOT)\release
15+
DOCS_ROOT = Docs
16+
SRC_ROOT = Src
17+
18+
# Defines macros giving directories relative to location of the Makefile
19+
BIN_REL = ..\$(BIN_ROOT)
20+
EXE_REL = ..\$(EXE_ROOT)
1421

1522
# Check for required environment variables
1623

@@ -75,11 +82,10 @@ DELPHIDEFINES =
7582

7683
# Implicit rules
7784

78-
# Resource files are compiled to the directory specified by BIN macro, which
79-
# must have been set by the caller.
85+
# Resource files are compiled to the directory specified by BIN_REL macro.
8086
.rc.res:
8187
@echo +++ Compiling Resource file $< +++
82-
@$(BRCC32) $< -fo$(BIN)\$(@F)
88+
@$(BRCC32) $< -fo$(BIN_REL)\$(@F)
8389

8490
# Version info files are compiled by VIEd. A temporary .rc file is left behind
8591
.vi.rc:
@@ -104,11 +110,12 @@ config:
104110
@copy /Y CodeSnip.cfg.tplt CodeSnip.cfg
105111
# Create build folders
106112
@cd ..
107-
@if exist Bin rmdir /S /Q Bin
108-
@mkdir Bin
109-
@if not exist Exe mkdir Exe
110-
@if not exist Release mkdir Release
111-
@cd Src
113+
@if not exist $(BUILD_ROOT) mkdir $(BUILD_ROOT)
114+
@if exist $(BIN_ROOT) rmdir /S /Q $(BIN_ROOT)
115+
@mkdir $(BIN_ROOT)
116+
@if not exist $(EXE_ROOT) mkdir $(EXE_ROOT)
117+
@if not exist $(RELEASE_ROOT) mkdir $(RELEASE_ROOT)
118+
@cd $(SRC_ROOT)
112119

113120
# Builds CodeSnip pascal files and links program
114121
pascal: CodeSnip.exe
@@ -118,14 +125,14 @@ pascal: CodeSnip.exe
118125
CodeSnip.exe:
119126
@echo +++ Compiling Pascal +++
120127
!ifdef PORTABLE
121-
@if exist $(EXE)\$(@F) copy $(EXE)\$(@F) $(EXE)\$(@F).bak
128+
@if exist $(EXE_REL)\$(@F) copy $(EXE_REL)\$(@F) $(EXE_REL)\$(@F).bak
122129
!endif
123130
@$(DCC32) $(@B).dpr -B $(DELPHIDEFINES)
124131
!ifdef PORTABLE
125-
@copy $(EXE)\$(@F) $(EXE)\$(@B)-p.exe /Y
126-
@del $(EXE)\$(@F)
127-
@if exist $(EXE)\$(@F).bak copy $(EXE)\$(@F).bak $(EXE)\$(@F)
128-
@if exist $(EXE)\$(@F).bak del $(EXE)\$(@F).bak
132+
@copy $(EXE_REL)\$(@F) $(EXE_REL)\$(@B)-p.exe /Y
133+
@del $(EXE_REL)\$(@F)
134+
@if exist $(EXE_REL)\$(@F).bak copy $(EXE_REL)\$(@F).bak $(EXE_REL)\$(@F)
135+
@if exist $(EXE_REL)\$(@F).bak del $(EXE_REL)\$(@F).bak
129136
!endif
130137

131138
# Builds help file
@@ -144,49 +151,58 @@ resources: $(VERINFOFILEBASE).res Resources.res HTML.res
144151
# Compiles HTMLres from .hrc file
145152
HTML.res: HTML.hrc
146153
@echo +++ Compiling HTML Resource manifest file +++
147-
@$(HTMLRES) -mHTML.hrc -o$(BIN)\HTML.res -r -q
154+
@$(HTMLRES) -mHTML.hrc -o$(BIN_REL)\HTML.res -r -q
148155

149156
# Compiles type library from IDL
150157
typelib:
151-
@$(GENTLB) .\ExternalObj.ridl -D$(BIN) -TExternalObj.tlb
158+
@$(GENTLB) .\ExternalObj.ridl -D$(BIN_REL) -TExternalObj.tlb
152159

153160
# Builds setup program
154161
setup:
155162
!ifndef PORTABLE
156-
@del ..\Exe\CodeSnip-Setup-*
163+
@del $(EXE_REL)\CodeSnip-Setup-*
157164
@$(ISCC) Install\CodeSnip.iss
158165
!else
159166
@echo **** Portable build - no setup file created ****
160167
!endif
161168

162169
# Creates auto generated files
163170
autogen:
164-
@$(TLIBIMP) -P+ -Ps+ -D.\AutoGen -FtIntfExternalObj $(BIN)\ExternalObj.tlb
171+
@$(TLIBIMP) -P+ -Ps+ -D.\AutoGen -FtIntfExternalObj $(BIN_REL)\ExternalObj.tlb
165172
@if exist .\AutoGen\IntfExternalObj.dcr del .\AutoGen\IntfExternalObj.dcr
166173

167174
# Build release files (.zip)
175+
# If RELEASEFILENAME is defined by caller then it is used as name of zip file
176+
# otherwise default zip file name is used, which depends on whether PORTABLE
177+
# is defined.
178+
# If VERSION is defined by caller then it is appended to RELEASEFILENAME,
179+
# separated by a dash.
168180
!ifndef RELEASEFILENAME
169-
RELEASEFILENAME = dd-codesnip
170-
!ifdef PORTABLE
171-
RELEASEFILENAME = $(RELEASEFILENAME)-portable
181+
!ifndef PORTABLE
182+
RELEASEFILENAME = codesnip-exe
183+
!else
184+
RELEASEFILENAME = codesnip-portable-exe
185+
!endif
172186
!endif
187+
!ifdef VERSION
188+
RELEASEFILENAME = $(RELEASEFILENAME)-$(VERSION)
173189
!endif
174-
OUTFILE = Release\$(RELEASEFILENAME).zip
190+
OUTFILE = $(RELEASE_ROOT)\$(RELEASEFILENAME).zip
175191
release:
176192
@echo ---------------------
177193
@echo Creating Release File
178194
@echo ---------------------
179195
@cd ..
180196
-@if exist $(OUTFILE) del $(OUTFILE)
181197
!ifndef PORTABLE
182-
@$(ZIP) -j -9 $(OUTFILE) Exe\CodeSnip-Setup-*.exe Docs\ReadMe.txt
198+
@$(ZIP) -j -9 $(OUTFILE) $(EXE_ROOT)\CodeSnip-Setup-*.exe $(DOCS_ROOT)\ReadMe.txt
183199
!else
184-
@$(ZIP) -j -9 $(OUTFILE) Exe\CodeSnip-p.exe
185-
@$(ZIP) -j -9 $(OUTFILE) Exe\CodeSnip.chm
186-
@$(ZIP) -j -9 $(OUTFILE) Docs\ReadMe.txt
187-
@$(ZIP) -j -9 $(OUTFILE) Docs\License.html
200+
@$(ZIP) -j -9 $(OUTFILE) $(EXE_ROOT)\CodeSnip-p.exe
201+
@$(ZIP) -j -9 $(OUTFILE) $(EXE_ROOT)\CodeSnip.chm
202+
@$(ZIP) -j -9 $(OUTFILE) $(DOCS_ROOT)\ReadMe.txt
203+
@$(ZIP) -j -9 $(OUTFILE) $(DOCS_ROOT)\License.html
188204
!endif
189-
@cd Src
205+
@cd $(SRC_ROOT)
190206

191207
# Clean up unwanted files
192208
clean:
@@ -200,4 +216,4 @@ clean:
200216
-@del /S *.tvsconfig 2>nul
201217
# remove __history folders
202218
-@for /F "usebackq" %i in (`dir /S /B /A:D ..\__history`) do @rmdir /S /Q %i
203-
@cd Src
219+
@cd $(SRC_ROOT)

0 commit comments

Comments
 (0)