Csound Csound-dev Csound-tekno Search About

[Csnd] csound development workflow with ninja

Date2022-12-11 13:45
FromHlöðver Sigurðsson
Subject[Csnd] csound development workflow with ninja
Attachments2022-12-11 14.34.17.png  
Someone at the last conference asked about workflow to help with contributing to csound.
I just wanted to bring it to attention, perhaps c-developer wizards were already aware of this.
That instead of waiting 1-2 minutes to wait for csound to fully rebuild and then see if the changes made were correct. It's possible to use cmake and ninja together in such a way that rebuilds take less than 3 seconds, and only the files which changed are rebuilt, or the files that changed and the dependencies of those files.

In this screenshot, I rebuilt a file with added printf statement, and ran a test csd file, all within 3 seconds.

2022-12-11 14.34.17.png

I'll explain how I did this with nix on osx, but nix is only a factor for the dependencies.

I enter a shell with the dependencies I need to build csound, these dependencies I don't want globally installed so I just create a shell with them when needed (I've made a fish function that does this for me)

nix-shell -p cmake libsndfile flex bison boost portaudio gettext clang ninja

now to the magic

$ cmake -Bbuild -H. -GNinja

this will create a new directory "build" with Ninja generator set up correctly configured

$ cd build

now it's possible to rebuild csound from scratch with

$ ninja

and from this moment on, every time you make a change in the csound c sources, you can, from that directory build, rebuild only the changed c source files by calling again ninja, and a new csound executeable binary will be made with those changes.

For me this is a dramatic save of time, and makes everything much more fun. I wish someone told me earlier about ninja :)
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2022-12-11 15:19
FromGiovanni Bedetti
SubjectRe: [Csnd] csound development workflow with ninja
Attachments2022-12-11 14.34.17.png  
This is super useful, thanks for sharing.

Il giorno dom 11 dic 2022 alle ore 13:47 Hlöðver Sigurðsson <hlolli@gmail.com> ha scritto:
Someone at the last conference asked about workflow to help with contributing to csound.
I just wanted to bring it to attention, perhaps c-developer wizards were already aware of this.
That instead of waiting 1-2 minutes to wait for csound to fully rebuild and then see if the changes made were correct. It's possible to use cmake and ninja together in such a way that rebuilds take less than 3 seconds, and only the files which changed are rebuilt, or the files that changed and the dependencies of those files.

In this screenshot, I rebuilt a file with added printf statement, and ran a test csd file, all within 3 seconds.

2022-12-11 14.34.17.png

I'll explain how I did this with nix on osx, but nix is only a factor for the dependencies.

I enter a shell with the dependencies I need to build csound, these dependencies I don't want globally installed so I just create a shell with them when needed (I've made a fish function that does this for me)

nix-shell -p cmake libsndfile flex bison boost portaudio gettext clang ninja

now to the magic

$ cmake -Bbuild -H. -GNinja

this will create a new directory "build" with Ninja generator set up correctly configured

$ cd build

now it's possible to rebuild csound from scratch with

$ ninja

and from this moment on, every time you make a change in the csound c sources, you can, from that directory build, rebuild only the changed c source files by calling again ninja, and a new csound executeable binary will be made with those changes.

For me this is a dramatic save of time, and makes everything much more fun. I wish someone told me earlier about ninja :)
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2022-12-11 17:20
FromRory Walsh
SubjectRe: [Csnd] csound development workflow with ninja
Attachments2022-12-11 14.34.17.png  
Yeah, I always use ninja for my CI builds. It's so much faster. 

On Sun, 11 Dec 2022 at 15:30, Giovanni Bedetti <giovanni.bedetti@gmail.com> wrote:
This is super useful, thanks for sharing.

Il giorno dom 11 dic 2022 alle ore 13:47 Hlöðver Sigurðsson <hlolli@gmail.com> ha scritto:
Someone at the last conference asked about workflow to help with contributing to csound.
I just wanted to bring it to attention, perhaps c-developer wizards were already aware of this.
That instead of waiting 1-2 minutes to wait for csound to fully rebuild and then see if the changes made were correct. It's possible to use cmake and ninja together in such a way that rebuilds take less than 3 seconds, and only the files which changed are rebuilt, or the files that changed and the dependencies of those files.

