Compare commits

...

10 Commits

Author SHA1 Message Date
Simon From Jakosen
ba238692a4 fix readme 2024-08-07 12:20:08 +02:00
Simon From Jakosen
dc9a4d3f7c add layer 2024-08-07 12:19:03 +02:00
Simon From Jakosen
5f94ed3ba1 decrease cmake version 2024-08-07 10:17:02 +02:00
Simon From Jakosen
ee26652f4e make yocto compatible 2024-08-07 10:13:30 +02:00
Peter Kragh
596937a04a Support older cmake 2024-08-05 16:18:55 +02:00
Simon From Jakobsen
3605714c09 add readme stuff 2024-08-02 14:33:53 +00:00
Simon From Jakobsen
567fff7e75 add readme stuff 2024-08-02 14:26:30 +00:00
Simon From Jakobsen
291fa30351 add readme 2024-08-02 14:16:08 +00:00
Simon From Jakobsen
7c891b99e8 add helloworld-c-make 2024-08-02 14:09:48 +00:00
Simon From Jakobsen
2d29797403 add helloworld-cpp-cmake 2024-08-02 14:07:33 +00:00
20 changed files with 320 additions and 1 deletions

28
README.md Normal file
View File

@ -0,0 +1,28 @@
# example-projects
## Yocto
### Add layer in a Yocto project
```
bitbake-layers add-layer /path/to/meta-helloworld
```
Then add this to `build/conf/local.conf`:
```sh
IMAGE_INSTALL:append = " helloworld-c-make"
IMAGE_INSTALL:append = " helloworld-cpp-cmake"
IMAGE_INSTALL:append = " helloworld-rs"
```
### Add/create recipes in a Yocto project
```
devtool add helloworld-c-make git@bitbucket.org:dol-sensors/example-projects.git --srcbranch main --src-subdir helloworld-c-make
devtool add helloworld-cpp-cmake git@bitbucket.org:dol-sensors/example-projects.git --srcbranch main --src-subdir helloworld-cpp-cmake
devtool add helloworld-rs git@bitbucket.org:dol-sensors/example-projects.git --srcbranch main --src-subdir helloworld-rs
```

View File

@ -0,0 +1,14 @@
BasedOnStyle: WebKit
IndentWidth: 4
ColumnLimit: 80
IndentCaseLabels: true
BreakBeforeBraces: Custom
BraceWrapping:
AfterFunction: true
SplitEmptyFunction: false
AlignAfterOpenBracket: BlockIndent
AlignOperands: AlignAfterOperator
BreakBeforeBinaryOperators: true
BinPackArguments: false
BinPackParameters: false

View File

@ -0,0 +1,5 @@
CompileFlags:
CompilationDatabase: build/compile_flags.txt
Remove:
- -Wempty-translation-unit

3
helloworld-c-make/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
build/
.cache/

View File

@ -0,0 +1,32 @@
EXECUTABLE = helloworld-c-make
CFLAGS = -std=c17 -Wall -Wextra -pedantic -pedantic-errors -O2
SOURCE_FILES = \
src/main.c
OBJECT_FILES = $(patsubst src/%.c, build/%.o, $(SOURCE_FILES))
HEADER_FILES = $(shell find src/ -name *.h)
all: build/$(EXECUTABLE) build/compile_flags.txt
build/$(EXECUTABLE): $(OBJECT_FILES)
$(CC) -o $@ $(LDFLAGS) $^
build/%.o: src/%.c $(HEADER_FILES) build-folder
$(CC) -c -o $@ $(CFLAGS) $<
build-folder:
mkdir -p build/
clean:
rm -rf build/
build/compile_flags.txt:
echo -xc $(CFLAGS) \
| tr ' ' '\n' \
> $@

View File

@ -0,0 +1,16 @@
# helloworld-c-make
```
make
./build/helloworld-c-make
```
```
make
sudo cp build/helloworld-c-make /usr/local/bin/
helloworld-c-make
```

View File

@ -0,0 +1,3 @@
#include <stdio.h>
int main(void) { printf("Hello, world!\n"); }

View File

@ -0,0 +1,14 @@
BasedOnStyle: WebKit
IndentWidth: 4
ColumnLimit: 80
IndentCaseLabels: true
BreakBeforeBraces: Custom
BraceWrapping:
AfterFunction: true
SplitEmptyFunction: false
AlignAfterOpenBracket: BlockIndent
AlignOperands: AlignAfterOperator
BreakBeforeBinaryOperators: true
BinPackArguments: false
BinPackParameters: false

3
helloworld-cpp-cmake/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
build/
.cache/

View File

@ -0,0 +1,13 @@
cmake_minimum_required(VERSION 3.22)
project(MyProject VERSION 1.0.0 LANGUAGES C CXX)
set(CMAKE_EXPORT_COMPILE_COMMANDS true)
add_executable(
helloworld-cpp-cmake
src/main.cpp
)
install(TARGETS helloworld-cpp-cmake)

View File

@ -0,0 +1,20 @@
# helloworld-cpp-cmake
```
mkdir build
cd build
cmake ..
make
./helloworld-cpp-cmake
```
```
mkdir build
cd build
cmake .. -CMAKE_BUILD_TYPE=Release
make
sudo make install
./helloworld-cpp-cmake
```

