Skip to content
This repository has been archived by the owner on Feb 5, 2023. It is now read-only.

Commit

Permalink
Merge pull request #64 from kitsudaiki/style/reduce-namespace
Browse files Browse the repository at this point in the history
Style/reduce namespace
  • Loading branch information
kitsudaiki authored Jan 7, 2023
2 parents d06434f + 68a84b7 commit d3896dc
Show file tree
Hide file tree
Showing 20 changed files with 116 additions and 156 deletions.
60 changes: 32 additions & 28 deletions .github/workflows/build_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,28 @@ on: [push]
jobs:
build:
runs-on: ubuntu-latest
container:
image: registry.gitlab.com/kitsudaiki/kitsunemimi-ci-docker-images/normal-tests:1.1.0
container:
image: registry.gitlab.com/kitsudaiki/kitsunemimi-ci-docker-images/normal-tests:1.2.0
name: build-job
steps:
- name: "Checkout repository"
uses: actions/checkout@v3
- name: "Check directory"
run: ls -l ./
- name: "update package-list"
run: apt-get update
- name: "Install missing packages"
run: apt-get install -y libssl-dev
run: |
# use manually clone, because with the "actions/checkout@v3" action the name of the
# branch can not be read by the git commands, which is necessary for the build-script
git clone https://github.com/kitsudaiki/${GITHUB_REPOSITORY#*/}.git
cd ${GITHUB_REPOSITORY#*/}
git checkout ${GITHUB_REF#refs/heads/}
- name: "Build project"
run: ./build.sh test
run: |
cd ${GITHUB_REPOSITORY#*/}
./build.sh test
- name: "Copy files"
run: |
mkdir /build_result
cp -r ../result/* /build_result/
cp ../build/libKitsunemimiJson/tests/unit_tests/unit_tests /build_result/
cp ../build/libKitsunemimiJson/tests/memory_leak_tests/memory_leak_tests /build_result/
cp -r result/* /build_result/
ls build/${GITHUB_REPOSITORY#*/}/tests
cp build/${GITHUB_REPOSITORY#*/}/tests/unit_tests/unit_tests /build_result/
cp build/${GITHUB_REPOSITORY#*/}/tests/memory_leak_tests/memory_leak_tests /build_result/
- name: "Check target-directory"
run: ls -l /build_result
- name: Create artifact
Expand All @@ -35,18 +37,14 @@ jobs:
unit_tests:
needs: build
runs-on: ubuntu-latest
container:
image: registry.gitlab.com/kitsudaiki/kitsunemimi-ci-docker-images/normal-tests:1.1.0
container:
image: registry.gitlab.com/kitsudaiki/kitsunemimi-ci-docker-images/normal-tests:1.2.0
name: unit-test-job
steps:
- name: "Checkout repository"
uses: actions/checkout@v3
- name: "Check directory"
run: ls -l ./
- name: "update package-list"
run: apt-get update
- name: "Install missing packages"
run: apt-get install -y libssl-dev
- name: Get artifact
uses: actions/download-artifact@v3
with:
Expand All @@ -58,23 +56,18 @@ jobs:
run: |
chmod +x /build_result/unit_tests
/build_result/unit_tests
memory_leak_test:
memory_leak_tests:
needs: build
runs-on: ubuntu-latest
container:
image: registry.gitlab.com/kitsudaiki/kitsunemimi-ci-docker-images/normal-tests:1.1.0
volumes:
- build_result:/build_result
container:
image: registry.gitlab.com/kitsudaiki/kitsunemimi-ci-docker-images/normal-tests:1.2.0
name: memory-leak-test-job
steps:
- name: "Checkout repository"
uses: actions/checkout@v3
- name: "Check directory"
run: ls -l ./
- name: "update package-list"
run: apt-get update
- name: "Install missing packages"
run: apt-get install -y libssl-dev
- name: Get artifact
uses: actions/download-artifact@v3
with:
Expand All @@ -87,3 +80,14 @@ jobs:
chmod +x /build_result/memory_leak_tests
/build_result/memory_leak_tests
cleanup:
needs: [unit_tests, memory_leak_tests]
runs-on: ubuntu-latest
container:
image: registry.gitlab.com/kitsudaiki/kitsunemimi-ci-docker-images/normal-tests:1.2.0
name: cleanup-job
steps:
- name: "Delete artifacts"
uses: geekyeggo/delete-artifact@v2
with:
name: result
44 changes: 0 additions & 44 deletions .gitlab-ci.yml

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# libKitsunemimiJson

![Github workfloat status](https://img.shields.io/github/workflow/status/kitsudaiki/libKitsunemimiJson/build-and-test/develop?label=build%20and%20test&style=flat-square)
![Github workfloat status](https://img.shields.io/github/actions/workflow/status/kitsudaiki/libKitsunemimiJson/build_test.yml?branch=develop&style=flat-square&label=build%20and%20test)
![GitHub tag (latest SemVer)](https://img.shields.io/github/v/tag/kitsudaiki/libKitsunemimiJson?label=version&style=flat-square)
![GitHub](https://img.shields.io/github/license/kitsudaiki/libKitsunemimiJson?style=flat-square)
![C++Version](https://img.shields.io/badge/c%2B%2B-17-blue?style=flat-square)
Expand Down Expand Up @@ -94,7 +94,7 @@ const std::string testString(



Kitsunemimi::Json::JsonItem object;
Kitsunemimi::JsonItem object;

// parse the test-string
Kitsunemimi::ErrorContainer error;
Expand Down
59 changes: 49 additions & 10 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# get current directory-path and the path of the parent-directory
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
PARENT_DIR="$(dirname "$DIR")"
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)

# create build-directory
BUILD_DIR="$PARENT_DIR/build"
Expand All @@ -25,40 +26,78 @@ function build_kitsune_lib_repo () {
cd $REPO_DIR

# build repo library with qmake
/usr/lib/x86_64-linux-gnu/qt5/bin/qmake "$PARENT_DIR/$REPO_NAME/$REPO_NAME.pro" -spec linux-g++ "CONFIG += optimize_full $ADDITIONAL_CONFIGS"
/usr/lib/x86_64-linux-gnu/qt5/bin/qmake "$PARENT_DIR/$REPO_NAME/$REPO_NAME.pro" -spec linux-g++ "CONFIG += optimize_full staticlib $ADDITIONAL_CONFIGS"
/usr/bin/make -j$NUMBER_OF_THREADS

# copy build-result and include-files into the result-directory
echo "----------------------------------------------------------------------"
echo $RESULT_DIR
cp $REPO_DIR/src/$REPO_NAME.a $RESULT_DIR/
cp -r $PARENT_DIR/$REPO_NAME/include $RESULT_DIR/
ls -l $RESULT_DIR/include/
ls -l $RESULT_DIR
}

function get_required_kitsune_lib_repo () {
function download_repo_github () {
REPO_NAME=$1
TAG_OR_BRANCH=$2
NUMBER_OF_THREADS=$3
ADDITIONAL_CONFIGS=$4

echo ""
echo ""
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
echo "$REPO_NAME"
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
echo "Branch/Tag: $TAG_OR_BRANCH"

# clone repo
git clone https://github.com/kitsudaiki/$REPO_NAME.git "$PARENT_DIR/$REPO_NAME"
git clone https://github.com/kitsudaiki/$REPO_NAME.git "$PARENT_DIR/$REPO_NAME"
cd "$PARENT_DIR/$REPO_NAME"
git checkout $TAG_OR_BRANCH

build_kitsune_lib_repo $REPO_NAME $NUMBER_OF_THREADS $ADDITIONAL_CONFIGS
# checkout branch
if [[ $CURRENT_BRANCH =~ ^tag.* ]] || [[ $CURRENT_BRANCH =~ ^hotfix.* ]] || [[ $CURRENT_BRANCH =~ ^v.* ]]; then
# if a stable branch, then use the defined tag of branch
# check if defined branch even exist
BRANCH_EXIST=$(git ls-remote --heads origin $TAG_OR_BRANCH)
if [[ -z "$BRANCH_EXIST" ]]; then
echo ""
echo "-------------------------------------------------------------------------------------"
echo "Branch or tag '$TAG_OR_BRANCH' does not exist for the repository '$REPO_NAME'"
echo "-------------------------------------------------------------------------------------"
echo ""
exit 1
fi
git checkout $TAG_OR_BRANCH
else
# if develop or feature branch, then try to checkout the feature-branch in the other repo as well
# or otherwise use the develop-branch as default
BRANCH_EXIST=$(git ls-remote --heads origin $CURRENT_BRANCH)
if [[ -n "$BRANCH_EXIST" ]]; then
git checkout $CURRENT_BRANCH
else
git checkout develop
fi
fi
}

function get_required_kitsune_lib_repo () {
REPO_NAME=$1
TAG_OR_BRANCH=$2
NUMBER_OF_THREADS=$3

download_repo_github $REPO_NAME $TAG_OR_BRANCH
build_kitsune_lib_repo $REPO_NAME $NUMBER_OF_THREADS
}

#-----------------------------------------------------------------------------------------------------------------

get_required_kitsune_lib_repo "libKitsunemimiCommon" "develop" 4 "staticlib"
get_required_kitsune_lib_repo "libKitsunemimiCommon" "develop" 4

#-----------------------------------------------------------------------------------------------------------------

if [ $1 = "test" ]; then
build_kitsune_lib_repo "libKitsunemimiJson" 1 "staticlib run_tests"
build_kitsune_lib_repo "libKitsunemimiJson" 1 "run_tests"
else
build_kitsune_lib_repo "libKitsunemimiJson" 1 "staticlib"
build_kitsune_lib_repo "libKitsunemimiJson" 1 ""
fi

#-----------------------------------------------------------------------------------------------------------------
3 changes: 0 additions & 3 deletions include/libKitsunemimiJson/json_item.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
namespace Kitsunemimi
{
class DataItem;
namespace Json
{

class JsonItem
{
Expand Down Expand Up @@ -102,7 +100,6 @@ class JsonItem
DataItem* m_content = nullptr;
};

} // namespace Json
} // namespace Kitsunemimi

#endif // JSON_ITEM_H
40 changes: 20 additions & 20 deletions src/grammar/json_lexer.l
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
# undef YY_DECL
# endif
# define YY_DECL \
Kitsunemimi::Json::JsonParser::symbol_type jsonlex (Kitsunemimi::Json::JsonParserInterface& driver)
Kitsunemimi::JsonParser::symbol_type jsonlex (Kitsunemimi::JsonParserInterface& driver)
YY_DECL;
Kitsunemimi::Json::location jsonloc;
Kitsunemimi::location jsonloc;

%}

Expand All @@ -49,18 +49,18 @@ blank [ \t]

{blank}+ jsonloc.step();
[\n] {jsonloc.lines(1); jsonloc.step(); }
"{" return Kitsunemimi::Json::JsonParser::make_EXPRESTART (jsonloc);
"}" return Kitsunemimi::Json::JsonParser::make_EXPREEND (jsonloc);
"[" return Kitsunemimi::Json::JsonParser::make_BRACKOPEN (jsonloc);
"]" return Kitsunemimi::Json::JsonParser::make_BRACKCLOSE (jsonloc);
"," return Kitsunemimi::Json::JsonParser::make_COMMA (jsonloc);
":" return Kitsunemimi::Json::JsonParser::make_ASSIGN (jsonloc);
"{" return Kitsunemimi::JsonParser::make_EXPRESTART (jsonloc);
"}" return Kitsunemimi::JsonParser::make_EXPREEND (jsonloc);
"[" return Kitsunemimi::JsonParser::make_BRACKOPEN (jsonloc);
"]" return Kitsunemimi::JsonParser::make_BRACKCLOSE (jsonloc);
"," return Kitsunemimi::JsonParser::make_COMMA (jsonloc);
":" return Kitsunemimi::JsonParser::make_ASSIGN (jsonloc);

"true" return Kitsunemimi::Json::JsonParser::make_BOOL_TRUE (jsonloc);
"false" return Kitsunemimi::Json::JsonParser::make_BOOL_FALSE (jsonloc);
"null" return Kitsunemimi::Json::JsonParser::make_NULLVAL (jsonloc);
"true" return Kitsunemimi::JsonParser::make_BOOL_TRUE (jsonloc);
"false" return Kitsunemimi::JsonParser::make_BOOL_FALSE (jsonloc);
"null" return Kitsunemimi::JsonParser::make_NULLVAL (jsonloc);

\"(\\.|[^"\\])*\" { return Kitsunemimi::Json::JsonParser::make_STRING(yytext, jsonloc); }
\"(\\.|[^"\\])*\" { return Kitsunemimi::JsonParser::make_STRING(yytext, jsonloc); }
{long} {
errno = 0;
Expand All @@ -71,35 +71,35 @@ blank [ \t]
{
driver.error(jsonloc, "integer is out of range");
}
return Kitsunemimi::Json::JsonParser::make_NUMBER (length, jsonloc);
return Kitsunemimi::JsonParser::make_NUMBER (length, jsonloc);
}
{double} {
double value = strtod( yytext , NULL );
return Kitsunemimi::Json::JsonParser::make_FLOAT(value, jsonloc);
return Kitsunemimi::JsonParser::make_FLOAT(value, jsonloc);
}
{id} return Kitsunemimi::Json::JsonParser::make_IDENTIFIER(yytext, jsonloc);
{id} return Kitsunemimi::JsonParser::make_IDENTIFIER(yytext, jsonloc);
[a-zA-Z_0-9|\-|.]* {
return Kitsunemimi::Json::JsonParser::make_STRING_PLN(yytext, jsonloc);
return Kitsunemimi::JsonParser::make_STRING_PLN(yytext, jsonloc);
}
. driver.error(jsonloc, "invalid character");
<<EOF>> return Kitsunemimi::Json::JsonParser::make_END(jsonloc);
<<EOF>> return Kitsunemimi::JsonParser::make_END(jsonloc);
%%
void Kitsunemimi::Json::JsonParserInterface::scan_begin(const std::string &inputString)
void Kitsunemimi::JsonParserInterface::scan_begin(const std::string &inputString)
{
Kitsunemimi::Json::location newJsonloc;
Kitsunemimi::location newJsonloc;
jsonloc = newJsonloc;
yy_flex_debug = m_traceParsing;
yy_scan_string(inputString.c_str());
}
void Kitsunemimi::Json::JsonParserInterface::scan_end()
void Kitsunemimi::JsonParserInterface::scan_end()
{
yy_delete_buffer(YY_CURRENT_BUFFER);
}
Expand Down
Loading

0 comments on commit d3896dc

Please sign in to comment.