-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature:Autograding] tree-sitter c-api (#2)
* Initial C-API * Update readme * Initial class implementation * Add function call counting * Refactor header * Add c counting * Fix function counting * Fix requested changes * Update source sh scripts * Add cpp shell static checks * Add function counting * File glob handling and format * Update cmakelists * Fix function changes * Update actions * Remove test.yml * Initial diagnostics * Refactor diagnostics * Add nlohmann json * Fix shell-check * Format json output * Add fixes * Add identifier counting * Add c++ * Update counting * Add tests for executable * Update test.yml * check * Fix file name * Switch user * Change to sudo * FIx format * Spaces for tabs
- Loading branch information
1 parent
046c660
commit a04e1a5
Showing
46 changed files
with
667 additions
and
10,891 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: Static analysis | ||
on: [push] | ||
|
||
jobs: | ||
cppcheck: | ||
name: Cppcheck | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: install cpp-check | ||
run: sudo apt-get install -y cppcheck | ||
- name: run cpp-check | ||
run: cppcheck src/ | ||
|
||
shellcheck: | ||
name: Shellcheck | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: install shellcheck | ||
run: sudo apt-get install -y shellcheck | ||
- name: run shell-check | ||
run: shellcheck *.sh -e SC1090 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,15 @@ | ||
name: Test | ||
|
||
on: ['push', 'pull_request'] | ||
on: [push] | ||
|
||
jobs: | ||
build: | ||
test: | ||
name: Test | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
# Disable 17.x for now, see https://github.com/tree-sitter/node-tree-sitter/issues/102 | ||
node-version: [16.x] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: npm | ||
|
||
- run: npm install | ||
|
||
- run: npm run lint | ||
|
||
- run: npm run build | ||
|
||
- run: npm run test | ||
|
||
- uses: codecov/codecov-action@v2 | ||
- uses: actions/checkout@v2 | ||
- name: Change permission | ||
run: chmod +x install_analysistoolsts.sh | ||
- name: Build executable | ||
run: sudo ./install_analysistoolsts.sh local | ||
- name: run tests | ||
run: python testRunner.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,2 @@ | ||
node_modules/ | ||
.DS_Store | ||
|
||
# build artifacts | ||
dist/ | ||
|
||
# test artifacts | ||
.nyc_output/ | ||
coverage/ | ||
include/ | ||
build/ |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
cmake_minimum_required(VERSION 3.16.3) | ||
|
||
project(analysis_tools_ts) | ||
|
||
set(JSONCODE include/json/include/) | ||
|
||
if(JSONDIR) | ||
set(JSONCODE ${JSONDIR}) | ||
endif() | ||
|
||
add_library(tree-sitter-python include/tree-sitter-python/src/parser.c | ||
include/tree-sitter-python/src/scanner.cc) | ||
|
||
add_library(tree-sitter-cpp include/tree-sitter-cpp/src/parser.c | ||
include/tree-sitter-cpp/src/scanner.cc) | ||
|
||
add_library(tree-sitter-c include/tree-sitter-c/src/parser.c) | ||
|
||
link_libraries(tree-sitter-python tree-sitter-c tree-sitter-cpp | ||
${PROJECT_SOURCE_DIR}/include/tree-sitter/libtree-sitter.a) | ||
|
||
add_executable(submitty_count_ts src/count.cpp src/parser.cpp src/utils.cpp) | ||
|
||
add_executable(submitty_diagnostics_ts src/diagnostics.cpp src/parser.cpp | ||
src/utils.cpp) | ||
|
||
include_directories(include/tree-sitter/lib/include) | ||
|
||
target_include_directories(submitty_diagnostics_ts PUBLIC ${JSONCODE}) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
#!/usr/bin/env bash | ||
|
||
######################################################################################################################## | ||
######################################################################################################################## | ||
# this script must be run by root or sudo | ||
if [[ "$UID" -ne "0" ]] ; then | ||
echo "ERROR: This script must be run by root or sudo" | ||
exit 1 | ||
fi | ||
|
||
VARS="$(dirname "$0")"/submitty.sh | ||
|
||
if [ $# -gt 0 ] && [ "$1" == "local" ]; then | ||
VARS="$(dirname "$0")"/local.sh | ||
fi | ||
|
||
source "${VARS}" | ||
|
||
echo -e "Installing AnalysisToolsTS... " | ||
|
||
mkdir -p "${INSTALLATION_DIR}" | ||
|
||
# Copy cloned files to AnalysisToolsTS directory | ||
rsync -rtz "${REPO_DIR}" "${INSTALLATION_DIR}" | ||
|
||
mkdir -p "${INCLUDE_DIR}" | ||
|
||
######################################################################## | ||
|
||
# Clone the tree-sitter repos | ||
repos=( tree-sitter tree-sitter-python tree-sitter-c tree-sitter-cpp) | ||
|
||
for repo in "${repos[@]}" | ||
do | ||
dir="${INCLUDE_DIR}"/"${repo}" | ||
|
||
echo "clone or update ${repo}... " | ||
|
||
if [ -d "${dir}" ]; then | ||
echo "pulling changes ..." | ||
# IF THE REPO ALREADY EXISTS... | ||
pushd "${dir}" || exit | ||
|
||
# PULL CHANGES | ||
git fetch | ||
git reset --hard HEAD | ||
git merge origin/"$CURRENT_BRANCH" | ||
popd || exit | ||
|
||
else | ||
# THE REPO DID NOT EXIST | ||
echo "the repository did not previously exist cloning... " | ||
pushd "${INCLUDE_DIR}" || exit | ||
git clone --depth 1 "https://github.com/tree-sitter/${repo}" || exit | ||
popd || exit | ||
|
||
fi | ||
done | ||
|
||
# CHECKOUT & INSTALL THE NLOHMANN C++ JSON LIBRARY | ||
# If we don't already have a copy of this repository, check it out, only for local development | ||
if [ $# -gt 0 ] && [ ! -d "${NLOHMANN_DIR}" ]; then | ||
git clone --depth 1 "https://github.com/nlohmann/json.git" "${NLOHMANN_DIR}" | ||
fi | ||
|
||
######################################################################## | ||
|
||
# build tree sitter library | ||
pushd "${INCLUDE_DIR}"/tree-sitter || exit | ||
|
||
make | ||
|
||
popd || exit | ||
|
||
echo "building submitty_count_ts ..." | ||
|
||
# Compile the project | ||
mkdir -p "${INSTALLATION_DIR}/build" | ||
|
||
cmake -S "${INSTALLATION_DIR}" -B "${INSTALLATION_DIR}/build" -DJSONDIR="${NLOHMANN_INCLUDE_DIR}" | ||
|
||
pushd "${INSTALLATION_DIR}/build" || exit | ||
|
||
make | ||
|
||
popd || exit | ||
|
||
# # change permissions | ||
if [ $# -eq 0 ]; then | ||
chown -R root:root "${INSTALLATION_DIR}" | ||
chmod -R 755 "${INSTALLATION_DIR}" | ||
fi | ||
|
||
echo "Done setting up AnalysisToolsTS" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
REPO_DIR=$(pwd) | ||
export REPO_DIR=. | ||
export INSTALLATION_DIR=. | ||
export INCLUDE_DIR=include | ||
export NLOHMANN_DIR=include/json | ||
export NLOHMANN_INCLUDE_DIR=include/json/include/ |
Oops, something went wrong.