Skip to content

Commit

Permalink
merge with previous version
Browse files Browse the repository at this point in the history
  • Loading branch information
0-Sacha committed Apr 21, 2024
1 parent dc21282 commit cb460a6
Show file tree
Hide file tree
Showing 172 changed files with 14,301 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Common
common --enable_platform_specific_config
common --experimental_platforms_api
common --show_timestamps
common --verbose_failures
test --test_output=errors

# Build
common:linux --config=default_compiler_opt
common:msvc --config=microsoft_compiler_opt

common:default_compiler_opt --copt -std=c++20
common:microsoft_compiler_opt --copt /std:c++20

# BuildBuddy
common:linux --workspace_status_command=$(pwd)/.buildbuddy/workspace_status.sh
common:windows --workspace_status_command=.buildbuddy/workspace_status.bat
Empty file added .bazelversion
Empty file.
2 changes: 2 additions & 0 deletions .buildbuddy/workspace_status.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@echo off
call PowerShell -NoProfile -ExecutionPolicy Bypass -Command "%CD%\.buildbuddy\workspace_status.ps1"
33 changes: 33 additions & 0 deletions .buildbuddy/workspace_status.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This script will be run by Bazel when the building process starts to
# generate key-value information that represents the status of the
# workspace. The output should be like
#
# KEY1 VALUE1
# KEY2 VALUE2
#
# If the script exits with a non-zero code, it's considered as a failure
# and the output will be discarded.

$ErrorActionPreference = "Stop"

# Get the repository URL without credentials
$repo_url = (git config --get remote.origin.url) -replace '//.*?:.*?@', '//'
$repo_url = $repo_url -replace '^[email protected]:', 'https://github.com/'
$urrepo_urll = $repo_url -replace '\.git$'
Write-Output "REPO_URL $repo_url"

# Get the commit SHA
$commit_sha = git rev-parse HEAD
Write-Output "COMMIT_SHA $commit_sha"

# Get the current Git branch
$git_branch = git rev-parse --abbrev-ref HEAD
Write-Output "GIT_BRANCH $git_branch"

# Check if there are any modified files in the working directory
if (git diff-index --quiet HEAD) {
$git_tree_status = 'Clean'
} else {
$git_tree_status = 'Modified'
}
Write-Output "GIT_TREE_STATUS $git_tree_status"
31 changes: 31 additions & 0 deletions .buildbuddy/workspace_status.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

# This script will be run bazel when building process starts to
# generate key-value information that represents the status of the
# workspace. The output should be like
#
# KEY1 VALUE1
# KEY2 VALUE2
#
# If the script exits with non-zero code, it's considered as a failure
# and the output will be discarded.

set -eo pipefail # exit immediately if any command fails.

function remove_url_credentials() {
which perl >/dev/null && perl -pe 's#//.*?:.*?@#//#' || cat
}

