* Let fpmake create complete installer

This commit is contained in:
michael 2017-12-28 12:25:41 +00:00
parent c2a989efd1
commit 7d8c29b0a6
3 changed files with 183 additions and 50 deletions

View File

@ -1529,8 +1529,9 @@ zipinstall: fpc_zipinstall
zipsourceinstall: fpc_zipsourceinstall
zipexampleinstall: fpc_zipexampleinstall
zipdistinstall: fpc_zipdistinstall
info: fpc_info
makefiles: fpc_makefiles
.PHONY: units examples shared sourceinstall exampleinstall zipinstall zipsourceinstall zipexampleinstall zipdistinstall makefiles
.PHONY: units examples shared sourceinstall exampleinstall zipinstall zipsourceinstall zipexampleinstall zipdistinstall info makefiles
ifneq ($(wildcard fpcmake.loc),)
include fpcmake.loc
endif
@ -1540,8 +1541,6 @@ override FPCOPT:=$(filter-out $(addprefix -Fu,$(COMPILER_UNITDIR)),$(FPCOPT))# C
ifdef FPMAKEOPT
FPMAKE_OPT+=$(FPMAKEOPT)
endif
FPMAKE_OPT+=--localunitdir=../..
FPMAKE_OPT+=--globalunitdir=../../packages
FPMAKE_OPT+=$(FPC_TARGETOPT)
FPMAKE_OPT+=$(addprefix -o ,$(FPCOPT))
FPMAKE_OPT+=--compiler=$(FPC)
@ -1587,10 +1586,12 @@ ifdef UNIXHier
else
$(LOCALFPMAKE) install $(FPMAKE_OPT) --prefix=$(INSTALL_BASEDIR) --baseinstalldir=$(INSTALL_BASEDIR) --unitinstalldir=$(INSTALL_UNITDIR) -ie -fsp 0
endif
PAS2JSVERSION:=$(shell pas2js -iV)
RTLFILES=$(wildcard src/rtl/*.pas)
RTLFILES+=rtl/rtl.js rtl/pas2js_rtl.lpk
PACKAGEFILES=$(wildcard packages/*/*.pas)
ifndef PAS2JS
PAS2JS=pas2js
endif
PAS2JSVERSION:=$(shell $(PAS2JS) -iV)
PACKAGEFILES=packages/rtl/rtl.js
PACKAGEFILES+=$(wildcard packages/*/*.pas)
PACKAGEFILES+=$(wildcard packages/*/*.pp)
PACKAGEFILES+=$(wildcard packages/*/*.lpk)
DEMOFILES=$(wildcard demo/rtl/*.html)
@ -1621,14 +1622,14 @@ DEMOFILES+=$(wildcard demo/fcldb/*.lpi)
DEMOFILES+=$(wildcard demo/fcldb/*.pas)
DEMOFILES+=$(wildcard demo/fcldb/*.json)
DEMOFILES+=demo/rtl/README.md
DOCFILES=README.md
DOCFILES+=docs/translation.html
ZIPFILE=pas2js-demo-$(PAS2JSVERSION).zip
COMPILERS=$(wildcard bin/$(PAS2JSVERSION)/pas2js*)
COMPILERS+=$(wildcard bin/$(PAS2JSVERSION)/libpas2js*)
ZIPFILE=pas2js-$(PAS2JSVERSION).zip
BINDIR=bin/$(CPU_TARGET)-$(OS_TARGET)
COMPILERS=$(wildcard $BINDIR/*$(EXEEXT))
COMPILERS+=$(wildcard $BINDIR/*$(SHAREDLIBEXT))
URL=http://www.freepascal.org/~michael/pas2js/
CFGFILE=bin/$(PAS2JSVERSION)/pas2js.cfg
info:
CFGFILE=bin/$(CPU_TARGET)-$(OS_TARGET)/pas2js.cfg
demoinfo:
@echo "Detected pas2js version: $(PAS2JSVERSION)"
@echo "Supported targets:"
@echo "all compile for current platform"
@ -1637,12 +1638,15 @@ info:
@echo "upload upload zip to $(URL)$(ZIPFILE)"
@echo "config create config file in bin dir"
@echo "URL for $(PAS2JSVERSION): $(URL)$(ZIPFILE)"
config:
./createconfig.sh $(CFGFILE) ../..
zip: config
utils/createconfig$(SRCEXEEXT): utils/createconfig.pp
$(FPC) utils/createconfig.pp
democonfig: utils/createconfig$(SRCEXEEXT)
utils/createconfig$(SRCEXEEXT) $(CFGFILE) ../..
demozip: democonfig
@echo Version: $(PAS2JSVERSION)
rm -f $(ZIPFILE)
cp compiler/utils/pas2js/dist/rtl.js packages/rtl
zip $(ZIPFILE) $(COMPILERS) $(RTLFILES) $(PACKAGEFILES) $(DOCFILES) $(DEMOFILES) $(CFGFILE)
upload: zip
demoupload: zip
scp $(ZIPFILE) idefix.freepascal.org:public_html/pas2js
@echo URL: $(URL)$(ZIPFILE)

View File

@ -32,8 +32,6 @@ override FPCOPT:=$(filter-out $(addprefix -Fu,$(COMPILER_UNITDIR)),$(FPCOPT))# C
ifdef FPMAKEOPT
FPMAKE_OPT+=$(FPMAKEOPT)
endif
FPMAKE_OPT+=--localunitdir=../..
FPMAKE_OPT+=--globalunitdir=../../packages
FPMAKE_OPT+=$(FPC_TARGETOPT)
FPMAKE_OPT+=$(addprefix -o ,$(FPCOPT))
FPMAKE_OPT+=--compiler=$(FPC)
@ -90,10 +88,12 @@ endif
#
# Custom installer
#
PAS2JSVERSION:=$(shell pas2js -iV)
RTLFILES=$(wildcard src/rtl/*.pas)
RTLFILES+=rtl/rtl.js rtl/pas2js_rtl.lpk
PACKAGEFILES=$(wildcard packages/*/*.pas)
ifndef PAS2JS
PAS2JS=pas2js
endif
PAS2JSVERSION:=$(shell $(PAS2JS) -iV)
PACKAGEFILES=packages/rtl/rtl.js
PACKAGEFILES+=$(wildcard packages/*/*.pas)
PACKAGEFILES+=$(wildcard packages/*/*.pp)
PACKAGEFILES+=$(wildcard packages/*/*.lpk)
DEMOFILES=$(wildcard demo/rtl/*.html)
@ -124,15 +124,15 @@ DEMOFILES+=$(wildcard demo/fcldb/*.lpi)
DEMOFILES+=$(wildcard demo/fcldb/*.pas)
DEMOFILES+=$(wildcard demo/fcldb/*.json)
DEMOFILES+=demo/rtl/README.md
DOCFILES=README.md
DOCFILES+=docs/translation.html
ZIPFILE=pas2js-demo-$(PAS2JSVERSION).zip
COMPILERS=$(wildcard bin/$(PAS2JSVERSION)/pas2js*)
COMPILERS+=$(wildcard bin/$(PAS2JSVERSION)/libpas2js*)
ZIPFILE=pas2js-$(PAS2JSVERSION).zip
BINDIR=bin/$(CPU_TARGET)-$(OS_TARGET)
COMPILERS=$(wildcard $BINDIR/*$(EXEEXT))
COMPILERS+=$(wildcard $BINDIR/*$(SHAREDLIBEXT))
URL=http://www.freepascal.org/~michael/pas2js/
CFGFILE=bin/$(PAS2JSVERSION)/pas2js.cfg
CFGFILE=bin/$(CPU_TARGET)-$(OS_TARGET)/pas2js.cfg
info:
demoinfo:
@echo "Detected pas2js version: $(PAS2JSVERSION)"
@echo "Supported targets:"
@echo "all compile for current platform"
@ -142,14 +142,18 @@ info:
@echo "config create config file in bin dir"
@echo "URL for $(PAS2JSVERSION): $(URL)$(ZIPFILE)"
config:
./createconfig.sh $(CFGFILE) ../..
zip: config
utils/createconfig$(SRCEXEEXT): utils/createconfig.pp
$(FPC) utils/createconfig.pp
democonfig: utils/createconfig$(SRCEXEEXT)
utils/createconfig$(SRCEXEEXT) $(CFGFILE) ../..
demozip: democonfig
@echo Version: $(PAS2JSVERSION)
rm -f $(ZIPFILE)
cp compiler/utils/pas2js/dist/rtl.js packages/rtl
zip $(ZIPFILE) $(COMPILERS) $(RTLFILES) $(PACKAGEFILES) $(DOCFILES) $(DEMOFILES) $(CFGFILE)
upload: zip
demoupload: zip
scp $(ZIPFILE) idefix.freepascal.org:public_html/pas2js
@echo URL: $(URL)$(ZIPFILE)

157
fpmake.pp
View File

@ -1,29 +1,131 @@
{$ifndef ALLPACKAGES}
{$mode objfpc}{$H+}
program fpmake;
uses fpmkunit;
{$endif ALLPACKAGES}
uses {$ifdef unix}cthreads{$endif},sysutils,fpmkunit;
procedure add_pas2js(const ADirectory: string);
Procedure CreateConfigFile(CfgFile,BaseDir : String);
Var
F : Text;
Procedure AddLn(S : String);
begin
Writeln(F,S);
end;
begin
if not ForceDirectories(ExtractFilePath(CfgFile)) then
begin
Writeln(StdErr,'Could not create destination directory ',ExtractFilePath(CfgFile));
Halt(2);
end;
Assign(F,CfgFile);
try
Rewrite(F);
except
On E : exception do
begin
Writeln(StdErr,'Could not create config file ',CfgFile,' : ',E.Message);
Halt(3);
end;
end;
if (BaseDir<>'') then
BaseDir:=ExcludeTrailingPathDelimiter(BaseDir);
if (BaseDir<>'') then
BaseDir:=ExcludeLeadingPathDelimiter(BaseDir);
Addln('#');
Addln('# Minimal config file for pas2js compiler');
Addln('#');
Addln('');
Addln('# not yet implemented: -d is the same as #DEFINE');
Addln('# not yet implemented: -u is the same as #UNDEF');
Addln('');
Addln('# Write always a nice logo ;)');
Addln('-l');
Addln('');
Addln('# Display Hints, Warnings and Notes');
Addln('-vwnh');
Addln('# If you don''t want so much verbosity use');
Addln('#-vw');
Addln('');
Addln('-Fu$CfgDir/'+BASEDIR+'/rtl');
Addln('-Fu$CfgDir/'+BASEDIR+'/fcl-base');
Addln('-Fu$CfgDir/'+BASEDIR+'/fcl-db');
Addln('-Fu$CfgDir/'+BASEDIR+'/fpcunit');
Addln('');
Addln('#IFDEF nodejs');
Addln('-Jirtl.js');
Addln('#ENDIF');
Addln('');
Addln('# end.');
Addln('EOCF');
Addln('');
Addln('# end');
Close(F);
end;
Procedure AddInstallFiles(Files : TConditionalDestStrings; ADir,AllowedExt,APrefix : String);
Var
Info : TSearchRec;
ADestDir,E : String;
P : Integer;
begin
ADestDir:=ADir;
P:=Pos(PathDelim,ADestDir);
if (P>0) then
Delete(ADestDir,1,P);
ADir:=IncludeTrailingPathDelimiter(ADir);
ADestDir:=IncludeTrailingPathDelimiter(ADestDir);
if FindFirst(aDir+AllFilesMask,0,Info)=0 then
try
Repeat
E:=LowerCase(ExtractFileExt(Info.Name));
if pos(E,AllowedExt)>0 then
Files.Add(ADir+Info.Name,aPrefix+ADestDir);
until (FindNext(Info)<>0);
finally
FindClose(Info);
end;
end;
Procedure AddPackageFiles(Files : TConditionalDestStrings; ADir,APrefix : String);
Const
PackExt = '.pas.inc.lpk';
begin
AddInstallFiles(Files,'packages'+PathDelim+ADir,packExt,aPrefix);
end;
Procedure AddDemoFiles(Files : TConditionalDestStrings; ADir,APrefix : String);
Const
DemoExt = '.pas.inc.lpr.lpi.html.md';
begin
AddInstallFiles(Files,'demo'+PathDelim+ADir,demoExt,APrefix);
end;
Var
P : TPackage;
PT,T : TTarget;
UnitDir,DemoDir,BD : String;
begin
With Installer do
begin
P:=AddPackage('pas2js');
P.Author := 'Free Pascal Team';
P.License := 'LGPL with modification';
P.HomepageURL := 'www.freepascal.org';
P.Description := 'Convert pascal sources to javascript.';
P.Email := 'michael@freepascal.org';
P.NeedLibC:= false;
P.Directory:=ADirectory;
P.Version:='3.1.1';
P.SourcePath.Add('compiler/utils/pas2js');
P.UnitPath.Add('compiler/utils/pas2js');
@ -32,18 +134,41 @@ begin
P.UnitPath.Add('compiler/packages/fcl-js/src');
P.UnitPath.Add('compiler/packages/fcl-json/src');
P.IncludePath.Add('compiler/packages/pastojs/src');
P.Dependencies.Clear;
Defaults.Options.Add('-Sc');
PT:=P.Targets.AddProgram('pas2js.pp');
PT:=P.Targets.AddLibrary('pas2jslib.pp');
P.Targets.AddProgram('pas2js.pp');
P.Targets.AddLibrary('pas2jslib.pp');
if Installer.RunMode in [rmInstall,rmArchive,rmZipInstall] then
begin
// Config file
BD:=IncludeTrailingPathDelimiter(P.GetBinOutputDir(Defaults.BuildCPU,Defaults.BuildOS));
// Determine unit files location
UnitDir:=ExcludeTrailingPathDelimiter(Defaults.UnitInstallDir);
UnitDir:=ExcludeTrailingPathDelimiter(ExtractFilePath(UnitDir));
UnitDir:=ExcludeTrailingPathDelimiter(ExtractFilePath(UnitDir));
UnitDir:=ExtractFilePath(UnitDir);
UnitDir:=UnitDir+'pas2js'+PathDelim;
// Create config file
CreateConfigFile(BD+'pas2js.cfg',ExtractRelativePath(IncludeTrailingPathDelimiter(Defaults.BinInstallDir),IncludeTrailingPathDelimiter(UnitDir)));
P.InstallFiles.Add(BD+'pas2js.cfg',Defaults.BinInstallDir);
P.InstallFiles.Add('compiler/utils/pas2js/dist/rtl.js',IncludeTrailingPathDelimiter(UnitDir)+'rtl');
AddPackageFiles(P.InstallFiles,'rtl',UnitDir);
AddPackageFiles(P.InstallFiles,'fcl-base',UnitDir);
AddPackageFiles(P.InstallFiles,'fcl-db',UnitDir);
AddPackageFiles(P.InstallFiles,'fpcunit',UnitDir);
// Demo files
DemoDir:=IncludeTrailingPathDelimiter(Defaults.ExamplesInstallDir);
AddDemoFiles(P.InstallFiles,'rtl',DemoDir);
AddDemoFiles(P.InstallFiles,'fcldb',DemoDir);
AddDemoFiles(P.InstallFiles,'fpcunit',DemoDir);
AddDemoFiles(P.InstallFiles,'fpreport',DemoDir);
AddDemoFiles(P.InstallFiles,'hotreload',DemoDir);
AddDemoFiles(P.InstallFiles,'jquery',DemoDir);
end;
Run;
end;
end;
{$ifndef ALLPACKAGES}
begin
add_pas2js('');
Installer.Run;
end.
{$endif ALLPACKAGES}