In this screenshot, I rebuilt a file with added printf statement, and ran a test csd file, all within 3 seconds.

2022-12-11 14.34.17.png

I'll explain how I did this with nix on osx, but nix is only a factor for the dependencies.

I enter a shell with the dependencies I need to build csound, these dependencies I don't want globally installed so I just create a shell with them when needed (I've made a fish function that does this for me)

nix-shell -p cmake libsndfile flex bison boost portaudio gettext clang ninja

now to the magic

$ cmake -Bbuild -H. -GNinja

this will create a new directory "build" with Ninja generator set up correctly configured

$ cd build

now it's possible to rebuild csound from scratch with

$ ninja

and from this moment on, every time you make a change in the csound c sources, you can, from that directory build, rebuild only the changed c source files by calling again ninja, and a new csound executeable binary will be made with those changes.

For me this is a dramatic save of time, and makes everything much more fun. I wish someone told me earlier about ninja :)
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2022-12-11 17:36
FromVictor Lazzarini
SubjectRe: [Csnd] [EXTERNAL] [Csnd] csound development workflow with ninja
I use make, I don’t mind slow. It gives me time to think (and get it wrong anyway).
========================
Prof. Victor Lazzarini
Maynooth University
Ireland

> On 11 Dec 2022, at 17:20, Rory Walsh  wrote:
> 
> WARNINGThis email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.
> Yeah, I always use ninja for my CI builds. It's so much faster. 
> 
> On Sun, 11 Dec 2022 at 15:30, Giovanni Bedetti  wrote:
> This is super useful, thanks for sharing.
> 
> Il giorno dom 11 dic 2022 alle ore 13:47 Hlöðver Sigurðsson  ha scritto:
> Someone at the last conference asked about workflow to help with contributing to csound.
> I just wanted to bring it to attention, perhaps c-developer wizards were already aware of this.
> That instead of waiting 1-2 minutes to wait for csound to fully rebuild and then see if the changes made were correct. It's possible to use cmake and ninja together in such a way that rebuilds take less than 3 seconds, and only the files which changed are rebuilt, or the files that changed and the dependencies of those files.
> 
> In this screenshot, I rebuilt a file with added printf statement, and ran a test csd file, all within 3 seconds.
> 
> <2022-12-11 14.34.17.png>
> 
> I'll explain how I did this with nix on osx, but nix is only a factor for the dependencies.
> 
> I enter a shell with the dependencies I need to build csound, these dependencies I don't want globally installed so I just create a shell with them when needed (I've made a fish function that does this for me)
> 
> nix-shell -p cmake libsndfile flex bison boost portaudio gettext clang ninja
> 
> now to the magic
> 
> $ cmake -Bbuild -H. -GNinja
> 
> this will create a new directory "build" with Ninja generator set up correctly configured
> 
> $ cd build
> 
> now it's possible to rebuild csound from scratch with
> 
> $ ninja
> 
> and from this moment on, every time you make a change in the csound c sources, you can, from that directory build, rebuild only the changed c source files by calling again ninja, and a new csound executeable binary will be made with those changes.
> 
> For me this is a dramatic save of time, and makes everything much more fun. I wish someone told me earlier about ninja :)
> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here


Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2022-12-11 20:13
FromSteven Yi
SubjectRe: [Csnd] [EXTERNAL] [Csnd] csound development workflow with ninja
I've used both for a long while. I typically run "make -j" for parallel make builds. Cmake tools in vscode get confused for me when I use ninja so my build folder in the repo is usually makefiles but I have a folder for ninja and xcode outside of the repo folder.


On Sun, Dec 11, 2022, 12:36 PM Victor Lazzarini <Victor.Lazzarini@mu.ie> wrote:
I use make, I don’t mind slow. It gives me time to think (and get it wrong anyway).
========================
Prof. Victor Lazzarini
Maynooth University
Ireland

