ps contest setting

This commit is contained in:
2026-07-10 19:13:15 +09:00
commit 2e53b25851
9 changed files with 440 additions and 0 deletions
+2
View File
@@ -0,0 +1,2 @@
CompileFlags:
Add: [-I, lib, --std=c++23, -DDEBUG]
+10
View File
@@ -0,0 +1,10 @@
/_archives/
/_contest/
temp
.PS
*.cpp
!lib/*.cpp
.DS_Store
+72
View File
@@ -0,0 +1,72 @@
#!/bin/bash
# version 1.0
path="$HOME/.PS"
path_warning="$path/warning"
path_obj="$path/obj"
path_objmd5="$path/objmd5"
path_output="$path/output.txt"
mkdir -p $path_warning
mkdir -p $path_obj
mkdir -p $path_objmd5
if [ -f "$1.cpp" ] && [ ! -z "$1.cpp" ]; then
md5=`md5sum $1.cpp | cut -f1 -d' '`
name=`basename $1`
echo "$1.cpp : File Exist!"
echo "md5: $md5"
if [ -e "$path_objmd5/$md5" ]; then
read -p "There's excutable file with same md5. Will you excute this?(Y/n) " yesno
if [ -z "$yesno" ] || [[ $yesno =~ [yY] ]] || [[ $yesno =~ [yY][eE][sS] ]]; then
echo -e "---------------- \"$1.cpp(?)\" Standard Input ----------------"
"$path_objmd5/$md5" > $path_output; ret=$?
echo -e "\n-------------------- \"$1.cpp(?)\" output --------------------"
cat $path_output
echo -e "\n----------------------- \"$1.cpp(?)\" ------------------------"
exit 0
fi
fi
copt="g++ $1.cpp -o $path_obj/$1 -O2 -lm -Wall -static -std=c++2a -DDEBUG -Wno-unused-result"
echo "Now Compiling..."
echo "## Name of Source File : $1.cpp" > "$path_warning/$1"
echo "## MD5 of Source File : $md5" >> "$path_warning/$1"
echo "## Compile command : $copt" >> "$path_warning/$1"
ctime=`date +%y%m%d%H%M%S`; echo "## Compile start time : $ctime" >> "$path_warning/$1"
`$copt 2> $path/latest`; res=$?
echo -e "## Compile end time : $(date +%y%m%d%H%M%S)\n" >> "$path_warning/$1"
cat "$path/latest" >> "$path_warning/$1"
echo "Compile Finished!"
cat "$path_warning/$1"
if [ $res -eq 0 ]; then
cp "$path_obj/$1" "$path_objmd5/$md5"
echo -e "---------------- \"$1.cpp\" Standard Input ----------------"
"$path_obj/$1" > $path_output; ret=$?
echo -e "\n-------------------- \"$1.cpp\" output --------------------"
cat $path_output
echo -e "\n----------------------- \"$1.cpp\" ------------------------"
echo -e "\nProgram returned with $ret"
echo -e "Excutable File : $path_obj/$1\n"
else
echo "Compile Failed!"
fi
elif [ -z "$1" ]; then
echo "No string is given!"
else
echo "There's no such file!"
fi
exit 0
+97
View File
@@ -0,0 +1,97 @@
#!/bin/bash
# version 2.0
# BASE : 0 -> executed directory (default)
# BASE : 1 -> home directory
BASE=0
YES=0
while getopts uy flag; do
case "$flag" in
u) BASE=1 ;;
y) YES=1 ;;
\?) usage; exit -1 ;;
esac
done
shift $((OPTIND - 1))
if [ $# -eq 1 ]; then
echo ${!1}
fi
if [ $BASE -eq 0 ]; then
path="${PWD}/.PS"
else
path="$HOME/.PS"
fi
path_warning="$path/warning"
path_obj="$path/obj"
path_objmd5="$path/objmd5"
path_output="$path/output.txt"
mkdir -p $path_warning
mkdir -p $path_obj
mkdir -p $path_objmd5
if [ -f "$1.cpp" ] && [ ! -z "$1.cpp" ]; then
md5=`md5sum $1.cpp | cut -f1 -d' '`
name=`basename $1`
echo "$1.cpp : File Exist!"
echo "md5: $md5"
if [ -e "$path_objmd5/$md5" ]; then
if [ $YES -eq 0 ]; then
read -p "There's excutable file with same md5. Will you excute this?(Y/n) " yesno
fi
if [ -z "$yesno" ] || [[ $yesno =~ [yY] ]] || [[ $yesno =~ [yY][eE][sS] ]]; then
echo -e "---------------- \"$1.cpp(?)\" Standard Input ----------------"
"$path_objmd5/$md5" > $path_output; ret=$?
echo -e "\n-------------------- \"$1.cpp(?)\" output --------------------"
cat $path_output
echo -e "\n----------------------- \"$1.cpp(?)\" ------------------------"
exit 0
fi
fi
copt="g++ $1.cpp -Ilib -Iac-library -fsanitize=undefined,address -o $path_obj/$1 -O2 -lm -Wall -std=c++2a -DDEBUG -Wno-unused-result"
echo "Now Compiling..."
echo "## Name of Source File : $1.cpp" > "$path_warning/$1"
echo "## MD5 of Source File : $md5" >> "$path_warning/$1"
echo "## Compile command : $copt" >> "$path_warning/$1"
ctime=`date +%y%m%d%H%M%S`; echo "## Compile start time : $ctime" >> "$path_warning/$1"
`$copt 2> $path/latest`; res=$?
echo -e "## Compile end time : $(date +%y%m%d%H%M%S)\n" >> "$path_warning/$1"
cat "$path/latest" >> "$path_warning/$1"
echo "Compile Finished!"
cat "$path_warning/$1"
if [ $res -eq 0 ]; then
cp "$path_obj/$1" "$path_objmd5/$md5"
echo -e "---------------- \"$1.cpp\" Standard Input ----------------"
"$path_obj/$1" > $path_output; ret=$?
echo -e "\n-------------------- \"$1.cpp\" output --------------------"
cat $path_output
echo -e "\n----------------------- \"$1.cpp\" ------------------------"
echo -e "\nProgram returned with $ret"
echo -e "Excutable File : $path_obj/$1\n"
else
echo "Compile Failed!"
fi
elif [ -z "$1" ]; then
echo "No string is given!"
else
echo "There's no such file!"
fi
exit 0
+100
View File
@@ -0,0 +1,100 @@
#!/bin/bash
# version 3.0
# BASE : 0 -> executed directory (default)
# BASE : 1 -> home directory
BASE=0
YES=0
USER_INCLUDES=""
while getopts "uyI:" flag; do
case "$flag" in
u) BASE=1 ;;
y) YES=1 ;;
I) USER_INCLUDES="$USER_INCLUDES -I$OPTARG" ;;
\?) usage; exit -1 ;;
esac
done
shift $((OPTIND - 1))
if [ $# -eq 1 ]; then
echo ${!1}
fi
if [ $BASE -eq 0 ]; then
path="${PWD}/.PS"
else
path="$HOME/.PS"
fi
path_warning="$path/warning"
path_obj="$path/obj"
path_objmd5="$path/objmd5"
path_output="$path/output.txt"
mkdir -p $path_warning
mkdir -p $path_obj
mkdir -p $path_objmd5
if [ -f "$1.cpp" ] && [ ! -z "$1.cpp" ]; then
md5=`md5sum $1.cpp | cut -f1 -d' '`
name=`basename $1`
echo "$1.cpp : File Exist!"
echo "md5: $md5"
if [ -e "$path_objmd5/$md5" ]; then
if [ $YES -eq 0 ]; then
read -p "There's excutable file with same md5. Will you excute this?(Y/n) " yesno
fi
if [ -z "$yesno" ] || [[ $yesno =~ [yY] ]] || [[ $yesno =~ [yY][eE][sS] ]]; then
echo -e "---------------- \"$1.cpp(?)\" Standard Input ----------------"
"$path_objmd5/$md5" > $path_output; ret=$?
echo -e "\n-------------------- \"$1.cpp(?)\" output --------------------"
cat $path_output
echo -e "\n----------------------- \"$1.cpp(?)\" ------------------------"
exit 0
fi
fi
# copt="g++ $1.cpp -Ilib -Iac-library -fsanitize=undefined,address -o $path_obj/$1 -O2 -lm -Wall -std=c++2a -DDEBUG -Wno-unused-result"
copt="g++ $1.cpp $USER_INCLUDES -fsanitize=undefined,address -o $path_obj/$1 -O2 -lm -Wall -std=c++2a -DDEBUG -Wno-unused-result"
echo "Now Compiling..."
echo "## Name of Source File : $1.cpp" > "$path_warning/$1"
echo "## MD5 of Source File : $md5" >> "$path_warning/$1"
echo "## Compile command : $copt" >> "$path_warning/$1"
ctime=`date +%y%m%d%H%M%S`; echo "## Compile start time : $ctime" >> "$path_warning/$1"
`$copt 2> $path/latest`; res=$?
echo -e "## Compile end time : $(date +%y%m%d%H%M%S)\n" >> "$path_warning/$1"
cat "$path/latest" >> "$path_warning/$1"
echo "Compile Finished!"
cat "$path_warning/$1"
if [ $res -eq 0 ]; then
cp "$path_obj/$1" "$path_objmd5/$md5"
echo -e "---------------- \"$1.cpp\" Standard Input ----------------"
"$path_obj/$1" > $path_output; ret=$?
echo -e "\n-------------------- \"$1.cpp\" output --------------------"
cat $path_output
echo -e "\n----------------------- \"$1.cpp\" ------------------------"
echo -e "\nProgram returned with $ret"
echo -e "Excutable File : $path_obj/$1\n"
else
echo "Compile Failed!"
fi
elif [ -z "$1" ]; then
echo "No string is given!"
else
echo "There's no such file!"
fi
exit 0
+100
View File
@@ -0,0 +1,100 @@
#!/bin/bash
# version 4.0
# BASE : 0 -> executed directory (default)
# BASE : 1 -> home directory
BASE=0
YES=0
USER_INCLUDES=""
while getopts "uyI:" flag; do
case "$flag" in
u) BASE=1 ;;
y) YES=1 ;;
I) USER_INCLUDES="$USER_INCLUDES -I$OPTARG" ;;
\?) usage; exit -1 ;;
esac
done
shift $((OPTIND - 1))
if [ $# -eq 1 ]; then
echo ${!1}
fi
if [ $BASE -eq 0 ]; then
path="${PWD}/.PS"
else
path="$HOME/.PS"
fi
path_warning="$path/warning"
path_obj="$path/obj"
path_objmd5="$path/objmd5"
path_output="$path/output.txt"
mkdir -p $path_warning
mkdir -p $path_obj
mkdir -p $path_objmd5
if [ -f "$1.cpp" ] && [ ! -z "$1.cpp" ]; then
md5=`md5sum $1.cpp | cut -f1 -d' '`
name=`basename $1`
echo "$1.cpp : File Exist!"
echo "md5: $md5"
if [ -e "$path_objmd5/$md5" ]; then
if [ $YES -eq 0 ]; then
read -p "There's excutable file with same md5. Will you excute this?(Y/n) " yesno
fi
if [ -z "$yesno" ] || [[ $yesno =~ [yY] ]] || [[ $yesno =~ [yY][eE][sS] ]]; then
echo -e "---------------- \"$1.cpp(?)\" Standard Input ----------------"
"$path_objmd5/$md5" > $path_output; ret=$?
echo -e "\n-------------------- \"$1.cpp(?)\" output --------------------"
cat $path_output
echo -e "\n----------------------- \"$1.cpp(?)\" ------------------------"
exit 0
fi
fi
# copt="g++ $1.cpp -Ilib -Iac-library -fsanitize=undefined,address -o $path_obj/$1 -O2 -lm -Wall -std=c++2a -DDEBUG -Wno-unused-result"
copt="g++ $1.cpp $USER_INCLUDES -fsanitize=undefined,address -o $path_obj/$1 -O2 -lm -Wall -std=c++2a -DDEBUG -Wno-unused-result"
echo "Now Compiling..."
echo "## Name of Source File : $1.cpp" > "$path_warning/$1"
echo "## MD5 of Source File : $md5" >> "$path_warning/$1"
echo "## Compile command : $copt" >> "$path_warning/$1"
ctime=`date +%y%m%d%H%M%S`; echo "## Compile start time : $ctime" >> "$path_warning/$1"
`$copt 2> $path/latest`; res=$?
echo -e "## Compile end time : $(date +%y%m%d%H%M%S)\n" >> "$path_warning/$1"
cat "$path/latest" >> "$path_warning/$1"
echo "Compile Finished!"
cat "$path_warning/$1"
if [ $res -eq 0 ]; then
cp "$path_obj/$1" "$path_objmd5/$md5"
echo -e "---------------- \"$1.cpp\" Standard Input ----------------"
"$path_obj/$1" > $path_output; ret=$?
echo -e "\n-------------------- \"$1.cpp\" output --------------------"
cat $path_output
echo -e "\n----------------------- \"$1.cpp\" ------------------------"
echo -e "\nProgram returned with $ret"
echo -e "Excutable File : $path_obj/$1\n"
else
echo "Compile Failed!"
fi
elif [ -z "$1" ]; then
echo "No string is given!"
else
echo "There's no such file!"
fi
exit 0
+56
View File
@@ -0,0 +1,56 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Single File PS Compile & Run with 'start'",
"type": "shell",
"command": "${workspaceFolder}/start",
"args": [
"${fileBasenameNoExtension}"
],
"options": { "cwd": "${fileDirname}" },
"group": { "kind": "build", "isDefault": true },
"presentation": {
"echo": true,
"reveal": "always",
"focus": true,
"panel": "shared",
"showReuseMessage": true,
"clear": false
}
},
{
"label": "Expand Main Code",
"type": "shell",
"command": "${workspaceFolder}/expand",
"args": ["-d", "${workspaceFolder}", "${fileBasenameNoExtension}", ">temp"],
"options": { "cwd": "${fileDirname}" },
"group": { "kind": "test", "isDefault": true },
"presentation": {
"echo": true,
"reveal": "always",
"focus": true,
"panel": "shared",
"showReuseMessage": true,
"clear": false
}
},
{
"label": "Single File PS Compile & Run",
"type": "shell",
"command": "/usr/bin/g++",
"args": [
"${fileBasename}",
"-o${fileBasenameNoExtension}",
"-O2", "-lm", "-Wall", "-static", "-std=c++2a",
"-DDEBUG", "-Wno-unused-result"
],
"options": {
},
"group": {
"kind": "build",
"isDefault": false
}
}
]
}
+2
View File
@@ -0,0 +1,2 @@
# Perfect PS Contest setting
Symlink
+1
View File
@@ -0,0 +1 @@
.scripts/start.3