build/snippets/using.html · build/snippets/using.rst 공식 원문 ↗

Zephyr 3.7.0 · Build · Snippets

Snippet 사용법

Snippet 이름을 west나 CMake에 전달하고 application 요구 사항으로 고정합니다.

Official pathbuild/snippets/using.html
Source filebuild/snippets/using.rst
Source versionZephyr 3.7.0
TranslationFull · reviewed

본문 기준: Zephyr 3.7.0 LTS3 · 이후 유지보수 패치는 별도입니다.

Part 1

요약·해설

-S, SNIPPET variable, CMakeLists.txt cache 설정을 실제 명령으로 보존했습니다.

West

-S

Multiple

-S 반복

CMake

SNIPPET

Required

CMakeLists.txt

Part 2

접을 수 있는 영어 원문 전체

영어 원문 전체 펼치기
원문 SHA-256 082205C599C78A3772EF1F285D56F7B0119B93D6E02922E27B9575990004832E
.. _using-snippets:

Using Snippets
##############

.. tip::

   See :ref:`built-in-snippets` for a list of snippets that are provided by
   Zephyr.

Snippets have names. You use snippets by giving their names to the build
system.

With west build
***************

To use a snippet named ``foo`` when building an application ``app``:

.. code-block:: console

   west build -S foo app

To use multiple snippets:

.. code-block:: console

   west build -S snippet1 -S snippet2 [...] app

With cmake
**********

If you are running CMake directly instead of using ``west build``, use the
``SNIPPET`` variable. This is a whitespace- or semicolon-separated list of
snippet names you want to use. For example:

.. code-block:: console

   cmake -Sapp -Bbuild -DSNIPPET="snippet1;snippet2" [...]
   cmake --build build

Application required snippets
*****************************

If an application should always be compiled with a given snippet, it
can be added to that application's ``CMakeLists.txt`` file. For example:

.. code-block:: cmake

   if(NOT snippet1 IN_LIST SNIPPET)
     set(SNIPPET snippet1 ${SNIPPET} CACHE STRING "" FORCE)
   endif()

   find_package(Zephyr ....)

Part 3

한국어 전문 번역

Snippet 사용

Snippet에는 이름이 있으며 build system에 그 이름을 전달해 사용합니다. Zephyr가 제공하는 목록은 built-in snippet 문서에서 확인할 수 있습니다.

west build에서 사용

app application을 build할 때 이름이 foo인 snippet을 사용합니다.

west build -S foo app

여러 snippet은 -S option을 반복합니다.

west build -S snippet1 -S snippet2 [...] app

CMake에서 사용

west build 대신 CMake를 직접 실행한다면 SNIPPET variable을 사용합니다. 공백 또는 semicolon으로 구분한 snippet 이름 목록입니다.

cmake -Sapp -Bbuild -DSNIPPET="snippet1;snippet2" [...]
cmake --build build

Application이 항상 요구하는 snippet

Application을 항상 특정 snippet과 compile해야 한다면 application의 CMakeLists.txt에 추가합니다.

if(NOT snippet1 IN_LIST SNIPPET)
  set(SNIPPET snippet1 ${SNIPPET} CACHE STRING "" FORCE)
endif()

find_package(Zephyr ....)

이미 목록에 없을 때만 snippet1을 cache variable 앞에 추가하고, 그 뒤 find_package(Zephyr ...)를 호출합니다.

Source

출처

영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.