mirror of
https://github.com/wasp-lang/wasp.git
synced 2024-12-24 09:34:28 +03:00
Initial setup of stick C++ project, with Bazel and Catch2.
This commit is contained in:
parent
8e412a161f
commit
7620f4c21c
35
stic/.gitignore
vendored
Normal file
35
stic/.gitignore
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
# Prerequisites
|
||||
*.d
|
||||
|
||||
# Compiled Object files
|
||||
*.slo
|
||||
*.lo
|
||||
*.o
|
||||
*.obj
|
||||
|
||||
# Precompiled Headers
|
||||
*.gch
|
||||
*.pch
|
||||
|
||||
# Compiled Dynamic libraries
|
||||
*.so
|
||||
*.dylib
|
||||
*.dll
|
||||
|
||||
# Fortran module files
|
||||
*.mod
|
||||
*.smod
|
||||
|
||||
# Compiled Static libraries
|
||||
*.lai
|
||||
*.la
|
||||
*.a
|
||||
*.lib
|
||||
|
||||
# Executables
|
||||
*.exe
|
||||
*.out
|
||||
*.app
|
||||
|
||||
# Bazel files/folders.
|
||||
bazel-*
|
@ -2,3 +2,22 @@ STIC
|
||||
====
|
||||
|
||||
![stick](./stick.png)
|
||||
|
||||
## Setup
|
||||
|
||||
### Bazel
|
||||
We are using Bazel as our build system, so make sure to install bazel globally on your machine.
|
||||
|
||||
|
||||
## Building
|
||||
We are using Bazel build system.
|
||||
Everything is defined in BUILD files (+ one WORKSPACE file).
|
||||
Learn more about Bazel to know how to build spepcific targets, locate produced binaries and so on.
|
||||
|
||||
For your convenience, there is `run-stick-cli` script that builds and runs `stick-cli` binary for you.
|
||||
|
||||
|
||||
## Tests
|
||||
We are using Catch2 testing framework.
|
||||
|
||||
While you can use Bazel to run specific tests, there is `run-all-tests` script to easily build and run all tests.
|
||||
|
0
stic/WORKSPACE
Normal file
0
stic/WORKSPACE
Normal file
3
stic/run-stick-cli
Executable file
3
stic/run-stick-cli
Executable file
@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
bazel build //src:stick-cli && bazel-bin/src/stick-cli
|
3
stic/run-tests
Executable file
3
stic/run-tests
Executable file
@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
bazel build //test:all-tests && bazel-bin/test/all-tests
|
16
stic/src/BUILD
Normal file
16
stic/src/BUILD
Normal file
@ -0,0 +1,16 @@
|
||||
cc_library(
|
||||
name = "hello-world",
|
||||
srcs = ["hello-world.cpp"],
|
||||
hdrs = ["hello-world.hpp"],
|
||||
visibility = [
|
||||
"//test:__pkg__"
|
||||
]
|
||||
)
|
||||
|
||||
cc_binary(
|
||||
name = "stick-cli",
|
||||
srcs = ["cli.cpp"],
|
||||
deps = [
|
||||
":hello-world"
|
||||
]
|
||||
)
|
7
stic/src/cli.cpp
Normal file
7
stic/src/cli.cpp
Normal file
@ -0,0 +1,7 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "./hello-world.hpp"
|
||||
|
||||
int main () {
|
||||
std::cout << sayHi() << std::endl;
|
||||
}
|
5
stic/src/hello-world.cpp
Normal file
5
stic/src/hello-world.cpp
Normal file
@ -0,0 +1,5 @@
|
||||
#include "./hello-world.hpp"
|
||||
|
||||
std::string sayHi() {
|
||||
return "Hello world!";
|
||||
}
|
5
stic/src/hello-world.hpp
Normal file
5
stic/src/hello-world.hpp
Normal file
@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
std::string sayHi();
|
19
stic/test/BUILD
Normal file
19
stic/test/BUILD
Normal file
@ -0,0 +1,19 @@
|
||||
cc_library(
|
||||
name = "catch-main",
|
||||
srcs = ["main.cpp"],
|
||||
copts = ["-Ivendor/catch2/"],
|
||||
deps = [
|
||||
"//vendor/catch2:catch2"
|
||||
]
|
||||
)
|
||||
|
||||
cc_test(
|
||||
name = "all-tests",
|
||||
srcs = glob(["**/*.test.cpp"]),
|
||||
copts = ["-Ivendor/catch2/", "-Isrc/"],
|
||||
deps = [
|
||||
"catch-main",
|
||||
"//vendor/catch2:catch2",
|
||||
"//src:hello-world"
|
||||
]
|
||||
)
|
7
stic/test/hello-world.test.cpp
Normal file
7
stic/test/hello-world.test.cpp
Normal file
@ -0,0 +1,7 @@
|
||||
#include "catch.hpp"
|
||||
|
||||
#include "hello-world.hpp"
|
||||
|
||||
TEST_CASE("Returns hello world.") {
|
||||
REQUIRE(sayHi() == "Hello world!");
|
||||
}
|
2
stic/test/main.cpp
Normal file
2
stic/test/main.cpp
Normal file
@ -0,0 +1,2 @@
|
||||
#define CATCH_CONFIG_MAIN
|
||||
#include "catch.hpp"
|
5
stic/vendor/catch2/BUILD
vendored
Normal file
5
stic/vendor/catch2/BUILD
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
cc_library(
|
||||
name = "catch2",
|
||||
hdrs = ["catch.hpp"],
|
||||
visibility = ["//test:__pkg__"]
|
||||
)
|
13922
stic/vendor/catch2/catch.hpp
vendored
Normal file
13922
stic/vendor/catch2/catch.hpp
vendored
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user