View File

@ -0,0 +1,3 @@
#include <iostream>
int main() { std::cout << "Hello, world!\n"; }

View File

@ -8,4 +8,8 @@ cargo run
```sh
cargo build --release
./target/release/helloworld-rs
``´
cargo install --path .
cargo install --path . --root /usr/local
```

View File

@ -0,0 +1,17 @@
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

41
meta-helloworld/README Normal file
View File

@ -0,0 +1,41 @@
This README file contains information on the contents of the meta-helloworld layer.
Please see the corresponding sections below for details.
Dependencies
============
URI: <first dependency>
branch: <branch name>
URI: <second dependency>
branch: <branch name>
.
.
.
Patches
=======
Please submit any patches against the meta-helloworld layer to the xxxx mailing list (xxxx@zzzz.org)
and cc: the maintainer:
Maintainer: XXX YYYYYY <xxx.yyyyyy@zzzzz.com>
Table of Contents
=================
I. Adding the meta-helloworld layer to your build
II. Misc
I. Adding the meta-helloworld layer to your build
=================================================
Run 'bitbake-layers add-layer meta-helloworld'
II. Misc
========
--- replace with specific information about the meta-helloworld layer ---

View File

@ -0,0 +1,13 @@
# We have a conf and classes directory, add to BBPATH
BBPATH .= ":${LAYERDIR}"
# We have recipes-* directories, add to BBFILES
BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \
${LAYERDIR}/recipes-*/*/*.bbappend"
BBFILE_COLLECTIONS += "helloworld"
BBFILE_PATTERN_helloworld = "^${LAYERDIR}/"
BBFILE_PRIORITY_helloworld = "6"
LAYERDEPENDS_helloworld = "core"
LAYERSERIES_COMPAT_helloworld = "kirkstone"

View File

@ -0,0 +1,13 @@
SUMMARY = "bitbake-layers recipe"
DESCRIPTION = "Recipe created by bitbake-layers"
LICENSE = "MIT"
python do_display_banner() {
bb.plain("***********************************************");
bb.plain("* *");
bb.plain("* Example recipe created by bitbake-layers *");
bb.plain("* *");
bb.plain("***********************************************");
}
addtask display_banner before do_build

View File

@ -0,0 +1,26 @@
# NOTE: LICENSE is being set to "CLOSED" to allow you to at least start building - if
# this is not accurate with respect to the licensing of the software being built (it
# will not be in most cases) you must specify the correct value before using this
# recipe for anything other than initial testing/development!
LICENSE = "CLOSED"
LIC_FILES_CHKSUM = ""
SRC_URI = "git://git@bitbucket.org/dol-sensors/example-projects.git;protocol=ssh;branch=main"
PV = "1.0+git${SRCPV}"
SRCREV = "5f94ed3ba1bff1c6631d0234c7dbe65c27c4791e"
S = "${WORKDIR}/git/${BPN}"
do_compile () {
oe_runmake
}
do_install () {
install -d ${D}${bindir}
install -m 0755 ${S}/build/helloworld-c-make ${D}${bindir}
}
FILES:${PN} += "${bindir}"

View File

@ -0,0 +1,27 @@
# Recipe created by recipetool
# This is the basis of a recipe and may need further editing in order to be fully functional.
# (Feel free to remove these comments when editing.)
# Unable to find any files that looked like license statements. Check the accompanying
# documentation and source headers and set LICENSE and LIC_FILES_CHKSUM accordingly.
#
# NOTE: LICENSE is being set to "CLOSED" to allow you to at least start building - if
# this is not accurate with respect to the licensing of the software being built (it
# will not be in most cases) you must specify the correct value before using this
# recipe for anything other than initial testing/development!
LICENSE = "CLOSED"
LIC_FILES_CHKSUM = ""
SRC_URI = "git://git@bitbucket.org/dol-sensors/example-projects.git;protocol=ssh;branch=main"
# Modify these as desired
PV = "1.0+git${SRCPV}"
SRCREV = "5f94ed3ba1bff1c6631d0234c7dbe65c27c4791e"
S = "${WORKDIR}/git/${BPN}"
inherit cmake
# Specify any options you want to pass to cmake using EXTRA_OECMAKE:
EXTRA_OECMAKE = ""

View File

@ -0,0 +1,24 @@
# Recipe created by recipetool
# This is the basis of a recipe and may need further editing in order to be fully functional.
# (Feel free to remove these comments when editing.)
# Unable to find any files that looked like license statements. Check the accompanying
# documentation and source headers and set LICENSE and LIC_FILES_CHKSUM accordingly.
#
# NOTE: LICENSE is being set to "CLOSED" to allow you to at least start building - if
# this is not accurate with respect to the licensing of the software being built (it
# will not be in most cases) you must specify the correct value before using this
# recipe for anything other than initial testing/development!
LICENSE = "CLOSED"
LIC_FILES_CHKSUM = ""
SRC_URI = "git://git@bitbucket.org/dol-sensors/example-projects.git;protocol=ssh;branch=main"
# Modify these as desired
PV = "1.0+git${SRCPV}"
SRCREV = "5f94ed3ba1bff1c6631d0234c7dbe65c27c4791e"
S = "${WORKDIR}/git/${BPN}"
inherit cargo