Skip to content

Commit

Permalink
Adding a C++ buid
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisdutz authored May 6, 2024
1 parent 12e5308 commit 571a6da
Show file tree
Hide file tree
Showing 518 changed files with 955 additions and 90 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,4 @@ jobs:
# Run the actual maven build including all unit- and integration-tests.
- name: Build and test with Maven (All others)
shell: bash
run: ./mvnw${{ steps.platform_suffix.outputs.platform_suffix }} clean verify
run: ./mvnw${{ steps.platform_suffix.outputs.platform_suffix }} -P with-java,with-cpp clean verify
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/.mvn/.gradle-enterprise/gradle-enterprise-workspace-id
/.mvn/wrapper/maven-wrapper.jar
**/target/**
/tsfile/test.tsfile
/java/tsfile/test.tsfile

# intellij IDE files
**/*.iml
Expand All @@ -15,4 +15,4 @@
docs/node_modules/
docs/src/.vuepress/.cache/
docs/src/.vuepress/.temp/
docs/src/.vuepress/dist/
docs/src/.vuepress/dist/
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ pipeline {
}
steps {
echo 'Building and Unit Test...'
sh "mvn ${MVN_TEST_FAIL_IGNORE} clean install"
sh "mvn ${MVN_TEST_FAIL_IGNORE} -P with-java,with-cpp clean install"
}
post {
always {
Expand Down
84 changes: 84 additions & 0 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#[[
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
]]

cmake_minimum_required(VERSION 3.20)

# Set the name of this project
project(TsFile)

# Set the C language level to C11
set(CMAKE_C_STANDARD 11)

# Save the root directory
set(TSFILE_ROOT_DIR ${CMAKE_SOURCE_DIR})

# Our link to the maven lifecycle
set(BUILD_PHASE test-compile CACHE STRING "Phase of the Maven build we are executing cmake")

# Access the Unity version the maven build is providing us with.
set(UNITY_VERSION 2.5.2 CACHE STRING "Version of the used Unity test framework")

# MinGW GCC versions above 4.7 on Windows include inline definitions of these functions
# If you run into problems, please read this article: https://stackoverflow.com/questions/27853225/is-there-a-way-to-include-stdio-h-but-ignore-some-of-the-functions-therein
# These are the constants needed to activate all patches.
add_compile_definitions(NO_INLINE_VFSCANF=1)
add_compile_definitions(NO_INLINE_VSSCANF=1)
add_compile_definitions(NO_INLINE_VSCANF=1)
add_compile_definitions(NO_INLINE_VSNPRINTF=1)
add_compile_definitions(NO_INLINE_SNPRINTF=1)
add_compile_definitions(NO_INLINE_VFWSCANF=1)
add_compile_definitions(NO_INLINE_VSWSCANF=1)
add_compile_definitions(NO_INLINE_VWSCANF=1)
add_compile_definitions(NO_INLINE_SNWPRINTF=1)
add_compile_definitions(NO_INLINE_VSNWPRINTF=1)
add_compile_definitions(NO_INLINE_VSWPRINTF=1)
add_compile_definitions(NO_INLINE_SWPRINTF=1)

# Depending on the phase of the build we are currently running, initialize
# The test system.
if (BUILD_PHASE STREQUAL compile)
# Nothing really to do here ... just need it to check the known values.
elseif (BUILD_PHASE STREQUAL test-compile)
# Initialize the test subsystem as well as the Unity library sources
include(CTest)

# Add the Unity sources to the build
add_subdirectory(target/dependency/Unity-${UNITY_VERSION})
else ()
# Output an error
message(FATAL_ERROR "Given BUILD_PHASE unknown. Known values are 'compile' and 'test-compile'")
endif ()

set(DEBUG_OUTPUT ON CACHE BOOL "Enable outputting of debug information")
if (DEBUG_OUTPUT)
# Trace all CMAKE Variables
get_cmake_property(_variableNames VARIABLES)
list(SORT _variableNames)
foreach (_variableName ${_variableNames})
message(STATUS "${_variableName}=${${_variableName}}")
endforeach ()
endif ()

#[[
Build all the modules of TSFILE
]]
# Core stuff
add_subdirectory(common)
add_subdirectory(examples)
add_subdirectory(tsfile)
36 changes: 36 additions & 0 deletions cpp/build-utils/source-bundle-descriptor.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.2.0 http://maven.apache.org/xsd/assembly-2.2.0.xsd">
<id>sources</id>
<formats>
<format>zip</format>
</formats>
<fileSets>
<fileSet>
<directory>${basedir}</directory>
<includes>
<include>common/**</include>
<include>examples/**</include>
<include>tsfile/**</include>
<include>CMakeLists.txt</include>
</includes>
</fileSet>
</fileSets>
</assembly>
48 changes: 48 additions & 0 deletions cpp/common/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#[[
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
]]

add_library(tsfile-common
src/common.cpp
)

target_include_directories(
tsfile-common
PUBLIC
"include")

IF (NOT WIN32)
target_link_libraries(tsfile-common
m
)
ELSE()
target_link_libraries(tsfile-common
)
ENDIF()

if (BUILD_PHASE STREQUAL test-compile)
add_executable(tsfile-common-test
test/common_test.cpp
)
target_link_libraries(tsfile-common-test
tsfile-common
unity

)
add_test(NAME tsfile-common-test COMMAND tsfile-common-test)
endif ()
30 changes: 30 additions & 0 deletions cpp/common/include/common.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
#ifndef TSFILE_COMMON_H
#define TSFILE_COMMON_H

class Common
{
public:
Common();

int doSomething(int a, int b) const;
};

#endif
27 changes: 27 additions & 0 deletions cpp/common/src/common.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
#include "common.hpp"

Common::Common() {
// Not really doing anything here ...
}

int Common::doSomething(int a, int b) const {
return a+b;
}
24 changes: 24 additions & 0 deletions cpp/common/test/common_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
#include <cstdio>

int main() {
printf("Test");
return 0;
}
50 changes: 50 additions & 0 deletions cpp/examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#[[
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
]]

add_library(tsfile-examples
src/example.cpp
)

target_include_directories(
tsfile-examples
PUBLIC
"include"
"../common/include"
"../tsfile/include")

IF (NOT WIN32)
target_link_libraries(tsfile-examples
m
)
ELSE()
target_link_libraries(tsfile-examples
)
ENDIF()

#if (BUILD_PHASE STREQUAL test-compile)
# add_executable(tsfile-examples-test
# test/system_test.c
# )
# target_link_libraries(tsfile-examples-test
# tsfile-examples
# unity
#
# )
# add_test(NAME tsfile-examples-test COMMAND tsfile-examples-test)
#endif ()
24 changes: 24 additions & 0 deletions cpp/examples/include/example.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
#ifndef TSFILE_EXAMPLE_H
#define TSFILE_EXAMPLE_H

// Not much to do here ...

#endif
29 changes: 29 additions & 0 deletions cpp/examples/src/example.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
#include <cstdio>

#include "tsfile.hpp"

int main()
{
TsFile* tsFile = new TsFile();
int result = tsFile->doSomethingElse(10, 20, 3);
printf("Result = %d", result);
return 0;
}
Loading

0 comments on commit 571a6da

Please sign in to comment.