I just downloaded source code of kicad (kicad-source-mirror-master). I want to look at the source code see if I can learn from it. I have the following questions.
Is there any kind of flow chart for the software?
Is there any document that show the structure of different pieces of .cpp codes? and explaining what .cpp does what?
What kind of IDE can I use to edit source codes?
What kind of compiler can I use to compiler all these codes?
How to compiler the source codes?
Any other information that could help me dive in the source code would be very much appreciated. Thanks
Joan_Sparky is right if you already donāt know C++. If you do, read first the Contribute/Developers section of the Kicad web pages. Follow all the relevant links there. Then thereās at least one video: https://archive.fosdem.org/2017/schedule/event/kicad_source/.
officially? only GNU tools, GCC and CMAKE. Using Mingw32 on Windows⦠Unofficially there was an effort by Simon Richter to make it build on MSVC. https://code.launchpad.net/~sjr/kicad/msvc but not sure if it was discontinued (lots of support effort)
see the link suggested by @slc; also, IMO, it is easier to build on Linux debian based (eg: ubuntu) distro.
Moreover if you are on windows, there is kicadwinbuilder that does all the jobā¦
Then you can have a full building environment where to do your tests.
KiCad uses CMake build system to compile the project. If you havenāt heard about it I suggest you check this first. You donāt have to be an expert on CMake to hack kicad source but knowing what cmake is and how to run it, is necessary. Itās not an IDE, itās more like a scripting language for building C++ projects. Although its a command line application it also has a GUI that you can use. But donāt expect much from it. A great feature of CMake is that it can create āprojectsā for many other IDEās (Visual Studio, CodeBlocks etc.) so you can use an IDE if you want to. Some IDEs such as QtCreator and KDevelop can directly open CMake projects without any āgenerationā. I suggest you try KDevelop. My experience with it was great.
By the way in my opinion, building open source projects especially big ones such as KiCad is much easier on Linux operating systems compared to windows. Simply because its much easier to collect dependencies. As an every day linux user I might be biased though. Just sayingā¦
Before you ādiveā into the code, I suggest you pick a feature and try to hack it. You should have something in your mind that you want to improve. Otherwise you are going to get lost in the code. KiCad has a relatively big code base.
A warning, currently KiCad is under heavy development. Because of that there is a significant amount of duplicate code. Especially on the PCB side. In my experience, sometimes finding the corresponding code for a specific feature can be challenging. But once you do, hacking kicad isnāt so hard.
I guess I miscommunicated. My intention was not learning CPP itself but learning how KiCAD is implemented. I am not software engineer but I know or should say knew CPP once upon a time. Thanks anyway.
Thanks a lot for your help and time. I have not looked at the code base in detail yet. What I want to do is to take a feature, for example schematics, strip it to the basic level and then start from there. I had studied CPP at university and my skill level, I guess is at intermediate level. At this point I am trying to learn. I am using Windows 10 and have not had Linux on my system for many years. Is it possible to use a windows based IDE like Visual Studio? Thanks
In theory yes. CMake can create Visual Studio projects. But thatās the easy part. CMake cannot guarantee that visual studio can build the generated project. First of all, codebase should be compatible with compiler used by visual studio. I donāt see why it shouldnāt be. But sometimes projects use specific features of a compiler (say gcc) and you may have trouble with other compilers. Itās generally a good idea to use the compiler that is used by the developers of the software, if possible. My advice is that donāt insist on an IDE at the beginning. Start with the command line, use a text editor designed for programmers (notepad++, sublime etc).
The other issue is the library dependencies. CMake doesnāt automatically download and prepare dependencies (unless itās scripted to do so). Thatās usually the hard part. Iāve never used the kicad-winbuilder, but Iām guessing itās a tool to download everything necessary and setup an environment for building KiCad. Itās written as a CMake script. Thatās why there is no binaries for it. Itās a script that is run with CMake.
winbuilder, setups an environment based on MSYS2. This is a platform for building and running linux software on Windows. Itās great because it provides tools that usually exist in linux operating systems. Such as a package manager which makes it very easy to download and install library dependencies. But these tools are actually windows native software so they can be run like any other EXE. Also software that is built under msys2 will run like a native software. I use msys2 to create windows binaries for my projects. A small warning, in my experience setting up msys2 requires a lot of download = ~5GB at least. Make sure you have good connection.
You will discover that the coding styles that coders use for real work is different than what you would use if you were writing code for a compSci textbook.
I also recommend KDevelop. Actually it can be run on Windows: https://www.kdevelop.org/download. It gives great amount of information with mouse-hover-over and you can jump back and forth in the codebase easily. Modern IDEs are from another world than trying to get familiar with the code base with only a text editor (even an advanced one). I would never try the latter after using modern IDEs.
Reading/editing the code and compiling it are of course two different things; maybe itās possible to use Visual Studio for reading and editing and MSYS environment for building.
Because we are talking about KiCad code base I would add āto put it mildlyā.