Premake5 prebuildcommands Directory - premake

I'm converting a premake4 config to premake5. My prebuildcommands are failing because the commands are executed from the root working directory, not the directory that the premake5.lua is in that contains the 'prebuildcommands'. premake4 executed them in the subdirectory containing the prebuildcommands call.
Is this the new intended behavior? If so, it's not documented anywhere that I can find. I don't mind correcting the paths as long as it's not an bug.

This looks like the correct behavior to me. Premake doesn't attempt to parse the commands to identify paths, so they are left intact as entered. The command itself is executed by the build tool (Visual Studio, GMake, etc.) and so will operate in whatever directory the tool makes current at that time.
If I'm reading it right, you would like the command to execute in the project directory, so what about:
prebuildcommands {
"%{prj.location}/styx/utils/ndate > %{prj.location}/include/kerndate.h"
}
For Visual Studio, Premake will convert those tokens to $(ProjectDir) so they will stay relative to the generated project file.

Related

Dockerfile COPY ${source:-obj/Docker/publish} not finding the correct source after upgrade to 3.1

I am using Jenkins to build and deploy a .Net Core microservice application. For each microservice, I am building a docker container. My dockerfile has the following in it:
ARG source
COPY ${source:-obj/Docker/publish} .
Prior to upgrading from .Net Core 2.2 to 3.1, this worked. After the upgrade, when I try to deploy, I am getting the following error:
COPY failed: stat /var/lib/docker/tmp/docker-builder609391151/obj/Docker/publish: no such file or directory
script returned exit code 1
From what I've read, it looks like .Net Core 2.2 compiled into the /obj/Docker/publish directory, but .Net Core 3.1 compiles into the /bin/Release/netcoreapp3.1 directory, however the source is still pointing to /obj/Docker/publish. I'm trying to figure out where the source arguement is defined, and how I should change this.
Update:
I decided to leave the source out entirely and hard-code the build path. I changed the copy line to
COPY /var/lib/jenkins/jobs/fusion-core/branches/master/workspace/src/CustomerAPI/obj/Release/netcoreapp3.1 .
I'm still getting an error when I try to build the docker container that says
COPY failed: stat /var/lib/docker/tmp/docker-builder356954794/var/lib/jenkins/jobs/fusion-core/branches/master/workspace/src/CustomerAPI/obj/Release/netcoreapp3.1: no such file or directory
script returned exit code 1
I'm not sure where the "/var/lib/docker/tmp/docker-builder356954794" is coming from, or why it is appending it to the front of my path, but it doesn't exist.
Still not sure how to get around this.
Some debugging suggestions in no certain order.
Default Value
${source:-obj/Docker/publish} is bash syntax that evaluates to the value of the variable source if it was defined, or obj/Docker/publish if it was not.
I'm trying to figure out where the source argument is defined, and how I should change this.
If you can't find anything that defines it to another value, it just means that the default value obj/Docker/publish was being used.
Publish directory
3.1 still uses the publish directory, but it will be at bin/Release/netcoreapp3.1/publish. Use a RUN find -type d -iname publish to find the publish directories in your container.
Dont use the full path, it will change every build. See the tmp/docker-builder356954794 in the path?
The COPY command uses relative files, based on the path in your machine (outside the docker container). So use a path that's relative to where the context directory (or Dockerfile) is. If the dockerfile is at /var/lib/jenkins/jobs/fusion-core/branches/master/workspace/src/CustomerAPI/Dockerfile and the publish directory on your machine is at /var/lib/jenkins/jobs/fusion-core/branches/master/workspace/src/CustomerAPI/bin/Release/netcoreapp3.1/publish, then use a COPY command like this:
COPY bin/Release/netcoreapp3.1/publish .
Funny paths
I'm not sure where the "/var/lib/docker/tmp/docker-builder356954794" is coming from
Containers need to share files from one directory (in your host) to another (in your container). Depending on the container technology, it uses one or more file systems or file directories.
One of those is /var/lib/docker/tmp/...

The output directory is under your source tree in meteor

how do I solve this
The output directory is under your source tree
warning:the output directory is under your source tree
your generated files may get interpreted as source code
consider building into a different directory instead meteor build ../output
I apologize for my ignorance on this matter, I am new in the world of programming and meteor. about my case. 1. I have a folder on Desk called “Findme” where I have the structure of my project (the code and everything which forms the application which works) 2. Then through the console I access that directory findme and then run the command meteor build/Desktop/MyApp --server = https: //findme.com, and start downloading. 3. But inside the console I also get the message indicated before and when it is finished, and I check the folder MyApp, it is empty. 4. And when I check the Findme folder it has created a folder named ~ and inside displays a file called Desktop/MyApp but it also doesn’t have any useful files, only winrar and nothing useful. 5. I am trying to generate the apk, could you please let me know what I might be doing wrong? Is there another way to generate the apk? I would appreciate it if you could help me!
Your should specify a path for where to build your application that is outside of your project directory.
Otherwise this can lead to problems with Meteor's file watcher and as your error already pointed out:
your generated files may get interpreted as source code consider
building into a different directory instead
So if your command uses a relative path, as used in meteor build ../output then it is important to call this command at the most upper project folder.
Consider the following project structure:
/myapp
/client
/import
/server
If you call meteor build ../output from within /myapp it will generate the output folder as expected outside of the project:
/output
/myapp
/client
/import
/server
However if you call it from within a subfolder, say /myapp/imports it may generate the output within the project like so:
/myapp
/client
/import
/output
/server
So keep this in mind when building your app.
Further readings:
https://guide.meteor.com/deployment.html#custom-deployment
https://docs.meteor.com/commandline.html#meteorbuild

Temp path too long when publishing a web site project

I am trying to publish an ASP.NET web site project using the Publish Web Site tool but get this error:
ASPNETCOMPILER(0,0): Error ASPRUNTIME: The specified path, file name,
or both are too long. The fully qualified file name must be less than
260 characters, and the directory name must be less than 248
characters.
I see that it is trying to copy the files to a very long path in AppData:
Copying all files to temporary location below for package/publish:
C:\Users\imx0\AppData\Local\Temp\1\WebSitePublish\BMW.Web-424993535\obj\Debug\AspnetCompileMerge\Source.
c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe -v /BMW.Web -p C:\Users\imx0\AppData\Local\Temp\1\WebSitePublish\BMW.Web-424993535\obj\Debug\AspnetCompileMerge\Source C:\Users\imx0\AppData\Local\Temp\1\WebSitePublish\BMW.Web-424993535\obj\Debug\AspnetCompileMerge\TempBuildDir
I couldn't find anything about this temp directory in my .pubxml publish profile. How can I change the temporary directory that Visual Studio copies the files to?
Add this to your publish profile to modify the temporary directory for package/publish:
<AspnetCompileMergeIntermediateOutputPath>c:\shortPath\</AspnetCompileMergeIntermediateOutputPath>
Go to your web project folder, navigate to Properties\PublishProfiles folder.
open your profile file profile_name.pubxml (not the profile_name.pubxml.user)
copy/past <AspnetCompileMergeIntermediateOutputPath>c:\shortPath\</AspnetCompileMergeIntermediateOutputPath> under the <PropertyGroup> tag
save your file, you would be able to publish your website using this profil
This is sort of an aside answer, but I ran into this problem when trying to MSBuild a solution that depended on nodeJS and gulp. The problem was that the gulp dependency tree became very deep and the aspnet_compiler was trying to copy that tree to a deeper directory, resulting in this error. I tried everything noted in here but nothing worked.
As it so happened, I was building with TFS, so my solution was to run an attrib +h node_modules\* /S /D before msbuild to hide the directory tree and then attrib +h node_modules\* /S /D. That did it for me.
Sure would be nice if the error thrown in this situation by the compiler revealed the path that caused the write to fail...
try adding this
<IntermediateOutputPath>..\Temp</IntermediateOutputPath>
to the default <propertyGroup />
None of the other answers worked for me.
Visual Studio 2013 Community Edition.
I changed the TMP and TEMP environment variable to a short folder name and it worked.
We identified the lengthy files/folders using this solution, then corrected the issue from there:
Run this script at the command prompt: dir /s /b | sort /r /+261 > out.txt it will output all file paths into the out.txt file
Copy the output to an Excel file
In the next column over from what you pasted in add this Excel function: =LEN(A1) where "A1" is the cell, copy this against every file length so you can see how long the paths are
Sort in Excel by the path length
Identify the lengths over the recommended limit
I know this is a bit long-winded but if you have several files that are resulting in this issue you'll be able to see them all.
Even though the content of node_modules was not included in neither version control not in the *.csprojfile itself Deleting the whole node_modules folder did the trick for me.
You can try the selected solution for correcting the long file path issue.
Still if not able to publish due to some other issue, You can try below method.
=> If the 'Solution Configuration' is in 'Debug' mode, please change the same to 'Release' mode and Publish the files.
=> If the Solution Configuration is in Release mode, and if the problem still persists, please try to delete the dll generated earlier in the 'Release' folder of our project and Publish the project once again.
Any of the above method will solve the issue.
For me, using Visual Studio 2019, the only change to the publish profile .pubxml file that worked was:
<WPPAllFilesInSingleFolder>c:\shortPath\</WPPAllFilesInSingleFolder>
I discovered this property at line 484 of Microsoft.Web.Publishing.targets file. Full path was C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VisualStudio\v16.0\Web.