repo_url=$(git config --get remote.origin.url | remove_url_credentials)
repo_url=${repo_url/git@github.com:/https://github.com/}
repo_url=${repo_url%.git}
echo "REPO_URL $repo_url"

commit_sha=$(git rev-parse HEAD)
echo "COMMIT_SHA $commit_sha"

git_branch=$(git rev-parse --abbrev-ref HEAD)
echo "GIT_BRANCH $git_branch"

git_tree_status=$(git diff-index --quiet HEAD -- && echo 'Clean' || echo 'Modified')
echo "GIT_TREE_STATUS $git_tree_status"
17 changes: 17 additions & 0 deletions .buildkite/linux_amd64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
agents:
queue: "agent-runners-linux-amd64"

steps:
- label: ":bazel: Build on gcc"
commands:
- CC=gcc bazelisk build //...
- label: ":bazel: Test on gcc"
commands:
- CC=gcc bazelisk test //...

- label: ":bazel: Build on Clang"
commands:
- CC=clang bazelisk build //...
- label: ":bazel: Test on Clang"
commands:
- CC=clang bazelisk test //...
5 changes: 5 additions & 0 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
steps:
- label: ":pipeline: Launch Windows Pipeline"
command: "buildkite-agent pipeline upload .buildkite/windows_amd64.yml"
- label: ":pipeline: Launch Linux Pipeline"
command: "buildkite-agent pipeline upload .buildkite/linux_amd64.yml"
4 changes: 4 additions & 0 deletions .buildkite/template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name: "ProjectCore"
steps:
- label: ":pipeline: Launch Embbeded Pipeline"
command: "buildkite-agent pipeline upload .builkite/pipeline.yml"
10 changes: 10 additions & 0 deletions .buildkite/windows_amd64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
agents:
queue: "agent-runners-windows-amd64"

steps:
- label: ":bazel: Build"
commands:
- bazelisk build //...
- label: ":bazel: Test"
commands:
- bazelisk test //...
64 changes: 64 additions & 0 deletions .github/workflows/ProjectCore.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: ProjectCore

on:
push:
branches:
- '**'
pull_request:
branches:
- '**'

jobs:
windows-latest-msvc:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: bazelbuild/setup-bazelisk@v3
- name: Mount bazel cache
uses: actions/cache@v4
with:
path: "~/.cache/bazel"
key: bazel
- name: Building...
run: bazelisk build //...
- name: Testing...
run: bazelisk test //...

ubuntu-latest-gcc:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: bazelbuild/setup-bazelisk@v3
- name: Mount bazel cache
uses: actions/cache@v4
with:
path: "~/.cache/bazel"
key: bazel
- name: Version
run: gcc --version
- name: Building...
run: CC=gcc bazelisk build //...
- name: Testing...
run: CC=gcc bazelisk test //...

ubuntu-latest-clang:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: bazelbuild/setup-bazelisk@v3
- name: Mount bazel cache
uses: actions/cache@v4
with:
path: "~/.cache/bazel"
key: bazel
- name: Install clang
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x ./llvm.sh
sudo ./llvm.sh 17
- name: Version
run: clang --version
- name: Building...
run: CC=clang++-17 bazelisk build //...
- name: Testing...
run: CC=clang++-17 bazelisk test //...
31 changes: 31 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

# bazel
MODULE.bazel.lock
bazel-bin
bazel-out
bazel-projectcore
bazel-testlogs

# VS
.vs
*.sln
*.vcxproj
*.vcxproj.filters
*.vcxproj.user

# Make
Makefile
*.make

# VSCode
.vscode

# VSCode
bin
bin-int

# Asset
Asset

# Tests
TestSuite_FMT.json
22 changes: 22 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
""

load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")

cc_library(
name = "ProjectCore",
srcs = glob([ "src/**/*.h", "src/**/*.cpp" ]),
hdrs = glob([ "src/**/*.h" ]),
includes = [ "src/" ],
strip_include_prefix = "src",
include_prefix = "ProjectCore",
linkstatic = True,
visibility = ["//visibility:public"],
)

cc_test(
name = "ProjectCoreTests",
includes = [ "src/" ],
srcs = glob([ "Tests/**/*.h", "Tests/**/*.cpp" ]),
deps = [ ":ProjectCore" ],
visibility = ["//visibility:public"],
)
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Bellier Sacha

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
10 changes: 10 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
""

# buildifier: disable=module-docstring
module(
name = "projectcore",
version = "0.1",
repo_name = "com_sacha_projectcore",
)

bazel_dep(name = "rules_cc", version = "0.0.4")
5 changes: 5 additions & 0 deletions Tests/FMT/BaseFMTTests.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#pragma once

#include "ProjectCore/Tester/TestSuite/AllTestSuite.h"

inline PCT_TEST_SUITE(FMT);
15 changes: 15 additions & 0 deletions Tests/FMT/ComplexPattern.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include "ProjectCore/Tester/TestSuite/AllTestSuite.h"
#include "ProjectCore/FMT/FMT.h"

#include "BaseFMTTests.h"

PCT_TEST_GROUP(FMT, COMPLEX_PATTERN);

#define TEST_FMT(fmt_test, expected, ...) PCT_EQ(ProjectCore::FMT::FormatString(fmt_test, __VA_ARGS__), expected)

PCT_TEST_FUNC(COMPLEX_PATTERN, UNESCAPED_ESCAPE_PATTERN)
{
TEST_FMT("{0}", "9", 9);
TEST_FMT("{{0}|", "{9|", 9);
TEST_FMT("{{0},", "{9,", 9);
}
73 changes: 73 additions & 0 deletions Tests/FMT/Globber.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#include "ProjectCore/Tester/TestSuite/AllTestSuite.h"
#include "ProjectCore/FMT/FMT.h"
#include "ProjectCore/FMT/Detail/Buffer/Utils/PatternMatching/Glob/Glob.h"

#include "BaseFMTTests.h"

PCT_TEST_GROUP(FMT, GLOBBER);
#define TEST_GLOBBER(data, glob) \
{ \
ProjectCore::FMT::Detail::BasicBufferIn<char> p_buffer(data); \
ProjectCore::FMT::Detail::BasicBufferIn<char> p_glob(glob); \
ProjectCore::FMT::Detail::Globber<char, char>::BufferInExecGlob(p_buffer, p_glob); \
PCT_ASSERT(p_buffer.IsEnd()); \
}

PCT_TEST_FUNC(GLOBBER, BASIC_WILDCARD)
{
TEST_GLOBBER("qwerty", "qwerty")
TEST_GLOBBER("qwerty", "q?erty")
TEST_GLOBBER("qwerty", "q?????")
TEST_GLOBBER("qwerty", "qwer?y")
TEST_GLOBBER("qwerty", "qwert?")
TEST_GLOBBER("qwerty", "??????")
TEST_GLOBBER("qwerty", "*")
TEST_GLOBBER("qwerty", "******")
TEST_GLOBBER("qwerty", "*?**?*")
}

PCT_TEST_GROUP(FMT, PARSE_GLOBBER);
PCT_TEST_FUNC(PARSE_GLOBBER, PG_BASIC_WILDCARD)
{
int k = 0;
ProjectCore::FMT::Parse("|123|", "|{}|", k);
PCT_EQ(k, 123);

{
char test[5];
ProjectCore::FMT::Parse("|test|", "|{}|", test);
PCT_EQ(std::string(test), std::string("test"));
}

{
char test[4];
ProjectCore::FMT::Parse("|test|", "|{:no-zero-end}|", test);
PCT_EQ(std::string(test, 4), std::string("test"));
}

{
char test[4];
ProjectCore::FMT::Parse("|test|", "|{}t|", test);
PCT_EQ(std::string(test), std::string("tes"));
}

{
char test[11];
ProjectCore::FMT::Parse("|test123456|", "|{}|", test);
PCT_EQ(std::string(test), std::string("test123456"));
}

{
char test[11];
ProjectCore::FMT::Parse("|test123456|", "|{:glob='*1'}23456|", test);
PCT_EQ(std::string(test), std::string("test1"));
}

{
char test[11];
// just glob = '????' but compiler are anrgy about trigraph on '??'
ProjectCore::FMT::Parse("|test123456|", "|{:glob='?""?""?""?'}123456|", test);
PCT_EQ(std::string(test), std::string("test"));
}
}

12 changes: 12 additions & 0 deletions Tests/FMT/Index.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include "ProjectCore/Tester/TestSuite/AllTestSuite.h"
#include "ProjectCore/FMT/FMT.h"

#include "BaseFMTTests.h"

/*
PCT_TEST_GROUP(FMT, INDEX);
PCT_TEST_FUNC(INDEX, ReIndexing)
{
}
*/
Loading

0 comments on commit cb460a6

Please sign in to comment.