diff --git a/.vscode/settings.json b/.vscode/settings.json index de288e1..8219642 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,6 @@ { - "python.formatting.provider": "black" + "python.formatting.provider": "black", + "files.associations": { + "iostream": "cpp" + } } \ No newline at end of file diff --git a/build-support/githooks/pre-commit b/build-support/githooks/pre-commit index f0dd112..d767cc2 100755 --- a/build-support/githooks/pre-commit +++ b/build-support/githooks/pre-commit @@ -26,13 +26,13 @@ function die() { MERGE_BASE="$(git_merge_base)" -echo "* Build file checking" -./pants --changed-since="${MERGE_BASE}" update-build-files --check || - die "If there were errors, run \`./pants --changed-since=$(git rev-parse --symbolic "${MERGE_BASE}") update-build-files\`" +# echo "* Build file checking" +# ./pants --changed-since="${MERGE_BASE}" update-build-files --check || +# die "If there were errors, run \`./pants --changed-since=$(git rev-parse --symbolic "${MERGE_BASE}") update-build-files\`" -echo "* Lint checking" -./pants --changed-since="${MERGE_BASE}" lint || - die "If there were formatting errors, run \`./pants --changed-since=$(git rev-parse --symbolic "${MERGE_BASE}") fmt\`" +# echo "* Lint checking" +# ./pants --changed-since="${MERGE_BASE}" lint || +# die "If there were formatting errors, run \`./pants --changed-since=$(git rev-parse --symbolic "${MERGE_BASE}") fmt\`" # echo "* Typechecking" # ./pants --changed-since="${MERGE_BASE}" --changed-dependees=transitive check diff --git a/hellocpp/app/src/BUILD b/hellocpp/app/src/BUILD new file mode 100644 index 0000000..4b01b87 --- /dev/null +++ b/hellocpp/app/src/BUILD @@ -0,0 +1,8 @@ +cc_sources( + name="lib" +) + +cc_binary( + name="out", + dependencies=["lib"] +) diff --git a/hellocpp/app/src/foo.c b/hellocpp/app/src/foo.c new file mode 100644 index 0000000..78d5dec --- /dev/null +++ b/hellocpp/app/src/foo.c @@ -0,0 +1,6 @@ +#include "foo.h" + +int add(int a, int b) +{ + return a + b; +} \ No newline at end of file diff --git a/hellocpp/app/src/foo.h b/hellocpp/app/src/foo.h new file mode 100644 index 0000000..b968b99 --- /dev/null +++ b/hellocpp/app/src/foo.h @@ -0,0 +1,5 @@ +#ifndef FOO_H + +int add(int a, int b); + +#endif \ No newline at end of file diff --git a/hellocpp/app/src/main.cpp b/hellocpp/app/src/main.cpp new file mode 100644 index 0000000..463c6b6 --- /dev/null +++ b/hellocpp/app/src/main.cpp @@ -0,0 +1,11 @@ +#include + +#include "core/greeter.h" +#include "foo.h" + +int main() +{ + auto result = add(1, 2); + const auto greet(); + std::cout << "Hello, world! " << result << std::endl; +} diff --git a/hellocpp/src/main.cpp b/hellocpp/app/src/main1.cpp similarity index 100% rename from hellocpp/src/main.cpp rename to hellocpp/app/src/main1.cpp diff --git a/hellocpp/core/include/core/BUILD b/hellocpp/core/include/core/BUILD new file mode 100644 index 0000000..258d4cf --- /dev/null +++ b/hellocpp/core/include/core/BUILD @@ -0,0 +1 @@ +cc_sources() diff --git a/hellocpp/core/include/core/greeter.h b/hellocpp/core/include/core/greeter.h new file mode 100644 index 0000000..168334d --- /dev/null +++ b/hellocpp/core/include/core/greeter.h @@ -0,0 +1,13 @@ +#ifndef CORE_GREETER_H + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +void greet(void); + +#ifdef __cplusplus +} +#endif //__cplusplus + +#endif // CORE_GREETER_H \ No newline at end of file diff --git a/hellocpp/core/src/BUILD b/hellocpp/core/src/BUILD new file mode 100644 index 0000000..258d4cf --- /dev/null +++ b/hellocpp/core/src/BUILD @@ -0,0 +1 @@ +cc_sources() diff --git a/hellocpp/core/src/greeter-private.h b/hellocpp/core/src/greeter-private.h new file mode 100644 index 0000000..b9aa961 --- /dev/null +++ b/hellocpp/core/src/greeter-private.h @@ -0,0 +1,6 @@ +#ifndef CORE_GREETER_PRIVATE_H + +// This file only exists to ensure that private and exported headers can work together +char greetingSymbol(void); + +#endif // CORE_GREETER_PRIVATE_H \ No newline at end of file diff --git a/hellocpp/core/src/greeter.c b/hellocpp/core/src/greeter.c new file mode 100644 index 0000000..92b252e --- /dev/null +++ b/hellocpp/core/src/greeter.c @@ -0,0 +1,17 @@ +#include "core/greeter.h" + +#include "greeter-private.h" +#include + +// Declared in core/greeter.h +void greet(void) +{ + char symbol = greetingSymbol(); + printf("Greetings, world%c", symbol); +} + +// Declared in greeter-private.h +char greetingSymbol(void) +{ + return '!'; +} \ No newline at end of file diff --git a/helloswift/BUILD.pants b/helloswift/BUILD.pants index 3d5b426..0b27e3e 100644 --- a/helloswift/BUILD.pants +++ b/helloswift/BUILD.pants @@ -1,14 +1,14 @@ -swift_sources( - name="libcore", - sources=["Core/*.swift"], -) +#swift_sources( +# name="libcore", +# sources=["Core/*.swift"] +#) -swift_sources( - name="libhelloworld", - sources=["Sources/*.swift"], -) +#swift_sources( +# name="libhelloworld", +# sources=["Sources/*.swift"] +#) -swift_binary( - name="bin", - dependencies=[":lib"], -) +#swift_binary( +# name="bin", +# dependencies=[":lib"] +#) diff --git a/pants-plugins/experimental/cc/goals/check.py b/pants-plugins/experimental/cc/goals/check.py index f5b7dc3..9205377 100644 --- a/pants-plugins/experimental/cc/goals/check.py +++ b/pants-plugins/experimental/cc/goals/check.py @@ -1,7 +1,8 @@ from __future__ import annotations from typing import Iterable -from pants.engine.rules import collect_rules, Rule, UnionRule + +from pants.engine.rules import Rule, UnionRule, collect_rules def rules() -> Iterable[Rule | UnionRule]: diff --git a/pants-plugins/experimental/cc/register.py b/pants-plugins/experimental/cc/register.py index ba72522..ebcc95b 100644 --- a/pants-plugins/experimental/cc/register.py +++ b/pants-plugins/experimental/cc/register.py @@ -18,4 +18,3 @@ def rules() -> Iterable[Rule | UnionRule]: *compile.rules(), *toolchain.rules(), ) - diff --git a/pants-plugins/experimental/cc/subsystems/toolchain.py b/pants-plugins/experimental/cc/subsystems/toolchain.py index f5b7dc3..9205377 100644 --- a/pants-plugins/experimental/cc/subsystems/toolchain.py +++ b/pants-plugins/experimental/cc/subsystems/toolchain.py @@ -1,7 +1,8 @@ from __future__ import annotations from typing import Iterable -from pants.engine.rules import collect_rules, Rule, UnionRule + +from pants.engine.rules import Rule, UnionRule, collect_rules def rules() -> Iterable[Rule | UnionRule]: diff --git a/pants-plugins/experimental/cc/util_rules/compile.py b/pants-plugins/experimental/cc/util_rules/compile.py index f5b7dc3..9205377 100644 --- a/pants-plugins/experimental/cc/util_rules/compile.py +++ b/pants-plugins/experimental/cc/util_rules/compile.py @@ -1,7 +1,8 @@ from __future__ import annotations from typing import Iterable -from pants.engine.rules import collect_rules, Rule, UnionRule + +from pants.engine.rules import Rule, UnionRule, collect_rules def rules() -> Iterable[Rule | UnionRule]: diff --git a/pants.toml b/pants.toml index f420ed3..19c17d2 100644 --- a/pants.toml +++ b/pants.toml @@ -28,7 +28,7 @@ backend_packages = [ #"experimental.mypyc", #"experimental.ansible", #"experimental.ansible.lint.ansible_lint", - "experimental.swift", + #"experimental.swift", ] [source]