> On 11 Dec 2022, at 17:20, Rory Walsh <rorywalsh@EAR.IE> wrote:
>
> WARNINGThis email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.
> Yeah, I always use ninja for my CI builds. It's so much faster.
>
> On Sun, 11 Dec 2022 at 15:30, Giovanni Bedetti <giovanni.bedetti@gmail.com> wrote:
> This is super useful, thanks for sharing.
>
> Il giorno dom 11 dic 2022 alle ore 13:47 Hlöðver Sigurðsson <hlolli@gmail.com> ha scritto:
> Someone at the last conference asked about workflow to help with contributing to csound.
> I just wanted to bring it to attention, perhaps c-developer wizards were already aware of this.
> That instead of waiting 1-2 minutes to wait for csound to fully rebuild and then see if the changes made were correct. It's possible to use cmake and ninja together in such a way that rebuilds take less than 3 seconds, and only the files which changed are rebuilt, or the files that changed and the dependencies of those files.
>
> In this screenshot, I rebuilt a file with added printf statement, and ran a test csd file, all within 3 seconds.
>
> <2022-12-11 14.34.17.png>
>
> I'll explain how I did this with nix on osx, but nix is only a factor for the dependencies.
>
> I enter a shell with the dependencies I need to build csound, these dependencies I don't want globally installed so I just create a shell with them when needed (I've made a fish function that does this for me)
>
> nix-shell -p cmake libsndfile flex bison boost portaudio gettext clang ninja
>
> now to the magic
>
> $ cmake -Bbuild -H. -GNinja
>
> this will create a new directory "build" with Ninja generator set up correctly configured
>
> $ cd build
>
> now it's possible to rebuild csound from scratch with
>
> $ ninja
>
> and from this moment on, every time you make a change in the csound c sources, you can, from that directory build, rebuild only the changed c source files by calling again ninja, and a new csound executeable binary will be made with those changes.
>
> For me this is a dramatic save of time, and makes everything much more fun. I wish someone told me earlier about ninja :)
> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here


Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2022-12-11 20:21
FromVictor Lazzarini
SubjectRe: [Csnd] [EXTERNAL] [Csnd] csound development workflow with ninja
yes, with make -j 8 here I can build Csound very quickly.

Prof. Victor Lazzarini
Maynooth University
Ireland

On 11 Dec 2022, at 20:15, Steven Yi <stevenyi@gmail.com> wrote:


I've used both for a long while. I typically run "make -j" for parallel make builds. Cmake tools in vscode get confused for me when I use ninja so my build folder in the repo is usually makefiles but I have a folder for ninja and xcode outside of the repo folder.


On Sun, Dec 11, 2022, 12:36 PM Victor Lazzarini <Victor.Lazzarini@mu.ie> wrote:
I use make, I don’t mind slow. It gives me time to think (and get it wrong anyway).
========================
Prof. Victor Lazzarini
Maynooth University
Ireland

> On 11 Dec 2022, at 17:20, Rory Walsh <rorywalsh@EAR.IE> wrote:
>
> WARNINGThis email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.
> Yeah, I always use ninja for my CI builds. It's so much faster.
>
> On Sun, 11 Dec 2022 at 15:30, Giovanni Bedetti <giovanni.bedetti@gmail.com> wrote:
> This is super useful, thanks for sharing.
>
> Il giorno dom 11 dic 2022 alle ore 13:47 Hlöðver Sigurðsson <hlolli@gmail.com> ha scritto:
> Someone at the last conference asked about workflow to help with contributing to csound.
> I just wanted to bring it to attention, perhaps c-developer wizards were already aware of this.
> That instead of waiting 1-2 minutes to wait for csound to fully rebuild and then see if the changes made were correct. It's possible to use cmake and ninja together in such a way that rebuilds take less than 3 seconds, and only the files which changed are rebuilt, or the files that changed and the dependencies of those files.
>
> In this screenshot, I rebuilt a file with added printf statement, and ran a test csd file, all within 3 seconds.
>
> <2022-12-11 14.34.17.png>
>
> I'll explain how I did this with nix on osx, but nix is only a factor for the dependencies.
>
> I enter a shell with the dependencies I need to build csound, these dependencies I don't want globally installed so I just create a shell with them when needed (I've made a fish function that does this for me)
>
> nix-shell -p cmake libsndfile flex bison boost portaudio gettext clang ninja
>
> now to the magic
>
> $ cmake -Bbuild -H. -GNinja
>
> this will create a new directory "build" with Ninja generator set up correctly configured
>
> $ cd build
>
> now it's possible to rebuild csound from scratch with
>
> $ ninja
>
> and from this moment on, every time you make a change in the csound c sources, you can, from that directory build, rebuild only the changed c source files by calling again ninja, and a new csound executeable binary will be made with those changes.
>
> For me this is a dramatic save of time, and makes everything much more fun. I wish someone told me earlier about ninja :)
> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here


Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2022-12-12 02:12
FromAlex Hofmann
SubjectRe: [Csnd] =?UTF-8?Q?=C2=A0Re=3A_?=[Csnd] [EXTERNAL] [Csnd] csound development workflow with ninja

