Premake command line option to include a project - premake

So I have a Premake5 script to generate makefiles for my current project (a static library). It has a command line option called "with-sandbox". "sandbox" is a testing environment for the library. But the makefiles for it should only be created if the "with-sandbox" option is set. Thus, I made a filter which includes the Premake5 script of "sandbox" only when the option is set. But it seems like "include" is not effected by filters and so this does not work.
This is how my Premake5 script looks like for the main project:
newoption
{
trigger = "with-sandbox",
description = "Creates a sandbox testing environment"
}
workspace "celer"
project "celer"
-- Project setup...
filter "options:with-sandbox"
include "tests/sandbox/"
And this is the Premake5 script for the "sandbox" project:
project "sandbox"
-- Project setup...
I only want the "sandbox" stuff to exist if I want it to.
This is especially important when I use Visual Studio to port the library to Windows. I only want the "sandbox" project in my solution when it's necessary.

i think you can do something like this
if _OPTIONS['with-sandbox'] then
project "sandbox"
...
end
This way the project will be generated only if you pass the option

Related

How to make Qt Creator use variables in the builddir path, so I can easily rename project?

In Qt Creator, in Tools -> Options -> Build & Run -> General -> Build and Run -> Default build directory I have this value:
../build-%{CurrentProject:Name}-%{CurrentKit:FileSystemName}-%{CurrentBuild:Name}
This works but on project creation the variables in that string get replaced with their values, which means that if I later rename the project, I need to go through all of [Debug, Profile, Release] modes and manually change the builddir's path so it reflects the new project name.
So I want:
A way to use variables like %{CurrentProject:Name} in the project settings
(less important) A way to have Qt Creator automatically put references to such variables in the project settings on project creation, so I don't have to adjust them on project creation
Alternatively: Some other pain-free way to rename my project without having to update so many places
Note: I could remove the project-name part from the builddir template, and put the builddir in "." (project dir) rather than in ".." (parent of project dir), that way it would work and there would be no name collisions (MS Visual Studio does it this way), but unfortunately qmake has a limitation (see tobias.hunger's post) that makes it sometimes break unless the project dir is at "the same level" as the builddir.
You'll need to implement this feature yourself. This happens so rarely that until now nobody really needed it. A workaround, if your build/run environment isn't customized, is to remove all kits from the project and re-add the desired kits. It will then create build folders using appropriate names.
But it seems like much ado about nothing: Qt Creator's build folder names might as well be random strings, you should not need to manually refer to them. For product deployment, you'd be using some sort of a CI system, or a manually invoked build script that stages the deliverable(s) (e.g. installer or disk image) where they belong.

Precompiling and Deploying website from Visual Studio Team Services

We're using Visual Studio Team Services with Git as the source control system and I've configured a build which executes successfully online. Ideally I'd like to:
After building the site in VSO, precompile and dump the aspx and .dll files to the git repository
On the on-premises web server, pull from git and move to our staging site
The second part I can figure out on my own, but the documentation for VSTeam seems sketchy on how to dump the compiled sources to git. I've kept the default build configration almost the same as the default with the exception of a Powershell script which is supposed to create artifacts for the drop. Despite this, the drop.zip file create is empty.
The following is how my build definition is set up in VSO.
Instead of the PowerShell script, you'd be able to use the "Copy and Publish artefacts" and have it create a specific artefact with the specific bits you need:
This will automatically create a named build artefact which you can then use from Release Management as an input.
The PowerShell script was used in the XAML builds when used with the "Project Output | As Configured" option.
To create your "packaged" website, you need to add a couple of parameters to the MsBuild/Visual Studio Build step to instrict the compiler to package your website:
/p:DeployOnBuild=true /p:DeployTarget=Package
/p:SkipInvalidConfigurations=true /p:PackageAsSingleFile=false
/p:AspNetCompileMerge=true
Optionally you can configure your target directory as well using
/p:PackageLocation="$(Build.BinariesDirectory)\Published"
If you do this, you need to configure this directory as your copy root in the copy and publish task.
I did a quick look at the Power-Shell script, there are two issues with it:
It still use the variables like "$Env:TF_BUILD_SOURCESDIRECTORY" which does not exist in VSTS(VSO). See Variables for VSTS.
It copies the files from "BUILD_SOURCESDIRECTORY" folder to "BUILD_BINARIESDIRECTORY". But the "Publish Build Artifacts" step in your definition publish the files in "BUILD_ARTIFACTSTAGINGDIRECTORY" folder.
So if you want to use this script, you need to update the script to remove the "TF_" string in the variables and update the "Publish Build Artifacts" step to publish the files in "BUILD_BINARIESDIRECTORY" folder(Set Path to Publish to: $(Build.BinariesDirectory)).
However, if you want to copy and publish the website files, you can simply add one more argument in "MSBuild Arguments" section of "Visual Studio Build" step:
"/p:outdir=$(build.artifactstagingdirectory)"
Remove the Power-Shell script step and the other steps just keep default settings.
Or you can also change the settings of "Copy Files" steps to select the files/folders you'd like to copy.

qmake subdirs optional target/sub project

I wondering if there is such a thing like optional targets or sub project in qmake, the Qt build tool.
Project
In my test example I have a subdirs project which contains another two projects, one shared library and one basic application. The application depends on the library which works great. Additionally I have one additional compiler (invoking lrelease) and one additional target (invoking lupdate), which also works like a charm (the shared library provides them as pri file for multiple projects).
After a complete build in release mode, the Windows deployment tool (namely windeployqt.exe) is called and deploys the target with all required shared libraries and plugins to my deployment directory.
Last component I wish to add is the creation of an installer using the Qt Installer Framework, which in fact should be easily done one the executables are located. Thus I want to create another sub project which contains all the installer stuff and provides the qmake steps to create one. But the project should not be build all the time but only when I want to, preferably over the create menu of Qt Creator.
Question
Is there any way to make a qmake subdirs sub project fully optional, so it will not be built using the default build all?
You can add a check around it:
enableOptional {
message(optional enabled)
SUBDIRS += YourSubDir
}
And call qmake with
qmake CONFIG+=enableOptional yourProject.pro
The qmake documentation states that one should use the test function requires(condition) to skip building a whole project. Using this one may add a new build configuration, namely bundle as example, which defines a configuration variable as #Jeffrey pointed out in his answer.
I managed to get it working with the following qmake project definition:
requires(BUNDLE_INSTALLER)
TEMPLATE = aux
QMAKE_POST_LINK = ...
Once you define the variable, over a new build configuration for proper working with Qt Creator (example), the steps listed under QMAKE_POST_LINK are performed. So I may bundle the installer, if I want to.

OpenCover in localhost with C# MVC 4 app

I just want to try OpenCover to get Coverage statistics from my app.
But I don't understand well how to use it. So here my questions?
Does the dll's have to be in the same directory? (my solutions have several projects)
Any example to get Coverage using OpenCover?
Is necessary to run the site in IIS Express or with ASP.NET development server is ok?
Thanks a lot!
I set up open cover as an external tool to make it easier on me.
Download the exe and drop it in a folder with as short a path as possible. then setup and external tool as follows:
Title : Open Cover {this is your choice}
Command: {your path to opencover}\OpenCover.Console.exe
Arguments: -register:user -target:"C:\Progra~1\Microsoft Visual Studio 11.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe" -targetargs:"$(TargetName)$(TargetExt)" -output:coverage.xml -targetdir:"$(ProjectDir)\bin\debug"
Initial directory: $(TargetDir)
Set it to use output window and close on exit. You will need to adjust the test runner program to suit you, i use vs2012, if you do too, that will make it easier on you.
To use it, click your test project in your solution explorer, then click on the open cover external tool and it will generate you the coverage report. I use it with Report Generator.
Set it up as an external tool too:
Title: Report Generator
Command: {Your path to report generator}\ReportGenerator.exe
Arguments: $(TargetDir)coverage.xml $(TargetDir)\coverageResults
Again, set to close on exit and use output window.
after generating your coverage report, you can then use report generator to create a nice looking html version that you can click through and see the stats.
hth
The docs that are installed alongside OpenCover carry a lot of useful information about running OpenCover. You should have a copy of this file https://github.com/sawilde/opencover/blob/master/main/OpenCover.Documentation/Usage.pdf in you download package (MSI/ZIP/NUGET)
The DLLs do not need to all be in the same directory but you will normally find that this happens due to the build process. Any assemblies that you want to gather coverage from will require that the PDBs for those assemblies to be in the same directory as the assembly or in the folder referenced by targetdir switch.
Yes you can use it to run iisexpress or the ASP.NET development server use the target switch.

Is it possible to run ILMerge at compile time within SharpDevelop?

I'd like to offer my .Net library (which I'm developing in the SharpDevelop IDE) as a single dll. I've been manually using ILMerge to merge my compiled library and all its reference libraries together, but would like this done automatically.
I'd ideally like to have this automatic merge happen from within SharpDevelop, without having to set up an external build script. Is this possible?
SharpDevelop uses MSBuild to compile your code so the simplest way would be to create a post build step that runs ILMerge with the correct parameters. You can create a post build step from the Project Options under the Build Events tab. Alternatively you can directly edit your project file in Notepad.

Resources