Skip to content

Commit

Permalink
Add some C++ stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Apr 16, 2024
1 parent 7e09c06 commit c98d5a4
Show file tree
Hide file tree
Showing 12 changed files with 134 additions and 9 deletions.
34 changes: 34 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
BasedOnStyle: Google

# Make it slightly more similar to Rust.
# Based loosely on https://gist.github.com/YodaEmbedding/c2c77dc693d11f3734d78489f9a6eea4
AccessModifierOffset: -2
AlignAfterOpenBracket: BlockIndent
AllowAllArgumentsOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: Never
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
BinPackArguments: false
BreakStringLiterals: false
ColumnLimit: 100
ContinuationIndentWidth: 4
DerivePointerAlignment: false
EmptyLineBeforeAccessModifier: LogicalBlock
IndentWidth: 4
IndentWrappedFunctionNames: true
InsertBraces: true
InsertTrailingCommas: Wrapped
MaxEmptyLinesToKeep: 1
NamespaceIndentation: All
PointerAlignment: Left
ReflowComments: false
SeparateDefinitionBlocks: Always
SpacesBeforeTrailingComments: 1

# Don't change include blocks, we want to control this manually.
# Sorting headers however is allowed as all our headers should be standalone.
IncludeBlocks: Preserve
SortIncludes: CaseInsensitive
19 changes: 19 additions & 0 deletions .github/workflows/cpp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
on: [push, pull_request]

name: C++

jobs:
pixi-build:
name: "pixi build"
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4

- uses: prefix-dev/[email protected]
with:
pixi-version: v0.6.0
cache: true

- run: pixi run build

# TODO(emilk): Add a step to check formatting etc
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Mac stuff:
.DS_Store

# C++ build directory
build

# Rust compile target directory:
**/target
**/target_ra
Expand Down
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
},
// Rust:
{
"name": "Debug 'template'",
"name": "Debug 'rerun_template'",
"type": "lldb",
"request": "launch",
"cargo": {
"args": [
"build"
],
"filter": {
"name": "template",
"name": "rerun_template",
"kind": "bin"
}
},
Expand Down
18 changes: 18 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
cmake_minimum_required(VERSION 3.16...3.27)

project(rerun_template LANGUAGES CXX) # TODO

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

if(NOT DEFINED CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
endif()

# Rerun:
include(FetchContent)
FetchContent_Declare(rerun_sdk URL https://github.com/rerun-io/rerun/releases/download/0.15.1/rerun_cpp_sdk.zip)
FetchContent_MakeAvailable(rerun_sdk)

add_executable(rerun_template src/main.cpp) # TODO
target_link_libraries(rerun_template rerun_sdk) # TODO
target_include_directories(rerun_template PRIVATE src) # TODO
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ authors = ["rerun.io <[email protected]>"]
categories = [] # TODO
description = "" # TODO
edition = "2021"
homepage = "https://github.com/rerun-io/template" # TODO
homepage = "https://github.com/rerun-io/rerun_template" # TODO
include = ["LICENSE-APACHE", "LICENSE-MIT", "**/*.rs", "Cargo.toml"]
keywords = [] # TODO
license = "MIT OR Apache-2.0"
name = "template" # TODO
name = "rerun_template" # TODO
readme = "README.md"
repository = "https://github.com/rerun-io/template" # TODO
repository = "https://github.com/rerun-io/rerun_template" # TODO
rust-version = "1.76"
version = "0.1.0"

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ This template includes


## How to use
Start by clicking "Use this template" at https://github.com/rerun-io/template/ or follow [these instructions](https://docs.github.com/en/free-pro-team@latest/github/creating-cloning-and-archiving-repositories/creating-a-repository-from-a-template).
Start by clicking "Use this template" at https://github.com/rerun-io/rerun_template/ or follow [these instructions](https://docs.github.com/en/free-pro-team@latest/github/creating-cloning-and-archiving-repositories/creating-a-repository-from-a-template).

Then search for `TODO` and fill in all those places (including changing the whole contents of this `README.md`, obviously).
2 changes: 1 addition & 1 deletion generate_changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from tqdm import tqdm

OWNER = "rerun-io"
REPO = "template" # TODO: Change this to the name of the repo
REPO = "rerun_template" # TODO: Change this to the name of the repo
INCLUDE_LABELS = False # It adds quite a bit of visual noise
OFFICIAL_RERUN_DEVS = [
"abey79",
Expand Down
43 changes: 43 additions & 0 deletions pixi.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Pixi is a package management tool for developers.
# Before running a task, pixi ensures that all listed dependencies are installed first.echop
#
# Pixi is not required for rerun, but it is a convenient way to install the
# dependencies required for this example.
#
# https://prefix.dev/docs/pixi/overview
#
# Use `pixi task list` to list the available tasks,
# and `pixi run TASK` to run it (e.g. `pixi run example`).

[project]
name = "rerun_template" # TODO
authors = ["rerun.io <[email protected]>"]
channels = ["conda-forge"]
description = "rerun_template" # TODO
homepage = "https://rerun.io"
license = "MIT OR Apache-2.0"

platforms = ["linux-64", "linux-aarch64", "osx-arm64", "osx-64", "win-64"]
readme = "README.md"
repository = "https://github.com/rerun-io/rerun_template" # TODO
version = "0.1.0"


[tasks]
# C++ stuff:
# Note: extra CLI argument after `pixi run TASK` are passed to the task cmd.
clean = { cmd = "rm -rf build bin CMakeFiles/" }
print-env = { cmd = "echo $PATH" }
prepare = "cmake -G 'Ninja' -B build -S . -DCMAKE_BUILD_TYPE=RelWithDebInfo"
build = { cmd = "cmake --build build --config RelWithDebInfo --target all", depends_on = [
"prepare",
] }
example = { cmd = "build/rerun_template", depends_on = ["build"] }
format = { cmd = "clang-format -i src/*" }

[dependencies]
# C++ build-tools:
cmake = "3.27.6"
clang-tools = ">=15,<16" # clang-format
cxx-compiler = "1.6.0.*"
ninja = "1.11.1"
8 changes: 8 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <cstdio>

#include <rerun.hpp>

int main(int argc, const char* argv[]) {
printf("Hello, World!\n");
return 0;
}
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
fn main() {
println!("Hello, template!");
println!("Hello, rerun_template!");
}

0 comments on commit c98d5a4

Please sign in to comment.