<h3>Contribution description</h3>
<p>Depending on the PROGRAMMER used, the file used for flashing may be<br>
different, like openocd/jlink, so the file being generated when<br>
compiling should be different.</p>
<p>Because of this, when building in docker, the build system needs to know<br>
for which programmer you are building for.</p>
<p>This manifested for 'nordic_softdevice' applications when using 'openocd'<br>
but is not limited to this case.</p>
<h3>Testing procedure</h3>
<p>Try flashing 'tests/nordic_softdevice' for 'nrf52dk' when usingĀ 'PROGRAMMER=openocd' and 'BUILD_IN_DOCKER=1' this must be done in a clean directory.</p>
<p>You do not need a board to even test.</p>
<pre><code>BUILD_IN_DOCKER=1 DOCKER="sudo docker" PROGRAMMER=openocd RIOT_CI_BUILD=1 make --no-print-directory -C tests/nordic_softdevice/ clean flash
</code></pre>
<details><summary>Output with this PR</summary>
<p>Note I tested without a board connected!</p>
<pre><code>BUILD_IN_DOCKER=1 DOCKER="sudo docker" PROGRAMMER=openocd RIOT_CI_BUILD=1 make --no-print-directory -C tests/nordic_softdevice/ clean flash
rm -rf /home/harter/work/git/RIOT/tests/nordic_softdevice/bin/pkg/nrf52dk/nordic_softdevice_ble/src/
Launching build container using image "riot/riotbuild:latest".
sudo docker run --rm -t -u "$(id -u)" \
    -v '/usr/share/zoneinfo/Europe/Berlin:/etc/localtime:ro' -v '/home/harter/work/git/RIOT:/data/riotbuild/riotbase' -e 'RIOTBASE=/data/riotbuild/riotbase' -e 'CCACHE_BASEDIR=/data/riotbuild/riotbase' -e 'BUILD_DIR=/data/riotbuild/riotbase/build' -e 'RIOTPROJECT=/data/riotbuild/riotbase' -e 'RIOTCPU=/data/riotbuild/riotbase/cpu' -e 'RIOTBOARD=/data/riotbuild/riotbase/boards' -e 'RIOTMAKE=/data/riotbuild/riotbase/makefiles' -v /home/harter/.gitcache:/data/riotbuild/gitcache -e GIT_CACHE_DIR=/data/riotbuild/gitcache   \
    -e 'PROGRAMMER=openocd' -e 'RIOT_CI_BUILD=1' \
    -w '/data/riotbuild/riotbase/tests/nordic_softdevice/' \
    'riot/riotbuild:latest' make
[sudo] password for harter:
Building application "tests_nordic_softdevice" for "nrf52dk" with MCU "nrf52".

rm -rf /data/riotbuild/riotbase/tests/nordic_softdevice/bin/pkg/nrf52dk/nordic_softdevice_ble/src
mkdir -p /data/riotbuild/riotbase/tests/nordic_softdevice/bin/pkg/nrf52dk/nordic_softdevice_ble/src
rm /data/riotbuild/riotbase/tests/nordic_softdevice/bin/pkg/nrf52dk/nordic_softdevice_ble/src/components/ble/common/ble_conn_params.c
cat /data/riotbuild/riotbase/pkg/nordic_softdevice_ble/Makefile.module > /data/riotbuild/riotbase/tests/nordic_softdevice/bin/pkg/nrf52dk/nordic_softdevice_ble/src/components/softdevice/common/softdevice_handler/Makefile
echo "MODULE=ble_common" > /data/riotbuild/riotbase/tests/nordic_softdevice/bin/pkg/nrf52dk/nordic_softdevice_ble/src/components/ble/common/Makefile
cat /data/riotbuild/riotbase/pkg/nordic_softdevice_ble/Makefile.module >> /data/riotbuild/riotbase/tests/nordic_softdevice/bin/pkg/nrf52dk/nordic_softdevice_ble/src/components/ble/common/Makefile
cat /data/riotbuild/riotbase/pkg/nordic_softdevice_ble/Makefile.module > /data/riotbuild/riotbase/tests/nordic_softdevice/bin/pkg/nrf52dk/nordic_softdevice_ble/src/components/iot/ble_ipsp/Makefile
touch /data/riotbuild/riotbase/tests/nordic_softdevice/bin/pkg/nrf52dk/nordic_softdevice_ble/src/.extracted
cp /data/riotbuild/riotbase/tests/nordic_softdevice/bin/pkg/nrf52dk/nordic_softdevice_ble/src/components/iot/ble_6lowpan/lib/ble_6lowpan.a /data/riotbuild/riotbase/tests/nordic_softdevice/bin/nrf52dk/ble_6lowpan.a
   text    data     bss     dec     hex filename
  55764     512   28716   84992   14c00 /data/riotbuild/riotbase/tests/nordic_softdevice/bin/nrf52dk/tests_nordic_softdevice.elf
