Skip to content

Commit

Permalink
Add Core cpp (#182)
Browse files Browse the repository at this point in the history
* resolve #176, add cpp core source code
  • Loading branch information
messixukejia authored Jun 29, 2022
1 parent 19456af commit 182267f
Show file tree
Hide file tree
Showing 411 changed files with 72,254 additions and 439 deletions.
67 changes: 67 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# clang-format -i --style=file <file>
# find . -iname '*.cpp' -o -iname '*.h' | xargs clang-format -i
# help: https://clang.llvm.org/docs/ClangFormatStyleOptions.html
BasedOnStyle: Google
Language: Cpp

AlignAfterOpenBracket: Align
BreakConstructorInitializersBeforeComma: false
Cpp11BracedListStyle: true
ColumnLimit: 120
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ExperimentalAutoDetectBinPacking: true
UseTab: Never
PointerAlignment: Left
MaxEmptyLinesToKeep: 2
KeepEmptyLinesAtTheStartOfBlocks: false
AllowShortFunctionsOnASingleLine: InlineOnly
AlwaysBreakTemplateDeclarations: true
IndentCaseLabels: true
SpaceAfterTemplateKeyword: true
SpaceBeforeCpp11BracedList: false
SortIncludes: false
ReflowComments: false
AlignEscapedNewlinesLeft: false
AlignEscapedNewlines: DontAlign
AlignTrailingComments: false

TabWidth: 4
IndentWidth: 4
AccessModifierOffset: -4
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
AlignConsecutiveAssignments: false
AlignOperands: false
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakBeforeMultilineStrings: false
BinPackArguments: false
BinPackParameters: false
BreakBeforeBinaryOperators: All
BreakBeforeTernaryOperators: true
CommentPragmas: '^ IWYU pragma:'
DerivePointerAlignment: false
DisableFormat: false
IndentWrappedFunctionNames: false
MacroBlockBegin: ''
MacroBlockEnd: ''
NamespaceIndentation: Inner
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
SpaceAfterCStyleCast: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# ignore build artifacts
build/
bin/
4 changes: 2 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ jobs:
with:
submodules: true

- name: Build
run: make build
- name: Build pure plugin
run: make plugin_main

- name: Build Docker
if: matrix.runner == 'ubuntu-latest'
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ jobs:
- name: E2E Test
run: make e2e

- name: UnitTest E2e Engine
if: matrix.runner == 'ubuntu'
run: make unittest_e2e_engine

result:
runs-on: ubuntu-latest
timeout-minutes: 30
Expand Down
12 changes: 4 additions & 8 deletions .github/workflows/static-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ jobs:
if: matrix.runner == 'ubuntu'
run: sudo apt-get clean && sudo apt-get update && sudo apt-get install -y libsystemd-dev


- name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@v2
with:
Expand All @@ -64,15 +63,12 @@ jobs:
- name: Lint
run: make lint

- name: Test
run: make test
- name: UnitTest
run: make unittest_plugin

- name: Test Core
run: make core-test
- name: UnitTest PluginManager
run: make unittest_pluginmanager

- name: Test E2e Engine
if: matrix.runner == 'ubuntu'
run: make test-e2e-engine

result:
runs-on: ubuntu-latest
Expand Down
42 changes: 33 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,17 +1,41 @@
main/main
# editor
*.swp
*.swo
.DS_Store
# ctags generated file.
/tags
# backup files.
*.bak

# go
plugin_main/plugin_main
pluginmanager/checkpoint/
*.txt
*.prof
*.gif
main/checkpoint/*
plugin_main/checkpoint/*
*.LOG
*.LOG.*
*.test
*.swp
.idea/
plugin_logger.xml
logtail_plugin.LOG*
plugins/input/input_telegraf/local_test/telegraf.conf
license_coverage.txt

# C++
CMakeFiles
CMakeCache.txt
*.cmake
Makefile
*.cbp
*.a
core/log_pb/*.pb.*
core/build/
core/common/Version.cpp
core/installer/public/
!/Makefile
!core/dependencies.cmake
!core/utils.cmakels
!core/libulogfs.a

# output
e2e-test
bin/
bin/
build/
find_licenses/
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"type": "go",
"request": "launch",
"mode": "debug",
"program": "${workspaceFolder}/main",
"program": "${workspaceFolder}/plugin_main",
"buildFlags": "-mod=vendor",
"env": {

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ your changes, such as:

- [public] [both] [updated] add a new feature
## [Unreleased]
- [public] [both] [added] add cpp core source code
98 changes: 50 additions & 48 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.

VERSION ?= github-latest
DOCKER_TYPE ?= default
.DEFAULT_GOAL := all
VERSION ?= 1.1.0
DOCKER_PUSH ?= false
DOCKER_REPOSITORY ?= aliyun/ilogtail
BUILD_REPOSITORY ?= aliyun/ilogtail_build
GENERATED_HOME ?= generated_files

SCOPE ?= .
BINARY = logtail-plugin
Expand Down Expand Up @@ -57,6 +59,7 @@ clean:
rm -rf core-test
rm -rf e2e-engine-coverage.txt
rm -rf find_licenses
rm -rf $(GENERATED_HOME)

.PHONY: license
license: clean tools
Expand All @@ -78,44 +81,38 @@ lint-pkg: clean tools
lint-e2e: clean tools
cd test && pwd && $(GO_LINT) run -v --timeout 5m ./...

.PHONY: build
build: clean
./scripts/build.sh vendor default
.PHONY: core
core: clean
./scripts/gen_build_scripts.sh core $(GENERATED_HOME) $(VERSION) $(BUILD_REPOSITORY)
./scripts/docker_build.sh build $(GENERATED_HOME) $(VERSION) $(BUILD_REPOSITORY) false
./$(GENERATED_HOME)/gen_copy_docker.sh

.PHONY: plugin
plugin: clean
./scripts/gen_build_scripts.sh plugin $(GENERATED_HOME) $(VERSION) $(BUILD_REPOSITORY)
./scripts/docker_build.sh build $(GENERATED_HOME) $(VERSION) $(BUILD_REPOSITORY) false
./$(GENERATED_HOME)/gen_copy_docker.sh

.PHONY: plugin_main
plugin_main: clean
./scripts/plugin_build.sh vendor default
cp pkg/logtail/libPluginAdapter.so bin/libPluginAdapter.so
cp pkg/logtail/PluginAdapter.dll bin/PluginAdapter.dll

.PHONY: cgobuild
cgobuild: clean
./scripts/build.sh vendor c-shared

.PHONY: gocbuild
gocbuild: clean
./scripts/gocbuild.sh

.PHONY: docker
docker: clean
./scripts/docker-build.sh $(VERSION) $(DOCKER_TYPE) $(DOCKER_REPOSITORY) $(DOCKER_PUSH)

# coveragedocker compile with goc to analysis the coverage in e2e testing
coveragedocker: clean
./scripts/docker-build.sh $(VERSION) coverage $(DOCKER_REPOSITORY) $(DOCKER_PUSH)

# provide base environment for ilogtail
basedocker: clean
./scripts/docker-build.sh $(VERSION) base $(DOCKER_REPOSITORY) $(DOCKER_PUSH)
./scripts/gen_build_scripts.sh all $(GENERATED_HOME) $(VERSION) $(DOCKER_REPOSITORY)
./scripts/docker_build.sh default $(GENERATED_HOME) $(VERSION) $(DOCKER_REPOSITORY) $(DOCKER_PUSH)

.PHONY: wholedocker
wholedocker: clean
./scripts/docker-build.sh $(VERSION) whole $(DOCKER_REPOSITORY) $(DOCKER_PUSH)

.PHONY: solib
solib: clean
./scripts/docker-build.sh $(VERSION) lib "aliyun/ilogtail" false && ./scripts/solib.sh
.PHONY: e2edocker
e2edocker: clean
./scripts/gen_build_scripts.sh e2e $(GENERATED_HOME) $(VERSION) $(DOCKER_REPOSITORY)
./scripts/docker_build.sh default $(GENERATED_HOME) $(VERSION) $(DOCKER_REPOSITORY) false

# provide a goc server for e2e testing
.PHONY: gocdocker
gocdocker: clean
docker build -t goc-server:latest --no-cache . -f ./docker/Dockerfile_goc
./scripts/docker_build.sh goc $(GENERATED_HOME) latest goc-server false

.PHONY: vendor
vendor: clean
Expand All @@ -125,7 +122,7 @@ vendor: clean

.PHONY: check-dependency-licenses
check-dependency-licenses: clean
./scripts/dependency_licenses.sh main LICENSE_OF_ILOGTAIL_DEPENDENCIES.md && ./scripts/dependency_licenses.sh test LICENSE_OF_TESTENGINE_DEPENDENCIES.md
./scripts/dependency_licenses.sh plugin_main LICENSE_OF_ILOGTAIL_DEPENDENCIES.md && ./scripts/dependency_licenses.sh test LICENSE_OF_TESTENGINE_DEPENDENCIES.md

.PHONY: docs
docs: clean build
Expand All @@ -137,34 +134,39 @@ e2e-docs: clean

# e2e test
.PHONY: e2e
e2e: clean gocdocker coveragedocker
e2e: clean gocdocker e2edocker
TEST_DEBUG=$(TEST_DEBUG) TEST_PROFILE=$(TEST_PROFILE) ./scripts/e2e.sh behavior $(TEST_SCOPE)

.PHONY: e2e-core
e2e-core: clean gocdocker coveragedocker
e2e-core: clean gocdocker e2edocker
TEST_DEBUG=$(TEST_DEBUG) TEST_PROFILE=$(TEST_PROFILE) ./scripts/e2e.sh core $(TEST_SCOPE)

.PHONY: e2e-performance
e2e-performance: clean docker
e2e-performance: clean docker gocdocker
TEST_DEBUG=$(TEST_DEBUG) TEST_PROFILE=$(TEST_PROFILE) ./scripts/e2e.sh performance $(TEST_SCOPE)

# unit test
.PHONY: test-e2e-engine
test-e2e-engine: clean gocdocker coveragedocker
.PHONY: unittest_e2e_engine
unittest_e2e_engine: clean gocdocker
cd test && go test ./... -coverprofile=../e2e-engine-coverage.txt -covermode=atomic -tags docker_ready

.PHONY: test
test: clean
cp pkg/logtail/libPluginAdapter.so ./main
cp pkg/logtail/PluginAdapter.dll ./main
.PHONY: unittest_plugin
unittest_plugin: clean
cp pkg/logtail/libPluginAdapter.so ./plugin_main
cp pkg/logtail/PluginAdapter.dll ./plugin_main
mv ./plugins/input/prometheus/input_prometheus.go ./plugins/input/prometheus/input_prometheus.go.bak
go test $$(go list ./...|grep -Ev "vendor|telegraf|external|envconfig|(input\/prometheus)|(input\/syslog)"| grep -Ev "main|pluginmanager") -coverprofile .testCoverage.txt
go test $$(go list ./...|grep -Ev "vendor|telegraf|external|envconfig|(input\/prometheus)|(input\/syslog)"| grep -Ev "plugin_main|pluginmanager") -coverprofile .testCoverage.txt
mv ./plugins/input/prometheus/input_prometheus.go.bak ./plugins/input/prometheus/input_prometheus.go

.PHONY: core-test
core-test: clean
cp pkg/logtail/libPluginAdapter.so ./main
cp pkg/logtail/PluginAdapter.dll ./main
.PHONY: unittest_pluginmanager
unittest_pluginmanager: clean
cp pkg/logtail/libPluginAdapter.so ./plugin_main
cp pkg/logtail/PluginAdapter.dll ./plugin_main
mv ./plugins/input/prometheus/input_prometheus.go ./plugins/input/prometheus/input_prometheus.go.bak
go test $$(go list ./...|grep -Ev "vendor|telegraf|external|envconfig|()"| grep -E "main|pluginmanager") -coverprofile .coretestCoverage.txt
mv ./plugins/input/prometheus/input_prometheus.go.bak ./plugins/input/prometheus/input_prometheus.go
go test $$(go list ./...|grep -Ev "vendor|telegraf|external|envconfig|()"| grep -E "plugin_main|pluginmanager") -coverprofile .coretestCoverage.txt
mv ./plugins/input/prometheus/input_prometheus.go.bak ./plugins/input/prometheus/input_prometheus.go

.PHONY: all
all: clean
./scripts/gen_build_scripts.sh all $(GENERATED_HOME) $(VERSION) $(BUILD_REPOSITORY)
./scripts/docker_build.sh build $(GENERATED_HOME) $(VERSION) $(BUILD_REPOSITORY) false
./$(GENERATED_HOME)/gen_copy_docker.sh
Loading

0 comments on commit 182267f

Please sign in to comment.