Skip to content

Commit

Permalink
Dev/v1.1.0 (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorKilipenko committed May 14, 2024
1 parent 3302c8c commit 3c0616c
Show file tree
Hide file tree
Showing 684 changed files with 271 additions and 158,365 deletions.
31 changes: 31 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
FROM mcr.microsoft.com/devcontainers/cpp:1-ubuntu-22.04

ARG REINSTALL_CMAKE_VERSION_FROM_SOURCE="3.29.3"
ARG REINSTALL_CLANG_VERSION_FROM_SOURCE="17"

# Optionally install the cmake for vcpkg
COPY ./reinstall-cmake.sh /tmp/

RUN if [ "${REINSTALL_CMAKE_VERSION_FROM_SOURCE}" != "none" ]; then \
chmod +x /tmp/reinstall-cmake.sh && /tmp/reinstall-cmake.sh ${REINSTALL_CMAKE_VERSION_FROM_SOURCE}; \
fi \
&& rm -f /tmp/reinstall-cmake.sh

# Install apt packages
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends \
openjdk-17-jdk \
libtbb-dev \
wget \
software-properties-common \
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*

# Reinstall clang
COPY ./reinstall-clang.sh /tmp/

RUN if [ "${REINSTALL_CLANG_VERSION_FROM_SOURCE}" != "none" ]; then \
chmod +x /tmp/reinstall-clang.sh && /tmp/reinstall-clang.sh ${REINSTALL_CLANG_VERSION_FROM_SOURCE}; \
fi \
&& rm -f /tmp/reinstall-clang.sh
17 changes: 17 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/cpp
{
"name": "C++",
"build": {
"dockerfile": "Dockerfile"
},
"customizations": {
"vscode": {
"extensions": [
"llvm-vs-code-extensions.vscode-clangd",
"streetsidesoftware.code-spell-checker",
"donjayamanne.githistory"
]
}
}
}
43 changes: 43 additions & 0 deletions .devcontainer/reinstall-clang.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env bash

set -e

CLANG_VERSION=${1:-"none"}

if [ "${CLANG_VERSION}" = "none" ]; then
echo "No Clang version specified, skipping Clang reinstallation"
exit 0
fi

# Remove installed Clang
echo "Removing existing Clang installation..."
apt-get -y purge --auto-remove clang && apt-get autoremove -y && apt-get clean -y
rm -rf /var/lib/apt/lists/*
echo "Clang removal completed."

# Install LLVM
echo "Downloading and installing LLVM ${CLANG_VERSION}..."
wget -O /tmp/llvm.sh https://apt.llvm.org/llvm.sh
chmod +x /tmp/llvm.sh
/tmp/llvm.sh ${CLANG_VERSION} all
rm -f /tmp/llvm.sh
echo "LLVM installation completed."

# Update alternatives for clang, clang++, and clangd
update_alternatives() {
local tool=$1
local version=$2
if [ -f /usr/bin/${tool}-${version} ]; then
update-alternatives --install /usr/bin/${tool} ${tool} /usr/bin/${tool}-${version} 100
echo "${tool}-${version} set as default."
else
echo "${tool}-${version} not found, skipping."
fi
}

echo "Updating alternatives for clang, clang++, and clangd..."
update_alternatives "clang" ${CLANG_VERSION}
update_alternatives "clang++" ${CLANG_VERSION}
update_alternatives "clangd" ${CLANG_VERSION}

echo "Clang ${CLANG_VERSION} installation and configuration completed."
59 changes: 59 additions & 0 deletions .devcontainer/reinstall-cmake.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/usr/bin/env bash
#-------------------------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
#-------------------------------------------------------------------------------------------------------------
#
set -e

CMAKE_VERSION=${1:-"none"}

if [ "${CMAKE_VERSION}" = "none" ]; then
echo "No CMake version specified, skipping CMake reinstallation"
exit 0
fi

# Cleanup temporary directory and associated files when exiting the script.
cleanup() {
EXIT_CODE=$?
set +e
if [[ -n "${TMP_DIR}" ]]; then
echo "Executing cleanup of tmp files"
rm -Rf "${TMP_DIR}"
fi
exit $EXIT_CODE
}
trap cleanup EXIT


echo "Installing CMake..."
apt-get -y purge --auto-remove cmake
mkdir -p /opt/cmake

architecture=$(dpkg --print-architecture)
case "${architecture}" in
arm64)
ARCH=aarch64 ;;
amd64)
ARCH=x86_64 ;;
*)
echo "Unsupported architecture ${architecture}."
exit 1
;;
esac

CMAKE_BINARY_NAME="cmake-${CMAKE_VERSION}-linux-${ARCH}.sh"
CMAKE_CHECKSUM_NAME="cmake-${CMAKE_VERSION}-SHA-256.txt"
TMP_DIR=$(mktemp -d -t cmake-XXXXXXXXXX)

echo "${TMP_DIR}"
cd "${TMP_DIR}"

curl -sSL "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/${CMAKE_BINARY_NAME}" -O
curl -sSL "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/${CMAKE_CHECKSUM_NAME}" -O

sha256sum -c --ignore-missing "${CMAKE_CHECKSUM_NAME}"
sh "${TMP_DIR}/${CMAKE_BINARY_NAME}" --prefix=/opt/cmake --skip-license

ln -s /opt/cmake/bin/cmake /usr/local/bin/cmake
ln -s /opt/cmake/bin/ctest /usr/local/bin/ctest
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = false
insert_final_newline = false
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for more information:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
# https://containers.dev/guide/dependabot

version: 2
updates:
- package-ecosystem: "devcontainers"
directory: "/"
schedule:
interval: weekly
10 changes: 10 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"recommendations": [
"ms-vscode.cpptools",
"josetr.cmake-language-support-vscode",
"llvm-vs-code-extensions.vscode-clangd",
"streetsidesoftware.code-spell-checker",
"donjayamanne.githistory",
"jeff-hykin.better-cpp-syntax"
]
}
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"value": "$PATH:${command:cmake.launchTargetDirectory}"
}
],
"externalConsole": true,
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
Expand Down
13 changes: 9 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
cmake_minimum_required(VERSION 3.14)
cmake_minimum_required(VERSION 3.24)
set(CMAKE_VERBOSE_MAKEFILE ON)
set(PROJECT_NAME "cpp-spreadsheet")
project(${PROJECT_NAME} VERSION 1.0.1 LANGUAGES CXX)

add_subdirectory("./spreadsheet")
project(cpp-spreadsheet-app VERSION 1.1.0 LANGUAGES CXX)

# Set C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)

# Add subdirectory with the library
add_subdirectory(spreadsheet)
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# cpp-spreadsheet
Дипломный проект: Электронная таблица
# Cpp-Spreadsheet

## Дипломный проект: Электронная таблица
67 changes: 14 additions & 53 deletions spreadsheet/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,69 +1,30 @@
cmake_minimum_required(VERSION 3.8 FATAL_ERROR)
cmake_minimum_required(VERSION 3.24)
project(spreadsheet)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
set(
CMAKE_CXX_FLAGS_DEBUG
"${CMAKE_CXX_FLAGS_DEBUG} /JMC"
)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /JMC")
else()
set(
CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic -Wno-unused-parameter -Wno-implicit-fallthrough"
)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic -Wno-unused-parameter -Wno-implicit-fallthrough")
endif()

set(ANTLR_EXECUTABLE ${CMAKE_CURRENT_SOURCE_DIR}/antlr-4.12.0-complete.jar)
include(${CMAKE_CURRENT_SOURCE_DIR}/FindANTLR.cmake)

add_definitions(
-DANTLR4CPP_STATIC
-D_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS
)

set(WITH_STATIC_CRT OFF CACHE BOOL "Visual C++ static CRT for ANTLR" FORCE)
add_subdirectory(antlr4_runtime)

antlr_target(FormulaParser Formula.g4 LEXER PARSER LISTENER)

include_directories(
${ANTLR4_INCLUDE_DIRS}
${ANTLR_FormulaParser_OUTPUT_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/antlr4_runtime/runtime/src
)

file(GLOB sources
*.cpp
*.h
)

set(sources_lib ${sources})

list(FILTER sources_lib EXCLUDE REGEX ".*main\\.cpp$")

add_library(
libspreadsheet
${ANTLR_FormulaParser_CXX_OUTPUTS}
${sources_lib}
)

add_executable(
spreadsheet
main.cpp
)
# Find Java
find_package(Java REQUIRED)

target_link_libraries(libspreadsheet antlr4_static)
if(MSVC)
target_compile_options(antlr4_static PRIVATE /W0)
endif()
# Include the ANTLR setup
include(cmake/SetupAntlr.cmake)

target_link_libraries(spreadsheet PRIVATE libspreadsheet)
# Include the source files and create targets
include(cmake/SetupTargets.cmake)

# Install target for spreadsheet
install(
TARGETS spreadsheet
DESTINATION bin
EXPORT libspreadsheet
)

set_directory_properties(PROPERTIES VS_STARTUP_PROJECT spreadsheet)
set_directory_properties(PROPERTIES VS_STARTUP_PROJECT spreadsheet)
Loading

0 comments on commit 3c0616c

Please sign in to comment.