Add an initial build system test
This commit is contained in:
commit
d5d4aed218
2
.clang-format
Normal file
2
.clang-format
Normal file
|
@ -0,0 +1,2 @@
|
|||
BasedOnStyle: LLVM
|
||||
IndentWidth: 4
|
7
.editorconfig
Normal file
7
.editorconfig
Normal file
|
@ -0,0 +1,7 @@
|
|||
root = true
|
||||
|
||||
[*]
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
indent_style = space
|
||||
indent_size = 4
|
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
.cache
|
||||
.direnv
|
||||
build
|
27
flake.lock
Normal file
27
flake.lock
Normal file
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1724300212,
|
||||
"narHash": "sha256-x3jl6OWTs+L9C7EtscuWZmGZWI0iSBDafvg3X7JMa1A=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "4de4818c1ffa76d57787af936e8a23648bda6be4",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
29
flake.nix
Normal file
29
flake.nix
Normal file
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
|
||||
};
|
||||
|
||||
outputs =
|
||||
{ self, nixpkgs }:
|
||||
let
|
||||
inherit (nixpkgs) lib;
|
||||
makePkgs = system: import nixpkgs { inherit system; };
|
||||
forAllSystems = f: lib.genAttrs lib.systems.flakeExposed (system: f (makePkgs system));
|
||||
in
|
||||
{
|
||||
formatter = forAllSystems (pkgs: pkgs.nixfmt-rfc-style);
|
||||
|
||||
devShells = forAllSystems (pkgs: {
|
||||
default = (pkgs.mkShell.override { stdenv = pkgs.llvmPackages.stdenv; }) {
|
||||
packages = with pkgs; [
|
||||
meson
|
||||
ninja
|
||||
pkg-config
|
||||
|
||||
boost
|
||||
curl
|
||||
];
|
||||
};
|
||||
});
|
||||
};
|
||||
}
|
11
meson.build
Normal file
11
meson.build
Normal file
|
@ -0,0 +1,11 @@
|
|||
project('vapore', 'cpp',
|
||||
default_options : [
|
||||
'cpp_std=c++20',
|
||||
'optimization=2',
|
||||
'debug=true',
|
||||
],
|
||||
)
|
||||
|
||||
curl = dependency('libcurl', 'curl', required : true)
|
||||
|
||||
tool = executable('vaporetool', 'src/tool/main.cpp', dependencies: [ curl ])
|
38
src/tool/main.cpp
Normal file
38
src/tool/main.cpp
Normal file
|
@ -0,0 +1,38 @@
|
|||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
#include <curl/curl.h>
|
||||
|
||||
namespace vapore {
|
||||
void initCurl() {
|
||||
static std::once_flag globalInit;
|
||||
std::call_once(globalInit, curl_global_init, CURL_GLOBAL_DEFAULT);
|
||||
}
|
||||
|
||||
int wrappedMain(int argc, char **argv) {
|
||||
initCurl();
|
||||
|
||||
auto curl = std::unique_ptr<CURL, decltype(&curl_easy_cleanup)>(
|
||||
curl_easy_init(), curl_easy_cleanup);
|
||||
|
||||
if (curl.get() == nullptr) {
|
||||
throw std::runtime_error("Could not create curl_easy");
|
||||
}
|
||||
|
||||
curl_easy_setopt(curl.get(), CURLOPT_URL, "https://example.com");
|
||||
curl_easy_perform(curl.get());
|
||||
|
||||
return 0;
|
||||
}
|
||||
} // namespace vapore
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
try {
|
||||
return vapore::wrappedMain(argc, argv);
|
||||
} catch (std::exception &ex) {
|
||||
std::cerr << std::string("Got exception: ") << ex.what() << std::endl;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue