This repository was archived by the owner on Jan 27, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathatom.xml
2019 lines (1563 loc) · 126 KB
/
atom.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
<title type="text">De Re mulle-sde</title>
<generator uri="https://github.com/jekyll/jekyll">Jekyll</generator>
<link rel="self" type="application/atom+xml" href="https://www.mulle-kybernetik.com/atom.xml" />
<link rel="alternate" type="text/html" href="https://www.mulle-kybernetik.com" />
<updated>2025-01-26T22:56:44+01:00</updated>
<id>https://www.mulle-kybernetik.com/</id>
<author>
<name>Nat!</name>
<uri>https://www.mulle-kybernetik.com/</uri>
</author>
<entry>
<title type="html"><![CDATA[Hecklers Corner]]></title>
<link rel="alternate" type="text/html" href="https://www.mulle-kybernetik.com/hecklers-corner.html" />
<id>https://www.mulle-kybernetik.com/hecklers-corner.html</id>
<published>2022-11-02T00:00:00+01:00</published>
<updated>2022-11-02T00:00:00+01:00</updated>
<author>
<name>Nat!</name>
<uri>https://www.mulle-kybernetik.com</uri>
</author>
<content type="html"><h4 id="why-dont-you-use-direnv-">Why don’t you use <code class="language-plaintext highlighter-rouge">direnv</code> ?</h4>
<p>I rarely use the interactive subshell for executing virtual environments, but
instead use <code class="language-plaintext highlighter-rouge">mulle-sde run</code> all the time.
direnv augments the environment, it doesn’t remove environment variables,
unless you explicity write environment files to do so.
For lack of a better term, there is no API to add and remove environment
variables. There is no “tool” functionality.</p>
<h4 id="why-dont-you-use-docker-instead-">Why don’t you use <code class="language-plaintext highlighter-rouge">docker</code> instead ?</h4>
<p>Docker is too slow and cumbersome. It’s not that popular on freebsd and I
doubt it will work in mingw.</p>
<h4 id="why-dont-you-use-git-submodules-instead-">Why don’t you use <code class="language-plaintext highlighter-rouge">git submodules</code> instead ?</h4>
<p>One advantage of mulle-sde dependencies over git submodules is, that when you
are doing git, you are not doing anything else.
mulle-sde dependencies can be used with various source control management
systems (SCM). You can mix tar archives with git and svn repositories.</p>
<h4 id="why-dont-you-use-my-pet-sandbox-instead-of-mulle-env-">Why don’t you use &lt;my pet sandbox&gt; instead of mulle-env ?</h4>
<p>Sandboxing would not help with the environment setting. Sandboxing can be
an interesting idea on top of mulle-sde. And actually in the newest version
there is support for linux landlock sandboxing (also there is some support
for apparmor) See the <a href="//github.com/mulle-sde/mulle-sde/wiki">Wiki</a> for
more info.</p>
<h4 id="why-is-this-written-bash-and-not-in-my-pet-language-">Why is this written bash and not in &lt;my pet language&gt; ?</h4>
<p>Actually this used to be written in “sh”, the Bourne Shell.
I would expect the Bourne Shell to be unbeatable in terms of availabilty and
long term compatibility (think decades not years). Sadly “sh” must rely on
external commands, to get anything slightly sophisticated done. This already
impedes cross-platform portability. But the main reason is that
running external commands for string operations is <em>just too slow</em>.</p>
<p>So I returned to the “bash”.</p>
<h4 id="why-is-this-written-in-fairly-ancient-bash-">Why is this written in fairly ancient bash ?</h4>
<p>When this project started on macOS (then as mulle-bootstrap), the “bash” was
seriously out of date and didn’t even support arrays (this is still noticable
in the code today). “bash” on macOS a mere decade or so later is still out of
date and has been officially replaced by “zsh”. So now I need to support two
shells “bash” and “zsh”. Both are mostly compatible with each other, but not 100%.
I am loathe to use too many fancy “bash” features to keep “zsh” as a fallback
option or vice versa.</p>
<h4 id="mulle-template-is-just-a-glorified-sed-script">mulle-template is just a glorified sed script!</h4>
<p>That’s pretty much what it is!</p>
<h4 id="mulle-match-is-just-a-glorified-find-command">mulle-match is just a glorified find command!</h4>
<p>That’s really not quite what it is!</p>
</content>
</entry>
<entry>
<title type="html"><![CDATA[Outro]]></title>
<link rel="alternate" type="text/html" href="https://www.mulle-kybernetik.com/outro.html" />
<id>https://www.mulle-kybernetik.com/outro.html</id>
<published>2022-11-01T00:00:00+01:00</published>
<updated>2022-11-01T00:00:00+01:00</updated>
<author>
<name>Nat!</name>
<uri>https://www.mulle-kybernetik.com</uri>
</author>
<content type="html"><p>When all roads have been traveled, the next trip might be the <a href="https://github-com/mulle-sde/mulle-sde.wiki">mulle-sde Wiki</a>. There is still a lot more to discover.</p>
<p>Some but not all of the topics not covered in this guide are</p>
<ul>
<li>version support (mulle-semver)</li>
<li>platform dependent dependencies</li>
<li>header only dependencies</li>
<li>control of generated cmake statements</li>
</ul>
<p>The <a href="//mulle-objc.github.io/De-Re-mulle-objc/">De Re mulle-objc</a>
developer guide might also be a good next read.</p>
<h2 id="links">Links</h2>
<ul>
<li><a href="//mulle-objc.github.io/">mulle-objc</a> homepage</li>
</ul>
</content>
</entry>
<entry>
<title type="html"><![CDATA[💄 Definition isolator]]></title>
<link rel="alternate" type="text/html" href="https://www.mulle-kybernetik.com/definition.html" />
<id>https://www.mulle-kybernetik.com/definition.html</id>
<published>2022-03-07T00:00:00+01:00</published>
<updated>2022-03-07T00:00:00+01:00</updated>
<author>
<name>Nat!</name>
<uri>https://www.mulle-kybernetik.com</uri>
</author>
<content type="html"><p>The mulle-sde <a href="virtual_env.html">virtual environment</a> shields the project from
unintentional environment settings. But that is not enough separation, if the
project is made up of multiple projects (a.k.a. “dependencies”).</p>
<p>Here is a contrived example. The main project get its current version via the
commandline like <code class="language-plaintext highlighter-rouge">cc -DVERSION='"1"'</code>. Lets use the mulle-sde environment to
set <code class="language-plaintext highlighter-rouge">CFLAGS</code>, assuming that this is picked up by the Makefile.</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>mulle-sde environment <span class="nb">set </span>CFLAGS <span class="s1">'-DVERSION="1"'</span>
</code></pre></div></div>
<p>It will work fine, until you add a third-party dependency, which also uses a
<code class="language-plaintext highlighter-rouge">VERSION</code> definition. As the mulle-sde environment is active during the build
of the project and the build of the dependency, there will be a clash.</p>
<h2 id="definitions-environments-for-a-build">Definitions: environments for a build</h2>
<p><em>mulle-make</em> is the meta-builder, that uses build systems like <em>cmake</em> and
<em>autoconf</em> and <em>xcodebuild</em>, to build a dependency or the project itself.
That may sound fancy, but is really not much more than what this little script
does:</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c">#! /bin/sh</span>
<span class="k">if</span> <span class="o">[</span> <span class="nt">-f</span> CMakeLists.txt <span class="o">]</span>
<span class="k">then
</span>cmake <span class="nt">-B</span> build <span class="nt">-S</span> <span class="nb">.</span>
cmake <span class="nt">--build</span> build
<span class="k">else</span>
<span class="c"># use some other build tool</span>
<span class="k">fi</span>
</code></pre></div></div>
<p>One thing <em>mulle-make</em> adds to the process, is that it looks at variables that
start with the string ‘DEFINITION_’ and uses those to create options for
the individual build tool (unknown options are passed verbatim).</p>
<p>For example the value of <code class="language-plaintext highlighter-rouge">DEFINITION_CFLAGS='-DVERSION="1"'</code> will be used
by the <em>cmake</em> plugin of mulle-make to produce a
<code class="language-plaintext highlighter-rouge">-DCMAKE_C_FLAGS='-DVERSION="1"'</code> command line option for cmake.</p>
<p>So how are <code class="language-plaintext highlighter-rouge">DEFINITION_</code> variables set in mulle-make ? They are fed to
mulle-make by another tool mulle-craft. mulle-craft searches for applicable
definition folders and applies them to the mulle-make call. There can be
multiple definitions, which enables inheritance schemes.</p>
<h2 id="project-definitions">Project definitions</h2>
<p>The main project <code class="language-plaintext highlighter-rouge">definition</code> folder is managed with the <code class="language-plaintext highlighter-rouge">mulle-sde definition</code>
commands. The values contained in it are only used for the main project and can
not be overridden.</p>
<p><img src="images/definition1.svg" alt="Project definitions" /></p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">cd </span>foo
cc <span class="nt">-DVERSION</span><span class="o">=</span><span class="s1">'"1"'</span> ...
</code></pre></div></div>
<h2 id="dependency-definitions">Dependency definitions</h2>
<p>A dependency definition is just a project definition from a different
perspective. Here a third party project may very well also have a <code class="language-plaintext highlighter-rouge">definition</code>
folder, if it is a mulle-sde project. This definition will be used during
its build. But it will not interfere with the main project craft.</p>
<p><img src="images/definition2.svg" alt="Dependency definitions" /></p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="o">(</span>
<span class="nb">cd </span>foo/stash/bar
cc <span class="nt">-DVERSION</span><span class="o">=</span><span class="s1">'"2"'</span> ...
<span class="o">)</span>
<span class="nb">cd </span>foo
cc <span class="nt">-DVERSION</span><span class="o">=</span><span class="s1">'"1"'</span> ...
</code></pre></div></div>
<h2 id="project-craftinfos">Project craftinfos</h2>
<p>The project has the option to override dependency definitions with <code class="language-plaintext highlighter-rouge">craftinfos</code>.
This is especially useful for third party projects, that are not mulle-sde
projects. With a <em>craftinfo</em> you can tweak the build process of that dependency
to your liking without having to edit the dependency source itself.</p>
<p><img src="images/definition3.svg" alt="Project craftinfos" /></p>
<p>The values in the <em>craftinfo</em> will usually override the values in the
<em>definition</em> of the dependency. So <code class="language-plaintext highlighter-rouge">-DVERSION="3"</code> will be in effect for
the craft of “bar”.</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="o">(</span>
<span class="nb">cd </span>foo/stash/bar
cc <span class="nt">-DVERSION</span><span class="o">=</span><span class="s1">'"3"'</span> ...
<span class="o">)</span>
<span class="nb">cd </span>foo
cc <span class="nt">-DVERSION</span><span class="o">=</span><span class="s1">'"1"'</span> ...
</code></pre></div></div>
<h2 id="inherited-definitions">Inherited definitions</h2>
<p>Maybe the most powerful feature of the mulle-sde build system are inherited
<em>definitions</em>. These definitions are installed by dependencies into the
<code class="language-plaintext highlighter-rouge">dependency/share</code> folder and can affect all consecutive dependencies.
This for example allows the switch of compilers during the craft of
dependencies.</p>
<p>Multiple dependencies can add and subtract from these definitions.</p>
<p><img src="images/definition4.svg" alt="Inherited craftinfos" /></p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="o">(</span>
<span class="nb">cd </span>foo/stash/bar
cc <span class="nt">-DVERSION</span><span class="o">=</span><span class="s1">'"3"'</span> ...
<span class="o">)</span>
<span class="nb">cd </span>foo
mulle-clang <span class="nt">-DVERSION</span><span class="o">=</span><span class="s1">'"1"'</span> ...
</code></pre></div></div>
<p>Inherited definitions can augment the <em>definitions</em> of the main project, but
it can not override them.</p>
<p>Inherited definitions can override the <em>definitions</em> of dependencies, but
it does not override <em>craftinfos</em>.</p>
</content>
</entry>
<entry>
<title type="html"><![CDATA[☑︎ Test suite with Coverage 🆕]]></title>
<link rel="alternate" type="text/html" href="https://www.mulle-kybernetik.com/test-coverage.html" />
<id>https://www.mulle-kybernetik.com/test-coverage.html</id>
<published>2022-03-06T00:00:00+01:00</published>
<updated>2022-03-06T00:00:00+01:00</updated>
<author>
<name>Nat!</name>
<uri>https://www.mulle-kybernetik.com</uri>
</author>
<content type="html"><p>Tests for libraries and executables are easily setup with mulle-sde. In
both cases just run:</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>mulle-sde <span class="nb">test </span>init
</code></pre></div></div>
<p>and a basic test setup should be setup in the <code class="language-plaintext highlighter-rouge">test</code> folder.</p>
<h2 id="executable-test--coverage">Executable Test + Coverage</h2>
<p>There are two simple principles behind mulle-sde tests.</p>
<p>They are:</p>
<ul>
<li>a non-zero exit code means a failed test (unless a <code class="language-plaintext highlighter-rouge">&lt;testname&gt;.errors</code> file is present)</li>
<li>if a file <code class="language-plaintext highlighter-rouge">&lt;testname&gt;.stdout</code> is present, then the output of the test must match the contents of this file exactly</li>
</ul>
<h3 id="setting-up-a-test">Setting up a test</h3>
<p>To build the executable for testing:</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>mulle-sde <span class="nb">test </span>craft
</code></pre></div></div>
<p>Each test for an executable is a file named <code class="language-plaintext highlighter-rouge">&lt;testname&gt;.args</code>. Conversely each
test for a C library is named <code class="language-plaintext highlighter-rouge">&lt;testname&gt;.c</code>, for an Objective-C library
<code class="language-plaintext highlighter-rouge">&lt;testname&gt;.m</code> and so on.</p>
<p>So a test named <code class="language-plaintext highlighter-rouge">hello.args</code> file is found in the <code class="language-plaintext highlighter-rouge">10-first</code> folder, so this
will be the demo test we will run (it will fail):</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>mulle-sde <span class="nb">test </span>run
</code></pre></div></div>
<p>Rerun it with <code class="language-plaintext highlighter-rouge">mulle-sde test rerun --serial</code>, it will fail again. Provide
the proper output in the <testname>.stdout and now all tests will pass.</testname></p>
<h3 id="creating-coverage-information">Creating coverage information</h3>
<p>When all tests pass, you can create coverage information:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>mulle-sde test coverage
</code></pre></div></div>
<p>This will rebuild the project with coverage information and then all tests
are run again. For a “hello world” executable, the output will look like this:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>------------------------------------------------------------------------------
GCC Code Coverage Report
Directory: /tmp/bbb/src
------------------------------------------------------------------------------
File Lines Exec Cover Missing
------------------------------------------------------------------------------
main.c 3 3 100%
------------------------------------------------------------------------------
TOTAL 3 3 100%
------------------------------------------------------------------------------
</code></pre></div></div>
<p>You can also get HTML output, check the usage of the <code class="language-plaintext highlighter-rouge">coverage</code> command for
more info.</p>
<h2 id="final-words">Final Words</h2>
<p><a href="//github.com/mulle-sde/mulle-test">mulle-test</a> provides much more
information how to setup and check tests.</p>
</content>
</entry>
<entry>
<title type="html"><![CDATA[💠 Makefile maintainer]]></title>
<link rel="alternate" type="text/html" href="https://www.mulle-kybernetik.com/makefile.html" />
<id>https://www.mulle-kybernetik.com/makefile.html</id>
<published>2022-03-05T00:00:00+01:00</published>
<updated>2022-03-05T00:00:00+01:00</updated>
<author>
<name>Nat!</name>
<uri>https://www.mulle-kybernetik.com</uri>
</author>
<content type="html"><p>There is no better tool to structure a project with, than the filesystem tools
you already have. That is either a textual command line terminal or the native
GUI “File Explorer”, “Finder”, “Nautilus”. Large scale project reorganizations
are usually a major pain in IDEs, but moving files between folders is a cinch
in the shell or in the Finder.</p>
<p>mulle-sde as a project maintenance tool examines the file arrangement of your
project and “reflects” it back into a “Makefile” or “CMakeLists.txt” or any
other build system of your choice.</p>
<h2 id="demo-nim-and-make">Demo: nim and make</h2>
<p>Let’s create a build system for the <a href="https://nim-lang.org/">nim</a> language
using <em>make</em>. <em>cmake</em> is more common for mulle-sde, but lets have a challenge
here.</p>
<h3 id="helloworldnim-and-a-makefile">Helloworld.nim and a Makefile</h3>
<p>Lets start with a “hello world” source, taken from the
<a href="https://nim-by-example.github.io/hello_world/">nim-by-example</a> website.
Though sources may reside in the root folder, a subfolder is more convenient
for technical reasons. So <code class="language-plaintext highlighter-rouge">helloworld.nim</code> is placed into a subdirectory called
<code class="language-plaintext highlighter-rouge">src</code>.</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">mkdir</span> <span class="nt">-p</span> nim-demo/src
<span class="nb">cat</span> <span class="o">&lt;&lt;</span><span class="no">EOF</span><span class="sh"> &gt; nim-demo/src/helloworld.nim
echo "Hello World"
</span><span class="no">EOF
</span></code></pre></div></div>
<p>A simple Makefile for the “helloworld” executable is:</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">cat</span> <span class="o">&lt;&lt;</span><span class="no">EOF</span><span class="sh"> &gt; nim-demo/Makefile
.SUFFIXES: .nim
SOURCES=src/helloworld.nim
OBJECTS=</span><span class="se">\$</span><span class="sh">(SOURCES:.nim=.o)
.nim.o:
nim -c -o </span><span class="se">\$</span><span class="sh">@ </span><span class="se">\$</span><span class="sh">&lt;
helloworld: </span><span class="se">\$</span><span class="sh">(OBJECTS)
ld -o </span><span class="se">\$</span><span class="sh">@ </span><span class="se">\$</span><span class="sh">&lt;
</span><span class="no">EOF
</span></code></pre></div></div>
<p>A <code class="language-plaintext highlighter-rouge">make</code> run shows this to be working.</p>
<h3 id="mulle-sde-integration-from-scratch">mulle-sde integration (from scratch)</h3>
<p>The first step is to make this a mulle-sde project. As neither <em>nim</em> nor <em>make</em>
are supported by any mulle-sde extensions yet, only a bare project can be
created:</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>mulle-sde init <span class="nt">-d</span> nim-demo <span class="nt">--no-post-init</span> none
</code></pre></div></div>
<h4 id="let-mulle-sde-manage-the-makefile">Let mulle-sde manage the Makefile</h4>
<p>The <code class="language-plaintext highlighter-rouge">mulle-sde -f files</code> command, checks, if a source is identified as an
interesting file by mulle-sde. The first time the output will be empty though.
<code class="language-plaintext highlighter-rouge">src/helloworld.nim</code> is not yet considered to be interesting. For that a
matcher is needed to associate files with the <code class="language-plaintext highlighter-rouge">.nim</code> extension with a
mulle-sde file type. Lets call the type “sources”.</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>mulle-sde <span class="nt">-d</span> nim-demo match <span class="s1">'*.nim'</span> sources
</code></pre></div></div>
<p>Now <code class="language-plaintext highlighter-rouge">mulle-sde -d nim-demo -f files</code> will return:</p>
<p><img src="images/manage-files.png" alt="" /></p>
<p>How to get this information into the Makefile ? A tool that edits an
existing Makefile is complicated to devise and seldom foolproof. Overwriting
the whole Makefile is undesirable, as it would delete user edits.
The best idea is to let some parts of the Makefile be generated as
separate file. This file is then included by the Makefile.
Thus the Makefile becomes:</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">cat</span> <span class="o">&lt;&lt;</span><span class="no">EOF</span><span class="sh"> &gt; nim-demo/Makefile
.SUFFIXES: .nim
SOURCES=
include make/sources.make
OBJECTS=</span><span class="se">\$</span><span class="sh">(SOURCES:.nim=.o)
.nim.o:
nim -c -o </span><span class="se">\$</span><span class="sh">@ </span><span class="se">\$</span><span class="sh">&lt;
helloworld: </span><span class="se">\$</span><span class="sh">(OBJECTS)
ld -o </span><span class="se">\$</span><span class="sh">@ </span><span class="se">\$</span><span class="sh">&lt;
</span><span class="no">EOF
</span></code></pre></div></div>
<p>The file <code class="language-plaintext highlighter-rouge">make/sources.make</code> should be generated by mulle-sde on
<code class="language-plaintext highlighter-rouge">mulle-sde -f reflect</code>. Lets create a small script to do just that:</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">cat</span> <span class="o">&lt;&lt;</span><span class="no">EOF</span><span class="sh"> &gt; nim-demo/nim-make-reflect
#! /bin/sh
mkdir -p make
mulle-match list --format '%T += %f</span><span class="se">\n</span><span class="sh">' &gt; make/sources.make
</span><span class="no">EOF
</span><span class="nb">chmod </span>755 nim-demo/nim-make-reflect
</code></pre></div></div>
<blockquote>
<p><strong>mulle-match</strong> is the program that is actually used when <code class="language-plaintext highlighter-rouge">mulle-sde files</code>
is run. <code class="language-plaintext highlighter-rouge">mulle-sde files</code> is very limited, but <code class="language-plaintext highlighter-rouge">mulle-match list</code> is quite
powerful. Besides various filter options, you can specify a printf like format
to be used on each file. In the above format string <code class="language-plaintext highlighter-rouge">%T</code> turns the mulle-sde
file type into an uppercase identifier and <code class="language-plaintext highlighter-rouge">%f</code> prints the filename.
Everything else is printed verbatim.</p>
</blockquote>
<p>To add the script into the reflection mechanism of mulle-sde, a named task has
to be created. The name “filesystem” is conventional, it is not required.
The integration with the <code class="language-plaintext highlighter-rouge">mulle-sde reflect</code> mechanism is done
via the environment <code class="language-plaintext highlighter-rouge">MULLE_SDE_REFLECT_CALLBACKS</code> variable:</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>mulle-sde <span class="nt">-f</span> <span class="nt">-d</span> nim-demo task create <span class="nt">--callback</span> filesystem <span class="s2">"</span><span class="k">${</span><span class="nv">PWD</span><span class="k">}</span><span class="s2">/nim-demo/nim-make-reflect"</span>
mulle-sde <span class="nt">-d</span> nim-demo environment <span class="nt">--global</span> <span class="nb">set </span>MULLE_SDE_REFLECT_CALLBACKS filesystem
</code></pre></div></div>
<p>After <code class="language-plaintext highlighter-rouge">mulle-sde -d nim-demo reflect</code> the file <code class="language-plaintext highlighter-rouge">cmake/sources.make</code> will have appeared.</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>mulle-sde reflect
<span class="nb">ls </span>cmake
</code></pre></div></div>
<p>Now “nim” files can be added and deleted. They can be renamed and moved around.
As long as <code class="language-plaintext highlighter-rouge">mulle-sde reflect</code> is called afterwards, the changes will be picked
up and the Makefile will be up-to-date.</p>
<h2 id="a-nimmake-mulle-sde-extension">A nim/make mulle-sde extension</h2>
<p>Ideally one wants to be able to create a <em>nim</em>/<em>make</em> project like above
with a single command line, such as:</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>mulle-sde init <span class="nt">-d</span> nim-demo <span class="nt">-m</span> nim/nim-developer executable
</code></pre></div></div>
<p>For this a mulle-sde “meta” extension is needed. mulle-sde extensions use the
<a href="template.html">template</a> capabilities to create boilerplate projects for new
languages and build systems. There are several different extension types:</p>
<table>
<thead>
<tr>
<th>Extension</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code class="language-plaintext highlighter-rouge">extra</code></td>
<td>a project can have multiple “extra” extensions. Typical “extra” extensions are “sublime-text” or “vscode”, which add IDE support.</td>
</tr>
<tr>
<td><code class="language-plaintext highlighter-rouge">runtime</code></td>
<td>a project can have one “runtime” extension, which is programming language specific</td>
</tr>
<tr>
<td><code class="language-plaintext highlighter-rouge">oneshot</code></td>
<td>“oneshot” extensions are used by the “mulle-sde add” command to add files to a project.</td>
</tr>
<tr>
<td><code class="language-plaintext highlighter-rouge">buildtool</code></td>
<td>a project can have one “buildtool” extension, to support tools like “autconf” or “cmake”</td>
</tr>
<tr>
<td><code class="language-plaintext highlighter-rouge">meta</code></td>
<td>a project is initialized with a “meta” extension, which combines buildtool and runtime and extra extensions</td>
</tr>
</tbody>
</table>
<p>To support <em>make</em> a “buildtool” extension is needed. Both are combined by a “meta extension”. So
all in all lets create three extensions:</p>
<h3 id="create-the-runtime-extension">Create the runtime extension</h3>
<p>For the language <em>nim</em> a <em>runtime</em> extension will be used. The runtime
extension defines the <code class="language-plaintext highlighter-rouge">.nim</code> file extension and adds a default
“helloworld” source. Extensions are grouped by a “vendor”, so <code class="language-plaintext highlighter-rouge">VENDOR_NAME</code>
(any word you like) must be specified:</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>mulle-sde <span class="nt">-f</span> init <span class="nt">--no-post-init</span> <span class="nt">-d</span> nim <span class="nt">-DVENDOR_NAME</span><span class="o">=</span>me <span class="nt">-m</span> mulle-sde/extension-developer runtime
</code></pre></div></div>
<p>Define the language basics with:</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">cat</span> <span class="o">&lt;&lt;</span><span class="no">EOF</span><span class="sh"> &gt; nim/src/me/nim/language
# language;dialect;extensions
nim;;nim
</span><span class="no">EOF
</span></code></pre></div></div>
<p>Create the demo source file:</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">mkdir</span> <span class="nt">-p</span> nim/src/me/nim/project/executable/src
<span class="nb">cat</span> <span class="o">&lt;&lt;</span><span class="no">EOF</span><span class="sh"> &gt; nim/src/me/nim/project/executable/src/PROJECT_NAME.nim
echo "Hello World"
</span><span class="no">EOF
</span></code></pre></div></div>
<p>Add a tool declaration for <em>nim</em> to be used in restrictive environments:</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">cat</span> <span class="o">&lt;&lt;</span><span class="no">EOF</span><span class="sh"> &gt; nim/src/me/nim/tool
nim
</span><span class="no">EOF
</span></code></pre></div></div>
<p>That’s it.</p>
<h3 id="create-the-buildtool-extension">Create the buildtool extension</h3>
<p>The buildtool extension is used to setup the <code class="language-plaintext highlighter-rouge">Makefile</code> and the reflection
mechanism:</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>mulle-sde <span class="nt">-f</span> init <span class="nt">--no-post-init</span> <span class="nt">-d</span> nim-make <span class="nt">-DVENDOR_NAME</span><span class="o">=</span>me <span class="nt">-m</span> mulle-sde/extension-developer buildtool
</code></pre></div></div>
<p>Create the demo <code class="language-plaintext highlighter-rouge">Makefile</code>:</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">mkdir</span> <span class="nt">-p</span> nim-make/src/me/nim-make/project/all
<span class="nb">cat</span> <span class="o">&lt;&lt;</span><span class="no">EOF</span><span class="sh"> &gt; nim-make/src/me/nim-make/project/all/Makefile
.SUFFIXES: .&lt;|PROJECT_EXTENSION|&gt;
SOURCES=
include make/sources.make
OBJECTS=</span><span class="se">\$</span><span class="sh">(SOURCES:.&lt;|PROJECT_EXTENSION|&gt;=.o)
.&lt;|PROJECT_EXTENSION|&gt;.o:
nim -c -o </span><span class="se">\$</span><span class="sh">@ </span><span class="se">\$</span><span class="sh">&lt;
&lt;|PROJECT_NAME|&gt;: </span><span class="se">\$</span><span class="sh">(OBJECTS)
ld -o </span><span class="se">\$</span><span class="sh">@ </span><span class="se">\$</span><span class="sh">&lt;
</span><span class="no">EOF
</span></code></pre></div></div>
<p>Create the match pattern for <code class="language-plaintext highlighter-rouge">.nim</code> files:</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">mkdir</span> <span class="nt">-p</span> nim-make/src/me/nim-make/share/match/match.d
<span class="nb">cat</span> <span class="o">&lt;&lt;</span><span class="no">EOF</span><span class="sh"> &gt; nim-make/src/me/nim-make/share/match/match.d/20-sources--nim-sources
*.nim
</span><span class="no">EOF
</span></code></pre></div></div>
<p>Setup the callback for the reflection mechanism:</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">mkdir</span> <span class="nt">-p</span> nim-make/src/me/nim-make/share/monitor/bin
<span class="nb">cat</span> <span class="o">&lt;&lt;</span><span class="no">EOF</span><span class="sh"> &gt; nim-make/src/me/nim-make/share/monitor/bin/filesystem-callback
#! /bin/sh
echo "filesystem"
</span><span class="no">EOF
</span><span class="nb">chmod </span>755 nim-make/src/me/nim-make/share/monitor/bin/filesystem-callback
</code></pre></div></div>
<p>Create a task that produces the <code class="language-plaintext highlighter-rouge">make/sources.make</code> file:</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">mkdir</span> <span class="nt">-p</span> nim-make/src/me/nim-make/share/monitor/libexec
<span class="nb">cat</span> <span class="o">&lt;&lt;</span><span class="no">EOF</span><span class="sh"> &gt; nim-make/src/me/nim-make/share/monitor/libexec/filesystem-task.sh
#! /usr/bin/env mulle-bash
# shellcheck shell=bash
#
# This function will be called by mulle-monitor
#
filesystem_task_run()
{
log_entry "filesystem_task_run" "</span><span class="se">\$</span><span class="sh">@"
mkdir -p make
mulle-match list --format '%T += %f</span><span class="se">\n</span><span class="sh">' &gt; make/sources.make
}
#
# Convenience to test your script standalone
#
if [ -z "</span><span class="se">\$</span><span class="sh">{MULLE_MONITOR_TASK_LOAD}" ]
then
filesystem_task_run "</span><span class="se">\$</span><span class="sh">@"
fi
</span><span class="no">EOF
</span><span class="nb">chmod </span>755 nim-make/src/me/nim-make/share/monitor/libexec/filesystem-task.sh
</code></pre></div></div>
<p>Add the “filesystem” callback to the callbacks executed on reflect with an
environment setting:</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">cat</span> <span class="o">&lt;&lt;</span><span class="no">EOF</span><span class="sh"> &gt; nim-make/src/me/nim-make/environment
MULLE_SDE_REFLECT_CALLBACKS='</span><span class="k">${</span><span class="nv">MULLE_SDE_REFLECT_CALLBACKS</span><span class="k">}</span><span class="sh">:filesystem'
</span><span class="no">EOF
</span></code></pre></div></div>
<p>Add <em>make</em> to the list of tools for restrictive environments:</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">cat</span> <span class="o">&lt;&lt;</span><span class="no">EOF</span><span class="sh"> &gt; nim-make/src/me/nim-make/tool
make;optional
</span><span class="no">EOF
</span></code></pre></div></div>
<h3 id="create-the-meta-extension">Create the meta extension</h3>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>mulle-sde <span class="nt">-f</span> init <span class="nt">--no-post-init</span> <span class="nt">-d</span> nim-developer <span class="nt">-DVENDOR_NAME</span><span class="o">=</span>me <span class="nt">-m</span> mulle-sde/extension-developer meta
</code></pre></div></div>
<p>The meta extension ties the runtime and the buildtool together. And that’s
it:</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">cat</span> <span class="o">&lt;&lt;</span><span class="no">EOF</span><span class="sh"> &gt;&gt; nim-developer/src/me/nim-developer/inherit
me/nim;runtime
me/nim-make;buildtool
</span><span class="no">EOF
</span></code></pre></div></div>
<h3 id="test-the-meta-extension">Test the meta extension</h3>
<p>Add your (uninstalled) extensions to the mulle-sde extension search path.
Then pick the meta extension “nim-developer” by vendor “me” and create a
new “executable” project in directory “nim-demo2”:</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">MULLE_SDE_EXTENSION_PATH</span><span class="o">=</span><span class="s2">"</span><span class="nv">$PWD</span><span class="s2">/nim/src:</span><span class="se">\</span><span class="s2">
</span><span class="nv">$PWD</span><span class="s2">/nim-make/src:</span><span class="se">\</span><span class="s2">
</span><span class="nv">$PWD</span><span class="s2">/nim-developer/src:</span><span class="se">\</span><span class="s2">
</span><span class="k">${</span><span class="nv">MULLE_SDE_EXTENSION_PATH</span><span class="k">}</span><span class="s2">"</span> <span class="se">\</span>
mulle-sde init <span class="nt">-d</span> nim-demo2 <span class="nt">-m</span> me/nim-developer executable
mulle-sde <span class="nt">-d</span> nim-demo2 run make
</code></pre></div></div>
<blockquote>
<p>As <code class="language-plaintext highlighter-rouge">nim-demo2</code> is now a proper mulle-sde project of type
“executable”, the <code class="language-plaintext highlighter-rouge">-f</code> flag that was used pervasively on the
“none” project commands, can now be omitted.</p>
</blockquote>
<h2 id="final-words">Final Words</h2>
<p><a href="//github.com/mulle-sde/mulle-sde-developer">mulle-sde-developer</a> provides
extensive support for maintaining cmake projects. Language support is available
for C, C++, Objective-C.</p>
</content>
</entry>
<entry>
<title type="html"><![CDATA[🚬 Fetch and build]]></title>
<link rel="alternate" type="text/html" href="https://www.mulle-kybernetik.com/builder.html" />
<id>https://www.mulle-kybernetik.com/builder.html</id>
<published>2022-03-04T00:00:00+01:00</published>
<updated>2022-03-04T00:00:00+01:00</updated>
<author>
<name>Nat!</name>
<uri>https://www.mulle-kybernetik.com</uri>
</author>
<content type="html"><p>With <a href="compositor.html">project composition</a>
one can embed third party code directly into a project. But often a project
needs third party code, that builds separately, possibly with a different
build system (say <em>autoconf</em> instead of <em>cmake</em>). More often than not this
third party code is a github or gitlab repository, that needs to be downloaded
and built. It will typically be a library to link the project against and
one or more header files, which will be included in the project source code.</p>
<p>mulle-sde will fetch these dependencies and will build them
and install them into a local <code class="language-plaintext highlighter-rouge">dependency</code> folder. That way you have access
to the headers and libraries in a uniform way.</p>
<h2 id="quick-demo">Quick Demo</h2>
<h3 id="setup">Setup</h3>
<p>Mix and match a few dependencies:</p>
<table>
<thead>
<tr>
<th>Dependency</th>
<th>Build System</th>
<th>SCM</th>
<th>URL</th>
</tr>
</thead>
<tbody>
<tr>
<td>zlib library</td>
<td>cmake</td>
<td>git</td>
<td>https://github.com/madler/zlib.git</td>
</tr>
<tr>
<td>bison</td>
<td>autoconf</td>
<td>tar</td>
<td>https://ftp.halifax.rwth-aachen.de/gnu/bison/bison-3.8.2.tar.xz</td>
</tr>
<tr>
<td>mulle-data</td>
<td>mulle-sde</td>
<td>zip</td>
<td>https://github.com/mulle-c/mulle-data/archive/refs/tags/latest.zip</td>
</tr>
</tbody>
</table>
<p>For dependency building only the most barebones, unencumbered virtual
environment is needed to store a few settings. Lets create a new project
“my-demo”, to be filled with the main code later on:</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>mulle-sde init <span class="nt">-d</span> my-demo <span class="nt">--no-post-init</span> <span class="nt">-s</span> none/wild none
<span class="nb">cd </span>my-demo
</code></pre></div></div>
<p>Now add the first dependency, a git repository. Dependency order may be
important, but it isn’t in this case.</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>mulle-sde dependency add https://github.com/madler/zlib.git
</code></pre></div></div>
<p>From the URL, mulle-sde will try to figure out what it needs to do. Sometimes
more information needs to be given with additional command line options,
but not in this case.</p>
<p><img src="images/dependency-zlib.png" alt="Zlib" /></p>
<p>As this is a demo, we immediately hit the best case, which is that <em>zlib</em> is
a known dependency, that has some documentation! The documentation is provided
by the <a href="//github.com/craftinfo">craftinfo</a> repository.</p>
<blockquote>
<p>Clearly the vision of the craftinfo repository is, that millions of developer
work together in harmony on craftinfos, so that all possible
dependencies can be added without effort. It’s not quite there yet though.</p>
</blockquote>
<p>Anyway let’s use the suggestions and continue:</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>mulle-sde dependency <span class="nb">set </span>zlib aliases z
mulle-sde dependency <span class="nb">set </span>zlib include zlib.h
</code></pre></div></div>
<p>Now add the next dependency <em>bison</em>, which is a tar archive:</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>mulle-sde dependency add https://ftp.halifax.rwth-aachen.de/gnu/bison/bison-3.8.2.tar.xz
</code></pre></div></div>
<p>And add <em>mulle-data</em>, which is a mulle-sde project in a zip archive:</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>mulle-sde dependency add https://github.com/mulle-c/mulle-data/archive/refs/tags/latest.zip
</code></pre></div></div>
<p><img src="images/dependency-bison-data.png" alt="Zlib" /></p>
<h3 id="fetch-and-craft">Fetch and Craft</h3>
<p>If the URLs are wrong or stale in some way, the fetch might not work. Otherwise
there is no expectation of failure here:</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>mulle-sde fetch
</code></pre></div></div>
<p><img src="images/dependency-fetch.png" alt="Zlib" /></p>
<p>As mulle-data is a mulle-sde project, it can advertise its dependencies
(mulle-c11). So dependencies of true mulle-sde dependencies will be fetched
as well. Everything ends up in a directory named “stash”. The separate “fetch”
step is not really necessary, as the craft step will fetch what is needed. So
for demonstration let’s do it all over again:</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>mulle-sde clean tidy
mulle-sde craft craftorder
</code></pre></div></div>
<p><img src="images/dependency-craft.png" alt="Zlib" /></p>
<p>The contents of the <code class="language-plaintext highlighter-rouge">dependency/Debug</code> are analogous to the contents of
a <code class="language-plaintext highlighter-rouge">/usr/local</code> folder, but local to your project:</p>
<blockquote>
<p>Find the location of the <code class="language-plaintext highlighter-rouge">dependency</code> folder with <code class="language-plaintext highlighter-rouge">mulle-sde dependency-dir</code>,
if you can’t find it in your project.</p>
</blockquote>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ tree -L 3 dependency
dependency/
├── Debug
│ ├── bin
│ │ ├── bison
│ │ ├── mulle-fnv1a
│ │ └── yacc
│ ├── include
│ │ ├── mulle-c11
│ │ ├── mulle-data
│ │ ├── zconf.h
│ │ └── zlib.h
│ ├── lib
│ │ ├── libmulle-data.a
│ │ ├── liby.a
│ │ ├── libz.a
│ │ ├── libz.so -&gt; libz.so.1
│ │ ├── libz.so.1 -&gt; libz.so.1.2.13
│ │ └── libz.so.1.2.13
│ └── share
│ ├── aclocal
│ ├── bison
│ ├── doc
│ ├── info
│ ├── locale
│ ├── man
│ └── pkgconfig
└── etc
└── craftorder-Default--Default--Debug
</code></pre></div></div>
<p>You can get arguments for the linker command line from mulle-sde after a little
tweaking of the <em>bison</em> dependency. The produced libary by bison is called
‘liby.a’ and not the default ‘libbison.a’ as would be expected. This can
be corrected though:</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>mulle-sde dependency <span class="nb">set </span>bison aliases y
</code></pre></div></div>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">$ </span>mulle-sde linkorder
<span class="nt">-L</span><span class="s1">'/tmp/my-demo/dependency/Debug/lib'</span>
<span class="nt">-Wl</span>,--export-dynamic <span class="nt">-lz</span>
<span class="nt">-Wl</span>,--export-dynamic <span class="nt">-ly</span>
<span class="nt">-Wl</span>,--export-dynamic <span class="nt">-lmulle-data</span>
</code></pre></div></div>
<p>You can also get include source code for your source files from mulle-sde with.
Again <em>bison</em> is a bit weird, as it produces no header files. To avoid an
error in the next step, lets mark it as having no header:</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>mulle-sde dependency mark bison no-header
</code></pre></div></div>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">$ </span>mulle-sde headerorder
<span class="nt">-isystem</span> <span class="s1">'/tmp/my-demo/dependency/Debug/include'</span>
<span class="c">#include &lt;zlib.h&gt;</span>
<span class="c">#include &lt;mulle-data/mulle-data.h&gt;</span>
</code></pre></div></div>
<h2 id="final-words">Final Words</h2>
<p>The fetching of archives and git repositories is done with
<a href="//github.com/mulle-sde/mulle-fetch">mulle-fetch</a>.
<a href="//github.com/mulle-sde/mulle-domain">mulle-domain</a> provides heuristics based
on URLs. <a href="//github.com/mulle-sde/mulle-fetch">mulle-make</a> is used to build
the dependency.</p>
</content>
</entry>
<entry>
<title type="html"><![CDATA[🌲 Project Compositor]]></title>
<link rel="alternate" type="text/html" href="https://www.mulle-kybernetik.com/compositor.html" />
<id>https://www.mulle-kybernetik.com/compositor.html</id>
<published>2022-03-03T00:00:00+01:00</published>
<updated>2022-03-03T00:00:00+01:00</updated>
<author>
<name>Nat!</name>
<uri>https://www.mulle-kybernetik.com</uri>
</author>
<content type="html"><p>Project composition adds remote or local files (and directories) to
a project. The project, as stored in a source code management sytem like git,
would commonly <strong><em>not</em></strong> include these files. These files <em>would</em> typically be part
of your build process (Makefile) though. So after a checkout, you need to run the
project composition to complete the project complete.</p>
<h2 id="quick-demo">Quick Demo</h2>
<p>For project composition only the most barebones, unencumbered virtual
environment is needed to store a few settings. On the assumption, that we are
in the right place already, prepare the virtual environment:</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>mulle-sde init <span class="nt">--no-post-init</span> <span class="nt">-s</span> none/wild none
</code></pre></div></div>
<p>As mulle-sde will not be used for building, its most convenient to use the
<code class="language-plaintext highlighter-rouge">none/wild</code> environment style. This makes the virtual environment completely
unencumbered.</p>
<h3 id="add-a-license-file">Add a LICENSE file</h3>
<p>With the <code class="language-plaintext highlighter-rouge">dependency add --embedded</code> command a LICENSE file will be downloaded
from a remote source and placed into the project root at a later time:</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>mulle-sde dependency add <span class="nt">--embedded</span> <span class="se">\</span>
<span class="nt">--address</span> LICENSE <span class="se">\</span>
https://www.gnu.org/licenses/gpl-3.0.txt
</code></pre></div></div>
<blockquote>
<p>If there was a <code class="language-plaintext highlighter-rouge">gpl-latest.txt</code>, we would be up to date with the latest
GPL automatically.</p>
</blockquote>
<h3 id="add-some-source-code">Add some source code</h3>
<p>Add a small hash library from the “mulle-c” project and place it into <code class="language-plaintext highlighter-rouge">src</code>.</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>mulle-sde dependency add <span class="se">\</span>
<span class="nt">--embedded</span> <span class="se">\</span>
<span class="nt">--address</span> src/farmhash <span class="se">\</span>
https://github.com/mulle-c/farmhash-c/archive/refs/tags/latest.tar.gz
</code></pre></div></div>
<h3 id="run-the-composition">Run the composition</h3>
<p>With these dependency definitions in place, it’s now time to run
<code class="language-plaintext highlighter-rouge">mulle-sde fetch</code> to compose the project.</p>
<p><img src="images/composition-fetch.png" alt="" /></p>
<p>To get rid of the embedded files, use <code class="language-plaintext highlighter-rouge">mulle-sde clean tidy</code>. Project
composition is fairly powerful. You can add and remove embedded dependencies
and change their URLs at will. A new <code class="language-plaintext highlighter-rouge">mulle-sde fetch</code> will track the
changes and synchronize your project.</p>
<h2 id="final-words">Final Words</h2>
<p>If you don’t need any other functionality from mulle-sde, you can get project
composition from <a href="//github.com/mulle-sde/mulle-sourcetree">mulle-sourcetree</a>
only. You would not need to run <code class="language-plaintext highlighter-rouge">mulle-sde init</code> then.</p>
<p>The fetching of archives and git repositories is done with
<a href="//github.com/mulle-sde/mulle-fetch">mulle-fetch</a>. mulle-fetch relies on
heuristics to save typework. This will work fine in common cases, but needs
explicitness, when it fails. Nevertheless just having to type
<code class="language-plaintext highlighter-rouge">mulle-fetch --github mulle-c mulle-container</code> to fetch a repository or
<code class="language-plaintext highlighter-rouge">mulle-fetch https://github.com/mulle-c/mulle-buffer/archive/refs/tags/latest.tar.gz</code>
to download and unpack a github tar link is handy.</p>
</content>
</entry>