<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://test-devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Adding existing code to current VS code application</title><link>https://test-devzone.nordicsemi.com/f/nordic-q-a/88814/adding-existing-code-to-current-vs-code-application</link><description>This should be so easy, but it isn&amp;#39;t. I started with the Dev Academy Lesson 6 I2C example. I wired up a little board with an I2C eeprom, created an overlay file to map the I2C pins to other port pins and everything worked great. 
 Now I want to add an</description><dc:language>en-US</dc:language><generator>Telligent Community 13 Non-Production</generator><lastBuildDate>Mon, 13 Jun 2022 15:22:06 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://test-devzone.nordicsemi.com/f/nordic-q-a/88814/adding-existing-code-to-current-vs-code-application" /><item><title>RE: Adding existing code to current VS code application</title><link>https://test-devzone.nordicsemi.com/thread/372210?ContentTypeID=1</link><pubDate>Mon, 13 Jun 2022 15:22:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:96a35041-ed1a-4ed2-8995-aec4c14cf7be</guid><dc:creator>user2315</dc:creator><description>&lt;p&gt;The example in&amp;nbsp;&lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/v2.0.0/samples/bluetooth/throughput/CMakeLists.txt#L14-L18"&gt;https://github.com/nrfconnect/sdk-nrf/blob/v2.0.0/samples/bluetooth/throughput/CMakeLists.txt#L14-L18&lt;/a&gt;&amp;nbsp; did it!&lt;br /&gt;&lt;br /&gt;Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding existing code to current VS code application</title><link>https://test-devzone.nordicsemi.com/thread/371930?ContentTypeID=1</link><pubDate>Fri, 10 Jun 2022 13:57:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8606f96c-7fed-444b-b0db-bd00578d192d</guid><dc:creator>user72692</dc:creator><description>&lt;p&gt;&lt;strong&gt;UPDATE:&lt;/strong&gt; I noticed after submitting this answer, that the person replying was different from the person behind the initial post. But I think I&amp;nbsp;(and Wayne) have answered the questions from the initial post as well&lt;/p&gt;
&lt;hr /&gt;[quote user="flaik-wayne"]I also wonder how this is supposed to work. I added the file to CMakeLists.txt and it works. Not sure if there is some integrated way to do it.[/quote]
&lt;p&gt;Yes, you need to add the .c files to CMakeLists.txt. I&amp;#39;m not aware of any ways to do it through the GUI.&lt;/p&gt;
&lt;p&gt;A trick is to add the following to the CMakeLists.txt:&amp;nbsp;&lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/v2.0.0/samples/bluetooth/throughput/CMakeLists.txt#L14-L18"&gt;https://github.com/nrfconnect/sdk-nrf/blob/v2.0.0/samples/bluetooth/throughput/CMakeLists.txt#L14-L18&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Then all the .c files in src will automatically get included in the build.&lt;/p&gt;
[quote user="flaik-wayne"]I just watched some of the walkthrough videos - in video 3 &lt;a href="https://youtu.be/3yi6kuxgdPg"&gt;https://youtu.be/3yi6kuxgdPg&lt;/a&gt;&amp;nbsp;he mentions doing a pristine build if you have edited CMakeLists.txt or the application configuration files.[/quote]
&lt;p&gt;Actually, it seems like it is enough to run a normal build after editing CMakeLists. I tried modifying the CMakeList.txt and built the app and got this result:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;Building hello_world
west build --build-dir c:\v2.0.0\zephyr\samples\hello_world\build_53 c:\v2.0.0\zephyr\samples\hello_world

[0/1] Re-running CMake...
.
.
.
.
.&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;So it seems like the cmake changes are detected, and it will re-run cmake. I think the same applies if you modify Kconfigs (e.g. prj.conf) or the Device tree (.overlay files), the changes will be detected and cmake wil re-run.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;A&amp;nbsp;&lt;/span&gt;&lt;em&gt;pristine&lt;/em&gt;&lt;span&gt;&amp;nbsp;build directory is essentially a new build directory. All byproducts from previous builds have been removed. As mentioned &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.9.1/zephyr/guides/west/build-flash-debug.html#:~:text=a%20pristine%20build%20directory%20is%20essentially%20a%20new%20build%20directory.%20all%20byproducts%20from%20previous%20builds%20have%20been%20removed."&gt;here&lt;/a&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I don&amp;#39;t know exactly how west works in details and in what circumstances it wil re-run cmake or not, but I can ask internally if you would like&amp;nbsp;a more certain answer.&lt;/span&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;Learn more about west build/pristine builds here:&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.9.1/zephyr/guides/west/build-flash-debug.html#pristine-builds"&gt;https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.9.1/zephyr/guides/west/build-flash-debug.html#pristine-builds&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Take a look at the page below&amp;nbsp;to learn about the build and configuration phase:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.9.1/zephyr/guides/build/index.html"&gt;https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.9.1/zephyr/guides/build/index.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;In short the &lt;strong&gt;configuration&lt;/strong&gt;&amp;nbsp;&lt;strong&gt;phase&lt;/strong&gt; wil run cmake and go through the dts/dts/.overlay files, Kconfig files and generate the build system. The &lt;strong&gt;build phase&lt;/strong&gt; will run ninja (similar to make) and generate the .hex/.elf files. If you only modify .h/.c files, it is only the build phase that will run.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding existing code to current VS code application</title><link>https://test-devzone.nordicsemi.com/thread/371742?ContentTypeID=1</link><pubDate>Thu, 09 Jun 2022 23:13:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bc4c0ae7-1a8d-42ee-a9e0-88b0e7d76ef6</guid><dc:creator>user116756</dc:creator><description>&lt;p&gt;I just watched some of the walkthrough videos - in video 3 &lt;a href="https://youtu.be/3yi6kuxgdPg"&gt;https://youtu.be/3yi6kuxgdPg&lt;/a&gt;&amp;nbsp;he mentions doing a pristine build if you have edited CMakeLists.txt or the application configuration files.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding existing code to current VS code application</title><link>https://test-devzone.nordicsemi.com/thread/371741?ContentTypeID=1</link><pubDate>Thu, 09 Jun 2022 23:06:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ea920bea-1487-44c3-a656-a7e5bbccf986</guid><dc:creator>user116756</dc:creator><description>&lt;p&gt;I also wonder how this is supposed to work. I added the file to CMakeLists.txt and it works. Not sure if there is some integrated way to do it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>