runnables, better control of the outputFolder usage

This commit is contained in:
Basile Burg 2017-01-26 10:17:45 +01:00
parent aedbdd92ab
commit 0ecfba7e9f
No known key found for this signature in database
GPG Key ID: 1868039F415CB8CF
4 changed files with 43 additions and 79 deletions

View File

@ -71,9 +71,13 @@ Note that the action _Run file unittest_ is based on the same internal function
![](img/options_runnables.png)
- __alwaysToFolder__: When checked the folder specified in __outputFolder__ is handled, even if the runnable module is not part of the current project.
- __compiler__: Select the [compiler](options_compilers_paths) used to produce the runnable binary. When GDC or LDC is selected their bridges based on DMD command line interface are used (GDMD and LDMD).
- __detectLibraries__: When checked the static libraries used by the runnable are detected from the [library manager](widgets_library_manager) by performing import analysis. When unchecked, all the library manager entries are passed and the compiler does the selection.
- __detectMain__: When checked the `main()` function is detected automatically and the `-main` switch is set accordingly. When not checked `-main` is never passed. This options is useful with the **Run file unittests** action because it allows to test a module that's also a valid program.
- __outputFolder__: Defines a folder where the runnable binary is output. If the runnable is part of the project this folder is used otherwise __alwaysToFolder__ must also be checked. When the folder is a relative path, it is solved using the runnable module parent directory as root.
- __staticSwitches__: Defines a list of switches that are always passed to the compiler when a runnable is produced or when a module is tested.
- **alwaysToFolder**: deprecated, checked meant **outputFolderCondition** set to [ifSaved, ifInProject], and [ifInProject] otherwise.
- **compiler**: Select the [compiler](options_compilers_paths) used to produce the runnable binary. When GDC or LDC is selected their bridges based on DMD command line interface are used (GDMD and LDMD).
- **detectLibraries**: When checked the static libraries used by the runnable are detected from the [library manager](widgets_library_manager) by performing import analysis. When unchecked, all the library manager entries are passed and the compiler does the selection.
- **detectMain**: When checked the `main()` function is detected automatically and the `-main` switch is set accordingly. When not checked `-main` is never passed. This options is useful with the **Run file unittests** action because it allows to test a module that's also a valid program.
- **outputFolder**: Defines a folder where the runnable binary is output. If the value starts by a drive letter or a directory separator then the folder must exist, otherwise it's considered as a subfolder, relative to the runnable filename, which is created automatically.
- **outputFolderConditions**: Defines the conditions for which **outputFolder** is handled.
- **ifInProject**: The runnable file is part of the current project. For example if **temp/** is in the `.gitignore` and if **outputFolder** is also set to **temp/** then the binary won't appear in the staging area.
- **ifSaved**: The runnable file is not in the current project but it's been saved explicitly out of the temp folder that's automatically used by Coedit.
- **ifNotSaved**: The runnable file is not part of the project and has never been saved explicitly.
- **staticSwitches**: Defines a list of switches that are always passed to the compiler when a runnable is produced or when a module is tested.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 KiB

After

Width:  |  Height:  |  Size: 64 KiB

View File

@ -35,6 +35,8 @@ type
ifSaved // runnable src not in project but saved not in temp dir
);
TRunnablesToFolderConditions = set of TRunnableToFolderCondition;
TCERunnableOptions = class(TWritableLfmTextComponent)
private
fCompiler: DCompiler;
@ -43,17 +45,19 @@ type
fOutputFolder: TCEPathname;
fAlwaysToFolder: boolean;
fStaticSwitches: TStringList;
fToFolderConditions: TRunnablesToFolderConditions;
procedure setOutputFolder(const value: TCEPathname);
procedure setStaticSwitches(value: TStringList);
procedure setCompiler(value: DCompiler);
protected
procedure afterLoad; override;
published
property alwaysToFolder: boolean read fAlwaysToFolder write fAlwaysToFolder;
property alwaysToFolder: boolean read fAlwaysToFolder write fAlwaysToFolder stored false; deprecated;
property compiler: DCompiler read fCompiler write setCompiler;
property detectMain: boolean read fDetectMain write fDetectMain;
property detectLibraries: boolean read fDetectLibraries write fDetectLibraries;
property outputFolder: TCEPathname read fOutputFolder write setOutputFolder;
property outputFolderConditions: TRunnablesToFolderConditions read fToFolderConditions write fToFolderConditions;
property staticSwitches: TStringList read fStaticSwitches write setStaticSwitches;
public
constructor create(aOwner: TComponent); override;
@ -629,7 +633,7 @@ begin
fDetectMain:= src.fDetectMain;
fDetectLibraries:= src.fDetectLibraries;
fOutputFolder:= src.fOutputFolder;
fAlwaysToFolder:= src.alwaysToFolder;
fToFolderConditions:= src.fToFolderConditions;
fStaticSwitches.assign(src.fStaticSwitches);
end
else inherited;
@ -2475,31 +2479,43 @@ end;
{$REGION run -------------------------------------------------------------------}
function TCEMainForm.runnableExename: string;
var
ofr: string;
of_yes: string;
of_no: string;
begin
result := '';
if fDoc.isNil then
exit;
result := fDoc.fileName.stripFileExt + exeExt;
if fDoc.isTemporary then
exit;
ofr := fRunnablesOptions.outputFolder;
if ofr.isNotEmpty then
of_no := fDoc.fileName.stripFileExt + exeExt;
of_yes:= fRunnablesOptions.outputFolder;
if not FilenameIsAbsolute(of_yes) then
of_yes := fDoc.fileName.extractFilePath + of_yes +
fDoc.fileName.extractFileName.stripFileExt + exeExt
else
of_yes := fRunnablesOptions.outputFolder +
fDoc.fileName.extractFileName.stripFileExt + exeExt;
result := of_no;
if fRunnablesOptions.outputFolderConditions <> [] then
begin
if not fRunnablesOptions.alwaysToFolder and assigned(fProject)
and not fProject.isSource(fDoc.fileName) then
exit;
if FilenameIsAbsolute(ofr) then
if ifNotSaved in fRunnablesOptions.outputFolderConditions then
begin
if ofr.dirExists then
result := ofr + fDoc.fileName.extractFileName.stripFileExt + exeExt;
end else
if fDoc.isTemporary then
result := of_yes;
end
else if ifInProject in fRunnablesOptions.outputFolderConditions then
begin
result := fDoc.fileName.extractFilePath + ofr
+ fDoc.fileName.extractFileName.stripFileExt + exeExt;
if fProject.isSource(fDoc.fileName) then
result := of_yes;
end
else if ifSaved in fRunnablesOptions.outputFolderConditions then
begin
if not fProject.isSource(fDoc.fileName) and not fDoc.isTemporary then
result := of_yes;
end;
end;
end;
procedure TCEMainForm.asyncprocOutput(sender: TObject);

View File

@ -1,56 +0,0 @@
**Content**
__________
**General**
* [Setup](https://github.com/BBasile/Coedit/wiki#detailed-setup-procedure)
* [setup program](https://github.com/BBasile/Coedit/wiki#setup-program)
* [from binaries](https://github.com/BBasile/Coedit/wiki#binaries)
* [build the sources](https://github.com/BBasile/Coedit/wiki#build-the-sources)
* [Linux package](https://github.com/BBasile/Coedit/wiki#linux-package)
* [Contribute](https://github.com/BBasile/Coedit/wiki#how-to-contribute)
* [Menu reference](https://github.com/BBasile/Coedit/wiki#menu-reference)
* [File](https://github.com/BBasile/Coedit/wiki#file)
* [Project](https://github.com/BBasile/Coedit/wiki#project)
* [Runnable module](https://github.com/BBasile/Coedit/wiki#runnable-module)
* [Native projects](https://github.com/BBasile/Coedit/wiki#native-projects)
* [DUB projects](https://github.com/BBasile/Coedit/wiki#dub-projects)
* [Completion daemon](https://github.com/BBasile/Coedit/wiki#d-completion-daemon-integration)
* [Symbolic strings](https://github.com/BBasile/Coedit/wiki#symbolic-strings)
* [Docking](https://github.com/BBasile/Coedit/wiki#docking)
__________
**Widgets**
* [Editor](https://github.com/BBasile/Coedit/wiki#editor-widget)
* [Find](https://github.com/BBasile/Coedit/wiki#find--replace-widget)
* [Library manager](https://github.com/BBasile/Coedit/wiki#library-manager-widget)
* [Symbol list](https://github.com/BBasile/Coedit/wiki#symbol-list-widget)
* [Project inspector](https://github.com/BBasile/Coedit/wiki#project-inspector-widget)
* [Project configuration](https://github.com/BBasile/Coedit/wiki#project-configuration-widget)
* [General](https://github.com/BBasile/Coedit/wiki#general-options)
* [Messages](https://github.com/BBasile/Coedit/wiki#message-options)
* [Debugging](https://github.com/BBasile/Coedit/wiki#debugging-options)
* [Documentation](https://github.com/BBasile/Coedit/wiki#documentation-options)
* [Output](https://github.com/BBasile/Coedit/wiki#output-options)
* [Others](https://github.com/BBasile/Coedit/wiki#other-options)
* [Path](https://github.com/BBasile/Coedit/wiki#path-options)
* [Pre&Post processes](https://github.com/BBasile/Coedit/wiki#prepost-build-process-options)
* [Run](https://github.com/BBasile/Coedit/wiki#run-options)
* [All](https://github.com/BBasile/Coedit/wiki#all-categories)
* [DUB editor](https://github.com/BBasile/Coedit/wiki#dub-project-editor)
* [Dfmt commander](https://github.com/BBasile/Coedit/wiki#dfmt-commander)
* [Messages](https://github.com/BBasile/Coedit/wiki#message-widget)
* [Custom tools](https://github.com/BBasile/Coedit/wiki#custom-tools-widget)
* [Todo list](https://github.com/BBasile/Coedit/wiki#todo-list)
* [Process input](https://github.com/BBasile/Coedit/wiki#process-input-widget)
* [Explorer](https://github.com/BBasile/Coedit/wiki#mini-explorer-widget)
* [Options editor](https://github.com/BBasile/Coedit/wiki#options-editor-widget)
__________
**Tutorials**
* [a project from scratch](https://github.com/BBasile/Coedit/wiki#new-project-flow)
* [runnable command interpreter](https://github.com/BBasile/Coedit/wiki#using-a-runnable-module-as-an-interactive-command-interpreter)