blob: 61be4334a0ba027b0eddd3efd0a211d06872a5a0 [file] [log] [blame] [view]
Carlos Chinchilla07c95b82020-08-20 13:50:09 -07001# Pigweed Sample Project
2
Anthony DiGirolamo675afb02020-10-27 09:44:35 -07003[TOC]
4
Carlos Chinchilla07c95b82020-08-20 13:50:09 -07005This repository outlines the recommended way of using Pigweed in a new or
6existing project. Feel free to fork this repository, or read it as a reference.
7
Anthony DiGirolamobd881c02020-10-08 18:23:41 -07008For more information see the [Pigweed Getting started
Rob Mohrf2234c72021-05-24 10:52:38 -07009guide](https://pigweed.dev/docs/getting_started.html).
Carlos Chinchilla07c95b82020-08-20 13:50:09 -070010
11Check back for more complex examples and features coming soon!
12
Armando Montanezae93bc42023-09-07 17:13:57 +000013## Getting started
Anthony DiGirolamobd881c02020-10-08 18:23:41 -070014
Armando Montanezae93bc42023-09-07 17:13:57 +000015Make sure you've set up [Pigweed's
16prerequisites](https://pigweed.dev/docs/getting_started.html#prerequisites).
Armando Montanez6011ab42023-09-22 00:08:02 +000017
18**If you're on Windows**, you can automate the initial setup by downloading the
19first-time setup script **from cmd.exe**:
20
21```bat
Armando Montanez35322972023-09-22 21:45:55 +000022curl 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 Montanez6011ab42023-09-22 00:08:02 +000023```
24
25Then you can run the script with the following command **in cmd.exe**:
26
27```bat
28setup_pigweed_prerequisites.bat
29```
30
31Note: You may see a few UAC prompts as the script installs Git, Python, and
32enables developer mode.
33
Armando Montaneze969e172023-09-20 22:55:01 +000034Once that is done, you can clone this project with the following command:
Anthony DiGirolamo675afb02020-10-27 09:44:35 -070035
36```sh
Armando Montanez3a471c32023-09-15 19:51:35 +000037git clone https://pigweed.googlesource.com/pigweed/sample_project
Anthony DiGirolamo675afb02020-10-27 09:44:35 -070038```
39
Armando Montanezae93bc42023-09-07 17:13:57 +000040### Environment setup
Anthony DiGirolamobd881c02020-10-08 18:23:41 -070041
Armando Montanezae93bc42023-09-07 17:13:57 +000042Pigweed uses a local development environment for most of its tools. This
43means tools are not installed to your machine, and are instead stored in a
44directory inside your project (Note: git ignores this directory). The tools
45are temporarily added to the PATH of the current shell session.
46
47To make sure the latest tooling has been fetched and set up, run the bootstrap
48command for your operating system:
Carlos Chinchilla5b83e822020-08-20 14:12:16 -070049
Anthony DiGirolamo675afb02020-10-27 09:44:35 -070050**Windows**
51
Armando Montanezae93bc42023-09-07 17:13:57 +000052```bat
Anthony DiGirolamo675afb02020-10-27 09:44:35 -070053bootstrap.bat
54```
55
56**Linux & Mac**
57
58```sh
Armando Montaneze969e172023-09-20 22:55:01 +000059source ./bootstrap.sh
Anthony DiGirolamo675afb02020-10-27 09:44:35 -070060```
61
Armando Montanezae93bc42023-09-07 17:13:57 +000062After tooling updates, you might need to run bootstrap again to ensure the
63latest tools.
Anthony DiGirolamo675afb02020-10-27 09:44:35 -070064
Armando Montanezae93bc42023-09-07 17:13:57 +000065After the initial bootstrap, you can use use the `activate` scripts to configure
66the current shell for development without doing a full update.
Anthony DiGirolamo675afb02020-10-27 09:44:35 -070067
68**Windows**
69
70```sh
71activate.bat
72```
73
74**Linux & Mac**
75
76```sh
Armando Montaneze969e172023-09-20 22:55:01 +000077source ./activate.sh
Anthony DiGirolamo675afb02020-10-27 09:44:35 -070078```
Carlos Chinchilla5b83e822020-08-20 14:12:16 -070079
Armando Montanezae93bc42023-09-07 17:13:57 +000080### Building
Anthony DiGirolamobd881c02020-10-08 18:23:41 -070081
Armando Montanezae93bc42023-09-07 17:13:57 +000082All of these commands must be run from inside an activated developer
83environment. See [Environment setup](#environment-setup)
Carlos Chinchilla641439b2020-08-20 15:46:40 -070084
Armando Montanezae93bc42023-09-07 17:13:57 +000085#### One-shot build
Carlos Chinchillad78999a2020-09-10 09:51:48 -070086
Armando Montanezae93bc42023-09-07 17:13:57 +000087To build the project, documentation, and tests, run the following command in
88an activated environment:
Anthony DiGirolamobd881c02020-10-08 18:23:41 -070089
90```sh
Armando Montanez89344ce2023-09-07 21:33:21 +000091pw build
Carlos Chinchilla038a1882020-09-23 11:19:24 -070092```
Carlos Chinchilla104afd62020-09-25 16:45:29 -070093
Armando Montanezae93bc42023-09-07 17:13:57 +000094#### Automatically build on file save
Anthony DiGirolamo28ec3ef2020-11-05 18:04:03 -080095
Armando Montanezae93bc42023-09-07 17:13:57 +000096Alternatively, if you'd like an automatic rebuild to trigger whenever you save
97changes to files, use `pw watch`:
Anthony DiGirolamo28ec3ef2020-11-05 18:04:03 -080098
99```sh
Armando Montanezae93bc42023-09-07 17:13:57 +0000100pw watch
Anthony DiGirolamo28ec3ef2020-11-05 18:04:03 -0800101```
102
Armando Montanezae93bc42023-09-07 17:13:57 +0000103## Typical workflow
Anthony DiGirolamo89e1c162020-10-12 19:11:40 -0700104
Armando Montanezae93bc42023-09-07 17:13:57 +0000105When you pull latest repository changes, run bootstrap:
Anthony DiGirolamo89e1c162020-10-12 19:11:40 -0700106```sh
Armando Montaneze969e172023-09-20 22:55:01 +0000107source ./bootstrap.sh
Anthony DiGirolamo89e1c162020-10-12 19:11:40 -0700108```
109
Armando Montanezae93bc42023-09-07 17:13:57 +0000110If you're just launching a new shell session, you can activate instead:
Anthony DiGirolamobd881c02020-10-08 18:23:41 -0700111```sh
Armando Montaneze969e172023-09-20 22:55:01 +0000112source ./activate.sh
Anthony DiGirolamobd881c02020-10-08 18:23:41 -0700113```
114
Armando Montanezae93bc42023-09-07 17:13:57 +0000115and rebuild with:
Anthony DiGirolamobd881c02020-10-08 18:23:41 -0700116```sh
Armando Montanez89344ce2023-09-07 21:33:21 +0000117pw build
Anthony DiGirolamobd881c02020-10-08 18:23:41 -0700118```
Carlos Chinchilla5a8ef412020-09-29 15:14:08 -0700119
Armando Montanezae93bc42023-09-07 17:13:57 +0000120## More info and Examples
Anthony DiGirolamobd881c02020-10-08 18:23:41 -0700121
Armando Montanezae93bc42023-09-07 17:13:57 +0000122Extended documentation and examples are built along code changes. You can view
Armando Montanezc1a9a322023-09-21 17:02:09 +0000123them at `out/gn/docs/gen/docs/html/index.html`.