/home/harter/work/git/RIOT/dist/tools/openocd/openocd.sh flash /home/harter/work/git/RIOT/tests/nordic_softdevice/bin/nrf52dk/tests_nordic_softdevice.hex
### Flashing Target ###
GNU MCU Eclipse 64-bit Open On-Chip Debugger 0.10.0+dev-00462-gdd1d90111 (2019-01-18-11:37)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
adapter speed: 1000 kHz
cortex_m reset_config sysresetreq
Error: No J-Link device found.

/home/harter/work/git/RIOT/tests/nordic_softdevice/../../Makefile.include:556: recipe for target 'flash' failed

</code></pre>
</details>
<details><summary>Failed output with master</summary>
<pre><code>BUILD_IN_DOCKER=1 DOCKER="sudo docker" PROGRAMMER=openocd RIOT_CI_BUILD=1 make --no-print-directory -C tests/nordic_softdevice/ clean flash
rm -rf /home/harter/work/git/worktree/riot_master/tests/nordic_softdevice/bin/pkg/nrf52dk/nordic_softdevice_ble/src/
Launching build container using image "riot/riotbuild:latest".
sudo docker run --rm -t -u "$(id -u)" \
    -v '/usr/share/zoneinfo/Europe/Berlin:/etc/localtime:ro' -v '/home/harter/work/git/worktree/riot_master:/data/riotbuild/riotbase' -e 'RIOTBASE=/data/riotbuild/riotbase' -e 'CCACHE_BASEDIR=/data/riotbuild/riotbase' -e 'BUILD_DIR=/data/riotbuild/riotbase/build' -e 'RIOTPROJECT=/data/riotbuild/riotbase' -e 'RIOTCPU=/data/riotbuild/riotbase/cpu' -e 'RIOTBOARD=/data/riotbuild/riotbase/boards' -e 'RIOTMAKE=/data/riotbuild/riotbase/makefiles' -v /home/harter/.gitcache:/data/riotbuild/gitcache -e GIT_CACHE_DIR=/data/riotbuild/gitcache  -v /home/harter/work/git/RIOT/.git:/home/harter/work/git/RIOT/.git \
    -e 'RIOT_CI_BUILD=1' \
    -w '/data/riotbuild/riotbase/tests/nordic_softdevice/' \
    'riot/riotbuild:latest' make
Building application "tests_nordic_softdevice" for "nrf52dk" with MCU "nrf52".

rm -rf /data/riotbuild/riotbase/tests/nordic_softdevice/bin/pkg/nrf52dk/nordic_softdevice_ble/src
mkdir -p /data/riotbuild/riotbase/tests/nordic_softdevice/bin/pkg/nrf52dk/nordic_softdevice_ble/src
rm /data/riotbuild/riotbase/tests/nordic_softdevice/bin/pkg/nrf52dk/nordic_softdevice_ble/src/components/ble/common/ble_conn_params.c
cat /data/riotbuild/riotbase/pkg/nordic_softdevice_ble/Makefile.module > /data/riotbuild/riotbase/tests/nordic_softdevice/bin/pkg/nrf52dk/nordic_softdevice_ble/src/components/softdevice/common/softdevice_handler/Makefile
echo "MODULE=ble_common" > /data/riotbuild/riotbase/tests/nordic_softdevice/bin/pkg/nrf52dk/nordic_softdevice_ble/src/components/ble/common/Makefile
cat /data/riotbuild/riotbase/pkg/nordic_softdevice_ble/Makefile.module >> /data/riotbuild/riotbase/tests/nordic_softdevice/bin/pkg/nrf52dk/nordic_softdevice_ble/src/components/ble/common/Makefile
cat /data/riotbuild/riotbase/pkg/nordic_softdevice_ble/Makefile.module > /data/riotbuild/riotbase/tests/nordic_softdevice/bin/pkg/nrf52dk/nordic_softdevice_ble/src/components/iot/ble_ipsp/Makefile
touch /data/riotbuild/riotbase/tests/nordic_softdevice/bin/pkg/nrf52dk/nordic_softdevice_ble/src/.extracted
cp /data/riotbuild/riotbase/tests/nordic_softdevice/bin/pkg/nrf52dk/nordic_softdevice_ble/src/components/iot/ble_6lowpan/lib/ble_6lowpan.a /data/riotbuild/riotbase/tests/nordic_softdevice/bin/nrf52dk/ble_6lowpan.a
   text    data     bss     dec     hex filename
  55764     512   28716   84992   14c00 /data/riotbuild/riotbase/tests/nordic_softdevice/bin/nrf52dk/tests_nordic_softdevice.elf
