diff --git a/.github/workflows/makefile.yml b/.github/workflows/makefile.yml index c2a9046c..9e5db690 100644 --- a/.github/workflows/makefile.yml +++ b/.github/workflows/makefile.yml @@ -34,40 +34,24 @@ jobs: - name: format_check working-directory: ./ - run: ./format.sh --dry + run: ./tools/format.sh --dry - name: cpp_check working-directory: ./ - run: ./cpp_check.sh + run: make cppcheck - name: unit_tests - working-directory: build/tests - run: | - cmake -S . -B build - cmake --build build - ./build/osp2_tests - - - name: build-qvm - working-directory: build/qvm - run: | - make - - - name: build-so - working-directory: build/library - run: | - make + working-directory: ./ + run: make tests - - uses: actions/upload-artifact@v4 - with: - name: qvm - path: build/qvm/zz-osp-pak8.pk3 - if-no-files-found: error - retention-days: 5 + - name: release + working-directory: ./ + run: make - uses: actions/upload-artifact@v4 with: - name: so - path: build/library/build/release-linux-x86_64/osp2/cgamex86_64.so + name: osp2_linux + path: osp2_linux.tar.gz if-no-files-found: error retention-days: 5 @@ -87,20 +71,15 @@ jobs: with: submodules: recursive - - name: build-qvm - working-directory: build/qvm - run: | - make - - - name: build-dll - working-directory: build/library + - name: release + working-directory: ./ run: | make - uses: actions/upload-artifact@v4 with: - name: dll - path: build/library/build/release-mingw64-x86_64/osp2/cgamex86_64.dll + name: osp2_windows + path: osp2_windows.zip if-no-files-found: error retention-days: 5 @@ -121,9 +100,8 @@ jobs: prerelease: false title: Latest Build files: | - qvm - so - dll + osp2_windows + osp2_linux diff --git a/.gitignore b/.gitignore index 9b5e983d..671911b7 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,6 @@ build/qvm/vm/ build/qvm/zz-osp-pak8.pk3 build/library/build/ build/tests/build/ +osp/ +osp2_linux.tar.gz +osp2_windows.zip diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..67b3b5ca --- /dev/null +++ b/Makefile @@ -0,0 +1,100 @@ +FORMAT_COMMAND=./tools/format.sh +CPPCHECK_COMMAND=./tools/cpp_check.sh + +LIB_ROOT_DIR=./build/library +PK3_ROOT_DIR=./build/qvm +TESTS_ROOT_DIR=./build/tests +MOD_ROOT_DIR=./osp +DOC_ROOT_DIR=$(MOD_ROOT_DIR)/Docs + +LIB_BUILD_DIR=$(LIB_ROOT_DIR)/build +PK3_BUILD_DIR=$(PK3_ROOT_DIR)/build +TESTS_BUILD_DIR=$(TESTS_ROOT_DIR)/build +LIB_BUILD_CLIENT_DIR=$(LIB_BUILD_DIR)/release-linux-x86_64/osp2 + +TESTS_FILE=osp2_tests +PK3_CLIENT_FILE=zz-osp-pak8.pk3 +LIB_CLIENT_FILE=cgamex86_64.so +RELEASE_FILE=osp2_linux.tar.gz + +MAKE_RELEASE_ARCHIVE=tar czf $(RELEASE_FILE) $(MOD_ROOT_DIR) + + +# check platform +COMPILE_PLATFORM=$(shell uname | sed -e 's/_.*//' | tr '[:upper:]' '[:lower:]' | sed -e 's/\//_/g') + +ifndef PLATFORM +PLATFORM=$(COMPILE_PLATFORM) +endif + +ifeq ($(PLATFORM),mingw32) + WINDOWS=1 +endif +ifeq ($(PLATFORM),mingw64) + WINDOWS=1 +endif +ifeq ($(PLATFORM),windows) + WINDOWS=1 +endif + +# change varibles for windows +ifdef WINDOWS + LIB_CLIENT_FILE=cgamex86_64.dll + RELEASE_FILE=osp2_windows.zip + LIB_BUILD_CLIENT_DIR=$(LIB_BUILD_DIR)/release-$(PLATFORM)-x86_64/osp2 + MAKE_RELEASE_ARCHIVE=$(PK3_ROOT_DIR)/tools/7za.exe u $(RELEASE_FILE) $(MOD_ROOT_DIR) +endif + +.PHONY: all clean client server osp2 format cppcheck pk3 lib dirs docs + +all: $(RELEASE_FILE) + +clean: + @rm -rf $(LIB_BUILD_DIR) + @rm -rf $(PK3_ROOT_DIR)/vm + @rm -rf $(PK3_ROOT_DIR)/$(PK3_CLIENT_FILE) + @rm -rf $(MOD_ROOT_DIR) + @rm -f $(RELEASE_FILE) + @rm -rf $(TESTS_BUILD_DIR) + +dirs: + @mkdir -p $(MOD_ROOT_DIR) + @mkdir -p $(DOC_ROOT_DIR) + @mkdir -p $(DOC_ROOT_DIR)/RUS + +format: + $(FORMAT_COMMAND) + +cppcheck: + $(CPPCHECK_COMMAND) + +pk3: + @make -C $(PK3_ROOT_DIR) + +lib: + @make -C $(LIB_ROOT_DIR) + +docs: dirs + @rm -f $(DOC_ROOT_DIR)/RUS/osp2-q3-ClientReadme.txt + @install -v docs/osp2-q3-ClientReadme.md $(DOC_ROOT_DIR)/RUS/osp2-q3-ClientReadme.txt + @rm -f $(DOC_ROOT_DIR)/RUS/osp2-q3-SuperHUD.txt + @install -v docs/osp2-q3-SuperHUD.md $(DOC_ROOT_DIR)/RUS/osp2-q3-SuperHUD.txt + +osp2: pk3 lib dirs docs + @rm -f $(MOD_ROOT_DIR)/$(LIB_CLIENT_FILE) + @install -v $(LIB_BUILD_CLIENT_DIR)/$(LIB_CLIENT_FILE) $(MOD_ROOT_DIR) + @rm -f $(MOD_ROOT_DIR)/$(PK3_CLIENT_FILE) + @install -v $(PK3_ROOT_DIR)/$(PK3_CLIENT_FILE) $(MOD_ROOT_DIR) + +$(RELEASE_FILE): osp2 + $(MAKE_RELEASE_ARCHIVE) + +$(TESTS_BUILD_DIR): + @cmake -S $(TESTS_ROOT_DIR) -B $(TESTS_BUILD_DIR) + +$(TESTS_FILE): $(TESTS_BUILD_DIR) + @cmake --build $(TESTS_BUILD_DIR) + +tests: $(TESTS_FILE) + $(TESTS_BUILD_DIR)/$(TESTS_FILE) + diff --git a/README.md b/README.md index e5419021..aa5917a3 100644 --- a/README.md +++ b/README.md @@ -38,30 +38,22 @@ Telegram [chat](https://t.me/q3_osp2). ## New commands -See [docs/commands.md](docs/commands.md) +See [docs/osp2-q3-ClientReadme.md](docs/osp2-q3-ClientReadme.md) Example config: OSP2.cfg inside mod. ## How to install - Install Quake3 and OSP mod v1.03 -- copy pk3 file (and so/dll library if you want) into `osp` folder +- Unpack zip or tar.gz into your Quake3 directory. ## How to build -### Windows - -Install [mingw](https://github.com/skeeto/w64devkit/releases) (just unzip and add bin folder to system PATH). - -### pk3 +### Linux - `cd build/qvm` +Run 'make' from OSP2 directory. - `make` - -### dll/so - - `cd build/library` +### Windows - `make` +Install [mingw](https://github.com/skeeto/w64devkit/releases) (just unzip and add bin folder to system PATH) and run 'make' from OSP2 directory. diff --git a/cpp_check.sh b/cpp_check.sh deleted file mode 100755 index 4c78620b..00000000 --- a/cpp_check.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -RET="$(cppcheck -D__GNUC__ -q -j32 --enable=warning,performance,portability --std=c89 --suppressions-list=./cppcheck_suppress.txt --error-exitcode=1 ./code)" -exit $RET diff --git a/docs/commands.md b/docs/osp2-q3-ClientReadme.md similarity index 100% rename from docs/commands.md rename to docs/osp2-q3-ClientReadme.md diff --git a/docs/superhud.md b/docs/osp2-q3-SuperHUD.md similarity index 100% rename from docs/superhud.md rename to docs/osp2-q3-SuperHUD.md diff --git a/astyle.conf b/tools/astyle.conf similarity index 100% rename from astyle.conf rename to tools/astyle.conf diff --git a/tools/cpp_check.sh b/tools/cpp_check.sh new file mode 100755 index 00000000..7e7a84c2 --- /dev/null +++ b/tools/cpp_check.sh @@ -0,0 +1,3 @@ +#!/bin/bash +RET="$(cppcheck -D__GNUC__ -q -j32 --enable=warning,performance,portability --std=c89 --suppressions-list=./tools/cppcheck_suppress.txt --error-exitcode=1 ./code)" +exit $RET diff --git a/cppcheck_suppress.txt b/tools/cppcheck_suppress.txt similarity index 100% rename from cppcheck_suppress.txt rename to tools/cppcheck_suppress.txt diff --git a/format.sh b/tools/format.sh similarity index 93% rename from format.sh rename to tools/format.sh index 2897ec55..517cfcf7 100755 --- a/format.sh +++ b/tools/format.sh @@ -12,7 +12,7 @@ declare -a FORMAT_PATHS=( \ ) DRY_RUN=0 -ASTYLE="astyle --formatted --errors-to-stdout --options=./astyle.conf" +ASTYLE="astyle --formatted --errors-to-stdout --options=./tools/astyle.conf" if [[ $1 = "--dry" ]]; then ASTYLE=$ASTYLE" --dry-run"