diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2976f670..129f4f4f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -90,6 +90,10 @@ jobs: run: | make test + - name: Uninstall + run: | + make uninstall + macos: name: macos runs-on: macos-latest @@ -125,6 +129,11 @@ jobs: run: | make test + - name: Uninstall + run: | + source ~/.bash_profile + make uninstall + windows: name: windows runs-on: windows-latest @@ -161,3 +170,8 @@ jobs: shell: cmd run: | call make.bat test + + - name: Uninstall + shell: cmd + run: | + call make.bat uninstall diff --git a/Makefile b/Makefile index 4d832c13..6e535f06 100644 --- a/Makefile +++ b/Makefile @@ -71,6 +71,17 @@ clean: install: requirements-dev mv chaos /usr/local/bin/ +uninstall: + rm /usr/local/bin/chaos + rm /usr/local/include/Chaos.h + rm -rf /usr/local/include/chaos/ +ifeq ($(UNAME_S), Darwin) + $(eval GCC_VERSION=$(shell gcc -dumpversion)) + $(eval GCC_MAJOR_VERSION=$(shell gcc -dumpversion | cut -d. -f1)) + rm /usr/local/Cellar/gcc@$(GCC_MAJOR_VERSION)/$(GCC_VERSION)/lib/gcc/$(GCC_MAJOR_VERSION)/gcc/x86_64-apple-darwin19/$(GCC_VERSION)/include/Chaos.h + rm -rf /usr/local/Cellar/gcc@$(GCC_MAJOR_VERSION)/$(GCC_VERSION)/lib/gcc/$(GCC_MAJOR_VERSION)/gcc/x86_64-apple-darwin19/$(GCC_VERSION)/include/chaos/ +endif + lint: cppcheck --force . diff --git a/README.md b/README.md index e48ebce1..7714aa5f 100644 --- a/README.md +++ b/README.md @@ -112,6 +112,14 @@ $ chaos dev.kaos hello world ``` +## Uninstallation + +You can uninstall the `chaos` binary and its C headers with: + +``` +make uninstall +``` + ## Useful Links [**Language Reference**](https://chaos-lang.org/docs/04_primitive-data-types) diff --git a/make.bat b/make.bat index 53067961..24385fa8 100644 --- a/make.bat +++ b/make.bat @@ -35,6 +35,13 @@ IF [%1]==[] ( ) ELSE ( EXIT /B 0 ) +) ELSE IF [%1]==[uninstall] ( + CALL :Uninstall + IF errorlevel 1 ( + EXIT /B 1 + ) ELSE ( + EXIT /B 0 + ) ) ELSE IF [%1]==[test] ( CALL tests\run.bat IF errorlevel 1 ( @@ -140,3 +147,30 @@ IF errorlevel 1 ( EXIT /B 1 ) EXIT /B 0 + +:Uninstall +DEL %windir%\System32\chaos.exe +CALL RefreshEnv.cmd + +gcc -dumpversion > tmpFile +SET /p GCC_VERSION= < tmpFile +DEL tmpFile + +clang -dumpversion > tmpFile +SET /p CLANG_VERSION= < tmpFile +DEL tmpFile + +ECHO "%programdata%\Chocolatey\lib\mingw\tools\install\mingw64\lib\gcc\x86_64-w64-mingw32\!GCC_VERSION!\include\" +DEL Chaos.h "%programdata%\Chocolatey\lib\mingw\tools\install\mingw64\lib\gcc\x86_64-w64-mingw32\!GCC_VERSION!\include\Chaos.h" +RMDIR /s /q "%programdata%\Chocolatey\lib\mingw\tools\install\mingw64\lib\gcc\x86_64-w64-mingw32\!GCC_VERSION!\include\chaos\" +IF errorlevel 1 ( + EXIT /B 1 +) + +ECHO "%programfiles%\LLVM\lib\clang\!CLANG_VERSION!\include\" +DEL "%programfiles%\LLVM\lib\clang\!CLANG_VERSION!\include\Chaos.h" +RMDIR /s /q "%programfiles%\LLVM\lib\clang\!CLANG_VERSION!\include\chaos\" +IF errorlevel 1 ( + EXIT /B 1 +) +EXIT /B 0