/home/harter/work/git/worktree/riot_master/dist/tools/openocd/openocd.sh flash /home/harter/work/git/worktree/riot_master/tests/nordic_softdevice/bin/nrf52dk/tests_nordic_softdevice.hex
### Flashing Target ###
Error: Unable to locate IMAGE_FILE
       (/home/harter/work/git/worktree/riot_master/tests/nordic_softdevice/bin/nrf52dk/tests_nordic_softdevice.hex)
/home/harter/work/git/worktree/riot_master/tests/nordic_softdevice/../../Makefile.include:556: recipe for target 'flash' failed
make: *** [flash] Error 1
</code></pre>
</details>
<p>The test currently fails on my board, but this will be another issue.<br>
<code>examples/default</code> works though.</p>
<h3>Issues/PRs references</h3>
<p>This issue was found after testing <a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="438773294" data-permission-text="Issue title is private" data-url="https://github.com/RIOT-OS/RIOT/issues/11470" data-hovercard-type="pull_request" data-hovercard-url="/RIOT-OS/RIOT/pull/11470/hovercard" href="https://github.com/RIOT-OS/RIOT/pull/11470">#11470</a> with building in docker.</p>

<hr>

<h4>You can view, comment on, or merge this pull request online at:</h4>
<p>  <a href='https://github.com/RIOT-OS/RIOT/pull/12207'>https://github.com/RIOT-OS/RIOT/pull/12207</a></p>

<h4>Commit Summary</h4>
<ul>
  <li>makefiles/docker.inc.mk: add PROGRAMMER to the exported variables</li>
</ul>

<h4>File Changes</h4>
<ul>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/12207/files#diff-0">makefiles/docker.inc.mk</a>
    (1)
  </li>
</ul>

<h4>Patch Links:</h4>
<ul>
  <li><a href='https://github.com/RIOT-OS/RIOT/pull/12207.patch'>https://github.com/RIOT-OS/RIOT/pull/12207.patch</a></li>
  <li><a href='https://github.com/RIOT-OS/RIOT/pull/12207.diff'>https://github.com/RIOT-OS/RIOT/pull/12207.diff</a></li>
</ul>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/RIOT-OS/RIOT/pull/12207?email_source=notifications&email_token=ABE7WYF33EP4IPG45W32ME3QJITWDA5CNFSM4IWCX2CKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HK62ONQ">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABE7WYHQQT47A4K6NGESNDLQJITWDANCNFSM4IWCX2CA">mute the thread</a>.<img src="https://github.com/notifications/beacon/ABE7WYDTVUWYJGDR3O6S2X3QJITWDA5CNFSM4IWCX2CKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HK62ONQ.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/RIOT-OS/RIOT/pull/12207?email_source=notifications\u0026email_token=ABE7WYF33EP4IPG45W32ME3QJITWDA5CNFSM4IWCX2CKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HK62ONQ",
"url": "https://github.com/RIOT-OS/RIOT/pull/12207?email_source=notifications\u0026email_token=ABE7WYF33EP4IPG45W32ME3QJITWDA5CNFSM4IWCX2CKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HK62ONQ",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>