Added new sample toolchain

Inherit from upstream Pigweed host toolchain to show how to create a
toolchain and override arguments of the base toolchain.
Also removed unused dependency in sample app.

Change-Id: Ib447d6942be95b9498c4eae3f77013b8103b69a7
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/sample_project/+/17921
Reviewed-by: Armando Montanez <amontanez@google.com>
Commit-Queue: Carlos Chinchilla <cachinchilla@google.com>
4 files changed
tree: 1abd389b6b34ac45b96c92492ee8fc45ab7cbcd2
  1. build_overrides/
  2. source/
  3. targets/
  4. third_party/
  5. .gitignore
  6. .gitmodules
  7. .gn
  8. activate.bat
  9. banner.txt
  10. bootstrap.bat
  11. bootstrap.sh
  12. BUILD.gn
  13. BUILDCONFIG.gn
  14. README.md
README.md

Pigweed Sample Project

This repository outlines the recommended way of using Pigweed in a new or existing project. Feel free to fork this repository, or read it as a reference.

For more information see the Pigweed Getting started guide

Check back for more complex examples and features coming soon!

Repository setup

The preferred method to add the Pigweed source is to use git submodules and place the Pigweed source repository in third_party/pigweed. If you forked this repository, don't forget to run git submodule init and git submodule update.

Environment Setup

The scripts bootstrap.bat for Windows, and bootstrap.sh for Unix systems call the respective Pigweed bootstrap scripts. Feel free to modify them to set up your development environment for the first time.

After the initial setup, use the activate.bat in Windows or activate.sh in Unix to enter the environment in a shell.

Banner

Make the project yours with your own banner. Create your own banner and place it in banner.txt.

Building

Generate the build files with gn gen out once, unless the build configuration has changed. Then, use ninja to build everything with ninja -C out.

Sample Application

The sample application in source/main.cc uses the sample module simple_counter. Look at source/BUILD.gn and source/simple_counter/BUILD.gn to see how these are built respectively. The key part is in the root BUILD.gn, which creates the host target using the host toolchain. A toolchain is required for each target.

Build the project and run the application. ./out/host_clang_debug/obj/source/bin/hello_world

Sample Test

The simple_counter module has tests defined in source/simple_counter_tests.cc. Look at source/simple_counter/BUILD.gn for an example of how a test is defined. The root BUILD.gn groups all the host tests together.

Build the project and run the tests. ./out/host_clang_debug/obj/source/simple_counter/test/simple_counter_test