mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-15 17:19:33 +02:00
* initial skeleton
git-svn-id: trunk@5147 -
This commit is contained in:
parent
5acc8b44a8
commit
654eaa0f0e
5
.gitattributes
vendored
5
.gitattributes
vendored
@ -7765,9 +7765,14 @@ utils/fppkg/README svneol=native#text/plain
|
||||
utils/fppkg/fpmkcnst.inc svneol=native#text/plain
|
||||
utils/fppkg/fpmktype.pp svneol=native#text/plain
|
||||
utils/fppkg/fpmkunit.pp svneol=native#text/plain
|
||||
utils/fppkg/fppkg.lpi svneol=native#text/plain
|
||||
utils/fppkg/fppkg.pp svneol=native#text/plain
|
||||
utils/fppkg/fprepos.pp svneol=native#text/plain
|
||||
utils/fppkg/fpxmlrep.pp svneol=native#text/plain
|
||||
utils/fppkg/pkgdownload.pp svneol=native#text/plain
|
||||
utils/fppkg/pkghandler.pp svneol=native#text/plain
|
||||
utils/fppkg/pkgmessages.pp svneol=native#text/plain
|
||||
utils/fppkg/pkgmkconv.pp svneol=native#text/plain
|
||||
utils/fppkg/pkgropts.pp svneol=native#text/plain
|
||||
utils/fppkg/rep2xml.lpi svneol=native#text/plain
|
||||
utils/fppkg/rep2xml.lpr svneol=native#text/plain
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Don't edit, this file is generated by FPCMake Version 2.0.0 [2006/10/28]
|
||||
# Don't edit, this file is generated by FPCMake Version 2.0.0 [2006/08/20]
|
||||
#
|
||||
default: all
|
||||
MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos sparc-linux sparc-netbsd sparc-solaris x86_64-linux x86_64-freebsd x86_64-win64 arm-linux arm-palmos arm-wince arm-gba powerpc64-linux
|
||||
@ -354,127 +354,127 @@ ifeq ($(FULL_TARGET),powerpc64-linux)
|
||||
override TARGET_PROGRAMS+=fppkg
|
||||
endif
|
||||
ifeq ($(FULL_TARGET),i386-linux)
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts pkghandler pkgmkconv pkgdownload
|
||||
endif
|
||||
ifeq ($(FULL_TARGET),i386-go32v2)
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts pkghandler pkgmkconv pkgdownload
|
||||
endif
|
||||
ifeq ($(FULL_TARGET),i386-win32)
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts pkghandler pkgmkconv pkgdownload
|
||||
endif
|
||||
ifeq ($(FULL_TARGET),i386-os2)
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts pkghandler pkgmkconv pkgdownload
|
||||
endif
|
||||
ifeq ($(FULL_TARGET),i386-freebsd)
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts pkghandler pkgmkconv pkgdownload
|
||||
endif
|
||||
ifeq ($(FULL_TARGET),i386-beos)
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts pkghandler pkgmkconv pkgdownload
|
||||
endif
|
||||
ifeq ($(FULL_TARGET),i386-netbsd)
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts pkghandler pkgmkconv pkgdownload
|
||||
endif
|
||||
ifeq ($(FULL_TARGET),i386-solaris)
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts pkghandler pkgmkconv pkgdownload
|
||||
endif
|
||||
ifeq ($(FULL_TARGET),i386-qnx)
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts pkghandler pkgmkconv pkgdownload
|
||||
endif
|
||||
ifeq ($(FULL_TARGET),i386-netware)
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts pkghandler pkgmkconv pkgdownload
|
||||
endif
|
||||
ifeq ($(FULL_TARGET),i386-openbsd)
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts pkghandler pkgmkconv pkgdownload
|
||||
endif
|
||||
ifeq ($(FULL_TARGET),i386-wdosx)
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts pkghandler pkgmkconv pkgdownload
|
||||
endif
|
||||
ifeq ($(FULL_TARGET),i386-darwin)
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts pkghandler pkgmkconv pkgdownload
|
||||
endif
|
||||
ifeq ($(FULL_TARGET),i386-emx)
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts pkghandler pkgmkconv pkgdownload
|
||||
endif
|
||||
ifeq ($(FULL_TARGET),i386-watcom)
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts pkghandler pkgmkconv pkgdownload
|
||||
endif
|
||||
ifeq ($(FULL_TARGET),i386-netwlibc)
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts pkghandler pkgmkconv pkgdownload
|
||||
endif
|
||||
ifeq ($(FULL_TARGET),i386-wince)
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts pkghandler pkgmkconv pkgdownload
|
||||
endif
|
||||
ifeq ($(FULL_TARGET),m68k-linux)
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts pkghandler pkgmkconv pkgdownload
|
||||
endif
|
||||
ifeq ($(FULL_TARGET),m68k-freebsd)
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts pkghandler pkgmkconv pkgdownload
|
||||
endif
|
||||
ifeq ($(FULL_TARGET),m68k-netbsd)
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts pkghandler pkgmkconv pkgdownload
|
||||
endif
|
||||
ifeq ($(FULL_TARGET),m68k-amiga)
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts pkghandler pkgmkconv pkgdownload
|
||||
endif
|
||||
ifeq ($(FULL_TARGET),m68k-atari)
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts pkghandler pkgmkconv pkgdownload
|
||||
endif
|
||||
ifeq ($(FULL_TARGET),m68k-openbsd)
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts pkghandler pkgmkconv pkgdownload
|
||||
endif
|
||||
ifeq ($(FULL_TARGET),m68k-palmos)
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts pkghandler pkgmkconv pkgdownload
|
||||
endif
|
||||
ifeq ($(FULL_TARGET),powerpc-linux)
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts pkghandler pkgmkconv pkgdownload
|
||||
endif
|
||||
ifeq ($(FULL_TARGET),powerpc-netbsd)
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts pkghandler pkgmkconv pkgdownload
|
||||
endif
|
||||
ifeq ($(FULL_TARGET),powerpc-amiga)
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts pkghandler pkgmkconv pkgdownload
|
||||
endif
|
||||
ifeq ($(FULL_TARGET),powerpc-macos)
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts pkghandler pkgmkconv pkgdownload
|
||||
endif
|
||||
ifeq ($(FULL_TARGET),powerpc-darwin)
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts pkghandler pkgmkconv pkgdownload
|
||||
endif
|
||||
ifeq ($(FULL_TARGET),powerpc-morphos)
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts pkghandler pkgmkconv pkgdownload
|
||||
endif
|
||||
ifeq ($(FULL_TARGET),sparc-linux)
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts pkghandler pkgmkconv pkgdownload
|
||||
endif
|
||||
ifeq ($(FULL_TARGET),sparc-netbsd)
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts pkghandler pkgmkconv pkgdownload
|
||||
endif
|
||||
ifeq ($(FULL_TARGET),sparc-solaris)
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts pkghandler pkgmkconv pkgdownload
|
||||
endif
|
||||
ifeq ($(FULL_TARGET),x86_64-linux)
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts pkghandler pkgmkconv pkgdownload
|
||||
endif
|
||||
ifeq ($(FULL_TARGET),x86_64-freebsd)
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts pkghandler pkgmkconv pkgdownload
|
||||
endif
|
||||
ifeq ($(FULL_TARGET),x86_64-win64)
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts pkghandler pkgmkconv pkgdownload
|
||||
endif
|
||||
ifeq ($(FULL_TARGET),arm-linux)
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts pkghandler pkgmkconv pkgdownload
|
||||
endif
|
||||
ifeq ($(FULL_TARGET),arm-palmos)
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts pkghandler pkgmkconv pkgdownload
|
||||
endif
|
||||
ifeq ($(FULL_TARGET),arm-wince)
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts pkghandler pkgmkconv pkgdownload
|
||||
endif
|
||||
ifeq ($(FULL_TARGET),arm-gba)
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts pkghandler pkgmkconv pkgdownload
|
||||
endif
|
||||
ifeq ($(FULL_TARGET),powerpc64-linux)
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts
|
||||
override TARGET_UNITS+=fpmktype fpmkunit fprepos fpxmlrep pkgropts pkghandler pkgmkconv pkgdownload
|
||||
endif
|
||||
ifeq ($(FULL_TARGET),i386-linux)
|
||||
override TARGET_RSTS+=fprepos fpxmlrep fppkg
|
||||
@ -2395,7 +2395,7 @@ ifeq ($(CPU_TARGET),powerpc)
|
||||
FPCCPUOPT:=-O1r
|
||||
endif
|
||||
else
|
||||
FPCCPUOPT:=-O2
|
||||
FPCCPUOPT:=-O1r
|
||||
endif
|
||||
override FPCOPT+=-Ur -Xs $(FPCCPUOPT) -n
|
||||
override FPCOPTDEF+=RELEASE
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
[target]
|
||||
programs=fppkg
|
||||
units=fpmktype fpmkunit fprepos fpxmlrep pkgropts
|
||||
units=fpmktype fpmkunit fprepos fpxmlrep pkgropts pkghandler pkgmkconv pkgdownload
|
||||
examples=rep2xml
|
||||
rsts=fprepos fpxmlrep fppkg
|
||||
|
||||
|
267
utils/fppkg/fppkg.lpi
Normal file
267
utils/fppkg/fppkg.lpi
Normal file
@ -0,0 +1,267 @@
|
||||
<?xml version="1.0"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<PathDelim Value="/"/>
|
||||
<Version Value="5"/>
|
||||
<General>
|
||||
<Flags>
|
||||
<MainUnitHasUsesSectionForAllUnits Value="False"/>
|
||||
<MainUnitHasCreateFormStatements Value="False"/>
|
||||
<MainUnitHasTitleStatement Value="False"/>
|
||||
</Flags>
|
||||
<MainUnit Value="0"/>
|
||||
<TargetFileExt Value=""/>
|
||||
<ActiveEditorIndexAtStart Value="3"/>
|
||||
</General>
|
||||
<VersionInfo>
|
||||
<ProjectVersion Value=""/>
|
||||
<Language Value=""/>
|
||||
<CharSet Value=""/>
|
||||
</VersionInfo>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
<IgnoreBinaries Value="False"/>
|
||||
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
|
||||
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
|
||||
</PublishOptions>
|
||||
<RunParams>
|
||||
<local>
|
||||
<FormatVersion Value="1"/>
|
||||
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
|
||||
</local>
|
||||
</RunParams>
|
||||
<Units Count="11">
|
||||
<Unit0>
|
||||
<Filename Value="fppkg.pp"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="fppkg"/>
|
||||
<CursorPos X="1" Y="13"/>
|
||||
<TopLine Value="1"/>
|
||||
<EditorIndex Value="0"/>
|
||||
<UsageCount Value="20"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="pkgropts.pp"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UsageCount Value="20"/>
|
||||
<SyntaxHighlighter Value="Text"/>
|
||||
</Unit1>
|
||||
<Unit2>
|
||||
<Filename Value="fpmkcnst.inc"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UsageCount Value="20"/>
|
||||
<SyntaxHighlighter Value="Text"/>
|
||||
</Unit2>
|
||||
<Unit3>
|
||||
<Filename Value="fpmktype.pp"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="fpmktype"/>
|
||||
<CursorPos X="3" Y="41"/>
|
||||
<TopLine Value="1"/>
|
||||
<EditorIndex Value="2"/>
|
||||
<UsageCount Value="20"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit3>
|
||||
<Unit4>
|
||||
<Filename Value="fpmkunit.pp"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UsageCount Value="20"/>
|
||||
<SyntaxHighlighter Value="Text"/>
|
||||
</Unit4>
|
||||
<Unit5>
|
||||
<Filename Value="fprepos.pp"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UsageCount Value="20"/>
|
||||
<SyntaxHighlighter Value="Text"/>
|
||||
</Unit5>
|
||||
<Unit6>
|
||||
<Filename Value="fpxmlrep.pp"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UsageCount Value="20"/>
|
||||
<SyntaxHighlighter Value="Text"/>
|
||||
</Unit6>
|
||||
<Unit7>
|
||||
<Filename Value="pkghandler.pp"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="pkghandler"/>
|
||||
<CursorPos X="18" Y="41"/>
|
||||
<TopLine Value="16"/>
|
||||
<EditorIndex Value="5"/>
|
||||
<UsageCount Value="20"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit7>
|
||||
<Unit8>
|
||||
<Filename Value="pkgmkconv.pp"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="pkgmkconv"/>
|
||||
<CursorPos X="20" Y="7"/>
|
||||
<TopLine Value="1"/>
|
||||
<EditorIndex Value="4"/>
|
||||
<UsageCount Value="20"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit8>
|
||||
<Unit9>
|
||||
<Filename Value="pkgdownload.pp"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="pkgdownload"/>
|
||||
<CursorPos X="1" Y="94"/>
|
||||
<TopLine Value="59"/>
|
||||
<EditorIndex Value="3"/>
|
||||
<UsageCount Value="20"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit9>
|
||||
<Unit10>
|
||||
<Filename Value="pkgmessages.pp"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="pkgmessages"/>
|
||||
<CursorPos X="1" Y="18"/>
|
||||
<TopLine Value="1"/>
|
||||
<EditorIndex Value="1"/>
|
||||
<UsageCount Value="20"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit10>
|
||||
</Units>
|
||||
<JumpHistory Count="30" HistoryIndex="29">
|
||||
<Position1>
|
||||
<Filename Value="pkgmkconv.pp"/>
|
||||
<Caret Line="614" Column="12" TopLine="591"/>
|
||||
</Position1>
|
||||
<Position2>
|
||||
<Filename Value="fppkg.pp"/>
|
||||
<Caret Line="7" Column="37" TopLine="1"/>
|
||||
</Position2>
|
||||
<Position3>
|
||||
<Filename Value="fppkg.pp"/>
|
||||
<Caret Line="75" Column="34" TopLine="52"/>
|
||||
</Position3>
|
||||
<Position4>
|
||||
<Filename Value="fppkg.pp"/>
|
||||
<Caret Line="61" Column="19" TopLine="52"/>
|
||||
</Position4>
|
||||
<Position5>
|
||||
<Filename Value="fppkg.pp"/>
|
||||
<Caret Line="44" Column="31" TopLine="1"/>
|
||||
</Position5>
|
||||
<Position6>
|
||||
<Filename Value="fppkg.pp"/>
|
||||
<Caret Line="239" Column="23" TopLine="216"/>
|
||||
</Position6>
|
||||
<Position7>
|
||||
<Filename Value="fppkg.pp"/>
|
||||
<Caret Line="282" Column="29" TopLine="243"/>
|
||||
</Position7>
|
||||
<Position8>
|
||||
<Filename Value="pkgdownload.pp"/>
|
||||
<Caret Line="14" Column="3" TopLine="1"/>
|
||||
</Position8>
|
||||
<Position9>
|
||||
<Filename Value="pkghandler.pp"/>
|
||||
<Caret Line="50" Column="1" TopLine="1"/>
|
||||
</Position9>
|
||||
<Position10>
|
||||
<Filename Value="pkghandler.pp"/>
|
||||
<Caret Line="42" Column="62" TopLine="18"/>
|
||||
</Position10>
|
||||
<Position11>
|
||||
<Filename Value="pkghandler.pp"/>
|
||||
<Caret Line="47" Column="24" TopLine="24"/>
|
||||
</Position11>
|
||||
<Position12>
|
||||
<Filename Value="pkghandler.pp"/>
|
||||
<Caret Line="45" Column="73" TopLine="24"/>
|
||||
</Position12>
|
||||
<Position13>
|
||||
<Filename Value="pkgmkconv.pp"/>
|
||||
<Caret Line="49" Column="14" TopLine="16"/>
|
||||
</Position13>
|
||||
<Position14>
|
||||
<Filename Value="pkgmkconv.pp"/>
|
||||
<Caret Line="1" Column="1" TopLine="1"/>
|
||||
</Position14>
|
||||
<Position15>
|
||||
<Filename Value="pkgdownload.pp"/>
|
||||
<Caret Line="30" Column="9" TopLine="4"/>
|
||||
</Position15>
|
||||
<Position16>
|
||||
<Filename Value="pkgdownload.pp"/>
|
||||
<Caret Line="36" Column="26" TopLine="13"/>
|
||||
</Position16>
|
||||
<Position17>
|
||||
<Filename Value="pkgdownload.pp"/>
|
||||
<Caret Line="26" Column="19" TopLine="3"/>
|
||||
</Position17>
|
||||
<Position18>
|
||||
<Filename Value="pkghandler.pp"/>
|
||||
<Caret Line="19" Column="26" TopLine="12"/>
|
||||
</Position18>
|
||||
<Position19>
|
||||
<Filename Value="pkghandler.pp"/>
|
||||
<Caret Line="56" Column="5" TopLine="12"/>
|
||||
</Position19>
|
||||
<Position20>
|
||||
<Filename Value="pkghandler.pp"/>
|
||||
<Caret Line="62" Column="11" TopLine="39"/>
|
||||
</Position20>
|
||||
<Position21>
|
||||
<Filename Value="pkgdownload.pp"/>
|
||||
<Caret Line="22" Column="1" TopLine="1"/>
|
||||
</Position21>
|
||||
<Position22>
|
||||
<Filename Value="pkgdownload.pp"/>
|
||||
<Caret Line="53" Column="1" TopLine="19"/>
|
||||
</Position22>
|
||||
<Position23>
|
||||
<Filename Value="pkgdownload.pp"/>
|
||||
<Caret Line="49" Column="5" TopLine="1"/>
|
||||
</Position23>
|
||||
<Position24>
|
||||
<Filename Value="pkgdownload.pp"/>
|
||||
<Caret Line="10" Column="1" TopLine="1"/>
|
||||
</Position24>
|
||||
<Position25>
|
||||
<Filename Value="pkgdownload.pp"/>
|
||||
<Caret Line="55" Column="28" TopLine="32"/>
|
||||
</Position25>
|
||||
<Position26>
|
||||
<Filename Value="pkgdownload.pp"/>
|
||||
<Caret Line="59" Column="1" TopLine="32"/>
|
||||
</Position26>
|
||||
<Position27>
|
||||
<Filename Value="pkgdownload.pp"/>
|
||||
<Caret Line="73" Column="46" TopLine="50"/>
|
||||
</Position27>
|
||||
<Position28>
|
||||
<Filename Value="pkgdownload.pp"/>
|
||||
<Caret Line="75" Column="19" TopLine="52"/>
|
||||
</Position28>
|
||||
<Position29>
|
||||
<Filename Value="pkgdownload.pp"/>
|
||||
<Caret Line="93" Column="7" TopLine="59"/>
|
||||
</Position29>
|
||||
<Position30>
|
||||
<Filename Value="pkgdownload.pp"/>
|
||||
<Caret Line="94" Column="11" TopLine="59"/>
|
||||
</Position30>
|
||||
</JumpHistory>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="5"/>
|
||||
<CodeGeneration>
|
||||
<Generate Value="Faster"/>
|
||||
</CodeGeneration>
|
||||
<Other>
|
||||
<CompilerPath Value="$(CompPath)"/>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
<Debugging>
|
||||
<Exceptions Count="2">
|
||||
<Item1>
|
||||
<Name Value="ECodetoolError"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<Name Value="EFOpenError"/>
|
||||
</Item2>
|
||||
</Exceptions>
|
||||
</Debugging>
|
||||
</CONFIG>
|
@ -3,26 +3,20 @@ program fppkg;
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
uses
|
||||
Classes, SysUtils, TypInfo
|
||||
{ add your units here };
|
||||
// General
|
||||
Classes, SysUtils, TypInfo, custapp,
|
||||
// Repository handler objects
|
||||
fprepos, fpxmlrep,fpmktype,
|
||||
// Package Handler components
|
||||
pkghandler, pkgmkconv, pkgdownload, pkgmessages;
|
||||
|
||||
Resourcestring
|
||||
// SErrInValidArgument = 'Invalid command-line argument at position %d : %s';
|
||||
SErrNeedArgument = 'Option at position %d (%s) needs an argument';
|
||||
SErrMissingConfig = 'Missing configuration Makefile.fpc or fpmake.pp';
|
||||
SErrRunning = 'The FPC make tool encountered the following error: %s';
|
||||
SErrFailedToCompileFPCMake = 'Could not compile fpmake driver program';
|
||||
SLogGeneratingFPMake = 'Generating fpmake.pp';
|
||||
SLogCompilingFPMake = 'Compiling fpmake.pp: ';
|
||||
SLogRunningFPMake = 'Running fpmake';
|
||||
|
||||
Type
|
||||
|
||||
TRunMode = (rmHelp,rmCompile,rmBuild,rmInstall,rmArchive,rmClean,rmDownload);
|
||||
|
||||
{ TMakeTool }
|
||||
|
||||
TMakeTool = Class(TObject)
|
||||
TMakeTool = Class(TCustomApplication)
|
||||
Private
|
||||
FConvertOnly,
|
||||
FLogging : Boolean;
|
||||
@ -41,691 +35,12 @@ Type
|
||||
procedure CreateFPMake;
|
||||
procedure CompileFPMake(Extra : Boolean);
|
||||
Function RunFPMake : Integer;
|
||||
Procedure Run;
|
||||
Procedure DoRun; Override;
|
||||
end;
|
||||
|
||||
EMakeToolError = Class(Exception);
|
||||
|
||||
|
||||
{ TMakeFileConverter }
|
||||
TSectionType = (stNone,stPackage,stTarget,stclean,stinstall,stCompiler,
|
||||
stDefault,stRequire,stRules,stPrerules);
|
||||
|
||||
TMakeFileConverter = Class(TObject)
|
||||
FSection : TSectionType;
|
||||
FPackageName,
|
||||
FpackageDir,
|
||||
FPackageOptions,
|
||||
FPackageDeps,
|
||||
FBuilDUnit,
|
||||
FSubName,
|
||||
FPackageVersion : String;
|
||||
// Reading;
|
||||
procedure DoPackageLine(Const S : String);
|
||||
Procedure DoTargetLine(Line : String; Var T,R,D : TStrings);
|
||||
Procedure DoInstallLine(Line : String; Var IFL : TStrings);
|
||||
procedure DoCleanLine(Line : String; Var CFL : TStrings);
|
||||
procedure DoRequireLine(Line : String);
|
||||
procedure DoCompilerLine(Line : String;Var SD : TStrings);
|
||||
// Writing;
|
||||
procedure WriteOSCPUCheck(Src: TStrings;OS,CPU : String);
|
||||
procedure StartPackage(Src : TStrings; Dir,OS : String);
|
||||
procedure EndPackage(Src : TStrings; Dir,OS : String);
|
||||
procedure DoTargets(Src,T,R,SD : TStrings; Dir,Prefix : String);
|
||||
procedure DoCleans(Src,CFL : TStrings);
|
||||
procedure DoInstalls(Src,IFL : TStrings);
|
||||
Procedure StartInstaller(Src : TStrings);
|
||||
Procedure EndInstaller(Src : TStrings);
|
||||
Function GetLine (L : TStrings; Var I : Integer) : String;
|
||||
Public
|
||||
procedure ConvertFile(const AFileName: String; Src: TStrings; Dir,OS : String);
|
||||
Procedure ConvertFile(Const Source,Dest: String);
|
||||
end;
|
||||
|
||||
{ Auxiliary functions }
|
||||
|
||||
Function GetWord(var S : String; Sep : Char) : String;
|
||||
|
||||
Var
|
||||
L : Integer;
|
||||
|
||||
begin
|
||||
L:=Pos(Sep,S);
|
||||
If (L=0) then
|
||||
L:=Length(S)+1;
|
||||
Result:=Copy(S,1,L-1);
|
||||
Delete(S,1,L);
|
||||
S:=Trim(S);
|
||||
end;
|
||||
|
||||
Function GetWord(var S : String) : String;
|
||||
|
||||
begin
|
||||
Result:=GetWord(S,' ');
|
||||
end;
|
||||
|
||||
|
||||
Function IsCPU (S: String) : Boolean;
|
||||
|
||||
begin
|
||||
Result:=Pos(lowercase(S)+',','i386,powerpc,arm,alpha,sparc,')<>0
|
||||
end;
|
||||
|
||||
Function GetOSCPU(L : String; var OS,CPU : String) : String;
|
||||
|
||||
Procedure Add(Var A : String; ad : String);
|
||||
|
||||
begin
|
||||
If (A<>'') then
|
||||
A:=A+',';
|
||||
A:=A+ad;
|
||||
end;
|
||||
|
||||
|
||||
Var
|
||||
S : String;
|
||||
|
||||
begin
|
||||
OS:='';
|
||||
CPU:='';
|
||||
S:=GetWord(L,',');
|
||||
While (S<>'') do
|
||||
begin
|
||||
If (S<>'all') then
|
||||
If IsCPU(S) then
|
||||
Add(CPU,S)
|
||||
else
|
||||
Add(OS,S);
|
||||
S:=GetWord(L,',');
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
{ TMakeFileConverter }
|
||||
|
||||
procedure TMakeFileConverter.StartInstaller(Src: TStrings);
|
||||
|
||||
begin
|
||||
With Src do
|
||||
begin
|
||||
Add('{$mode objfpc}{$H+}');
|
||||
Add('program fpmake;');
|
||||
|
||||
Add('');
|
||||
Add(' { Generated automatically by '+ExtractFileName(Paramstr(0))+' on '+DateToStr(Sysutils.Date)+' }');
|
||||
Add('');
|
||||
Add('uses fpmkunit;');
|
||||
Add('');
|
||||
Add('Var');
|
||||
Add(' T : TTarget;');
|
||||
Add('');
|
||||
Add('begin');
|
||||
Add(' With Installer do ');
|
||||
Add(' begin');
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TMakeFileConverter.EndInstaller(Src: TStrings);
|
||||
begin
|
||||
With Src do
|
||||
begin
|
||||
Add(' Run;');
|
||||
Add(' end;');
|
||||
Add('end.');
|
||||
Add('');
|
||||
end;
|
||||
end;
|
||||
|
||||
Function TMakeFileConverter.GetLine (L : TStrings; Var I : Integer) : String;
|
||||
|
||||
Var
|
||||
P : Integer;
|
||||
OK : Boolean;
|
||||
|
||||
begin
|
||||
OK:=False;
|
||||
Result:='';
|
||||
Repeat
|
||||
Result:=Result+L[i];
|
||||
P:=Pos('#',Result);
|
||||
If (P>0) then
|
||||
Result:=Copy(Result,1,P-1);
|
||||
Result:=Trim(Result);
|
||||
P:=Length(Result);
|
||||
If (P>0) and (Result[P]='\') then
|
||||
Result:=Copy(Result,1,P-1)
|
||||
else
|
||||
OK:=(Result<>'');
|
||||
if Not OK then
|
||||
Inc(I);
|
||||
Until OK or (I>L.Count-1);
|
||||
end;
|
||||
|
||||
Function SplitNamevalue(Const S : String; Var AName,AValue : String) : boolean;
|
||||
|
||||
var
|
||||
L : Integer;
|
||||
|
||||
begin
|
||||
L:=Pos('=',S);
|
||||
Result:=(L<>0);
|
||||
If Result then
|
||||
begin
|
||||
AName:=LowerCase(trim(Copy(S,1,L-1)));
|
||||
AValue:=S;
|
||||
Delete(AValue,1,L);
|
||||
AValue:=Trim(Avalue);
|
||||
end
|
||||
else
|
||||
begin
|
||||
AName:='';
|
||||
AValue:='';
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
procedure TMakeFileConverter.StartPackage(Src : TStrings; Dir,OS : String);
|
||||
|
||||
Var
|
||||
S : String;
|
||||
|
||||
begin
|
||||
With Src do
|
||||
begin
|
||||
Add(' { ');
|
||||
Add(' '+FPackageName);
|
||||
Add(' } ');
|
||||
Add(' StartPackage('''+FPackageName+''');');
|
||||
If (Dir<>'') then
|
||||
Add(' Directory:='''+ExcludeTrailingPathDelimiter(Dir)+''';');
|
||||
If (OS<>'') and (OS<>'all') then
|
||||
Add(' OS:=['+OS+'];');
|
||||
If (FPackageVersion<>'') then
|
||||
Add(' Version:='''+FPackageVersion+''';');
|
||||
If (FPackageOptions<>'') then
|
||||
Add(' Options:='''+FPackageOptions+''';');
|
||||
If (FPackageDeps<>'') then
|
||||
begin
|
||||
S:=GetWord(FPackageDeps);
|
||||
While S<>'' do
|
||||
begin
|
||||
Add(' Dependencies.Add('''+S+''');');
|
||||
S:=GetWord(FPackageDeps);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TMakeFileConverter.EndPackage(Src : TStrings; Dir,OS : String);
|
||||
|
||||
begin
|
||||
Src.add(' EndPackage;');
|
||||
FPackageName:='';
|
||||
FPackageVersion:='';
|
||||
FPackageOptions:='';
|
||||
FBuilDUnit:='';
|
||||
FPackageDeps:='';
|
||||
end;
|
||||
|
||||
|
||||
procedure TMakeFileConverter.DoPackageLine(Const S : String);
|
||||
|
||||
Var V,N : String;
|
||||
|
||||
begin
|
||||
SplitNameValue(S,N,V);
|
||||
If (N='name') then
|
||||
FPackageName:=V
|
||||
else If (N='version') then
|
||||
FPackageVersion:=V
|
||||
else If (N='main') then
|
||||
begin
|
||||
FPackageName:='sub';
|
||||
FSubName:=V;
|
||||
end
|
||||
else
|
||||
Writeln(StdErr,'Unknown name/value pair in package section :',N);
|
||||
end;
|
||||
|
||||
|
||||
{
|
||||
Convert various entries of type
|
||||
XXYY_OSN=words
|
||||
to entries of type
|
||||
prefix_word=OS1,OS2,OS3
|
||||
OS is never empty, 'all' is default.
|
||||
}
|
||||
Procedure AddStrings(Var L : TStrings; Values,Prefix,OS : String) ;
|
||||
|
||||
Var
|
||||
S,O : String;
|
||||
i : integer;
|
||||
|
||||
begin
|
||||
If (L=Nil) then
|
||||
L:=TstringList.Create;
|
||||
If prefix<>'' then
|
||||
prefix:=prefix+'_';
|
||||
S:=GetWord(Values);
|
||||
While (S<>'') do
|
||||
begin
|
||||
S:=Prefix+S;
|
||||
I:=L.IndexOfName(S);
|
||||
If (I<>-1) then
|
||||
begin
|
||||
O:=L.Values[S];
|
||||
If (O='all') then
|
||||
O:='';
|
||||
If (O<>'') then
|
||||
O:=O+',';
|
||||
O:=O+OS;
|
||||
L.Values[S]:=O;
|
||||
end
|
||||
else
|
||||
L.Add(S+'='+OS);
|
||||
S:=GetWord(Values);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
procedure TMakeFileConverter.DoTargetLine(Line : String; Var T,R,D : TStrings);
|
||||
|
||||
Var
|
||||
V,N,OS : String;
|
||||
P : Integer;
|
||||
|
||||
begin
|
||||
SplitNameValue(Line,N,V);
|
||||
P:=Pos('_',N);
|
||||
If (P=0) then
|
||||
OS:='all'
|
||||
else
|
||||
begin
|
||||
OS:=N;
|
||||
Delete(OS,1,P);
|
||||
N:=Copy(N,1,P-1);
|
||||
end;
|
||||
If (N='dirs') then
|
||||
AddStrings(D,V,'',OS)
|
||||
else If (N='units') then
|
||||
AddStrings(T,V,'unit',OS)
|
||||
else If (N='implicitunits') then
|
||||
AddStrings(T,V,'unit',OS)
|
||||
else If (N='programs') then
|
||||
AddStrings(T,V,'program',OS)
|
||||
else If (N='examples') then
|
||||
AddStrings(T,V,'exampleunit',OS)
|
||||
else If (N='rsts') then
|
||||
AddStrings(R,V,'',OS)
|
||||
else
|
||||
Writeln(StdErr,'Unknown name/value pair in target section : ',Line);
|
||||
end;
|
||||
|
||||
procedure TMakeFileConverter.DoInstallLine(Line : String; Var IFL : TStrings);
|
||||
|
||||
Var
|
||||
S,V,N,OS : String;
|
||||
P : Integer;
|
||||
|
||||
begin
|
||||
SplitNameValue(Line,N,V);
|
||||
P:=Pos('_',N);
|
||||
If (P=0) then
|
||||
OS:='all'
|
||||
else
|
||||
begin
|
||||
OS:=N;
|
||||
Delete(OS,1,P);
|
||||
N:=Copy(N,1,P-1);
|
||||
end;
|
||||
If (N='fpcpackage') then
|
||||
P:=0 // temporary, needs fixing.
|
||||
else If (N='buildunit') then
|
||||
FBuildUnit:=V // temporary, needs fixing.
|
||||
else If (N='units') then
|
||||
begin
|
||||
S:=GetWord(V);
|
||||
While (S<>'') do
|
||||
begin
|
||||
AddStrings(IFL,S+'.o','',OS);
|
||||
AddStrings(IFL,S+'.ppu','',OS);
|
||||
S:=GetWord(V);
|
||||
end;
|
||||
end
|
||||
else
|
||||
Writeln(StdErr,'Unknown name/value pair in install section : ',N);
|
||||
end;
|
||||
|
||||
procedure TMakeFileConverter.DoCleanLine(Line : String; Var CFL : TStrings);
|
||||
|
||||
Var
|
||||
V,N,S,OS : String;
|
||||
P : Integer;
|
||||
|
||||
begin
|
||||
SplitNameValue(Line,N,V);
|
||||
P:=Pos('_',N);
|
||||
If (P=0) then
|
||||
OS:='all'
|
||||
else
|
||||
begin
|
||||
OS:=N;
|
||||
Delete(OS,1,P);
|
||||
N:=Copy(N,1,P-1);
|
||||
end;
|
||||
If (N='fpcpackage') then
|
||||
P:=0 // temporary, needs fixing.
|
||||
else If (N='units') then
|
||||
begin
|
||||
S:=GetWord(V);
|
||||
While (S<>'') do
|
||||
begin
|
||||
AddStrings(CFL,S+'.o','',OS);
|
||||
AddStrings(CFL,S+'.ppu','',OS);
|
||||
S:=GetWord(V);
|
||||
end;
|
||||
end
|
||||
else
|
||||
Writeln(StdErr,'Unknown name/value pair in clean section : ',N);
|
||||
end;
|
||||
|
||||
procedure TMakeFileConverter.DoRequireLine(Line : String);
|
||||
|
||||
Var
|
||||
V,N,OS : String;
|
||||
P : Integer;
|
||||
|
||||
begin
|
||||
SplitNameValue(Line,N,V);
|
||||
P:=Pos('_',N);
|
||||
If (P=0) then
|
||||
OS:='all'
|
||||
else
|
||||
begin
|
||||
OS:=N;
|
||||
Delete(OS,1,P);
|
||||
N:=Copy(N,1,P-1);
|
||||
end;
|
||||
if (N='packages') then
|
||||
FPackageDeps:=V
|
||||
else If (N='libc') and (Upcase(V)='Y') then
|
||||
P:=0 // Set options ?
|
||||
else
|
||||
Writeln(StdErr,'Unknown name/value pair in require section : ',N);
|
||||
end;
|
||||
|
||||
|
||||
procedure TMakeFileConverter.DoCompilerLine(Line : String;Var SD : TStrings);
|
||||
|
||||
Var
|
||||
V,N,OS : String;
|
||||
P : Integer;
|
||||
|
||||
begin
|
||||
SplitNameValue(Line,N,V);
|
||||
P:=Pos('_',N);
|
||||
If (P=0) then
|
||||
OS:='all'
|
||||
else
|
||||
begin
|
||||
OS:=N;
|
||||
Delete(OS,1,P);
|
||||
N:=Copy(N,1,P-1);
|
||||
end;
|
||||
If (N='includedir') then
|
||||
FPackageOptions:=Trim(FPackageOptions+' -Fi'+V)
|
||||
else If (N='options') then
|
||||
FPackageOptions:=Trim(FPackageOptions+' '+V)
|
||||
else If (N='targetdir') then
|
||||
P:=0 // Ignore
|
||||
else if (N='sourcedir') or (N='unitdir') then
|
||||
begin
|
||||
If (SD=Nil) then
|
||||
SD:=TStringList.Create;
|
||||
SD.Add(OS+'='+V);
|
||||
end
|
||||
else
|
||||
Writeln(StdErr,'Unknown name/value pair in compiler section : ',N);
|
||||
end;
|
||||
|
||||
Function SearchInDirs(Prefix,AName, Dirs : String) : string;
|
||||
|
||||
Var
|
||||
D,S : String;
|
||||
|
||||
begin
|
||||
S:=GetWord(Dirs);
|
||||
Result:='';
|
||||
While (Result='') and (S<>'') do
|
||||
begin
|
||||
D:=Prefix+S+PathDelim;
|
||||
If FileExists(D+AName+'.pp') or FileExists(D+AName+'.pas') then
|
||||
Result:=S;
|
||||
S:=GetWord(Dirs);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TMakeFileConverter.DoTargets(Src,T,R,SD : TStrings; Dir,Prefix : String);
|
||||
|
||||
Var
|
||||
I,J,P : Integer;
|
||||
Pre,N,V,D,DOS,OS,CPU : String;
|
||||
Res : Boolean;
|
||||
|
||||
begin
|
||||
If (Dir<>'') then
|
||||
Dir:=IncludeTrailingPathDelimiter(Dir);
|
||||
If (Prefix<>'') then
|
||||
Prefix:=IncludeTrailingPathDelimiter(Prefix);
|
||||
Dir:=Prefix+Dir;
|
||||
Res:=False;
|
||||
If Assigned(T) then
|
||||
For I:=0 to T.Count-1 do
|
||||
begin
|
||||
T.GetNamevalue(I,N,V);
|
||||
P:=Pos('_',N);
|
||||
If (P<>0) then
|
||||
begin
|
||||
Pre:=Copy(N,1,P-1);
|
||||
Delete(N,1,P);
|
||||
end;
|
||||
If Assigned(R) then
|
||||
Res:=R.IndexOfName(N)<>-1;
|
||||
GetOSCPU(V,OS,CPU);
|
||||
Pre[1]:=Upcase(Pre[1]);
|
||||
Src.Add(' T:=Targets.Add'+Pre+'('''+Prefix+N+''');');
|
||||
If (CPU<>'') then
|
||||
Src.Add(' T.CPU:=['+CPU+'];');
|
||||
If (OS<>'') then
|
||||
Src.Add(' T.OS:=['+OS+'];');
|
||||
If res then
|
||||
Src.add(' T.ResourceStrings:=True;');
|
||||
If (CompareText(FBuildUnit,N)=0) then
|
||||
Src.add(' T.Install:=False;');
|
||||
if Assigned(SD) then
|
||||
for J:=0 to SD.Count-1 do
|
||||
begin
|
||||
SD.GetNameValue(J,DOS,D);
|
||||
If (DOS<>'all') then
|
||||
Src.Add(' if (Defaults.OS='+DOS+') then');
|
||||
Src.add(' T.Directory:='''+SearchInDirs(Dir,N,D)+''';');
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TMakeFileConverter.WriteOSCPUCheck(Src: TStrings;OS,CPU : String);
|
||||
|
||||
Var
|
||||
S : String;
|
||||
|
||||
begin
|
||||
If (CPU<>'') then
|
||||
S:='(Defaults.CPU='+CPU+')';
|
||||
If (OS<>'') then
|
||||
begin
|
||||
IF (S<>'') then
|
||||
S:=S+' OR ';
|
||||
S:=S+'(Defaults.OS='+CPU+')';
|
||||
end;
|
||||
If (S<>'') then
|
||||
Src.Add(' If '+S+' then');
|
||||
end;
|
||||
|
||||
procedure TMakeFileConverter.DoInstalls(Src,IFL : TStrings);
|
||||
|
||||
Var
|
||||
I,J,P : Integer;
|
||||
Pre,N,V,D,DOS,OS,CPU : String;
|
||||
|
||||
begin
|
||||
If Assigned(IFL) then
|
||||
For I:=0 to IFL.Count-1 do
|
||||
begin
|
||||
IFL.GetNamevalue(I,N,V);
|
||||
GetOSCPU(V,OS,CPU);
|
||||
WriteOSCPUCheck(Src,OS,CPU);
|
||||
Src.add(' InstallFiles.Add('''+N+''');');
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TMakeFileConverter.DoCleans(Src,CFL : TStrings);
|
||||
|
||||
Var
|
||||
I,J,P : Integer;
|
||||
N,V,DOS,OS,CPU : String;
|
||||
|
||||
|
||||
begin
|
||||
If Assigned(CFL) then
|
||||
For I:=0 to CFL.Count-1 do
|
||||
begin
|
||||
CFL.GetNamevalue(I,N,V);
|
||||
GetOSCPU(V,OS,CPU);
|
||||
WriteOSCPUCheck(Src,OS,CPU);
|
||||
Src.add(' CleanFiles.Add('''+N+''');');
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
procedure TMakeFileConverter.ConvertFile(const AFileName: String; Src: TStrings; Dir,OS : String);
|
||||
|
||||
Function IsSection(var S : String) : Boolean;
|
||||
|
||||
Var
|
||||
L : Integer;
|
||||
|
||||
begin
|
||||
L:=Length(S);
|
||||
Result:=(L>0) and (S[1]='[') and (S[L]=']');
|
||||
If Result then
|
||||
S:=trim(Copy(S,2,L-2));
|
||||
end;
|
||||
|
||||
Var
|
||||
R,L,T,D,S,SD,IFL,CFL : TStrings;
|
||||
I,J : Integer;
|
||||
Prefix,Line,DN : String;
|
||||
B : Boolean;
|
||||
|
||||
begin
|
||||
Writeln('Converting '+AFileName);
|
||||
T:=Nil;
|
||||
D:=Nil;
|
||||
S:=Nil;
|
||||
SD:=Nil;
|
||||
R:=Nil;
|
||||
IFL:=Nil;
|
||||
CFL:=Nil;
|
||||
FPackageOptions:='';
|
||||
FPackageDir:='';
|
||||
L:=TStringList.Create;
|
||||
try
|
||||
L.LoadFromFile(AFileName);
|
||||
I:=0;
|
||||
While (I<L.Count) do
|
||||
begin
|
||||
Line:=GetLine(L,I);
|
||||
If IsSection(Line) then
|
||||
begin
|
||||
J:=GetEnumValue(TypeInfo(TSectionType),'st'+Line);
|
||||
If (J=-1) then
|
||||
begin
|
||||
FSection:=stNone;
|
||||
Writeln(stdErr,'Unsupported section: ',Line);
|
||||
end
|
||||
else
|
||||
FSection:=TSectiontype(J);
|
||||
end
|
||||
else
|
||||
case FSection of
|
||||
stPackage : DoPackageLine(Line);
|
||||
stTarget : DoTargetLine(Line,T,R,D);
|
||||
stInstall : DoInstallLine(Line,IFL);
|
||||
stClean : DoCleanLine(Line,CFL);
|
||||
stCompiler : DoCompilerLine(Line,SD);
|
||||
strequire : DoRequireLine(Line);
|
||||
end;
|
||||
inc(I);
|
||||
end;
|
||||
// If there are only 'dir' entries, then there is no package name.
|
||||
B:=False;
|
||||
if (FPackageName<>'') then
|
||||
begin
|
||||
Prefix:='';
|
||||
B:=FPackageName<>'sub';
|
||||
If B then
|
||||
StartPackage(Src,Dir,OS)
|
||||
else
|
||||
Prefix:=Dir;
|
||||
DoTargets(Src,T,R,SD,Dir,Prefix);
|
||||
DoInstalls(Src,IFL);
|
||||
DoCleans(Src,CFL);
|
||||
end;
|
||||
If Assigned(D) then
|
||||
begin
|
||||
If (Dir<>'') then
|
||||
Dir:=IncludeTrailingPathDelimiter(Dir);
|
||||
For I:=0 to D.Count-1 do
|
||||
begin
|
||||
D.GetNameValue(I,DN,Line);
|
||||
If (Line<>'all') and (Line<>'') then
|
||||
OS:=Line;
|
||||
DN:=Dir+DN+PathDelim;
|
||||
If FileExists(DN+'Makefile.fpc') then
|
||||
ConvertFile(DN+'Makefile.fpc',Src,DN,OS);
|
||||
end;
|
||||
end;
|
||||
If B then
|
||||
EndPackage(Src,Dir,OS);
|
||||
Finally
|
||||
S.Free;
|
||||
IFL.Free;
|
||||
CFL.Free;
|
||||
D.Free;
|
||||
SD.Free;
|
||||
T.Free;
|
||||
L.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TMakeFileConverter.ConvertFile(const Source, Dest: String);
|
||||
|
||||
Var
|
||||
L : TStrings;
|
||||
|
||||
begin
|
||||
L:=TStringList.Create;
|
||||
Try
|
||||
StartInstaller(L);
|
||||
ConvertFile(Source,L,'','');
|
||||
EndInstaller(L);
|
||||
L.SaveToFile(Dest);
|
||||
Finally
|
||||
L.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
{ TMakeTool }
|
||||
|
||||
procedure TMakeTool.CompileFPMake(Extra: Boolean);
|
||||
@ -746,7 +61,7 @@ end;
|
||||
procedure TMakeTool.CreateFPMake;
|
||||
begin
|
||||
Log(SLogGeneratingFPMake);
|
||||
With TMakeFileConverter.Create do
|
||||
With TMakeFileConverter.Create(Nil) do
|
||||
try
|
||||
ConvertFile('Makefile.fpc','fpmake.pp');
|
||||
finally
|
||||
@ -910,7 +225,7 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
procedure TMakeTool.Run;
|
||||
procedure TMakeTool.DoRun;
|
||||
|
||||
|
||||
begin
|
||||
@ -953,7 +268,7 @@ end;
|
||||
|
||||
|
||||
begin
|
||||
With TMakeTool.Create do
|
||||
With TMakeTool.Create(Nil) do
|
||||
try
|
||||
run;
|
||||
finally
|
||||
|
105
utils/fppkg/pkgdownload.pp
Normal file
105
utils/fppkg/pkgdownload.pp
Normal file
@ -0,0 +1,105 @@
|
||||
unit pkgdownload;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, pkghandler;
|
||||
|
||||
Type
|
||||
|
||||
{ TBasePackageDownloader }
|
||||
|
||||
TBasePackageDownloader = Class(TPackageHandler)
|
||||
Protected
|
||||
// Needs overriding.
|
||||
Procedure FTPDownload(Const URL : String; Dest : TStream); Virtual;
|
||||
Procedure HTTPDownload(Const URL : String; Dest : TStream); Virtual;
|
||||
Procedure FileDownload(Const URL : String; Dest : TStream); Virtual;
|
||||
Public
|
||||
Procedure Download(Const URL,DestFileName : String);
|
||||
Procedure Download(Const URL : String; Dest : TStream);
|
||||
end;
|
||||
TBasePackageDownloaderClass = Class of TBasePackageDownloader;
|
||||
|
||||
Var
|
||||
DownloaderClass : TBasePackageDownloaderClass;
|
||||
|
||||
implementation
|
||||
|
||||
uses pkgmessages,uriparser;
|
||||
|
||||
{ TBasePackageDownloader }
|
||||
|
||||
procedure TBasePackageDownloader.FTPDownload(const URL: String; Dest: TStream);
|
||||
begin
|
||||
Error(SErrNoFTPDownload);
|
||||
end;
|
||||
|
||||
procedure TBasePackageDownloader.HTTPDownload(const URL: String; Dest: TStream);
|
||||
begin
|
||||
Error(SErrNoHTTPDownload);
|
||||
end;
|
||||
|
||||
procedure TBasePackageDownloader.FileDownload(const URL: String; Dest: TStream);
|
||||
|
||||
Var
|
||||
URI : TURI;
|
||||
FN : String;
|
||||
F : TFileStream;
|
||||
|
||||
begin
|
||||
URI:=ParseURI(URL);
|
||||
FN:=URI.Path+'/'+URI.Document;
|
||||
If Not FileExists(FN) then
|
||||
Error(SErrNoSuchFile,[FN]);
|
||||
F:=TFileStream.Create(FN,fmOpenRead);
|
||||
Try
|
||||
Dest.CopyFrom(F,0);
|
||||
Finally
|
||||
F.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TBasePackageDownloader.Download(const URL, DestFileName: String);
|
||||
|
||||
Var
|
||||
F : TFileStream;
|
||||
|
||||
begin
|
||||
If FileExists(DestFileName) and BackupFiles then
|
||||
BackupFile(DestFileName);
|
||||
F:=TFileStream.Create(DestFileName,fmCreate);
|
||||
Try
|
||||
Download(URL,F);
|
||||
Finally
|
||||
F.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TBasePackageDownloader.Download(const URL: String; Dest: TStream);
|
||||
|
||||
Var
|
||||
URI : TURI;
|
||||
P : String;
|
||||
|
||||
begin
|
||||
URI:=ParseURI(URL);
|
||||
P:=URI.Protocol;
|
||||
If CompareText(P,'ftp')=0 then
|
||||
FTPDownload(URL,Dest)
|
||||
else if CompareText(P,'http')=0 then
|
||||
HTTPDownload(URL,Dest)
|
||||
else if CompareText(P,'file')=0 then
|
||||
FileDownload(URL,Dest)
|
||||
else
|
||||
Error(SErrUnknownProtocol,[P]);
|
||||
end;
|
||||
|
||||
initialization
|
||||
// Default value.
|
||||
DownloaderClass := TBasePackageDownloader;
|
||||
|
||||
end.
|
||||
|
97
utils/fppkg/pkghandler.pp
Normal file
97
utils/fppkg/pkghandler.pp
Normal file
@ -0,0 +1,97 @@
|
||||
{$mode objfpc}
|
||||
{$h+}
|
||||
unit pkghandler;
|
||||
|
||||
interface
|
||||
|
||||
uses Classes,SysUtils, fpmktype;
|
||||
|
||||
Type
|
||||
|
||||
TVerbosity = (vError,vInfo,vCommands,vDebug);
|
||||
TVerbosities = Set of TVerbosity;
|
||||
TMessageEvent = Procedure (Sender : TObject; Const Msg : String) of object;
|
||||
|
||||
{ TPackageHandler }
|
||||
|
||||
TPackageHandler = Class(TComponent)
|
||||
private
|
||||
FBackupFile: Boolean;
|
||||
FOnMessage: TMessageEvent;
|
||||
FVerbosity: TVerbosities;
|
||||
Protected
|
||||
Procedure Error(Const Msg : String);
|
||||
Procedure Error(Const Fmt : String; Args : Array of const);
|
||||
Public
|
||||
Procedure BackupFile(Const FileName : String);
|
||||
Constructor Create(AOwner : TComponent); override;
|
||||
Procedure Verbose(Msg : String);
|
||||
Procedure Verbose(Fmt : String; Args : Array of const);
|
||||
Procedure Verbose(Level : TVerbosity; Msg : String);
|
||||
Procedure Verbose(Level : TVerbosity; Fmt : String; Args : Array of const);
|
||||
Property BackupFiles : Boolean Read FBackupFile Write FBackupFile;
|
||||
Property OnMessage : TMessageEvent Read FOnMessage Write FOnMessage;
|
||||
Property Verbosity : TVerbosities Read FVerbosity Write FVerbosity;
|
||||
end;
|
||||
|
||||
EPackageHandler = Class(EInstallerError);
|
||||
|
||||
Implementation
|
||||
|
||||
uses pkgmessages;
|
||||
|
||||
{ TPackageHandler }
|
||||
|
||||
procedure TPackageHandler.Error(const Msg: String);
|
||||
begin
|
||||
Raise EPackageHandler.CreateFmt('%s : %s',[ClassName,Msg]);
|
||||
end;
|
||||
|
||||
procedure TPackageHandler.Error(const Fmt: String; Args: Array of const);
|
||||
begin
|
||||
Error(Format(Fmt,Args));
|
||||
end;
|
||||
|
||||
procedure TPackageHandler.BackupFile(const FileName: String);
|
||||
|
||||
Var
|
||||
BFN : String;
|
||||
|
||||
|
||||
begin
|
||||
BFN:=FileName+'.bak';
|
||||
If not RenameFile(FileName,BFN) then
|
||||
Error(SErrBackupFailed,[FileName,BFN]);
|
||||
end;
|
||||
|
||||
constructor TPackageHandler.Create(AOwner: TComponent);
|
||||
begin
|
||||
inherited Create(AOwner);
|
||||
FVerbosity:=[vError];
|
||||
end;
|
||||
|
||||
procedure TPackageHandler.Verbose(Msg: String);
|
||||
begin
|
||||
Verbose(vInfo,Msg);
|
||||
end;
|
||||
|
||||
procedure TPackageHandler.Verbose(Fmt: String; Args: array of const);
|
||||
begin
|
||||
Verbose(vInfo,Fmt,Args);
|
||||
end;
|
||||
|
||||
procedure TPackageHandler.Verbose(Level: TVerbosity; Msg: String);
|
||||
begin
|
||||
If (Level in FVerbosity) and Assigned(FOnMessage) then
|
||||
FOnMessage(Self,Msg);
|
||||
end;
|
||||
|
||||
procedure TPackageHandler.Verbose(Level: TVerbosity; Fmt: String;
|
||||
Args: array of const);
|
||||
begin
|
||||
// Save a format call
|
||||
If (Level in FVerbosity) and Assigned(FOnMessage) then
|
||||
Verbose(Level,Format(Fmt,Args));
|
||||
end;
|
||||
|
||||
end.
|
27
utils/fppkg/pkgmessages.pp
Normal file
27
utils/fppkg/pkgmessages.pp
Normal file
@ -0,0 +1,27 @@
|
||||
unit pkgmessages;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
|
||||
Resourcestring
|
||||
// SErrInValidArgument = 'Invalid command-line argument at position %d : %s';
|
||||
SErrNeedArgument = 'Option at position %d (%s) needs an argument';
|
||||
SErrMissingConfig = 'Missing configuration Makefile.fpc or fpmake.pp';
|
||||
SErrRunning = 'The FPC make tool encountered the following error: %s';
|
||||
SErrFailedToCompileFPCMake = 'Could not compile fpmake driver program';
|
||||
SErrNoFTPDownload = 'This binary has no support for FTP downloads.';
|
||||
SErrNoHTTPDownload = 'This binary has no support for HTTP downloads.';
|
||||
SErrBackupFailed = 'Backup of file "%s" to file "%s" failed.';
|
||||
SErrUnknownProtocol = 'Unknown download protocol: "%s"';
|
||||
SErrNoSuchFile = 'File "%s" does not exist.';
|
||||
|
||||
SLogGeneratingFPMake = 'Generating fpmake.pp';
|
||||
SLogCompilingFPMake = 'Compiling fpmake.pp: ';
|
||||
SLogRunningFPMake = 'Running fpmake';
|
||||
|
||||
implementation
|
||||
|
||||
end.
|
||||
|
695
utils/fppkg/pkgmkconv.pp
Normal file
695
utils/fppkg/pkgmkconv.pp
Normal file
@ -0,0 +1,695 @@
|
||||
unit pkgmkconv;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils,pkghandler;
|
||||
{ TMakeFileConverter }
|
||||
|
||||
Type
|
||||
TSectionType = (stNone,stPackage,stTarget,stclean,stinstall,stCompiler,
|
||||
stDefault,stRequire,stRules,stPrerules);
|
||||
|
||||
TMakeFileConverter = Class(TPackagehandler)
|
||||
Private
|
||||
FSection : TSectionType;
|
||||
FPackageName,
|
||||
FpackageDir,
|
||||
FPackageOptions,
|
||||
FPackageDeps,
|
||||
FBuilDUnit,
|
||||
FSubName,
|
||||
FPackageVersion : String;
|
||||
// Reading;
|
||||
procedure DoPackageLine(Const S : String);
|
||||
Procedure DoTargetLine(Line : String; Var T,R,D : TStrings);
|
||||
Procedure DoInstallLine(Line : String; Var IFL : TStrings);
|
||||
procedure DoCleanLine(Line : String; Var CFL : TStrings);
|
||||
procedure DoRequireLine(Line : String);
|
||||
procedure DoCompilerLine(Line : String;Var SD : TStrings);
|
||||
// Writing;
|
||||
procedure WriteOSCPUCheck(Src: TStrings;OS,CPU : String);
|
||||
procedure StartPackage(Src : TStrings; Dir,OS : String);
|
||||
procedure EndPackage(Src : TStrings; Dir,OS : String);
|
||||
procedure DoTargets(Src,T,R,SD : TStrings; Dir,Prefix : String);
|
||||
procedure DoCleans(Src,CFL : TStrings);
|
||||
procedure DoInstalls(Src,IFL : TStrings);
|
||||
Procedure StartInstaller(Src : TStrings);
|
||||
Procedure EndInstaller(Src : TStrings);
|
||||
Function GetLine (L : TStrings; Var I : Integer) : String;
|
||||
Public
|
||||
procedure ConvertFile(const AFileName: String; Src: TStrings; Dir,OS : String);
|
||||
Procedure ConvertFile(Const Source,Dest: String);
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses typinfo;
|
||||
|
||||
Function GetWord(var S : String; Sep : Char) : String;
|
||||
|
||||
Var
|
||||
L : Integer;
|
||||
|
||||
begin
|
||||
L:=Pos(Sep,S);
|
||||
If (L=0) then
|
||||
L:=Length(S)+1;
|
||||
Result:=Copy(S,1,L-1);
|
||||
Delete(S,1,L);
|
||||
S:=Trim(S);
|
||||
end;
|
||||
|
||||
Function GetWord(var S : String) : String;
|
||||
|
||||
begin
|
||||
Result:=GetWord(S,' ');
|
||||
end;
|
||||
|
||||
|
||||
Function IsCPU (S: String) : Boolean;
|
||||
|
||||
begin
|
||||
Result:=Pos(lowercase(S)+',','i386,powerpc,arm,alpha,sparc,')<>0
|
||||
end;
|
||||
|
||||
Function GetOSCPU(L : String; var OS,CPU : String) : String;
|
||||
|
||||
Procedure Add(Var A : String; ad : String);
|
||||
|
||||
begin
|
||||
If (A<>'') then
|
||||
A:=A+',';
|
||||
A:=A+ad;
|
||||
end;
|
||||
|
||||
|
||||
Var
|
||||
S : String;
|
||||
|
||||
begin
|
||||
OS:='';
|
||||
CPU:='';
|
||||
S:=GetWord(L,',');
|
||||
While (S<>'') do
|
||||
begin
|
||||
If (S<>'all') then
|
||||
If IsCPU(S) then
|
||||
Add(CPU,S)
|
||||
else
|
||||
Add(OS,S);
|
||||
S:=GetWord(L,',');
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
{ TMakeFileConverter }
|
||||
|
||||
procedure TMakeFileConverter.StartInstaller(Src: TStrings);
|
||||
|
||||
begin
|
||||
With Src do
|
||||
begin
|
||||
Add('{$mode objfpc}{$H+}');
|
||||
Add('program fpmake;');
|
||||
|
||||
Add('');
|
||||
Add(' { Generated automatically by '+ExtractFileName(Paramstr(0))+' on '+DateToStr(Sysutils.Date)+' }');
|
||||
Add('');
|
||||
Add('uses fpmkunit;');
|
||||
Add('');
|
||||
Add('Var');
|
||||
Add(' T : TTarget;');
|
||||
Add('');
|
||||
Add('begin');
|
||||
Add(' With Installer do ');
|
||||
Add(' begin');
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TMakeFileConverter.EndInstaller(Src: TStrings);
|
||||
begin
|
||||
With Src do
|
||||
begin
|
||||
Add(' Run;');
|
||||
Add(' end;');
|
||||
Add('end.');
|
||||
Add('');
|
||||
end;
|
||||
end;
|
||||
|
||||
Function TMakeFileConverter.GetLine (L : TStrings; Var I : Integer) : String;
|
||||
|
||||
Var
|
||||
P : Integer;
|
||||
OK : Boolean;
|
||||
|
||||
begin
|
||||
OK:=False;
|
||||
Result:='';
|
||||
Repeat
|
||||
Result:=Result+L[i];
|
||||
P:=Pos('#',Result);
|
||||
If (P>0) then
|
||||
Result:=Copy(Result,1,P-1);
|
||||
Result:=Trim(Result);
|
||||
P:=Length(Result);
|
||||
If (P>0) and (Result[P]='\') then
|
||||
Result:=Copy(Result,1,P-1)
|
||||
else
|
||||
OK:=(Result<>'');
|
||||
if Not OK then
|
||||
Inc(I);
|
||||
Until OK or (I>L.Count-1);
|
||||
end;
|
||||
|
||||
Function SplitNamevalue(Const S : String; Var AName,AValue : String) : boolean;
|
||||
|
||||
var
|
||||
L : Integer;
|
||||
|
||||
begin
|
||||
L:=Pos('=',S);
|
||||
Result:=(L<>0);
|
||||
If Result then
|
||||
begin
|
||||
AName:=LowerCase(trim(Copy(S,1,L-1)));
|
||||
AValue:=S;
|
||||
Delete(AValue,1,L);
|
||||
AValue:=Trim(Avalue);
|
||||
end
|
||||
else
|
||||
begin
|
||||
AName:='';
|
||||
AValue:='';
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
procedure TMakeFileConverter.StartPackage(Src : TStrings; Dir,OS : String);
|
||||
|
||||
Var
|
||||
S : String;
|
||||
|
||||
begin
|
||||
With Src do
|
||||
begin
|
||||
Add(' { ');
|
||||
Add(' '+FPackageName);
|
||||
Add(' } ');
|
||||
Add(' StartPackage('''+FPackageName+''');');
|
||||
If (Dir<>'') then
|
||||
Add(' Directory:='''+ExcludeTrailingPathDelimiter(Dir)+''';');
|
||||
If (OS<>'') and (OS<>'all') then
|
||||
Add(' OS:=['+OS+'];');
|
||||
If (FPackageVersion<>'') then
|
||||
Add(' Version:='''+FPackageVersion+''';');
|
||||
If (FPackageOptions<>'') then
|
||||
Add(' Options:='''+FPackageOptions+''';');
|
||||
If (FPackageDeps<>'') then
|
||||
begin
|
||||
S:=GetWord(FPackageDeps);
|
||||
While S<>'' do
|
||||
begin
|
||||
Add(' Dependencies.Add('''+S+''');');
|
||||
S:=GetWord(FPackageDeps);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TMakeFileConverter.EndPackage(Src : TStrings; Dir,OS : String);
|
||||
|
||||
begin
|
||||
Src.add(' EndPackage;');
|
||||
FPackageName:='';
|
||||
FPackageVersion:='';
|
||||
FPackageOptions:='';
|
||||
FBuilDUnit:='';
|
||||
FPackageDeps:='';
|
||||
end;
|
||||
|
||||
|
||||
procedure TMakeFileConverter.DoPackageLine(Const S : String);
|
||||
|
||||
Var V,N : String;
|
||||
|
||||
begin
|
||||
SplitNameValue(S,N,V);
|
||||
If (N='name') then
|
||||
FPackageName:=V
|
||||
else If (N='version') then
|
||||
FPackageVersion:=V
|
||||
else If (N='main') then
|
||||
begin
|
||||
FPackageName:='sub';
|
||||
FSubName:=V;
|
||||
end
|
||||
else
|
||||
Writeln(StdErr,'Unknown name/value pair in package section :',N);
|
||||
end;
|
||||
|
||||
|
||||
{
|
||||
Convert various entries of type
|
||||
XXYY_OSN=words
|
||||
to entries of type
|
||||
prefix_word=OS1,OS2,OS3
|
||||
OS is never empty, 'all' is default.
|
||||
}
|
||||
Procedure AddStrings(Var L : TStrings; Values,Prefix,OS : String) ;
|
||||
|
||||
Var
|
||||
S,O : String;
|
||||
i : integer;
|
||||
|
||||
begin
|
||||
If (L=Nil) then
|
||||
L:=TstringList.Create;
|
||||
If prefix<>'' then
|
||||
prefix:=prefix+'_';
|
||||
S:=GetWord(Values);
|
||||
While (S<>'') do
|
||||
begin
|
||||
S:=Prefix+S;
|
||||
I:=L.IndexOfName(S);
|
||||
If (I<>-1) then
|
||||
begin
|
||||
O:=L.Values[S];
|
||||
If (O='all') then
|
||||
O:='';
|
||||
If (O<>'') then
|
||||
O:=O+',';
|
||||
O:=O+OS;
|
||||
L.Values[S]:=O;
|
||||
end
|
||||
else
|
||||
L.Add(S+'='+OS);
|
||||
S:=GetWord(Values);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
procedure TMakeFileConverter.DoTargetLine(Line : String; Var T,R,D : TStrings);
|
||||
|
||||
Var
|
||||
V,N,OS : String;
|
||||
P : Integer;
|
||||
|
||||
begin
|
||||
SplitNameValue(Line,N,V);
|
||||
P:=Pos('_',N);
|
||||
If (P=0) then
|
||||
OS:='all'
|
||||
else
|
||||
begin
|
||||
OS:=N;
|
||||
Delete(OS,1,P);
|
||||
N:=Copy(N,1,P-1);
|
||||
end;
|
||||
If (N='dirs') then
|
||||
AddStrings(D,V,'',OS)
|
||||
else If (N='units') then
|
||||
AddStrings(T,V,'unit',OS)
|
||||
else If (N='implicitunits') then
|
||||
AddStrings(T,V,'unit',OS)
|
||||
else If (N='programs') then
|
||||
AddStrings(T,V,'program',OS)
|
||||
else If (N='examples') then
|
||||
AddStrings(T,V,'exampleunit',OS)
|
||||
else If (N='rsts') then
|
||||
AddStrings(R,V,'',OS)
|
||||
else
|
||||
Writeln(StdErr,'Unknown name/value pair in target section : ',Line);
|
||||
end;
|
||||
|
||||
procedure TMakeFileConverter.DoInstallLine(Line : String; Var IFL : TStrings);
|
||||
|
||||
Var
|
||||
S,V,N,OS : String;
|
||||
P : Integer;
|
||||
|
||||
begin
|
||||
SplitNameValue(Line,N,V);
|
||||
P:=Pos('_',N);
|
||||
If (P=0) then
|
||||
OS:='all'
|
||||
else
|
||||
begin
|
||||
OS:=N;
|
||||
Delete(OS,1,P);
|
||||
N:=Copy(N,1,P-1);
|
||||
end;
|
||||
If (N='fpcpackage') then
|
||||
P:=0 // temporary, needs fixing.
|
||||
else If (N='buildunit') then
|
||||
FBuildUnit:=V // temporary, needs fixing.
|
||||
else If (N='units') then
|
||||
begin
|
||||
S:=GetWord(V);
|
||||
While (S<>'') do
|
||||
begin
|
||||
AddStrings(IFL,S+'.o','',OS);
|
||||
AddStrings(IFL,S+'.ppu','',OS);
|
||||
S:=GetWord(V);
|
||||
end;
|
||||
end
|
||||
else
|
||||
Writeln(StdErr,'Unknown name/value pair in install section : ',N);
|
||||
end;
|
||||
|
||||
procedure TMakeFileConverter.DoCleanLine(Line : String; Var CFL : TStrings);
|
||||
|
||||
Var
|
||||
V,N,S,OS : String;
|
||||
P : Integer;
|
||||
|
||||
begin
|
||||
SplitNameValue(Line,N,V);
|
||||
P:=Pos('_',N);
|
||||
If (P=0) then
|
||||
OS:='all'
|
||||
else
|
||||
begin
|
||||
OS:=N;
|
||||
Delete(OS,1,P);
|
||||
N:=Copy(N,1,P-1);
|
||||
end;
|
||||
If (N='fpcpackage') then
|
||||
P:=0 // temporary, needs fixing.
|
||||
else If (N='units') then
|
||||
begin
|
||||
S:=GetWord(V);
|
||||
While (S<>'') do
|
||||
begin
|
||||
AddStrings(CFL,S+'.o','',OS);
|
||||
AddStrings(CFL,S+'.ppu','',OS);
|
||||
S:=GetWord(V);
|
||||
end;
|
||||
end
|
||||
else
|
||||
Writeln(StdErr,'Unknown name/value pair in clean section : ',N);
|
||||
end;
|
||||
|
||||
procedure TMakeFileConverter.DoRequireLine(Line : String);
|
||||
|
||||
Var
|
||||
V,N,OS : String;
|
||||
P : Integer;
|
||||
|
||||
begin
|
||||
SplitNameValue(Line,N,V);
|
||||
P:=Pos('_',N);
|
||||
If (P=0) then
|
||||
OS:='all'
|
||||
else
|
||||
begin
|
||||
OS:=N;
|
||||
Delete(OS,1,P);
|
||||
N:=Copy(N,1,P-1);
|
||||
end;
|
||||
if (N='packages') then
|
||||
FPackageDeps:=V
|
||||
else If (N='libc') and (Upcase(V)='Y') then
|
||||
P:=0 // Set options ?
|
||||
else
|
||||
Writeln(StdErr,'Unknown name/value pair in require section : ',N);
|
||||
end;
|
||||
|
||||
|
||||
procedure TMakeFileConverter.DoCompilerLine(Line : String;Var SD : TStrings);
|
||||
|
||||
Var
|
||||
V,N,OS : String;
|
||||
P : Integer;
|
||||
|
||||
begin
|
||||
SplitNameValue(Line,N,V);
|
||||
P:=Pos('_',N);
|
||||
If (P=0) then
|
||||
OS:='all'
|
||||
else
|
||||
begin
|
||||
OS:=N;
|
||||
Delete(OS,1,P);
|
||||
N:=Copy(N,1,P-1);
|
||||
end;
|
||||
If (N='includedir') then
|
||||
FPackageOptions:=Trim(FPackageOptions+' -Fi'+V)
|
||||
else If (N='options') then
|
||||
FPackageOptions:=Trim(FPackageOptions+' '+V)
|
||||
else If (N='targetdir') then
|
||||
P:=0 // Ignore
|
||||
else if (N='sourcedir') or (N='unitdir') then
|
||||
begin
|
||||
If (SD=Nil) then
|
||||
SD:=TStringList.Create;
|
||||
SD.Add(OS+'='+V);
|
||||
end
|
||||
else
|
||||
Writeln(StdErr,'Unknown name/value pair in compiler section : ',N);
|
||||
end;
|
||||
|
||||
Function SearchInDirs(Prefix,AName, Dirs : String) : string;
|
||||
|
||||
Var
|
||||
D,S : String;
|
||||
|
||||
begin
|
||||
S:=GetWord(Dirs);
|
||||
Result:='';
|
||||
While (Result='') and (S<>'') do
|
||||
begin
|
||||
D:=Prefix+S+PathDelim;
|
||||
If FileExists(D+AName+'.pp') or FileExists(D+AName+'.pas') then
|
||||
Result:=S;
|
||||
S:=GetWord(Dirs);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TMakeFileConverter.DoTargets(Src,T,R,SD : TStrings; Dir,Prefix : String);
|
||||
|
||||
Var
|
||||
I,J,P : Integer;
|
||||
Pre,N,V,D,DOS,OS,CPU : String;
|
||||
Res : Boolean;
|
||||
|
||||
begin
|
||||
If (Dir<>'') then
|
||||
Dir:=IncludeTrailingPathDelimiter(Dir);
|
||||
If (Prefix<>'') then
|
||||
Prefix:=IncludeTrailingPathDelimiter(Prefix);
|
||||
Dir:=Prefix+Dir;
|
||||
Res:=False;
|
||||
If Assigned(T) then
|
||||
For I:=0 to T.Count-1 do
|
||||
begin
|
||||
T.GetNamevalue(I,N,V);
|
||||
P:=Pos('_',N);
|
||||
If (P<>0) then
|
||||
begin
|
||||
Pre:=Copy(N,1,P-1);
|
||||
Delete(N,1,P);
|
||||
end;
|
||||
If Assigned(R) then
|
||||
Res:=R.IndexOfName(N)<>-1;
|
||||
GetOSCPU(V,OS,CPU);
|
||||
Pre[1]:=Upcase(Pre[1]);
|
||||
Src.Add(' T:=Targets.Add'+Pre+'('''+Prefix+N+''');');
|
||||
If (CPU<>'') then
|
||||
Src.Add(' T.CPU:=['+CPU+'];');
|
||||
If (OS<>'') then
|
||||
Src.Add(' T.OS:=['+OS+'];');
|
||||
If res then
|
||||
Src.add(' T.ResourceStrings:=True;');
|
||||
If (CompareText(FBuildUnit,N)=0) then
|
||||
Src.add(' T.Install:=False;');
|
||||
if Assigned(SD) then
|
||||
for J:=0 to SD.Count-1 do
|
||||
begin
|
||||
SD.GetNameValue(J,DOS,D);
|
||||
If (DOS<>'all') then
|
||||
Src.Add(' if (Defaults.OS='+DOS+') then');
|
||||
Src.add(' T.Directory:='''+SearchInDirs(Dir,N,D)+''';');
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TMakeFileConverter.WriteOSCPUCheck(Src: TStrings;OS,CPU : String);
|
||||
|
||||
Var
|
||||
S : String;
|
||||
|
||||
begin
|
||||
If (CPU<>'') then
|
||||
S:='(Defaults.CPU='+CPU+')';
|
||||
If (OS<>'') then
|
||||
begin
|
||||
IF (S<>'') then
|
||||
S:=S+' OR ';
|
||||
S:=S+'(Defaults.OS='+CPU+')';
|
||||
end;
|
||||
If (S<>'') then
|
||||
Src.Add(' If '+S+' then');
|
||||
end;
|
||||
|
||||
procedure TMakeFileConverter.DoInstalls(Src,IFL : TStrings);
|
||||
|
||||
Var
|
||||
I,J,P : Integer;
|
||||
Pre,N,V,D,DOS,OS,CPU : String;
|
||||
|
||||
begin
|
||||
If Assigned(IFL) then
|
||||
For I:=0 to IFL.Count-1 do
|
||||
begin
|
||||
IFL.GetNamevalue(I,N,V);
|
||||
GetOSCPU(V,OS,CPU);
|
||||
WriteOSCPUCheck(Src,OS,CPU);
|
||||
Src.add(' InstallFiles.Add('''+N+''');');
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TMakeFileConverter.DoCleans(Src,CFL : TStrings);
|
||||
|
||||
Var
|
||||
I,J,P : Integer;
|
||||
N,V,DOS,OS,CPU : String;
|
||||
|
||||
|
||||
begin
|
||||
If Assigned(CFL) then
|
||||
For I:=0 to CFL.Count-1 do
|
||||
begin
|
||||
CFL.GetNamevalue(I,N,V);
|
||||
GetOSCPU(V,OS,CPU);
|
||||
WriteOSCPUCheck(Src,OS,CPU);
|
||||
Src.add(' CleanFiles.Add('''+N+''');');
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
procedure TMakeFileConverter.ConvertFile(const AFileName: String; Src: TStrings; Dir,OS : String);
|
||||
|
||||
Function IsSection(var S : String) : Boolean;
|
||||
|
||||
Var
|
||||
L : Integer;
|
||||
|
||||
begin
|
||||
L:=Length(S);
|
||||
Result:=(L>0) and (S[1]='[') and (S[L]=']');
|
||||
If Result then
|
||||
S:=trim(Copy(S,2,L-2));
|
||||
end;
|
||||
|
||||
Var
|
||||
R,L,T,D,S,SD,IFL,CFL : TStrings;
|
||||
I,J : Integer;
|
||||
Prefix,Line,DN : String;
|
||||
B : Boolean;
|
||||
|
||||
begin
|
||||
Writeln('Converting '+AFileName);
|
||||
T:=Nil;
|
||||
D:=Nil;
|
||||
S:=Nil;
|
||||
SD:=Nil;
|
||||
R:=Nil;
|
||||
IFL:=Nil;
|
||||
CFL:=Nil;
|
||||
FPackageOptions:='';
|
||||
FPackageDir:='';
|
||||
L:=TStringList.Create;
|
||||
try
|
||||
L.LoadFromFile(AFileName);
|
||||
I:=0;
|
||||
While (I<L.Count) do
|
||||
begin
|
||||
Line:=GetLine(L,I);
|
||||
If IsSection(Line) then
|
||||
begin
|
||||
J:=GetEnumValue(TypeInfo(TSectionType),'st'+Line);
|
||||
If (J=-1) then
|
||||
begin
|
||||
FSection:=stNone;
|
||||
Writeln(stdErr,'Unsupported section: ',Line);
|
||||
end
|
||||
else
|
||||
FSection:=TSectiontype(J);
|
||||
end
|
||||
else
|
||||
case FSection of
|
||||
stPackage : DoPackageLine(Line);
|
||||
stTarget : DoTargetLine(Line,T,R,D);
|
||||
stInstall : DoInstallLine(Line,IFL);
|
||||
stClean : DoCleanLine(Line,CFL);
|
||||
stCompiler : DoCompilerLine(Line,SD);
|
||||
strequire : DoRequireLine(Line);
|
||||
end;
|
||||
inc(I);
|
||||
end;
|
||||
// If there are only 'dir' entries, then there is no package name.
|
||||
B:=False;
|
||||
if (FPackageName<>'') then
|
||||
begin
|
||||
Prefix:='';
|
||||
B:=FPackageName<>'sub';
|
||||
If B then
|
||||
StartPackage(Src,Dir,OS)
|
||||
else
|
||||
Prefix:=Dir;
|
||||
DoTargets(Src,T,R,SD,Dir,Prefix);
|
||||
DoInstalls(Src,IFL);
|
||||
DoCleans(Src,CFL);
|
||||
end;
|
||||
If Assigned(D) then
|
||||
begin
|
||||
If (Dir<>'') then
|
||||
Dir:=IncludeTrailingPathDelimiter(Dir);
|
||||
For I:=0 to D.Count-1 do
|
||||
begin
|
||||
D.GetNameValue(I,DN,Line);
|
||||
If (Line<>'all') and (Line<>'') then
|
||||
OS:=Line;
|
||||
DN:=Dir+DN+PathDelim;
|
||||
If FileExists(DN+'Makefile.fpc') then
|
||||
ConvertFile(DN+'Makefile.fpc',Src,DN,OS);
|
||||
end;
|
||||
end;
|
||||
If B then
|
||||
EndPackage(Src,Dir,OS);
|
||||
Finally
|
||||
S.Free;
|
||||
IFL.Free;
|
||||
CFL.Free;
|
||||
D.Free;
|
||||
SD.Free;
|
||||
T.Free;
|
||||
L.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TMakeFileConverter.ConvertFile(const Source, Dest: String);
|
||||
|
||||
Var
|
||||
L : TStrings;
|
||||
|
||||
begin
|
||||
L:=TStringList.Create;
|
||||
Try
|
||||
StartInstaller(L);
|
||||
ConvertFile(Source,L,'','');
|
||||
EndInstaller(L);
|
||||
L.SaveToFile(Dest);
|
||||
Finally
|
||||
L.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user