-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #633 from GDATASoftwareAG/add-common-build-tool
Add common build tool
- Loading branch information
Showing
15 changed files
with
587 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,5 +53,7 @@ _trial_temp*/ | |
ruby/.idea | ||
ruby/Gemfile.lock | ||
ruby/test/test.txt | ||
ruby/**/*.gem | ||
|
||
*.env* | ||
|
||
.env* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
* Very simple dotenv implementation in C++, | ||
* specifically for the use case of running tests in this repository. | ||
* | ||
* It tries to read `.env` file in the current directory or a custom file. | ||
* If no file is found, no error is thrown, instead the environment variable | ||
* is expected to be set in the environment. | ||
* | ||
* If both the file and the environment variable are set, the environment variable | ||
* takes precedence. | ||
*/ | ||
|
||
#ifndef DOTENV_H | ||
#define DOTENV_H | ||
|
||
#include <algorithm> | ||
#include <exception> | ||
#include <filesystem> | ||
#include <fstream> | ||
#include <map> | ||
#include <stdexcept> | ||
#include <string> | ||
|
||
namespace dotenv { | ||
|
||
class Dotenv { | ||
private: | ||
std::string envFile; | ||
std::map<std::string, std::string> envFromFile; | ||
|
||
std::map<std::string, std::string> readEnvFromFile() { | ||
std::map<std::string, std::string> env; | ||
std::ifstream file(envFile); | ||
char charsToRemove[] = {'"', '\''}; | ||
|
||
if (!file) { | ||
return env; | ||
} | ||
|
||
for (std::string line; std::getline(file, line);) { | ||
const auto pos = line.find('='); | ||
if (pos != std::string::npos) { | ||
const auto key = line.substr(0, pos); | ||
auto value = line.substr(pos + 1); | ||
|
||
removeCharsFromString(value, charsToRemove); | ||
|
||
env[key] = value; | ||
} | ||
} | ||
|
||
return env; | ||
} | ||
|
||
static void removeCharsFromString(std::string& str, char* charsToRemove) { | ||
for (unsigned int i = 0; i < sizeof(charsToRemove); ++i) { | ||
str.erase(remove(str.begin(), str.end(), charsToRemove[i]), str.end()); | ||
} | ||
} | ||
|
||
public: | ||
Dotenv() : Dotenv(".env") {} | ||
|
||
Dotenv(const std::string& envFile) : envFile(envFile) { | ||
this->envFromFile = readEnvFromFile(); | ||
} | ||
|
||
std::string get(const std::string& key) { | ||
if (std::getenv(key.c_str())) { | ||
return std::getenv(key.c_str()); | ||
} | ||
|
||
if (envFromFile.find(key) != envFromFile.end()) { | ||
return envFromFile[key]; | ||
} | ||
|
||
throw std::runtime_error(key + " must be set"); | ||
} | ||
}; | ||
|
||
} // namespace dotenv | ||
#endif // !DOTENV_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
{ | ||
description = "A flake for easy development of the multi-language Verdict-as-a-Service libraries"; | ||
|
||
inputs = { | ||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; | ||
flake-utils.url = "github:numtide/flake-utils"; | ||
}; | ||
|
||
outputs = { self, nixpkgs, flake-utils, ... }: | ||
flake-utils.lib.eachDefaultSystem (system: | ||
let | ||
pkgs = import nixpkgs { inherit system; }; | ||
inherit (pkgs) lib; | ||
|
||
tools = [ | ||
pkgs.just | ||
pkgs.lazygit | ||
]; | ||
|
||
rustDeps = [ | ||
pkgs.cargo | ||
pkgs.rustc | ||
pkgs.clippy | ||
pkgs.rustfmt | ||
] ++ lib.optional pkgs.stdenv.isDarwin [ | ||
pkgs.darwin.apple_sdk.frameworks.Cocoa | ||
pkgs.libiconv | ||
pkgs.iconv | ||
]; | ||
|
||
typeScriptDeps = [ | ||
pkgs.nodejs | ||
]; | ||
|
||
dotnetDeps = [ | ||
pkgs.dotnet-sdk_8 | ||
]; | ||
|
||
goDeps = [ | ||
pkgs.go | ||
]; | ||
|
||
pythonDeps = [ | ||
pkgs.python3 | ||
pkgs.python312Packages.pip | ||
]; | ||
|
||
phpDeps = [ | ||
pkgs.php | ||
pkgs.php83Packages.composer | ||
]; | ||
|
||
javaDeps = [ | ||
pkgs.jdk22 | ||
pkgs.gradle | ||
]; | ||
|
||
rubyDeps = [ | ||
pkgs.ruby | ||
pkgs.git | ||
]; | ||
|
||
cppDeps = [ | ||
pkgs.vcpkg | ||
pkgs.cmake | ||
pkgs.curl | ||
pkgs.jsoncpp | ||
pkgs.doctest | ||
]; | ||
|
||
in | ||
with pkgs; | ||
{ | ||
devShells.default = pkgs.mkShell { | ||
buildInputs = [ | ||
pkg-config | ||
openssl | ||
] ++ tools | ||
++ rustDeps | ||
++ typeScriptDeps | ||
++ dotnetDeps | ||
++ goDeps | ||
++ pythonDeps | ||
++ phpDeps | ||
++ javaDeps | ||
++ rubyDeps | ||
++ cppDeps; | ||
|
||
shellHook = '' | ||
alias c=cargo | ||
alias j=just | ||
alias lg=lazygit | ||
alias ll="ls -la" | ||
alias lll="ls -lah" | ||
''; | ||
|
||
DOTNET_CLI_HOME = "/tmp/nix/.dotnet"; | ||
GOPATH = "/tmp/nix/.go"; | ||
GOCACHE = "/tmp/nix/.gocache"; | ||
COMPOSER_HOME = "/tmp/nix/.composer"; | ||
GEM_HOME = "/tmp/nix/.gem"; | ||
}; | ||
} | ||
); | ||
} |
Oops, something went wrong.