Problem in creating text file(Qt application) in installation directory (using CMake to install)

I am new to programming. I am creating a small word jumble game to practice qt programming. In this application I am creating a text file (score.txt) to keep score of player. I have done this by:
QFile scoreFile("score.txt");
if (QFile::exists("score.txt"))
{
scoreFile.open(QIODevice::ReadWrite | QIODevice::Text)
// and update the score.
}
else
{
scoreFile.open(QIODevice::ReadWrite | QIODevice::Text);//create score file
//and write the score to it.
}
this code is working good here. Now I am using CMake to build and install generated binary (I am working on Ubuntu) using this code:
#set project name, version and build code here.
install(TARGETS wordJumbleGame DESTINATION bin)
I build project in /home/myname/project/build/
My source code is in /home/myname/project/src/
CMakeLists.txt is in /home/myname/project/CMakeLists.txt
I installed program using make install.
Till here all things working fine. But now problem is that when I run this program (I run it from terminal giving command wordJumbleGame) It creates score.txt in /home/myname/project/build directory. It is not being created in installation dir bin.
So please help me out, what am I doing wrong. And please also tell me how do I make my program to appear in application->game lists so I can run it from there not from command prompt.
Unless you prefix it with a slash (on unix) or a drive path (Windows), QFile's constructor parameter is a relative path - relative to the current working directory. score.txt is created in the build/ directory because that's probably where you're executing the binary from.
You can't store score.txt in the /usr/bin directory because, typically, you can't write there without root privileges.
What you want to do is get a path to some directory where you can store your score.txt file. To do that, you can use the QDesktopServices class. That will give you directory information on a per-user basis. Here's an example:
#include <QDesktopServices>
// this would go in main(), probably
QCoreApplication::setApplicationName( "word jumble game" );
// now when you want to read/write the scores file:
QString dataPath = QDesktopService::storageLocation( QDesktopService::DataLocation );
QFile scoreFile( dataPath + "score.txt" );
// on my system, this produces: "/home/adam/.local/share/data/word jumble game/score.txt"
// it will produce something similar for Windows and Mac too
You should set your appication name via QCoreApplication::setApplicationName before getting path information to keep the user data directory nice and organised.
As for getting your application in the games list, you'll need to create a menu entry that follows the freedesktop.org spec. I can't help you more with that, but this is a good starting point. Somebody else might have more info for you.
You need to create a .desktop entry file and install it using xdg-desktop-menu install. Here are two resources for you: freedesktop.org menu spec and adding .desktop files using CMake

Qmake does not support build directories below the source directory

I have created an application that compiles and runs like a charm on OS-X. I would now like to start getting it to work on Windows. To start, I copied the project to a windows machine and just tried to compile, but got this error:
:: warning: Qmake does not support build directories below the source directory.
Any ideas?
Set the shadow build directory to some folder on the same level of your project directory:
folder/
project/
project-shadow-build-release/
project-shadow-build-debug/
You can do this in the "Projects" view, via the toolbar on the left. To me, this warning was just an annoyance, a project never failed to build because of it.
Don't copy your project.pro.user file when you are copying a project from one machine to another, or from one directory to another. When you open the project, Qt Creator will offer to create a new build directory in the proper place.
Andref gave the correct answer to resolve this warning, but you may want to understand why this requirement exists.
In fact, the build directory must be at the same folder level as the project (i.e. it can't be above or below). The reason why is that the linker is called from the build directory. Hence, any relative paths to library files will be different than what you entered in your project file.
It kinda sucks. I like to put all intermediate files in their own folder. But you simply can't with qmake.
.pro.user are generated files by Qt Creator. They are unrelated to qmake and should not be touched (and not put into a VCS for that matter)
Just remove the files with the pro.user extension , worked for me
I also got this, trying to compile a project created on linux.
Another way to solve it is to change the paths in the .pro.user file (in the directory of your project)
Right Click on a project: Set As Active Project
Click on the Projects button (The one with the spanner image)
Edit build configuration : Debug / Profile / Release / and change the default directories, OR just uncheck the Shadow build check box.
The Build directory path should now change to black, from red

Resources