commit 9a070a5f8fc31896f4e26b2f6daf22f7143b75c7 Author: John Doty Date: Sat Jan 11 10:08:07 2025 -0800 Initial commit I guess diff --git a/.buckconfig b/.buckconfig new file mode 100644 index 0000000..4d493cf --- /dev/null +++ b/.buckconfig @@ -0,0 +1,27 @@ +[cells] + root = . + prelude = prelude + toolchains = toolchains + none = none + +[cell_aliases] + config = prelude + ovr_config = prelude + fbcode = none + fbsource = none + fbcode_macros = none + buck = none + +# Uses a copy of the prelude bundled with the buck2 binary. You can alternatively delete this +# section and vendor a copy of the prelude to the `prelude` directory of your project. +[external_cells] + prelude = bundled + +[parser] + target_platform_detector_spec = target:root//...->prelude//platforms:default + +[build] + execution_platforms = prelude//platforms:default + +[project] + ignore = .git diff --git a/.buckroot b/.buckroot new file mode 100644 index 0000000..e69de29 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0a0ddb2 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/buck-out diff --git a/BUCK b/BUCK new file mode 100644 index 0000000..b07a066 --- /dev/null +++ b/BUCK @@ -0,0 +1,13 @@ +# A list of available rules and their signatures can be found here: https://buck2.build/docs/prelude/globals/ + +genrule( + name = "hello_world", + out = "out.txt", + cmd = "echo BUILT BY BUCK2> $OUT", +) + +cxx_binary( + name = "main", + srcs = ["main.cpp"], + link_style = "static", +) diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..6ea8af0 --- /dev/null +++ b/main.cpp @@ -0,0 +1,5 @@ +#include + +int main() { + printf("Hello from a C++ Buck2 program!\n"); +} diff --git a/toolchains/BUCK b/toolchains/BUCK new file mode 100644 index 0000000..885cf38 --- /dev/null +++ b/toolchains/BUCK @@ -0,0 +1,20 @@ +load("@prelude//toolchains:cxx.bzl", "system_cxx_toolchain") +load("@prelude//toolchains:python.bzl", "system_python_bootstrap_toolchain") + +# Ugh. +system_cxx_toolchain( + name = "cxx", + visibility = ["PUBLIC"], + + compiler = "gcc", + compiler_type = "gcc", + cxx_compiler = "g++", + rc_compiler = None, + cvtres_compiler = None, + linker = "g++", +) + +system_python_bootstrap_toolchain( + name = "python_bootstrap", + visibility = ["PUBLIC"], +) diff --git a/toolchains/tools.bzl b/toolchains/tools.bzl new file mode 100644 index 0000000..2fa735e --- /dev/null +++ b/toolchains/tools.bzl @@ -0,0 +1,25 @@ +load("@prelude//cxx:cxx_toolchain_types.bzl", "LinkerType") +load("@prelude//toolchains:cxx.bzl", "CxxToolsInfo") + +def _path_gcc_tools_impl(_ctx) -> list[Provider]: + return [ + DefaultInfo(), + CxxToolsInfo( + compiler = "gcc", + compiler_type = "gcc", + cxx_compiler = "g++", + asm_compiler = "gcc", + asm_compiler_type = "gcc", + rc_compiler = None, + cvtres_compiler = None, + archiver = "ar", + archiver_type = "gnu", + linker = "g++", + linker_type = LinkerType("gnu"), + ), + ] + +path_gcc_tools = rule( + impl = _path_gcc_tools_impl, + attrs = {}, +)