Hlöðver, thanks for sharing. (first time I heard of this ninja approach). Alex
--
Sent from my Android phone with GMX Mail. Please excuse my brevity.
On 12/11/22, 21:21 Victor Lazzarini <Victor.Lazzarini@MU.IE> wrote:
yes, with make -j 8 here I can build Csound very quickly.

Prof. Victor Lazzarini
Maynooth University
Ireland

On 11 Dec 2022, at 20:15, Steven Yi <stevenyi@gmail.com> wrote:


I've used both for a long while. I typically run "make -j" for parallel make builds. Cmake tools in vscode get confused for me when I use ninja so my build folder in the repo is usually makefiles but I have a folder for ninja and xcode outside of the repo folder.


On Sun, Dec 11, 2022, 12:36 PM Victor Lazzarini <Victor.Lazzarini@mu.ie> wrote:
I use make, I don’t mind slow. It gives me time to think (and get it wrong anyway).
========================
Prof. Victor Lazzarini
Maynooth University
Ireland

> On 11 Dec 2022, at 17:20, Rory Walsh <rorywalsh@EAR.IE> wrote:
>
> WARNINGThis email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.
> Yeah, I always use ninja for my CI builds. It's so much faster.
>
> On Sun, 11 Dec 2022 at 15:30, Giovanni Bedetti <giovanni.bedetti@gmail.com> wrote:
> This is super useful, thanks for sharing.
>
> Il giorno dom 11 dic 2022 alle ore 13:47 Hlöðver Sigurðsson <hlolli@gmail.com> ha scritto:
> Someone at the last conference asked about workflow to help with contributing to csound.
> I just wanted to bring it to attention, perhaps c-developer wizards were already aware of this.
> That instead of waiting 1-2 minutes to wait for csound to fully rebuild and then see if the changes made were correct. It's possible to use cmake and ninja together in such a way that rebuilds take less than 3 seconds, and only the files which changed are rebuilt, or the files that changed and the dependencies of those files.
>
> In this screenshot, I rebuilt a file with added printf statement, and ran a test csd file, all within 3 seconds.
>
> <2022-12-11 14.34.17.png>
>
> I'll explain how I did this with nix on osx, but nix is only a factor for the dependencies.
>
> I enter a shell with the dependencies I need to build csound, these dependencies I don't want globally installed so I just create a shell with them when needed (I've made a fish function that does this for me)
>
> nix-shell -p cmake libsndfile flex bison boost portaudio gettext clang ninja
>
> now to the magic
>
> $ cmake -Bbuild -H. -GNinja
>
> this will create a new directory "build" with Ninja generator set up correctly configured
>
> $ cd build
>
> now it's possible to rebuild csound from scratch with
>
> $ ninja
>
> and from this moment on, every time you make a change in the csound c sources, you can, from that directory build, rebuild only the changed c source files by calling again ninja, and a new csound executeable binary will be made with those changes.
>
> For me this is a dramatic save of time, and makes everything much more fun. I wish someone told me earlier about ninja :)
> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here


Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here