I have a directory containing a repo and a build folder. The build folder contains the complete build of objects, as triggered using ninja. I want thousands of copies of this directory where just one source file will be different between copies. I'm hoping to use ninja on these copied directories, triggering an incremental, rather than complete build, making the build much faster. However, running ninja in a copied directory, even with no changes applied, performs a total rebuild. The copied directory already contains all of the built objects so this is wasteful.
How does ninja detect which files have to be rebuilt and how might I go about changing the copied directory to avoid the full rebuild?
Turns out the timestamps of copies have to be the same too. I was using cp -r source dest but I should have added the flag to copy timestamps: cp -rp source dest.
Related
I am using the ORB_SLAM3 project (https://github.com/UZ-SLAMLab/ORB_SLAM3) as a baseline for a monocular odometry system.
To understand how the ORB_SLAM3 software ingests the EuRoCV dataset, I am modifying some of the initial codes in the mono_euroc.cc file available in /Examples/Monocular folder.
However, each time I change the .cc file, I cannot compile just the mono_euroc.cc file by itself, but need to run the ./build.sh command from the parent directory which executes the entire CMake. The process which takes a while to complete.
My question is, is there a tool within CMake that would allow me to only change the "mono_euroc.cc" file directly from the "/Examples/Monocular" subdirectory rather than having to constantly invoke the "./build.sh" from the parent directory?
For the time being, I am following this process. I opened two terminal windows, both pointing to the parent directory (i.e ~/Dev/ORB_SLAM3). Everytime I change something in the target file (here it is the ./Examples/Monocular/euroc_mono) I execture the ./build.sh command in one and run the file on the other. I can confirm that though the cmake command looks over all the files, it only builds the one that was changed. I guess this method works when one is using the CMake tool to build a C++ project in Linux.
I am creating some software with C++ and Cmake that I want people to be able to effortlessly build and run. Cloning the GitHub repo will install the folder Project/, and the code in the file Project/src/navigation/camera/image.cpp compiled into and linked to multiple programs all over the Project repository. However, inside image.cpp there is a path to a file Project/Models/model.txt, and the file path is relative to Project/build/navigation/camera/image.o:
image.cpp:
int processImage() {
read_file("../../../Models/model.txt");
// Do something
}
But since the object file is linked to other programs all over the project, the path should be relative to many different locations. What is the standard "Software Engineering" technique to solve this? Do you tell Cmake the path of Project/, and somehow let it modify image.cpp before building? Or is there a way to still use relative paths?
If you are using CMake, the typical build model separates the source tree from the build tree, which means that your build folder could be anywhere relatively to the source folder. Therefore, any relative path wouldn't work reliably.
If I can't avoid having an hardcoded path in the source, my favourite solution is to pass your cpp file to the configure function of CMake to replace that relative path to an absolute path that CMake will calculate at generation time
I don't know how "standard" this approach is, but what I would expect is a requirement that Models be a subdirectory of whatever directory the executable is executed from. Usually this is wherever the executable ends up, but not necessarily. For released projects, this directory is usually (expected to be) the installation directory. There is a caveat that other functions are capable of changing the current working directory, and that would make it more difficult for your code to find model.txt. So I would also expect a requirement that the current working directory be restored before your code is run.
If you go this route, the relative path to your data file would be Models/model.txt. It would be up to each project to copy this data to the appropriate directory (or create a link from the directory to the data file). Note that each project would probably want this configuration for release anyway since you usually should not (sometimes cannot) access the parent of your install directory.
We debug our binary using an IAR workspace (.eww) that wasn't used to build the binary - it was done using make from the command line. The make files were generated by a build system (exactly how is lost in the mists of time).
Is there a way to add the sources to the .eww after the make i.e. automatically traverse the source file directory structure and add the same sources that make uses? There are multiple copies of some of the sources in the structure due to some sloppy copy & pasting i.e. same file, 2 copies, possibly identical, different directories.
Project files (.ewp) are simply xml files. Source files are listed as
<file><name>path\to\source.c</name></file>
in <project> node.
You could create a script (Python for example) which searches for files or make gives them as parameters. Script could then filter out duplicates and update IAR project file accordingly.
But if you are using IAR compiler to build and workbench to debug, then maybe ditch make file completely and create project file from ground up, so you could build and debug directly from the IDE?
I'm experimenting with OpenDDS (and ACE/TAO), which uses MPC (Make Project Creator) to generate the actual make files, and it's doing a couple really annoying things.
First, it generates a lot of intermediate sources files (some IDL, and c++ headers/implementation), and it places them in the same directory with manually created IDL and C++ files. I'd like to have the manually created files and the generated files be in separate directories, because all the generated files are distracting. Is there any way to do this?
Second, make I run "make clean" it cleans up the generated object files, but it does not clean up generated source files. Is there a way to make it clean all the generated files?
To delete all the generated files (when using make files), simple do a 'make realclean'. 'make clean' simply cleans up the C++ compilation products (object files, library, & executables) while 'make realclean' removes all generated files.
Changing the output directory for the generated files is probably not something you really want to do. Yes, the large amount of generated IDL and C++ does sometimes get in the way, but after a while you learn to look past them. If you are dead set on this, one indirect way is to use the clone_build_tree.pl script that comes with MPC. This script creates a new directory (under build/xxx) which contains symbolic links to all the source files. You then do your build there, leaving the original source directories pristine. Here is a simplified example (assumes ACE, TAO, and MPC are already setup):
cd DDS
$MPC_ROOT/clone_build_tree.pl test
cd build/test
export DDS_ROOT=`pwd`
build using normal Open DDS instructions...
I'm making changes to a form in Creator but when I build the changes are not being "refreshed".
I've gone so far as to remove every element from the form and get rid of every stylesheet but when I build the project I get the same result; as if I had never made a change at all.
What gives? Am I missing something obvious? (obvious to everyone but me.. obviously)
I guess you're using QtCreator 2.0? I found the same strange issue. You have two options:
Remove the ui_{the_name_of_design}.h from the project's build dir. Then run qmake again.
make clean or Build → Rebuild All
But the second option even doesn't help with me. By the way that's why is good to use a different build dir than that where the sources are. If some changes don't appear to be applied, just delete the content of build dir, and everything goes fine as well.
Cheers
Most likely cause if that your make procedure is not noticing the changes in the .ui file, and so it is not calling the uic tool. Try to do a make clean to see if it helps, and check your build log to see if uic is being called.
For me, the solution was to change the BuildDirectory to the same directory where the code is, instead of the **-build-desktop directory.
I stumbled upon this issue as well and one thing I noticed was that my program was still running in the background without me knowing. Ending the task through task manager fixes it and you can make changes again.
A few suggestions:
Perform a make distclean.
Use a shadow build directory. Building “inside” the source code is not advised.
Check your computer’s clock and the date and time of your files.
This thread is a little dated but since I got caught up in the same problem I thought I would share how I resolved this.
I've been incrementally building up a ui with designer under QtCreator 2.4.1/Qt 4.8.1 using a poor man's source control approach: snapshots. At one point I inadvertently created a non-shadowed build project. In a subsequent snapshot I reverted the project back to shadow build and at that point new widgets added in the ui form were no longer being recognized in the build.
Solution:
Delete stale ui_.h files from the source directory.
Delete make and ui_.h files from your shadaow build directory.
Rebuild
Latest generated ui_.h files will reappear in the shadow build directory.
No copies of ui_.h files appear in the source directory indicating that the stale files were taking precedence in the build order. Not obvious.
I have this problem and i solve it by changing the project path. I had stored the project in my flash memory when i had this problem, then i copy the project folder and it's build folder also in the Desktop and open it with QtCreator and the problem was solved.
Problem is indeed stale generated files in project source directory. This can happen both with genrated ui_*.h files, as well as with moc_*.* files. Below is not covered by existing answers, so here we go:
To remove generated files from the project source directory, without affecting Qt Creator settings or current shadow build directories, there are two principal ways, which can also be combined for extra coverage.
Go to Qt command prompt, go to project source directory and run these commands:
qmake -r
make clean
make distclean
1st one will recursively create makefiles. 2nd one will remove all files produced by building the project. 3rd one will remove the makefiles again. Then continue using shadow build from Qt Creator as before.
The problem with this is, it will leave files which are not part of the project. So if some files have been removed from project, related generated files may remain, and cause trouble if files with same name are added back. So even after this it is good idea to verify no ui_* or moc_* files remain, if you know you have removed files from project.
Use your version control software to first commit or stash/shelve all uncommitted changes, and then remove all unversioned (also otherwise ignored) files. For some version control software this may not be easy as git clean -dxf (beware, that will also lose uncommited changes and Qt Creator's custom project settings), and in that case it may be easier to just remove project source directory and get a clean checkout.
The problem with this is, if some generated files have accidentally been added to project, they will not be cleaned up with this. So it may still be a good idea to do the step 1 above too.
Above steps should be in sync so that after step 1, any files in source directory (except Qt Creators's projectname.pro.user and possible *~ backup files) should be under in version control.