Development tips: Difference between revisions
Jump to navigation
Jump to search
(3 intermediate revisions by the same user not shown) | |||
Line 13: | Line 13: | ||
:* At the very least, this means in the same repository. Ideally code and tests are updated together in the same commit. |
:* At the very least, this means in the same repository. Ideally code and tests are updated together in the same commit. |
||
* Make your startup / boot / init sequence independent of system configuration. Avoid early optimization. |
* Make your startup / boot / init sequence independent of system configuration. Avoid early optimization. |
||
== Reproducible build == |
|||
This section is dedicated to reproducible builds / build determinism / deterministic builds. |
|||
=== libraries / ar === |
|||
With libraries produced with <code>ar</code>, use option <code>D</code> to produce '''deterministic build'''. |
|||
<source lang="bash"> |
|||
ar rcsD mylib.a foo.o bar.o |
|||
</source> |
|||
Alternatively one can run <code>ranlib</code> in deterministic mode: |
|||
<source lang="bash"> |
|||
ranlib -D mylib.a |
|||
</source> |
|||
I also made a custom python script <code>ardee.py</code> (that also works on libraries produce by ARM toolchain <code>armar</code>, which doesn't have the <code>D</code> flag) |
|||
<source lang="bash"> |
|||
ardee.py mylib.a |
|||
</source> |
|||
=== clang === |
|||
See https://blog.llvm.org/2019/11/deterministic-builds-with-clang-and-lld.html . |
|||
Import flags include: |
|||
<source lang="text"> |
|||
CCFLAGS += -no-canonical-prefixes |
|||
CCFLAGS += -fdebug-compilation-dir . |
|||
sCFLAGS += -Wa,-fdebug-compilation-dir,. |
|||
SCFLAGS += -Wa,-fdebug-compilation-dir,. |
|||
</source> |
|||
== Good practices === |
|||
* [https://www.youtube.com/watch?v=z7w2lKG8zWM Felienne Hermans: How patterns in variable names can make code easier to read] |
|||
:* Avoid '''linguistic smells'''. |
|||
:: That is method or identifier that does more / less / reverse of what they say |
|||
:* Adopt '''name molds'''. |
|||
:: That is conventions on where to put quantifier, letter case... to increase the likelihood that developers pick the same variable names. |
|||
== Calendars == |
== Calendars == |
Latest revision as of 08:02, 23 May 2022
Summary of things I do frequently or that I learned the hard way
Console tips
- Search for whole words occurence:
ag "\bWHOLEWORD\b" # or
ag -w WHOLEWORD
Advices
- Always keep your tests in sync with your source code.
- At the very least, this means in the same repository. Ideally code and tests are updated together in the same commit.
- Make your startup / boot / init sequence independent of system configuration. Avoid early optimization.
Reproducible build
This section is dedicated to reproducible builds / build determinism / deterministic builds.
libraries / ar
With libraries produced with ar
, use option D
to produce deterministic build.
ar rcsD mylib.a foo.o bar.o
Alternatively one can run ranlib
in deterministic mode:
ranlib -D mylib.a
I also made a custom python script ardee.py
(that also works on libraries produce by ARM toolchain armar
, which doesn't have the D
flag)
ardee.py mylib.a
clang
See https://blog.llvm.org/2019/11/deterministic-builds-with-clang-and-lld.html .
Import flags include:
CCFLAGS += -no-canonical-prefixes
CCFLAGS += -fdebug-compilation-dir .
sCFLAGS += -Wa,-fdebug-compilation-dir,.
SCFLAGS += -Wa,-fdebug-compilation-dir,.
Good practices =
- Avoid linguistic smells.
- That is method or identifier that does more / less / reverse of what they say
- Adopt name molds.
- That is conventions on where to put quantifier, letter case... to increase the likelihood that developers pick the same variable names.
Calendars
Use ICU libraries that deal with all subtleties!