Meson build system user learning D.

Mike Brockus michaelbrockus at icloud.com
Tue May 21 05:21:13 UTC 2019


On Tuesday, 21 May 2019 at 03:07:20 UTC, Johannes Loher wrote:
> On Sunday, 19 May 2019 at 16:47:39 UTC, Mike Brockus wrote:
>> On Sunday, 19 May 2019 at 07:46:11 UTC, Johannes Loher wrote:
>>> Am 18.05.19 um 08:20 schrieb Mike Brockus:
>>>> [...]
>>>
>>> Hey there,
>>>
>>> I already tried to answer your questions on reddit.
>>>
>>> You can post links here by simply pasting the URL (the link 
>>> will not be highlighted in the editor, but it will be when it 
>>> is posted).
>>>
>>> Regarding your problem: Could you please describe what you 
>>> are actually trying to do? Are you trying to use D in an 
>>> exisiting Meson project (as an addition to the existing 
>>> code)? Why are you trying to use the Unity test framework (I 
>>> only had a quick look at it, but from what I saw it uses a 
>>> lot of preprocessor macros which will make it difficult to 
>>> get it wotk work properly with D). Why not use the built-in 
>>> unittests or one of the many already existing unit testing 
>>> frameworks for D ([1], [2], [3], [4], [5])?
>>>
>>> [1] https://code.dlang.org/packages/unit-threaded
>>> [2] https://code.dlang.org/packages/dunit
>>> [3] https://code.dlang.org/packages/d-unit
>>> [4] https://code.dlang.org/packages/fluent-asserts
>>> [5] https://code.dlang.org/packages/trial
>>
>> I am trying to do two things one being able to turn a pure C 
>> project into a pure D project without destroying the existing 
>> file structure.
>> The project (https://github.com/squidfarts/c-project.git)
>>
>> The other is to make a new Arduino UNO board project that 
>> leverages existing C and C++ code so I can spend small amounts 
>> of time writing new D code as I update all of my Arduino 
>> applications.
>>
>> I would like to use the Unity test framework for that Arduino 
>> UNO based project that uses D, C, C++ and both Meson build 
>> system and Conan package manager.  The part with C and C++ are 
>> just for linking with the Arduino libraries, including exiting 
>> classes while I write new D code to replace the existing C and 
>> C++ code where ever it makes since.  Conan is used to get both 
>> the Unity and CMock from GitHub.
>>
>> For the pure D project I would like to use whatever D provides 
>> me.  Since you provided this list I would start with 
>> unit-threaded and see if it can help with this main function 
>> problem.
>
> Hey again, does my answer from reddit not solve your first 
> problem (keeping the existing file structure)? As mentioned, 
> using Unity for the tests does not really make sense with D, 
> though it might be possible to use it with dpp ([1]).
>
> Regarding your second problem: The Arduino UNO is based on the 
> ATmega328P, which is an AVR chip. There is currently no D 
> compiler available, that targets AVR, so you won‘t be able to 
> use D for programming your Arduino UNO for now. There have been 
> discussions about this ([2], [3]), but for now it is simply not 
> possible.
>
> [1] https://github.com/atilaneves/dpp
> [2] 
> https://forum.dlang.org/thread/1328258826.2142.4.camel@ububox?page=1
> [3] 
> https://forum.dlang.org/thread/zvderukicijcuxgqgwzk@forum.dlang.org

The solution from Reddit solves the problem for 'dub' but as part 
of my project C to D I wanted to use Meson and run test with 
whatever is available, coming next week I will try to incorporate 
'unit-threaded' and if it works then I can tell Meson to include 
it as my decency and to use 'dub' to get it for me so I can focus 
on writing test for my code.  I am currently working on becoming 
an Android app developer leaning Kotlin and on the weekends it's 
D.

As for Arduino I was thinking more in the ways of using D to 
interface with existing C functionality in the Arduino, for this 
to work I think I just need to tell Meson to make this a C, C++, 
D project.  Something like this:

# Root meson.build

project('uno_proj', 'c', 'cpp', 'd')# this would work...

subdir('src')



# src/main.d
extern (C) void setup(); // This should call the defections for 
the most important
extern (C) void loop();  // functions in any Arduino program.


void setup()
{
     // some code here.
}// end of function setup

void loop()
{
     // Whatever the program needs to do.
}// end of function loop



In the actual project the meson.build in the 'src' directory is 
where I manage generating the other required files also, this was 
just meant to be like pseudocode example to give some idea as to 
what I meant.

However it is good to know that there is currently no compiler 
for D on a AVR chip.









More information about the Digitalmars-d-learn mailing list