Carlos Chinchilla | 07c95b8 | 2020-08-20 13:50:09 -0700 | [diff] [blame] | 1 | # Pigweed Sample Project |
| 2 | |
Anthony DiGirolamo | 675afb0 | 2020-10-27 09:44:35 -0700 | [diff] [blame] | 3 | [TOC] |
| 4 | |
Carlos Chinchilla | 07c95b8 | 2020-08-20 13:50:09 -0700 | [diff] [blame] | 5 | This repository outlines the recommended way of using Pigweed in a new or |
| 6 | existing project. Feel free to fork this repository, or read it as a reference. |
| 7 | |
Anthony DiGirolamo | bd881c0 | 2020-10-08 18:23:41 -0700 | [diff] [blame] | 8 | For more information see the [Pigweed Getting started |
Rob Mohr | f2234c7 | 2021-05-24 10:52:38 -0700 | [diff] [blame] | 9 | guide](https://pigweed.dev/docs/getting_started.html). |
Carlos Chinchilla | 07c95b8 | 2020-08-20 13:50:09 -0700 | [diff] [blame] | 10 | |
| 11 | Check back for more complex examples and features coming soon! |
| 12 | |
Armando Montanez | ae93bc4 | 2023-09-07 17:13:57 +0000 | [diff] [blame] | 13 | ## Getting started |
Anthony DiGirolamo | bd881c0 | 2020-10-08 18:23:41 -0700 | [diff] [blame] | 14 | |
Armando Montanez | ae93bc4 | 2023-09-07 17:13:57 +0000 | [diff] [blame] | 15 | Make sure you've set up [Pigweed's |
| 16 | prerequisites](https://pigweed.dev/docs/getting_started.html#prerequisites). |
Armando Montanez | 6011ab4 | 2023-09-22 00:08:02 +0000 | [diff] [blame] | 17 | |
| 18 | **If you're on Windows**, you can automate the initial setup by downloading the |
| 19 | first-time setup script **from cmd.exe**: |
| 20 | |
| 21 | ```bat |
Armando Montanez | 3532297 | 2023-09-22 21:45:55 +0000 | [diff] [blame] | 22 | 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] | 23 | ``` |
| 24 | |
| 25 | Then you can run the script with the following command **in cmd.exe**: |
| 26 | |
| 27 | ```bat |
| 28 | setup_pigweed_prerequisites.bat |
| 29 | ``` |
| 30 | |
| 31 | Note: You may see a few UAC prompts as the script installs Git, Python, and |
| 32 | enables developer mode. |
| 33 | |
Armando Montanez | e969e17 | 2023-09-20 22:55:01 +0000 | [diff] [blame] | 34 | Once that is done, you can clone this project with the following command: |
Anthony DiGirolamo | 675afb0 | 2020-10-27 09:44:35 -0700 | [diff] [blame] | 35 | |
| 36 | ```sh |
Armando Montanez | 3a471c3 | 2023-09-15 19:51:35 +0000 | [diff] [blame] | 37 | git clone https://pigweed.googlesource.com/pigweed/sample_project |
Anthony DiGirolamo | 675afb0 | 2020-10-27 09:44:35 -0700 | [diff] [blame] | 38 | ``` |
| 39 | |
Armando Montanez | ae93bc4 | 2023-09-07 17:13:57 +0000 | [diff] [blame] | 40 | ### Environment setup |
Anthony DiGirolamo | bd881c0 | 2020-10-08 18:23:41 -0700 | [diff] [blame] | 41 | |
Armando Montanez | ae93bc4 | 2023-09-07 17:13:57 +0000 | [diff] [blame] | 42 | Pigweed uses a local development environment for most of its tools. This |
| 43 | means tools are not installed to your machine, and are instead stored in a |
| 44 | directory inside your project (Note: git ignores this directory). The tools |
| 45 | are temporarily added to the PATH of the current shell session. |
| 46 | |
| 47 | To make sure the latest tooling has been fetched and set up, run the bootstrap |
| 48 | command for your operating system: |
Carlos Chinchilla | 5b83e82 | 2020-08-20 14:12:16 -0700 | [diff] [blame] | 49 | |
Anthony DiGirolamo | 675afb0 | 2020-10-27 09:44:35 -0700 | [diff] [blame] | 50 | **Windows** |
| 51 | |
Armando Montanez | ae93bc4 | 2023-09-07 17:13:57 +0000 | [diff] [blame] | 52 | ```bat |
Anthony DiGirolamo | 675afb0 | 2020-10-27 09:44:35 -0700 | [diff] [blame] | 53 | bootstrap.bat |
| 54 | ``` |
| 55 | |
| 56 | **Linux & Mac** |
| 57 | |
| 58 | ```sh |
Armando Montanez | e969e17 | 2023-09-20 22:55:01 +0000 | [diff] [blame] | 59 | source ./bootstrap.sh |
Anthony DiGirolamo | 675afb0 | 2020-10-27 09:44:35 -0700 | [diff] [blame] | 60 | ``` |
| 61 | |
Armando Montanez | ae93bc4 | 2023-09-07 17:13:57 +0000 | [diff] [blame] | 62 | After tooling updates, you might need to run bootstrap again to ensure the |
| 63 | latest tools. |
Anthony DiGirolamo | 675afb0 | 2020-10-27 09:44:35 -0700 | [diff] [blame] | 64 | |
Armando Montanez | ae93bc4 | 2023-09-07 17:13:57 +0000 | [diff] [blame] | 65 | After the initial bootstrap, you can use use the `activate` scripts to configure |
| 66 | the current shell for development without doing a full update. |
Anthony DiGirolamo | 675afb0 | 2020-10-27 09:44:35 -0700 | [diff] [blame] | 67 | |
| 68 | **Windows** |
| 69 | |
| 70 | ```sh |
| 71 | activate.bat |
| 72 | ``` |
| 73 | |
| 74 | **Linux & Mac** |
| 75 | |
| 76 | ```sh |
Armando Montanez | e969e17 | 2023-09-20 22:55:01 +0000 | [diff] [blame] | 77 | source ./activate.sh |
Anthony DiGirolamo | 675afb0 | 2020-10-27 09:44:35 -0700 | [diff] [blame] | 78 | ``` |
Carlos Chinchilla | 5b83e82 | 2020-08-20 14:12:16 -0700 | [diff] [blame] | 79 | |
Armando Montanez | ae93bc4 | 2023-09-07 17:13:57 +0000 | [diff] [blame] | 80 | ### Building |
Anthony DiGirolamo | bd881c0 | 2020-10-08 18:23:41 -0700 | [diff] [blame] | 81 | |
Armando Montanez | ae93bc4 | 2023-09-07 17:13:57 +0000 | [diff] [blame] | 82 | All of these commands must be run from inside an activated developer |
| 83 | environment. See [Environment setup](#environment-setup) |
Carlos Chinchilla | 641439b | 2020-08-20 15:46:40 -0700 | [diff] [blame] | 84 | |
Armando Montanez | ae93bc4 | 2023-09-07 17:13:57 +0000 | [diff] [blame] | 85 | #### One-shot build |
Carlos Chinchilla | d78999a | 2020-09-10 09:51:48 -0700 | [diff] [blame] | 86 | |
Armando Montanez | ae93bc4 | 2023-09-07 17:13:57 +0000 | [diff] [blame] | 87 | To build the project, documentation, and tests, run the following command in |
| 88 | an activated environment: |
Anthony DiGirolamo | bd881c0 | 2020-10-08 18:23:41 -0700 | [diff] [blame] | 89 | |
| 90 | ```sh |
Armando Montanez | 89344ce | 2023-09-07 21:33:21 +0000 | [diff] [blame] | 91 | pw build |
Carlos Chinchilla | 038a188 | 2020-09-23 11:19:24 -0700 | [diff] [blame] | 92 | ``` |
Carlos Chinchilla | 104afd6 | 2020-09-25 16:45:29 -0700 | [diff] [blame] | 93 | |
Armando Montanez | ae93bc4 | 2023-09-07 17:13:57 +0000 | [diff] [blame] | 94 | #### Automatically build on file save |
Anthony DiGirolamo | 28ec3ef | 2020-11-05 18:04:03 -0800 | [diff] [blame] | 95 | |
Armando Montanez | ae93bc4 | 2023-09-07 17:13:57 +0000 | [diff] [blame] | 96 | Alternatively, if you'd like an automatic rebuild to trigger whenever you save |
| 97 | changes to files, use `pw watch`: |
Anthony DiGirolamo | 28ec3ef | 2020-11-05 18:04:03 -0800 | [diff] [blame] | 98 | |
| 99 | ```sh |
Armando Montanez | ae93bc4 | 2023-09-07 17:13:57 +0000 | [diff] [blame] | 100 | pw watch |
Anthony DiGirolamo | 28ec3ef | 2020-11-05 18:04:03 -0800 | [diff] [blame] | 101 | ``` |
| 102 | |
Armando Montanez | ae93bc4 | 2023-09-07 17:13:57 +0000 | [diff] [blame] | 103 | ## Typical workflow |
Anthony DiGirolamo | 89e1c16 | 2020-10-12 19:11:40 -0700 | [diff] [blame] | 104 | |
Armando Montanez | ae93bc4 | 2023-09-07 17:13:57 +0000 | [diff] [blame] | 105 | When you pull latest repository changes, run bootstrap: |
Anthony DiGirolamo | 89e1c16 | 2020-10-12 19:11:40 -0700 | [diff] [blame] | 106 | ```sh |
Armando Montanez | e969e17 | 2023-09-20 22:55:01 +0000 | [diff] [blame] | 107 | source ./bootstrap.sh |
Anthony DiGirolamo | 89e1c16 | 2020-10-12 19:11:40 -0700 | [diff] [blame] | 108 | ``` |
| 109 | |
Armando Montanez | ae93bc4 | 2023-09-07 17:13:57 +0000 | [diff] [blame] | 110 | If you're just launching a new shell session, you can activate instead: |
Anthony DiGirolamo | bd881c0 | 2020-10-08 18:23:41 -0700 | [diff] [blame] | 111 | ```sh |
Armando Montanez | e969e17 | 2023-09-20 22:55:01 +0000 | [diff] [blame] | 112 | source ./activate.sh |
Anthony DiGirolamo | bd881c0 | 2020-10-08 18:23:41 -0700 | [diff] [blame] | 113 | ``` |
| 114 | |
Armando Montanez | ae93bc4 | 2023-09-07 17:13:57 +0000 | [diff] [blame] | 115 | and rebuild with: |
Anthony DiGirolamo | bd881c0 | 2020-10-08 18:23:41 -0700 | [diff] [blame] | 116 | ```sh |
Armando Montanez | 89344ce | 2023-09-07 21:33:21 +0000 | [diff] [blame] | 117 | pw build |
Anthony DiGirolamo | bd881c0 | 2020-10-08 18:23:41 -0700 | [diff] [blame] | 118 | ``` |
Carlos Chinchilla | 5a8ef41 | 2020-09-29 15:14:08 -0700 | [diff] [blame] | 119 | |
Armando Montanez | ae93bc4 | 2023-09-07 17:13:57 +0000 | [diff] [blame] | 120 | ## More info and Examples |
Anthony DiGirolamo | bd881c0 | 2020-10-08 18:23:41 -0700 | [diff] [blame] | 121 | |
Armando Montanez | ae93bc4 | 2023-09-07 17:13:57 +0000 | [diff] [blame] | 122 | Extended documentation and examples are built along code changes. You can view |
Armando Montanez | c1a9a32 | 2023-09-21 17:02:09 +0000 | [diff] [blame] | 123 | them at `out/gn/docs/gen/docs/html/index.html`. |