What exactly does "Clean and Build" do? - objective-c

Maybe this seems like a naive question.
I have some functionality in my project that suddenly doesn't work, an when I "Clean and Build", it works again.
What might be the problem that is being solved by performing this Clean and Build?
Your input is highly appreciated.

The actions on a Make and clean are derermined by the makefile. You can look at the Makefile itself to see what is there.
make by itself corresponds to the very first rule in the makefile.
make clean corresponds to the clean rule in the makefile
Also, you can use
make -n
and
make -n clean
These will show you the sequence of command(s) that are actually executed when make or make clean are run.
As a general convention, make by itself is a rule for compiling so it executes the compile commands necessary to build the project.
make clean is used for cleaning the project. It deletes the object files and the executable, and any other files necessary to allow a clean build of the project on next make.
Why doing make clean followed by a make helps?
It can be due to a number of reasons and its hard for me to tell you what may be going on. Can you give some more details on the failure mode?

with help of "build and clean" you can remove the old build files and make the new files.so that the updates will be effectively shown in the views.

Related

Bundling versus debugging in a Visual Studio Code extension

I have written an extension for VS Code and now am creating a package for it.
It is recommended then to bundle the files, which I do with esbuild. Packaging works, but it leaves me with a dilemma. In package.json, I can either write
"main": "./out/main.js",
which lets VS Code use the bundled code; this results in a usable package but I cannot debug the code.
Or I can write
"main": "./out/extension.js",
which directs VS Code to the original code; then I can debug but I do not generate a usable package.
Surely I must misunderstand something, but what is it?
Update yo code and generate a new extension from it. The sample has already been configured to bundle the files so you don't need to do anything yourself.
But if you want to use esbuild for bundling, then probably you are on your own. Moving to rebuild has been mentioned last year, but no progress ever after, https://github.com/microsoft/vscode/issues/115023#issuecomment-771692495
If you "npm run esbuild" in a powershell terminal, it runs the "esbuild" script (which I copied into package.json from https://code.visualstudio.com/api/working-with-extensions/bundling-extension ) that uses --sourcemap, and that seems to make debugging possible. (You can use breakpoints in extension.ts even though it's running main.js.)
Then, you can replace the "watch" script names in tasks.json with "esbuild-watch", and it will automatically run esbuild when you make changes.
I haven't tested this thoroughly (I'm about as lost as you are with this stuff) but I thought this might help anyway.

Why does NS3 build every time I run a file

I am working on NS3 and I am using the ./ns3 cmake wrapper to run my .cc files. The issue is that the ns3 builds all the dependencies every time i run a file, even when there are no code changes. Is this expected? This is really hogging my time and I see in the NS3 manual that it should not build every single time, and builds only what is necessary
The behavior you report should not be happening, especially if you are using the latest ns-3.36.1 release. If it is with that release or later, please file an issue with enough details for a maintainer to try to reproduce the issue. In any case, you can suppress even checking whether a new build is needed by passing the --no-build option to ./ns3 run command.

Best way to call Cargo from CMake?

I found this: https://github.com/AndrewGaspar/cmake-cargo but couldn't make it work
Anyway, if I were to use a Makefile instead of CMake, I'd simply create a rule that watches for the .rs files to change and recompile.
I couldn't find a solution for calling Cargo from Cmake (not the other way around) so I'm opening one here.
How can I make my CMakeLists.txt watch for .rs file changes and recompile by calling cargo build?
I'm the author of the linked project in the OP. I apologize for the sorry state it was in when you found it, but in the last month or so I've invested a bunch of time to really flesh it out, and gave it a more inspiring name: https://github.com/AndrewGaspar/corrosion
I hope you could check out the latest README and let me know if you can get it working for your scenario. And if not, please file an issue, letting me know where in the documentation you ran into issues.
Following recommendations, I simply added the command cargo build as a dependency to my library
add_library(libsmoltcp_cpp ${libsmoltcp_cpp_sources})
add_custom_target(
lib_smol_tcp_rust
COMMAND cargo build
)
add_dependencies(libsmoltcp_cpp lib_smol_tcp_rust)

CMake Fails until you remove CMake Cache

I have a project that I am managing using CMake and I have run into some very strange behavior that I don't understand. If I clear out my build directory, run cmake, run make, then run my program my program crashes every time because I fail an assertion somewhere in pthreads/boost threads. No matter how many times I make, and make clean this project it crashes every time I run it. However, if I then remove CMaketCache.txt, regenerate my makefiles, build and run, the program runs as expected every time.
In summary I need to follow the following steps for my code to work...
Run Cmake
Run Make
rm CMakeCache.txt
Run Make
Run program
It appears that the Make files before and after I remove CMakeCache.txt differ. What could explain this behavior?
Do you have git installed? If so, you can use this trick:
Run cmake
make
git add .
git commit -m ""
rm CMakeCache.txt
run make
git diff
Some odd things I can see in what you are saying. I don't see why your program would recompile anything just because you removed the CMakeCache.txt. Everything should be up-to-date from the first make, so something is bad there... My guess is that it is finding a different thread library or no thread library the second time.

Pre-Pre-build Steps in Hudson

I'm in a bit of a pickle. I'm trying to run some environmental scripts before I run the build in a m2 project, but it seems no matter how hard I try - the 'pre' build script are never run early enough.
Before the 'pre-build' scripts are run, the project checks to see if the correct files are in the workspace - files that won't be there until the scripts I've written are executed.
To make them 'pre-build', I'm using the M2 Extra Steps plugin - but's it's not 'pre' enough.
Has anyone got any suggestions as to how I can carry out what I want to do?
Cheers.
Have you considered breaking it up into two projects, and setting the pre-build project to be upstream of the build project?
e.g.,
Foo Pre-build
Foo Build
After Foo Pre-build runs, cause "Foo Build" to run.
I have used this, admittedly in different scenarios than yours, quite successfully. This has the added benefit (if you need it) of allowing you to manually run a build without going through the pre-build steps, if you know they aren't necessary.
You should use the free form project type and not the maven project type.
If this is a problem (ie, there are projects that are expecting to be triggered by or triggering from), consider using a custom workspace location and having a free form project execute in this workspace before the maven project runs. The free form project can be used as the trigger for the maven project.
Does adding another build step as a shell script work?
My problem stemmed from the fact I wanted to set-up my workspace before I ran anything due to an issue with Dynamic Views (ClearCase) not being accessible from the workspace - I wanted to add a symlink to fix this.
However, Andrew Bayer has made a change to the plugin that I'm currently testing that should fix this...so the question is probably invalid in it's current form.
Will edit it once we come to a conclusion.