Anthony DiGirolamo | 701489b | 2023-08-24 01:01:42 +0000 | [diff] [blame] | 1 | .. _docs-root: |
| 2 | |
Armando Montanez | ae93bc4 | 2023-09-07 17:13:57 +0000 | [diff] [blame] | 3 | ====================== |
| 4 | Pigweed Sample Project |
| 5 | ====================== |
| 6 | |
Anthony DiGirolamo | 701489b | 2023-08-24 01:01:42 +0000 | [diff] [blame] | 7 | .. toctree:: |
Anthony DiGirolamo | 1682d53 | 2024-05-14 17:45:29 +0000 | [diff] [blame] | 8 | :maxdepth: 1 |
| 9 | :hidden: |
Anthony DiGirolamo | 701489b | 2023-08-24 01:01:42 +0000 | [diff] [blame] | 10 | |
Anthony DiGirolamo | 1682d53 | 2024-05-14 17:45:29 +0000 | [diff] [blame] | 11 | Home <self> |
| 12 | Examples <examples/docs> |
| 13 | Customization <customization> |
| 14 | Pigweed Docs <https://pigweed.dev> |
| 15 | Mailing List <https://groups.google.com/forum/#!forum/pigweed> |
| 16 | Chat Room <https://discord.gg/M9NSeTA> |
| 17 | Source Code <https://cs.pigweed.dev/pigweed> |
| 18 | Code Reviews <https://pigweed-review.googlesource.com> |
| 19 | Issue Tracker <https://issues.pigweed.dev/issues?q=status:open> |
Anthony DiGirolamo | 701489b | 2023-08-24 01:01:42 +0000 | [diff] [blame] | 20 | |
Armando Montanez | ae93bc4 | 2023-09-07 17:13:57 +0000 | [diff] [blame] | 21 | This repository outlines the recommended way of using Pigweed in a new or |
| 22 | existing project. Feel free to fork this repository, or read it as a reference. |
Anthony DiGirolamo | 701489b | 2023-08-24 01:01:42 +0000 | [diff] [blame] | 23 | |
| 24 | For more information see the `Pigweed Getting started |
| 25 | guide <https://pigweed.dev/docs/getting_started.html>`__. |
| 26 | |
| 27 | Check back for more complex examples and features coming soon! |
| 28 | |
Armando Montanez | ae93bc4 | 2023-09-07 17:13:57 +0000 | [diff] [blame] | 29 | --------------- |
| 30 | Getting started |
| 31 | --------------- |
| 32 | Make sure you've set up `Pigweed's |
| 33 | prerequisites <https://pigweed.dev/docs/getting_started.html#prerequisites>`__. |
Armando Montanez | 6011ab4 | 2023-09-22 00:08:02 +0000 | [diff] [blame] | 34 | |
| 35 | **If you're on Windows**, you can automate the initial setup by downloading the |
| 36 | first-time setup script **from cmd.exe**: |
| 37 | |
| 38 | .. code-block:: batch |
| 39 | |
Armando Montanez | 3532297 | 2023-09-22 21:45:55 +0000 | [diff] [blame] | 40 | curl https://pigweed.googlesource.com/pigweed/sample_project/+/main/tools/setup_windows_prerequisites.bat?format=TEXT > setup_pigweed_prerequisites.b64 && certutil -decode -f setup_pigweed_prerequisites.b64 setup_pigweed_prerequisites.bat && del setup_pigweed_prerequisites.b64 |
Armando Montanez | 6011ab4 | 2023-09-22 00:08:02 +0000 | [diff] [blame] | 41 | |
| 42 | Then you can run the script with the following command **in cmd.exe**: |
| 43 | |
| 44 | .. code-block:: batch |
| 45 | |
| 46 | setup_pigweed_prerequisites.bat |
| 47 | |
| 48 | .. note:: |
| 49 | |
| 50 | You may see a few UAC prompts as the script installs Git, Python, and |
| 51 | enables developer mode. |
| 52 | |
Armando Montanez | e969e17 | 2023-09-20 22:55:01 +0000 | [diff] [blame] | 53 | Once that is done, you can clone this project with the following command: |
Anthony DiGirolamo | 701489b | 2023-08-24 01:01:42 +0000 | [diff] [blame] | 54 | |
Armando Montanez | ae93bc4 | 2023-09-07 17:13:57 +0000 | [diff] [blame] | 55 | .. code-block:: bash |
Anthony DiGirolamo | 701489b | 2023-08-24 01:01:42 +0000 | [diff] [blame] | 56 | |
Armando Montanez | e969e17 | 2023-09-20 22:55:01 +0000 | [diff] [blame] | 57 | git clone https://pigweed.googlesource.com/pigweed/sample_project |
Anthony DiGirolamo | 701489b | 2023-08-24 01:01:42 +0000 | [diff] [blame] | 58 | |
Armando Montanez | ae93bc4 | 2023-09-07 17:13:57 +0000 | [diff] [blame] | 59 | Environment setup |
| 60 | ================= |
| 61 | Pigweed uses a local development environment for most of its tools. This |
| 62 | means tools are not installed to your machine, and are instead stored in a |
| 63 | directory inside your project (Note: git ignores this directory). The tools |
| 64 | are temporarily added to the PATH of the current shell session. |
Anthony DiGirolamo | 701489b | 2023-08-24 01:01:42 +0000 | [diff] [blame] | 65 | |
Armando Montanez | ae93bc4 | 2023-09-07 17:13:57 +0000 | [diff] [blame] | 66 | To make sure the latest tooling has been fetched and set up, run the bootstrap |
| 67 | command for your operating system: |
Anthony DiGirolamo | 701489b | 2023-08-24 01:01:42 +0000 | [diff] [blame] | 68 | |
Armando Montanez | b34ab3c | 2024-01-02 21:03:13 +0000 | [diff] [blame] | 69 | .. tab-set:: |
Anthony DiGirolamo | 701489b | 2023-08-24 01:01:42 +0000 | [diff] [blame] | 70 | |
Armando Montanez | b34ab3c | 2024-01-02 21:03:13 +0000 | [diff] [blame] | 71 | .. tab-item:: Linux |
| 72 | :sync: linux |
Anthony DiGirolamo | 701489b | 2023-08-24 01:01:42 +0000 | [diff] [blame] | 73 | |
Armando Montanez | b34ab3c | 2024-01-02 21:03:13 +0000 | [diff] [blame] | 74 | .. code-block:: bash |
Anthony DiGirolamo | 701489b | 2023-08-24 01:01:42 +0000 | [diff] [blame] | 75 | |
Armando Montanez | b34ab3c | 2024-01-02 21:03:13 +0000 | [diff] [blame] | 76 | source ./bootstrap.sh |
Anthony DiGirolamo | 701489b | 2023-08-24 01:01:42 +0000 | [diff] [blame] | 77 | |
Armando Montanez | b34ab3c | 2024-01-02 21:03:13 +0000 | [diff] [blame] | 78 | .. tab-item:: macOS |
| 79 | :sync: macos |
Anthony DiGirolamo | 701489b | 2023-08-24 01:01:42 +0000 | [diff] [blame] | 80 | |
Armando Montanez | b34ab3c | 2024-01-02 21:03:13 +0000 | [diff] [blame] | 81 | .. code-block:: bash |
| 82 | |
| 83 | source ./bootstrap.sh |
| 84 | |
| 85 | .. tab-item:: Windows |
| 86 | :sync: windows |
| 87 | |
| 88 | .. code-block:: batch |
| 89 | |
| 90 | bootstrap.bat |
Anthony DiGirolamo | 701489b | 2023-08-24 01:01:42 +0000 | [diff] [blame] | 91 | |
Armando Montanez | ae93bc4 | 2023-09-07 17:13:57 +0000 | [diff] [blame] | 92 | After tooling updates, you might need to run bootstrap again to ensure the |
| 93 | latest tools. |
Anthony DiGirolamo | 701489b | 2023-08-24 01:01:42 +0000 | [diff] [blame] | 94 | |
Armando Montanez | ae93bc4 | 2023-09-07 17:13:57 +0000 | [diff] [blame] | 95 | After the initial bootstrap, you can use use the ``activate`` scripts to |
| 96 | configure the current shell for development without doing a full update. |
Anthony DiGirolamo | 701489b | 2023-08-24 01:01:42 +0000 | [diff] [blame] | 97 | |
Armando Montanez | b34ab3c | 2024-01-02 21:03:13 +0000 | [diff] [blame] | 98 | .. tab-set:: |
Anthony DiGirolamo | 701489b | 2023-08-24 01:01:42 +0000 | [diff] [blame] | 99 | |
Armando Montanez | b34ab3c | 2024-01-02 21:03:13 +0000 | [diff] [blame] | 100 | .. tab-item:: Linux |
| 101 | :sync: linux |
Anthony DiGirolamo | 701489b | 2023-08-24 01:01:42 +0000 | [diff] [blame] | 102 | |
Armando Montanez | b34ab3c | 2024-01-02 21:03:13 +0000 | [diff] [blame] | 103 | .. code-block:: bash |
Anthony DiGirolamo | 701489b | 2023-08-24 01:01:42 +0000 | [diff] [blame] | 104 | |
Armando Montanez | b34ab3c | 2024-01-02 21:03:13 +0000 | [diff] [blame] | 105 | source ./activate.sh |
Anthony DiGirolamo | 701489b | 2023-08-24 01:01:42 +0000 | [diff] [blame] | 106 | |
Armando Montanez | b34ab3c | 2024-01-02 21:03:13 +0000 | [diff] [blame] | 107 | .. tab-item:: macOS |
| 108 | :sync: macos |
Anthony DiGirolamo | 701489b | 2023-08-24 01:01:42 +0000 | [diff] [blame] | 109 | |
Armando Montanez | b34ab3c | 2024-01-02 21:03:13 +0000 | [diff] [blame] | 110 | .. code-block:: bash |
| 111 | |
| 112 | source ./activate.sh |
| 113 | |
| 114 | .. tab-item:: Windows |
| 115 | :sync: windows |
| 116 | |
| 117 | .. code-block:: batch |
| 118 | |
| 119 | activate.bat |
Anthony DiGirolamo | 701489b | 2023-08-24 01:01:42 +0000 | [diff] [blame] | 120 | |
Armando Montanez | ae93bc4 | 2023-09-07 17:13:57 +0000 | [diff] [blame] | 121 | .. _docs-building: |
Anthony DiGirolamo | 701489b | 2023-08-24 01:01:42 +0000 | [diff] [blame] | 122 | |
| 123 | Building |
Armando Montanez | ae93bc4 | 2023-09-07 17:13:57 +0000 | [diff] [blame] | 124 | ======== |
| 125 | All of these commands must be run from inside an activated developer |
| 126 | environment. See `Environment setup <#environment-setup>`__ |
Anthony DiGirolamo | 701489b | 2023-08-24 01:01:42 +0000 | [diff] [blame] | 127 | |
Armando Montanez | ae93bc4 | 2023-09-07 17:13:57 +0000 | [diff] [blame] | 128 | One-shot build |
| 129 | -------------- |
| 130 | To build the project, documentation, and tests, run the following command in |
| 131 | an activated environment: |
Anthony DiGirolamo | 701489b | 2023-08-24 01:01:42 +0000 | [diff] [blame] | 132 | |
Armando Montanez | ae93bc4 | 2023-09-07 17:13:57 +0000 | [diff] [blame] | 133 | .. code-block:: bash |
Anthony DiGirolamo | 701489b | 2023-08-24 01:01:42 +0000 | [diff] [blame] | 134 | |
Armando Montanez | 89344ce | 2023-09-07 21:33:21 +0000 | [diff] [blame] | 135 | pw build |
Anthony DiGirolamo | 701489b | 2023-08-24 01:01:42 +0000 | [diff] [blame] | 136 | |
Armando Montanez | ae93bc4 | 2023-09-07 17:13:57 +0000 | [diff] [blame] | 137 | Automatically build on file save |
| 138 | -------------------------------- |
| 139 | Alternatively, if you'd like an automatic rebuild to trigger whenever you save |
| 140 | changes to files, use ``pw watch``: |
Anthony DiGirolamo | 701489b | 2023-08-24 01:01:42 +0000 | [diff] [blame] | 141 | |
Armando Montanez | ae93bc4 | 2023-09-07 17:13:57 +0000 | [diff] [blame] | 142 | .. code-block:: bash |
Anthony DiGirolamo | 701489b | 2023-08-24 01:01:42 +0000 | [diff] [blame] | 143 | |
Armando Montanez | ae93bc4 | 2023-09-07 17:13:57 +0000 | [diff] [blame] | 144 | pw watch |
Anthony DiGirolamo | 701489b | 2023-08-24 01:01:42 +0000 | [diff] [blame] | 145 | |
Armando Montanez | ae93bc4 | 2023-09-07 17:13:57 +0000 | [diff] [blame] | 146 | ---------------- |
| 147 | Typical workflow |
| 148 | ---------------- |
| 149 | When you pull latest repository changes, run bootstrap: |
Anthony DiGirolamo | 701489b | 2023-08-24 01:01:42 +0000 | [diff] [blame] | 150 | |
Armando Montanez | b34ab3c | 2024-01-02 21:03:13 +0000 | [diff] [blame] | 151 | .. tab-set:: |
Anthony DiGirolamo | 701489b | 2023-08-24 01:01:42 +0000 | [diff] [blame] | 152 | |
Armando Montanez | b34ab3c | 2024-01-02 21:03:13 +0000 | [diff] [blame] | 153 | .. tab-item:: Linux |
| 154 | :sync: linux |
| 155 | |
| 156 | .. code-block:: bash |
| 157 | |
| 158 | source ./bootstrap.sh |
| 159 | |
| 160 | .. tab-item:: macOS |
| 161 | :sync: macos |
| 162 | |
| 163 | .. code-block:: bash |
| 164 | |
| 165 | source ./bootstrap.sh |
| 166 | |
| 167 | .. tab-item:: Windows |
| 168 | :sync: windows |
| 169 | |
| 170 | .. code-block:: batch |
| 171 | |
| 172 | bootstrap.bat |
Anthony DiGirolamo | 701489b | 2023-08-24 01:01:42 +0000 | [diff] [blame] | 173 | |
Armando Montanez | ae93bc4 | 2023-09-07 17:13:57 +0000 | [diff] [blame] | 174 | If you're just launching a new shell session, you can activate instead: |
Anthony DiGirolamo | 701489b | 2023-08-24 01:01:42 +0000 | [diff] [blame] | 175 | |
Armando Montanez | b34ab3c | 2024-01-02 21:03:13 +0000 | [diff] [blame] | 176 | .. tab-set:: |
Anthony DiGirolamo | 701489b | 2023-08-24 01:01:42 +0000 | [diff] [blame] | 177 | |
Armando Montanez | b34ab3c | 2024-01-02 21:03:13 +0000 | [diff] [blame] | 178 | .. tab-item:: Linux |
| 179 | :sync: linux |
| 180 | |
| 181 | .. code-block:: bash |
| 182 | |
| 183 | source ./activate.sh |
| 184 | |
| 185 | .. tab-item:: macOS |
| 186 | :sync: macos |
| 187 | |
| 188 | .. code-block:: bash |
| 189 | |
| 190 | source ./activate.sh |
| 191 | |
| 192 | .. tab-item:: Windows |
| 193 | :sync: windows |
| 194 | |
| 195 | .. code-block:: batch |
| 196 | |
| 197 | activate.bat |
Anthony DiGirolamo | 701489b | 2023-08-24 01:01:42 +0000 | [diff] [blame] | 198 | |
Armando Montanez | ae93bc4 | 2023-09-07 17:13:57 +0000 | [diff] [blame] | 199 | and rebuild with: |
Anthony DiGirolamo | 701489b | 2023-08-24 01:01:42 +0000 | [diff] [blame] | 200 | |
Armando Montanez | ae93bc4 | 2023-09-07 17:13:57 +0000 | [diff] [blame] | 201 | .. code-block:: bash |
Anthony DiGirolamo | 701489b | 2023-08-24 01:01:42 +0000 | [diff] [blame] | 202 | |
Armando Montanez | 89344ce | 2023-09-07 21:33:21 +0000 | [diff] [blame] | 203 | pw build |
Anthony DiGirolamo | 701489b | 2023-08-24 01:01:42 +0000 | [diff] [blame] | 204 | |
Armando Montanez | ae93bc4 | 2023-09-07 17:13:57 +0000 | [diff] [blame] | 205 | ---------------------- |
| 206 | More info and Examples |
| 207 | ---------------------- |
| 208 | Check out some introductory examples :ref:`here <examples-root>`! |