I have found some time to look further in meson.
I have some questions regarding CCompiler class and meson architecture.
Why do you have get_always_args and get_buildtype_args separately?
theoretically you can use only get_buildtype_args and return self.always_args + buildtype_args[buildtype]
What is the difference between get_debug_args() and get_buildtype_args("debug")? I see there are different flags returned but I don't know context for both methods.
Why did you put all compiler classes into compilers.py? From readability point of view it will be better to have separate file for each compiler and it will be easier to add new compilers.
On Mon, Dec 22, 2014 at 5:12 PM, Paweł Wiśniewski <pavel.wi...@gmail.com> wrote:I have found some time to look further in meson.
I have some questions regarding CCompiler class and meson architecture.
Why do you have get_always_args and get_buildtype_args separately?
theoretically you can use only get_buildtype_args and return self.always_args + buildtype_args[buildtype]This follows the basic rule of Python: explicit is better than implicit. Combining always flags with buildtype flags would mix to unrelated concepts.
What is the difference between get_debug_args() and get_buildtype_args("debug")? I see there are different flags returned but I don't know context for both methods.These were remnants of the old way Meson used to do it. All get_debug_args methods are now removed in trunk.Why did you put all compiler classes into compilers.py? From readability point of view it will be better to have separate file for each compiler and it will be easier to add new compilers.No particular reason but having one file for each compiler would make the number of files grow too large. There are no hard and fast rules here.
From my experience sometimes it's better to have more files but smaller files.
In case of compilers I think it would be better to have more smaller files that contain only compiler specific code. It will be easier to add new compiler without risk of breaking existing one.
I will try to add my cross-compiler as separate module.
I'm not sure whether separating compiler from linker is a good idea. I think it's not good idea to use gcc as compiler and VS as linker, it should be somehow connected.
Maybe some concept of toolchain that contain compiler and linker definition. Did you considered such a solution?
I'm thinking about moving some things from environment.py to compilers.py. For example part of __init__ that is creating compiler for target platform (default_c, default_cpp, etc).
I think platform information is part of compiler definition not environment. What do you think about it?
On Mon, Jan 5, 2015 at 12:31 PM, Paweł Wiśniewski <pavel.wi...@gmail.com> wrote:From my experience sometimes it's better to have more files but smaller files.
In case of compilers I think it would be better to have more smaller files that contain only compiler specific code. It will be easier to add new compiler without risk of breaking existing one.
I will try to add my cross-compiler as separate module.Please try to do your submissions in small batches. That is, first just add the compiler in the current file and only after that start thinking about how to change the module structure. The former is simple and noncontroversial whereas module refactorings need a lot more work and have a greater chance of being rejected for one reason or another.
I'm not sure whether separating compiler from linker is a good idea. I think it's not good idea to use gcc as compiler and VS as linker, it should be somehow connected.
Maybe some concept of toolchain that contain compiler and linker definition. Did you considered such a solution?This is what Meson already does. If you select gcc, it will always select gcc's linker, for MSVC it will always select Microsoft's linker and so on. The separate classes are just a way of keeping linker information separate from compilers (because that is what they are after all).
I'm thinking about moving some things from environment.py to compilers.py. For example part of __init__ that is creating compiler for target platform (default_c, default_cpp, etc).
I think platform information is part of compiler definition not environment. What do you think about it?I have thought about this but unfortunately it is not as simple. The same compiler can run on a multitude of different platforms, as an example gcc runs on Linux, FreeBSD, OSX, Aix and so on and so on. You need to separate those two and putting all that platform stuff inside the compiler class would probably make it explode.If you have specific ideas on how to change this (the autodetection bit especially feels a bit wonky) please post your ideas on this list first. There are probably hidden potholes that you might hit if you just start coding.
I have seen this, but I was thinking about some abstraction between environment and compiler/linker. At this moment you are making decision based on compiler class type inside environment. When I want to add new compiler and linker I have to add one more If isinstance.
I'm thinking about adding toolchain layer between compiler and environment. Environment could ask toolchain whether it can run on current operating system or ask for list with supported operating systems. other thing could be asking for supported cross compile platforms.I've made some UML with how it could look like, you can find it here: http://goo.gl/hvNgzD