mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-14 12:09:30 +02:00
pas2js: compileserver: fixed mimetypes under darwin
git-svn-id: trunk@41338 -
This commit is contained in:
parent
2b876c6079
commit
305c754042
@ -7,7 +7,8 @@ interface
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
sysutils, classes, fpjson, contnrs, syncobjs, custhttpapp, fpwebfile, httproute,
|
sysutils, classes, fpjson, contnrs, syncobjs, custhttpapp, fpwebfile, httproute,
|
||||||
pas2jscompiler, httpdefs, dirwatch;
|
httpdefs, dirwatch,
|
||||||
|
Pas2JSFSCompiler, Pas2JSCompilerCfg;
|
||||||
|
|
||||||
Const
|
Const
|
||||||
nErrTooManyThreads = -1;
|
nErrTooManyThreads = -1;
|
||||||
@ -101,6 +102,7 @@ Type
|
|||||||
function ScheduleCompile(const aProjectFile: String; Options : TStrings = Nil): Integer;
|
function ScheduleCompile(const aProjectFile: String; Options : TStrings = Nil): Integer;
|
||||||
procedure StartWatch(ADir: String);
|
procedure StartWatch(ADir: String);
|
||||||
procedure Usage(Msg: String);
|
procedure Usage(Msg: String);
|
||||||
|
function GetDefaultMimetypes: string;
|
||||||
public
|
public
|
||||||
Constructor Create(AOWner : TComponent); override;
|
Constructor Create(AOWner : TComponent); override;
|
||||||
Destructor Destroy; override;
|
Destructor Destroy; override;
|
||||||
@ -142,13 +144,14 @@ end;
|
|||||||
procedure TCompileThread.Execute;
|
procedure TCompileThread.Execute;
|
||||||
|
|
||||||
Var
|
Var
|
||||||
C : TPas2jsCompiler;
|
C : TPas2JSFSCompiler;
|
||||||
L : TStrings;
|
L : TStrings;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
L:=Nil;
|
L:=Nil;
|
||||||
C:=TPas2jsCompiler.Create;
|
C:=TPas2JSFSCompiler.Create;
|
||||||
Try
|
Try
|
||||||
|
C.ConfigSupport:=TPas2JSFileConfigSupport.Create(C);
|
||||||
FApp.ReportBuilding(Item);
|
FApp.ReportBuilding(Item);
|
||||||
L:=TStringList.Create;
|
L:=TStringList.Create;
|
||||||
L.Assign(Item.Options);
|
L.Assign(Item.Options);
|
||||||
@ -259,11 +262,25 @@ begin
|
|||||||
Writeln('-q --quiet Do not write diagnostic messages');
|
Writeln('-q --quiet Do not write diagnostic messages');
|
||||||
Writeln('-w --watch Watch directory for changes');
|
Writeln('-w --watch Watch directory for changes');
|
||||||
Writeln('-c --compile[=proj] Recompile project if pascal files change. Default project is app.lpr');
|
Writeln('-c --compile[=proj] Recompile project if pascal files change. Default project is app.lpr');
|
||||||
|
Writeln('-m --mimetypes=file filename of mimetypes. Default is ',GetDefaultMimetypes);
|
||||||
Writeln('-s --simpleserver Only serve files, do not enable compilation.');
|
Writeln('-s --simpleserver Only serve files, do not enable compilation.');
|
||||||
Halt(Ord(Msg<>''));
|
Halt(Ord(Msg<>''));
|
||||||
{AllowWriteln-}
|
{AllowWriteln-}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function THTTPCompilerApplication.GetDefaultMimetypes: string;
|
||||||
|
begin
|
||||||
|
{$ifdef unix}
|
||||||
|
Result:='/etc/mime.types';
|
||||||
|
{$ifdef darwin}
|
||||||
|
if not FileExists(Result) then
|
||||||
|
Result:='/private/etc/apache2/mime.types';
|
||||||
|
{$endif}
|
||||||
|
{$else}
|
||||||
|
Result:=ExtractFilePath(System.ParamStr(0))+'mime.types';
|
||||||
|
{$endif}
|
||||||
|
end;
|
||||||
|
|
||||||
constructor THTTPCompilerApplication.Create(AOWner: TComponent);
|
constructor THTTPCompilerApplication.Create(AOWner: TComponent);
|
||||||
begin
|
begin
|
||||||
inherited Create(AOWner);
|
inherited Create(AOWner);
|
||||||
@ -403,7 +420,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Function THTTPCompilerApplication.ScheduleCompile(const aProjectFile : String; Options : TStrings = Nil) : Integer;
|
function THTTPCompilerApplication.ScheduleCompile(const aProjectFile: String;
|
||||||
|
Options: TStrings): Integer;
|
||||||
|
|
||||||
Var
|
Var
|
||||||
CI : TCompileItem;
|
CI : TCompileItem;
|
||||||
@ -479,7 +497,7 @@ begin
|
|||||||
AResponse.SendResponse;
|
AResponse.SendResponse;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Function THTTPCompilerApplication.HandleCompileOptions(aDir : String) : Boolean;
|
function THTTPCompilerApplication.HandleCompileOptions(aDir: String): Boolean;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Result:=False;
|
Result:=False;
|
||||||
@ -510,14 +528,14 @@ begin
|
|||||||
Result:=True;
|
Result:=True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Function THTTPCompilerApplication.ProcessOptions : Boolean;
|
function THTTPCompilerApplication.ProcessOptions: Boolean;
|
||||||
|
|
||||||
Var
|
Var
|
||||||
S,IndexPage,D : String;
|
S,IndexPage,D : String;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Result:=False;
|
Result:=False;
|
||||||
S:=Checkoptions('shqd:ni:p:wP::c',['help','quiet','noindexpage','directory:','port:','indexpage:','watch','project::','config:','simpleserver']);
|
S:=Checkoptions('shqd:ni:p:wP::cm:',['help','quiet','noindexpage','directory:','port:','indexpage:','watch','project::','config:','simpleserver','mimetypes:']);
|
||||||
if (S<>'') or HasOption('h','help') then
|
if (S<>'') or HasOption('h','help') then
|
||||||
usage(S);
|
usage(S);
|
||||||
FServeOnly:=HasOption('s','serve-only');
|
FServeOnly:=HasOption('s','serve-only');
|
||||||
@ -526,11 +544,12 @@ begin
|
|||||||
D:=GetOptionValue('d','directory');
|
D:=GetOptionValue('d','directory');
|
||||||
if D='' then
|
if D='' then
|
||||||
D:=GetCurrentDir;
|
D:=GetCurrentDir;
|
||||||
{$ifdef unix}
|
if HasOption('m','mimetypes') then
|
||||||
MimeTypesFile:='/etc/mime.types';
|
MimeTypesFile:=GetOptionValue('m','mimetypes');
|
||||||
{$else}
|
if MimeTypesFile='' then
|
||||||
MimeTypesFile:=ExtractFilePath(System.ParamStr(0))+'mime.types';
|
MimeTypesFile:=GetDefaultMimetypes;
|
||||||
{$endif}
|
if (MimeTypesFile<>'') and not FileExists(MimeTypesFile) then
|
||||||
|
Log(etWarning,'mimetypes file not found: '+MimeTypesFile);
|
||||||
FBaseDir:=D;
|
FBaseDir:=D;
|
||||||
if not ServeOnly then
|
if not ServeOnly then
|
||||||
if not HandleCompileOptions(D) then
|
if not HandleCompileOptions(D) then
|
||||||
|
Loading…
Reference in New Issue
Block a user