mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-15 16:41:29 +00:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6c057308da | ||
|
|
0bc0ee609a | ||
|
|
c84df0d5ba | ||
|
|
9b3f9f356d | ||
|
|
e42dc2e1d2 | ||
|
|
c611a25385 | ||
|
|
f74efcaa5f | ||
|
|
eb4e7d694c | ||
|
|
ecc0d4b5c0 | ||
|
|
8175ae6187 |
11
.devcontainer/.gitignore
vendored
11
.devcontainer/.gitignore
vendored
@ -1,6 +1,5 @@
|
||||
!Makefile
|
||||
base/*.sql
|
||||
base/*.zip
|
||||
base/db/
|
||||
base/maps/
|
||||
!base/expansion/Makefile
|
||||
base/
|
||||
!base/*.json
|
||||
override/
|
||||
repo/
|
||||
cache/
|
||||
|
||||
@ -1,196 +1,127 @@
|
||||
# Build binaries: make cmake, make build
|
||||
# One time initial setup (or to reset db): make prep, make inject-mariadb, make maps
|
||||
# Update custom db edits: make inject-custom
|
||||
# Start up server: make shared, make login, make world, make zone
|
||||
# in game, stop combat spam #logs set gmsay 79 0
|
||||
# in game, stop loot spam #logs set gmsay 69 0
|
||||
NAME := eqemu-server
|
||||
.ONESHELL:
|
||||
|
||||
DOCKER_ARGS := --rm --name ${NAME} -v $$PWD:/src -w /src ${NAME}
|
||||
DOCKER_ARM64_ARGS := --rm --platform linux/arm64 --name ${NAME}-arm64 -v $$PWD:/src -w /src ${NAME}-arm64
|
||||
|
||||
.PHONY: build
|
||||
build:
|
||||
ifeq ($(findstring .devcontainer,$(CURDIR)),.devcontainer)
|
||||
@make -C ../ -f .devcontainer/Makefile build --no-print-directory
|
||||
exit
|
||||
endif
|
||||
cd build$$BUILD_SUFFIX && cmake --build . --config Release --target all --
|
||||
|
||||
.PHONY: cmake
|
||||
cmake:
|
||||
ifeq ($(findstring .devcontainer,$(CURDIR)),.devcontainer)
|
||||
@make -C ../ -f .devcontainer/Makefile cmake --no-print-directory
|
||||
exit
|
||||
endif
|
||||
@echo "working directory: $$PWD"
|
||||
mkdir -p build$$BUILD_SUFFIX
|
||||
@cd build$$BUILD_SUFFIX && cmake -DEQEMU_BUILD_LOGIN=ON \
|
||||
-DEQEMU_BUILD_TESTS=ON \
|
||||
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache -G Ninja ..
|
||||
|
||||
clean:
|
||||
ifneq (,$(findstring .devcontainer,$$PWD))
|
||||
@make -C ../ -f .devcontainer/Makefile clean --no-print-directory
|
||||
endif
|
||||
rm -rf build
|
||||
|
||||
docker-cmake:
|
||||
ifeq ($(findstring .devcontainer,$(CURDIR)),.devcontainer)
|
||||
@make -C ../ -f .devcontainer/Makefile docker-cmake --no-print-directory
|
||||
exit
|
||||
endif
|
||||
@echo "working directory: $$PWD"
|
||||
git submodule update --init --recursive
|
||||
docker run ${DOCKER_ARGS} make cmake
|
||||
|
||||
docker-build:
|
||||
ifeq ($(findstring .devcontainer,$(CURDIR)),.devcontainer)
|
||||
@make -C ../ -f .devcontainer/Makefile docker-build --no-print-directory
|
||||
exit
|
||||
endif
|
||||
docker run ${DOCKER_ARGS} make build
|
||||
|
||||
# Build image if it doesn't exist
|
||||
docker-image-build:
|
||||
ifeq ($(findstring .devcontainer,$(CURDIR)),.devcontainer)
|
||||
@make -C ../ -f .devcontainer/Makefile docker-image-build --no-print-directory
|
||||
exit
|
||||
endif
|
||||
ifeq ($(shell docker images -q ${NAME} 2> /dev/null),)
|
||||
@echo "Docker image not found. Building..."
|
||||
docker build -f Dockerfile.debian.dev -t ${NAME} .
|
||||
endif
|
||||
|
||||
docker-arm-cmake: docker-arm-image-build
|
||||
ifeq ($(findstring .devcontainer,$(CURDIR)),.devcontainer)
|
||||
@make -C ../ -f .devcontainer/Makefile docker-arm-cmake --no-print-directory
|
||||
exit
|
||||
endif
|
||||
git submodule update --init --recursive
|
||||
docker run ${DOCKER_ARM64_ARGS} make cmake BUILD_SUFFIX=arm64
|
||||
|
||||
docker-arm-build: docker-arm-image-build
|
||||
ifeq ($(findstring .devcontainer,$(CURDIR)),.devcontainer)
|
||||
@make -C ../ -f .devcontainer/Makefile docker-arm-build --no-print-directory
|
||||
exit
|
||||
endif
|
||||
docker run ${DOCKER_ARM64_ARGS} make build BUILD_SUFFIX=arm64
|
||||
|
||||
docker-arm-image-build:
|
||||
ifeq ($(shell docker images -q ${NAME}-arm64 2> /dev/null),)
|
||||
@echo "Docker image not found. Building..."
|
||||
docker build -f Dockerfile.debian.arm.dev -t ${NAME}-arm64 .
|
||||
endif
|
||||
|
||||
docker-clean: clean
|
||||
|
||||
.PHONY: prep
|
||||
prep:
|
||||
ifeq ($(findstring .devcontainer,$(CURDIR)),.devcontainer)
|
||||
@make -C ../ -f .devcontainer/Makefile prep --no-print-directory
|
||||
exit
|
||||
endif
|
||||
prep: is-vscode
|
||||
@echo "Preparing build/bin for usage..."
|
||||
mkdir -p build/bin/assets/patches
|
||||
cp -R -u -p .devcontainer/base/eqemu_config.json build/bin/eqemu_config.json
|
||||
cp -R -u -p .devcontainer/base/login.json build/bin/login.json
|
||||
cp -R -u -p loginserver/login_util/* build/bin/assets/patches/
|
||||
mkdir -p build/bin/assets
|
||||
cp -R -u -p utils/patches build/bin/assets/
|
||||
-unlink build/bin/lua_modules
|
||||
cd build/bin && ln -s quests/lua_modules lua_modules
|
||||
-unlink build/bin/mods
|
||||
cd build/bin && ln -s quests/mods mods
|
||||
-unlink build/bin/maps
|
||||
cd build/bin && ln -s ../../base/maps maps
|
||||
mkdir -p build/bin/logs
|
||||
mkdir -p build/bin/shared
|
||||
|
||||
@echo "Prepping folders..."
|
||||
@mkdir -p .devcontainer/override
|
||||
@mkdir -p .devcontainer/repo
|
||||
@mkdir -p .devcontainer/cache
|
||||
@mkdir -p build/bin/logs
|
||||
@mkdir -p build/bin/shared
|
||||
@mkdir -p build/bin/assets
|
||||
|
||||
@echo "Applying overrides..."
|
||||
@if [ ! -f .devcontainer/override/eqemu_config.json ]; then cp .devcontainer/base/eqemu_config.json .devcontainer/override/eqemu_config.json; fi
|
||||
@if [ -f build/bin/eqemu_config.json ]; then unlink build/bin/eqemu_config.json; fi
|
||||
cd build/bin && ln -s ../../.devcontainer/override/eqemu_config.json eqemu_config.json
|
||||
@if [ ! -f .devcontainer/override/login.json ]; then cp .devcontainer/base/login.json .devcontainer/override/login.json; fi
|
||||
@if [ -f build/bin/login.json ]; then unlink build/bin/login.json; fi
|
||||
cd build/bin && ln -s ../../.devcontainer/override/login.json login.json
|
||||
|
||||
@echo "Cloning repositories..."
|
||||
cd .devcontainer/repo && if [ ! -d "quests" ]; then cd ../../.devcontainer/repo/ && git clone https://github.com/ProjectEQ/projecteqquests.git quests; fi
|
||||
cd .devcontainer/repo && if [ ! -d "eqemu-definitions" ]; then cd ../../.devcontainer/repo/ && git clone https://github.com/xackery/eqemu-definitions.git eqemu-definitions; fi
|
||||
cd .devcontainer/repo && if [ ! -d "maps" ]; then cd ../../ && make maps; fi
|
||||
@if [ -d build/bin/quests ]; then unlink build/bin/quests; fi
|
||||
cd build/bin && ln -s ../../.devcontainer/repo/quests quests
|
||||
@if [ -d build/bin/maps ]; then unlink build/bin/maps; fi
|
||||
cd build/bin && ln -s ../../.devcontainer/repo/maps maps
|
||||
@if [ -d build/bin/eqemu-definitions ]; then unlink build/bin/eqemu-definitions; fi
|
||||
cd build/bin && ln -s ../../.devcontainer/repo/eqemu-definitions eqemu-definitions
|
||||
@mkdir -p build/bin/quests/mods
|
||||
|
||||
@echo "Applying base links..."
|
||||
cp -R -u -p utils/patches .devcontainer/base/
|
||||
@if [ -d build/bin/assets/patches ]; then unlink build/bin/assets/patches; fi
|
||||
cd build/bin/assets && ln -s ../../../.devcontainer/base/patches patches
|
||||
@if [ -d build/bin/lua_modules ]; then unlink build/bin/lua_modules; fi
|
||||
cd build/bin && ln -s ../../.devcontainer/repo/quests/lua_modules lua_modules
|
||||
@if [ -d build/bin/mods ]; then unlink build/bin/mods; fi
|
||||
cd build/bin && ln -s ../../.devcontainer/repo/quests/mods mods
|
||||
@if [ -d build/bin/plugins ]; then unlink build/bin/plugins; fi
|
||||
cd build/bin && ln -s ../../.devcontainer/repo/quests/plugins plugins
|
||||
|
||||
@echo "Eqemu is prepared. Edit build/bin/eqemu_config.json to configure."
|
||||
|
||||
maps:
|
||||
@echo "Downloading maps..."
|
||||
@mkdir -p base/maps
|
||||
@cd base/maps && wget -nc https://github.com/Akkadius/eqemu-maps/archive/refs/heads/master.zip
|
||||
@cd base/maps && unzip -o master.zip
|
||||
@cd base/maps && mv eqemu-maps-master/* .
|
||||
@cd base/maps && rm -rf eqemu-maps-master
|
||||
@echo "Maps downloaded."
|
||||
is-vscode:
|
||||
@if [ -z "$$REMOTE_CONTAINERS" ]; then \
|
||||
echo "Not running in VS Code devcontainer"; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
quests:
|
||||
ifeq ($(findstring .devcontainer,$(CURDIR)),.devcontainer)
|
||||
@make -C ../ -f .devcontainer/Makefile quests --no-print-directory
|
||||
exit
|
||||
endif
|
||||
@cd build/bin && git clone https://github.com/ProjectEQ/projecteqquests.git quests
|
||||
clean: is-vscode
|
||||
rm -rf build
|
||||
|
||||
.PHONY: maps
|
||||
maps: is-vscode
|
||||
@echo "Downloading maps..."
|
||||
@mkdir -p .devcontainer/repo/maps
|
||||
@cd .devcontainer/repo/maps && wget -nc https://github.com/EQEmu/maps/archive/refs/heads/master.zip
|
||||
@cd .devcontainer/repo/maps && unzip -o master.zip
|
||||
@cd .devcontainer/repo/maps && mv maps-master/* .
|
||||
@cd .devcontainer/repo/maps && rm -rf maps-master
|
||||
@echo "Maps downloaded."
|
||||
|
||||
# Runs tests
|
||||
.PHONY: test
|
||||
test:
|
||||
ifeq ($(findstring .devcontainer,$(CURDIR)),.devcontainer)
|
||||
@make -C ../ -f .devcontainer/Makefile test --no-print-directory
|
||||
exit
|
||||
endif
|
||||
test: is-vscode
|
||||
cd build/bin && ./tests
|
||||
|
||||
# Runs login binary
|
||||
.PHONY: login
|
||||
login:
|
||||
ifeq ($(findstring .devcontainer,$(CURDIR)),.devcontainer)
|
||||
@make -C ../ -f .devcontainer/Makefile login --no-print-directory
|
||||
exit
|
||||
endif
|
||||
login: is-vscode check-mariadb
|
||||
cd build/bin && ./loginserver
|
||||
|
||||
.PHONY: hotfix
|
||||
hotfix: shared
|
||||
|
||||
# Runs shared_memory binary
|
||||
.PHONY: shared
|
||||
shared:
|
||||
ifeq ($(findstring .devcontainer,$(CURDIR)),.devcontainer)
|
||||
@make -C ../ -f .devcontainer/Makefile shared --no-print-directory
|
||||
exit
|
||||
endif
|
||||
shared: is-vscode check-mariadb
|
||||
cd build/bin && ./shared_memory
|
||||
|
||||
# Runs zone binary
|
||||
.PHONY: zone
|
||||
zone:
|
||||
ifeq ($(findstring .devcontainer,$(CURDIR)),.devcontainer)
|
||||
@make -C ../ -f .devcontainer/Makefile zone --no-print-directory
|
||||
exit
|
||||
endif
|
||||
@-rm build/bin/logs/zone/zone*.log
|
||||
zone: is-vscode check-mariadb
|
||||
@find build/bin/logs/zone/ -type f -name 'zone*.log' -exec rm -f {} +
|
||||
cd build/bin && ./zone
|
||||
|
||||
check-mariadb: is-vscode
|
||||
@if ! sudo service mariadb status | grep -q 'active (running)'; then \
|
||||
sudo service mariadb start; \
|
||||
fi
|
||||
|
||||
# Runs world binary
|
||||
.PHONY: world
|
||||
world:
|
||||
ifeq ($(findstring .devcontainer,$(CURDIR)),.devcontainer)
|
||||
@make -C ../ -f .devcontainer/Makefile world --no-print-directory
|
||||
exit
|
||||
endif
|
||||
@-rm build/bin/logs/world*.log
|
||||
world: is-vscode check-mariadb
|
||||
@find build/bin/logs/ -type f -name 'world*.log' -exec rm -f {} +
|
||||
cd build/bin && ./world
|
||||
|
||||
# Runs ucs binary
|
||||
.PHONY: ucs
|
||||
ucs:
|
||||
ifeq ($(findstring .devcontainer,$(CURDIR)),.devcontainer)
|
||||
@make -C ../ -f .devcontainer/Makefile ucs --no-print-directory
|
||||
exit
|
||||
endif
|
||||
@-rm build/bin/logs/ucs*.log
|
||||
ucs: is-vscode check-mariadb
|
||||
@find build/bin/logs/ -type f -name 'ucs*.log' -exec rm -f {} +
|
||||
cd build/bin && ./ucs
|
||||
|
||||
# Runs queryserv binary
|
||||
.PHONY: queryserv
|
||||
queryserv:
|
||||
ifeq ($(findstring .devcontainer,$(CURDIR)),.devcontainer)
|
||||
@make -C ../ -f .devcontainer/Makefile queryserv --no-print-directory
|
||||
exit
|
||||
endif
|
||||
@-rm build/bin/logs/query_server*.log
|
||||
queryserv: is-vscode check-mariadb
|
||||
@find build/bin/logs/ -type f -name 'query_server*.log' -exec rm -f {} +
|
||||
cd build/bin && ./queryserv
|
||||
|
||||
valgrind-%:
|
||||
ifeq ($(findstring .devcontainer,$(CURDIR)),.devcontainer)
|
||||
@make -C ../ -f .devcontainer/Makefile valgrind --no-print-directory
|
||||
exit
|
||||
endif
|
||||
reset-content:
|
||||
@echo "Resetting content tables in database peq..."
|
||||
cd .devcontainer/cache/db/peq-dump && sudo mariadb --database peq -e "source create_tables_content.sql"
|
||||
|
||||
valgrind-%: is-vscode
|
||||
cd build/bin && valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --verbose --log-file=logs/$*.valgrind.log ./$*
|
||||
|
||||
# Start mariaDB standalone
|
||||
@ -201,30 +132,33 @@ mariadb:
|
||||
.PHONY: inject-mariadb
|
||||
inject-mariadb:
|
||||
-sudo service mariadb start
|
||||
-mkdir -p base/db/
|
||||
-mkdir -p .devcontainer/cache/db/
|
||||
-sudo mariadb -e 'DROP DATABASE IF EXISTS peq;'
|
||||
-sudo mariadb -e 'CREATE DATABASE peq;'
|
||||
-sudo mariadb -e "CREATE USER 'peq'@'127.0.0.1' IDENTIFIED BY 'peqpass';"
|
||||
-sudo mariadb -e "CREATE USER IF NOT EXISTS 'peq'@'127.0.0.1' IDENTIFIED BY 'peqpass';"
|
||||
-sudo mariadb -e "GRANT ALL PRIVILEGES ON *.* TO 'peq'@'127.0.0.1';"
|
||||
ifeq (,$(wildcard base/db/db.sql.zip))
|
||||
@echo "base/db.sql.zip not found. Downloading latest from https://db.projecteq.net/"
|
||||
wget -nc https://db.projecteq.net/latest -O base/db/db.sql.zip
|
||||
-cd base/db && unzip db.sql.zip
|
||||
ifeq (,$(wildcard .devcontainer/cache/db/db.sql.zip))
|
||||
@echo ".devcontainer/cache/db.sql.zip not found. Downloading database from https://db.eqemu.dev/latest"
|
||||
wget -nc https://db.eqemu.dev/latest -O .devcontainer/cache/db/db.sql.zip
|
||||
-cd .devcontainer/cache/db && unzip db.sql.zip
|
||||
endif
|
||||
@echo "Sourcing db may take a while, please wait..."
|
||||
@cd base/db/peq-dump && sudo mariadb --database peq -e "source create_all_tables.sql"
|
||||
|
||||
@cd .devcontainer/cache/db/peq-dump && sudo mariadb --database peq -e "source create_tables_content.sql"
|
||||
@cd .devcontainer/cache/db/peq-dump && sudo mariadb --database peq -e "source create_tables_login.sql"
|
||||
@cd .devcontainer/cache/db/peq-dump && sudo mariadb --database peq -e "source create_tables_player.sql"
|
||||
@# deprecated cd .devcontainer/cache/db/peq-dump && sudo mariadb --database peq -e "source create_tables_queryserv.sql"
|
||||
@cd .devcontainer/cache/db/peq-dump && sudo mariadb --database peq -e "source create_tables_state.sql"
|
||||
@cd .devcontainer/cache/db/peq-dump && sudo mariadb --database peq -e "source create_tables_system.sql"
|
||||
|
||||
@echo "MariaDB is now injected."
|
||||
|
||||
.PHONY: gm-%
|
||||
gm-%:
|
||||
gm-%: is-vscode
|
||||
sudo mariadb --database peq -e "UPDATE account SET status=255 WHERE name = '$*';"
|
||||
@echo "Account $* is now a GM. /camp to have it go into effect."
|
||||
|
||||
depends:
|
||||
ifeq ($(findstring .devcontainer,$(CURDIR)),.devcontainer)
|
||||
@make -C ../ -f .devcontainer/Makefile depends --no-print-directory
|
||||
exit
|
||||
endif
|
||||
depends: is-vscode
|
||||
sudo apt install graphviz pip time
|
||||
pip3 install graphviz
|
||||
mkdir -p build/depends
|
||||
@ -241,44 +175,54 @@ endif
|
||||
@echo "Common..."
|
||||
time python3 build/depends/dependency_graph.py -f png common build/depends/common.dot
|
||||
|
||||
backup:
|
||||
ifeq ($(findstring .devcontainer,$(CURDIR)),.devcontainer)
|
||||
@make -C ../ -f .devcontainer/Makefile backup --no-print-directory
|
||||
exit
|
||||
endif
|
||||
backup: is-vscode
|
||||
@mkdir -p build/bin/backup
|
||||
cd build/bin && ./world database:dump --compress --player-tables --state-tables --system-tables --query-serv-tables
|
||||
|
||||
cpu-zone:
|
||||
restore-%: is-vscode
|
||||
@if [ -z "$*" ]; then \
|
||||
echo "Please provide a backup file to restore from. Example: make restore-backup.sql"; \
|
||||
exit 1; \
|
||||
fi
|
||||
@echo "Restoring from backup $*"
|
||||
@sudo mariadb --database peq -e "$*"
|
||||
|
||||
|
||||
cpu-zone: is-vscode
|
||||
ifeq ($(findstring .devcontainer,$(CURDIR)),.devcontainer)
|
||||
@make -C ../ -f .devcontainer/Makefile cpu-zone --no-print-directory
|
||||
@echo "This makefile is not intended to be run from the .devcontainer directory."
|
||||
exit
|
||||
endif
|
||||
@cd build/bin && mkdir -p tmp
|
||||
cd build/bin && CPUPROFILE=prof.out ./zone
|
||||
|
||||
pprof-zone:
|
||||
pprof-zone: is-vscode
|
||||
ifeq ($(findstring .devcontainer,$(CURDIR)),.devcontainer)
|
||||
@make -C ../ -f .devcontainer/Makefile pprof-zone --no-print-directory
|
||||
@echo "This makefile is not intended to be run from the .devcontainer directory."
|
||||
exit
|
||||
endif
|
||||
cd build/bin && google-pprof --pdf zone prof.out > prof.pdf
|
||||
pprof-web-zone:
|
||||
|
||||
pprof-gv-zone: is-vscode
|
||||
ifeq ($(findstring .devcontainer,$(CURDIR)),.devcontainer)
|
||||
@make -C ../ -f .devcontainer/Makefile pprof-web-zone --no-print-directory
|
||||
exit
|
||||
endif
|
||||
cd build/bin && google-pprof --web zone prof.out
|
||||
pprof-gv-zone:
|
||||
ifeq ($(findstring .devcontainer,$(CURDIR)),.devcontainer)
|
||||
@make -C ../ -f .devcontainer/Makefile pprof-gv-zone --no-print-directory
|
||||
@echo "This makefile is not intended to be run from the .devcontainer directory."
|
||||
exit
|
||||
endif
|
||||
cd build/bin && google-pprof --gv zone prof.out > prof.gv
|
||||
heap-zone:
|
||||
|
||||
heap-zone: is-vscode
|
||||
ifeq ($(findstring .devcontainer,$(CURDIR)),.devcontainer)
|
||||
@make -C ../ -f .devcontainer/Makefile heap-zone --no-print-directory
|
||||
@echo "This makefile is not intended to be run from the .devcontainer directory."
|
||||
exit
|
||||
endif
|
||||
@cd build/bin && mkdir -p tmp
|
||||
cd build/bin && HEAPPROFILE=prof.out ./zone
|
||||
|
||||
|
||||
.PHONY: pull
|
||||
pull:
|
||||
git pull
|
||||
@if [ ! -d "quests" ]; then git clone https://github.com/rebuildeq/quests.git quests; fi
|
||||
cd quests && git pull
|
||||
@if [ ! -d "eqemu-definitions" ]; then git clone https://github.com/xackery/eqemu-definitions.git eqemu-definitions; fi
|
||||
cd eqemu-definitions && git pull
|
||||
@ -40,10 +40,41 @@
|
||||
"GitHub.copilot",
|
||||
"xackery.make-magic",
|
||||
"Gruntfuggly.todo-tree",
|
||||
"ms-vscode.cmake-tools"
|
||||
]
|
||||
"ms-vscode.cmake-tools",
|
||||
"sumneko.lua"
|
||||
],
|
||||
"settings": {
|
||||
"Lua.runtime.version": "Lua 5.1",
|
||||
"Lua.workspace.library": [
|
||||
"/src/repo/eqemu-definitions"
|
||||
],
|
||||
"Lua.diagnostics.disable": [
|
||||
"lowercase-global"
|
||||
],
|
||||
"cmake.statusbar.advanced": {
|
||||
"kit": {
|
||||
"visibility": "hidden"
|
||||
},
|
||||
"debug": {
|
||||
"visibility": "hidden"
|
||||
},
|
||||
"buildTarget": {
|
||||
"visibility": "compact"
|
||||
},
|
||||
"launch": {
|
||||
"visibility": "hidden"
|
||||
},
|
||||
"ctest": {
|
||||
"visibility": "icon"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"mounts": [
|
||||
"source=${localWorkspaceFolder}/.devcontainer/Makefile,target=/src/Makefile,type=bind,consistency=cached"
|
||||
],
|
||||
|
||||
"workspaceFolder": "/src",
|
||||
"workspaceMount": "source=${localWorkspaceFolder},target=/src,type=bind,consistency=cached"
|
||||
}
|
||||
98
.drone.yml
98
.drone.yml
@ -1,98 +0,0 @@
|
||||
---
|
||||
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: Build Linux
|
||||
|
||||
# Limits how many of these builds can run on the drone runner at a time, this isn't about cores
|
||||
concurrency:
|
||||
limit: 1
|
||||
|
||||
volumes:
|
||||
- name: cache
|
||||
host:
|
||||
path: /var/lib/cache-release
|
||||
|
||||
steps:
|
||||
- name: Build Linux X64
|
||||
image: akkadius/eqemu-server:v14
|
||||
environment:
|
||||
GITHUB_TOKEN:
|
||||
from_secret: GH_RELEASE_GITHUB_API_TOKEN
|
||||
RCLONE_CONFIG_REMOTE_TYPE: ftp
|
||||
RCLONE_FTP_HOST: drone.akkadius.com
|
||||
RCLONE_FTP_USER: artifacts
|
||||
RCLONE_FTP_PASS:
|
||||
from_secret: RCLONE_FTP_PASS
|
||||
commands:
|
||||
- ./utils/scripts/build/linux-build.sh
|
||||
volumes:
|
||||
- name: cache
|
||||
path: /home/eqemu/.ccache/
|
||||
|
||||
---
|
||||
|
||||
kind: pipeline
|
||||
type: exec
|
||||
name: Build Windows
|
||||
|
||||
# Limits how many of these builds can run on the drone runner at a time, this isn't about cores
|
||||
concurrency:
|
||||
limit: 1
|
||||
|
||||
platform:
|
||||
os: windows
|
||||
arch: amd64
|
||||
|
||||
steps:
|
||||
- name: Build Windows X64
|
||||
environment:
|
||||
RCLONE_CONFIG_REMOTE_TYPE: ftp
|
||||
RCLONE_FTP_HOST: drone.akkadius.com
|
||||
RCLONE_FTP_USER: artifacts
|
||||
RCLONE_FTP_PASS:
|
||||
from_secret: RCLONE_FTP_PASS
|
||||
GITHUB_TOKEN:
|
||||
from_secret: GH_RELEASE_GITHUB_API_TOKEN
|
||||
commands:
|
||||
- .\utils\scripts\build\windows-build.ps1
|
||||
|
||||
---
|
||||
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: Publish Artifacts to Github
|
||||
|
||||
steps:
|
||||
- name: Upload Artifacts
|
||||
image: akkadius/eqemu-build-releaser:v3
|
||||
environment:
|
||||
RCLONE_CONFIG_REMOTE_TYPE: ftp
|
||||
RCLONE_FTP_HOST: drone.akkadius.com
|
||||
RCLONE_FTP_USER: artifacts
|
||||
RCLONE_FTP_PASS:
|
||||
from_secret: RCLONE_FTP_PASS
|
||||
GH_RELEASE_GITHUB_API_TOKEN:
|
||||
from_secret: GH_RELEASE_GITHUB_API_TOKEN
|
||||
GITHUB_TOKEN:
|
||||
from_secret: GH_RELEASE_GITHUB_API_TOKEN
|
||||
commands:
|
||||
- ./utils/scripts/build/should-release/should-release
|
||||
- rclone config create remote ftp env_auth true > /dev/null
|
||||
- |
|
||||
rclone copy remote: --include "eqemu-server*.zip" .
|
||||
- gh-release --assets=eqemu-server-linux-x64.zip,eqemu-server-windows-x64.zip -y
|
||||
- |
|
||||
rclone delete remote: --include "eqemu-server*.zip"
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
- master
|
||||
event:
|
||||
- push
|
||||
|
||||
depends_on:
|
||||
- Build Windows
|
||||
- Build Linux
|
||||
|
||||
|
||||
81
.github/workflows/build.yaml
vendored
Normal file
81
.github/workflows/build.yaml
vendored
Normal file
@ -0,0 +1,81 @@
|
||||
name: Build
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
linux:
|
||||
name: Linux
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout source
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Setup ccache
|
||||
uses: hendrikmuhs/ccache-action@v1.2
|
||||
with:
|
||||
key: ${{ runner.os }}-ccache
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y build-essential ninja-build ccache uuid-dev
|
||||
|
||||
- name: Configure
|
||||
run: |
|
||||
cmake -S . -B build -G Ninja \
|
||||
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
|
||||
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
|
||||
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
|
||||
-DEQEMU_BUILD_TESTS=ON \
|
||||
-DEQEMU_BUILD_LOGIN=ON \
|
||||
-DEQEMU_BUILD_LUA=ON \
|
||||
-DEQEMU_BUILD_PERL=ON \
|
||||
-DEQEMU_BUILD_CLIENT_FILES=ON
|
||||
|
||||
- name: Build
|
||||
run: cmake --build build --parallel
|
||||
|
||||
- name: Test
|
||||
working-directory: build
|
||||
run: ./bin/tests
|
||||
|
||||
windows:
|
||||
name: Windows
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- name: Checkout source
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Enable long paths
|
||||
run: git config --global core.longpaths true
|
||||
|
||||
- name: Setup MSVC environment
|
||||
uses: ilammy/msvc-dev-cmd@v1
|
||||
with:
|
||||
arch: x64
|
||||
|
||||
- name: Configure
|
||||
shell: pwsh
|
||||
run: |
|
||||
cmake -S . -B build -G "Visual Studio 17 2022" -A x64 `
|
||||
-DCMAKE_BUILD_TYPE=RelWithDebInfo `
|
||||
-DEQEMU_BUILD_TESTS=ON `
|
||||
-DEQEMU_BUILD_LOGIN=ON `
|
||||
-DEQEMU_BUILD_LUA=ON `
|
||||
-DEQEMU_BUILD_ZLIB=ON `
|
||||
-DEQEMU_BUILD_CLIENT_FILES=ON
|
||||
|
||||
- name: Build
|
||||
shell: pwsh
|
||||
run: cmake --build build --config RelWithDebInfo --target ALL_BUILD -- /m
|
||||
|
||||
- name: Test
|
||||
working-directory: build
|
||||
run: ./bin/RelWithDebInfo/tests.exe
|
||||
18
.gitmodules
vendored
18
.gitmodules
vendored
@ -1,18 +1,6 @@
|
||||
[submodule "submodules/glm"]
|
||||
path = submodules/glm
|
||||
url = https://github.com/g-truc/glm.git
|
||||
[submodule "submodules/fmt"]
|
||||
path = submodules/fmt
|
||||
url = https://github.com/fmtlib/fmt.git
|
||||
[submodule "submodules/libuv"]
|
||||
path = submodules/libuv
|
||||
url = https://github.com/libuv/libuv.git
|
||||
[submodule "submodules/cereal"]
|
||||
path = submodules/cereal
|
||||
url = https://github.com/USCiLab/cereal.git
|
||||
[submodule "submodules/websocketpp"]
|
||||
path = submodules/websocketpp
|
||||
url = https://github.com/zaphoyd/websocketpp.git
|
||||
[submodule "submodules/recastnavigation"]
|
||||
path = submodules/recastnavigation
|
||||
url = https://github.com/EQEmu/recastnavigation.git
|
||||
[submodule "submodules/vcpkg"]
|
||||
path = submodules/vcpkg
|
||||
url = https://github.com/microsoft/vcpkg.git
|
||||
|
||||
25
.vscode/settings.json
vendored
25
.vscode/settings.json
vendored
@ -21,14 +21,6 @@
|
||||
"${workspaceFolder}/dependencies/zlibng"
|
||||
],
|
||||
"telemetry.enableTelemetry": false,
|
||||
"cmake.buildDirectory": "${workspaceFolder}/build",
|
||||
"cmake.configureArgs": [
|
||||
"-DEQEMU_BUILD_LOGIN=ON",
|
||||
"-DEQEMU_BUILD_TESTS=ON",
|
||||
"-DCMAKE_CXX_COMPILER_LAUNCHER=ccache",
|
||||
"-DEQEMU_ADD_PROFILER=ON",
|
||||
"Ninja"
|
||||
],
|
||||
"cmake.skipConfigureIfCachePresent": true,
|
||||
"cmake.configureOnOpen": false,
|
||||
"files.associations": {
|
||||
@ -115,22 +107,5 @@
|
||||
"format": "cpp",
|
||||
"ranges": "cpp",
|
||||
"span": "cpp"
|
||||
},
|
||||
"cmake.statusbar.advanced": {
|
||||
"kit": {
|
||||
"visibility": "hidden",
|
||||
},
|
||||
"debug": {
|
||||
"visibility": "hidden",
|
||||
},
|
||||
"buildTarget": {
|
||||
"visibility": "hidden",
|
||||
},
|
||||
"launch": {
|
||||
"visibility": "hidden",
|
||||
},
|
||||
"ctest": {
|
||||
"visibility": "icon",
|
||||
}
|
||||
}
|
||||
}
|
||||
21
BUILD.md
21
BUILD.md
@ -4,46 +4,35 @@ This guide is far from exhaustive, you should expect to have some experience wit
|
||||
|
||||
### CMake
|
||||
|
||||
EQEmu uses CMake as the build system on all platforms. You will need CMake 3.2 or higher to build from source.
|
||||
EQEmu uses CMake as the build system on all platforms. You will need CMake 3.20 or higher to build from source.
|
||||
|
||||
### Dependencies
|
||||
|
||||
The following libraries are required to build from source:
|
||||
- [boost](https://www.boost.org/ "boost")
|
||||
- [zlib](https://www.zlib.net/ "zlib") (If not included the source will build [zlib-ng](https://github.com/zlib-ng/zlib-ng "zlib-ng") instead)
|
||||
- [libmysql](https://dev.mysql.com/downloads/connector/c/ "libmysql") or [libmariadb](https://github.com/MariaDB/mariadb-connector-c "libmariadb")
|
||||
- uuid (unix)
|
||||
|
||||
The following libraries are not strictly required but in many cased recommended.
|
||||
- [OpenSSL](https://www.openssl.org/ "OpenSSL") or [mbedTLS](https://tls.mbed.org/ "mbedTLS") (Required for the loginserver and headless client)
|
||||
- [libsodium](https://github.com/jedisct1/libsodium "libsodium") (Required for strong password hashing on the loginserver)
|
||||
- [Lua 5.1](https://www.lua.org/ "Lua 5.1") or [LuaJit](http://luajit.org/ "LuaJit") (Required for Lua Quest Scripting)
|
||||
- [Perl](https://www.perl.org/ "Perl") (Required for Perl Quest Scripting)
|
||||
|
||||
##### Windows
|
||||
For windows it is suggested you make use of [vcpkg](https://github.com/microsoft/vcpkg "vcpkg") if you wish to build your own dependencies.
|
||||
|
||||
If you wish to use Perl then you should use whichever version of Perl you have installed on the target system.
|
||||
|
||||
You can also download a vcpkg export from our releases section for Visual Studio [x86](https://github.com/EQEmu/Server/releases/download/v1.2/vcpkg-export-x86.zip "x86") or [x64](https://github.com/EQEmu/Server/releases/download/v1.2/vcpkg-export-x64.zip "x64") that includes a toolchain file you can pass to CMake.
|
||||
|
||||
##### Linux
|
||||
For Linux you simply can install the dependencies from your package manager, below is an example of doing it on Ubuntu using apt-get.
|
||||
|
||||
sudo apt-get install libmysqlclient-dev libperl-dev libboost-dev liblua5.1-0-dev zlib1g-dev uuid-dev libssl-dev
|
||||
sudo apt-get install libperl-dev uuid-dev
|
||||
|
||||
### Running CMake
|
||||
|
||||
##### Windows
|
||||
The following is a modified command our automated build server uses to run CMake via the release vcpkg export and its toolchain file.
|
||||
|
||||
Assuming it is starting in c:/projects/eqemu and the x64 dependencies were extracted to c:/projects/eqemu/vcpkg.
|
||||
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -G "Visual Studio 15 2017 Win64" -DEQEMU_BUILD_TESTS=ON -DEQEMU_BUILD_LOGIN=ON -DEQEMU_BUILD_ZLIB=ON -DCMAKE_TOOLCHAIN_FILE="c:/projects/eqemu/vcpkg/vcpkg-export-20180828-145455/scripts/buildsystems/vcpkg.cmake" ..
|
||||
cmake -G "Visual Studio 15 2022 Win64" -DEQEMU_BUILD_TESTS=ON -DEQEMU_BUILD_LOGIN=ON ..
|
||||
|
||||
##### Linux
|
||||
Similarly to Windows running CMake on Linux is simple it just omits the toolchain file and uses a different generator.
|
||||
Similarly to Windows running CMake on Linux is simple it just uses a different generator.
|
||||
|
||||
mkdir build
|
||||
cd build
|
||||
|
||||
@ -1,3 +1,9 @@
|
||||
## [23.10.3] 9/16/2025
|
||||
|
||||
### Hotfix
|
||||
|
||||
* Hotfix crashes occurring in #4987. @Akkadius 2025-09-17
|
||||
|
||||
## [23.10.2] 9/16/2025
|
||||
|
||||
### Hotfix
|
||||
|
||||
608
CMakeLists.txt
608
CMakeLists.txt
@ -1,490 +1,180 @@
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 3.12)
|
||||
cmake_minimum_required(VERSION 3.20.0)
|
||||
|
||||
SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/" ${CMAKE_MODULE_PATH})
|
||||
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/" ${CMAKE_MODULE_PATH})
|
||||
|
||||
IF(POLICY CMP0074)
|
||||
CMAKE_POLICY(SET CMP0074 NEW)
|
||||
ENDIF()
|
||||
if(NOT CMAKE_TOOLCHAIN_FILE)
|
||||
if(DEFINED ENV{VCPKG_ROOT})
|
||||
message(STATUS "Using vcpkg from VCPKG_ROOT")
|
||||
set(CMAKE_TOOLCHAIN_FILE
|
||||
"$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
|
||||
CACHE FILEPATH "Vcpkg toolchain file"
|
||||
)
|
||||
else()
|
||||
message(STATUS "Using vcpkg submodule")
|
||||
set(CMAKE_TOOLCHAIN_FILE
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/submodules/vcpkg/scripts/buildsystems/vcpkg.cmake"
|
||||
CACHE FILEPATH "Vcpkg toolchain file"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
PROJECT(EQEmu)
|
||||
project(EQEmu
|
||||
VERSION 24.10.3
|
||||
LANGUAGES CXX
|
||||
)
|
||||
|
||||
IF(NOT CMAKE_BUILD_TYPE)
|
||||
SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build." FORCE)
|
||||
ENDIF(NOT CMAKE_BUILD_TYPE)
|
||||
#explicitly set CMP0167 for Find Boost
|
||||
if(POLICY CMP0167)
|
||||
cmake_policy(SET CMP0167 NEW)
|
||||
endif()
|
||||
|
||||
SET(CMAKE_CXX_STANDARD 20)
|
||||
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
SET(CMAKE_CXX_EXTENSIONS OFF)
|
||||
if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Build type")
|
||||
endif()
|
||||
|
||||
OPTION(EQEMU_BUILD_STATIC "Build with static linking" OFF)
|
||||
OPTION(EQEMU_BUILD_PCH "Build with precompiled headers (Windows)" ON)
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
|
||||
IF (EQEMU_BUILD_STATIC)
|
||||
SET(BUILD_SHARED_LIBS OFF)
|
||||
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".lib" ".a")
|
||||
MESSAGE(STATUS "Building with static linking")
|
||||
SET(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++")
|
||||
IF (UNIX)
|
||||
SET(PERL_LIBRARY "/opt/eqemu-perl/lib/5.32.1/x86_64-linux-thread-multi/CORE/libperl.so")
|
||||
SET(PERL_INCLUDE_PATH "/opt/eqemu-perl/lib/5.32.1/x86_64-linux-thread-multi/CORE/")
|
||||
SET(PERL_EXECUTABLE "/opt/eqemu-perl/bin/perl")
|
||||
ENDIF ()
|
||||
ENDIF (EQEMU_BUILD_STATIC)
|
||||
option(EQEMU_BUILD_PCH "Build with precompiled headers (Windows)" ON)
|
||||
|
||||
|
||||
# Requires libgoogle-perftools-dev google-perftools packages for linux (debian)
|
||||
IF(EQEMU_ADD_PROFILER)
|
||||
SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--no-as-needed,-lprofiler,--as-needed")
|
||||
ENDIF(EQEMU_ADD_PROFILER)
|
||||
|
||||
IF(USE_MAP_MMFS)
|
||||
ADD_DEFINITIONS(-DUSE_MAP_MMFS)
|
||||
ENDIF (USE_MAP_MMFS)
|
||||
|
||||
IF(MSVC)
|
||||
if(MSVC)
|
||||
add_compile_options(/bigobj)
|
||||
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
|
||||
ADD_DEFINITIONS(-DNOMINMAX)
|
||||
ADD_DEFINITIONS(-DCRASH_LOGGING)
|
||||
ADD_DEFINITIONS(-D_HAS_AUTO_PTR_ETC) # for Luabind on C++17
|
||||
add_compile_definitions(_CRT_SECURE_NO_WARNINGS NOMINMAX CRASH_LOGGING _HAS_AUTO_PTR_ETC)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
|
||||
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
|
||||
|
||||
OPTION(EQEMU_DISABLE_MSVC_WARNINGS "Disable MSVC compile warnings." ON)
|
||||
IF(EQEMU_DISABLE_MSVC_WARNINGS)
|
||||
ADD_DEFINITIONS( "/W0 /D_CRT_SECURE_NO_WARNINGS /wd4005 /wd4996 /nologo /Os")
|
||||
ENDIF(EQEMU_DISABLE_MSVC_WARNINGS)
|
||||
ELSE(MSVC)
|
||||
ADD_DEFINITIONS(-DHAS_UNION_SEMUN)
|
||||
ENDIF(MSVC)
|
||||
option(EQEMU_DISABLE_MSVC_WARNINGS "Disable MSVC compile warnings." ON)
|
||||
if(EQEMU_DISABLE_MSVC_WARNINGS)
|
||||
add_compile_options(/W0 /wd4005 /wd4996 /nologo /Os)
|
||||
endif()
|
||||
else()
|
||||
add_compile_definitions(HAS_UNION_SEMUN)
|
||||
endif()
|
||||
|
||||
#FreeBSD support
|
||||
IF(UNIX)
|
||||
IF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
|
||||
ADD_DEFINITIONS(-DFREEBSD)
|
||||
ADD_DEFINITIONS(-D_GLIBCXX_USE_C99)
|
||||
SET(FREEBSD TRUE)
|
||||
ENDIF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
|
||||
IF(CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||
ADD_DEFINITIONS(-DDARWIN)
|
||||
SET(DARWIN TRUE)
|
||||
ENDIF(CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||
ENDIF(UNIX)
|
||||
if(UNIX)
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
|
||||
add_compile_definitions(FREEBSD)
|
||||
add_compile_definitions(_GLIBCXX_USE_C99)
|
||||
set(FREEBSD TRUE)
|
||||
endif()
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||
add_compile_definitions(DARWIN)
|
||||
set(DARWIN TRUE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
ADD_DEFINITIONS(-DGLM_FORCE_RADIANS)
|
||||
ADD_DEFINITIONS(-DGLM_FORCE_CTOR_INIT)
|
||||
ADD_DEFINITIONS(-DGLM_ENABLE_EXPERIMENTAL)
|
||||
find_package(Boost REQUIRED COMPONENTS dynamic_bitset foreach tuple)
|
||||
find_package(cereal CONFIG REQUIRED)
|
||||
find_package(fmt CONFIG REQUIRED)
|
||||
find_package(glm CONFIG REQUIRED)
|
||||
find_package(unofficial-libmariadb CONFIG REQUIRED)
|
||||
find_package(libuv CONFIG REQUIRED)
|
||||
find_package(OpenSSL REQUIRED)
|
||||
find_package(recastnavigation CONFIG REQUIRED)
|
||||
find_package(ZLIB REQUIRED)
|
||||
find_package(LuaJit REQUIRED)
|
||||
find_package(unofficial-sodium CONFIG REQUIRED)
|
||||
find_package(PerlLibs)
|
||||
|
||||
#MSVC can fetch dependencies automatically.
|
||||
IF(MSVC)
|
||||
INCLUDE("${CMAKE_SOURCE_DIR}/cmake/DependencyHelperMSVC.cmake")
|
||||
ENDIF()
|
||||
message(STATUS "**************************************************")
|
||||
message(STATUS "* Library Detection *")
|
||||
message(STATUS "**************************************************")
|
||||
|
||||
#Find everything we need
|
||||
FIND_PACKAGE(Boost REQUIRED)
|
||||
FIND_PACKAGE(MySQL)
|
||||
FIND_PACKAGE(MariaDB)
|
||||
FIND_PACKAGE(ZLIB)
|
||||
FIND_PACKAGE(OpenSSL)
|
||||
FIND_PACKAGE(Lua51)
|
||||
FIND_PACKAGE(LuaJit)
|
||||
FIND_PACKAGE(PerlLibs)
|
||||
FIND_PACKAGE(Sodium)
|
||||
FIND_PACKAGE(mbedTLS)
|
||||
if(MARIADB_FOUND)
|
||||
message(STATUS "* MariaDB: FOUND *")
|
||||
else()
|
||||
message(STATUS "* MariaDB: MISSING *")
|
||||
endif()
|
||||
|
||||
MESSAGE(STATUS "**************************************************")
|
||||
MESSAGE(STATUS "* Library Detection *")
|
||||
MESSAGE(STATUS "**************************************************")
|
||||
if(ZLIB_FOUND)
|
||||
message(STATUS "* ZLIB: FOUND *")
|
||||
else()
|
||||
message(STATUS "* ZLIB: MISSING *")
|
||||
endif()
|
||||
|
||||
IF(MYSQL_FOUND)
|
||||
MESSAGE(STATUS "* MySQL: FOUND *")
|
||||
ELSE()
|
||||
MESSAGE(STATUS "* MySQL: MISSING *")
|
||||
ENDIF()
|
||||
if(LuaJit_FOUND)
|
||||
message(STATUS "* LuaJIT: FOUND *")
|
||||
else()
|
||||
message(STATUS "* LuaJIT: MISSING *")
|
||||
endif()
|
||||
|
||||
IF(MARIADB_FOUND)
|
||||
MESSAGE(STATUS "* MariaDB: FOUND *")
|
||||
ELSE()
|
||||
MESSAGE(STATUS "* MariaDB: MISSING *")
|
||||
ENDIF()
|
||||
if(PerlLibs_FOUND)
|
||||
message(STATUS "* Perl: FOUND *")
|
||||
else()
|
||||
message(STATUS "* Perl: MISSING *")
|
||||
endif()
|
||||
|
||||
IF(ZLIB_FOUND)
|
||||
MESSAGE(STATUS "* ZLIB: FOUND *")
|
||||
ELSE()
|
||||
MESSAGE(STATUS "* ZLIB: MISSING *")
|
||||
ENDIF()
|
||||
if(OpenSSL_FOUND)
|
||||
message(STATUS "* OpenSSL: FOUND *")
|
||||
else()
|
||||
message(STATUS "* OpenSSL: MISSING *")
|
||||
endif()
|
||||
|
||||
IF(Lua51_FOUND)
|
||||
MESSAGE(STATUS "* Lua: FOUND *")
|
||||
ELSE()
|
||||
MESSAGE(STATUS "* Lua: MISSING *")
|
||||
ENDIF()
|
||||
|
||||
IF(LuaJit_FOUND)
|
||||
MESSAGE(STATUS "* LuaJIT: FOUND *")
|
||||
ELSE()
|
||||
MESSAGE(STATUS "* LuaJIT: MISSING *")
|
||||
ENDIF()
|
||||
|
||||
IF(PerlLibs_FOUND)
|
||||
MESSAGE(STATUS "* Perl: FOUND *")
|
||||
ELSE()
|
||||
MESSAGE(STATUS "* Perl: MISSING *")
|
||||
ENDIF()
|
||||
|
||||
IF(SODIUM_FOUND)
|
||||
MESSAGE(STATUS "* libsodium: FOUND *")
|
||||
ELSE()
|
||||
MESSAGE(STATUS "* libsodium: MISSING *")
|
||||
ENDIF()
|
||||
|
||||
IF(OpenSSL_FOUND)
|
||||
MESSAGE(STATUS "* OpenSSL: FOUND *")
|
||||
ELSE()
|
||||
MESSAGE(STATUS "* OpenSSL: MISSING *")
|
||||
ENDIF()
|
||||
|
||||
IF(MBEDTLS_FOUND)
|
||||
MESSAGE(STATUS "* mbedTLS: FOUND *")
|
||||
ELSE()
|
||||
MESSAGE(STATUS "* mbedTLS: MISSING *")
|
||||
ENDIF()
|
||||
|
||||
MESSAGE(STATUS "PERL_INCLUDE_PATH: ${PERL_INCLUDE_PATH}")
|
||||
MESSAGE(STATUS "PERL_LIBRARY: ${PERL_LIBRARY}")
|
||||
MESSAGE(STATUS "PERL_INCLUDE_DIR: ${PERL_INCLUDE_DIR}")
|
||||
MESSAGE(STATUS "PERL_INCLUDE_DIRS: ${PERL_INCLUDE_DIRS}")
|
||||
MESSAGE(STATUS "PERL_LIBRARIES: ${PERL_LIBRARIES}")
|
||||
MESSAGE(STATUS "PERL_VERSION: ${PERL_VERSION}")
|
||||
|
||||
MESSAGE(STATUS "**************************************************")
|
||||
message(STATUS "PERL_INCLUDE_PATH: ${PERL_INCLUDE_PATH}")
|
||||
message(STATUS "PERL_LIBRARY: ${PERL_LIBRARY}")
|
||||
message(STATUS "PERL_INCLUDE_DIR: ${PERL_INCLUDE_DIR}")
|
||||
message(STATUS "PERL_INCLUDE_DIRS: ${PERL_INCLUDE_DIRS}")
|
||||
message(STATUS "PERL_LIBRARIES: ${PERL_LIBRARIES}")
|
||||
message(STATUS "PERL_VERSION: ${PERL_VERSION}")
|
||||
message(STATUS "**************************************************")
|
||||
|
||||
#options
|
||||
OPTION(EQEMU_COMMANDS_LOGGING "Enable GM Command logs" ON)
|
||||
OPTION(EQEMU_BUILD_SERVER "Build the game server." ON)
|
||||
OPTION(EQEMU_BUILD_LOGIN "Build the login server." ON)
|
||||
OPTION(EQEMU_BUILD_HC "Build the headless client." OFF)
|
||||
OPTION(EQEMU_BUILD_TESTS "Build utility tests." OFF)
|
||||
OPTION(EQEMU_BUILD_CLIENT_FILES "Build Client Import/Export Data Programs." ON)
|
||||
OPTION(EQEMU_PREFER_LUA "Build with normal Lua even if LuaJIT is found." OFF)
|
||||
option(EQEMU_BUILD_SERVER "Build the game server." ON)
|
||||
option(EQEMU_BUILD_LOGIN "Build the login server." ON)
|
||||
option(EQEMU_BUILD_TESTS "Build utility tests." OFF)
|
||||
option(EQEMU_BUILD_CLIENT_FILES "Build Client Import/Export Data Programs." ON)
|
||||
|
||||
#PRNG options
|
||||
OPTION(EQEMU_ADDITIVE_LFIB_PRNG "Use Additive LFib for PRNG." OFF)
|
||||
MARK_AS_ADVANCED(EQEMU_ADDITIVE_LFIB_PRNG)
|
||||
OPTION(EQEMU_BIASED_INT_DIST "Use biased int dist instead of uniform." OFF)
|
||||
MARK_AS_ADVANCED(EQEMU_BIASED_INT_DIST)
|
||||
SET(EQEMU_CUSTOM_PRNG_ENGINE "" CACHE STRING "Custom random engine. (ex. std::default_random_engine)")
|
||||
MARK_AS_ADVANCED(EQEMU_CUSTOM_PRNG_ENGINE)
|
||||
if(PerlLibs_FOUND)
|
||||
option(EQEMU_BUILD_PERL "Build Perl parser." ON)
|
||||
|
||||
if(EQEMU_BUILD_PERL)
|
||||
set(PERL_LIBRARY_TYPE " Perl")
|
||||
else()
|
||||
set(PERL_LIBRARY_TYPE " Missing")
|
||||
endif()
|
||||
else()
|
||||
set(PERL_LIBRARY_TYPE "Disabled")
|
||||
endif()
|
||||
|
||||
IF(CMAKE_COMPILER_IS_GNUCXX)
|
||||
OPTION(EQEMU_SFMT19937 "Use GCC's extention for SIMD Fast MT19937." OFF)
|
||||
MARK_AS_ADVANCED(EQEMU_SFMT19937)
|
||||
ENDIF()
|
||||
message(STATUS "")
|
||||
message(STATUS "**************************************************")
|
||||
message(STATUS "* Library Usage *")
|
||||
message(STATUS "**************************************************")
|
||||
message(STATUS "* Database: MariaDB *")
|
||||
message(STATUS "* TLS: OpenSSL *")
|
||||
message(STATUS "* Lua: LuaJIT *")
|
||||
message(STATUS "* Perl: ${PERL_LIBRARY_TYPE} *")
|
||||
message(STATUS "* zlib: ZLIB *")
|
||||
message(STATUS "**************************************************")
|
||||
|
||||
IF(EQEMU_ADDITIVE_LFIB_PRNG)
|
||||
ADD_DEFINITIONS(-DUSE_ADDITIVE_LFIB_PRNG)
|
||||
IF(EQEMU_SFMT19937)
|
||||
MESSAGE(STATUS "SFMT19937 and ADDITITVE_LFIB_PRNG both set, SFMT19937 ignored.")
|
||||
SET(EQEMU_SFMT19937 OFF)
|
||||
ENDIF()
|
||||
IF(NOT EQEMU_CUSTOM_PRNG_ENGINE STREQUAL "")
|
||||
MESSAGE(STATUS "CUSTOM_PRNG_ENGINE and ADDITITVE_LFIB_PRNG both set, CUSTOM_PRNG_ENGINE ignored.")
|
||||
SET(EQEMU_CUSTOM_PRNG_ENGINE "")
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
IF(EQEMU_SFMT19937)
|
||||
ADD_DEFINITIONS(-DUSE_SFMT19937)
|
||||
IF(NOT EQEMU_CUSTOM_PRNG_ENGINE STREQUAL "")
|
||||
MESSAGE(STATUS "CUSTOM_PRNG_ENGINE and SFMT19937 both set, CUSTOM_PRNG_ENGINE ignored.")
|
||||
SET(EQEMU_CUSTOM_PRNG_ENGINE "")
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
option(EQEMU_BUILD_LUA "Build Lua parser." ON)
|
||||
|
||||
IF(NOT EQEMU_CUSTOM_PRNG_ENGINE STREQUAL "")
|
||||
ADD_DEFINITIONS(-DUSE_CUSTOM_PRNG_ENGINE=${EQEMU_CUSTOM_PRNG_ENGINE})
|
||||
ENDIF()
|
||||
if(EQEMU_BUILD_SERVER OR EQEMU_BUILD_LOGIN OR EQEMU_BUILD_TESTS OR EQEMU_BUILD_CLIENT_FILES)
|
||||
add_subdirectory(common)
|
||||
add_subdirectory(libs)
|
||||
else()
|
||||
message(FATAL_ERROR "No targets were selected to build, we must build at least one target.")
|
||||
endif()
|
||||
|
||||
IF(EQEMU_BIASED_INT_DIST)
|
||||
ADD_DEFINITIONS(-DBIASED_INT_DIST)
|
||||
ENDIF()
|
||||
if(EQEMU_BUILD_SERVER)
|
||||
add_subdirectory(shared_memory)
|
||||
add_subdirectory(world)
|
||||
add_subdirectory(zone)
|
||||
add_subdirectory(ucs)
|
||||
add_subdirectory(queryserv)
|
||||
add_subdirectory(eqlaunch)
|
||||
endif()
|
||||
|
||||
IF(EQEMU_COMMANDS_LOGGING)
|
||||
ADD_DEFINITIONS(-DCOMMANDS_LOGGING)
|
||||
ENDIF(EQEMU_COMMANDS_LOGGING)
|
||||
if(EQEMU_BUILD_LOGIN)
|
||||
add_subdirectory(loginserver)
|
||||
endif()
|
||||
|
||||
#database
|
||||
IF(MySQL_FOUND AND MariaDB_FOUND)
|
||||
SET(DATABASE_LIBRARY_SELECTION MariaDB CACHE STRING "Database library to use:
|
||||
MySQL
|
||||
MariaDB"
|
||||
)
|
||||
if(EQEMU_BUILD_TESTS)
|
||||
add_subdirectory(tests)
|
||||
endif()
|
||||
|
||||
IF(DATABASE_LIBRARY_SELECTION STREQUAL "MySQL")
|
||||
SET(DATABASE_LIBRARY_TYPE " MySQL")
|
||||
SET(DATABASE_LIBRARY_LIBS ${MySQL_LIBRARIES})
|
||||
SET(DATABASE_LIBRARY_INCLUDE ${MySQL_INCLUDE_DIR})
|
||||
ELSEIF(DATABASE_LIBRARY_SELECTION STREQUAL "MariaDB")
|
||||
SET(DATABASE_LIBRARY_TYPE "MariaDB")
|
||||
SET(DATABASE_LIBRARY_LIBS ${MariaDB_LIBRARIES})
|
||||
SET(DATABASE_LIBRARY_INCLUDE ${MariaDB_INCLUDE_DIR})
|
||||
ELSE()
|
||||
MESSAGE(FATAL_ERROR "Unknown database library set, should be one of: MySQL, MariaDB")
|
||||
ENDIF()
|
||||
ELSEIF(MariaDB_FOUND)
|
||||
SET(DATABASE_LIBRARY_TYPE "MariaDB")
|
||||
SET(DATABASE_LIBRARY_LIBS ${MariaDB_LIBRARIES})
|
||||
SET(DATABASE_LIBRARY_INCLUDE ${MariaDB_INCLUDE_DIR})
|
||||
ELSEIF(MySQL_FOUND)
|
||||
SET(DATABASE_LIBRARY_TYPE " MySQL")
|
||||
SET(DATABASE_LIBRARY_LIBS ${MySQL_LIBRARIES})
|
||||
SET(DATABASE_LIBRARY_INCLUDE ${MySQL_INCLUDE_DIR})
|
||||
ELSE()
|
||||
MESSAGE(FATAL_ERROR "One of MySQL or MariaDB is a required dependency.")
|
||||
ENDIF()
|
||||
|
||||
#security
|
||||
#prefer openssl to mbedtls (arbitrary)
|
||||
IF(OpenSSL_FOUND AND MBEDTLS_FOUND)
|
||||
SET(TLS_LIBRARY_SELECTION OpenSSL CACHE STRING "TLS library to use:
|
||||
OpenSSL
|
||||
mbedTLS"
|
||||
)
|
||||
|
||||
IF(TLS_LIBRARY_SELECTION STREQUAL "OpenSSL")
|
||||
SET(TLS_LIBRARY_TYPE " OpenSSL")
|
||||
SET(TLS_LIBRARY_ENABLED ON)
|
||||
SET(TLS_LIBRARY_LIBS ${OPENSSL_LIBRARIES})
|
||||
SET(TLS_LIBRARY_INCLUDE ${OPENSSL_INCLUDE_DIR})
|
||||
ADD_DEFINITIONS(-DEQEMU_USE_OPENSSL)
|
||||
IF(${OPENSSL_VERSION} VERSION_GREATER_EQUAL "1.1.1")
|
||||
ADD_DEFINITIONS(-DCPPHTTPLIB_OPENSSL_SUPPORT)
|
||||
ENDIF()
|
||||
ELSEIF(TLS_LIBRARY_SELECTION STREQUAL "mbedTLS")
|
||||
SET(TLS_LIBRARY_TYPE " mbedTLS")
|
||||
SET(TLS_LIBRARY_ENABLED ON)
|
||||
SET(TLS_LIBRARY_LIBS ${MBEDTLS_LIBRARY} ${MBEDX509_LIBRARY} ${MBEDCRYPTO_LIBRARY})
|
||||
SET(TLS_LIBRARY_INCLUDE ${MBEDTLS_INCLUDE_DIR})
|
||||
ADD_DEFINITIONS(-DEQEMU_USE_MBEDTLS)
|
||||
ELSE()
|
||||
MESSAGE(FATAL_ERROR "Unknown TLS library set, should be one of: OpenSSL, mbedTLS")
|
||||
ENDIF()
|
||||
ELSEIF(OpenSSL_FOUND)
|
||||
SET(TLS_LIBRARY_TYPE " OpenSSL")
|
||||
SET(TLS_LIBRARY_ENABLED ON)
|
||||
SET(TLS_LIBRARY_LIBS ${OPENSSL_LIBRARIES})
|
||||
SET(TLS_LIBRARY_INCLUDE ${OPENSSL_INCLUDE_DIR})
|
||||
ADD_DEFINITIONS(-DEQEMU_USE_OPENSSL)
|
||||
IF(${OPENSSL_VERSION} VERSION_GREATER_EQUAL "1.1.1")
|
||||
ADD_DEFINITIONS(-DCPPHTTPLIB_OPENSSL_SUPPORT)
|
||||
ENDIF()
|
||||
ELSEIF(MBEDTLS_FOUND)
|
||||
SET(TLS_LIBRARY_TYPE " mbedTLS")
|
||||
SET(TLS_LIBRARY_ENABLED ON)
|
||||
SET(TLS_LIBRARY_LIBS ${MBEDTLS_LIBRARY} ${MBEDX509_LIBRARY} ${MBEDCRYPTO_LIBRARY})
|
||||
SET(TLS_LIBRARY_INCLUDE ${MBEDTLS_INCLUDE_DIR})
|
||||
ADD_DEFINITIONS(-DEQEMU_USE_MBEDTLS)
|
||||
ELSE()
|
||||
SET(TLS_LIBRARY_TYPE "Disabled")
|
||||
SET(TLS_LIBRARY_ENABLED OFF)
|
||||
ENDIF()
|
||||
|
||||
IF(SODIUM_FOUND)
|
||||
SET(SODIUM_LIBRARY_TYPE "Libsodium")
|
||||
SET(SODIUM_LIBRARY_ENABLED ON)
|
||||
SET(SODIUM_LIBRARY_LIBS ${SODIUM_LIBRARIES})
|
||||
SET(SODIUM_LIBRARY_INCLUDE ${SODIUM_INCLUDE_DIRS})
|
||||
ADD_DEFINITIONS(-DENABLE_SECURITY)
|
||||
ELSE()
|
||||
SET(SODIUM_LIBRARY_TYPE " Disabled")
|
||||
SET(SODIUM_LIBRARY_ENABLED OFF)
|
||||
ENDIF()
|
||||
|
||||
IF(LUAJIT_FOUND AND NOT (EQEMU_PREFER_LUA AND Lua51_FOUND))
|
||||
SET(LUA_LIBRARY_TYPE " LuaJIT")
|
||||
SET(LUA_LIBRARY_ENABLED ON)
|
||||
SET(LUA_LIBRARY_LIBS ${LUAJIT_LIBRARY} luabind)
|
||||
SET(LUA_LIBRARY_INCLUDE ${LUAJIT_INCLUDE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/libs/luabind")
|
||||
ELSEIF(Lua51_FOUND )
|
||||
SET(LUA_LIBRARY_TYPE " Lua 5.1")
|
||||
SET(LUA_LIBRARY_ENABLED ON)
|
||||
SET(LUA_LIBRARY_LIBS ${LUA_LIBRARY} luabind)
|
||||
SET(LUA_LIBRARY_INCLUDE ${LUA_INCLUDE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/libs/luabind")
|
||||
ELSE()
|
||||
SET(LUA_LIBRARY_TYPE "Disabled")
|
||||
SET(LUA_LIBRARY_ENABLED OFF)
|
||||
ENDIF()
|
||||
|
||||
IF(PerlLibs_FOUND)
|
||||
SET(PERL_LIBRARY_TYPE " Perl")
|
||||
SET(PERL_LIBRARY_ENABLED ON)
|
||||
SET(PERL_LIBRARY_LIBS ${PERL_LIBRARY})
|
||||
SET(PERL_LIBRARY_INCLUDE ${PERL_INCLUDE_PATH})
|
||||
ELSE()
|
||||
SET(PERL_LIBRARY_TYPE "Disabled")
|
||||
SET(PERL_LIBRARY_ENABLED OFF)
|
||||
ENDIF()
|
||||
|
||||
#use zlib if exists
|
||||
IF(ZLIB_FOUND)
|
||||
OPTION(EQEMU_BUILD_ZLIB "Build internal version of zlib." ON)
|
||||
IF(EQEMU_BUILD_ZLIB)
|
||||
SET(ZLIB_LIBRARY_TYPE "zlib-ng")
|
||||
SET(ZLIB_LIBRARY_LIBS "zlibstatic")
|
||||
SET(ZLIB_LIBRARY_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/libs/zlibng")
|
||||
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_BINARY_DIR}/libs/zlibng")
|
||||
ELSE()
|
||||
SET(ZLIB_LIBRARY_TYPE " zlib")
|
||||
SET(ZLIB_LIBRARY_LIBS ${ZLIB_LIBRARY})
|
||||
SET(ZLIB_LIBRARY_INCLUDE ${ZLIB_INCLUDE_DIRS})
|
||||
ENDIF()
|
||||
ELSE()
|
||||
SET(ZLIB_LIBRARY_TYPE "zlib-ng")
|
||||
SET(ZLIB_LIBRARY_LIBS "zlibstatic")
|
||||
SET(ZLIB_LIBRARY_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/libs/zlibng")
|
||||
ENDIF()
|
||||
|
||||
IF (EQEMU_BUILD_STATIC)
|
||||
SET(ZLIB_LIBRARY_LIBS libz.a)
|
||||
ENDIF(EQEMU_BUILD_STATIC)
|
||||
|
||||
MESSAGE(STATUS "")
|
||||
MESSAGE(STATUS "**************************************************")
|
||||
MESSAGE(STATUS "* Library Usage *")
|
||||
MESSAGE(STATUS "**************************************************")
|
||||
MESSAGE(STATUS "* Database: ${DATABASE_LIBRARY_TYPE} *")
|
||||
MESSAGE(STATUS "* TLS: ${TLS_LIBRARY_TYPE} *")
|
||||
MESSAGE(STATUS "* Sodium: ${SODIUM_LIBRARY_TYPE} *")
|
||||
MESSAGE(STATUS "* Lua: ${LUA_LIBRARY_TYPE} *")
|
||||
MESSAGE(STATUS "* Perl: ${PERL_LIBRARY_TYPE} *")
|
||||
MESSAGE(STATUS "* zlib: ${ZLIB_LIBRARY_TYPE} *")
|
||||
MESSAGE(STATUS "**************************************************")
|
||||
|
||||
#setup server libs and headers
|
||||
SET(SERVER_LIBS common ${DATABASE_LIBRARY_LIBS} ${ZLIB_LIBRARY_LIBS} ${Boost_LIBRARIES} uv_a fmt RecastNavigation::Detour)
|
||||
|
||||
set(FMT_HEADER_ONLY OFF)
|
||||
|
||||
INCLUDE_DIRECTORIES(SYSTEM "${DATABASE_LIBRARY_INCLUDE}")
|
||||
INCLUDE_DIRECTORIES(SYSTEM "${ZLIB_LIBRARY_INCLUDE}")
|
||||
INCLUDE_DIRECTORIES(SYSTEM "${Boost_INCLUDE_DIRS}")
|
||||
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/glm")
|
||||
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/cereal/include")
|
||||
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/fmt/include")
|
||||
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/libuv/include" )
|
||||
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/recastnavigation/DebugUtils/Include")
|
||||
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/recastnavigation/Detour/Include")
|
||||
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/recastnavigation/DetourCrowd/Include")
|
||||
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/recastnavigation/DetourTileCache/Include")
|
||||
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/recastnavigation/Recast/Include")
|
||||
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/websocketpp")
|
||||
|
||||
# silence obnoxious deprecation message
|
||||
ADD_DEFINITIONS(-DBOOST_BIND_GLOBAL_PLACEHOLDERS)
|
||||
|
||||
IF(TLS_LIBRARY_ENABLED)
|
||||
SET(SERVER_LIBS ${SERVER_LIBS} ${TLS_LIBRARY_LIBS})
|
||||
INCLUDE_DIRECTORIES(SYSTEM "${TLS_LIBRARY_INCLUDE}")
|
||||
ENDIF()
|
||||
|
||||
IF(SODIUM_LIBRARY_ENABLED)
|
||||
SET(SERVER_LIBS ${SERVER_LIBS} ${SODIUM_LIBRARY_LIBS})
|
||||
INCLUDE_DIRECTORIES(SYSTEM "${SODIUM_LIBRARY_INCLUDE}")
|
||||
ENDIF()
|
||||
|
||||
IF(LUA_LIBRARY_ENABLED)
|
||||
OPTION(EQEMU_BUILD_LUA "Build Lua parser." ON)
|
||||
|
||||
IF(EQEMU_BUILD_LUA)
|
||||
ADD_DEFINITIONS(-DLUA_EQEMU)
|
||||
SET(ZONE_LIBS ${LUA_LIBRARY_LIBS})
|
||||
INCLUDE_DIRECTORIES(SYSTEM "${LUA_LIBRARY_INCLUDE}")
|
||||
|
||||
OPTION(EQEMU_SANITIZE_LUA_LIBS "Sanitize Lua Libraries (Remove OS and IO standard libraries from being able to run)." ON)
|
||||
IF(EQEMU_SANITIZE_LUA_LIBS)
|
||||
ADD_DEFINITIONS(-DSANITIZE_LUA_LIBS)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
IF(PERL_LIBRARY_ENABLED)
|
||||
OPTION(EQEMU_BUILD_PERL "Build Perl parser." ON)
|
||||
IF(EQEMU_BUILD_PERL)
|
||||
SET(SERVER_LIBS ${SERVER_LIBS} ${PERL_LIBRARY_LIBS} perlbind)
|
||||
INCLUDE_DIRECTORIES(SYSTEM "${PERL_LIBRARY_INCLUDE}")
|
||||
ADD_DEFINITIONS(-DEMBPERL)
|
||||
ADD_DEFINITIONS(-DEMBPERL_PLUGIN)
|
||||
ADD_DEFINITIONS(-DPERLBIND_NO_STRICT_SCALAR_TYPES)
|
||||
IF (UNIX AND EQEMU_BUILD_STATIC)
|
||||
SET(SERVER_LIBS ${SERVER_LIBS} libcrypt.a)
|
||||
ENDIF ()
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
IF(WIN32)
|
||||
SET(SERVER_LIBS ${SERVER_LIBS} "ws2_32" "psapi" "iphlpapi" "userenv")
|
||||
ENDIF()
|
||||
|
||||
IF(UNIX)
|
||||
SET(SERVER_LIBS ${SERVER_LIBS} ${CMAKE_DL_LIBS} "z" "m" "pthread")
|
||||
IF(NOT DARWIN)
|
||||
SET(SERVER_LIBS ${SERVER_LIBS} "rt")
|
||||
ENDIF()
|
||||
# Freebsd provides uuids in the C library
|
||||
IF(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
|
||||
SET(SERVER_LIBS ${SERVER_LIBS} "uuid")
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
SET(ZONE_LIBS ${ZONE_LIBS} ${SERVER_LIBS})
|
||||
|
||||
IF(EQEMU_BUILD_LOGIN AND NOT TLS_LIBRARY_ENABLED)
|
||||
MESSAGE(FATAL_ERROR "Login server requires a TLS Library to build.")
|
||||
ENDIF()
|
||||
|
||||
IF(EQEMU_BUILD_HC AND NOT TLS_LIBRARY_ENABLED)
|
||||
MESSAGE(FATAL_ERROR "Headless client requires a TLS Library to build.")
|
||||
ENDIF()
|
||||
|
||||
IF(EQEMU_BUILD_SERVER OR EQEMU_BUILD_LOGIN OR EQEMU_BUILD_TESTS OR EQEMU_BUILD_HC)
|
||||
ADD_SUBDIRECTORY(common)
|
||||
ADD_SUBDIRECTORY(libs)
|
||||
ADD_SUBDIRECTORY(submodules/fmt)
|
||||
ADD_SUBDIRECTORY(submodules/libuv)
|
||||
|
||||
IF(EQEMU_BUILD_ZLIB)
|
||||
SET(ZLIB_COMPAT ON CACHE BOOL "Compile with zlib compatible API")
|
||||
SET(ZLIB_ENABLE_TESTS OFF CACHE BOOL "Build test binaries")
|
||||
ADD_SUBDIRECTORY(libs/zlibng)
|
||||
ENDIF()
|
||||
|
||||
SET(RECASTNAVIGATION_DEMO OFF CACHE BOOL "Build demo")
|
||||
SET(RECASTNAVIGATION_TESTS OFF CACHE BOOL "Build tests")
|
||||
SET(RECASTNAVIGATION_EXAMPLES OFF CACHE BOOL "Build examples")
|
||||
ADD_SUBDIRECTORY(submodules/recastnavigation)
|
||||
ENDIF(EQEMU_BUILD_SERVER OR EQEMU_BUILD_LOGIN OR EQEMU_BUILD_TESTS OR EQEMU_BUILD_HC)
|
||||
|
||||
IF(EQEMU_BUILD_SERVER)
|
||||
ADD_SUBDIRECTORY(shared_memory)
|
||||
ADD_SUBDIRECTORY(world)
|
||||
ADD_SUBDIRECTORY(zone)
|
||||
ADD_SUBDIRECTORY(ucs)
|
||||
ADD_SUBDIRECTORY(queryserv)
|
||||
ADD_SUBDIRECTORY(eqlaunch)
|
||||
ENDIF(EQEMU_BUILD_SERVER)
|
||||
|
||||
IF(EQEMU_BUILD_LOGIN)
|
||||
ADD_SUBDIRECTORY(loginserver)
|
||||
ENDIF(EQEMU_BUILD_LOGIN)
|
||||
|
||||
IF(EQEMU_BUILD_HC)
|
||||
ADD_SUBDIRECTORY(hc)
|
||||
ENDIF(EQEMU_BUILD_HC)
|
||||
|
||||
IF(EQEMU_BUILD_TESTS)
|
||||
ADD_SUBDIRECTORY(tests)
|
||||
ENDIF(EQEMU_BUILD_TESTS)
|
||||
|
||||
IF(EQEMU_BUILD_CLIENT_FILES)
|
||||
ADD_SUBDIRECTORY(client_files)
|
||||
ENDIF(EQEMU_BUILD_CLIENT_FILES)
|
||||
if(EQEMU_BUILD_CLIENT_FILES)
|
||||
add_subdirectory(client_files)
|
||||
endif()
|
||||
|
||||
49
CMakePresets.json
Normal file
49
CMakePresets.json
Normal file
@ -0,0 +1,49 @@
|
||||
{
|
||||
"version": 3,
|
||||
"cmakeMinimumRequired": {
|
||||
"major": 3,
|
||||
"minor": 19,
|
||||
"patch": 0
|
||||
},
|
||||
"configurePresets": [
|
||||
{
|
||||
"name": "linux-debug",
|
||||
"displayName": "Linux Debug",
|
||||
"generator": "Ninja",
|
||||
"binaryDir": "${sourceDir}/build",
|
||||
"cacheVariables": {
|
||||
"CMAKE_BUILD_TYPE": "Debug",
|
||||
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
|
||||
"CMAKE_C_COMPILER_LAUNCHER": "ccache",
|
||||
"CMAKE_CXX_COMPILER_LAUNCHER": "ccache",
|
||||
"EQEMU_BUILD_LOGIN": "ON",
|
||||
"EQEMU_BUILD_TESTS": "ON",
|
||||
"EQEMU_ADD_PROFILER": "ON"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "linux-release",
|
||||
"displayName": "Linux Release",
|
||||
"generator": "Ninja",
|
||||
"binaryDir": "${sourceDir}/build/release",
|
||||
"cacheVariables": {
|
||||
"CMAKE_BUILD_TYPE": "Release",
|
||||
"CMAKE_C_COMPILER_LAUNCHER": "ccache",
|
||||
"CMAKE_CXX_COMPILER_LAUNCHER": "ccache",
|
||||
"EQEMU_BUILD_LOGIN": "ON"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "win-msvc",
|
||||
"displayName": "Windows MSVC (VS 2022)",
|
||||
"generator": "Visual Studio 17 2022",
|
||||
"binaryDir": "${sourceDir}/build/{presetName}",
|
||||
"architecture": { "value": "x64" },
|
||||
"cacheVariables": {
|
||||
"CMAKE_CONFIGURATION_TYPES": "Debug;Release",
|
||||
"EQEMU_BUILD_LOGIN": "ON",
|
||||
"EQEMU_BUILD_TESTS": "ON"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 3.5)
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
add_subdirectory(import)
|
||||
add_subdirectory(export)
|
||||
|
||||
@ -1,16 +1,16 @@
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 3.12)
|
||||
cmake_minimum_required(VERSION 3.20.0)
|
||||
|
||||
SET(export_sources
|
||||
set(export_sources
|
||||
main.cpp
|
||||
)
|
||||
|
||||
SET(export_headers
|
||||
set(export_headers
|
||||
)
|
||||
|
||||
ADD_EXECUTABLE(export_client_files ${export_sources} ${export_headers})
|
||||
add_executable(export_client_files ${export_sources} ${export_headers})
|
||||
|
||||
INSTALL(TARGETS export_client_files RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
|
||||
install(TARGETS export_client_files RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
|
||||
|
||||
TARGET_LINK_LIBRARIES(export_client_files ${SERVER_LIBS})
|
||||
target_link_libraries(export_client_files common)
|
||||
|
||||
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
|
||||
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
|
||||
|
||||
@ -1,16 +1,16 @@
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 3.12)
|
||||
cmake_minimum_required(VERSION 3.20.0)
|
||||
|
||||
SET(import_sources
|
||||
set(import_sources
|
||||
main.cpp
|
||||
)
|
||||
|
||||
SET(import_headers
|
||||
set(import_headers
|
||||
)
|
||||
|
||||
ADD_EXECUTABLE(import_client_files ${import_sources} ${import_headers})
|
||||
add_executable(import_client_files ${import_sources} ${import_headers})
|
||||
|
||||
INSTALL(TARGETS import_client_files RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
|
||||
install(TARGETS import_client_files RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
|
||||
|
||||
TARGET_LINK_LIBRARIES(import_client_files ${SERVER_LIBS})
|
||||
target_link_libraries(import_client_files common)
|
||||
|
||||
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
|
||||
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
|
||||
|
||||
@ -1,94 +0,0 @@
|
||||
OPTION(EQEMU_FETCH_MSVC_DEPENDENCIES_VCPKG "Automatically fetch vcpkg dependencies for MSCV" ON)
|
||||
OPTION(EQEMU_FETCH_MSVC_DEPENDENCIES_PERL "Automatically fetch perl dependencies for MSCV" ON)
|
||||
|
||||
MARK_AS_ADVANCED(EQEMU_FETCH_MSVC_DEPENDENCIES_VCPKG)
|
||||
MARK_AS_ADVANCED(EQEMU_FETCH_MSVC_DEPENDENCIES_PERL)
|
||||
|
||||
SET(EQEMU_MSVC_DEPENDENCIES_VCPKG_X86 "https://github.com/EQEmu/Server/releases/download/v1.2/vcpkg-export-x86.zip")
|
||||
SET(EQEMU_MSVC_DEPENDENCIES_VCPKG_X64 "https://github.com/EQEmu/Server/releases/download/v1.2/vcpkg-export-x64.zip")
|
||||
SET(EQEMU_MSVC_DEPENDENCIES_PERL_X86 "http://strawberryperl.com/download/5.24.4.1/strawberry-perl-5.24.4.1-32bit-portable.zip")
|
||||
SET(EQEMU_MSVC_DEPENDENCIES_PERL_X64 "http://strawberryperl.com/download/5.24.4.1/strawberry-perl-5.24.4.1-64bit-portable.zip")
|
||||
SET(EQEMU_MSVC_DEPENDENCIES_VCPKG_X86_ZIP "vcpkg-export-x86.zip")
|
||||
SET(EQEMU_MSVC_DEPENDENCIES_VCPKG_X64_ZIP "vcpkg-export-x64.zip")
|
||||
SET(EQEMU_MSVC_DEPENDENCIES_VCPKG_X86_DIR "vcpkg-export-x86")
|
||||
SET(EQEMU_MSVC_DEPENDENCIES_VCPKG_X64_DIR "vcpkg-export-x64")
|
||||
SET(EQEMU_MSVC_DEPENDENCIES_PERL_X86_ZIP "strawberry-perl-5.24.4.1-32bit-portable.zip")
|
||||
SET(EQEMU_MSVC_DEPENDENCIES_PERL_X64_ZIP "strawberry-perl-5.24.4.1-64bit-portable.zip")
|
||||
SET(EQEMU_MSVC_DEPENDENCIES_PERL_X86_DIR "x86")
|
||||
SET(EQEMU_MSVC_DEPENDENCIES_PERL_X64_DIR "x64")
|
||||
|
||||
IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
SET(EQEMU_VCPKG_URL ${EQEMU_MSVC_DEPENDENCIES_VCPKG_X64})
|
||||
SET(EQEMU_PERL_URL ${EQEMU_MSVC_DEPENDENCIES_PERL_X64})
|
||||
SET(EQEMU_VCPKG_ZIP ${EQEMU_MSVC_DEPENDENCIES_VCPKG_X64_ZIP})
|
||||
SET(EQEMU_VCPKG_DIR ${EQEMU_MSVC_DEPENDENCIES_VCPKG_X64_DIR})
|
||||
SET(EQEMU_PERL_ZIP ${EQEMU_MSVC_DEPENDENCIES_PERL_X64_ZIP})
|
||||
SET(EQEMU_PERL_DIR ${EQEMU_MSVC_DEPENDENCIES_PERL_X64_DIR})
|
||||
ELSE()
|
||||
SET(EQEMU_VCPKG_URL ${EQEMU_MSVC_DEPENDENCIES_VCPKG_X86})
|
||||
SET(EQEMU_PERL_URL ${EQEMU_MSVC_DEPENDENCIES_PERL_X86})
|
||||
SET(EQEMU_VCPKG_ZIP ${EQEMU_MSVC_DEPENDENCIES_VCPKG_X86_ZIP})
|
||||
SET(EQEMU_VCPKG_DIR ${EQEMU_MSVC_DEPENDENCIES_VCPKG_X86_DIR})
|
||||
SET(EQEMU_PERL_ZIP ${EQEMU_MSVC_DEPENDENCIES_PERL_X86_ZIP})
|
||||
SET(EQEMU_PERL_DIR ${EQEMU_MSVC_DEPENDENCIES_PERL_X86_DIR})
|
||||
ENDIF()
|
||||
|
||||
IF(EQEMU_FETCH_MSVC_DEPENDENCIES_VCPKG)
|
||||
MESSAGE(STATUS "Resolving vcpkg dependencies...")
|
||||
|
||||
IF(NOT EXISTS ${PROJECT_SOURCE_DIR}/vcpkg/${EQEMU_VCPKG_ZIP})
|
||||
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_SOURCE_DIR}/vcpkg)
|
||||
|
||||
MESSAGE(STATUS "Downloading existing vcpkg dependencies from releases...")
|
||||
FILE(DOWNLOAD ${EQEMU_VCPKG_URL} ${PROJECT_SOURCE_DIR}/vcpkg/${EQEMU_VCPKG_ZIP}
|
||||
SHOW_PROGRESS
|
||||
STATUS DOWNLOAD_STATUS)
|
||||
|
||||
LIST(GET DOWNLOAD_STATUS 0 STATUS_CODE)
|
||||
IF(NOT STATUS_CODE EQUAL 0)
|
||||
MESSAGE(FATAL_ERROR "Was unable to download dependencies from ${EQEMU_VCPKG_URL}")
|
||||
ENDIF()
|
||||
|
||||
MESSAGE(STATUS "Extracting files...")
|
||||
EXECUTE_PROCESS(
|
||||
COMMAND ${CMAKE_COMMAND} -E tar xzf ${PROJECT_SOURCE_DIR}/vcpkg/${EQEMU_VCPKG_ZIP}
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/vcpkg
|
||||
)
|
||||
ENDIF()
|
||||
|
||||
INCLUDE(${PROJECT_SOURCE_DIR}/vcpkg/${EQEMU_VCPKG_DIR}/scripts/buildsystems/vcpkg.cmake)
|
||||
ENDIF()
|
||||
|
||||
IF(EQEMU_FETCH_MSVC_DEPENDENCIES_PERL)
|
||||
#Try to find perl first, (so you can use your active install first)
|
||||
FIND_PACKAGE(PerlLibs)
|
||||
|
||||
IF(NOT PerlLibs_FOUND)
|
||||
MESSAGE(STATUS "Resolving perl dependencies...")
|
||||
|
||||
IF(NOT EXISTS ${PROJECT_SOURCE_DIR}/perl/${EQEMU_PERL_ZIP})
|
||||
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_SOURCE_DIR}/perl)
|
||||
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_SOURCE_DIR}/perl/${EQEMU_PERL_DIR})
|
||||
|
||||
MESSAGE(STATUS "Downloading portable perl...")
|
||||
FILE(DOWNLOAD ${EQEMU_PERL_URL} ${PROJECT_SOURCE_DIR}/perl/${EQEMU_PERL_ZIP}
|
||||
SHOW_PROGRESS
|
||||
STATUS DOWNLOAD_STATUS)
|
||||
|
||||
LIST(GET DOWNLOAD_STATUS 0 STATUS_CODE)
|
||||
IF(NOT STATUS_CODE EQUAL 0)
|
||||
MESSAGE(FATAL_ERROR "Was unable to download dependencies from ${EQEMU_PERL_URL}")
|
||||
ENDIF()
|
||||
|
||||
MESSAGE(STATUS "Extracting files...")
|
||||
EXECUTE_PROCESS(
|
||||
COMMAND ${CMAKE_COMMAND} -E tar xzf ${PROJECT_SOURCE_DIR}/perl/${EQEMU_PERL_ZIP}
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/perl/${EQEMU_PERL_DIR}
|
||||
)
|
||||
ENDIF()
|
||||
|
||||
SET(PERL_EXECUTABLE ${PROJECT_SOURCE_DIR}/perl/${EQEMU_PERL_DIR}/perl/bin/perl.exe CACHE FILEPATH "Path to perl program" FORCE)
|
||||
SET(PERL_INCLUDE_PATH ${PROJECT_SOURCE_DIR}/perl/${EQEMU_PERL_DIR}/perl/lib/CORE CACHE PATH "Path to perl include files" FORCE)
|
||||
SET(PERL_LIBRARY ${PROJECT_SOURCE_DIR}/perl/${EQEMU_PERL_DIR}/perl/lib/CORE/libperl524.a CACHE FILEPATH "Path to perl library" FORCE)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
@ -1,91 +0,0 @@
|
||||
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
# file Copyright.txt or https://cmake.org/licensing for details.
|
||||
# Modified from the FindLua51 that comes with CMake
|
||||
|
||||
#[=======================================================================[.rst:
|
||||
FindLua51
|
||||
---------
|
||||
|
||||
|
||||
|
||||
Locate Lua51 library This module defines
|
||||
|
||||
::
|
||||
|
||||
LUA51_FOUND, if false, do not try to link to Lua
|
||||
LUA_LIBRARIES
|
||||
LUA_INCLUDE_DIR, where to find lua.h
|
||||
LUA_VERSION_STRING, the version of Lua found (since CMake 2.8.8)
|
||||
|
||||
|
||||
|
||||
Note that the expected include convention is
|
||||
|
||||
::
|
||||
|
||||
#include "lua.h"
|
||||
|
||||
and not
|
||||
|
||||
::
|
||||
|
||||
#include <lua/lua.h>
|
||||
|
||||
This is because, the lua location is not standardized and may exist in
|
||||
locations other than lua/
|
||||
#]=======================================================================]
|
||||
|
||||
find_path(LUA_INCLUDE_DIR lua.h
|
||||
HINTS
|
||||
ENV LUA_DIR
|
||||
PATH_SUFFIXES include/lua51 include/lua5.1 include/lua-5.1 include/lua include
|
||||
PATHS
|
||||
~/Library/Frameworks
|
||||
/Library/Frameworks
|
||||
/sw # Fink
|
||||
/opt/local # DarwinPorts
|
||||
/opt/csw # Blastwave
|
||||
/opt
|
||||
)
|
||||
|
||||
find_library(LUA_LIBRARY
|
||||
NAMES lua51 lua5.1 lua-5.1 lua
|
||||
HINTS
|
||||
ENV LUA_DIR
|
||||
PATH_SUFFIXES lib
|
||||
PATHS
|
||||
~/Library/Frameworks
|
||||
/Library/Frameworks
|
||||
/sw
|
||||
/opt/local
|
||||
/opt/csw
|
||||
/opt
|
||||
)
|
||||
|
||||
if(LUA_LIBRARY)
|
||||
# include the math library for Unix
|
||||
if(UNIX AND NOT APPLE AND NOT BEOS AND NOT HAIKU)
|
||||
find_library(LUA_MATH_LIBRARY m)
|
||||
set( LUA_LIBRARIES "${LUA_LIBRARY};${LUA_MATH_LIBRARY}" CACHE STRING "Lua Libraries")
|
||||
# For Windows and Mac, don't need to explicitly include the math library
|
||||
else()
|
||||
set( LUA_LIBRARIES "${LUA_LIBRARY}" CACHE STRING "Lua Libraries")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(LUA_INCLUDE_DIR AND EXISTS "${LUA_INCLUDE_DIR}/lua.h")
|
||||
file(STRINGS "${LUA_INCLUDE_DIR}/lua.h" lua_version_str REGEX "^#define[ \t]+LUA_RELEASE[ \t]+\"Lua .+\"")
|
||||
|
||||
string(REGEX REPLACE "^#define[ \t]+LUA_RELEASE[ \t]+\"Lua ([^\"]+)\".*" "\\1" LUA_VERSION_STRING "${lua_version_str}")
|
||||
unset(lua_version_str)
|
||||
endif()
|
||||
|
||||
include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake)
|
||||
# handle the QUIETLY and REQUIRED arguments and set LUA51_FOUND to TRUE if
|
||||
# all listed variables are TRUE
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lua51
|
||||
REQUIRED_VARS LUA_LIBRARIES LUA_INCLUDE_DIR
|
||||
VERSION_VAR LUA_VERSION_STRING)
|
||||
|
||||
mark_as_advanced(LUA_INCLUDE_DIR LUA_LIBRARIES LUA_LIBRARY LUA_MATH_LIBRARY)
|
||||
|
||||
@ -88,4 +88,3 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(LuaJit
|
||||
VERSION_VAR LUAJIT_VERSION_STRING)
|
||||
|
||||
mark_as_advanced(LUAJIT_INCLUDE_DIR LUAJIT_LIBRARIES LUAJIT_LIBRARY LUAJIT_MATH_LIBRARY)
|
||||
|
||||
|
||||
@ -1,87 +0,0 @@
|
||||
# - Find mariadbclient
|
||||
#
|
||||
# -*- cmake -*-
|
||||
#
|
||||
# Find the native MariaDB includes and library
|
||||
#
|
||||
# MariaDB_INCLUDE_DIR - where to find mysql.h, etc.
|
||||
# MariaDB_LIBRARIES - List of libraries when using MariaDB.
|
||||
# MariaDB_FOUND - True if MariaDB found.
|
||||
# The following can be used as a hint as to where to search:
|
||||
# MARIADB_ROOT
|
||||
|
||||
IF (MariaDB_INCLUDE_DIR AND MariaDB_LIBRARIES)
|
||||
# Already in cache, be silent
|
||||
SET(MariaDB_FIND_QUIETLY TRUE)
|
||||
ENDIF (MariaDB_INCLUDE_DIR AND MariaDB_LIBRARIES)
|
||||
|
||||
# Include dir
|
||||
IF(MARIADB_ROOT)
|
||||
FIND_PATH(MariaDB_INCLUDE_DIR
|
||||
NAMES mariadb_version.h
|
||||
PATHS ${MARIADB_ROOT}/include
|
||||
PATH_SUFFIXES mysql mariadb
|
||||
NO_DEFAULT_PATH
|
||||
NO_SYSTEM_ENVIRONMENT_PATH
|
||||
)
|
||||
FIND_PATH(MariaDB_INCLUDE_DIR
|
||||
NAMES mariadb_version.h
|
||||
PATH_SUFFIXES mysql mariadb
|
||||
)
|
||||
ELSE(MARIADB_ROOT)
|
||||
FIND_PATH(MariaDB_INCLUDE_DIR
|
||||
NAMES mariadb_version.h
|
||||
PATH_SUFFIXES mysql mariadb
|
||||
)
|
||||
ENDIF(MARIADB_ROOT)
|
||||
|
||||
# Library
|
||||
SET(MariaDB_NAMES libmariadb)
|
||||
IF(MARIADB_ROOT)
|
||||
FIND_LIBRARY(MariaDB_LIBRARY
|
||||
NAMES ${MariaDB_NAMES}
|
||||
PATHS ${MARIADB_ROOT}/lib
|
||||
PATH_SUFFIXES mysql mariadb
|
||||
NO_DEFAULT_PATH
|
||||
NO_SYSTEM_ENVIRONMENT_PATH
|
||||
)
|
||||
|
||||
FIND_LIBRARY(MariaDB_LIBRARY
|
||||
NAMES ${MariaDB_NAMES}
|
||||
PATH_SUFFIXES mysql mariadb
|
||||
)
|
||||
ELSE(MARIADB_ROOT)
|
||||
FIND_LIBRARY(MariaDB_LIBRARY
|
||||
NAMES ${MariaDB_NAMES} mariadbclient_r mariadbclient
|
||||
PATHS /usr/lib /usr/local/lib /usr/lib64 /usr/local/lib64
|
||||
PATH_SUFFIXES mysql mariadb
|
||||
)
|
||||
ENDIF(MARIADB_ROOT)
|
||||
|
||||
IF (MariaDB_INCLUDE_DIR AND MariaDB_LIBRARY)
|
||||
SET(MariaDB_FOUND TRUE)
|
||||
SET(MariaDB_LIBRARIES ${MariaDB_LIBRARY})
|
||||
ELSE (MariaDB_INCLUDE_DIR AND MariaDB_LIBRARY)
|
||||
SET(MariaDB_FOUND FALSE)
|
||||
SET(MariaDB_LIBRARIES)
|
||||
ENDIF (MariaDB_INCLUDE_DIR AND MariaDB_LIBRARY)
|
||||
|
||||
|
||||
# handle the QUIETLY and REQUIRED arguments and set MariaDB_FOUND to TRUE if
|
||||
# all listed variables are TRUE
|
||||
INCLUDE(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(MariaDB DEFAULT_MSG MariaDB_LIBRARY MariaDB_INCLUDE_DIR)
|
||||
|
||||
IF(MariaDB_FOUND)
|
||||
SET( MariaDB_LIBRARY_RELEASE ${MariaDB_LIBRARY} )
|
||||
SET( MariaDB_LIBRARY_DEBUG ${MariaDB_LIBRARY} )
|
||||
SET( MariaDB_LIBRARIES ${MariaDB_LIBRARY_RELEASE} ${MariaDB_LIBRARY_DEBUG} )
|
||||
ELSE(MariaDB_FOUND)
|
||||
SET( MariaDB_LIBRARIES )
|
||||
ENDIF(MariaDB_FOUND)
|
||||
|
||||
MARK_AS_ADVANCED(
|
||||
MariaDB_LIBRARY_DEBUG
|
||||
MariaDB_LIBRARY_RELEASE
|
||||
MariaDB_INCLUDE_DIR
|
||||
)
|
||||
@ -1,87 +0,0 @@
|
||||
# - Find mysqlclient
|
||||
#
|
||||
# -*- cmake -*-
|
||||
#
|
||||
# Find the native MySQL includes and library
|
||||
#
|
||||
# MySQL_INCLUDE_DIR - where to find mysql.h, etc.
|
||||
# MySQL_LIBRARIES - List of libraries when using MySQL.
|
||||
# MySQL_FOUND - True if MySQL found.
|
||||
# The following can be used as a hint as to where to search:
|
||||
# MYSQL_ROOT
|
||||
|
||||
IF (MySQL_INCLUDE_DIR AND MySQL_LIBRARIES)
|
||||
# Already in cache, be silent
|
||||
SET(MySQL_FIND_QUIETLY TRUE)
|
||||
ENDIF (MySQL_INCLUDE_DIR AND MySQL_LIBRARIES)
|
||||
|
||||
# Include dir
|
||||
IF(MYSQL_ROOT)
|
||||
FIND_PATH(MySQL_INCLUDE_DIR
|
||||
NAMES mysql.h
|
||||
PATHS ${MYSQL_ROOT}/include
|
||||
PATH_SUFFIXES mysql
|
||||
NO_DEFAULT_PATH
|
||||
NO_SYSTEM_ENVIRONMENT_PATH
|
||||
)
|
||||
FIND_PATH(MySQL_INCLUDE_DIR
|
||||
NAMES mysql.h
|
||||
PATH_SUFFIXES mysql
|
||||
)
|
||||
ELSE(MYSQL_ROOT)
|
||||
FIND_PATH(MySQL_INCLUDE_DIR
|
||||
NAMES mysql.h
|
||||
PATH_SUFFIXES mysql
|
||||
)
|
||||
ENDIF(MYSQL_ROOT)
|
||||
|
||||
# Library
|
||||
SET(MySQL_NAMES libmysql)
|
||||
IF(MYSQL_ROOT)
|
||||
FIND_LIBRARY(MySQL_LIBRARY
|
||||
NAMES ${MySQL_NAMES}
|
||||
PATHS ${MYSQL_ROOT}/lib
|
||||
PATH_SUFFIXES mysql
|
||||
NO_DEFAULT_PATH
|
||||
NO_SYSTEM_ENVIRONMENT_PATH
|
||||
)
|
||||
|
||||
FIND_LIBRARY(MySQL_LIBRARY
|
||||
NAMES ${MySQL_NAMES}
|
||||
PATH_SUFFIXES mysql
|
||||
)
|
||||
ELSE(MYSQL_ROOT)
|
||||
FIND_LIBRARY(MySQL_LIBRARY
|
||||
NAMES ${MySQL_NAMES} mysqlclient_r mysqlclient
|
||||
PATHS /usr/lib /usr/local/lib /usr/lib64 /usr/local/lib64
|
||||
PATH_SUFFIXES mysql
|
||||
)
|
||||
ENDIF(MYSQL_ROOT)
|
||||
|
||||
IF (MySQL_INCLUDE_DIR AND MySQL_LIBRARY)
|
||||
SET(MySQL_FOUND TRUE)
|
||||
SET( MySQL_LIBRARIES ${MySQL_LIBRARY} )
|
||||
ELSE (MySQL_INCLUDE_DIR AND MySQL_LIBRARY)
|
||||
SET(MySQL_FOUND FALSE)
|
||||
SET( MySQL_LIBRARIES )
|
||||
ENDIF (MySQL_INCLUDE_DIR AND MySQL_LIBRARY)
|
||||
|
||||
|
||||
# handle the QUIETLY and REQUIRED arguments and set MySQL_FOUND to TRUE if
|
||||
# all listed variables are TRUE
|
||||
INCLUDE(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(MySQL DEFAULT_MSG MySQL_LIBRARY MySQL_INCLUDE_DIR)
|
||||
|
||||
IF(MySQL_FOUND)
|
||||
SET( MySQL_LIBRARY_RELEASE ${MySQL_LIBRARY} )
|
||||
SET( MySQL_LIBRARY_DEBUG ${MySQL_LIBRARY} )
|
||||
SET( MySQL_LIBRARIES ${MySQL_LIBRARY_RELEASE} ${MySQL_LIBRARY_DEBUG} )
|
||||
ELSE(MySQL_FOUND)
|
||||
SET( MySQL_LIBRARIES )
|
||||
ENDIF(MySQL_FOUND)
|
||||
|
||||
MARK_AS_ADVANCED(
|
||||
MySQL_LIBRARY_DEBUG
|
||||
MySQL_LIBRARY_RELEASE
|
||||
MySQL_INCLUDE_DIR
|
||||
)
|
||||
@ -1,30 +0,0 @@
|
||||
if (NOT MSVC)
|
||||
include(FindPkgConfig)
|
||||
pkg_check_modules(PC_SODIUM "libsodium")
|
||||
if (NOT PC_SODIUM_FOUND)
|
||||
pkg_check_modules(PC_SODIUM "sodium")
|
||||
endif (NOT PC_SODIUM_FOUND)
|
||||
if (PC_SODIUM_FOUND)
|
||||
set(SODIUM_INCLUDE_HINTS ${PC_SODIUM_INCLUDE_DIRS} ${PC_SODIUM_INCLUDE_DIRS}/*)
|
||||
set(SODIUM_LIBRARY_HINTS ${PC_SODIUM_LIBRARY_DIRS} ${PC_SODIUM_LIBRARY_DIRS}/*)
|
||||
endif()
|
||||
endif (NOT MSVC)
|
||||
|
||||
# some libraries install the headers is a subdirectory of the include dir
|
||||
# returned by pkg-config, so use a wildcard match to improve chances of finding
|
||||
# headers and libraries.
|
||||
find_path(
|
||||
SODIUM_INCLUDE_DIRS
|
||||
NAMES sodium.h
|
||||
HINTS ${SODIUM_INCLUDE_HINTS}
|
||||
)
|
||||
|
||||
find_library(
|
||||
SODIUM_LIBRARIES
|
||||
NAMES libsodium sodium
|
||||
HINTS ${SODIUM_LIBRARY_HINTS}
|
||||
)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(SODIUM DEFAULT_MSG SODIUM_LIBRARIES SODIUM_INCLUDE_DIRS)
|
||||
mark_as_advanced(SODIUM_FOUND SODIUM_LIBRARIES SODIUM_INCLUDE_DIRS)
|
||||
@ -1,93 +0,0 @@
|
||||
# - Try to find mbedTLS
|
||||
# Once done this will define
|
||||
#
|
||||
# Read-Only variables
|
||||
# MBEDTLS_FOUND - system has mbedTLS
|
||||
# MBEDTLS_INCLUDE_DIR - the mbedTLS include directory
|
||||
# MBEDTLS_LIBRARY_DIR - the mbedTLS library directory
|
||||
# MBEDTLS_LIBRARIES - Link these to use mbedTLS
|
||||
# MBEDTLS_LIBRARY - path to mbedTLS library
|
||||
# MBEDX509_LIBRARY - path to mbedTLS X.509 library
|
||||
# MBEDCRYPTO_LIBRARY - path to mbedTLS Crypto library
|
||||
#
|
||||
# Hint
|
||||
# MBEDTLS_ROOT_DIR can be pointed to a local mbedTLS installation.
|
||||
|
||||
SET(_MBEDTLS_ROOT_HINTS
|
||||
${MBEDTLS_ROOT_DIR}
|
||||
ENV MBEDTLS_ROOT_DIR
|
||||
)
|
||||
|
||||
SET(_MBEDTLS_ROOT_HINTS_AND_PATHS
|
||||
HINTS ${_MBEDTLS_ROOT_HINTS}
|
||||
PATHS ${_MBEDTLS_ROOT_PATHS}
|
||||
)
|
||||
|
||||
FIND_PATH(MBEDTLS_INCLUDE_DIR
|
||||
NAMES mbedtls/version.h
|
||||
${_MBEDTLS_ROOT_HINTS_AND_PATHS}
|
||||
PATH_SUFFIXES include
|
||||
)
|
||||
|
||||
IF(MBEDTLS_INCLUDE_DIR AND MBEDTLS_LIBRARIES)
|
||||
# Already in cache, be silent
|
||||
SET(MBEDTLS_FIND_QUIETLY TRUE)
|
||||
ENDIF()
|
||||
|
||||
FIND_LIBRARY(MBEDTLS_LIBRARY
|
||||
NAMES mbedtls libmbedtls
|
||||
${_MBEDTLS_ROOT_HINTS_AND_PATHS}
|
||||
PATH_SUFFIXES library
|
||||
)
|
||||
FIND_LIBRARY(MBEDX509_LIBRARY
|
||||
NAMES mbedx509 libmbedx509
|
||||
${_MBEDTLS_ROOT_HINTS_AND_PATHS}
|
||||
PATH_SUFFIXES library
|
||||
)
|
||||
FIND_LIBRARY(MBEDCRYPTO_LIBRARY
|
||||
NAMES mbedcrypto libmbedcrypto
|
||||
${_MBEDTLS_ROOT_HINTS_AND_PATHS}
|
||||
PATH_SUFFIXES library
|
||||
)
|
||||
|
||||
IF(MBEDTLS_INCLUDE_DIR AND MBEDTLS_LIBRARY AND MBEDX509_LIBRARY AND MBEDCRYPTO_LIBRARY)
|
||||
SET(MBEDTLS_FOUND TRUE)
|
||||
ENDIF()
|
||||
|
||||
IF(MBEDTLS_FOUND)
|
||||
# split mbedTLS into -L and -l linker options, so we can set them for pkg-config
|
||||
GET_FILENAME_COMPONENT(MBEDTLS_LIBRARY_DIR ${MBEDTLS_LIBRARY} PATH)
|
||||
GET_FILENAME_COMPONENT(MBEDTLS_LIBRARY_FILE ${MBEDTLS_LIBRARY} NAME_WE)
|
||||
GET_FILENAME_COMPONENT(MBEDX509_LIBRARY_FILE ${MBEDX509_LIBRARY} NAME_WE)
|
||||
GET_FILENAME_COMPONENT(MBEDCRYPTO_LIBRARY_FILE ${MBEDCRYPTO_LIBRARY} NAME_WE)
|
||||
STRING(REGEX REPLACE "^lib" "" MBEDTLS_LIBRARY_FILE ${MBEDTLS_LIBRARY_FILE})
|
||||
STRING(REGEX REPLACE "^lib" "" MBEDX509_LIBRARY_FILE ${MBEDX509_LIBRARY_FILE})
|
||||
STRING(REGEX REPLACE "^lib" "" MBEDCRYPTO_LIBRARY_FILE ${MBEDCRYPTO_LIBRARY_FILE})
|
||||
SET(MBEDTLS_LIBRARIES "-L${MBEDTLS_LIBRARY_DIR} -l${MBEDTLS_LIBRARY_FILE} -l${MBEDX509_LIBRARY_FILE} -l${MBEDCRYPTO_LIBRARY_FILE}")
|
||||
|
||||
IF(NOT MBEDTLS_FIND_QUIETLY)
|
||||
MESSAGE(STATUS "Found mbedTLS:")
|
||||
FILE(READ ${MBEDTLS_INCLUDE_DIR}/mbedtls/version.h MBEDTLSCONTENT)
|
||||
STRING(REGEX MATCH "MBEDTLS_VERSION_STRING +\"[0-9|.]+\"" MBEDTLSMATCH ${MBEDTLSCONTENT})
|
||||
IF (MBEDTLSMATCH)
|
||||
STRING(REGEX REPLACE "MBEDTLS_VERSION_STRING +\"([0-9|.]+)\"" "\\1" MBEDTLS_VERSION ${MBEDTLSMATCH})
|
||||
MESSAGE(STATUS " version ${MBEDTLS_VERSION}")
|
||||
ENDIF(MBEDTLSMATCH)
|
||||
MESSAGE(STATUS " TLS: ${MBEDTLS_LIBRARY}")
|
||||
MESSAGE(STATUS " X509: ${MBEDX509_LIBRARY}")
|
||||
MESSAGE(STATUS " Crypto: ${MBEDCRYPTO_LIBRARY}")
|
||||
ENDIF(NOT MBEDTLS_FIND_QUIETLY)
|
||||
ELSE(MBEDTLS_FOUND)
|
||||
IF(MBEDTLS_FIND_REQUIRED)
|
||||
MESSAGE(FATAL_ERROR "Could not find mbedTLS")
|
||||
ENDIF(MBEDTLS_FIND_REQUIRED)
|
||||
ENDIF(MBEDTLS_FOUND)
|
||||
|
||||
MARK_AS_ADVANCED(
|
||||
MBEDTLS_INCLUDE_DIR
|
||||
MBEDTLS_LIBRARY_DIR
|
||||
MBEDTLS_LIBRARIES
|
||||
MBEDTLS_LIBRARY
|
||||
MBEDX509_LIBRARY
|
||||
MBEDCRYPTO_LIBRARY
|
||||
)
|
||||
File diff suppressed because it is too large
Load Diff
@ -16,6 +16,7 @@
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include <fmt/format.h>
|
||||
#include <fmt/ranges.h>
|
||||
#include "../common/global_define.h"
|
||||
#include "../common/classes.h"
|
||||
#include "data_verification.h"
|
||||
|
||||
@ -19,6 +19,7 @@
|
||||
*/
|
||||
|
||||
#include <fmt/format.h>
|
||||
#include <fmt/ranges.h>
|
||||
#include "eqemu_command_handler.h"
|
||||
#include "terminal_color.hpp"
|
||||
#include "../platform.h"
|
||||
|
||||
@ -23,7 +23,7 @@ void SendCrashReport(const std::string &crash_report)
|
||||
{
|
||||
// can configure multiple endpoints if need be
|
||||
std::vector<std::string> endpoints = {
|
||||
"https://spire.akkadius.com/api/v1/analytics/server-crash-report",
|
||||
"https://spire.eqemu.dev/api/v1/analytics/server-crash-report",
|
||||
// "http://localhost:3010/api/v1/analytics/server-crash-report", // development
|
||||
};
|
||||
|
||||
|
||||
@ -9,17 +9,7 @@ using json = nlohmann::json;
|
||||
const std::string NESTED_KEY_DELIMITER = ".";
|
||||
std::vector<DataBucketsRepository::DataBuckets> g_data_bucket_cache = {};
|
||||
|
||||
#if defined(ZONE)
|
||||
#include "../zone/zonedb.h"
|
||||
extern ZoneDatabase database;
|
||||
#elif defined(WORLD)
|
||||
#include "../world/worlddb.h"
|
||||
extern WorldDatabase database;
|
||||
#else
|
||||
#error "You must define either ZONE or WORLD"
|
||||
#endif
|
||||
|
||||
void DataBucket::SetData(const std::string &bucket_key, const std::string &bucket_value, std::string expires_time)
|
||||
void DataBucket::SetData(SharedDatabase* database, const std::string &bucket_key, const std::string &bucket_value, std::string expires_time)
|
||||
{
|
||||
auto k = DataBucketKey{
|
||||
.key = bucket_key,
|
||||
@ -27,10 +17,10 @@ void DataBucket::SetData(const std::string &bucket_key, const std::string &bucke
|
||||
.expires = expires_time,
|
||||
};
|
||||
|
||||
DataBucket::SetData(k);
|
||||
DataBucket::SetData(database, k);
|
||||
}
|
||||
|
||||
void DataBucket::SetData(const DataBucketKey &k_)
|
||||
void DataBucket::SetData(SharedDatabase *database, const DataBucketKey &k_)
|
||||
{
|
||||
DataBucketKey k = k_; // copy the key so we can modify it
|
||||
bool is_nested = k.key.find(NESTED_KEY_DELIMITER) != std::string::npos;
|
||||
@ -39,7 +29,7 @@ void DataBucket::SetData(const DataBucketKey &k_)
|
||||
}
|
||||
|
||||
auto b = DataBucketsRepository::NewEntity();
|
||||
auto r = GetData(k, true);
|
||||
auto r = GetData(database, k, true);
|
||||
// if we have an entry, use it
|
||||
if (r.id > 0) {
|
||||
b = r;
|
||||
@ -149,10 +139,10 @@ void DataBucket::SetData(const DataBucketKey &k_)
|
||||
}
|
||||
}
|
||||
|
||||
DataBucketsRepository::UpdateOne(database, b);
|
||||
DataBucketsRepository::UpdateOne(*database, b);
|
||||
}
|
||||
else {
|
||||
b = DataBucketsRepository::InsertOne(database, b);
|
||||
b = DataBucketsRepository::InsertOne(*database, b);
|
||||
|
||||
// add to cache if it doesn't exist
|
||||
if (CanCache(k) && !ExistsInCache(b)) {
|
||||
@ -162,9 +152,9 @@ void DataBucket::SetData(const DataBucketKey &k_)
|
||||
}
|
||||
}
|
||||
|
||||
std::string DataBucket::GetData(const std::string &bucket_key)
|
||||
std::string DataBucket::GetData(SharedDatabase* database, const std::string &bucket_key)
|
||||
{
|
||||
return GetData(DataBucketKey{.key = bucket_key}).value;
|
||||
return GetData(database, DataBucketKey{.key = bucket_key}).value;
|
||||
}
|
||||
|
||||
DataBucketsRepository::DataBuckets DataBucket::ExtractNestedValue(
|
||||
@ -214,7 +204,7 @@ DataBucketsRepository::DataBuckets DataBucket::ExtractNestedValue(
|
||||
// if the bucket doesn't exist, it will be added to the cache as a miss
|
||||
// if ignore_misses_cache is true, the bucket will not be added to the cache as a miss
|
||||
// the only place we should be ignoring the misses cache is on the initial read during SetData
|
||||
DataBucketsRepository::DataBuckets DataBucket::GetData(const DataBucketKey &k_, bool ignore_misses_cache)
|
||||
DataBucketsRepository::DataBuckets DataBucket::GetData(SharedDatabase* database, const DataBucketKey &k_, bool ignore_misses_cache)
|
||||
{
|
||||
DataBucketKey k = k_; // Copy the key so we can modify it
|
||||
|
||||
@ -244,7 +234,7 @@ DataBucketsRepository::DataBuckets DataBucket::GetData(const DataBucketKey &k_,
|
||||
if (CheckBucketMatch(e, k)) {
|
||||
if (e.expires > 0 && e.expires < std::time(nullptr)) {
|
||||
LogDataBuckets("Attempted to read expired key [{}] removing from cache", e.key_);
|
||||
DeleteData(k);
|
||||
DeleteData(database, k);
|
||||
return DataBucketsRepository::NewEntity();
|
||||
}
|
||||
|
||||
@ -261,7 +251,7 @@ DataBucketsRepository::DataBuckets DataBucket::GetData(const DataBucketKey &k_,
|
||||
|
||||
// Fetch the value from the database
|
||||
auto r = DataBucketsRepository::GetWhere(
|
||||
database,
|
||||
*database,
|
||||
fmt::format(
|
||||
" {} `key` = '{}' LIMIT 1",
|
||||
DataBucket::GetScopedDbFilters(k),
|
||||
@ -310,7 +300,7 @@ DataBucketsRepository::DataBuckets DataBucket::GetData(const DataBucketKey &k_,
|
||||
|
||||
// If the entry has expired, delete it
|
||||
if (bucket.expires > 0 && bucket.expires < static_cast<long long>(std::time(nullptr))) {
|
||||
DeleteData(k);
|
||||
DeleteData(database, k);
|
||||
return DataBucketsRepository::NewEntity();
|
||||
}
|
||||
|
||||
@ -337,22 +327,22 @@ DataBucketsRepository::DataBuckets DataBucket::GetData(const DataBucketKey &k_,
|
||||
return bucket;
|
||||
}
|
||||
|
||||
std::string DataBucket::GetDataExpires(const std::string &bucket_key)
|
||||
std::string DataBucket::GetDataExpires(SharedDatabase* database, const std::string &bucket_key)
|
||||
{
|
||||
return GetDataExpires(DataBucketKey{.key = bucket_key});
|
||||
return GetDataExpires(database, DataBucketKey{.key = bucket_key});
|
||||
}
|
||||
|
||||
std::string DataBucket::GetDataRemaining(const std::string &bucket_key)
|
||||
std::string DataBucket::GetDataRemaining(SharedDatabase* database, const std::string &bucket_key)
|
||||
{
|
||||
return GetDataRemaining(DataBucketKey{.key = bucket_key});
|
||||
return GetDataRemaining(database, DataBucketKey{.key = bucket_key});
|
||||
}
|
||||
|
||||
bool DataBucket::DeleteData(const std::string &bucket_key)
|
||||
bool DataBucket::DeleteData(SharedDatabase* database, const std::string &bucket_key)
|
||||
{
|
||||
return DeleteData(DataBucketKey{.key = bucket_key});
|
||||
return DeleteData(database, DataBucketKey{.key = bucket_key});
|
||||
}
|
||||
|
||||
bool DataBucket::DeleteData(const DataBucketKey &k)
|
||||
bool DataBucket::DeleteData(SharedDatabase* database, const DataBucketKey &k)
|
||||
{
|
||||
bool is_nested_key = k.key.find(NESTED_KEY_DELIMITER) != std::string::npos;
|
||||
|
||||
@ -374,7 +364,7 @@ bool DataBucket::DeleteData(const DataBucketKey &k)
|
||||
|
||||
// Regular key deletion, no nesting involved
|
||||
return DataBucketsRepository::DeleteWhere(
|
||||
database,
|
||||
*database,
|
||||
fmt::format("{} `key` = '{}'", DataBucket::GetScopedDbFilters(k), k.key)
|
||||
);
|
||||
}
|
||||
@ -384,7 +374,7 @@ bool DataBucket::DeleteData(const DataBucketKey &k)
|
||||
DataBucketKey top_level_k = k;
|
||||
top_level_k.key = top_level_key;
|
||||
|
||||
auto r = GetData(top_level_k);
|
||||
auto r = GetData(database, top_level_k);
|
||||
if (r.id == 0 || r.value.empty() || !Strings::IsValidJson(r.value)) {
|
||||
LogDataBuckets("Attempted to delete nested key [{}] but parent key [{}] does not exist or is invalid JSON", k.key, top_level_key);
|
||||
return false;
|
||||
@ -444,14 +434,14 @@ bool DataBucket::DeleteData(const DataBucketKey &k)
|
||||
}
|
||||
|
||||
return DataBucketsRepository::DeleteWhere(
|
||||
database,
|
||||
*database,
|
||||
fmt::format("{} `key` = '{}'", DataBucket::GetScopedDbFilters(k), top_level_key)
|
||||
);
|
||||
}
|
||||
|
||||
// Otherwise, update the existing JSON without the deleted key
|
||||
r.value = json_value.dump();
|
||||
DataBucketsRepository::UpdateOne(database, r);
|
||||
DataBucketsRepository::UpdateOne(*database, r);
|
||||
|
||||
// Update cache
|
||||
if (CanCache(k)) {
|
||||
@ -466,7 +456,7 @@ bool DataBucket::DeleteData(const DataBucketKey &k)
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string DataBucket::GetDataExpires(const DataBucketKey &k)
|
||||
std::string DataBucket::GetDataExpires(SharedDatabase* database, const DataBucketKey &k)
|
||||
{
|
||||
LogDataBuckets(
|
||||
"Getting bucket expiration key [{}] bot_id [{}] account_id [{}] character_id [{}] npc_id [{}]",
|
||||
@ -477,7 +467,7 @@ std::string DataBucket::GetDataExpires(const DataBucketKey &k)
|
||||
k.npc_id
|
||||
);
|
||||
|
||||
auto r = GetData(k);
|
||||
auto r = GetData(database, k);
|
||||
if (r.id == 0) {
|
||||
return {};
|
||||
}
|
||||
@ -485,7 +475,7 @@ std::string DataBucket::GetDataExpires(const DataBucketKey &k)
|
||||
return std::to_string(r.expires);
|
||||
}
|
||||
|
||||
std::string DataBucket::GetDataRemaining(const DataBucketKey &k)
|
||||
std::string DataBucket::GetDataRemaining(SharedDatabase* database, const DataBucketKey &k)
|
||||
{
|
||||
LogDataBuckets(
|
||||
"Getting bucket remaining key [{}] bot_id [{}] account_id [{}] character_id [{}] npc_id [{}] bot_id [{}] zone_id [{}] instance_id [{}]",
|
||||
@ -499,7 +489,7 @@ std::string DataBucket::GetDataRemaining(const DataBucketKey &k)
|
||||
k.instance_id
|
||||
);
|
||||
|
||||
auto r = GetData(k);
|
||||
auto r = GetData(database, k);
|
||||
if (r.id == 0) {
|
||||
return "0";
|
||||
}
|
||||
@ -565,10 +555,10 @@ bool DataBucket::CheckBucketMatch(const DataBucketsRepository::DataBuckets &dbe,
|
||||
);
|
||||
}
|
||||
|
||||
void DataBucket::LoadZoneCache(uint16 zone_id, uint16 instance_id)
|
||||
void DataBucket::LoadZoneCache(SharedDatabase* database, uint16 zone_id, uint16 instance_id)
|
||||
{
|
||||
const auto &l = DataBucketsRepository::GetWhere(
|
||||
database,
|
||||
*database,
|
||||
fmt::format(
|
||||
"zone_id = {} AND instance_id = {} AND (`expires` > {} OR `expires` = 0)",
|
||||
zone_id,
|
||||
@ -608,7 +598,7 @@ void DataBucket::LoadZoneCache(uint16 zone_id, uint16 instance_id)
|
||||
);
|
||||
}
|
||||
|
||||
void DataBucket::BulkLoadEntitiesToCache(DataBucketLoadType::Type t, std::vector<uint32> ids)
|
||||
void DataBucket::BulkLoadEntitiesToCache(SharedDatabase* database, DataBucketLoadType::Type t, std::vector<uint32> ids)
|
||||
{
|
||||
if (ids.empty()) {
|
||||
return;
|
||||
@ -653,7 +643,7 @@ void DataBucket::BulkLoadEntitiesToCache(DataBucketLoadType::Type t, std::vector
|
||||
}
|
||||
|
||||
const auto &l = DataBucketsRepository::GetWhere(
|
||||
database,
|
||||
*database,
|
||||
fmt::format(
|
||||
"{} IN ({}) AND (`expires` > {} OR `expires` = 0)",
|
||||
column,
|
||||
@ -843,4 +833,4 @@ bool DataBucket::CanCache(const DataBucketKey &key)
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
#include "types.h"
|
||||
#include "repositories/data_buckets_repository.h"
|
||||
#include "json/json_archive_single_line.h"
|
||||
#include "shareddb.h"
|
||||
|
||||
struct DataBucketKey {
|
||||
std::string key;
|
||||
@ -38,26 +39,26 @@ namespace DataBucketLoadType {
|
||||
class DataBucket {
|
||||
public:
|
||||
// non-scoped bucket methods (for global buckets)
|
||||
static void SetData(const std::string &bucket_key, const std::string &bucket_value, std::string expires_time = "");
|
||||
static bool DeleteData(const std::string &bucket_key);
|
||||
static std::string GetData(const std::string &bucket_key);
|
||||
static std::string GetDataExpires(const std::string &bucket_key);
|
||||
static std::string GetDataRemaining(const std::string &bucket_key);
|
||||
static void SetData(SharedDatabase *database, const std::string &bucket_key, const std::string &bucket_value, std::string expires_time = "");
|
||||
static bool DeleteData(SharedDatabase *database, const std::string &bucket_key);
|
||||
static std::string GetData(SharedDatabase *database, const std::string &bucket_key);
|
||||
static std::string GetDataExpires(SharedDatabase *database, const std::string &bucket_key);
|
||||
static std::string GetDataRemaining(SharedDatabase *database, const std::string &bucket_key);
|
||||
|
||||
// scoped bucket methods
|
||||
static void SetData(const DataBucketKey &k_);
|
||||
static bool DeleteData(const DataBucketKey &k);
|
||||
static DataBucketsRepository::DataBuckets GetData(const DataBucketKey &k_, bool ignore_misses_cache = false);
|
||||
static std::string GetDataExpires(const DataBucketKey &k);
|
||||
static std::string GetDataRemaining(const DataBucketKey &k);
|
||||
static void SetData(SharedDatabase *database, const DataBucketKey &k_);
|
||||
static bool DeleteData(SharedDatabase *database, const DataBucketKey &k);
|
||||
static DataBucketsRepository::DataBuckets GetData(SharedDatabase *database, const DataBucketKey &k_, bool ignore_misses_cache = false);
|
||||
static std::string GetDataExpires(SharedDatabase *database, const DataBucketKey &k);
|
||||
static std::string GetDataRemaining(SharedDatabase *database, const DataBucketKey &k);
|
||||
static std::string GetScopedDbFilters(const DataBucketKey &k);
|
||||
|
||||
// bucket repository versus key matching
|
||||
static bool CheckBucketMatch(const DataBucketsRepository::DataBuckets &dbe, const DataBucketKey &k);
|
||||
static bool ExistsInCache(const DataBucketsRepository::DataBuckets &entry);
|
||||
|
||||
static void LoadZoneCache(uint16 zone_id, uint16 instance_id);
|
||||
static void BulkLoadEntitiesToCache(DataBucketLoadType::Type t, std::vector<uint32> ids);
|
||||
static void LoadZoneCache(SharedDatabase* database, uint16 zone_id, uint16 instance_id);
|
||||
static void BulkLoadEntitiesToCache(SharedDatabase* database, DataBucketLoadType::Type t, std::vector<uint32> ids);
|
||||
static void DeleteCachedBuckets(DataBucketLoadType::Type type, uint32 id, uint32 secondary_id = 0);
|
||||
|
||||
static void DeleteFromMissesCache(DataBucketsRepository::DataBuckets e);
|
||||
|
||||
@ -5,11 +5,10 @@
|
||||
#include "../strings.h"
|
||||
#include "../rulesys.h"
|
||||
#include "../http/httplib.h"
|
||||
|
||||
#include "database_update_manifest.cpp"
|
||||
#include "database_update_manifest_custom.cpp"
|
||||
#include "database_update_manifest_bots.cpp"
|
||||
#include "database_dump_service.h"
|
||||
#include "database_update_manifest.h"
|
||||
#include "database_update_manifest_custom.h"
|
||||
#include "database_update_manifest_bots.h"
|
||||
|
||||
constexpr int BREAK_LENGTH = 70;
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
#include "database_update.h"
|
||||
#pragma once
|
||||
|
||||
std::vector<ManifestEntry> manifest_entries = {
|
||||
ManifestEntry{
|
||||
@ -1,4 +1,4 @@
|
||||
#include "database_update.h"
|
||||
#pragma once
|
||||
|
||||
std::vector<ManifestEntry> bot_manifest_entries = {
|
||||
ManifestEntry{
|
||||
@ -1,4 +1,4 @@
|
||||
#include "database_update.h"
|
||||
#pragma once
|
||||
|
||||
std::vector<ManifestEntry> manifest_entries_custom = {
|
||||
ManifestEntry{
|
||||
@ -258,9 +258,17 @@ bool DBcore::Open(uint32 *errnum, char *errbuf)
|
||||
if (pCompress) {
|
||||
flags |= CLIENT_COMPRESS;
|
||||
}
|
||||
|
||||
//todo: we need to revisit this ssl handling later
|
||||
//the whole connect code is ancient and tls is starting to come as a default requirement for many db setups
|
||||
if (pSSL) {
|
||||
flags |= CLIENT_SSL;
|
||||
}
|
||||
else {
|
||||
int off = 0;
|
||||
mysql_options(mysql, MYSQL_OPT_SSL_ENFORCE, &off);
|
||||
mysql_options(mysql, MYSQL_OPT_SSL_VERIFY_SERVER_CERT, &off);
|
||||
}
|
||||
if (mysql_real_connect(mysql, pHost, pUser, pPassword, pDatabase, pPort, 0, flags)) {
|
||||
pStatus = Connected;
|
||||
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
#include "rulesys.h"
|
||||
#include "util/uuid.h"
|
||||
#include <fmt/format.h>
|
||||
#include <fmt/ranges.h>
|
||||
#include <cereal/types/chrono.hpp>
|
||||
|
||||
DzLockout::DzLockout(std::string uuid, std::string expedition, std::string event, uint64_t expire_time, uint32_t duration)
|
||||
|
||||
@ -23,9 +23,9 @@
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
#include <time.h>
|
||||
#include "../cereal/include/cereal/archives/binary.hpp"
|
||||
#include "../cereal/include/cereal/types/string.hpp"
|
||||
#include "../cereal/include/cereal/types/vector.hpp"
|
||||
#include <cereal/archives/binary.hpp>
|
||||
#include <cereal/types/string.hpp>
|
||||
#include <cereal/types/vector.hpp>
|
||||
#include "../common/version.h"
|
||||
#include "emu_constants.h"
|
||||
#include "textures.h"
|
||||
|
||||
@ -23,6 +23,7 @@
|
||||
#include "path_manager.h"
|
||||
#include <fstream>
|
||||
#include <fmt/format.h>
|
||||
#include <fmt/ranges.h>
|
||||
|
||||
struct LoginConfig {
|
||||
std::string LoginHost;
|
||||
|
||||
@ -34,6 +34,7 @@
|
||||
#endif
|
||||
|
||||
#include <fmt/format.h>
|
||||
#include <fmt/ranges.h>
|
||||
#include "types.h"
|
||||
|
||||
namespace Logs {
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
#include "../json/json_archive_single_line.h"
|
||||
#include <vector>
|
||||
#include <fmt/format.h>
|
||||
#include <fmt/ranges.h>
|
||||
#include <cereal/archives/json.hpp>
|
||||
#include <cereal/types/vector.hpp>
|
||||
|
||||
|
||||
@ -36,6 +36,7 @@
|
||||
#endif
|
||||
|
||||
#include <fmt/format.h>
|
||||
#include <fmt/ranges.h>
|
||||
#include <filesystem>
|
||||
#include <iostream>
|
||||
#include <sys/stat.h>
|
||||
|
||||
@ -20,6 +20,7 @@
|
||||
|
||||
#include <cstring>
|
||||
#include <fmt/format.h>
|
||||
#include <fmt/ranges.h>
|
||||
#include <csignal>
|
||||
#include <vector>
|
||||
#include "ip_util.h"
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
#include "console_server.h"
|
||||
#include "../strings.h"
|
||||
#include <fmt/format.h>
|
||||
#include <fmt/ranges.h>
|
||||
|
||||
EQ::Net::ConsoleServer::ConsoleServer(const std::string &addr, int port)
|
||||
{
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
#include "../servertalk.h"
|
||||
#include "../rulesys.h"
|
||||
#include <fmt/format.h>
|
||||
#include <fmt/ranges.h>
|
||||
|
||||
EQ::Net::ConsoleServerConnection::ConsoleServerConnection(ConsoleServer *parent, std::shared_ptr<TCPConnection> connection)
|
||||
{
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
#include "endian.h"
|
||||
#include <cctype>
|
||||
#include <fmt/format.h>
|
||||
#include <fmt/ranges.h>
|
||||
|
||||
void EQ::Net::Packet::PutInt8(size_t offset, int8_t value)
|
||||
{
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
#include "crc32.h"
|
||||
#include <zlib.h>
|
||||
#include <fmt/format.h>
|
||||
#include <fmt/ranges.h>
|
||||
|
||||
// observed client receive window is 300 packets, 140KB
|
||||
constexpr size_t MAX_CLIENT_RECV_PACKETS_PER_WINDOW = 300;
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
#include "../event/event_loop.h"
|
||||
#include "../event/timer.h"
|
||||
#include <fmt/format.h>
|
||||
#include <fmt/ranges.h>
|
||||
#include <map>
|
||||
#include <unordered_set>
|
||||
#include <array>
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
#include "../util/uuid.h"
|
||||
#include <sstream>
|
||||
#include <fmt/format.h>
|
||||
#include <fmt/ranges.h>
|
||||
|
||||
struct EQ::Net::WebsocketServerConnection::Impl {
|
||||
WebsocketServer *parent;
|
||||
|
||||
@ -38,7 +38,7 @@
|
||||
#include "../raid.h"
|
||||
#include "../guilds.h"
|
||||
//#include "../repositories/trader_repository.h"
|
||||
#include "../cereal/include/cereal/types/vector.hpp"
|
||||
#include <cereal/types/vector.hpp>
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
#include <memory>
|
||||
#include "process.h"
|
||||
#include <fmt/format.h>
|
||||
#include <fmt/ranges.h>
|
||||
|
||||
std::string Process::execute(const std::string &cmd)
|
||||
{
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include <fmt/ranges.h>
|
||||
|
||||
class DBcore;
|
||||
|
||||
|
||||
@ -7,8 +7,8 @@
|
||||
#include "items_repository.h"
|
||||
#include "../../common/item_data.h"
|
||||
#include "../../common/races.h"
|
||||
#include "../cereal/include/cereal/archives/binary.hpp"
|
||||
#include "../cereal/include/cereal/types/string.hpp"
|
||||
#include <cereal/archives/binary.hpp>
|
||||
#include <cereal/types/string.hpp>
|
||||
|
||||
class TraderRepository : public BaseTraderRepository {
|
||||
public:
|
||||
|
||||
@ -23,6 +23,7 @@
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <fmt/format.h>
|
||||
#include <fmt/ranges.h>
|
||||
|
||||
#include "../common/repositories/rule_sets_repository.h"
|
||||
#include "../common/repositories/rule_values_repository.h"
|
||||
|
||||
@ -19,6 +19,7 @@
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
#include <fmt/format.h>
|
||||
#include <fmt/ranges.h>
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1800
|
||||
#include <algorithm>
|
||||
|
||||
@ -36,6 +36,7 @@
|
||||
#include "strings.h"
|
||||
#include <cereal/external/rapidjson/document.h>
|
||||
#include <fmt/format.h>
|
||||
#include <fmt/ranges.h>
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
|
||||
@ -47,14 +48,9 @@
|
||||
#include <random>
|
||||
#include <string>
|
||||
|
||||
//Const char based
|
||||
#include "strings_legacy.cpp" // legacy c functions
|
||||
#include "strings_misc.cpp" // anything non "Strings" scoped
|
||||
|
||||
#ifdef _WINDOWS
|
||||
#include <ctype.h>
|
||||
#include <functional>
|
||||
#include <algorithm>
|
||||
#endif
|
||||
|
||||
std::string Strings::Random(size_t length)
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
#include <ios>
|
||||
#include <fmt/format.h>
|
||||
#include <fmt/ranges.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <objbase.h>
|
||||
|
||||
@ -25,7 +25,7 @@
|
||||
|
||||
// Build variables
|
||||
// these get injected during the build pipeline
|
||||
#define CURRENT_VERSION "23.10.2-dev" // always append -dev to the current version for custom-builds
|
||||
#define CURRENT_VERSION "23.10.3-dev" // always append -dev to the current version for custom-builds
|
||||
#define LOGIN_VERSION "0.8.0"
|
||||
#define COMPILE_DATE __DATE__
|
||||
#define COMPILE_TIME __TIME__
|
||||
|
||||
@ -1,20 +1,20 @@
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 3.12)
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
SET(eqlaunch_sources
|
||||
set(eqlaunch_sources
|
||||
eqlaunch.cpp
|
||||
worldserver.cpp
|
||||
zone_launch.cpp
|
||||
)
|
||||
|
||||
SET(eqlaunch_headers
|
||||
set(eqlaunch_headers
|
||||
worldserver.h
|
||||
zone_launch.h
|
||||
)
|
||||
|
||||
ADD_EXECUTABLE(eqlaunch ${eqlaunch_sources} ${eqlaunch_headers})
|
||||
add_executable(eqlaunch ${eqlaunch_sources} ${eqlaunch_headers})
|
||||
|
||||
INSTALL(TARGETS eqlaunch RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
|
||||
install(TARGETS eqlaunch RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
|
||||
|
||||
TARGET_LINK_LIBRARIES(eqlaunch ${SERVER_LIBS})
|
||||
target_link_libraries(eqlaunch common)
|
||||
|
||||
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
|
||||
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
|
||||
|
||||
@ -1,22 +0,0 @@
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 3.2)
|
||||
|
||||
SET(hc_sources
|
||||
eq.cpp
|
||||
main.cpp
|
||||
login.cpp
|
||||
world.cpp
|
||||
)
|
||||
|
||||
SET(hc_headers
|
||||
eq.h
|
||||
login.h
|
||||
world.h
|
||||
)
|
||||
|
||||
ADD_EXECUTABLE(hc ${hc_sources} ${hc_headers})
|
||||
|
||||
INSTALL(TARGETS hc RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
|
||||
|
||||
TARGET_LINK_LIBRARIES(hc ${SERVER_LIBS})
|
||||
|
||||
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
|
||||
350
hc/eq.cpp
350
hc/eq.cpp
@ -1,350 +0,0 @@
|
||||
#include "eq.h"
|
||||
#include "../common/net/dns.h"
|
||||
|
||||
const char* eqcrypt_block(const char *buffer_in, size_t buffer_in_sz, char* buffer_out, bool enc) {
|
||||
DES_key_schedule k;
|
||||
DES_cblock v;
|
||||
|
||||
memset(&k, 0, sizeof(DES_key_schedule));
|
||||
memset(&v, 0, sizeof(DES_cblock));
|
||||
|
||||
if (!enc && buffer_in_sz && buffer_in_sz % 8 != 0) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
DES_ncbc_encrypt((const unsigned char*)buffer_in, (unsigned char*)buffer_out, (long)buffer_in_sz, &k, &v, enc);
|
||||
return buffer_out;
|
||||
}
|
||||
|
||||
EverQuest::EverQuest(const std::string &host, int port, const std::string &user, const std::string &pass, const std::string &server, const std::string &character)
|
||||
{
|
||||
m_host = host;
|
||||
m_port = port;
|
||||
m_user = user;
|
||||
m_pass = pass;
|
||||
m_server = server;
|
||||
m_character = character;
|
||||
m_dbid = 0;
|
||||
|
||||
EQ::Net::DNSLookup(m_host, port, false, [&](const std::string &addr) {
|
||||
if (addr.empty()) {
|
||||
Log.OutF(Logs::General, Logs::Headless_Client, "Could not resolve address: {0}", m_host);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
m_host = addr;
|
||||
m_login_connection_manager.reset(new EQ::Net::ReliableStreamConnectionManager());
|
||||
|
||||
m_login_connection_manager->OnNewConnection(std::bind(&EverQuest::LoginOnNewConnection, this, std::placeholders::_1));
|
||||
m_login_connection_manager->OnConnectionStateChange(std::bind(&EverQuest::LoginOnStatusChangeReconnectEnabled, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
|
||||
m_login_connection_manager->OnPacketRecv(std::bind(&EverQuest::LoginOnPacketRecv, this, std::placeholders::_1, std::placeholders::_2));
|
||||
|
||||
m_login_connection_manager->Connect(m_host, m_port);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
EverQuest::~EverQuest()
|
||||
{
|
||||
}
|
||||
|
||||
void EverQuest::LoginOnNewConnection(std::shared_ptr<EQ::Net::ReliableStreamConnection> connection)
|
||||
{
|
||||
m_login_connection = connection;
|
||||
Log.OutF(Logs::General, Logs::Headless_Client, "Connecting...");
|
||||
}
|
||||
|
||||
void EverQuest::LoginOnStatusChangeReconnectEnabled(std::shared_ptr<EQ::Net::ReliableStreamConnection> conn, EQ::Net::DbProtocolStatus from, EQ::Net::DbProtocolStatus to)
|
||||
{
|
||||
if (to == EQ::Net::StatusConnected) {
|
||||
Log.OutF(Logs::General, Logs::Headless_Client, "Login connected.");
|
||||
LoginSendSessionReady();
|
||||
}
|
||||
|
||||
if (to == EQ::Net::StatusDisconnected) {
|
||||
Log.OutF(Logs::General, Logs::Headless_Client, "Login connection lost before we got to world, reconnecting.");
|
||||
m_key.clear();
|
||||
m_dbid = 0;
|
||||
m_login_connection.reset();
|
||||
m_login_connection_manager->Connect(m_host, m_port);
|
||||
}
|
||||
}
|
||||
|
||||
void EverQuest::LoginOnStatusChangeReconnectDisabled(std::shared_ptr<EQ::Net::ReliableStreamConnection> conn, EQ::Net::DbProtocolStatus from, EQ::Net::DbProtocolStatus to)
|
||||
{
|
||||
if (to == EQ::Net::StatusDisconnected) {
|
||||
m_login_connection.reset();
|
||||
}
|
||||
}
|
||||
|
||||
void EverQuest::LoginOnPacketRecv(std::shared_ptr<EQ::Net::ReliableStreamConnection> conn, const EQ::Net::Packet & p)
|
||||
{
|
||||
auto opcode = p.GetUInt16(0);
|
||||
switch (opcode) {
|
||||
case 0x0017: //OP_ChatMessage
|
||||
LoginSendLogin();
|
||||
break;
|
||||
case 0x0018:
|
||||
LoginProcessLoginResponse(p);
|
||||
break;
|
||||
case 0x0019:
|
||||
LoginProcessServerPacketList(p);
|
||||
break;
|
||||
case 0x0022:
|
||||
LoginProcessServerPlayResponse(p);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void EverQuest::LoginSendSessionReady()
|
||||
{
|
||||
EQ::Net::DynamicPacket p;
|
||||
p.PutUInt16(0, 1); //OP_SessionReady
|
||||
p.PutUInt32(2, 2);
|
||||
|
||||
m_login_connection->QueuePacket(p);
|
||||
}
|
||||
|
||||
void EverQuest::LoginSendLogin()
|
||||
{
|
||||
size_t buffer_len = m_user.length() + m_pass.length() + 2;
|
||||
std::unique_ptr<char[]> buffer(new char[buffer_len]);
|
||||
|
||||
strcpy(&buffer[0], m_user.c_str());
|
||||
strcpy(&buffer[m_user.length() + 1], m_pass.c_str());
|
||||
|
||||
size_t encrypted_len = buffer_len;
|
||||
|
||||
if (encrypted_len % 8 > 0) {
|
||||
encrypted_len = ((encrypted_len / 8) + 1) * 8;
|
||||
}
|
||||
|
||||
EQ::Net::DynamicPacket p;
|
||||
p.Resize(12 + encrypted_len);
|
||||
p.PutUInt16(0, 2); //OP_Login
|
||||
p.PutUInt32(2, 3);
|
||||
|
||||
eqcrypt_block(&buffer[0], buffer_len, (char*)p.Data() + 12, true);
|
||||
|
||||
m_login_connection->QueuePacket(p);
|
||||
}
|
||||
|
||||
void EverQuest::LoginSendServerRequest()
|
||||
{
|
||||
EQ::Net::DynamicPacket p;
|
||||
p.PutUInt16(0, 4); //OP_ServerListRequest
|
||||
p.PutUInt32(2, 4);
|
||||
|
||||
m_login_connection->QueuePacket(p);
|
||||
}
|
||||
|
||||
void EverQuest::LoginSendPlayRequest(uint32_t id)
|
||||
{
|
||||
EQ::Net::DynamicPacket p;
|
||||
p.PutUInt16(0, 0x000d);
|
||||
p.PutUInt16(2, 5);
|
||||
p.PutUInt32(4, 0);
|
||||
p.PutUInt32(8, 0);
|
||||
p.PutUInt32(12, id);
|
||||
|
||||
m_login_connection->QueuePacket(p);
|
||||
}
|
||||
|
||||
void EverQuest::LoginProcessLoginResponse(const EQ::Net::Packet & p)
|
||||
{
|
||||
auto encrypt_size = p.Length() - 12;
|
||||
if (encrypt_size % 8 > 0) {
|
||||
encrypt_size = (encrypt_size / 8) * 8;
|
||||
}
|
||||
|
||||
std::unique_ptr<char[]> decrypted(new char[encrypt_size]);
|
||||
|
||||
eqcrypt_block((char*)p.Data() + 12, encrypt_size, &decrypted[0], false);
|
||||
|
||||
EQ::Net::StaticPacket sp(&decrypted[0], encrypt_size);
|
||||
auto response_error = sp.GetUInt16(1);
|
||||
|
||||
if (response_error > 101) {
|
||||
Log.OutF(Logs::General, Logs::Headless_Client, "Error logging in response code: {0}", response_error);
|
||||
LoginDisableReconnect();
|
||||
}
|
||||
else {
|
||||
m_key = sp.GetCString(12);
|
||||
m_dbid = sp.GetUInt32(8);
|
||||
|
||||
Log.OutF(Logs::General, Logs::Headless_Client, "Logged in successfully with dbid {0} and key {1}", m_dbid, m_key);
|
||||
LoginSendServerRequest();
|
||||
}
|
||||
}
|
||||
|
||||
void EverQuest::LoginProcessServerPacketList(const EQ::Net::Packet & p)
|
||||
{
|
||||
m_world_servers.clear();
|
||||
auto number_of_servers = p.GetUInt32(18);
|
||||
size_t idx = 22;
|
||||
|
||||
for (auto i = 0U; i < number_of_servers; ++i) {
|
||||
WorldServer ws;
|
||||
ws.address = p.GetCString(idx);
|
||||
idx += (ws.address.length() + 1);
|
||||
|
||||
ws.type = p.GetInt32(idx);
|
||||
idx += 4;
|
||||
|
||||
auto id = p.GetUInt32(idx);
|
||||
idx += 4;
|
||||
|
||||
ws.long_name = p.GetCString(idx);
|
||||
idx += (ws.long_name.length() + 1);
|
||||
|
||||
ws.lang = p.GetCString(idx);
|
||||
idx += (ws.lang.length() + 1);
|
||||
|
||||
ws.region = p.GetCString(idx);
|
||||
idx += (ws.region.length() + 1);
|
||||
|
||||
ws.status = p.GetInt32(idx);
|
||||
idx += 4;
|
||||
|
||||
ws.players = p.GetInt32(idx);
|
||||
idx += 4;
|
||||
|
||||
m_world_servers[id] = ws;
|
||||
}
|
||||
|
||||
for (auto server : m_world_servers) {
|
||||
if (server.second.long_name.compare(m_server) == 0) {
|
||||
Log.OutF(Logs::General, Logs::Headless_Client, "Found world server {0}, attempting to login.", m_server);
|
||||
LoginSendPlayRequest(server.first);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Log.OutF(Logs::General, Logs::Headless_Client, "Got response from login server but could not find world server {0} disconnecting.", m_server);
|
||||
LoginDisableReconnect();
|
||||
}
|
||||
|
||||
void EverQuest::LoginProcessServerPlayResponse(const EQ::Net::Packet &p)
|
||||
{
|
||||
auto allowed = p.GetUInt8(12);
|
||||
|
||||
if (allowed) {
|
||||
auto server = p.GetUInt32(18);
|
||||
auto ws = m_world_servers.find(server);
|
||||
if (ws != m_world_servers.end()) {
|
||||
ConnectToWorld();
|
||||
LoginDisableReconnect();
|
||||
}
|
||||
}
|
||||
else {
|
||||
auto message = p.GetUInt16(13);
|
||||
Log.OutF(Logs::General, Logs::Headless_Client, "Failed to login to server with message {0}");
|
||||
LoginDisableReconnect();
|
||||
}
|
||||
}
|
||||
|
||||
void EverQuest::LoginDisableReconnect()
|
||||
{
|
||||
m_login_connection_manager->OnConnectionStateChange(std::bind(&EverQuest::LoginOnStatusChangeReconnectDisabled, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
|
||||
m_login_connection->Close();
|
||||
}
|
||||
|
||||
void EverQuest::ConnectToWorld()
|
||||
{
|
||||
m_world_connection_manager.reset(new EQ::Net::ReliableStreamConnectionManager());
|
||||
m_world_connection_manager->OnNewConnection(std::bind(&EverQuest::WorldOnNewConnection, this, std::placeholders::_1));
|
||||
m_world_connection_manager->OnConnectionStateChange(std::bind(&EverQuest::WorldOnStatusChangeReconnectEnabled, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
|
||||
m_world_connection_manager->OnPacketRecv(std::bind(&EverQuest::WorldOnPacketRecv, this, std::placeholders::_1, std::placeholders::_2));
|
||||
m_world_connection_manager->Connect(m_host, 9000);
|
||||
}
|
||||
|
||||
void EverQuest::WorldOnNewConnection(std::shared_ptr<EQ::Net::ReliableStreamConnection> connection)
|
||||
{
|
||||
m_world_connection = connection;
|
||||
Log.OutF(Logs::General, Logs::Headless_Client, "Connecting to world...");
|
||||
}
|
||||
|
||||
void EverQuest::WorldOnStatusChangeReconnectEnabled(std::shared_ptr<EQ::Net::ReliableStreamConnection> conn, EQ::Net::DbProtocolStatus from, EQ::Net::DbProtocolStatus to)
|
||||
{
|
||||
if (to == EQ::Net::StatusConnected) {
|
||||
Log.OutF(Logs::General, Logs::Headless_Client, "World connected.");
|
||||
WorldSendClientAuth();
|
||||
}
|
||||
|
||||
if (to == EQ::Net::StatusDisconnected) {
|
||||
Log.OutF(Logs::General, Logs::Headless_Client, "World connection lost, reconnecting.");
|
||||
m_world_connection.reset();
|
||||
m_world_connection_manager->Connect(m_host, 9000);
|
||||
}
|
||||
}
|
||||
|
||||
void EverQuest::WorldOnStatusChangeReconnectDisabled(std::shared_ptr<EQ::Net::ReliableStreamConnection> conn, EQ::Net::DbProtocolStatus from, EQ::Net::DbProtocolStatus to)
|
||||
{
|
||||
if (to == EQ::Net::StatusDisconnected) {
|
||||
m_world_connection.reset();
|
||||
}
|
||||
}
|
||||
|
||||
void EverQuest::WorldOnPacketRecv(std::shared_ptr<EQ::Net::ReliableStreamConnection> conn, const EQ::Net::Packet & p)
|
||||
{
|
||||
auto opcode = p.GetUInt16(0);
|
||||
switch (opcode) {
|
||||
case 0x00d2:
|
||||
WorldProcessCharacterSelect(p);
|
||||
break;
|
||||
default:
|
||||
Log.OutF(Logs::General, Logs::Headless_Client, "Unhandled opcode: {0:#x}", opcode);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void EverQuest::WorldSendClientAuth()
|
||||
{
|
||||
EQ::Net::DynamicPacket p;
|
||||
p.Resize(2 + 464);
|
||||
|
||||
p.PutUInt16(0, 0x7a09U);
|
||||
std::string dbid_str = std::to_string(m_dbid);
|
||||
|
||||
p.PutCString(2, dbid_str.c_str());
|
||||
p.PutCString(2 + dbid_str.length() + 1, m_key.c_str());
|
||||
|
||||
m_world_connection->QueuePacket(p);
|
||||
}
|
||||
|
||||
void EverQuest::WorldSendEnterWorld(const std::string &character)
|
||||
{
|
||||
EQ::Net::DynamicPacket p;
|
||||
p.PutUInt16(0, 0x578f);
|
||||
p.PutString(2, character);
|
||||
p.PutUInt32(66, 0);
|
||||
p.PutUInt32(70, 0);
|
||||
|
||||
m_world_connection->QueuePacket(p);
|
||||
}
|
||||
|
||||
void EverQuest::WorldProcessCharacterSelect(const EQ::Net::Packet &p)
|
||||
{
|
||||
auto char_count = p.GetUInt32(2);
|
||||
size_t idx = 6;
|
||||
|
||||
//Log.OutF(Logs::General, Logs::Headless_Client, "{0} characters", char_count);
|
||||
for (uint32_t i = 0; i < char_count; ++i) {
|
||||
auto name = p.GetCString(idx);
|
||||
idx += name.length() + 1;
|
||||
|
||||
auto pclass = p.GetUInt8(idx);
|
||||
auto prace = p.GetUInt32(idx + 1);
|
||||
auto plevel = p.GetUInt8(idx + 5);
|
||||
|
||||
idx += 274;
|
||||
if (m_character.compare(name) == 0) {
|
||||
Log.OutF(Logs::General, Logs::Headless_Client, "Found {0}, would attempt to login here.", m_character);
|
||||
WorldSendEnterWorld(m_character);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Log.OutF(Logs::General, Logs::Headless_Client, "Could not find {0}, cannot continue to login.", m_character);
|
||||
}
|
||||
|
||||
74
hc/eq.h
74
hc/eq.h
@ -1,74 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "../common/eqemu_logsys.h"
|
||||
#include "../common/net/reliable_stream_connection.h"
|
||||
#include "../common/event/timer.h"
|
||||
#include <openssl/des.h>
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
struct WorldServer
|
||||
{
|
||||
std::string long_name;
|
||||
std::string address;
|
||||
int type;
|
||||
std::string lang;
|
||||
std::string region;
|
||||
int status;
|
||||
int players;
|
||||
};
|
||||
|
||||
class EverQuest
|
||||
{
|
||||
public:
|
||||
EverQuest(const std::string &host, int port, const std::string &user, const std::string &pass, const std::string &server, const std::string &character);
|
||||
~EverQuest();
|
||||
|
||||
private:
|
||||
//Login
|
||||
void LoginOnNewConnection(std::shared_ptr<EQ::Net::ReliableStreamConnection> connection);
|
||||
void LoginOnStatusChangeReconnectEnabled(std::shared_ptr<EQ::Net::ReliableStreamConnection> conn, EQ::Net::DbProtocolStatus from, EQ::Net::DbProtocolStatus to);
|
||||
void LoginOnStatusChangeReconnectDisabled(std::shared_ptr<EQ::Net::ReliableStreamConnection> conn, EQ::Net::DbProtocolStatus from, EQ::Net::DbProtocolStatus to);
|
||||
void LoginOnPacketRecv(std::shared_ptr<EQ::Net::ReliableStreamConnection> conn, const EQ::Net::Packet &p);
|
||||
|
||||
void LoginSendSessionReady();
|
||||
void LoginSendLogin();
|
||||
void LoginSendServerRequest();
|
||||
void LoginSendPlayRequest(uint32_t id);
|
||||
void LoginProcessLoginResponse(const EQ::Net::Packet &p);
|
||||
void LoginProcessServerPacketList(const EQ::Net::Packet &p);
|
||||
void LoginProcessServerPlayResponse(const EQ::Net::Packet &p);
|
||||
|
||||
void LoginDisableReconnect();
|
||||
|
||||
std::unique_ptr<EQ::Net::ReliableStreamConnectionManager> m_login_connection_manager;
|
||||
std::shared_ptr<EQ::Net::ReliableStreamConnection> m_login_connection;
|
||||
std::map<uint32_t, WorldServer> m_world_servers;
|
||||
|
||||
//World
|
||||
void ConnectToWorld();
|
||||
|
||||
void WorldOnNewConnection(std::shared_ptr<EQ::Net::ReliableStreamConnection> connection);
|
||||
void WorldOnStatusChangeReconnectEnabled(std::shared_ptr<EQ::Net::ReliableStreamConnection> conn, EQ::Net::DbProtocolStatus from, EQ::Net::DbProtocolStatus to);
|
||||
void WorldOnStatusChangeReconnectDisabled(std::shared_ptr<EQ::Net::ReliableStreamConnection> conn, EQ::Net::DbProtocolStatus from, EQ::Net::DbProtocolStatus to);
|
||||
void WorldOnPacketRecv(std::shared_ptr<EQ::Net::ReliableStreamConnection> conn, const EQ::Net::Packet &p);
|
||||
|
||||
void WorldSendClientAuth();
|
||||
void WorldSendEnterWorld(const std::string &character);
|
||||
|
||||
void WorldProcessCharacterSelect(const EQ::Net::Packet &p);
|
||||
|
||||
std::unique_ptr<EQ::Net::ReliableStreamConnectionManager> m_world_connection_manager;
|
||||
std::shared_ptr<EQ::Net::ReliableStreamConnection> m_world_connection;
|
||||
|
||||
//Variables
|
||||
std::string m_host;
|
||||
int m_port;
|
||||
std::string m_user;
|
||||
std::string m_pass;
|
||||
std::string m_server;
|
||||
std::string m_character;
|
||||
|
||||
std::string m_key;
|
||||
uint32_t m_dbid;
|
||||
};
|
||||
255
hc/login.cpp
255
hc/login.cpp
@ -1,255 +0,0 @@
|
||||
/*#include "login.h"
|
||||
#include "../common/eqemu_logsys.h"
|
||||
#include <openssl/des.h>
|
||||
|
||||
const char* eqcrypt_block(const char *buffer_in, size_t buffer_in_sz, char* buffer_out, bool enc) {
|
||||
DES_key_schedule k;
|
||||
DES_cblock v;
|
||||
|
||||
memset(&k, 0, sizeof(DES_key_schedule));
|
||||
memset(&v, 0, sizeof(DES_cblock));
|
||||
|
||||
if (!enc && buffer_in_sz && buffer_in_sz % 8 != 0) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
DES_ncbc_encrypt((const unsigned char*)buffer_in, (unsigned char*)buffer_out, (long)buffer_in_sz, &k, &v, enc);
|
||||
return buffer_out;
|
||||
}
|
||||
|
||||
LoginConnection::LoginConnection(const std::string &username, const std::string &password, const std::string &host, int host_port, const std::string &server)
|
||||
{
|
||||
m_connecting = false;
|
||||
m_username = username;
|
||||
m_password = password;
|
||||
m_host = host;
|
||||
m_host_port = host_port;
|
||||
m_server = server;
|
||||
|
||||
m_connection_manager.reset(new EQ::Net::ReliableStreamConnectionManager());
|
||||
|
||||
m_connection_manager->OnNewConnection(std::bind(&LoginConnection::OnNewConnection, this, std::placeholders::_1));
|
||||
m_connection_manager->OnConnectionStateChange(std::bind(&LoginConnection::OnStatusChangeActive, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
|
||||
m_connection_manager->OnPacketRecv(std::bind(&LoginConnection::OnPacketRecv, this, std::placeholders::_1, std::placeholders::_2));
|
||||
|
||||
m_connection_manager->Connect(host, host_port);
|
||||
}
|
||||
|
||||
LoginConnection::~LoginConnection()
|
||||
{
|
||||
}
|
||||
|
||||
void LoginConnection::OnNewConnection(std::shared_ptr<EQ::Net::ReliableStreamConnection> connection)
|
||||
{
|
||||
m_connection = connection;
|
||||
Log.OutF(Logs::General, Logs::Headless_Client, "Connecting...");
|
||||
}
|
||||
|
||||
void LoginConnection::OnStatusChangeActive(std::shared_ptr<EQ::Net::ReliableStreamConnection> conn, EQ::Net::DbProtocolStatus from, EQ::Net::DbProtocolStatus to)
|
||||
{
|
||||
if (to == EQ::Net::StatusConnected) {
|
||||
Log.OutF(Logs::General, Logs::Headless_Client, "Login connected.");
|
||||
SendSessionReady();
|
||||
}
|
||||
|
||||
if (to == EQ::Net::StatusDisconnected) {
|
||||
Log.OutF(Logs::General, Logs::Headless_Client, "Login connection lost, reconnecting.");
|
||||
m_key.clear();
|
||||
m_dbid = 0;
|
||||
m_connection.reset();
|
||||
m_connection_manager->Connect(m_host, m_host_port);
|
||||
}
|
||||
}
|
||||
|
||||
void LoginConnection::OnStatusChangeInactive(std::shared_ptr<EQ::Net::ReliableStreamConnection> conn, EQ::Net::DbProtocolStatus from, EQ::Net::DbProtocolStatus to)
|
||||
{
|
||||
if (to == EQ::Net::StatusDisconnected) {
|
||||
m_key.clear();
|
||||
m_dbid = 0;
|
||||
m_connection.reset();
|
||||
}
|
||||
}
|
||||
|
||||
void LoginConnection::OnPacketRecv(std::shared_ptr<EQ::Net::ReliableStreamConnection> conn, const EQ::Net::Packet &p)
|
||||
{
|
||||
auto opcode = p.GetUInt16(0);
|
||||
switch (opcode) {
|
||||
case 0x0017: //OP_ChatMessage
|
||||
SendLogin();
|
||||
break;
|
||||
case 0x0018:
|
||||
ProcessLoginResponse(p);
|
||||
break;
|
||||
case 0x0019:
|
||||
ProcessServerPacketList(p);
|
||||
break;
|
||||
case 0x0022:
|
||||
ProcessServerPlayResponse(p);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void LoginConnection::Kill()
|
||||
{
|
||||
m_connection_manager->OnConnectionStateChange(std::bind(&LoginConnection::OnStatusChangeInactive, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
|
||||
m_key.clear();
|
||||
m_dbid = 0;
|
||||
m_connection->Close();
|
||||
}
|
||||
|
||||
void LoginConnection::Start()
|
||||
{
|
||||
m_connection_manager->OnConnectionStateChange(std::bind(&LoginConnection::OnStatusChangeActive, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
|
||||
m_connection_manager->Connect(m_host, m_host_port);
|
||||
}
|
||||
|
||||
void LoginConnection::SendSessionReady()
|
||||
{
|
||||
EQ::Net::DynamicPacket p;
|
||||
p.PutUInt16(0, 1); //OP_SessionReady
|
||||
p.PutUInt32(2, 2);
|
||||
|
||||
m_connection->QueuePacket(p);
|
||||
}
|
||||
|
||||
void LoginConnection::SendLogin()
|
||||
{
|
||||
size_t buffer_len = m_username.length() + m_password.length() + 2;
|
||||
std::unique_ptr<char[]> buffer(new char[buffer_len]);
|
||||
|
||||
strcpy(&buffer[0], m_username.c_str());
|
||||
strcpy(&buffer[m_username.length() + 1], m_password.c_str());
|
||||
|
||||
size_t encrypted_len = buffer_len;
|
||||
|
||||
if (encrypted_len % 8 > 0) {
|
||||
encrypted_len = ((encrypted_len / 8) + 1) * 8;
|
||||
}
|
||||
|
||||
EQ::Net::DynamicPacket p;
|
||||
p.Resize(12 + encrypted_len);
|
||||
p.PutUInt16(0, 2); //OP_Login
|
||||
p.PutUInt32(2, 3);
|
||||
|
||||
eqcrypt_block(&buffer[0], buffer_len, (char*)p.Data() + 12, true);
|
||||
|
||||
m_connection->QueuePacket(p);
|
||||
}
|
||||
|
||||
void LoginConnection::SendServerRequest()
|
||||
{
|
||||
EQ::Net::DynamicPacket p;
|
||||
p.PutUInt16(0, 4); //OP_ServerListRequest
|
||||
p.PutUInt32(2, 4);
|
||||
|
||||
m_connection->QueuePacket(p);
|
||||
}
|
||||
|
||||
void LoginConnection::SendPlayRequest(uint32_t id)
|
||||
{
|
||||
EQ::Net::DynamicPacket p;
|
||||
p.PutUInt16(0, 0x000d);
|
||||
p.PutUInt16(2, 5);
|
||||
p.PutUInt32(4, 0);
|
||||
p.PutUInt32(8, 0);
|
||||
p.PutUInt32(12, id);
|
||||
|
||||
m_connection->QueuePacket(p);
|
||||
}
|
||||
|
||||
void LoginConnection::ProcessLoginResponse(const EQ::Net::Packet &p)
|
||||
{
|
||||
auto encrypt_size = p.Length() - 12;
|
||||
if (encrypt_size % 8 > 0) {
|
||||
encrypt_size = (encrypt_size / 8) * 8;
|
||||
}
|
||||
|
||||
std::unique_ptr<char[]> decrypted(new char[encrypt_size]);
|
||||
|
||||
eqcrypt_block((char*)p.Data() + 12, encrypt_size, &decrypted[0], false);
|
||||
|
||||
EQ::Net::StaticPacket sp(&decrypted[0], encrypt_size);
|
||||
auto response_error = sp.GetUInt16(1);
|
||||
|
||||
if (response_error > 101) {
|
||||
Log.OutF(Logs::General, Logs::Headless_Client, "Error logging in response code: {0}", response_error);
|
||||
Kill();
|
||||
}
|
||||
else {
|
||||
m_key = sp.GetCString(12);
|
||||
m_dbid = sp.GetUInt32(8);
|
||||
|
||||
Log.OutF(Logs::General, Logs::Headless_Client, "Logged in successfully with dbid {0} and key {1}", m_dbid, m_key);
|
||||
SendServerRequest();
|
||||
}
|
||||
}
|
||||
|
||||
void LoginConnection::ProcessServerPacketList(const EQ::Net::Packet &p)
|
||||
{
|
||||
m_world_servers.clear();
|
||||
auto number_of_servers = p.GetUInt32(18);
|
||||
size_t idx = 22;
|
||||
|
||||
for (auto i = 0U; i < number_of_servers; ++i) {
|
||||
WorldServer ws;
|
||||
ws.address = p.GetCString(idx);
|
||||
idx += (ws.address.length() + 1);
|
||||
|
||||
ws.type = p.GetInt32(idx);
|
||||
idx += 4;
|
||||
|
||||
auto id = p.GetUInt32(idx);
|
||||
idx += 4;
|
||||
|
||||
ws.long_name = p.GetCString(idx);
|
||||
idx += (ws.long_name.length() + 1);
|
||||
|
||||
ws.lang = p.GetCString(idx);
|
||||
idx += (ws.lang.length() + 1);
|
||||
|
||||
ws.region = p.GetCString(idx);
|
||||
idx += (ws.region.length() + 1);
|
||||
|
||||
ws.status = p.GetInt32(idx);
|
||||
idx += 4;
|
||||
|
||||
ws.players = p.GetInt32(idx);
|
||||
idx += 4;
|
||||
|
||||
m_world_servers[id] = ws;
|
||||
}
|
||||
|
||||
for (auto server : m_world_servers) {
|
||||
if (server.second.long_name.compare(m_server) == 0) {
|
||||
Log.OutF(Logs::General, Logs::Headless_Client, "Found world server {0}, attempting to login.", m_server);
|
||||
SendPlayRequest(server.first);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Log.OutF(Logs::General, Logs::Headless_Client, "Got response from login server but could not find world server {0} disconnecting.", m_server);
|
||||
Kill();
|
||||
}
|
||||
|
||||
void LoginConnection::ProcessServerPlayResponse(const EQ::Net::Packet &p)
|
||||
{
|
||||
auto allowed = p.GetUInt8(12);
|
||||
|
||||
if (allowed) {
|
||||
auto server = p.GetUInt32(18);
|
||||
auto ws = m_world_servers.find(server);
|
||||
if (ws != m_world_servers.end()) {
|
||||
if (m_on_can_login_world) {
|
||||
m_on_can_login_world(ws->second, m_key, m_dbid);
|
||||
}
|
||||
|
||||
Kill();
|
||||
}
|
||||
}
|
||||
else {
|
||||
auto message = p.GetUInt16(13);
|
||||
Log.OutF(Logs::General, Logs::Headless_Client, "Failed to login to server with message {0}");
|
||||
Kill();
|
||||
}
|
||||
}
|
||||
*/
|
||||
56
hc/login.h
56
hc/login.h
@ -1,56 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "../common/net/reliable_stream_connection.h"
|
||||
#include "../common/event/timer.h"
|
||||
#include <map>
|
||||
|
||||
struct WorldServer
|
||||
{
|
||||
std::string long_name;
|
||||
std::string address;
|
||||
int type;
|
||||
std::string lang;
|
||||
std::string region;
|
||||
int status;
|
||||
int players;
|
||||
};
|
||||
|
||||
class LoginConnection
|
||||
{
|
||||
public:
|
||||
LoginConnection(const std::string &username, const std::string &password, const std::string &host, int host_port, const std::string &server);
|
||||
void OnCanLoginToWorld(std::function<void(const WorldServer&, const std::string&, uint32_t)> cb) { m_on_can_login_world = cb; }
|
||||
|
||||
~LoginConnection();
|
||||
private:
|
||||
void OnNewConnection(std::shared_ptr<EQ::Net::ReliableStreamConnection> connection);
|
||||
void OnStatusChangeActive(std::shared_ptr<EQ::Net::ReliableStreamConnection> conn, EQ::Net::DbProtocolStatus from, EQ::Net::DbProtocolStatus to);
|
||||
void OnStatusChangeInactive(std::shared_ptr<EQ::Net::ReliableStreamConnection> conn, EQ::Net::DbProtocolStatus from, EQ::Net::DbProtocolStatus to);
|
||||
void OnPacketRecv(std::shared_ptr<EQ::Net::ReliableStreamConnection> conn, const EQ::Net::Packet &p);
|
||||
void Kill();
|
||||
void Start();
|
||||
|
||||
void SendSessionReady();
|
||||
void SendLogin();
|
||||
void SendServerRequest();
|
||||
void SendPlayRequest(uint32_t id);
|
||||
void ProcessLoginResponse(const EQ::Net::Packet &p);
|
||||
void ProcessServerPacketList(const EQ::Net::Packet &p);
|
||||
void ProcessServerPlayResponse(const EQ::Net::Packet &p);
|
||||
|
||||
std::unique_ptr<EQ::Net::ReliableStreamConnectionManager> m_connection_manager;
|
||||
std::shared_ptr<EQ::Net::ReliableStreamConnection> m_connection;
|
||||
bool m_connecting;
|
||||
std::unique_ptr<EQ::Timer> m_connect_timer;
|
||||
|
||||
std::string m_username;
|
||||
std::string m_password;
|
||||
std::string m_host;
|
||||
int m_host_port;
|
||||
std::string m_server;
|
||||
|
||||
std::string m_key;
|
||||
uint32_t m_dbid;
|
||||
std::map<uint32_t, WorldServer> m_world_servers;
|
||||
std::function<void(const WorldServer&, const std::string&, uint32_t)> m_on_can_login_world;
|
||||
};
|
||||
51
hc/main.cpp
51
hc/main.cpp
@ -1,51 +0,0 @@
|
||||
#include "../common/event/event_loop.h"
|
||||
#include "../common/eqemu_logsys.h"
|
||||
#include "../common/crash.h"
|
||||
#include "../common/platform.h"
|
||||
#include "../common/json_config.h"
|
||||
#include <thread>
|
||||
|
||||
#include "eq.h"
|
||||
|
||||
EQEmuLogSys Log;
|
||||
|
||||
int main() {
|
||||
RegisterExecutablePlatform(ExePlatformHC);
|
||||
Log.LoadLogSettingsDefaults();
|
||||
set_exception_handler();
|
||||
|
||||
Log.OutF(Logs::General, Logs::Headless_Client, "Starting EQEmu Headless Client.");
|
||||
|
||||
auto config = EQ::JsonConfigFile::Load("hc.json");
|
||||
auto config_handle = config.RawHandle();
|
||||
|
||||
std::vector<std::unique_ptr<EverQuest>> eq_list;
|
||||
|
||||
try {
|
||||
for (int i = 0; i < config_handle.size(); ++i) {
|
||||
auto c = config_handle[i];
|
||||
|
||||
auto host = c["host"].asString();
|
||||
auto port = c["port"].asInt();
|
||||
auto user = c["user"].asString();
|
||||
auto pass = c["pass"].asString();
|
||||
auto server = c["server"].asString();
|
||||
auto character = c["character"].asString();
|
||||
|
||||
Log.OutF(Logs::General, Logs::Headless_Client, "Connecting to {0}:{1} as Account '{2}' to Server '{3}' under Character '{4}'", host, port, user, server, character);
|
||||
|
||||
eq_list.push_back(std::unique_ptr<EverQuest>(new EverQuest(host, port, user, pass, server, character)));
|
||||
}
|
||||
}
|
||||
catch (std::exception &ex) {
|
||||
Log.OutF(Logs::General, Logs::Headless_Client, "Error parsing config file: {0}", ex.what());
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
EQ::EventLoop::Get().Process();
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
78
hc/world.cpp
78
hc/world.cpp
@ -1,78 +0,0 @@
|
||||
#include "world.h"
|
||||
#include "../common/eqemu_logsys.h"
|
||||
|
||||
WorldConnection::WorldConnection(const std::string &key, uint32_t dbid, const std::string &host)
|
||||
{
|
||||
m_connecting = false;
|
||||
m_host = host;
|
||||
m_key = key;
|
||||
m_dbid = dbid;
|
||||
|
||||
m_connection_manager.reset(new EQ::Net::ReliableStreamConnectionManager());
|
||||
m_connection_manager->OnNewConnection(std::bind(&WorldConnection::OnNewConnection, this, std::placeholders::_1));
|
||||
m_connection_manager->OnConnectionStateChange(std::bind(&WorldConnection::OnStatusChangeActive, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
|
||||
m_connection_manager->OnPacketRecv(std::bind(&WorldConnection::OnPacketRecv, this, std::placeholders::_1, std::placeholders::_2));
|
||||
m_connection_manager->Connect(host, 9000);
|
||||
}
|
||||
|
||||
WorldConnection::~WorldConnection() {
|
||||
}
|
||||
|
||||
void WorldConnection::OnNewConnection(std::shared_ptr<EQ::Net::ReliableStreamConnection> connection)
|
||||
{
|
||||
m_connection = connection;
|
||||
Log.OutF(Logs::General, Logs::Headless_Client, "Connecting to world...");
|
||||
}
|
||||
|
||||
void WorldConnection::OnStatusChangeActive(std::shared_ptr<EQ::Net::ReliableStreamConnection> conn, EQ::Net::DbProtocolStatus from, EQ::Net::DbProtocolStatus to)
|
||||
{
|
||||
if (to == EQ::Net::StatusConnected) {
|
||||
Log.OutF(Logs::General, Logs::Headless_Client, "World connected.");
|
||||
SendClientAuth();
|
||||
}
|
||||
|
||||
if (to == EQ::Net::StatusDisconnected) {
|
||||
Log.OutF(Logs::General, Logs::Headless_Client, "World connection lost, reconnecting.");
|
||||
m_connection.reset();
|
||||
m_connection_manager->Connect(m_host, 9000);
|
||||
}
|
||||
}
|
||||
|
||||
void WorldConnection::OnStatusChangeInactive(std::shared_ptr<EQ::Net::ReliableStreamConnection> conn, EQ::Net::DbProtocolStatus from, EQ::Net::DbProtocolStatus to)
|
||||
{
|
||||
if (to == EQ::Net::StatusDisconnected) {
|
||||
m_connection.reset();
|
||||
}
|
||||
}
|
||||
|
||||
void WorldConnection::OnPacketRecv(std::shared_ptr<EQ::Net::ReliableStreamConnection> conn, const EQ::Net::Packet &p)
|
||||
{
|
||||
auto opcode = p.GetUInt16(0);
|
||||
Log.OutF(Logs::General, Logs::Headless_Client, "Packet in:\n{0}", p.ToString());
|
||||
}
|
||||
|
||||
void WorldConnection::Kill()
|
||||
{
|
||||
m_connection_manager->OnConnectionStateChange(std::bind(&WorldConnection::OnStatusChangeInactive, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
|
||||
m_connection->Close();
|
||||
}
|
||||
|
||||
void WorldConnection::Start()
|
||||
{
|
||||
m_connection_manager->OnConnectionStateChange(std::bind(&WorldConnection::OnStatusChangeActive, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
|
||||
m_connection_manager->Connect(m_host, 9000);
|
||||
}
|
||||
|
||||
void WorldConnection::SendClientAuth()
|
||||
{
|
||||
EQ::Net::DynamicPacket p;
|
||||
p.Resize(2 + 464);
|
||||
|
||||
p.PutUInt16(0, 0x7a09U);
|
||||
std::string dbid_str = std::to_string(m_dbid);
|
||||
|
||||
p.PutCString(2, dbid_str.c_str());
|
||||
p.PutCString(2 + dbid_str.length() + 1, m_key.c_str());
|
||||
|
||||
m_connection->QueuePacket(p);
|
||||
}
|
||||
31
hc/world.h
31
hc/world.h
@ -1,31 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "../common/net/reliable_stream_connection.h"
|
||||
#include "../common/event/timer.h"
|
||||
#include <map>
|
||||
|
||||
class WorldConnection
|
||||
{
|
||||
public:
|
||||
WorldConnection(const std::string &key, uint32_t dbid, const std::string &host);
|
||||
~WorldConnection();
|
||||
private:
|
||||
void OnNewConnection(std::shared_ptr<EQ::Net::ReliableStreamConnection> connection);
|
||||
void OnStatusChangeActive(std::shared_ptr<EQ::Net::ReliableStreamConnection> conn, EQ::Net::DbProtocolStatus from, EQ::Net::DbProtocolStatus to);
|
||||
void OnStatusChangeInactive(std::shared_ptr<EQ::Net::ReliableStreamConnection> conn, EQ::Net::DbProtocolStatus from, EQ::Net::DbProtocolStatus to);
|
||||
void OnPacketRecv(std::shared_ptr<EQ::Net::ReliableStreamConnection> conn, const EQ::Net::Packet &p);
|
||||
void Kill();
|
||||
void Start();
|
||||
|
||||
void SendClientAuth();
|
||||
|
||||
std::unique_ptr<EQ::Net::ReliableStreamConnectionManager> m_connection_manager;
|
||||
std::shared_ptr<EQ::Net::ReliableStreamConnection> m_connection;
|
||||
bool m_connecting;
|
||||
std::unique_ptr<EQ::Timer> m_connect_timer;
|
||||
|
||||
std::string m_host;
|
||||
|
||||
std::string m_key;
|
||||
uint32_t m_dbid;
|
||||
};
|
||||
@ -1,7 +1,7 @@
|
||||
IF(EQEMU_BUILD_LUA)
|
||||
ADD_SUBDIRECTORY(luabind)
|
||||
ENDIF(EQEMU_BUILD_LUA)
|
||||
if(EQEMU_BUILD_LUA)
|
||||
add_subdirectory(luabind)
|
||||
endif()
|
||||
|
||||
IF(EQEMU_BUILD_PERL)
|
||||
ADD_SUBDIRECTORY(perlbind)
|
||||
ENDIF(EQEMU_BUILD_PERL)
|
||||
if(EQEMU_BUILD_PERL)
|
||||
add_subdirectory(perlbind)
|
||||
endif()
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 3.12)
|
||||
cmake_minimum_required(VERSION 3.20.0)
|
||||
|
||||
SET(lb_sources
|
||||
set(lb_sources
|
||||
src/class.cpp
|
||||
src/class_info.cpp
|
||||
src/class_registry.cpp
|
||||
@ -20,19 +20,16 @@ SET(lb_sources
|
||||
src/wrapper_base.cpp
|
||||
)
|
||||
|
||||
SET(lb_headers
|
||||
add_library(luabind ${lb_sources})
|
||||
target_include_directories(luabind PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${LUAJIT_INCLUDE_DIR})
|
||||
target_link_libraries(luabind PUBLIC Boost::dynamic_bitset Boost::tuple Boost::foreach ${LUAJIT_LIBRARY})
|
||||
|
||||
)
|
||||
|
||||
ADD_LIBRARY(luabind ${lb_sources} ${lb_headers})
|
||||
|
||||
|
||||
IF(UNIX)
|
||||
if(UNIX)
|
||||
set_source_files_properties(${lb_sources} PROPERTY COMPILE_FLAGS -Wno-deprecated-declarations)
|
||||
ENDIF(UNIX)
|
||||
endif()
|
||||
|
||||
IF(MSVC)
|
||||
if(MSVC)
|
||||
set_source_files_properties(${lb_sources} PROPERTY COMPILE_FLAGS " /W0 " )
|
||||
ENDIF(MSVC)
|
||||
endif()
|
||||
|
||||
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
|
||||
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
|
||||
|
||||
@ -1,11 +1,7 @@
|
||||
cmake_minimum_required(VERSION 3.7)
|
||||
cmake_minimum_required(VERSION 3.20.0)
|
||||
|
||||
project(perlbind LANGUAGES CXX)
|
||||
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib" ".so" ".a")
|
||||
|
||||
find_package(PerlLibs)
|
||||
|
||||
set(PERLBIND_HEADERS
|
||||
include/perlbind/array.h
|
||||
include/perlbind/forward.h
|
||||
|
||||
4
libs/zlibng/.gitattributes
vendored
4
libs/zlibng/.gitattributes
vendored
@ -1,4 +0,0 @@
|
||||
* text=auto
|
||||
*.c text
|
||||
*.h text
|
||||
Makefile text
|
||||
39
libs/zlibng/.github/workflows/analyze.yml
vendored
39
libs/zlibng/.github/workflows/analyze.yml
vendored
@ -1,39 +0,0 @@
|
||||
name: CI Static Analysis
|
||||
on: [push, pull_request]
|
||||
jobs:
|
||||
GCC-10:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Install packages (Ubuntu)
|
||||
run: |
|
||||
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y gcc-10
|
||||
- name: Generate project files
|
||||
run: |
|
||||
cmake . -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DWITH_FUZZERS=OFF -DWITH_CODE_COVERAGE=OFF -DWITH_MAINTAINER_WARNINGS=OFF
|
||||
env:
|
||||
CC: gcc-10
|
||||
CFLAGS: "-fanalyzer -Werror -Wanalyzer-double-fclose -Wanalyzer-double-free -Wanalyzer-exposure-through-output-file -Wanalyzer-file-leak -Wanalyzer-free-of-non-heap -Wanalyzer-malloc-leak -Wanalyzer-null-argument -Wanalyzer-null-dereference -Wanalyzer-possible-null-argument -Wanalyzer-possible-null-dereference -Wanalyzer-stale-setjmp-buffer -Wanalyzer-tainted-array-index -Wanalyzer-unsafe-call-within-signal-handler -Wanalyzer-use-after-free -Wanalyzer-use-of-pointer-in-stale-stack-frame"
|
||||
CI: true
|
||||
- name: Compile source code
|
||||
run: |
|
||||
cmake --build . --config Release > /dev/null
|
||||
Clang-12:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Install packages (Ubuntu)
|
||||
run: |
|
||||
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add -
|
||||
sudo apt-add-repository "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic main" -y
|
||||
sudo apt install clang-tools-12 -y
|
||||
- name: Generate project files
|
||||
run: |
|
||||
scan-build-12 --status-bugs cmake . -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DWITH_FUZZERS=OFF -DWITH_CODE_COVERAGE=OFF -DWITH_MAINTAINER_WARNINGS=OFF
|
||||
env:
|
||||
CI: true
|
||||
- name: Compile source code
|
||||
run: |
|
||||
scan-build-12 --status-bugs cmake --build . --config Release > /dev/null
|
||||
381
libs/zlibng/.github/workflows/cmake.yml
vendored
381
libs/zlibng/.github/workflows/cmake.yml
vendored
@ -1,381 +0,0 @@
|
||||
name: CI CMake
|
||||
on: [push, pull_request]
|
||||
jobs:
|
||||
ci-cmake:
|
||||
name: ${{ matrix.name }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- name: Ubuntu GCC
|
||||
os: ubuntu-latest
|
||||
compiler: gcc
|
||||
cmake-args: -DWITH_SANITIZER=Address
|
||||
codecov: ubuntu_gcc
|
||||
|
||||
- name: Ubuntu GCC OSB -O1 No Unaligned64
|
||||
os: ubuntu-latest
|
||||
compiler: gcc
|
||||
cmake-args: -DWITH_UNALIGNED=ON -DUNALIGNED64_OK=OFF -DWITH_SANITIZER=Undefined
|
||||
build-dir: ../build
|
||||
build-src-dir: ../zlib-ng
|
||||
codecov: ubuntu_gcc_osb
|
||||
cflags: -O1 -g3
|
||||
|
||||
- name: Ubuntu GCC -O3 No Unaligned
|
||||
os: ubuntu-latest
|
||||
compiler: gcc
|
||||
cmake-args: -DWITH_UNALIGNED=OFF
|
||||
codecov: ubuntu_gcc_o3
|
||||
cflags: -O3
|
||||
|
||||
- name: Ubuntu GCC Link Zlib
|
||||
os: ubuntu-latest
|
||||
compiler: gcc
|
||||
cmake-args: -DZLIB_DUAL_LINK=ON
|
||||
|
||||
- name: Ubuntu GCC No AVX2
|
||||
os: ubuntu-latest
|
||||
compiler: gcc
|
||||
cmake-args: -DWITH_AVX2=OFF -DWITH_SANITIZER=Undefined
|
||||
codecov: ubuntu_gcc_no_avx2
|
||||
|
||||
- name: Ubuntu GCC No SSE2
|
||||
os: ubuntu-latest
|
||||
compiler: gcc
|
||||
cmake-args: -DWITH_SSE2=OFF -DWITH_SANITIZER=Undefined
|
||||
codecov: ubuntu_gcc_no_sse2
|
||||
|
||||
- name: Ubuntu GCC No SSE4
|
||||
os: ubuntu-latest
|
||||
compiler: gcc
|
||||
cmake-args: -DWITH_SSE4=OFF -DWITH_SANITIZER=Undefined
|
||||
codecov: ubuntu_gcc_no_sse4
|
||||
|
||||
- name: Ubuntu GCC No PCLMULQDQ
|
||||
os: ubuntu-latest
|
||||
compiler: gcc
|
||||
cmake-args: -DWITH_PCLMULQDQ=OFF -DWITH_SANITIZER=Undefined
|
||||
codecov: ubuntu_gcc_no_pclmulqdq
|
||||
|
||||
- name: Ubuntu GCC Compat No Opt
|
||||
os: ubuntu-latest
|
||||
compiler: gcc
|
||||
cmake-args: -DZLIB_COMPAT=ON -DWITH_NEW_STRATEGIES=OFF -DWITH_OPTIM=OFF -DWITH_SANITIZER=Address
|
||||
codecov: ubuntu_gcc_compat_no_opt
|
||||
cflags: -DNOT_TWEAK_COMPILER
|
||||
|
||||
- name: Ubuntu GCC ARM SF
|
||||
os: ubuntu-latest
|
||||
compiler: arm-linux-gnueabi-gcc
|
||||
cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-arm.cmake -DCMAKE_C_COMPILER_TARGET=arm-linux-gnueabi -DWITH_SANITIZER=Address
|
||||
packages: qemu gcc-arm-linux-gnueabi libc-dev-armel-cross
|
||||
codecov: ubuntu_gcc_armsf
|
||||
|
||||
- name: Ubuntu GCC ARM SF Compat No Opt
|
||||
os: ubuntu-latest
|
||||
compiler: arm-linux-gnueabi-gcc
|
||||
cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-arm.cmake -DCMAKE_C_COMPILER_TARGET=arm-linux-gnueabi -DZLIB_COMPAT=ON -DWITH_NEW_STRATEGIES=OFF -DWITH_OPTIM=OFF -DWITH_SANITIZER=Undefined
|
||||
packages: qemu gcc-arm-linux-gnueabi libc-dev-armel-cross
|
||||
codecov: ubuntu_gcc_armsf_compat_no_opt
|
||||
|
||||
- name: Ubuntu GCC ARM HF
|
||||
os: ubuntu-latest
|
||||
compiler: arm-linux-gnueabihf-gcc
|
||||
cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-arm.cmake -DCMAKE_C_COMPILER_TARGET=arm-linux-gnueabihf -DWITH_SANITIZER=Address
|
||||
packages: qemu gcc-arm-linux-gnueabihf libc-dev-armel-cross
|
||||
codecov: ubuntu_gcc_armhf
|
||||
|
||||
- name: Ubuntu GCC ARM HF No ACLE
|
||||
os: ubuntu-latest
|
||||
compiler: arm-linux-gnueabihf-gcc
|
||||
cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-arm.cmake -DCMAKE_C_COMPILER_TARGET=arm-linux-gnueabihf -DWITH_ACLE=OFF -DWITH_SANITIZER=Address
|
||||
packages: qemu gcc-arm-linux-gnueabihf libc-dev-armel-cross
|
||||
codecov: ubuntu_gcc_armhf_no_acle
|
||||
|
||||
- name: Ubuntu GCC ARM HF No NEON
|
||||
os: ubuntu-latest
|
||||
compiler: arm-linux-gnueabihf-gcc
|
||||
cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-arm.cmake -DCMAKE_C_COMPILER_TARGET=arm-linux-gnueabihf -DWITH_NEON=OFF -DWITH_SANITIZER=Address
|
||||
packages: qemu gcc-arm-linux-gnueabihf libc-dev-armel-cross
|
||||
codecov: ubuntu_gcc_armhf_no_neon
|
||||
|
||||
- name: Ubuntu GCC ARM HF Compat No Opt
|
||||
os: ubuntu-latest
|
||||
compiler: arm-linux-gnueabihf-gcc
|
||||
cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-arm.cmake -DCMAKE_C_COMPILER_TARGET=arm-linux-gnueabihf -DZLIB_COMPAT=ON -DWITH_NEW_STRATEGIES=OFF -DWITH_OPTIM=OFF -DWITH_SANITIZER=Undefined
|
||||
packages: qemu gcc-arm-linux-gnueabihf libc-dev-armel-cross
|
||||
codecov: ubuntu_gcc_armhf_compat_no_opt
|
||||
|
||||
- name: Ubuntu GCC AARCH64
|
||||
os: ubuntu-latest
|
||||
compiler: aarch64-linux-gnu-gcc
|
||||
cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-aarch64.cmake -DWITH_SANITIZER=Address
|
||||
asan-options: detect_leaks=0
|
||||
packages: qemu gcc-aarch64-linux-gnu libc-dev-arm64-cross
|
||||
codecov: ubuntu_gcc_aarch64
|
||||
|
||||
- name: Ubuntu GCC AARCH64 No ACLE
|
||||
os: ubuntu-latest
|
||||
compiler: aarch64-linux-gnu-gcc
|
||||
cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-aarch64.cmake -DWITH_ACLE=OFF -DWITH_SANITIZER=Undefined
|
||||
asan-options: detect_leaks=0
|
||||
packages: qemu gcc-aarch64-linux-gnu libc-dev-arm64-cross
|
||||
codecov: ubuntu_gcc_aarch64_no_acle
|
||||
|
||||
- name: Ubuntu GCC AARCH64 No NEON
|
||||
os: ubuntu-latest
|
||||
compiler: aarch64-linux-gnu-gcc
|
||||
cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-aarch64.cmake -DWITH_NEON=OFF -DWITH_SANITIZER=Undefined
|
||||
asan-options: detect_leaks=0
|
||||
packages: qemu gcc-aarch64-linux-gnu libc-dev-arm64-cross
|
||||
codecov: ubuntu_gcc_aarch64_no_neon
|
||||
|
||||
- name: Ubuntu GCC AARCH64 Compat No Opt
|
||||
os: ubuntu-latest
|
||||
compiler: aarch64-linux-gnu-gcc
|
||||
cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-aarch64.cmake -DZLIB_COMPAT=ON -DWITH_NEW_STRATEGIES=OFF -DWITH_OPTIM=OFF -DWITH_SANITIZER=Undefined
|
||||
asan-options: detect_leaks=0
|
||||
packages: qemu gcc-aarch64-linux-gnu libc-dev-arm64-cross
|
||||
codecov: ubuntu_gcc_aarch64_compat_no_opt
|
||||
|
||||
- name: Ubuntu GCC PPC
|
||||
os: ubuntu-latest
|
||||
compiler: powerpc-linux-gnu-gcc
|
||||
cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-powerpc.cmake
|
||||
packages: qemu gcc-powerpc-linux-gnu libc-dev-powerpc-cross
|
||||
ldflags: -static
|
||||
codecov: ubuntu_gcc_ppc
|
||||
|
||||
- name: Ubuntu GCC PPC64
|
||||
os: ubuntu-latest
|
||||
compiler: powerpc64-linux-gnu-gcc
|
||||
cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-powerpc64.cmake
|
||||
packages: qemu gcc-powerpc64-linux-gnu libc-dev-ppc64-cross
|
||||
ldflags: -static
|
||||
codecov: ubuntu_gcc_ppc64
|
||||
|
||||
- name: Ubuntu GCC PPC64LE
|
||||
os: ubuntu-latest
|
||||
compiler: powerpc64le-linux-gnu-gcc
|
||||
cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-powerpc64le.cmake
|
||||
packages: qemu gcc-powerpc64le-linux-gnu libc-dev-ppc64el-cross
|
||||
codecov: ubuntu_gcc_ppc64le
|
||||
|
||||
- name: Ubuntu GCC SPARC64
|
||||
os: ubuntu-latest
|
||||
compiler: sparc64-linux-gnu-gcc
|
||||
cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-sparc64.cmake
|
||||
packages: qemu gcc-sparc64-linux-gnu libc-dev-sparc64-cross
|
||||
ldflags: -static
|
||||
codecov: ubuntu_gcc_sparc64
|
||||
|
||||
- name: Ubuntu GCC S390X
|
||||
os: ubuntu-latest
|
||||
compiler: s390x-linux-gnu-gcc
|
||||
cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-s390x.cmake -DWITH_SANITIZER=Address
|
||||
packages: qemu gcc-s390x-linux-gnu libc-dev-s390x-cross
|
||||
ldflags: -static
|
||||
codecov: ubuntu_gcc_s390x
|
||||
|
||||
- name: Ubuntu GCC S390X DFLTCC
|
||||
os: ubuntu-latest
|
||||
compiler: s390x-linux-gnu-gcc
|
||||
cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-s390x.cmake -DWITH_DFLTCC_DEFLATE=ON -DWITH_DFLTCC_INFLATE=ON -DWITH_SANITIZER=Address
|
||||
packages: qemu gcc-s390x-linux-gnu libc-dev-s390x-cross
|
||||
ldflags: -static
|
||||
codecov: ubuntu_gcc_s390x
|
||||
|
||||
- name: Ubuntu GCC S390X DFLTCC Compat
|
||||
os: ubuntu-latest
|
||||
compiler: s390x-linux-gnu-gcc
|
||||
cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-s390x.cmake -DZLIB_COMPAT=ON -DWITH_DFLTCC_DEFLATE=ON -DWITH_DFLTCC_INFLATE=ON -DWITH_SANITIZER=Undefined
|
||||
packages: qemu gcc-s390x-linux-gnu libc-dev-s390x-cross
|
||||
ldflags: -static
|
||||
codecov: ubuntu_gcc_s390x
|
||||
|
||||
- name: Ubuntu MinGW i686
|
||||
os: ubuntu-latest
|
||||
compiler: i686-w64-mingw32-gcc
|
||||
cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-mingw-i686.cmake
|
||||
packages: wine32 gcc-mingw-w64
|
||||
# Codecov disabled due to gcov locking issue error
|
||||
|
||||
- name: Ubuntu MinGW x86_64
|
||||
os: ubuntu-latest
|
||||
compiler: x86_64-w64-mingw32-gcc
|
||||
cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-mingw-x86_64.cmake
|
||||
packages: wine-stable gcc-mingw-w64
|
||||
codecov: ubuntu_gcc_mingw_x86_64
|
||||
|
||||
- name: Ubuntu Clang
|
||||
os: ubuntu-latest
|
||||
compiler: clang
|
||||
packages: llvm-6.0
|
||||
gcov-exec: llvm-cov-6.0 gcov
|
||||
codecov: ubuntu_clang
|
||||
|
||||
- name: Ubuntu Clang Inflate Strict
|
||||
os: ubuntu-latest
|
||||
compiler: clang
|
||||
cmake-args: -DWITH_INFLATE_STRICT=ON
|
||||
packages: llvm-6.0
|
||||
gcov-exec: llvm-cov-6.0 gcov
|
||||
codecov: ubuntu_clang_inflate_strict
|
||||
|
||||
- name: Ubuntu Clang Inflate Allow Invalid Dist
|
||||
os: ubuntu-latest
|
||||
compiler: clang
|
||||
cmake-args: -DWITH_INFLATE_ALLOW_INVALID_DIST=ON
|
||||
packages: llvm-6.0
|
||||
gcov-exec: llvm-cov-6.0 gcov
|
||||
codecov: ubuntu_clang_inflate_allow_invalid_dist
|
||||
|
||||
- name: Ubuntu Clang Memory Map
|
||||
os: ubuntu-latest
|
||||
compiler: clang
|
||||
cflags: -DUSE_MMAP
|
||||
packages: llvm-6.0
|
||||
gcov-exec: llvm-cov-6.0 gcov
|
||||
codecov: ubuntu_clang_mmap
|
||||
|
||||
- name: Ubuntu Clang Debug
|
||||
os: ubuntu-latest
|
||||
compiler: clang
|
||||
packages: llvm-6.0
|
||||
gcov-exec: llvm-cov-6.0 gcov
|
||||
codecov: ubuntu_clang_debug
|
||||
build-config: Debug
|
||||
|
||||
- name: Ubuntu Clang MSAN
|
||||
os: ubuntu-latest
|
||||
compiler: clang
|
||||
cmake-args: -GNinja -DWITH_SANITIZER=Memory
|
||||
packages: ninja-build llvm-6.0
|
||||
gcov-exec: llvm-cov-6.0 gcov
|
||||
cflags: -g3 -fno-omit-frame-pointer -fno-optimize-sibling-calls -fsanitize-memory-track-origins
|
||||
codecov: ubuntu_clang_msan
|
||||
|
||||
- name: Windows MSVC Win32
|
||||
os: windows-latest
|
||||
compiler: cl
|
||||
cmake-args: -A Win32
|
||||
|
||||
- name: Windows MSVC Win64
|
||||
os: windows-latest
|
||||
compiler: cl
|
||||
cmake-args: -A x64
|
||||
|
||||
- name: Windows MSVC ARM No Test
|
||||
os: windows-latest
|
||||
compiler: cl
|
||||
cmake-args: -A ARM
|
||||
|
||||
- name: Windows MSVC ARM64 No Test
|
||||
os: windows-latest
|
||||
compiler: cl
|
||||
cmake-args: -A ARM64
|
||||
|
||||
- name: Windows GCC
|
||||
os: windows-latest
|
||||
compiler: gcc
|
||||
cmake-args: -G Ninja
|
||||
codecov: win64_gcc
|
||||
|
||||
- name: Windows GCC Compat No Opt
|
||||
os: windows-latest
|
||||
compiler: gcc
|
||||
cmake-args: -G Ninja -DZLIB_COMPAT=ON -DWITH_NEW_STRATEGIES=OFF -DWITH_OPTIM=OFF
|
||||
codecov: win64_gcc_compat_no_opt
|
||||
|
||||
- name: macOS Clang
|
||||
os: macos-latest
|
||||
compiler: clang
|
||||
cmake-args: -DWITH_SANITIZER=Address
|
||||
codecov: macos_clang
|
||||
|
||||
- name: macOS GCC
|
||||
os: macos-latest
|
||||
compiler: gcc-10
|
||||
cmake-args: -DWITH_SANITIZER=Undefined
|
||||
packages: gcc@10
|
||||
gcov-exec: gcov-10
|
||||
codecov: macos_gcc
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Checkout test corpora
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
repository: nmoinvaz/corpora
|
||||
path: test/data/corpora
|
||||
|
||||
- name: Install packages (Ubuntu)
|
||||
if: runner.os == 'Linux' && matrix.packages
|
||||
run: |
|
||||
sudo dpkg --add-architecture i386 # Required for wine32
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y ${{ matrix.packages }}
|
||||
|
||||
- name: Install packages (Windows)
|
||||
if: runner.os == 'Windows'
|
||||
run: |
|
||||
choco install ninja ${{ matrix.packages }} --no-progress
|
||||
|
||||
- name: Install packages (macOS)
|
||||
if: runner.os == 'macOS'
|
||||
run: |
|
||||
brew install ninja ${{ matrix.packages }}
|
||||
env:
|
||||
HOMEBREW_NO_INSTALL_CLEANUP: 1
|
||||
|
||||
- name: Install codecov.io tools
|
||||
if: matrix.codecov
|
||||
run: |
|
||||
python -u -m pip install codecov
|
||||
|
||||
- name: Generate project files
|
||||
# Shared libaries turned off for qemu ppc* and sparc & reduce code coverage sources
|
||||
run: |
|
||||
mkdir ${{ matrix.build-dir || '.not-used' }}
|
||||
cd ${{ matrix.build-dir || '.' }}
|
||||
cmake ${{ matrix.build-src-dir || '.' }} ${{ matrix.cmake-args }} -DCMAKE_BUILD_TYPE=${{ matrix.build-config || 'Release' }} -DBUILD_SHARED_LIBS=OFF -DWITH_FUZZERS=ON -DWITH_CODE_COVERAGE=ON -DWITH_MAINTAINER_WARNINGS=ON
|
||||
env:
|
||||
CC: ${{ matrix.compiler }}
|
||||
CFLAGS: ${{ matrix.cflags }}
|
||||
LDFLAGS: ${{ matrix.ldflags }}
|
||||
CI: true
|
||||
|
||||
- name: Compile source code
|
||||
run: |
|
||||
cd ${{ matrix.build-dir || '.' }}
|
||||
cmake --build . --config ${{ matrix.build-config || 'Release' }}
|
||||
|
||||
- name: Run test cases
|
||||
# Don't run tests on Windows ARM
|
||||
if: runner.os != 'Windows' || contains(matrix.name, 'ARM') == false
|
||||
run: |
|
||||
cd ${{ matrix.build-dir || '.' }}
|
||||
ctest --verbose -C Release --output-on-failure --max-width 120 -j 6
|
||||
env:
|
||||
ASAN_OPTIONS: ${{ matrix.asan-options || 'verbosity=0' }}:abort_on_error=1
|
||||
MSAN_OPTIONS: ${{ matrix.msan-options || 'verbosity=0' }}:abort_on_error=1
|
||||
TSAN_OPTIONS: ${{ matrix.tsan-options || 'verbosity=0' }}:abort_on_error=1
|
||||
LSAN_OPTIONS: ${{ matrix.lsan-options || 'verbosity=0' }}:abort_on_error=1
|
||||
|
||||
- name: Upload coverage report
|
||||
if: matrix.codecov && ( env.CODECOV_TOKEN_SECRET != '' || github.repository == 'zlib-ng/zlib-ng' )
|
||||
shell: bash
|
||||
run: |
|
||||
bash tools/codecov-upload.sh
|
||||
env:
|
||||
# Codecov does not yet support GitHub Actions
|
||||
CODECOV_TOKEN_SECRET: "${{secrets.CODECOV_TOKEN}}"
|
||||
CODECOV_TOKEN: "${{ secrets.CODECOV_TOKEN || 'e4fdf847-f541-4ab1-9d50-3d27e5913906' }}"
|
||||
CODECOV_FLAGS: "${{ matrix.codecov }}"
|
||||
CODECOV_NAME: "${{ matrix.name }}"
|
||||
CODECOV_EXEC: "${{ matrix.gcov-exec || 'gcov' }}"
|
||||
CODECOV_DIR: "${{ matrix.build-dir || '.' }}"
|
||||
185
libs/zlibng/.github/workflows/configure.yml
vendored
185
libs/zlibng/.github/workflows/configure.yml
vendored
@ -1,185 +0,0 @@
|
||||
name: CI Configure
|
||||
on: [push, pull_request]
|
||||
jobs:
|
||||
ci-configure:
|
||||
name: ${{ matrix.name }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- name: Ubuntu GCC
|
||||
os: ubuntu-latest
|
||||
compiler: gcc
|
||||
configure-args: --warn
|
||||
|
||||
- name: Ubuntu GCC OSB
|
||||
os: ubuntu-latest
|
||||
compiler: gcc
|
||||
configure-args: --warn
|
||||
build-dir: ../build
|
||||
build-src-dir: ../zlib-ng
|
||||
|
||||
- name: Ubuntu GCC Compat No Opt
|
||||
os: ubuntu-latest
|
||||
compiler: gcc
|
||||
configure-args: --warn --zlib-compat --without-optimizations --without-new-strategies
|
||||
|
||||
- name: Ubuntu GCC ARM SF
|
||||
os: ubuntu-latest
|
||||
compiler: arm-linux-gnueabi-gcc
|
||||
configure-args: --warn
|
||||
chost: arm-linux-gnueabi
|
||||
packages: qemu gcc-arm-linux-gnueabi libc-dev-armel-cross
|
||||
|
||||
- name: Ubuntu GCC ARM SF Compat No Opt
|
||||
os: ubuntu-latest
|
||||
compiler: arm-linux-gnueabi-gcc
|
||||
configure-args: --warn --zlib-compat --without-optimizations --without-new-strategies
|
||||
chost: arm-linux-gnueabi
|
||||
packages: qemu gcc-arm-linux-gnueabi libc-dev-armel-cross
|
||||
|
||||
- name: Ubuntu GCC ARM HF
|
||||
os: ubuntu-latest
|
||||
compiler: arm-linux-gnueabihf-gcc
|
||||
configure-args: --warn
|
||||
chost: arm-linux-gnueabihf
|
||||
packages: qemu gcc-arm-linux-gnueabihf libc-dev-armel-cross
|
||||
|
||||
- name: Ubuntu GCC ARM HF No ACLE
|
||||
os: ubuntu-latest
|
||||
compiler: arm-linux-gnueabihf-gcc
|
||||
configure-args: --warn --without-acle
|
||||
chost: arm-linux-gnueabihf
|
||||
packages: qemu gcc-arm-linux-gnueabihf libc-dev-armel-cross
|
||||
|
||||
- name: Ubuntu GCC ARM HF No NEON
|
||||
os: ubuntu-latest
|
||||
compiler: arm-linux-gnueabihf-gcc
|
||||
configure-args: --warn --without-neon
|
||||
chost: arm-linux-gnueabihf
|
||||
packages: qemu gcc-arm-linux-gnueabihf libc-dev-armel-cross
|
||||
|
||||
- name: Ubuntu GCC ARM HF Compat No Opt
|
||||
os: ubuntu-latest
|
||||
compiler: arm-linux-gnueabihf-gcc
|
||||
configure-args: --warn --zlib-compat --without-optimizations --without-new-strategies
|
||||
chost: arm-linux-gnueabihf
|
||||
packages: qemu gcc-arm-linux-gnueabihf libc-dev-armel-cross
|
||||
|
||||
- name: Ubuntu GCC AARCH64
|
||||
os: ubuntu-latest
|
||||
compiler: aarch64-linux-gnu-gcc
|
||||
configure-args: --warn
|
||||
chost: aarch64-linux-gnu
|
||||
packages: qemu gcc-aarch64-linux-gnu libc-dev-arm64-cross
|
||||
|
||||
- name: Ubuntu GCC AARCH64 No ACLE
|
||||
os: ubuntu-latest
|
||||
compiler: aarch64-linux-gnu-gcc
|
||||
configure-args: --warn --without-acle
|
||||
chost: aarch64-linux-gnu
|
||||
packages: qemu gcc-aarch64-linux-gnu libc-dev-arm64-cross
|
||||
|
||||
- name: Ubuntu GCC AARCH64 No NEON
|
||||
os: ubuntu-latest
|
||||
compiler: aarch64-linux-gnu-gcc
|
||||
configure-args: --warn --without-neon
|
||||
chost: aarch64-linux-gnu
|
||||
packages: qemu gcc-aarch64-linux-gnu libc-dev-arm64-cross
|
||||
|
||||
- name: Ubuntu GCC AARCH64 Compat No Opt
|
||||
os: ubuntu-latest
|
||||
compiler: aarch64-linux-gnu-gcc
|
||||
configure-args: --warn --zlib-compat --without-optimizations --without-new-strategies
|
||||
chost: aarch64-linux-gnu
|
||||
packages: qemu gcc-aarch64-linux-gnu libc-dev-arm64-cross
|
||||
|
||||
- name: Ubuntu GCC PPC
|
||||
os: ubuntu-latest
|
||||
compiler: powerpc-linux-gnu-gcc
|
||||
configure-args: --warn --static
|
||||
chost: powerpc-linux-gnu
|
||||
packages: qemu gcc-powerpc-linux-gnu libc-dev-powerpc-cross
|
||||
cflags: -static
|
||||
ldflags: -static
|
||||
|
||||
- name: Ubuntu GCC PPC64
|
||||
os: ubuntu-latest
|
||||
compiler: powerpc64-linux-gnu-gcc
|
||||
configure-args: --warn --static
|
||||
chost: powerpc-linux-gnu
|
||||
packages: qemu gcc-powerpc64-linux-gnu libc-dev-ppc64-cross
|
||||
cflags: -static
|
||||
ldflags: -static
|
||||
|
||||
- name: Ubuntu GCC PPC64LE
|
||||
os: ubuntu-latest
|
||||
compiler: powerpc64le-linux-gnu-gcc
|
||||
configure-args: --warn
|
||||
chost: powerpc64le-linux-gnu
|
||||
packages: qemu gcc-powerpc64le-linux-gnu libc-dev-ppc64el-cross
|
||||
|
||||
- name: Ubuntu GCC S390X
|
||||
os: ubuntu-latest
|
||||
compiler: s390x-linux-gnu-gcc
|
||||
configure-args: --warn --static
|
||||
chost: s390x-linux-gnu
|
||||
packages: qemu gcc-s390x-linux-gnu libc-dev-s390x-cross
|
||||
cflags: -static
|
||||
ldflags: -static
|
||||
|
||||
- name: Ubuntu GCC S390X DFLTCC
|
||||
os: ubuntu-latest
|
||||
compiler: s390x-linux-gnu-gcc
|
||||
configure-args: --warn --static --with-dfltcc-deflate --with-dfltcc-inflate
|
||||
chost: s390x-linux-gnu
|
||||
packages: qemu gcc-s390x-linux-gnu libc-dev-s390x-cross
|
||||
cflags: -static
|
||||
ldflags: -static
|
||||
|
||||
- name: Ubuntu GCC S390X DFLTCC Compat
|
||||
os: ubuntu-latest
|
||||
compiler: s390x-linux-gnu-gcc
|
||||
configure-args: --warn --zlib-compat --static --with-dfltcc-deflate --with-dfltcc-inflate
|
||||
chost: s390x-linux-gnu
|
||||
packages: qemu gcc-s390x-linux-gnu libc-dev-s390x-cross
|
||||
cflags: -static
|
||||
ldflags: -static
|
||||
|
||||
- name: macOS GCC
|
||||
os: macOS-latest
|
||||
compiler: gcc
|
||||
configure-args: --warn
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v1
|
||||
|
||||
- name: Install packages (Ubuntu)
|
||||
if: runner.os == 'Linux' && matrix.packages
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y ${{ matrix.packages }}
|
||||
|
||||
- name: Generate project files
|
||||
run: |
|
||||
mkdir ${{ matrix.build-dir || '.not-used' }}
|
||||
cd ${{ matrix.build-dir || '.' }}
|
||||
${{ matrix.build-src-dir || '.' }}/configure ${{ matrix.configure-args }}
|
||||
env:
|
||||
CC: ${{ matrix.compiler }}
|
||||
CFLAGS: ${{ matrix.cflags }}
|
||||
LDFLAGS: ${{ matrix.ldflags }}
|
||||
CHOST: ${{ matrix.chost }}
|
||||
CI: true
|
||||
|
||||
- name: Compile source code
|
||||
run: |
|
||||
cd ${{ matrix.build-dir || '.' }}
|
||||
make -j2
|
||||
|
||||
- name: Run test cases
|
||||
run: |
|
||||
cd ${{ matrix.build-dir || '.' }}
|
||||
make test
|
||||
23
libs/zlibng/.github/workflows/fuzz.yml
vendored
23
libs/zlibng/.github/workflows/fuzz.yml
vendored
@ -1,23 +0,0 @@
|
||||
name: CI Fuzz
|
||||
on: [pull_request]
|
||||
jobs:
|
||||
Fuzzing:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Build Fuzzers
|
||||
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
|
||||
with:
|
||||
oss-fuzz-project-name: 'zlib-ng'
|
||||
dry-run: false
|
||||
- name: Run Fuzzers
|
||||
uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
|
||||
with:
|
||||
oss-fuzz-project-name: 'zlib-ng'
|
||||
fuzz-seconds: 600
|
||||
dry-run: false
|
||||
- name: Upload Crash
|
||||
uses: actions/upload-artifact@v1
|
||||
if: failure()
|
||||
with:
|
||||
name: artifacts
|
||||
path: ./out/artifacts
|
||||
46
libs/zlibng/.github/workflows/libpng.yml
vendored
46
libs/zlibng/.github/workflows/libpng.yml
vendored
@ -1,46 +0,0 @@
|
||||
name: CI Libpng
|
||||
on: [pull_request]
|
||||
jobs:
|
||||
pngtest:
|
||||
name: Ubuntu Clang
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout repository (zlib-ng)
|
||||
uses: actions/checkout@v1
|
||||
|
||||
- name: Generate project files (zlib-ng)
|
||||
run: |
|
||||
cmake . -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DZLIB_COMPAT=ON -DZLIB_ENABLE_TESTS=OFF
|
||||
env:
|
||||
CC: clang
|
||||
CFLAGS: -fPIC
|
||||
CI: true
|
||||
|
||||
- name: Compile source code (zlib-ng)
|
||||
run: |
|
||||
cmake --build . --config Release
|
||||
|
||||
- name: Checkout repository (libpng)
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
repository: glennrp/libpng
|
||||
path: libpng
|
||||
|
||||
- name: Generate project files (libpng)
|
||||
run: |
|
||||
cd libpng
|
||||
cmake . -DCMAKE_BUILD_TYPE=Release -DPNG_TESTS=ON -DPNG_STATIC=OFF -DZLIB_INCLUDE_DIR=.. -DZLIB_LIBRARY=$PWD/../libz.a
|
||||
env:
|
||||
CC: clang
|
||||
CI: true
|
||||
|
||||
- name: Compile source code (libpng)
|
||||
run: |
|
||||
cd libpng
|
||||
cmake --build . --config Release
|
||||
|
||||
- name: Run test cases (libpng)
|
||||
run: |
|
||||
cd libpng
|
||||
ctest -C Release --output-on-failure --max-width 120
|
||||
48
libs/zlibng/.github/workflows/nmake.yml
vendored
48
libs/zlibng/.github/workflows/nmake.yml
vendored
@ -1,48 +0,0 @@
|
||||
name: CI NMake
|
||||
on: [push, pull_request]
|
||||
jobs:
|
||||
ci-cmake:
|
||||
name: ${{ matrix.name }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- name: Windows NMake x86
|
||||
os: windows-latest
|
||||
makefile: win32/Makefile.msc
|
||||
vc-vars: x86
|
||||
|
||||
- name: Windows NMake x64
|
||||
os: windows-latest
|
||||
makefile: win32/Makefile.msc
|
||||
vc-vars: x86_amd64
|
||||
|
||||
- name: Windows NMake ARM No Test
|
||||
os: windows-latest
|
||||
makefile: win32/Makefile.arm
|
||||
vc-vars: x86_arm
|
||||
|
||||
- name: Windows NMake ARM64 No Test
|
||||
os: windows-latest
|
||||
makefile: win32/Makefile.a64
|
||||
vc-vars: x86_arm64
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v1
|
||||
|
||||
- name: Compile source code
|
||||
shell: cmd
|
||||
run: |
|
||||
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" ${{ matrix.vc-vars }}
|
||||
nmake -f ${{ matrix.makefile }}
|
||||
|
||||
- name: Run test cases
|
||||
shell: cmd
|
||||
# Don't run tests on Windows ARM
|
||||
if: contains(matrix.vc-vars, 'arm') == false
|
||||
run: |
|
||||
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" ${{ matrix.vc-vars }}
|
||||
nmake -f ${{ matrix.makefile }} test
|
||||
nmake -f ${{ matrix.makefile }} testdll
|
||||
121
libs/zlibng/.github/workflows/pkgcheck.yml
vendored
121
libs/zlibng/.github/workflows/pkgcheck.yml
vendored
@ -1,121 +0,0 @@
|
||||
name: CI Pkgcheck
|
||||
on: [push, pull_request]
|
||||
jobs:
|
||||
ci-pkgcheck:
|
||||
name: ${{ matrix.name }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- name: Ubuntu GCC
|
||||
os: ubuntu-latest
|
||||
compiler: gcc
|
||||
|
||||
- name: Ubuntu GCC -m32
|
||||
os: ubuntu-latest
|
||||
compiler: gcc
|
||||
packages: gcc-multilib
|
||||
cmake-args: -DCMAKE_C_FLAGS=-m32
|
||||
cflags: -m32
|
||||
ldflags: -m32
|
||||
|
||||
- name: Ubuntu GCC ARM HF
|
||||
os: ubuntu-latest
|
||||
chost: arm-linux-gnueabihf
|
||||
compiler: arm-linux-gnueabihf-gcc
|
||||
cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-arm.cmake -DCMAKE_C_COMPILER_TARGET=arm-linux-gnueabihf
|
||||
packages: qemu gcc-arm-linux-gnueabihf libc6-dev-armhf-cross
|
||||
|
||||
- name: Ubuntu GCC AARCH64
|
||||
os: ubuntu-latest
|
||||
chost: aarch64-linux-gnu
|
||||
compiler: aarch64-linux-gnu-gcc
|
||||
cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-aarch64.cmake
|
||||
packages: qemu gcc-aarch64-linux-gnu libc6-dev-arm64-cross
|
||||
|
||||
- name: Ubuntu GCC PPC
|
||||
os: ubuntu-latest
|
||||
chost: powerpc-linux-gnu
|
||||
compiler: powerpc-linux-gnu-gcc
|
||||
cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-powerpc.cmake
|
||||
packages: qemu gcc-powerpc-linux-gnu libc6-dev-powerpc-cross
|
||||
|
||||
- name: Ubuntu GCC PPC64LE
|
||||
os: ubuntu-latest
|
||||
chost: powerpc64le-linux-gnu
|
||||
compiler: powerpc64le-linux-gnu-gcc
|
||||
cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-powerpc64le.cmake
|
||||
packages: qemu gcc-powerpc64le-linux-gnu libc6-dev-ppc64el-cross
|
||||
|
||||
- name: macOS Clang
|
||||
os: macOS-latest
|
||||
compiler: clang
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v1
|
||||
|
||||
- name: Install packages (Ubuntu)
|
||||
if: runner.os == 'Linux'
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y --no-install-recommends abigail-tools ninja-build diffoscope ${{ matrix.packages }}
|
||||
|
||||
- name: Install packages (macOS)
|
||||
if: runner.os == 'macOS'
|
||||
run: |
|
||||
brew install ninja diffoscope ${{ matrix.packages }}
|
||||
env:
|
||||
HOMEBREW_NO_INSTALL_CLEANUP: 1
|
||||
|
||||
- name: Select Xcode version (macOS)
|
||||
# Use a version of Xcode that supports ZERO_AR_DATE until CMake supports
|
||||
# AppleClang linking with libtool using -D argument
|
||||
# https://gitlab.kitware.com/cmake/cmake/-/issues/19852
|
||||
if: runner.os == 'macOS'
|
||||
uses: maxim-lobanov/setup-xcode@v1
|
||||
with:
|
||||
xcode-version: '12.1.1'
|
||||
|
||||
- name: Compare builds
|
||||
run: |
|
||||
sh test/pkgcheck.sh
|
||||
env:
|
||||
CC: ${{ matrix.compiler }}
|
||||
CFLAGS: ${{ matrix.cflags }}
|
||||
CHOST: ${{ matrix.chost }}
|
||||
CMAKE_ARGS: ${{ matrix.cmake-args }}
|
||||
LDFLAGS: ${{ matrix.ldflags }}
|
||||
|
||||
- name: Compare builds (compat)
|
||||
run: |
|
||||
sh test/pkgcheck.sh --zlib-compat
|
||||
env:
|
||||
CC: ${{ matrix.compiler }}
|
||||
CFLAGS: ${{ matrix.cflags }}
|
||||
CHOST: ${{ matrix.chost }}
|
||||
CMAKE_ARGS: ${{ matrix.cmake-args }}
|
||||
LDFLAGS: ${{ matrix.ldflags }}
|
||||
|
||||
- name: Check ABI
|
||||
# macOS runner does not contain abigail
|
||||
if: runner.os != 'macOS'
|
||||
run: |
|
||||
sh test/abicheck.sh --refresh_if
|
||||
env:
|
||||
CC: ${{ matrix.compiler }}
|
||||
CFLAGS: ${{ matrix.cflags }}
|
||||
CHOST: ${{ matrix.chost }}
|
||||
LDFLAGS: ${{ matrix.ldflags }}
|
||||
|
||||
- name: Check ABI (compat)
|
||||
# macOS runner does not contain abigail
|
||||
if: runner.os != 'macOS'
|
||||
run: |
|
||||
sh test/abicheck.sh --zlib-compat --refresh_if
|
||||
env:
|
||||
CC: ${{ matrix.compiler }}
|
||||
CFLAGS: ${{ matrix.cflags }}
|
||||
CHOST: ${{ matrix.chost }}
|
||||
LDFLAGS: ${{ matrix.ldflags }}
|
||||
73
libs/zlibng/.github/workflows/release.yml
vendored
73
libs/zlibng/.github/workflows/release.yml
vendored
@ -1,73 +0,0 @@
|
||||
name: CI Release
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '*'
|
||||
jobs:
|
||||
ci-cmake:
|
||||
name: ${{ matrix.name }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- name: Windows MSVC Win32
|
||||
os: windows-latest
|
||||
compiler: cl
|
||||
cmake-args: -A Win32
|
||||
deploy-name: win32
|
||||
|
||||
- name: Windows MSVC Win32 Compat
|
||||
os: windows-latest
|
||||
compiler: cl
|
||||
cmake-args: -A Win32 -DZLIB_COMPAT=ON
|
||||
deploy-name: win32-compat
|
||||
|
||||
- name: Windows MSVC Win64
|
||||
os: windows-latest
|
||||
compiler: cl
|
||||
cmake-args: -A x64
|
||||
deploy-name: win64
|
||||
|
||||
- name: Windows MSVC Win64 Compat
|
||||
os: windows-latest
|
||||
compiler: cl
|
||||
cmake-args: -A x64 -DZLIB_COMPAT=ON
|
||||
deploy-name: win64-compat
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v1
|
||||
|
||||
- name: Set environment variables
|
||||
shell: bash
|
||||
run: echo "tag=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
|
||||
|
||||
- name: Generate project files
|
||||
run: |
|
||||
cmake . ${{ matrix.cmake-args }} -DCMAKE_BUILD_TYPE=Release -DZLIB_ENABLE_TESTS=ON -DCMAKE_INSTALL_PREFIX=out -DINSTALL_UTILS=ON
|
||||
env:
|
||||
CC: ${{ matrix.compiler }}
|
||||
CI: true
|
||||
|
||||
- name: Compile source code
|
||||
run: |
|
||||
cmake --build . --config Release --target install
|
||||
|
||||
- name: Package release (Windows)
|
||||
if: runner.os == 'Windows'
|
||||
run: |
|
||||
cd out
|
||||
7z a -tzip ../zlib-ng-${{ matrix.deploy-name }}.zip bin include lib ../LICENSE.md ../README.md
|
||||
|
||||
- name: Upload release (Windows)
|
||||
uses: svenstaro/upload-release-action@v1-release
|
||||
if: runner.os == 'Windows'
|
||||
with:
|
||||
asset_name: zlib-ng-${{ matrix.deploy-name }}.zip
|
||||
file: zlib-ng-${{ matrix.deploy-name }}.zip
|
||||
tag: ${{env.tag}}
|
||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
overwrite: true
|
||||
env:
|
||||
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
|
||||
86
libs/zlibng/.gitignore
vendored
86
libs/zlibng/.gitignore
vendored
@ -1,86 +0,0 @@
|
||||
*.diff
|
||||
*.patch
|
||||
*.orig
|
||||
*.rej
|
||||
|
||||
*~
|
||||
*.a
|
||||
*.lo
|
||||
*.o
|
||||
*.dylib
|
||||
|
||||
*.gcda
|
||||
*.gcno
|
||||
*.gcov
|
||||
|
||||
/adler32_test
|
||||
/adler32_testsh
|
||||
/example
|
||||
/example64
|
||||
/examplesh
|
||||
/libz.so*
|
||||
/libz-ng.so*
|
||||
/makefixed
|
||||
/minigzip
|
||||
/minigzip64
|
||||
/minigzipsh
|
||||
/switchlevels
|
||||
/zlib.pc
|
||||
/zlib-ng.pc
|
||||
/CVE-2003-0107
|
||||
|
||||
.DS_Store
|
||||
*_fuzzer
|
||||
*.obj
|
||||
*.exe
|
||||
*.pdb
|
||||
*.exp
|
||||
*.lib
|
||||
*.dll
|
||||
*.res
|
||||
foo.gz
|
||||
*.manifest
|
||||
*.opensdf
|
||||
*.sln
|
||||
*.sdf
|
||||
*.vcxproj
|
||||
*.vcxproj.filters
|
||||
.vs
|
||||
|
||||
CMakeCache.txt
|
||||
CMakeFiles
|
||||
Testing
|
||||
/*.cmake
|
||||
*.stackdump
|
||||
*._h
|
||||
zconf.h
|
||||
zconf.h.cmakein
|
||||
zconf.h.included
|
||||
zconf-ng.h
|
||||
zconf-ng.h.cmakein
|
||||
ztest*
|
||||
|
||||
configure.log
|
||||
a.out
|
||||
|
||||
/Makefile
|
||||
/arch/arm/Makefile
|
||||
/arch/generic/Makefile
|
||||
/arch/power/Makefile
|
||||
/arch/x86/Makefile
|
||||
.kdev4
|
||||
*.kdev4
|
||||
|
||||
/Debug
|
||||
/example.dir
|
||||
/minigzip.dir
|
||||
/zlib.dir
|
||||
/zlibstatic.dir
|
||||
/win32/Debug
|
||||
/build/
|
||||
/build[.-]*/
|
||||
/btmp[12]/
|
||||
/pkgtmp[12]/
|
||||
|
||||
/.idea
|
||||
/cmake-build-debug
|
||||
@ -1 +0,0 @@
|
||||
disable=SC2140,SC2086,SC2046,SC2015,SC1097,SC1035,SC1036,SC1007,SC2154,SC2155,SC2000,SC2034,SC2016,SC1091,SC1090,SC2212,SC2143,SC2129,SC2102,SC2069,SC1041,SC1042,SC1044,SC1046,SC1119,SC1110,SC1111,SC1112,SC1102,SC1105,SC1101,SC1004,SC1003,SC1012,SC2068,SC2065,SC2064,SC2063,SC2059,SC2053,SC2048,SC2044,SC2032,SC2031,SC2030,SC2029,SC2025,SC2024,SC2022,SC2018,SC2019,SC2017,SC2014,SC2013,SC2012,SC2009,SC2001,SC2098,SC2096,SC2094,SC2091,SC2092,SC2088,SC2087,SC2076,SC2072,SC2071,SC2223,SC2221,SC2222,SC2217,SC2207,SC2206,SC2205,SC2190,SC2188,SC2187,SC2185,SC2179,SC2178,SC2174,SC2168,SC2167,SC2163,SC2161,SC2160,SC2153,SC2150,SC2148,SC2147,SC2146,SC2142,SC2139,SC2126,SC2123,SC2120,SC2119,SC2117,SC2114,SC1117,SC2164,SC1083,SC2004,SC2125,SC2128,SC2011,SC1008,SC1019,SC2093,SC1132,SC1129,SC2236,SC2237,SC2231,SC2230,SC2229,SC2106,SC2102,SC2243,SC2244,SC2245,SC2247,SC2248,SC2249,SC2250,SC2251,SC2252,SC2181
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,374 +0,0 @@
|
||||
##
|
||||
# THIS IS AN UNMAINTAINED COPY OF THE ORIGINAL FILE DISTRIBUTED WITH ZLIB 1.2.11
|
||||
##
|
||||
|
||||
|
||||
|
||||
|
||||
Frequently Asked Questions about zlib
|
||||
|
||||
|
||||
If your question is not there, please check the zlib home page
|
||||
http://zlib.net/ which may have more recent information.
|
||||
The lastest zlib FAQ is at http://zlib.net/zlib_faq.html
|
||||
|
||||
|
||||
1. Is zlib Y2K-compliant?
|
||||
|
||||
Yes. zlib doesn't handle dates.
|
||||
|
||||
2. Where can I get a Windows DLL version?
|
||||
|
||||
The zlib sources can be compiled without change to produce a DLL. See the
|
||||
file win32/DLL_FAQ.txt in the zlib distribution. Pointers to the
|
||||
precompiled DLL are found in the zlib web site at http://zlib.net/ .
|
||||
|
||||
3. Where can I get a Visual Basic interface to zlib?
|
||||
|
||||
See
|
||||
* http://marknelson.us/1997/01/01/zlib-engine/
|
||||
* win32/DLL_FAQ.txt in the zlib distribution
|
||||
|
||||
4. compress() returns Z_BUF_ERROR.
|
||||
|
||||
Make sure that before the call of compress(), the length of the compressed
|
||||
buffer is equal to the available size of the compressed buffer and not
|
||||
zero. For Visual Basic, check that this parameter is passed by reference
|
||||
("as any"), not by value ("as long").
|
||||
|
||||
5. deflate() or inflate() returns Z_BUF_ERROR.
|
||||
|
||||
Before making the call, make sure that avail_in and avail_out are not zero.
|
||||
When setting the parameter flush equal to Z_FINISH, also make sure that
|
||||
avail_out is big enough to allow processing all pending input. Note that a
|
||||
Z_BUF_ERROR is not fatal--another call to deflate() or inflate() can be
|
||||
made with more input or output space. A Z_BUF_ERROR may in fact be
|
||||
unavoidable depending on how the functions are used, since it is not
|
||||
possible to tell whether or not there is more output pending when
|
||||
strm.avail_out returns with zero. See http://zlib.net/zlib_how.html for a
|
||||
heavily annotated example.
|
||||
|
||||
6. Where's the zlib documentation (man pages, etc.)?
|
||||
|
||||
It's in zlib.h . Examples of zlib usage are in the files test/example.c
|
||||
and test/minigzip.c, with more in examples/ .
|
||||
|
||||
7. Why don't you use GNU autoconf or libtool or ...?
|
||||
|
||||
Because we would like to keep zlib as a very small and simple package.
|
||||
zlib is rather portable and doesn't need much configuration.
|
||||
|
||||
8. I found a bug in zlib.
|
||||
|
||||
Most of the time, such problems are due to an incorrect usage of zlib.
|
||||
Please try to reproduce the problem with a small program and send the
|
||||
corresponding source to us at zlib@gzip.org . Do not send multi-megabyte
|
||||
data files without prior agreement.
|
||||
|
||||
9. Why do I get "undefined reference to gzputc"?
|
||||
|
||||
If "make test" produces something like
|
||||
|
||||
example.o(.text+0x154): undefined reference to `gzputc'
|
||||
|
||||
check that you don't have old files libz.* in /usr/lib, /usr/local/lib or
|
||||
/usr/X11R6/lib. Remove any old versions, then do "make install".
|
||||
|
||||
10. I need a Delphi interface to zlib.
|
||||
|
||||
See the contrib/delphi directory in the zlib distribution.
|
||||
|
||||
11. Can zlib handle .zip archives?
|
||||
|
||||
Not by itself, no. See the directory contrib/minizip in the zlib
|
||||
distribution.
|
||||
|
||||
12. Can zlib handle .Z files?
|
||||
|
||||
No, sorry. You have to spawn an uncompress or gunzip subprocess, or adapt
|
||||
the code of uncompress on your own.
|
||||
|
||||
13. How can I make a Unix shared library?
|
||||
|
||||
By default a shared (and a static) library is built for Unix. So:
|
||||
|
||||
make distclean
|
||||
./configure
|
||||
make
|
||||
|
||||
14. How do I install a shared zlib library on Unix?
|
||||
|
||||
After the above, then:
|
||||
|
||||
make install
|
||||
|
||||
However, many flavors of Unix come with a shared zlib already installed.
|
||||
Before going to the trouble of compiling a shared version of zlib and
|
||||
trying to install it, you may want to check if it's already there! If you
|
||||
can #include <zlib.h>, it's there. The -lz option will probably link to
|
||||
it. You can check the version at the top of zlib.h or with the
|
||||
ZLIB_VERSION symbol defined in zlib.h .
|
||||
|
||||
15. I have a question about OttoPDF.
|
||||
|
||||
We are not the authors of OttoPDF. The real author is on the OttoPDF web
|
||||
site: Joel Hainley, jhainley@myndkryme.com.
|
||||
|
||||
16. Can zlib decode Flate data in an Adobe PDF file?
|
||||
|
||||
Yes. See http://www.pdflib.com/ . To modify PDF forms, see
|
||||
http://sourceforge.net/projects/acroformtool/ .
|
||||
|
||||
17. Why am I getting this "register_frame_info not found" error on Solaris?
|
||||
|
||||
After installing zlib 1.1.4 on Solaris 2.6, running applications using zlib
|
||||
generates an error such as:
|
||||
|
||||
ld.so.1: rpm: fatal: relocation error: file /usr/local/lib/libz.so:
|
||||
symbol __register_frame_info: referenced symbol not found
|
||||
|
||||
The symbol __register_frame_info is not part of zlib, it is generated by
|
||||
the C compiler (cc or gcc). You must recompile applications using zlib
|
||||
which have this problem. This problem is specific to Solaris. See
|
||||
http://www.sunfreeware.com for Solaris versions of zlib and applications
|
||||
using zlib.
|
||||
|
||||
18. Why does gzip give an error on a file I make with compress/deflate?
|
||||
|
||||
The compress and deflate functions produce data in the zlib format, which
|
||||
is different and incompatible with the gzip format. The gz* functions in
|
||||
zlib on the other hand use the gzip format. Both the zlib and gzip formats
|
||||
use the same compressed data format internally, but have different headers
|
||||
and trailers around the compressed data.
|
||||
|
||||
19. Ok, so why are there two different formats?
|
||||
|
||||
The gzip format was designed to retain the directory information about a
|
||||
single file, such as the name and last modification date. The zlib format
|
||||
on the other hand was designed for in-memory and communication channel
|
||||
applications, and has a much more compact header and trailer and uses a
|
||||
faster integrity check than gzip.
|
||||
|
||||
20. Well that's nice, but how do I make a gzip file in memory?
|
||||
|
||||
You can request that deflate write the gzip format instead of the zlib
|
||||
format using deflateInit2(). You can also request that inflate decode the
|
||||
gzip format using inflateInit2(). Read zlib.h for more details.
|
||||
|
||||
21. Is zlib thread-safe?
|
||||
|
||||
Yes. However any library routines that zlib uses and any application-
|
||||
provided memory allocation routines must also be thread-safe. zlib's gz*
|
||||
functions use stdio library routines, and most of zlib's functions use the
|
||||
library memory allocation routines by default. zlib's *Init* functions
|
||||
allow for the application to provide custom memory allocation routines.
|
||||
|
||||
Of course, you should only operate on any given zlib or gzip stream from a
|
||||
single thread at a time.
|
||||
|
||||
22. Can I use zlib in my commercial application?
|
||||
|
||||
Yes. Please read the license in zlib.h.
|
||||
|
||||
23. Is zlib under the GNU license?
|
||||
|
||||
No. Please read the license in zlib.h.
|
||||
|
||||
24. The license says that altered source versions must be "plainly marked". So
|
||||
what exactly do I need to do to meet that requirement?
|
||||
|
||||
You need to change the ZLIB_VERSION and ZLIB_VERNUM #defines in zlib.h. In
|
||||
particular, the final version number needs to be changed to "f", and an
|
||||
identification string should be appended to ZLIB_VERSION. Version numbers
|
||||
x.x.x.f are reserved for modifications to zlib by others than the zlib
|
||||
maintainers. For example, if the version of the base zlib you are altering
|
||||
is "1.2.3.4", then in zlib.h you should change ZLIB_VERNUM to 0x123f, and
|
||||
ZLIB_VERSION to something like "1.2.3.f-zachary-mods-v3". You can also
|
||||
update the version strings in deflate.c and inftrees.c.
|
||||
|
||||
For altered source distributions, you should also note the origin and
|
||||
nature of the changes in zlib.h, as well as in ChangeLog and README, along
|
||||
with the dates of the alterations. The origin should include at least your
|
||||
name (or your company's name), and an email address to contact for help or
|
||||
issues with the library.
|
||||
|
||||
Note that distributing a compiled zlib library along with zlib.h and
|
||||
zconf.h is also a source distribution, and so you should change
|
||||
ZLIB_VERSION and ZLIB_VERNUM and note the origin and nature of the changes
|
||||
in zlib.h as you would for a full source distribution.
|
||||
|
||||
25. Will zlib work on a big-endian or little-endian architecture, and can I
|
||||
exchange compressed data between them?
|
||||
|
||||
Yes and yes.
|
||||
|
||||
26. Will zlib work on a 64-bit machine?
|
||||
|
||||
Yes. It has been tested on 64-bit machines, and has no dependence on any
|
||||
data types being limited to 32-bits in length. If you have any
|
||||
difficulties, please provide a complete problem report to zlib@gzip.org
|
||||
|
||||
27. Will zlib decompress data from the PKWare Data Compression Library?
|
||||
|
||||
No. The PKWare DCL uses a completely different compressed data format than
|
||||
does PKZIP and zlib. However, you can look in zlib's contrib/blast
|
||||
directory for a possible solution to your problem.
|
||||
|
||||
28. Can I access data randomly in a compressed stream?
|
||||
|
||||
No, not without some preparation. If when compressing you periodically use
|
||||
Z_FULL_FLUSH, carefully write all the pending data at those points, and
|
||||
keep an index of those locations, then you can start decompression at those
|
||||
points. You have to be careful to not use Z_FULL_FLUSH too often, since it
|
||||
can significantly degrade compression. Alternatively, you can scan a
|
||||
deflate stream once to generate an index, and then use that index for
|
||||
random access. See examples/zran.c .
|
||||
|
||||
29. Does zlib work on MVS, OS/390, CICS, etc.?
|
||||
|
||||
It has in the past, but we have not heard of any recent evidence. There
|
||||
were working ports of zlib 1.1.4 to MVS, but those links no longer work.
|
||||
If you know of recent, successful applications of zlib on these operating
|
||||
systems, please let us know. Thanks.
|
||||
|
||||
30. Is there some simpler, easier to read version of inflate I can look at to
|
||||
understand the deflate format?
|
||||
|
||||
First off, you should read RFC 1951. Second, yes. Look in zlib's
|
||||
contrib/puff directory.
|
||||
|
||||
31. Does zlib infringe on any patents?
|
||||
|
||||
As far as we know, no. In fact, that was originally the whole point behind
|
||||
zlib. Look here for some more information:
|
||||
|
||||
http://www.gzip.org/#faq11
|
||||
|
||||
32. Can zlib work with greater than 4 GB of data?
|
||||
|
||||
Yes. inflate() and deflate() will process any amount of data correctly.
|
||||
Each call of inflate() or deflate() is limited to input and output chunks
|
||||
of the maximum value that can be stored in the compiler's "unsigned int"
|
||||
type, but there is no limit to the number of chunks. Note however that the
|
||||
strm.total_in and strm_total_out counters may be limited to 4 GB. These
|
||||
counters are provided as a convenience and are not used internally by
|
||||
inflate() or deflate(). The application can easily set up its own counters
|
||||
updated after each call of inflate() or deflate() to count beyond 4 GB.
|
||||
compress() and uncompress() may be limited to 4 GB, since they operate in a
|
||||
single call. gzseek() and gztell() may be limited to 4 GB depending on how
|
||||
zlib is compiled. See the zlibCompileFlags() function in zlib.h.
|
||||
|
||||
The word "may" appears several times above since there is a 4 GB limit only
|
||||
if the compiler's "long" type is 32 bits. If the compiler's "long" type is
|
||||
64 bits, then the limit is 16 exabytes.
|
||||
|
||||
33. Does zlib have any security vulnerabilities?
|
||||
|
||||
The only one that we are aware of is potentially in gzprintf(). If zlib is
|
||||
compiled to use sprintf() or vsprintf(), then there is no protection
|
||||
against a buffer overflow of an 8K string space (or other value as set by
|
||||
gzbuffer()), other than the caller of gzprintf() assuring that the output
|
||||
will not exceed 8K. On the other hand, if zlib is compiled to use
|
||||
snprintf() or vsnprintf(), which should normally be the case, then there is
|
||||
no vulnerability. The ./configure script will display warnings if an
|
||||
insecure variation of sprintf() will be used by gzprintf(). Also the
|
||||
zlibCompileFlags() function will return information on what variant of
|
||||
sprintf() is used by gzprintf().
|
||||
|
||||
If you don't have snprintf() or vsnprintf() and would like one, you can
|
||||
find a portable implementation here:
|
||||
|
||||
http://www.ijs.si/software/snprintf/
|
||||
|
||||
Note that you should be using the most recent version of zlib. Versions
|
||||
1.1.3 and before were subject to a double-free vulnerability, and versions
|
||||
1.2.1 and 1.2.2 were subject to an access exception when decompressing
|
||||
invalid compressed data.
|
||||
|
||||
34. Is there a Java version of zlib?
|
||||
|
||||
Probably what you want is to use zlib in Java. zlib is already included
|
||||
as part of the Java SDK in the java.util.zip package. If you really want
|
||||
a version of zlib written in the Java language, look on the zlib home
|
||||
page for links: http://zlib.net/ .
|
||||
|
||||
35. I get this or that compiler or source-code scanner warning when I crank it
|
||||
up to maximally-pedantic. Can't you guys write proper code?
|
||||
|
||||
Many years ago, we gave up attempting to avoid warnings on every compiler
|
||||
in the universe. It just got to be a waste of time, and some compilers
|
||||
were downright silly as well as contradicted each other. So now, we simply
|
||||
make sure that the code always works.
|
||||
|
||||
36. Valgrind (or some similar memory access checker) says that deflate is
|
||||
performing a conditional jump that depends on an uninitialized value.
|
||||
Isn't that a bug?
|
||||
|
||||
No. That is intentional for performance reasons, and the output of deflate
|
||||
is not affected. This only started showing up recently since zlib 1.2.x
|
||||
uses malloc() by default for allocations, whereas earlier versions used
|
||||
calloc(), which zeros out the allocated memory. Even though the code was
|
||||
correct, versions 1.2.4 and later was changed to not stimulate these
|
||||
checkers.
|
||||
|
||||
37. Will zlib read the (insert any ancient or arcane format here) compressed
|
||||
data format?
|
||||
|
||||
Probably not. Look in the comp.compression FAQ for pointers to various
|
||||
formats and associated software.
|
||||
|
||||
38. How can I encrypt/decrypt zip files with zlib?
|
||||
|
||||
zlib doesn't support encryption. The original PKZIP encryption is very
|
||||
weak and can be broken with freely available programs. To get strong
|
||||
encryption, use GnuPG, http://www.gnupg.org/ , which already includes zlib
|
||||
compression. For PKZIP compatible "encryption", look at
|
||||
http://www.info-zip.org/
|
||||
|
||||
39. What's the difference between the "gzip" and "deflate" HTTP 1.1 encodings?
|
||||
|
||||
"gzip" is the gzip format, and "deflate" is the zlib format. They should
|
||||
probably have called the second one "zlib" instead to avoid confusion with
|
||||
the raw deflate compressed data format. While the HTTP 1.1 RFC 2616
|
||||
correctly points to the zlib specification in RFC 1950 for the "deflate"
|
||||
transfer encoding, there have been reports of servers and browsers that
|
||||
incorrectly produce or expect raw deflate data per the deflate
|
||||
specification in RFC 1951, most notably Microsoft. So even though the
|
||||
"deflate" transfer encoding using the zlib format would be the more
|
||||
efficient approach (and in fact exactly what the zlib format was designed
|
||||
for), using the "gzip" transfer encoding is probably more reliable due to
|
||||
an unfortunate choice of name on the part of the HTTP 1.1 authors.
|
||||
|
||||
Bottom line: use the gzip format for HTTP 1.1 encoding.
|
||||
|
||||
40. Does zlib support the new "Deflate64" format introduced by PKWare?
|
||||
|
||||
No. PKWare has apparently decided to keep that format proprietary, since
|
||||
they have not documented it as they have previous compression formats. In
|
||||
any case, the compression improvements are so modest compared to other more
|
||||
modern approaches, that it's not worth the effort to implement.
|
||||
|
||||
41. I'm having a problem with the zip functions in zlib, can you help?
|
||||
|
||||
There are no zip functions in zlib. You are probably using minizip by
|
||||
Giles Vollant, which is found in the contrib directory of zlib. It is not
|
||||
part of zlib. In fact none of the stuff in contrib is part of zlib. The
|
||||
files in there are not supported by the zlib authors. You need to contact
|
||||
the authors of the respective contribution for help.
|
||||
|
||||
42. The match.asm code in contrib is under the GNU General Public License.
|
||||
Since it's part of zlib, doesn't that mean that all of zlib falls under the
|
||||
GNU GPL?
|
||||
|
||||
No. The files in contrib are not part of zlib. They were contributed by
|
||||
other authors and are provided as a convenience to the user within the zlib
|
||||
distribution. Each item in contrib has its own license.
|
||||
|
||||
43. Is zlib subject to export controls? What is its ECCN?
|
||||
|
||||
zlib is not subject to export controls, and so is classified as EAR99.
|
||||
|
||||
44. Can you please sign these lengthy legal documents and fax them back to us
|
||||
so that we can use your software in our product?
|
||||
|
||||
No. Go away. Shoo.
|
||||
@ -1,37 +0,0 @@
|
||||
Contents
|
||||
--------
|
||||
|
||||
| Name | Description |
|
||||
|:-----------------|:---------------------------------------------------------------|
|
||||
| arch/ | Architecture-specific code |
|
||||
| doc/ | Documentation for formats and algorithms |
|
||||
| test/example.c | Zlib usages examples for build testing |
|
||||
| test/minigzip.c | Minimal gzip-like functionality for build testing |
|
||||
| test/infcover.c | Inflate code coverage for build testing |
|
||||
| win32/ | Shared library version resources for Windows |
|
||||
| CMakeLists.txt | Cmake build script |
|
||||
| configure | Bash configure/build script |
|
||||
| adler32.c | Compute the Adler-32 checksum of a data stream |
|
||||
| chunkset.* | Inline functions to copy small data chunks |
|
||||
| compress.c | Compress a memory buffer |
|
||||
| deflate.* | Compress data using the deflate algorithm |
|
||||
| deflate_fast.c | Compress data using the deflate algorithm with fast strategy |
|
||||
| deflate_medium.c | Compress data using the deflate algorithm with medium strategy |
|
||||
| deflate_slow.c | Compress data using the deflate algorithm with slow strategy |
|
||||
| functable.* | Struct containing function pointers to optimized functions |
|
||||
| gzguts.h | Internal definitions for gzip operations |
|
||||
| gzlib.c | Functions common to reading and writing gzip files |
|
||||
| gzread.c | Read gzip files |
|
||||
| gzwrite.c | Write gzip files |
|
||||
| infback.* | Inflate using a callback interface |
|
||||
| inflate.* | Decompress data |
|
||||
| inffast.* | Decompress data with speed optimizations |
|
||||
| inffixed_tbl.h | Table for decoding fixed codes |
|
||||
| inftrees.h | Generate Huffman trees for efficient decoding |
|
||||
| trees.* | Output deflated data using Huffman coding |
|
||||
| uncompr.c | Decompress a memory buffer |
|
||||
| zconf.h.cmakein | zconf.h template for cmake |
|
||||
| zendian.h | BYTE_ORDER for endian tests |
|
||||
| zlib.3 | Man page for zlib |
|
||||
| zlib.map | Linux symbol information |
|
||||
| zlib.pc.in | Pkg-config template |
|
||||
@ -1,19 +0,0 @@
|
||||
(C) 1995-2013 Jean-loup Gailly and Mark Adler
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
@ -1,441 +0,0 @@
|
||||
# Makefile for zlib
|
||||
# Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler
|
||||
# For conditions of distribution and use, see copyright notice in zlib.h
|
||||
|
||||
# To compile and test, type:
|
||||
# ./configure; make test
|
||||
# Normally configure builds both a static and a shared library.
|
||||
# If you want to build just a static library, use: ./configure --static
|
||||
|
||||
# To install /usr/local/lib/libz.* and /usr/local/include/zlib.h, type:
|
||||
# make install
|
||||
# To install in $HOME instead of /usr/local, use:
|
||||
# make install prefix=$HOME
|
||||
|
||||
CC=cc
|
||||
|
||||
CFLAGS=-O
|
||||
#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
|
||||
#CFLAGS=-g -DZLIB_DEBUG
|
||||
#CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
|
||||
# -Wstrict-prototypes -Wmissing-prototypes
|
||||
|
||||
SFLAGS=-O
|
||||
LDFLAGS=-L.
|
||||
LIBNAME1=libz-ng
|
||||
LIBNAME2=zlib-ng
|
||||
SUFFIX=-ng
|
||||
TEST_LIBS=$(LIBNAME1).a
|
||||
LDSHARED=$(CC)
|
||||
LDSHAREDFLAGS=-shared
|
||||
|
||||
VER=2.0.0-RC2
|
||||
VER1=2
|
||||
|
||||
STATICLIB=$(LIBNAME1).a
|
||||
SHAREDLIB=$(LIBNAME1).so
|
||||
SHAREDLIBV=$(LIBNAME1).so.$(VER)
|
||||
SHAREDLIBM=$(LIBNAME1).so.$(VER1)
|
||||
IMPORTLIB=
|
||||
SHAREDTARGET=$(LIBNAME1).so.$(VER)
|
||||
PKGFILE=$(LIBNAME2).pc
|
||||
|
||||
LIBS=$(STATICLIB) $(SHAREDTARGET)
|
||||
|
||||
AR=ar
|
||||
ARFLAGS=rc
|
||||
DEFFILE=
|
||||
RC=
|
||||
RCFLAGS=
|
||||
RCOBJS=
|
||||
STRIP=
|
||||
RANLIB=ranlib
|
||||
LDCONFIG=ldconfig
|
||||
LDSHAREDLIBC=
|
||||
EXE=
|
||||
|
||||
SRCDIR=.
|
||||
INCLUDES=-I$(SRCDIR)
|
||||
|
||||
ARCHDIR=arch/generic
|
||||
ARCH_STATIC_OBJS=
|
||||
ARCH_SHARED_OBJS=
|
||||
|
||||
prefix = /usr/local
|
||||
exec_prefix = ${prefix}
|
||||
bindir = ${exec_prefix}/bin
|
||||
libdir = ${exec_prefix}/lib
|
||||
sharedlibdir = ${libdir}
|
||||
includedir = ${prefix}/include
|
||||
mandir = ${prefix}/share/man
|
||||
man3dir = ${mandir}/man3
|
||||
pkgconfigdir = ${libdir}/pkgconfig
|
||||
|
||||
OBJZ = \
|
||||
adler32.o \
|
||||
chunkset.o \
|
||||
compare258.o \
|
||||
compress.o \
|
||||
crc32.o \
|
||||
crc32_comb.o \
|
||||
deflate.o \
|
||||
deflate_fast.o \
|
||||
deflate_medium.o \
|
||||
deflate_quick.o \
|
||||
deflate_slow.o \
|
||||
functable.o \
|
||||
infback.o \
|
||||
inffast.o \
|
||||
inflate.o \
|
||||
inftrees.o \
|
||||
insert_string.o \
|
||||
trees.o \
|
||||
uncompr.o \
|
||||
zutil.o \
|
||||
$(ARCH_STATIC_OBJS)
|
||||
|
||||
OBJG = \
|
||||
gzlib.o \
|
||||
gzread.o \
|
||||
gzwrite.o
|
||||
|
||||
OBJC = $(OBJZ) $(OBJG)
|
||||
|
||||
PIC_OBJZ = \
|
||||
adler32.lo \
|
||||
chunkset.lo \
|
||||
compare258.lo \
|
||||
compress.lo \
|
||||
crc32.lo \
|
||||
crc32_comb.lo \
|
||||
deflate.lo \
|
||||
deflate_fast.lo \
|
||||
deflate_medium.lo \
|
||||
deflate_quick.lo \
|
||||
deflate_slow.lo \
|
||||
functable.lo \
|
||||
infback.lo \
|
||||
inffast.lo \
|
||||
inflate.lo \
|
||||
inftrees.lo \
|
||||
insert_string.lo \
|
||||
trees.lo \
|
||||
uncompr.lo \
|
||||
zutil.lo \
|
||||
$(ARCH_SHARED_OBJS)
|
||||
|
||||
PIC_OBJG = \
|
||||
gzlib.lo \
|
||||
gzread.lo \
|
||||
gzwrite.lo
|
||||
|
||||
PIC_OBJC = $(PIC_OBJZ) $(PIC_OBJG)
|
||||
|
||||
OBJS = $(OBJC)
|
||||
|
||||
PIC_OBJS = $(PIC_OBJC)
|
||||
|
||||
all: static shared
|
||||
|
||||
static: adler32_test$(EXE) example$(EXE) minigzip$(EXE) fuzzers makefixed$(EXE) maketrees$(EXE) makecrct$(EXE)
|
||||
|
||||
shared: adler32_testsh$(EXE) examplesh$(EXE) minigzipsh$(EXE)
|
||||
|
||||
check: test
|
||||
|
||||
.SECONDARY:
|
||||
|
||||
$(ARCHDIR)/%.o: $(SRCDIR)/$(ARCHDIR)/%.c
|
||||
$(MAKE) -C $(ARCHDIR) $(notdir $@)
|
||||
|
||||
$(ARCHDIR)/%.lo: $(SRCDIR)/$(ARCHDIR)/%.c
|
||||
$(MAKE) -C $(ARCHDIR) $(notdir $@)
|
||||
|
||||
%.o: $(ARCHDIR)/%.o
|
||||
-cp $< $@
|
||||
|
||||
%.lo: $(ARCHDIR)/%.lo
|
||||
-cp $< $@
|
||||
|
||||
test: all
|
||||
$(MAKE) -C test
|
||||
|
||||
# This variable is set by configure.
|
||||
WITH_FUZZERS=
|
||||
|
||||
# By default, use our own standalone_fuzz_target_runner.
|
||||
# This runner does no fuzzing, but simply executes the inputs
|
||||
# provided via parameters.
|
||||
# Run e.g. "make all LIB_FUZZING_ENGINE=/path/to/libFuzzer.a"
|
||||
# to link the fuzzer(s) against a real fuzzing engine.
|
||||
ifeq (,$(LIB_FUZZING_ENGINE))
|
||||
LIB_FUZZING_ENGINE = standalone_fuzz_target_runner.o
|
||||
else
|
||||
# OSS-Fuzz will define its own value for LIB_FUZZING_ENGINE.
|
||||
WITH_FUZZERS=1
|
||||
endif
|
||||
|
||||
ifeq (1,$(WITH_FUZZERS))
|
||||
fuzzers: checksum_fuzzer$(EXE) compress_fuzzer$(EXE) example_small_fuzzer$(EXE) example_large_fuzzer$(EXE) example_flush_fuzzer$(EXE) example_dict_fuzzer$(EXE) minigzip_fuzzer$(EXE)
|
||||
else
|
||||
fuzzers:
|
||||
endif
|
||||
|
||||
# The standalone fuzz target runner.
|
||||
standalone_fuzz_target_runner.o:
|
||||
$(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $<
|
||||
checksum_fuzzer.o:
|
||||
$(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $<
|
||||
compress_fuzzer.o:
|
||||
$(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $<
|
||||
example_small_fuzzer.o:
|
||||
$(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $<
|
||||
example_large_fuzzer.o:
|
||||
$(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $<
|
||||
example_flush_fuzzer.o:
|
||||
$(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $<
|
||||
example_dict_fuzzer.o:
|
||||
$(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $<
|
||||
minigzip_fuzzer.o:
|
||||
$(CC) $(CFLAGS) -DWITH_GZFILEOP $(INCLUDES) -c -o $@ $<
|
||||
checksum_fuzzer$(EXE): checksum_fuzzer.o standalone_fuzz_target_runner.o $(STATICLIB)
|
||||
$(CC) $(LDFLAGS) -o $@ $(LIB_FUZZING_ENGINE) checksum_fuzzer.o $(STATICLIB) -lpthread
|
||||
compress_fuzzer$(EXE): compress_fuzzer.o standalone_fuzz_target_runner.o $(STATICLIB)
|
||||
$(CC) $(LDFLAGS) -o $@ $(LIB_FUZZING_ENGINE) compress_fuzzer.o $(STATICLIB) -lpthread
|
||||
example_small_fuzzer$(EXE): example_small_fuzzer.o standalone_fuzz_target_runner.o $(STATICLIB)
|
||||
$(CC) $(LDFLAGS) -o $@ $(LIB_FUZZING_ENGINE) example_small_fuzzer.o $(STATICLIB) -lpthread
|
||||
example_large_fuzzer$(EXE): example_large_fuzzer.o standalone_fuzz_target_runner.o $(STATICLIB)
|
||||
$(CC) $(LDFLAGS) -o $@ $(LIB_FUZZING_ENGINE) example_large_fuzzer.o $(STATICLIB) -lpthread
|
||||
example_flush_fuzzer$(EXE): example_flush_fuzzer.o standalone_fuzz_target_runner.o $(STATICLIB)
|
||||
$(CC) $(LDFLAGS) -o $@ $(LIB_FUZZING_ENGINE) example_flush_fuzzer.o $(STATICLIB) -lpthread
|
||||
example_dict_fuzzer$(EXE): example_dict_fuzzer.o standalone_fuzz_target_runner.o $(STATICLIB)
|
||||
$(CC) $(LDFLAGS) -o $@ $(LIB_FUZZING_ENGINE) example_dict_fuzzer.o $(STATICLIB) -lpthread
|
||||
minigzip_fuzzer$(EXE): minigzip_fuzzer.o standalone_fuzz_target_runner.o $(OBJG) $(STATICLIB)
|
||||
$(CC) $(LDFLAGS) -o $@ $(LIB_FUZZING_ENGINE) minigzip_fuzzer.o $(OBJG) $(STATICLIB) -lpthread
|
||||
|
||||
infcover.o: $(SRCDIR)/test/infcover.c $(SRCDIR)/zlib$(SUFFIX).h zconf$(SUFFIX).h
|
||||
$(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/test/infcover.c
|
||||
|
||||
infcover$(EXE): infcover.o $(STATICLIB)
|
||||
$(CC) $(LDFLAGS) -o $@ infcover.o $(STATICLIB)
|
||||
ifneq ($(STRIP),)
|
||||
$(STRIP) $@
|
||||
endif
|
||||
|
||||
cover: infcover$(EXE)
|
||||
rm -f *.gcda
|
||||
./infcover
|
||||
gcov inf*.c
|
||||
|
||||
$(STATICLIB): $(OBJS)
|
||||
$(AR) $(ARFLAGS) $@ $(OBJS)
|
||||
-@ ($(RANLIB) $@ || true) >/dev/null 2>&1
|
||||
|
||||
adler32_test.o:
|
||||
$(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/test/adler32_test.c
|
||||
|
||||
example.o:
|
||||
$(CC) $(CFLAGS) -DWITH_GZFILEOP $(INCLUDES) -c -o $@ $(SRCDIR)/test/example.c
|
||||
|
||||
minigzip.o:
|
||||
$(CC) $(CFLAGS) -DWITH_GZFILEOP $(INCLUDES) -c -o $@ $(SRCDIR)/test/minigzip.c
|
||||
|
||||
makefixed.o:
|
||||
$(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/tools/makefixed.c
|
||||
|
||||
maketrees.o:
|
||||
$(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/tools/maketrees.c
|
||||
|
||||
makecrct.o:
|
||||
$(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/tools/makecrct.c
|
||||
|
||||
zlibrc.o: win32/zlib$(SUFFIX)1.rc
|
||||
$(RC) $(RCFLAGS) -o $@ win32/zlib$(SUFFIX)1.rc
|
||||
|
||||
.SUFFIXES: .lo
|
||||
|
||||
%.o: $(SRCDIR)/%.c
|
||||
$(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $<
|
||||
|
||||
%.lo: $(SRCDIR)/%.c
|
||||
$(CC) $(SFLAGS) -DPIC $(INCLUDES) -c -o $@ $<
|
||||
|
||||
$(OBJG): %.o: $(SRCDIR)/%.c
|
||||
$(CC) $(CFLAGS) -DWITH_GZFILEOP $(INCLUDES) -c -o $@ $<
|
||||
|
||||
$(SHAREDTARGET): $(PIC_OBJS) $(DEFFILE) $(RCOBJS)
|
||||
ifneq ($(SHAREDTARGET),)
|
||||
$(LDSHARED) $(CFLAGS) $(LDSHAREDFLAGS) $(LDFLAGS) -o $@ $(DEFFILE) $(PIC_OBJS) $(RCOBJS) $(LDSHAREDLIBC)
|
||||
ifneq ($(STRIP),)
|
||||
$(STRIP) $@
|
||||
endif
|
||||
ifneq ($(SHAREDLIB),$(SHAREDTARGET))
|
||||
rm -f $(SHAREDLIB) $(SHAREDLIBM)
|
||||
ln -s $@ $(SHAREDLIB)
|
||||
ln -s $@ $(SHAREDLIBM)
|
||||
endif
|
||||
endif
|
||||
|
||||
adler32_test$(EXE): adler32_test.o $(OBJG) $(STATICLIB)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ adler32_test.o $(OBJG) $(TEST_LIBS) $(LDSHAREDLIBC)
|
||||
ifneq ($(STRIP),)
|
||||
$(STRIP) $@
|
||||
endif
|
||||
|
||||
example$(EXE): example.o $(OBJG) $(STATICLIB)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ example.o $(OBJG) $(TEST_LIBS) $(LDSHAREDLIBC)
|
||||
ifneq ($(STRIP),)
|
||||
$(STRIP) $@
|
||||
endif
|
||||
|
||||
minigzip$(EXE): minigzip.o $(OBJG) $(STATICLIB)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ minigzip.o $(OBJG) $(TEST_LIBS) $(LDSHAREDLIBC)
|
||||
ifneq ($(STRIP),)
|
||||
$(STRIP) $@
|
||||
endif
|
||||
|
||||
adler32_testsh$(EXE): adler32_test.o $(OBJG) $(SHAREDTARGET)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ adler32_test.o $(OBJG) $(SHAREDTARGET) $(LDSHAREDLIBC)
|
||||
ifneq ($(STRIP),)
|
||||
$(STRIP) $@
|
||||
endif
|
||||
|
||||
examplesh$(EXE): example.o $(OBJG) $(SHAREDTARGET)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ example.o $(OBJG) $(SHAREDTARGET) $(LDSHAREDLIBC)
|
||||
ifneq ($(STRIP),)
|
||||
$(STRIP) $@
|
||||
endif
|
||||
|
||||
minigzipsh$(EXE): minigzip.o $(OBJG) $(SHAREDTARGET)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ minigzip.o $(OBJG) $(SHAREDTARGET) $(LDSHAREDLIBC)
|
||||
ifneq ($(STRIP),)
|
||||
$(STRIP) $@
|
||||
endif
|
||||
|
||||
makefixed$(EXE): makefixed.o $(OBJG) $(STATICLIB)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ makefixed.o $(OBJG) $(TEST_LIBS) $(LDSHAREDLIBC)
|
||||
ifneq ($(STRIP),)
|
||||
$(STRIP) $@
|
||||
endif
|
||||
|
||||
maketrees$(EXE): maketrees.o $(OBJG) $(STATICLIB)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ maketrees.o $(OBJG) $(TEST_LIBS) $(LDSHAREDLIBC)
|
||||
ifneq ($(STRIP),)
|
||||
$(STRIP) $@
|
||||
endif
|
||||
|
||||
makecrct$(EXE): makecrct.o $(OBJG) $(STATICLIB)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ makecrct.o $(OBJG) $(TEST_LIBS) $(LDSHAREDLIBC)
|
||||
ifneq ($(STRIP),)
|
||||
$(STRIP) $@
|
||||
endif
|
||||
|
||||
install-shared: $(SHAREDTARGET)
|
||||
ifneq ($(SHAREDTARGET),)
|
||||
-@if [ ! -d $(DESTDIR)$(sharedlibdir) ]; then mkdir -p $(DESTDIR)$(sharedlibdir); fi
|
||||
rm -f $(DESTDIR)$(sharedlibdir)/$(SHAREDTARGET)
|
||||
cp $(SHAREDTARGET) $(DESTDIR)$(sharedlibdir)
|
||||
chmod 755 $(DESTDIR)$(sharedlibdir)/$(SHAREDTARGET)
|
||||
ifneq ($(SHAREDLIB),$(SHAREDTARGET))
|
||||
rm -f $(DESTDIR)$(sharedlibdir)/$(SHAREDLIB) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBM)
|
||||
ln -s $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIB)
|
||||
ln -s $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBM)
|
||||
($(LDCONFIG) || true) >/dev/null 2>&1
|
||||
# ldconfig is for Linux
|
||||
endif
|
||||
ifneq ($(IMPORTLIB),)
|
||||
cp $(IMPORTLIB) $(DESTDIR)$(sharedlibdir)
|
||||
chmod 644 $(DESTDIR)$(sharedlibdir)/$(IMPORTLIB)
|
||||
endif
|
||||
endif
|
||||
|
||||
install-static: $(STATICLIB)
|
||||
-@if [ ! -d $(DESTDIR)$(libdir) ]; then mkdir -p $(DESTDIR)$(libdir); fi
|
||||
rm -f $(DESTDIR)$(libdir)/$(STATICLIB)
|
||||
cp $(STATICLIB) $(DESTDIR)$(libdir)
|
||||
chmod 644 $(DESTDIR)$(libdir)/$(STATICLIB)
|
||||
-@($(RANLIB) $(DESTDIR)$(libdir)/$(STATICLIB) || true) >/dev/null 2>&1
|
||||
# The ranlib in install-static is needed on NeXTSTEP which checks file times
|
||||
|
||||
install-libs: install-shared install-static
|
||||
-@if [ ! -d $(DESTDIR)$(man3dir) ]; then mkdir -p $(DESTDIR)$(man3dir); fi
|
||||
-@if [ ! -d $(DESTDIR)$(pkgconfigdir) ]; then mkdir -p $(DESTDIR)$(pkgconfigdir); fi
|
||||
rm -f $(DESTDIR)$(man3dir)/zlib$(SUFFIX).3
|
||||
cp $(SRCDIR)/zlib.3 $(DESTDIR)$(man3dir)/zlib$(SUFFIX).3
|
||||
chmod 644 $(DESTDIR)$(man3dir)/zlib$(SUFFIX).3
|
||||
rm -f $(DESTDIR)$(pkgconfigdir)/$(PKGFILE)
|
||||
cp $(PKGFILE) $(DESTDIR)$(pkgconfigdir)
|
||||
chmod 644 $(DESTDIR)$(pkgconfigdir)/$(PKGFILE)
|
||||
|
||||
install: install-libs
|
||||
-@if [ ! -d $(DESTDIR)$(includedir) ]; then mkdir -p $(DESTDIR)$(includedir); fi
|
||||
rm -f $(DESTDIR)$(includedir)/zlib$(SUFFIX).h $(DESTDIR)$(includedir)/zconf$(SUFFIX).h
|
||||
cp $(SRCDIR)/zlib$(SUFFIX).h $(DESTDIR)$(includedir)/zlib$(SUFFIX).h
|
||||
cp zconf$(SUFFIX).h $(DESTDIR)$(includedir)/zconf$(SUFFIX).h
|
||||
chmod 644 $(DESTDIR)$(includedir)/zlib$(SUFFIX).h $(DESTDIR)$(includedir)/zconf$(SUFFIX).h
|
||||
|
||||
uninstall-static:
|
||||
cd $(DESTDIR)$(libdir) && rm -f $(STATICLIB)
|
||||
|
||||
uninstall-shared:
|
||||
ifneq ($(SHAREDLIB),)
|
||||
cd $(DESTDIR)$(sharedlibdir) && rm -f $(SHAREDLIBV) $(SHAREDLIB) $(SHAREDLIBM)
|
||||
endif
|
||||
ifneq ($(IMPORTLIB),)
|
||||
cd $(DESTDIR)$(sharedlibdir) && rm -f $(IMPORTLIB)
|
||||
endif
|
||||
|
||||
uninstall: uninstall-static uninstall-shared
|
||||
cd $(DESTDIR)$(includedir) && rm -f zlib$(SUFFIX).h zconf$(SUFFIX).h
|
||||
cd $(DESTDIR)$(man3dir) && rm -f zlib$(SUFFIX).3
|
||||
cd $(DESTDIR)$(pkgconfigdir) && rm -f $(PKGFILE)
|
||||
|
||||
docs: zlib.3.pdf
|
||||
|
||||
zlib.3.pdf: $(SRCDIR)/zlib.3
|
||||
groff -mandoc -f H -T ps $(SRCDIR)/zlib.3 | ps2pdf - zlib.3.pdf
|
||||
|
||||
mostlyclean: clean
|
||||
clean:
|
||||
@if [ -f $(ARCHDIR)/Makefile ]; then $(MAKE) -C $(ARCHDIR) clean; fi
|
||||
@if [ -f test/Makefile ]; then $(MAKE) -C test clean; fi
|
||||
rm -f *.o *.lo *~ \
|
||||
adler32_test$(EXE) example$(EXE) minigzip$(EXE) \
|
||||
adler32_testsh$(EXE) examplesh$(EXE) minigzipsh$(EXE) \
|
||||
checksum_fuzzer$(EXE) compress_fuzzer$(EXE) example_small_fuzzer$(EXE) example_large_fuzzer$(EXE) \
|
||||
example_flush_fuzzer$(EXE) example_dict_fuzzer$(EXE) minigzip_fuzzer$(EXE) \
|
||||
infcover makefixed$(EXE) maketrees$(EXE) makecrct$(EXE) \
|
||||
$(STATICLIB) $(IMPORTLIB) $(SHAREDLIB) $(SHAREDLIBV) $(SHAREDLIBM) \
|
||||
foo.gz so_locations \
|
||||
_match.s maketree
|
||||
rm -rf objs
|
||||
rm -f *.gcda *.gcno *.gcov
|
||||
rm -f a.out a.exe
|
||||
rm -f *.pc
|
||||
rm -f *._h
|
||||
rm -rf btmp1 btmp2 pkgtmp1 pkgtmp2
|
||||
|
||||
maintainer-clean: distclean
|
||||
distclean: clean
|
||||
@if [ -f $(ARCHDIR)/Makefile ]; then $(MAKE) -C $(ARCHDIR) distclean; fi
|
||||
@if [ -f test/Makefile ]; then $(MAKE) -C test distclean; fi
|
||||
rm -f $(PKGFILE) configure.log zconf.h zconf.h.cmakein
|
||||
-@rm -f .DS_Store
|
||||
# Reset Makefile if building inside source tree
|
||||
@if [ -f Makefile.in ]; then \
|
||||
printf 'all:\n\t-@echo "Please use ./configure first. Thank you."\n' > Makefile ; \
|
||||
printf '\ndistclean:\n\t$(MAKE) -f Makefile.in distclean\n' >> Makefile ; \
|
||||
touch -r $(SRCDIR)/Makefile.in Makefile ; fi
|
||||
# Reset zconf.h and zconf.h.cmakein if building inside source tree
|
||||
@if [ -f zconf.h.in ]; then \
|
||||
cp -p $(SRCDIR)/zconf.h.in zconf.h ; \
|
||||
grep -v '^#cmakedefine' $(SRCDIR)/zconf.h.in > zconf.h.cmakein &&\
|
||||
touch -r $(SRCDIR)/zconf.h.in zconf.h.cmakein ; fi
|
||||
# Cleanup these files if building outside source tree
|
||||
@if [ ! -f zlib.3 ]; then rm -f zlib.3.pdf Makefile; fi
|
||||
# Remove arch and test directory if building outside source tree
|
||||
@if [ ! -f $(ARCHDIR)/Makefile.in ]; then rm -rf arch; fi
|
||||
@if [ ! -f test/Makefile.in ]; then rm -rf test; fi
|
||||
|
||||
tags:
|
||||
etags $(SRCDIR)/*.[ch]
|
||||
@ -1,206 +0,0 @@
|
||||
## zlib-ng
|
||||
*zlib data compression library for the next generation systems*
|
||||
|
||||
Maintained by Hans Kristian Rosbach
|
||||
aka Dead2 (zlib-ng àt circlestorm dót org)
|
||||
|
||||
|CI|Status|
|
||||
|:-|-|
|
||||
|GitHub Actions|[](https://github.com/zlib-ng/zlib-ng/actions) [](https://github.com/zlib-ng/zlib-ng/actions) [](https://github.com/zlib-ng/zlib-ng/actions)|
|
||||
|Buildkite|[](https://buildkite.com/circlestorm-productions/zlib-ng)|
|
||||
|CodeFactor|[](https://www.codefactor.io/repository/github/zlib-ng/zlib-ng)|
|
||||
|OSS-Fuzz|[](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:zlib-ng)
|
||||
|Codecov|[](https://codecov.io/github/zlib-ng/zlib-ng/)|
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Zlib compatible API with support for dual-linking
|
||||
* Modernized native API based on zlib API for ease of porting
|
||||
* Modern C99 syntax and a clean code layout
|
||||
* Deflate medium and quick algorithms based on Intels zlib fork
|
||||
* Support for CPU intrinsics when available
|
||||
* Adler32 implementation using SSSE3, AVX2, Neon & VSX
|
||||
* CRC32-B implementation using PCLMULQDQ & ACLE
|
||||
* Hash table implementation using CRC32-C intrinsics on x86 and ARM
|
||||
* Slide hash implementations using SSE2, AVX2, Neon & VSX
|
||||
* Compare256/258 implementations using SSE4.2 & AVX2
|
||||
* Inflate chunk copying using SSE2, AVX2 & Neon
|
||||
* Support for hardware-accelerated deflate using IBM Z DFLTCC
|
||||
* Unaligned memory read/writes and large bit buffer improvements
|
||||
* Includes improvements from Cloudflare and Intel forks
|
||||
* Configure, CMake, and NMake build system support
|
||||
* Comprehensive set of CMake unit tests
|
||||
* Code sanitizers, fuzzing, and coverage
|
||||
* GitHub Actions continuous integration on Windows, macOS, and Linux
|
||||
* Emulated CI for ARM, AARCH64, PPC, PPC64, SPARC64, S390x using qemu
|
||||
|
||||
Fork Motivation
|
||||
---------------------------
|
||||
|
||||
The motivation for this fork was due to seeing several 3rd party
|
||||
contributions containing new optimizations not getting implemented
|
||||
into the official zlib repository.
|
||||
|
||||
Mark Adler has been maintaining zlib for a very long time, and he has
|
||||
done a great job and hopefully he will continue for a long time yet.
|
||||
The idea of zlib-ng is not to replace zlib, but to co-exist as a
|
||||
drop-in replacement with a lower threshold for code change.
|
||||
|
||||
zlib has a long history and is incredibly portable, even supporting
|
||||
lots of systems that predate the Internet. This is great, but it does
|
||||
complicate further development and maintainability.
|
||||
The zlib code has numerous workarounds for old compilers that do not
|
||||
understand ANSI-C or to accommodate systems with limitations such as
|
||||
operating in a 16-bit environment.
|
||||
|
||||
Many of these workarounds are only maintenance burdens, some of them
|
||||
are pretty huge code-wise. For example, the [v]s[n]printf workaround
|
||||
code has a whopping 8 different implementations just to cater to
|
||||
various old compilers. With this many workarounds cluttered throughout
|
||||
the code, new programmers with an idea/interest for zlib will need
|
||||
to take some time to figure out why all of these seemingly strange
|
||||
things are used, and how to work within those confines.
|
||||
|
||||
So I decided to make a fork, merge all the Intel optimizations, merge
|
||||
the Cloudflare optimizations that did not conflict, plus a couple
|
||||
of other smaller patches. Then I started cleaning out workarounds,
|
||||
various dead code, all contrib and example code as there is little
|
||||
point in having those in this fork for various reasons.
|
||||
|
||||
A lot of improvements have gone into zlib-ng since its start, and
|
||||
numerous people and companies have contributed both small and big
|
||||
improvements, or valuable testing.
|
||||
|
||||
Please read LICENSE.md, it is very simple and very liberal.
|
||||
|
||||
Build
|
||||
-----
|
||||
|
||||
There are two ways to build zlib-ng:
|
||||
|
||||
### Cmake
|
||||
|
||||
To build zlib-ng using the cross-platform makefile generator cmake.
|
||||
|
||||
```
|
||||
cmake .
|
||||
cmake --build . --config Release
|
||||
ctest --verbose -C Release
|
||||
```
|
||||
|
||||
Alternatively, you can use the cmake configuration GUI tool ccmake:
|
||||
|
||||
```
|
||||
ccmake .
|
||||
```
|
||||
|
||||
### Configure
|
||||
|
||||
To build zlib-ng using the bash configure script:
|
||||
|
||||
```
|
||||
./configure
|
||||
make
|
||||
make test
|
||||
```
|
||||
|
||||
Build Options
|
||||
-------------
|
||||
| CMake | configure | Description | Default |
|
||||
|:-------------------------|:-------------------------|:--------------------------------------------------------------------------------------|---------|
|
||||
| ZLIB_COMPAT | --zlib-compat | Compile with zlib compatible API | OFF |
|
||||
| ZLIB_ENABLE_TESTS | | Build test binaries | ON |
|
||||
| WITH_GZFILEOP | --without-gzfileops | Compile with support for gzFile related functions | ON |
|
||||
| WITH_OPTIM | --without-optimizations | Build with optimisations | ON |
|
||||
| WITH_NEW_STRATEGIES | --without-new-strategies | Use new strategies | ON |
|
||||
| WITH_NATIVE_INSTRUCTIONS | --native | Compiles with full instruction set supported on this host (gcc/clang -march=native) | OFF |
|
||||
| WITH_SANITIZER | --with-sanitizer | Build with sanitizer (memory, address, undefined) | OFF |
|
||||
| WITH_FUZZERS | --with-fuzzers | Build test/fuzz | OFF |
|
||||
| WITH_MAINTAINER_WARNINGS | | Build with project maintainer warnings | OFF |
|
||||
| WITH_CODE_COVERAGE | | Enable code coverage reporting | OFF |
|
||||
|
||||
Install
|
||||
-------
|
||||
|
||||
WARNING: We do not recommend manually installing unless you really
|
||||
know what you are doing, because this can potentially override the system
|
||||
default zlib library, and any incompatibility or wrong configuration of
|
||||
zlib-ng can make the whole system unusable, requiring recovery or reinstall.
|
||||
If you still want a manual install, we recommend using the /opt/ path prefix.
|
||||
|
||||
For Linux distros, an alternative way to use zlib-ng (if compiled in
|
||||
zlib-compat mode) instead of zlib, is through the use of the
|
||||
_LD_PRELOAD_ environment variable. If the program is dynamically linked
|
||||
with zlib, then zlib-ng will temporarily be used instead by the program,
|
||||
without risking system-wide instability.
|
||||
|
||||
```
|
||||
LD_PRELOAD=/opt/zlib-ng/libz.so.1.2.11.zlib-ng /usr/bin/program
|
||||
```
|
||||
|
||||
### Cmake
|
||||
|
||||
To install zlib-ng system-wide using cmake:
|
||||
|
||||
```
|
||||
cmake --build . --target install
|
||||
```
|
||||
|
||||
### Configure
|
||||
|
||||
To install zlib-ng system-wide using the configure script:
|
||||
|
||||
```
|
||||
make install
|
||||
```
|
||||
|
||||
Contributing
|
||||
------------
|
||||
|
||||
Zlib-ng is a aiming to be open to contributions, and we would be
|
||||
delighted to receive pull requests on github.
|
||||
Just remember that any code you submit must be your own and it must
|
||||
be zlib licensed.
|
||||
Help with testing and reviewing of pull requests etc is also very
|
||||
much appreciated.
|
||||
|
||||
If you are interested in contributing, please consider joining our
|
||||
IRC channel #zlib-ng on the Freenode IRC network.
|
||||
|
||||
|
||||
Acknowledgments
|
||||
----------------
|
||||
|
||||
Thanks to Servebolt.com for sponsoring my maintainership of zlib-ng.
|
||||
|
||||
Thanks go out to all the people and companies who have taken the time
|
||||
to contribute code reviews, testing and/or patches. Zlib-ng would not
|
||||
have been nearly as good without you.
|
||||
|
||||
The deflate format used by zlib was defined by Phil Katz.
|
||||
The deflate and zlib specifications were written by L. Peter Deutsch.
|
||||
|
||||
zlib was originally created by Jean-loup Gailly (compression)
|
||||
and Mark Adler (decompression).
|
||||
|
||||
Advanced Build Options
|
||||
----------------------
|
||||
|
||||
| CMake | configure | Description | Default |
|
||||
|:--------------------------------|:----------------------|:--------------------------------------------------------------------|------------------------|
|
||||
| ZLIB_DUAL_LINK | | Dual link tests with system zlib | OFF |
|
||||
| | --force-sse2 | Assume SSE2 instructions are always available | ON (x86), OFF (x86_64) |
|
||||
| WITH_AVX2 | | Build with AVX2 intrinsics | ON |
|
||||
| WITH_SSE2 | | Build with SSE2 intrinsics | ON |
|
||||
| WITH_SSE4 | | Build with SSE4 intrinsics | ON |
|
||||
| WITH_PCLMULQDQ | | Build with PCLMULQDQ intrinsics | ON |
|
||||
| WITH_ACLE | --without-acle | Build with ACLE intrinsics | ON |
|
||||
| WITH_NEON | --without-neon | Build with NEON intrinsics | ON |
|
||||
| WITH_POWER8 | | Build with POWER8 optimisations | ON |
|
||||
| WITH_DFLTCC_DEFLATE | --with-dfltcc-deflate | Use DEFLATE COMPRESSION CALL instruction for compression on IBM Z | OFF |
|
||||
| WITH_DFLTCC_INFLATE | --with-dfltcc-inflate | Use DEFLATE COMPRESSION CALL instruction for decompression on IBM Z | OFF |
|
||||
| WITH_UNALIGNED | | Allow optimizations that use unaligned reads if safe on current arch| ON |
|
||||
| WITH_INFLATE_STRICT | | Build with strict inflate distance checking | OFF |
|
||||
| WITH_INFLATE_ALLOW_INVALID_DIST | | Build with zero fill for inflate invalid distances | OFF |
|
||||
| INSTALL_UTILS | | Copy minigzip and minideflate during install | OFF |
|
||||
@ -1,139 +0,0 @@
|
||||
/* adler32.c -- compute the Adler-32 checksum of a data stream
|
||||
* Copyright (C) 1995-2011, 2016 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
#include "zbuild.h"
|
||||
#include "zutil.h"
|
||||
#include "functable.h"
|
||||
#include "adler32_p.h"
|
||||
|
||||
/* ========================================================================= */
|
||||
Z_INTERNAL uint32_t adler32_c(uint32_t adler, const unsigned char *buf, size_t len) {
|
||||
uint32_t sum2;
|
||||
unsigned n;
|
||||
|
||||
/* split Adler-32 into component sums */
|
||||
sum2 = (adler >> 16) & 0xffff;
|
||||
adler &= 0xffff;
|
||||
|
||||
/* in case user likes doing a byte at a time, keep it fast */
|
||||
if (UNLIKELY(len == 1))
|
||||
return adler32_len_1(adler, buf, sum2);
|
||||
|
||||
/* initial Adler-32 value (deferred check for len == 1 speed) */
|
||||
if (UNLIKELY(buf == NULL))
|
||||
return 1L;
|
||||
|
||||
/* in case short lengths are provided, keep it somewhat fast */
|
||||
if (UNLIKELY(len < 16))
|
||||
return adler32_len_16(adler, buf, len, sum2);
|
||||
|
||||
/* do length NMAX blocks -- requires just one modulo operation */
|
||||
while (len >= NMAX) {
|
||||
len -= NMAX;
|
||||
#ifdef UNROLL_MORE
|
||||
n = NMAX / 16; /* NMAX is divisible by 16 */
|
||||
#else
|
||||
n = NMAX / 8; /* NMAX is divisible by 8 */
|
||||
#endif
|
||||
do {
|
||||
#ifdef UNROLL_MORE
|
||||
DO16(adler, sum2, buf); /* 16 sums unrolled */
|
||||
buf += 16;
|
||||
#else
|
||||
DO8(adler, sum2, buf, 0); /* 8 sums unrolled */
|
||||
buf += 8;
|
||||
#endif
|
||||
} while (--n);
|
||||
adler %= BASE;
|
||||
sum2 %= BASE;
|
||||
}
|
||||
|
||||
/* do remaining bytes (less than NMAX, still just one modulo) */
|
||||
if (len) { /* avoid modulos if none remaining */
|
||||
#ifdef UNROLL_MORE
|
||||
while (len >= 16) {
|
||||
len -= 16;
|
||||
DO16(adler, sum2, buf);
|
||||
buf += 16;
|
||||
#else
|
||||
while (len >= 8) {
|
||||
len -= 8;
|
||||
DO8(adler, sum2, buf, 0);
|
||||
buf += 8;
|
||||
#endif
|
||||
}
|
||||
while (len) {
|
||||
--len;
|
||||
adler += *buf++;
|
||||
sum2 += adler;
|
||||
}
|
||||
adler %= BASE;
|
||||
sum2 %= BASE;
|
||||
}
|
||||
|
||||
/* return recombined sums */
|
||||
return adler | (sum2 << 16);
|
||||
}
|
||||
|
||||
#ifdef ZLIB_COMPAT
|
||||
unsigned long Z_EXPORT PREFIX(adler32_z)(unsigned long adler, const unsigned char *buf, size_t len) {
|
||||
return (unsigned long)functable.adler32((uint32_t)adler, buf, len);
|
||||
}
|
||||
#else
|
||||
uint32_t Z_EXPORT PREFIX(adler32_z)(uint32_t adler, const unsigned char *buf, size_t len) {
|
||||
return functable.adler32(adler, buf, len);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* ========================================================================= */
|
||||
#ifdef ZLIB_COMPAT
|
||||
unsigned long Z_EXPORT PREFIX(adler32)(unsigned long adler, const unsigned char *buf, unsigned int len) {
|
||||
return (unsigned long)functable.adler32((uint32_t)adler, buf, len);
|
||||
}
|
||||
#else
|
||||
uint32_t Z_EXPORT PREFIX(adler32)(uint32_t adler, const unsigned char *buf, uint32_t len) {
|
||||
return functable.adler32(adler, buf, len);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* ========================================================================= */
|
||||
static uint32_t adler32_combine_(uint32_t adler1, uint32_t adler2, z_off64_t len2) {
|
||||
uint32_t sum1;
|
||||
uint32_t sum2;
|
||||
unsigned rem;
|
||||
|
||||
/* for negative len, return invalid adler32 as a clue for debugging */
|
||||
if (len2 < 0)
|
||||
return 0xffffffff;
|
||||
|
||||
/* the derivation of this formula is left as an exercise for the reader */
|
||||
len2 %= BASE; /* assumes len2 >= 0 */
|
||||
rem = (unsigned)len2;
|
||||
sum1 = adler1 & 0xffff;
|
||||
sum2 = rem * sum1;
|
||||
sum2 %= BASE;
|
||||
sum1 += (adler2 & 0xffff) + BASE - 1;
|
||||
sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem;
|
||||
if (sum1 >= BASE) sum1 -= BASE;
|
||||
if (sum1 >= BASE) sum1 -= BASE;
|
||||
if (sum2 >= ((unsigned long)BASE << 1)) sum2 -= ((unsigned long)BASE << 1);
|
||||
if (sum2 >= BASE) sum2 -= BASE;
|
||||
return sum1 | (sum2 << 16);
|
||||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
#ifdef ZLIB_COMPAT
|
||||
unsigned long Z_EXPORT PREFIX(adler32_combine)(unsigned long adler1, unsigned long adler2, z_off_t len2) {
|
||||
return (unsigned long)adler32_combine_((uint32_t)adler1, (uint32_t)adler2, len2);
|
||||
}
|
||||
|
||||
unsigned long Z_EXPORT PREFIX4(adler32_combine)(unsigned long adler1, unsigned long adler2, z_off64_t len2) {
|
||||
return (unsigned long)adler32_combine_((uint32_t)adler1, (uint32_t)adler2, len2);
|
||||
}
|
||||
#else
|
||||
uint32_t Z_EXPORT PREFIX4(adler32_combine)(uint32_t adler1, uint32_t adler2, z_off64_t len2) {
|
||||
return adler32_combine_(adler1, adler2, len2);
|
||||
}
|
||||
#endif
|
||||
@ -1,53 +0,0 @@
|
||||
/* adler32_p.h -- Private inline functions and macros shared with
|
||||
* different computation of the Adler-32 checksum
|
||||
* of a data stream.
|
||||
* Copyright (C) 1995-2011, 2016 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
#ifndef ADLER32_P_H
|
||||
#define ADLER32_P_H
|
||||
|
||||
#define BASE 65521U /* largest prime smaller than 65536 */
|
||||
#define NMAX 5552
|
||||
/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
|
||||
|
||||
#define DO1(sum1, sum2, buf, i) {(sum1) += buf[(i)]; (sum2) += (sum1);}
|
||||
#define DO2(sum1, sum2, buf, i) {DO1(sum1, sum2, buf, i); DO1(sum1, sum2, buf, i+1);}
|
||||
#define DO4(sum1, sum2, buf, i) {DO2(sum1, sum2, buf, i); DO2(sum1, sum2, buf, i+2);}
|
||||
#define DO8(sum1, sum2, buf, i) {DO4(sum1, sum2, buf, i); DO4(sum1, sum2, buf, i+4);}
|
||||
#define DO16(sum1, sum2, buf) {DO8(sum1, sum2, buf, 0); DO8(sum1, sum2, buf, 8);}
|
||||
|
||||
static inline uint32_t adler32_len_1(uint32_t adler, const unsigned char *buf, uint32_t sum2) {
|
||||
adler += buf[0];
|
||||
if (adler >= BASE)
|
||||
adler -= BASE;
|
||||
sum2 += adler;
|
||||
if (sum2 >= BASE)
|
||||
sum2 -= BASE;
|
||||
return adler | (sum2 << 16);
|
||||
}
|
||||
|
||||
static inline uint32_t adler32_len_16(uint32_t adler, const unsigned char *buf, size_t len, uint32_t sum2) {
|
||||
while (len) {
|
||||
--len;
|
||||
adler += *buf++;
|
||||
sum2 += adler;
|
||||
}
|
||||
if (adler >= BASE)
|
||||
adler -= BASE;
|
||||
sum2 %= BASE; /* only added so many BASE's */
|
||||
return adler | (sum2 << 16);
|
||||
}
|
||||
|
||||
static inline uint32_t adler32_len_64(uint32_t adler, const unsigned char *buf, size_t len, uint32_t sum2) {
|
||||
while (len >= 16) {
|
||||
len -= 16;
|
||||
DO16(adler, sum2, buf);
|
||||
buf += 16;
|
||||
}
|
||||
/* Process tail (len < 16). */
|
||||
return adler32_len_16(adler, buf, len, sum2);
|
||||
}
|
||||
|
||||
#endif /* ADLER32_P_H */
|
||||
2
libs/zlibng/arch/.gitignore
vendored
2
libs/zlibng/arch/.gitignore
vendored
@ -1,2 +0,0 @@
|
||||
# ignore Makefiles; they're all automatically generated
|
||||
Makefile
|
||||
@ -1,68 +0,0 @@
|
||||
# Makefile for zlib
|
||||
# Copyright (C) 1995-2013 Jean-loup Gailly, Mark Adler
|
||||
# For conditions of distribution and use, see copyright notice in zlib.h
|
||||
|
||||
CC=
|
||||
CFLAGS=
|
||||
SFLAGS=
|
||||
INCLUDES=
|
||||
ACLEFLAG=
|
||||
NEONFLAG=
|
||||
SUFFIX=
|
||||
|
||||
SRCDIR=.
|
||||
SRCTOP=../..
|
||||
TOPDIR=$(SRCTOP)
|
||||
|
||||
all: \
|
||||
adler32_neon.o adler32_neon.lo \
|
||||
armfeature.o armfeature.lo \
|
||||
chunkset_neon.o chunkset_neon.lo \
|
||||
crc32_acle.o crc32_acle.lo \
|
||||
slide_neon.o slide_neon.lo \
|
||||
insert_string_acle.o insert_string_acle.lo
|
||||
|
||||
adler32_neon.o:
|
||||
$(CC) $(CFLAGS) $(NEONFLAG) $(INCLUDES) -c -o $@ $(SRCDIR)/adler32_neon.c
|
||||
|
||||
adler32_neon.lo:
|
||||
$(CC) $(SFLAGS) $(NEONFLAG) $(INCLUDES) -c -o $@ $(SRCDIR)/adler32_neon.c
|
||||
|
||||
armfeature.o:
|
||||
$(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/armfeature.c
|
||||
|
||||
armfeature.lo:
|
||||
$(CC) $(SFLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/armfeature.c
|
||||
|
||||
chunkset_neon.o:
|
||||
$(CC) $(CFLAGS) $(NEONFLAG) $(INCLUDES) -c -o $@ $(SRCDIR)/chunkset_neon.c
|
||||
|
||||
chunkset_neon.lo:
|
||||
$(CC) $(SFLAGS) $(NEONFLAG) $(INCLUDES) -c -o $@ $(SRCDIR)/chunkset_neon.c
|
||||
|
||||
crc32_acle.o:
|
||||
$(CC) $(CFLAGS) $(ACLEFLAG) $(INCLUDES) -c -o $@ $(SRCDIR)/crc32_acle.c
|
||||
|
||||
crc32_acle.lo:
|
||||
$(CC) $(SFLAGS) $(ACLEFLAG) $(INCLUDES) -c -o $@ $(SRCDIR)/crc32_acle.c
|
||||
|
||||
slide_neon.o:
|
||||
$(CC) $(CFLAGS) $(NEONFLAG) $(INCLUDES) -c -o $@ $(SRCDIR)/slide_neon.c
|
||||
|
||||
slide_neon.lo:
|
||||
$(CC) $(SFLAGS) $(NEONFLAG) $(INCLUDES) -c -o $@ $(SRCDIR)/slide_neon.c
|
||||
|
||||
insert_string_acle.o:
|
||||
$(CC) $(CFLAGS) $(ACLEFLAG) $(INCLUDES) -c -o $@ $(SRCDIR)/insert_string_acle.c
|
||||
|
||||
insert_string_acle.lo:
|
||||
$(CC) $(SFLAGS) $(ACLEFLAG) $(INCLUDES) -c -o $@ $(SRCDIR)/insert_string_acle.c
|
||||
|
||||
mostlyclean: clean
|
||||
clean:
|
||||
rm -f *.o *.lo *~
|
||||
rm -rf objs
|
||||
rm -f *.gcda *.gcno *.gcov
|
||||
|
||||
distclean:
|
||||
rm -f Makefile
|
||||
@ -1,126 +0,0 @@
|
||||
/* Copyright (C) 1995-2011, 2016 Mark Adler
|
||||
* Copyright (C) 2017 ARM Holdings Inc.
|
||||
* Author: Adenilson Cavalcanti <adenilson.cavalcanti@arm.com>
|
||||
*
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
#ifdef ARM_NEON_ADLER32
|
||||
#ifdef _M_ARM64
|
||||
# include <arm64_neon.h>
|
||||
#else
|
||||
# include <arm_neon.h>
|
||||
#endif
|
||||
#include "../../zutil.h"
|
||||
#include "../../adler32_p.h"
|
||||
|
||||
static void NEON_accum32(uint32_t *s, const unsigned char *buf, size_t len) {
|
||||
static const uint8_t taps[32] = {
|
||||
32, 31, 30, 29, 28, 27, 26, 25,
|
||||
24, 23, 22, 21, 20, 19, 18, 17,
|
||||
16, 15, 14, 13, 12, 11, 10, 9,
|
||||
8, 7, 6, 5, 4, 3, 2, 1 };
|
||||
|
||||
uint32x2_t adacc2, s2acc2, as;
|
||||
uint8x16_t t0 = vld1q_u8(taps), t1 = vld1q_u8(taps + 16);
|
||||
|
||||
uint32x4_t adacc = vdupq_n_u32(0), s2acc = vdupq_n_u32(0);
|
||||
adacc = vsetq_lane_u32(s[0], adacc, 0);
|
||||
s2acc = vsetq_lane_u32(s[1], s2acc, 0);
|
||||
|
||||
while (len >= 2) {
|
||||
uint8x16_t d0 = vld1q_u8(buf), d1 = vld1q_u8(buf + 16);
|
||||
uint16x8_t adler, sum2;
|
||||
s2acc = vaddq_u32(s2acc, vshlq_n_u32(adacc, 5));
|
||||
adler = vpaddlq_u8( d0);
|
||||
adler = vpadalq_u8(adler, d1);
|
||||
sum2 = vmull_u8( vget_low_u8(t0), vget_low_u8(d0));
|
||||
sum2 = vmlal_u8(sum2, vget_high_u8(t0), vget_high_u8(d0));
|
||||
sum2 = vmlal_u8(sum2, vget_low_u8(t1), vget_low_u8(d1));
|
||||
sum2 = vmlal_u8(sum2, vget_high_u8(t1), vget_high_u8(d1));
|
||||
adacc = vpadalq_u16(adacc, adler);
|
||||
s2acc = vpadalq_u16(s2acc, sum2);
|
||||
len -= 2;
|
||||
buf += 32;
|
||||
}
|
||||
|
||||
while (len > 0) {
|
||||
uint8x16_t d0 = vld1q_u8(buf);
|
||||
uint16x8_t adler, sum2;
|
||||
s2acc = vaddq_u32(s2acc, vshlq_n_u32(adacc, 4));
|
||||
adler = vpaddlq_u8(d0);
|
||||
sum2 = vmull_u8( vget_low_u8(t1), vget_low_u8(d0));
|
||||
sum2 = vmlal_u8(sum2, vget_high_u8(t1), vget_high_u8(d0));
|
||||
adacc = vpadalq_u16(adacc, adler);
|
||||
s2acc = vpadalq_u16(s2acc, sum2);
|
||||
buf += 16;
|
||||
len--;
|
||||
}
|
||||
|
||||
adacc2 = vpadd_u32(vget_low_u32(adacc), vget_high_u32(adacc));
|
||||
s2acc2 = vpadd_u32(vget_low_u32(s2acc), vget_high_u32(s2acc));
|
||||
as = vpadd_u32(adacc2, s2acc2);
|
||||
s[0] = vget_lane_u32(as, 0);
|
||||
s[1] = vget_lane_u32(as, 1);
|
||||
}
|
||||
|
||||
static void NEON_handle_tail(uint32_t *pair, const unsigned char *buf, size_t len) {
|
||||
unsigned int i;
|
||||
for (i = 0; i < len; ++i) {
|
||||
pair[0] += buf[i];
|
||||
pair[1] += pair[0];
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t adler32_neon(uint32_t adler, const unsigned char *buf, size_t len) {
|
||||
/* split Adler-32 into component sums */
|
||||
uint32_t sum2 = (adler >> 16) & 0xffff;
|
||||
adler &= 0xffff;
|
||||
|
||||
/* in case user likes doing a byte at a time, keep it fast */
|
||||
if (len == 1)
|
||||
return adler32_len_1(adler, buf, sum2);
|
||||
|
||||
/* initial Adler-32 value (deferred check for len == 1 speed) */
|
||||
if (buf == NULL)
|
||||
return 1L;
|
||||
|
||||
/* in case short lengths are provided, keep it somewhat fast */
|
||||
if (len < 16)
|
||||
return adler32_len_16(adler, buf, len, sum2);
|
||||
|
||||
uint32_t pair[2];
|
||||
int n = NMAX;
|
||||
unsigned int done = 0;
|
||||
unsigned int i;
|
||||
|
||||
/* Split Adler-32 into component sums, it can be supplied by
|
||||
* the caller sites (e.g. in a PNG file).
|
||||
*/
|
||||
pair[0] = adler;
|
||||
pair[1] = sum2;
|
||||
|
||||
for (i = 0; i < len; i += n) {
|
||||
if ((i + n) > len)
|
||||
n = (int)(len - i);
|
||||
|
||||
if (n < 16)
|
||||
break;
|
||||
|
||||
NEON_accum32(pair, buf + i, n / 16);
|
||||
pair[0] %= BASE;
|
||||
pair[1] %= BASE;
|
||||
|
||||
done += (n / 16) * 16;
|
||||
}
|
||||
|
||||
/* Handle the tail elements. */
|
||||
if (done < len) {
|
||||
NEON_handle_tail(pair, (buf + done), len - done);
|
||||
pair[0] %= BASE;
|
||||
pair[1] %= BASE;
|
||||
}
|
||||
|
||||
/* D = B * 65536 + A, see: https://en.wikipedia.org/wiki/Adler-32. */
|
||||
return (pair[1] << 16) | pair[0];
|
||||
}
|
||||
#endif
|
||||
@ -1,13 +0,0 @@
|
||||
/* arm.h -- check for ARM features.
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
#ifndef ARM_H_
|
||||
#define ARM_H_
|
||||
|
||||
extern int arm_cpu_has_neon;
|
||||
extern int arm_cpu_has_crc32;
|
||||
|
||||
void Z_INTERNAL arm_check_features(void);
|
||||
|
||||
#endif /* ARM_H_ */
|
||||
@ -1,69 +0,0 @@
|
||||
#include "../../zutil.h"
|
||||
|
||||
#if defined(__linux__)
|
||||
# include <sys/auxv.h>
|
||||
# include <asm/hwcap.h>
|
||||
#elif defined(__FreeBSD__) && defined(__aarch64__)
|
||||
# include <machine/armreg.h>
|
||||
# ifndef ID_AA64ISAR0_CRC32_VAL
|
||||
# define ID_AA64ISAR0_CRC32_VAL ID_AA64ISAR0_CRC32
|
||||
# endif
|
||||
#elif defined(__APPLE__)
|
||||
# include <sys/sysctl.h>
|
||||
#elif defined(_WIN32)
|
||||
# include <winapifamily.h>
|
||||
#endif
|
||||
|
||||
static int arm_has_crc32() {
|
||||
#if defined(__linux__) && defined(HWCAP2_CRC32)
|
||||
return (getauxval(AT_HWCAP2) & HWCAP2_CRC32) != 0 ? 1 : 0;
|
||||
#elif defined(__FreeBSD__) && defined(__aarch64__)
|
||||
return getenv("QEMU_EMULATING") == NULL
|
||||
&& ID_AA64ISAR0_CRC32_VAL(READ_SPECIALREG(id_aa64isar0_el1)) >= ID_AA64ISAR0_CRC32_BASE;
|
||||
#elif defined(__APPLE__)
|
||||
int hascrc32;
|
||||
size_t size = sizeof(hascrc32);
|
||||
return sysctlbyname("hw.optional.armv8_crc32", &hascrc32, &size, NULL, 0) == 0
|
||||
&& hascrc32 == 1;
|
||||
#elif defined(ARM_NOCHECK_ACLE)
|
||||
return 1;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* AArch64 has neon. */
|
||||
#if !defined(__aarch64__) && !defined(_M_ARM64)
|
||||
static inline int arm_has_neon() {
|
||||
#if defined(__linux__) && defined(HWCAP_NEON)
|
||||
return (getauxval(AT_HWCAP) & HWCAP_NEON) != 0 ? 1 : 0;
|
||||
#elif defined(__APPLE__)
|
||||
int hasneon;
|
||||
size_t size = sizeof(hasneon);
|
||||
return sysctlbyname("hw.optional.neon", &hasneon, &size, NULL, 0) == 0
|
||||
&& hasneon == 1;
|
||||
#elif defined(_M_ARM) && defined(WINAPI_FAMILY_PARTITION)
|
||||
# if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP)
|
||||
return 1; /* Always supported */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(ARM_NOCHECK_NEON)
|
||||
return 1;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
Z_INTERNAL int arm_cpu_has_neon;
|
||||
Z_INTERNAL int arm_cpu_has_crc32;
|
||||
|
||||
void Z_INTERNAL arm_check_features(void) {
|
||||
#if defined(__aarch64__) || defined(_M_ARM64)
|
||||
arm_cpu_has_neon = 1; /* always available */
|
||||
#else
|
||||
arm_cpu_has_neon = arm_has_neon();
|
||||
#endif
|
||||
arm_cpu_has_crc32 = arm_has_crc32();
|
||||
}
|
||||
@ -1,54 +0,0 @@
|
||||
/* chunkset_neon.c -- NEON inline functions to copy small data chunks.
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
#ifdef ARM_NEON_CHUNKSET
|
||||
#ifdef _M_ARM64
|
||||
# include <arm64_neon.h>
|
||||
#else
|
||||
# include <arm_neon.h>
|
||||
#endif
|
||||
#include "../../zbuild.h"
|
||||
#include "../../zutil.h"
|
||||
|
||||
typedef uint8x16_t chunk_t;
|
||||
|
||||
#define HAVE_CHUNKMEMSET_1
|
||||
#define HAVE_CHUNKMEMSET_2
|
||||
#define HAVE_CHUNKMEMSET_4
|
||||
#define HAVE_CHUNKMEMSET_8
|
||||
|
||||
static inline void chunkmemset_1(uint8_t *from, chunk_t *chunk) {
|
||||
*chunk = vld1q_dup_u8(from);
|
||||
}
|
||||
|
||||
static inline void chunkmemset_2(uint8_t *from, chunk_t *chunk) {
|
||||
*chunk = vreinterpretq_u8_s16(vdupq_n_s16(*(int16_t *)from));
|
||||
}
|
||||
|
||||
static inline void chunkmemset_4(uint8_t *from, chunk_t *chunk) {
|
||||
*chunk = vreinterpretq_u8_s32(vdupq_n_s32(*(int32_t *)from));
|
||||
}
|
||||
|
||||
static inline void chunkmemset_8(uint8_t *from, chunk_t *chunk) {
|
||||
*chunk = vcombine_u8(vld1_u8(from), vld1_u8(from));
|
||||
}
|
||||
|
||||
#define CHUNKSIZE chunksize_neon
|
||||
#define CHUNKCOPY chunkcopy_neon
|
||||
#define CHUNKCOPY_SAFE chunkcopy_safe_neon
|
||||
#define CHUNKUNROLL chunkunroll_neon
|
||||
#define CHUNKMEMSET chunkmemset_neon
|
||||
#define CHUNKMEMSET_SAFE chunkmemset_safe_neon
|
||||
|
||||
static inline void loadchunk(uint8_t const *s, chunk_t *chunk) {
|
||||
*chunk = vld1q_u8(s);
|
||||
}
|
||||
|
||||
static inline void storechunk(uint8_t *out, chunk_t *chunk) {
|
||||
vst1q_u8(out, *chunk);
|
||||
}
|
||||
|
||||
#include "chunkset_tpl.h"
|
||||
|
||||
#endif
|
||||
@ -1,110 +0,0 @@
|
||||
/* crc32_acle.c -- compute the CRC-32 of a data stream
|
||||
* Copyright (C) 1995-2006, 2010, 2011, 2012 Mark Adler
|
||||
* Copyright (C) 2016 Yang Zhang
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef ARM_ACLE_CRC_HASH
|
||||
#ifndef _MSC_VER
|
||||
# include <arm_acle.h>
|
||||
#endif
|
||||
#include "../../zutil.h"
|
||||
|
||||
uint32_t crc32_acle(uint32_t crc, const unsigned char *buf, uint64_t len) {
|
||||
Z_REGISTER uint32_t c;
|
||||
Z_REGISTER const uint16_t *buf2;
|
||||
Z_REGISTER const uint32_t *buf4;
|
||||
|
||||
c = ~crc;
|
||||
if (len && ((ptrdiff_t)buf & 1)) {
|
||||
c = __crc32b(c, *buf++);
|
||||
len--;
|
||||
}
|
||||
|
||||
if ((len > sizeof(uint16_t)) && ((ptrdiff_t)buf & sizeof(uint16_t))) {
|
||||
buf2 = (const uint16_t *) buf;
|
||||
c = __crc32h(c, *buf2++);
|
||||
len -= sizeof(uint16_t);
|
||||
buf4 = (const uint32_t *) buf2;
|
||||
} else {
|
||||
buf4 = (const uint32_t *) buf;
|
||||
}
|
||||
|
||||
#if defined(__aarch64__)
|
||||
if ((len > sizeof(uint32_t)) && ((ptrdiff_t)buf & sizeof(uint32_t))) {
|
||||
c = __crc32w(c, *buf4++);
|
||||
len -= sizeof(uint32_t);
|
||||
}
|
||||
|
||||
const uint64_t *buf8 = (const uint64_t *) buf4;
|
||||
|
||||
#ifdef UNROLL_MORE
|
||||
while (len >= 4 * sizeof(uint64_t)) {
|
||||
c = __crc32d(c, *buf8++);
|
||||
c = __crc32d(c, *buf8++);
|
||||
c = __crc32d(c, *buf8++);
|
||||
c = __crc32d(c, *buf8++);
|
||||
len -= 4 * sizeof(uint64_t);
|
||||
}
|
||||
#endif
|
||||
|
||||
while (len >= sizeof(uint64_t)) {
|
||||
c = __crc32d(c, *buf8++);
|
||||
len -= sizeof(uint64_t);
|
||||
}
|
||||
|
||||
if (len >= sizeof(uint32_t)) {
|
||||
buf4 = (const uint32_t *) buf8;
|
||||
c = __crc32w(c, *buf4++);
|
||||
len -= sizeof(uint32_t);
|
||||
buf2 = (const uint16_t *) buf4;
|
||||
} else {
|
||||
buf2 = (const uint16_t *) buf8;
|
||||
}
|
||||
|
||||
if (len >= sizeof(uint16_t)) {
|
||||
c = __crc32h(c, *buf2++);
|
||||
len -= sizeof(uint16_t);
|
||||
}
|
||||
|
||||
buf = (const unsigned char *) buf2;
|
||||
#else /* __aarch64__ */
|
||||
|
||||
# ifdef UNROLL_MORE
|
||||
while (len >= 8 * sizeof(uint32_t)) {
|
||||
c = __crc32w(c, *buf4++);
|
||||
c = __crc32w(c, *buf4++);
|
||||
c = __crc32w(c, *buf4++);
|
||||
c = __crc32w(c, *buf4++);
|
||||
c = __crc32w(c, *buf4++);
|
||||
c = __crc32w(c, *buf4++);
|
||||
c = __crc32w(c, *buf4++);
|
||||
c = __crc32w(c, *buf4++);
|
||||
len -= 8 * sizeof(uint32_t);
|
||||
}
|
||||
# endif
|
||||
|
||||
while (len >= sizeof(uint32_t)) {
|
||||
c = __crc32w(c, *buf4++);
|
||||
len -= sizeof(uint32_t);
|
||||
}
|
||||
|
||||
if (len >= sizeof(uint16_t)) {
|
||||
buf2 = (const uint16_t *) buf4;
|
||||
c = __crc32h(c, *buf2++);
|
||||
len -= sizeof(uint16_t);
|
||||
buf = (const unsigned char *) buf2;
|
||||
} else {
|
||||
buf = (const unsigned char *) buf4;
|
||||
}
|
||||
#endif /* __aarch64__ */
|
||||
|
||||
if (len) {
|
||||
c = __crc32b(c, *buf);
|
||||
}
|
||||
|
||||
c = ~c;
|
||||
return c;
|
||||
}
|
||||
#endif
|
||||
@ -1,12 +0,0 @@
|
||||
#ifndef ARM_CTZL_H
|
||||
#define ARM_CTZL_H
|
||||
|
||||
#include <armintr.h>
|
||||
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
static __forceinline unsigned long __builtin_ctzl(unsigned long value) {
|
||||
return _arm_clz(_arm_rbit(value));
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@ -1,22 +0,0 @@
|
||||
/* insert_string_acle.c -- insert_string variant using ACLE's CRC instructions
|
||||
*
|
||||
* Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef ARM_ACLE_CRC_HASH
|
||||
#ifndef _MSC_VER
|
||||
# include <arm_acle.h>
|
||||
#endif
|
||||
#include "../../zbuild.h"
|
||||
#include "../../deflate.h"
|
||||
|
||||
#define UPDATE_HASH(s, h, val) \
|
||||
h = __crc32w(0, val)
|
||||
|
||||
#define INSERT_STRING insert_string_acle
|
||||
#define QUICK_INSERT_STRING quick_insert_string_acle
|
||||
|
||||
#include "../../insert_string_tpl.h"
|
||||
#endif
|
||||
@ -1,52 +0,0 @@
|
||||
/* slide_neon.c -- Optimized hash table shifting for ARM with support for NEON instructions
|
||||
* Copyright (C) 2017-2020 Mika T. Lindqvist
|
||||
*
|
||||
* Authors:
|
||||
* Mika T. Lindqvist <postmaster@raasu.org>
|
||||
* Jun He <jun.he@arm.com>
|
||||
*
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
#if defined(ARM_NEON_SLIDEHASH)
|
||||
#ifdef _M_ARM64
|
||||
# include <arm64_neon.h>
|
||||
#else
|
||||
# include <arm_neon.h>
|
||||
#endif
|
||||
#include "../../zbuild.h"
|
||||
#include "../../deflate.h"
|
||||
|
||||
/* SIMD version of hash_chain rebase */
|
||||
static inline void slide_hash_chain(Pos *table, unsigned int entries, uint16_t window_size) {
|
||||
Z_REGISTER uint16x8_t v, *p;
|
||||
Z_REGISTER size_t n;
|
||||
|
||||
size_t size = entries*sizeof(table[0]);
|
||||
Assert((size % sizeof(uint16x8_t) * 8 == 0), "hash table size err");
|
||||
|
||||
Assert(sizeof(Pos) == 2, "Wrong Pos size");
|
||||
v = vdupq_n_u16(window_size);
|
||||
|
||||
p = (uint16x8_t *)table;
|
||||
n = size / (sizeof(uint16x8_t) * 8);
|
||||
do {
|
||||
p[0] = vqsubq_u16(p[0], v);
|
||||
p[1] = vqsubq_u16(p[1], v);
|
||||
p[2] = vqsubq_u16(p[2], v);
|
||||
p[3] = vqsubq_u16(p[3], v);
|
||||
p[4] = vqsubq_u16(p[4], v);
|
||||
p[5] = vqsubq_u16(p[5], v);
|
||||
p[6] = vqsubq_u16(p[6], v);
|
||||
p[7] = vqsubq_u16(p[7], v);
|
||||
p += 8;
|
||||
} while (--n);
|
||||
}
|
||||
|
||||
Z_INTERNAL void slide_hash_neon(deflate_state *s) {
|
||||
unsigned int wsize = s->w_size;
|
||||
|
||||
slide_hash_chain(s->head, HASH_SIZE, wsize);
|
||||
slide_hash_chain(s->prev, wsize, wsize);
|
||||
}
|
||||
#endif
|
||||
@ -1,21 +0,0 @@
|
||||
# Makefile for zlib
|
||||
# Copyright (C) 1995-2013 Jean-loup Gailly, Mark Adler
|
||||
# For conditions of distribution and use, see copyright notice in zlib.h
|
||||
|
||||
CC=
|
||||
CFLAGS=
|
||||
SFLAGS=
|
||||
INCLUDES=
|
||||
|
||||
SRCDIR=.
|
||||
SRCTOP=../..
|
||||
TOPDIR=$(SRCTOP)
|
||||
|
||||
all:
|
||||
|
||||
|
||||
mostlyclean: clean
|
||||
clean:
|
||||
rm -f *.o *.lo *~ \
|
||||
rm -rf objs
|
||||
rm -f *.gcda *.gcno *.gcov
|
||||
@ -1,49 +0,0 @@
|
||||
# Makefile for POWER-specific files
|
||||
# Copyright (C) 2020 Matheus Castanho <msc@linux.ibm.com>, IBM
|
||||
# For conditions of distribution and use, see copyright notice in zlib.h
|
||||
|
||||
CC=
|
||||
CFLAGS=
|
||||
SFLAGS=
|
||||
INCLUDES=
|
||||
SUFFIX=
|
||||
|
||||
SRCDIR=.
|
||||
SRCTOP=../..
|
||||
TOPDIR=$(SRCTOP)
|
||||
|
||||
P8FLAGS=-mcpu=power8
|
||||
|
||||
all: power.o \
|
||||
power.lo \
|
||||
adler32_power8.o \
|
||||
adler32_power8.lo \
|
||||
slide_hash_power8.o \
|
||||
slide_hash_power8.lo
|
||||
|
||||
power.o:
|
||||
$(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/power.c
|
||||
|
||||
power.lo:
|
||||
$(CC) $(SFLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/power.c
|
||||
|
||||
adler32_power8.o:
|
||||
$(CC) $(CFLAGS) $(P8FLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/adler32_power8.c
|
||||
|
||||
adler32_power8.lo:
|
||||
$(CC) $(SFLAGS) $(P8FLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/adler32_power8.c
|
||||
|
||||
slide_hash_power8.o:
|
||||
$(CC) $(CFLAGS) $(P8FLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/slide_hash_power8.c
|
||||
|
||||
slide_hash_power8.lo:
|
||||
$(CC) $(SFLAGS) $(P8FLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/slide_hash_power8.c
|
||||
|
||||
mostlyclean: clean
|
||||
clean:
|
||||
rm -f *.o *.lo *~
|
||||
rm -rf objs
|
||||
rm -f *.gcda *.gcno *.gcov
|
||||
|
||||
distclean:
|
||||
rm -f Makefile
|
||||
@ -1,154 +0,0 @@
|
||||
/* Adler32 for POWER8 using VSX instructions.
|
||||
* Copyright (C) 2020 IBM Corporation
|
||||
* Author: Rogerio Alves <rcardoso@linux.ibm.com>
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*
|
||||
* Calculate adler32 checksum for 16 bytes at once using POWER8+ VSX (vector)
|
||||
* instructions.
|
||||
*
|
||||
* If adler32 do 1 byte at time on the first iteration s1 is s1_0 (_n means
|
||||
* iteration n) is the initial value of adler - at start _0 is 1 unless
|
||||
* adler initial value is different than 1. So s1_1 = s1_0 + c[0] after
|
||||
* the first calculation. For the iteration s1_2 = s1_1 + c[1] and so on.
|
||||
* Hence, for iteration N, s1_N = s1_(N-1) + c[N] is the value of s1 on
|
||||
* after iteration N.
|
||||
*
|
||||
* Therefore, for s2 and iteration N, s2_N = s2_0 + N*s1_N + N*c[0] +
|
||||
* N-1*c[1] + ... + c[N]
|
||||
*
|
||||
* In a more general way:
|
||||
*
|
||||
* s1_N = s1_0 + sum(i=1 to N)c[i]
|
||||
* s2_N = s2_0 + N*s1 + sum (i=1 to N)(N-i+1)*c[i]
|
||||
*
|
||||
* Where s1_N, s2_N are the values for s1, s2 after N iterations. So if we
|
||||
* can process N-bit at time we can do this at once.
|
||||
*
|
||||
* Since VSX can support 16-bit vector instructions, we can process
|
||||
* 16-bit at time using N = 16 we have:
|
||||
*
|
||||
* s1 = s1_16 = s1_(16-1) + c[16] = s1_0 + sum(i=1 to 16)c[i]
|
||||
* s2 = s2_16 = s2_0 + 16*s1 + sum(i=1 to 16)(16-i+1)*c[i]
|
||||
*
|
||||
* After the first iteration we calculate the adler32 checksum for 16 bytes.
|
||||
*
|
||||
* For more background about adler32 please check the RFC:
|
||||
* https://www.ietf.org/rfc/rfc1950.txt
|
||||
*/
|
||||
|
||||
#ifdef POWER8_VSX_ADLER32
|
||||
|
||||
#include <altivec.h>
|
||||
#include "zbuild.h"
|
||||
#include "zutil.h"
|
||||
#include "adler32_p.h"
|
||||
|
||||
/* Vector across sum unsigned int (saturate). */
|
||||
inline vector unsigned int vec_sumsu(vector unsigned int __a, vector unsigned int __b) {
|
||||
__b = vec_sld(__a, __a, 8);
|
||||
__b = vec_add(__b, __a);
|
||||
__a = vec_sld(__b, __b, 4);
|
||||
__a = vec_add(__a, __b);
|
||||
|
||||
return __a;
|
||||
}
|
||||
|
||||
uint32_t adler32_power8(uint32_t adler, const unsigned char* buf, size_t len) {
|
||||
uint32_t s1 = adler & 0xffff;
|
||||
uint32_t s2 = (adler >> 16) & 0xffff;
|
||||
|
||||
/* in case user likes doing a byte at a time, keep it fast */
|
||||
if (UNLIKELY(len == 1))
|
||||
return adler32_len_1(s1, buf, s2);
|
||||
|
||||
/* If buffer is empty or len=0 we need to return adler initial value. */
|
||||
if (UNLIKELY(buf == NULL))
|
||||
return 1;
|
||||
|
||||
/* This is faster than VSX code for len < 64. */
|
||||
if (len < 64)
|
||||
return adler32_len_64(s1, buf, len, s2);
|
||||
|
||||
/* Use POWER VSX instructions for len >= 64. */
|
||||
const vector unsigned int v_zeros = { 0 };
|
||||
const vector unsigned char v_mul = {16, 15, 14, 13, 12, 11, 10, 9, 8, 7,
|
||||
6, 5, 4, 3, 2, 1};
|
||||
const vector unsigned char vsh = vec_splat_u8(4);
|
||||
const vector unsigned int vmask = {0xffffffff, 0x0, 0x0, 0x0};
|
||||
vector unsigned int vs1 = { 0 };
|
||||
vector unsigned int vs2 = { 0 };
|
||||
vector unsigned int vs1_save = { 0 };
|
||||
vector unsigned int vsum1, vsum2;
|
||||
vector unsigned char vbuf;
|
||||
int n;
|
||||
|
||||
vs1[0] = s1;
|
||||
vs2[0] = s2;
|
||||
|
||||
/* Do length bigger than NMAX in blocks of NMAX size. */
|
||||
while (len >= NMAX) {
|
||||
len -= NMAX;
|
||||
n = NMAX / 16;
|
||||
do {
|
||||
vbuf = vec_xl(0, (unsigned char *) buf);
|
||||
vsum1 = vec_sum4s(vbuf, v_zeros); /* sum(i=1 to 16) buf[i]. */
|
||||
/* sum(i=1 to 16) buf[i]*(16-i+1). */
|
||||
vsum2 = vec_msum(vbuf, v_mul, v_zeros);
|
||||
/* Save vs1. */
|
||||
vs1_save = vec_add(vs1_save, vs1);
|
||||
/* Accumulate the sums. */
|
||||
vs1 = vec_add(vsum1, vs1);
|
||||
vs2 = vec_add(vsum2, vs2);
|
||||
|
||||
buf += 16;
|
||||
} while (--n);
|
||||
/* Once each block of NMAX size. */
|
||||
vs1 = vec_sumsu(vs1, vsum1);
|
||||
vs1_save = vec_sll(vs1_save, vsh); /* 16*vs1_save. */
|
||||
vs2 = vec_add(vs1_save, vs2);
|
||||
vs2 = vec_sumsu(vs2, vsum2);
|
||||
|
||||
/* vs1[0] = (s1_i + sum(i=1 to 16)buf[i]) mod 65521. */
|
||||
vs1[0] = vs1[0] % BASE;
|
||||
/* vs2[0] = s2_i + 16*s1_save +
|
||||
sum(i=1 to 16)(16-i+1)*buf[i] mod 65521. */
|
||||
vs2[0] = vs2[0] % BASE;
|
||||
|
||||
vs1 = vec_and(vs1, vmask);
|
||||
vs2 = vec_and(vs2, vmask);
|
||||
vs1_save = v_zeros;
|
||||
}
|
||||
|
||||
/* len is less than NMAX one modulo is needed. */
|
||||
if (len >= 16) {
|
||||
while (len >= 16) {
|
||||
len -= 16;
|
||||
|
||||
vbuf = vec_xl(0, (unsigned char *) buf);
|
||||
|
||||
vsum1 = vec_sum4s(vbuf, v_zeros); /* sum(i=1 to 16) buf[i]. */
|
||||
/* sum(i=1 to 16) buf[i]*(16-i+1). */
|
||||
vsum2 = vec_msum(vbuf, v_mul, v_zeros);
|
||||
/* Save vs1. */
|
||||
vs1_save = vec_add(vs1_save, vs1);
|
||||
/* Accumulate the sums. */
|
||||
vs1 = vec_add(vsum1, vs1);
|
||||
vs2 = vec_add(vsum2, vs2);
|
||||
|
||||
buf += 16;
|
||||
}
|
||||
/* Since the size will be always less than NMAX we do this once. */
|
||||
vs1 = vec_sumsu(vs1, vsum1);
|
||||
vs1_save = vec_sll(vs1_save, vsh); /* 16*vs1_save. */
|
||||
vs2 = vec_add(vs1_save, vs2);
|
||||
vs2 = vec_sumsu(vs2, vsum2);
|
||||
}
|
||||
/* Copy result back to s1, s2 (mod 65521). */
|
||||
s1 = vs1[0] % BASE;
|
||||
s2 = vs2[0] % BASE;
|
||||
|
||||
/* Process tail (len < 16).and return */
|
||||
return adler32_len_16(s1, buf, len, s2);
|
||||
}
|
||||
|
||||
#endif /* POWER8_VSX_ADLER32 */
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user