Part 1
요약·해설
운영체제별 일회성·영구 설정, zephyrrc loading, zephyr-env script, BOARD·ZEPHYR_BASE·toolchain path 등 주요 변수를 설명합니다.
Once · Startup · zephyrrc
zephyr-env.sh · .cmd
Build · SDK · PATH
Part 2
접을 수 있는 영어 원문 전체
영어 원문 전체 펼치기
11593DBBEC169460B2391F956A20F0ED077DB48083B6155CEC7AB92DE1158625
.. _env_vars:
Environment Variables
=====================
Various pages in this documentation refer to setting Zephyr-specific
environment variables. This page describes how.
Setting Variables
*****************
Option 1: Just Once
-------------------
To set the environment variable ``MY_VARIABLE`` to ``foo`` for the
lifetime of your current terminal window:
.. tabs::
.. group-tab:: Linux/macOS
.. code-block:: console
export MY_VARIABLE=foo
.. group-tab:: Windows
.. code-block:: console
set MY_VARIABLE=foo
.. warning::
This is best for experimentation. If you close your terminal window, use
another terminal window or tab, restart your computer, etc., this setting
will be lost forever.
Using options 2 or 3 is recommended if you want to keep using the setting.
Option 2: In all Terminals
--------------------------
.. tabs::
.. group-tab:: Linux/macOS
Add the ``export MY_VARIABLE=foo`` line to your shell's startup script in
your home directory. For Bash, this is usually :file:`~/.bashrc` on Linux
or :file:`~/.bash_profile` on macOS. Changes in these startup scripts
don't affect shell instances already started; try opening a new terminal
window to get the new settings.
.. group-tab:: Windows
You can use the ``setx`` program in ``cmd.exe`` or the third-party RapidEE
program.
To use ``setx``, type this command, then close the terminal window. Any
new ``cmd.exe`` windows will have ``MY_VARIABLE`` set to ``foo``.
.. code-block:: console
setx MY_VARIABLE foo
To install RapidEE, a freeware graphical environment variable editor,
`using Chocolatey`_ in an Administrator command prompt:
.. code-block:: console
choco install rapidee
You can then run ``rapidee`` from your terminal to launch the program and set
environment variables. Make sure to use the "User" environment variables area
-- otherwise, you have to run RapidEE as administrator. Also make sure to save
your changes by clicking the Save button at top left before exiting. Settings
you make in RapidEE will be available whenever you open a new terminal window.
.. _env_vars_zephyrrc:
Option 3: Using ``zephyrrc`` files
----------------------------------
Choose this option if you don't want to make the variable's setting available
to all of your terminals, but still want to save the value for loading into
your environment when you are using Zephyr.
.. tabs::
.. group-tab:: Linux/macOS
Create a file named :file:`~/.zephyrrc` if it doesn't exist, then add this
line to it:
.. code-block:: console
export MY_VARIABLE=foo
To get this value back into your current terminal environment, **you must
run** ``source zephyr-env.sh`` from the main ``zephyr`` repository. Among
other things, this script sources :file:`~/.zephyrrc`.
The value will be lost if you close the window, etc.; run ``source
zephyr-env.sh`` again to get it back.
.. group-tab:: Windows
Add the line ``set MY_VARIABLE=foo`` to the file
:file:`%userprofile%\\zephyrrc.cmd` using a text editor such as Notepad to
save the value.
To get this value back into your current terminal environment, **you must
run** ``zephyr-env.cmd`` in a ``cmd.exe`` window after changing directory
to the main ``zephyr`` repository. Among other things, this script runs
:file:`%userprofile%\\zephyrrc.cmd`.
The value will be lost if you close the window, etc.; run
``zephyr-env.cmd`` again to get it back.
These scripts:
- set :envvar:`ZEPHYR_BASE` to the location of the zephyr repository
- adds some Zephyr-specific locations (such as zephyr's :file:`scripts`
directory) to your :envvar:`PATH` environment variable
- loads any settings from the ``zephyrrc`` files described above in
:ref:`env_vars_zephyrrc`.
You can thus use them any time you need any of these settings.
.. _zephyr-env:
Zephyr Environment Scripts
**************************
You can use the zephyr repository scripts ``zephyr-env.sh`` (for macOS and
Linux) and ``zephyr-env.cmd`` (for Windows) to load Zephyr-specific settings
into your current terminal's environment. To do so, run this command from the
zephyr repository:
.. tabs::
.. group-tab:: Linux/macOS
.. code-block:: console
source zephyr-env.sh
.. group-tab:: Windows
.. code-block:: console
zephyr-env.cmd
These scripts:
- set :envvar:`ZEPHYR_BASE` to the location of the zephyr repository
- adds some Zephyr-specific locations (such as zephyr's :file:`scripts`
directory) to your ``PATH`` environment variable
- loads any settings from the ``zephyrrc`` files described above in
:ref:`env_vars_zephyrrc`.
You can thus use them any time you need any of these settings.
.. _env_vars_important:
Important Environment Variables
*******************************
Some :ref:`important-build-vars` can also be set in the environment. Here
is a description of some of these important environment variables. This is not
a comprehensive list.
.. envvar:: BOARD
See :ref:`important-build-vars`.
.. envvar:: CONF_FILE
See :ref:`important-build-vars`.
.. envvar:: SHIELD
See :ref:`shields`.
.. envvar:: ZEPHYR_BASE
See :ref:`important-build-vars`.
.. envvar:: EXTRA_ZEPHYR_MODULES
See :ref:`important-build-vars`.
.. envvar:: ZEPHYR_MODULES
See :ref:`important-build-vars`.
.. envvar:: ZEPHYR_BOARD_ALIASES
See :ref:`gs-board-aliases`
The following additional environment variables are significant when configuring
the :ref:`toolchain <gs_toolchain>` used to build Zephyr applications.
.. envvar:: ZEPHYR_SDK_INSTALL_DIR
Path where Zephyr SDK is installed.
.. envvar:: ZEPHYR_TOOLCHAIN_VARIANT
The name of the toolchain to use.
.. envvar:: {TOOLCHAIN}_TOOLCHAIN_PATH
Path to the toolchain specified by :envvar:`ZEPHYR_TOOLCHAIN_VARIANT`. For
example, if ``ZEPHYR_TOOLCHAIN_VARIANT=llvm``, use ``LLVM_TOOLCHAIN_PATH``.
(Note the capitalization when forming the environment variable name.)
You might need to update some of these variables when you
:ref:`update the Zephyr SDK toolchain <gs_toolchain_update>`.
Emulators and boards may also depend on additional programs. The build system
will try to locate those programs automatically, but may rely on additional
CMake or environment variables to do so. Please consult your emulator's or
board's documentation for more information. The following environment variables
may be useful in such situations:
.. envvar:: PATH
``PATH`` is an environment variable used on Unix-like or Microsoft Windows
operating systems to specify a set of directories where executable programs
are located.
.. _using Chocolatey: https://chocolatey.org/packages/RapidEE
Part 3
한국어 전문 번역
환경 변수
이 문서의 여러 페이지는 Zephyr 전용 환경 변수를 설정하라고 안내합니다. 이 페이지는 환경 변수를 설정하고 유지하는 방법을 설명합니다.
변수 설정
방법 1: 현재 terminal에서 한 번만
MY_VARIABLE 환경 변수를 현재 terminal window가 살아 있는 동안 foo로 설정하려면 운영체제에 맞는 command를 사용합니다.
Linux/macOS:
export MY_VARIABLE=fooWindows:
set MY_VARIABLE=foo방법 2: 모든 terminal에서
Linux/macOS에서는 home directory에 있는 shell startup script에 export MY_VARIABLE=foo를 추가합니다. Bash에서는 보통 Linux의 ~/.bashrc, macOS의 ~/.bash_profile입니다. 이미 실행 중인 shell에는 startup script 변경이 적용되지 않으므로 새 terminal window를 여십시오.
Windows에서는 cmd.exe의 setx program 또는 third-party RapidEE를 사용할 수 있습니다.
setx를 사용하려면 다음 command를 실행하고 terminal window를 닫습니다. 이후 새로 여는 cmd.exe window에는 MY_VARIABLE=foo가 적용됩니다.
setx MY_VARIABLE fooFreeware graphical environment variable editor인 RapidEE는 Administrator command prompt에서 Chocolatey로 설치할 수 있습니다.
choco install rapideerapidee를 실행해 program을 열고 환경 변수를 설정합니다. Administrator로 실행하지 않으려면 반드시 User 환경 변수 영역을 사용하십시오. 종료 전 왼쪽 위 Save button을 눌러 변경을 저장해야 합니다. RapidEE 설정은 새 terminal window를 열 때마다 사용할 수 있습니다.
방법 3: zephyrrc file 사용
변수 설정을 모든 terminal에 노출하고 싶지는 않지만 Zephyr 작업 때 environment로 불러올 값을 저장하고 싶다면 이 방법을 선택합니다.
Linux/macOS에서는 ~/.zephyrrc가 없으면 만들고 다음 줄을 추가합니다.
export MY_VARIABLE=foo이 값을 현재 terminal environment로 가져오려면 main zephyr repository에서 반드시 source zephyr-env.sh를 실행해야 합니다. 이 script는 여러 작업과 함께 ~/.zephyrrc를 source합니다. Window를 닫으면 값이 사라지므로 다시 필요할 때 source zephyr-env.sh를 실행합니다.
Windows에서는 Notepad 같은 text editor로 %userprofile%\zephyrrc.cmd에 set MY_VARIABLE=foo를 추가해 값을 저장합니다. 이 값을 현재 environment로 가져오려면 main zephyr repository로 이동한 뒤 cmd.exe에서 반드시 zephyr-env.cmd를 실행해야 합니다. 이 script는 %userprofile%\zephyrrc.cmd도 실행합니다. Window를 닫으면 값이 사라지므로 다시 zephyr-env.cmd를 실행해야 합니다.
이 script들은 다음 작업을 수행합니다.
ZEPHYR_BASE를 zephyr repository 위치로 설정합니다.- Zephyr의
scriptsdirectory 같은 Zephyr 전용 위치를PATH환경 변수에 추가합니다. - 앞에서 설명한 zephyrrc file의 설정을 불러옵니다.
따라서 이런 설정 중 하나라도 필요할 때 이 script를 사용할 수 있습니다.
Zephyr environment script
Zephyr repository의 zephyr-env.sh(macOS·Linux)와 zephyr-env.cmd(Windows)는 Zephyr 전용 설정을 현재 terminal environment로 불러옵니다. Zephyr repository에서 다음 command를 실행합니다.
Linux/macOS:
source zephyr-env.shWindows:
zephyr-env.cmd이 script들은 다음 작업을 수행합니다.
ZEPHYR_BASE를 zephyr repository 위치로 설정합니다.- Zephyr의
scriptsdirectory 같은 Zephyr 전용 위치를PATH환경 변수에 추가합니다. - 앞에서 설명한 zephyrrc file의 설정을 불러옵니다.
따라서 이런 설정이 필요할 때마다 script를 사용할 수 있습니다.
중요 환경 변수
중요 build variable 중 일부는 environment에서도 설정할 수 있습니다. 다음은 주요 환경 변수에 대한 설명이며 전체 목록은 아닙니다.
BOARDApplication build의 target board를 선택합니다. 중요한 build variable 설명을 참고하십시오.
CONF_FILEApplication Kconfig fragment를 지정합니다. 중요한 build variable 설명을 참고하십시오.
SHIELDShield를 선택합니다.
ZEPHYR_BASE사용할 Zephyr repository base 위치입니다. 중요한 build variable 설명을 참고하십시오.
EXTRA_ZEPHYR_MODULES추가 Zephyr module을 지정합니다. 중요한 build variable 설명을 참고하십시오.
ZEPHYR_MODULESBuild에 사용할 Zephyr module 집합을 지정합니다. 중요한 build variable 설명을 참고하십시오.
ZEPHYR_BOARD_ALIASESBoard alias 정의 file을 지정합니다.
다음 변수는 Zephyr application을 build하는 toolchain 구성에 중요합니다.
ZEPHYR_SDK_INSTALL_DIRZephyr SDK가 설치된 path입니다.
ZEPHYR_TOOLCHAIN_VARIANT사용할 toolchain 이름입니다.
{TOOLCHAIN}_TOOLCHAIN_PATHZEPHYR_TOOLCHAIN_VARIANT가 지정한 toolchain의 path입니다. 예를 들어ZEPHYR_TOOLCHAIN_VARIANT=llvm이면LLVM_TOOLCHAIN_PATH를 사용합니다. 환경 변수 이름을 만들 때 대문자 표기에 유의하십시오.
Zephyr SDK toolchain을 갱신할 때 이 변수 중 일부를 바꿔야 할 수 있습니다.
Emulator와 board는 추가 program에 의존할 수 있습니다. Build system은 이를 자동으로 찾으려 하지만 추가 CMake variable이나 환경 변수에 의존할 수도 있습니다. Emulator 또는 board 문서를 확인하십시오.
PATHUnix 계열 또는 Microsoft Windows 운영체제에서 executable program이 있는 directory 집합을 지정하는 환경 변수입니다.
Source
출처
영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.