mirror of
https://github.com/davidallendj/gdpm.git
synced 2026-02-04 00:56:27 -07:00
Compare commits
30 commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f59319ad16 | |||
| 13487a1498 | |||
| 62bb8fabdf | |||
| aebd86b70a | |||
| d50dbeb051 | |||
| 7570f48cad | |||
|
|
341f0752a3 | ||
| 9f56c0b8c7 | |||
| a6635b1f02 | |||
| e8020aa0b0 | |||
| 1e92c16cdf | |||
| 2b5c838a4f | |||
| 6199486b68 | |||
|
|
f77d92cfef | ||
| c78cdd3da9 | |||
| ce347d9b56 | |||
| 6ab1345cfe | |||
| 920d648a51 | |||
| adb80a7176 | |||
| 1fe1f19891 | |||
| defbc079cd | |||
| 5819c76289 | |||
| c1ca0524f1 | |||
| 56adb85f4d | |||
| 113dee2194 | |||
| 050b7a482b | |||
| e225312197 | |||
| 846bc4932f | |||
| 13da8c03f2 | |||
| 23b27bf276 |
22 changed files with 217 additions and 71 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -16,3 +16,5 @@ vgcore.*
|
|||
config.json
|
||||
*.txt
|
||||
actions-runner/
|
||||
**.tar.gz
|
||||
**.tar.zst
|
||||
|
|
|
|||
3
.gitmodules
vendored
3
.gitmodules
vendored
|
|
@ -16,3 +16,6 @@
|
|||
[submodule "modules/argparse"]
|
||||
path = modules/argparse
|
||||
url = https://github.com/p-ranav/argparse
|
||||
[submodule "modules/indicators"]
|
||||
path = modules/indicators
|
||||
url = https://github.com/p-ranav/indicators
|
||||
|
|
|
|||
|
|
@ -2,8 +2,14 @@ FROM cgr.dev/chainguard/wolfi-base
|
|||
|
||||
RUN apk add --no-cache tini
|
||||
|
||||
# run as nobody
|
||||
USER 65534:65534
|
||||
|
||||
|
||||
# build the binary then copy into container
|
||||
RUN bin/compile.sh --link
|
||||
RUN bin/compile.sh --all
|
||||
|
||||
COPY build/gdpm.static /gdpm
|
||||
|
||||
CMD ["/gdpm"]
|
||||
|
|
|
|||
22
PKGBUILD
22
PKGBUILD
|
|
@ -1,22 +0,0 @@
|
|||
# Maintainer: David J. Allen <davidallendj@gmail.com>
|
||||
pkgname=gdpm
|
||||
pkgver=0.0.1
|
||||
pkgrel=1
|
||||
pkgdesc="CLI tool to automate managing Godot game engine assets from the command-line. This includes a pre-built, static binary."
|
||||
arch=('x86_64')
|
||||
url="https://github.com/davidallendj/gdpm"
|
||||
license=('MIT')
|
||||
#groups=
|
||||
depends=('glibc')
|
||||
makedepends=('cmake', 'make', 'clang')
|
||||
source=("https://github.com/davidallendj/gdpm/releases/download/v$pkgver/$pkgname.static.$arch.linux.static")
|
||||
sha256sums=('012e3c32511d6d762ac070808e8bcae7f68dd261bf1cad3dbf4607c97aa1bb3d')
|
||||
|
||||
build () {
|
||||
# shouldn't need to build anything with static binary...
|
||||
}
|
||||
|
||||
package() {
|
||||
cd "$srcdir/$pkgname-$pkgver"
|
||||
make DESTDIR="$pkgdir/" install
|
||||
}
|
||||
79
README.md
79
README.md
|
|
@ -7,10 +7,12 @@ GDPM is an attempt to make a simple, front-end, command-line, package manager de
|
|||
|
||||
\*GDPM has not been tested for Windows or Mac.
|
||||
|
||||
- [Godot Package Manager (GDPM)](#godot-package-manager-gdpm)
|
||||
- [Quick Start](#quick-start)
|
||||
- [Rational](#rationale)
|
||||
- [Rationale](#rationale)
|
||||
- [How It Works](#how-it-works)
|
||||
- [Features](#features)
|
||||
- [Installing with Package Managers](#installing-with-package-managers)
|
||||
- [Building from Source](#building-from-source)
|
||||
- [Prerequisites](#prerequisites)
|
||||
- [Macro Definitions](#macro-definitions)
|
||||
|
|
@ -33,10 +35,16 @@ GDPM is an attempt to make a simple, front-end, command-line, package manager de
|
|||
Common commands for searching, installing, listing, and removing assets.
|
||||
|
||||
```bash
|
||||
gdpm search demo
|
||||
gdpm install "Third Person Controller" --skip-prompt
|
||||
# fetch updates local database if "no packages to install" error
|
||||
gdpm fetch
|
||||
|
||||
# search and install "Godot Jolt" globally
|
||||
gdpm search jolt
|
||||
gdpm install "Godot Jolt" --skip-prompt
|
||||
|
||||
# list installed packages and remove
|
||||
gdpm list --style=table
|
||||
gdpm remove "Third Person Controller" --clean
|
||||
gdpm remove "Godot Jolt" --clean
|
||||
```
|
||||
|
||||
Use `gdpm help` to see full list of commands.
|
||||
|
|
@ -100,6 +108,18 @@ The local database stores all the information sent by the Asset API with additio
|
|||
|
||||
* Parallel downloads using `libcurl`.
|
||||
|
||||
|
||||
## Installing with Package Managers
|
||||
|
||||
Currently, `gdpm` can only be installed using `makepkg` on Arch Linux with plans of packaging for other distributions in the future.
|
||||
|
||||
```bash
|
||||
git clone https://github.com/davidallendj/gdpm && cd gdpm/dist/archlinux
|
||||
makepkg -si
|
||||
```
|
||||
|
||||
This should build the static binary from source and then install it in `/usr/bin/gdpm`.
|
||||
|
||||
## Building from Source
|
||||
|
||||
The project uses the CMake or Meson build system and has been tested with GCC and Clang on Arch/Manjaro Linux. CMake is preferred, but a `meson.build` script is provided and should work with some tweaking. Building on Windows or Mac has not been tested yet so it's not guaranteed to work. Compiling with CMake will build 2 executables, 3 shared libraries, and an archive library to link, while compiling with Meson only builds an executable that links with a shared library.
|
||||
|
|
@ -118,33 +138,58 @@ The project uses the CMake or Meson build system and has been tested with GCC an
|
|||
|
||||
* fmt (may be removed later in favor of C++20 std::format)
|
||||
|
||||
* SQLite 3
|
||||
* SQLite 3 and SQLite C++ wrapper
|
||||
|
||||
* cxxopts
|
||||
|
||||
* doctest (optional; for tests, but still WIP)
|
||||
|
||||
* Doxygen (optional; to generate API docs)
|
||||
|
||||
Arch Linux users can simply install required libs through pacman:
|
||||
Arch Linux users can simply install required libs through `pacman` and/or `yay`:
|
||||
|
||||
```bash
|
||||
pacman -S base-devel fmt sqlite3 rapidjson cmake libzip curl
|
||||
pacman -S base-devel fmt sqlite rapidjson cmake libzip curl catch2 cxxopts doctest
|
||||
yay -S sqlitecpp libcurlpp
|
||||
```
|
||||
|
||||
After installing all necessary dependencies, build the project::
|
||||
After installing the packages, clone the submodules and link the headers:
|
||||
|
||||
```bash
|
||||
git submodule add https://github.com/p-ranav/argparse modules/argparse
|
||||
git submodule add https://github.com/p-ranav/tabulate modules/tabulate
|
||||
git submodule add https://github.com/p-ranav/indicators modules/indicators
|
||||
git submodule add https://github.com/p-ranav/csv2 modules/csv2
|
||||
|
||||
ln -s ../modules/argparse/include/argparse include/argparse
|
||||
ln -s ../modules/tabulate/include/tabulate include/tabulate
|
||||
ln -s ../modules/indicators/include/indicators include/indicators
|
||||
ln -s ../modules/csv2/include/csv2 include/csv2
|
||||
```
|
||||
|
||||
Otherwise, you can just update the modules if they're already there and out-of-date:
|
||||
|
||||
```bash
|
||||
git submodule update --init --recursive
|
||||
```
|
||||
|
||||
And then build the binaries (check the "build" directory):
|
||||
|
||||
```bash
|
||||
# Start by cloning the repo, then...
|
||||
git clone https://github.com/davidallendj/gdpm
|
||||
cd gdpm
|
||||
export project_root=${pwd}
|
||||
git clone https://github.com/davidallendj/gdpm && cd gdpm
|
||||
|
||||
# ... if using CMake with Ninja instead (preferred and tested)...
|
||||
cmake -B build -S . -D CMAKE_EXPORT_COMPILE_COMMANDS=1 -D CMAKE_BUILD_TYPE=Release -G Ninja
|
||||
ninja -C build -j$(nproc)
|
||||
|
||||
# ...if using Meson with Clang on Linux...
|
||||
meson build
|
||||
meson configure build # only needed if reconfiguring build
|
||||
meson compile -C build -j$(nproc)
|
||||
CXX=clang++ meson compile -C build -j$(npoc)
|
||||
CXX=clang++ meson compile -C build -j$(nproc)
|
||||
|
||||
# ...if using CMake on Linux (needs work!)...
|
||||
# ...if using CMake with Make on Linux (needs work!)...
|
||||
cd build
|
||||
cmake ..
|
||||
make -j$(nproc)
|
||||
|
|
@ -373,17 +418,17 @@ $ gdpm config set username towk
|
|||
|
||||
- [ ] Adapted to new Asset API.
|
||||
|
||||
- [ ] Unit tests.
|
||||
|
||||
- [ ] User interface.
|
||||
|
||||
- [ ] Experimental dependency management. There is no way of handling dependencies using the Godot Asset API. This is a [hot topic](https://github.com/godotengine/godot-proposals/issues/142) and might change in the near future.
|
||||
## Known Issues
|
||||
|
||||
* The code is currently still changing so API is unstable.
|
||||
|
||||
* Logging doesn't write to file.
|
||||
* Logging doesn't write to file yet.
|
||||
|
||||
* Download progress bars are not showing when downloading archives. This is being reworked to display multiple bars dynamically to better show download status.
|
||||
|
||||
## License
|
||||
|
||||
See the LICENSE.md file.
|
||||
See the `LICENSE.md` file.
|
||||
|
|
|
|||
25
SConstruct
Normal file
25
SConstruct
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
|
||||
# set up variables and glob files
|
||||
env = Environment(
|
||||
CPPPATH = Glob('include/*.hpp'),
|
||||
CPPDEFINES = [],
|
||||
LIBS = []
|
||||
)
|
||||
base_name = "gdpm"
|
||||
include_files = Glob('include/*.hpp')
|
||||
source_files = Glob('src/*.cpp')
|
||||
test_files = Glob('tests/*.cpp')
|
||||
compile_flags = ""
|
||||
|
||||
# build the main executable and tests
|
||||
env.Program(f'{base_name}', source_files)
|
||||
env.Program(f'{base_name}.tests', test_files)
|
||||
|
||||
# build the static library
|
||||
StaticLibrary(f'{base_name}-static')
|
||||
|
||||
# build the shared libraries
|
||||
SharedLibrary(f'{base_name}-shared')
|
||||
SharedLibrary(f'{base_name}-static')
|
||||
SharedLibrary(f'{base_name}-http')
|
||||
SharedLibrary(f'{base_name}-restapi')
|
||||
|
|
@ -46,6 +46,16 @@ function link_all(){
|
|||
link_exe $script_dir/../build/gdpm.tests $script_dir/../bin/$tests
|
||||
}
|
||||
|
||||
function get_deps() {
|
||||
#git submodule init -f
|
||||
#git submodule init -f
|
||||
|
||||
# link the include headers
|
||||
ln -s ../modules/indicators/include/indicators include/indicators
|
||||
ln -s ../modules/tabulate/include/tabulate include/tabulate
|
||||
ln -s ../modules/argparse/include/argparse include/argparse
|
||||
}
|
||||
|
||||
|
||||
function clean(){
|
||||
rm ${script_dir}/../bin/$exe
|
||||
|
|
@ -126,6 +136,7 @@ do
|
|||
--exe) build_exe shift;;
|
||||
--libs) build_libs shift;;
|
||||
--tests) build_tests shift;;
|
||||
--deps) get_deps shift;;
|
||||
--sums) checksums shift;;
|
||||
-d|--docs) build_docs shift;;
|
||||
-c|--clean) clean shift;;
|
||||
|
|
|
|||
56
dist/archlinux/PKGBUILD
vendored
Normal file
56
dist/archlinux/PKGBUILD
vendored
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
# Maintainer: David J. Allen <davidallendj@gmail.com>
|
||||
pkgname=gdpm-git
|
||||
pkgver=r94.341f075
|
||||
pkgrel=1
|
||||
pkgdesc="CLI tool to automate managing Godot game engine assets from the command-line. This includes a pre-built, static binary."
|
||||
arch=('x86_64')
|
||||
url="https://github.com/davidallendj/gdpm"
|
||||
license=('MIT')
|
||||
depends=('glibc')
|
||||
makedepends=('cmake' 'ninja' 'clang' 'gcc')
|
||||
optdepends=('meson' 'make')
|
||||
source=("$pkgname-$pkgver::git+https://github.com/davidallendj/gdpm")
|
||||
sha256sums=('SKIP')
|
||||
|
||||
pkgver() {
|
||||
printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
|
||||
}
|
||||
|
||||
prepare() {
|
||||
cd "$srcdir/$pkgname-$pkgver"
|
||||
|
||||
# remove all links to modules
|
||||
rm -f include/argparse
|
||||
rm -f include/tabulate
|
||||
rm -f include/indicators
|
||||
rm -f include/csv2
|
||||
|
||||
# update and initialize submodules
|
||||
git submodule update --init modules/argparse
|
||||
git submodule update --init modules/tabulate
|
||||
git submodule update --init modules/indicators
|
||||
git submodule update --init modules/csv2
|
||||
|
||||
# link module headers to include/*
|
||||
ln -s ../modules/argparse/include/argparse include/argparse
|
||||
ln -s ../modules/tabulate/include/tabulate include/tabulate
|
||||
ln -s ../modules/indicators/include/indicators include/indicators
|
||||
ln -s ../modules/csv2/include/csv2 include/csv2
|
||||
}
|
||||
|
||||
build () {
|
||||
cd "$srcdir/$pkgname-$pkgver"
|
||||
bin/compile.sh --all
|
||||
}
|
||||
|
||||
package() {
|
||||
cd "$srcdir/$pkgname-$pkgver"
|
||||
|
||||
# install the binary to /usr/bin
|
||||
mkdir -p "${pkgdir}/usr/bin"
|
||||
install -m755 build/gdpm.static "${pkgdir}/usr/bin/gdpm"
|
||||
}
|
||||
|
||||
clean() {
|
||||
rm -rf "$srcdir/$pkgname-$pkgver"
|
||||
}
|
||||
1
include/argparse
Symbolic link
1
include/argparse
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../modules/argparse/include/argparse
|
||||
|
|
@ -16,6 +16,7 @@ namespace gdpm::cache {
|
|||
string table_name = GDPM_PACKAGE_CACHE_TABLENAME;
|
||||
};
|
||||
|
||||
bool exists(const params& = params());
|
||||
error create_package_database(bool overwrite = false, const params& = params());
|
||||
error insert_package_info(const package::info_list& packages, const params& = params());
|
||||
result_t<package::info_list> get_package_info_by_id(const package::id_list& package_ids, const params& = params());
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ namespace gdpm::config{
|
|||
bool enable_sync = true;
|
||||
bool enable_cache = true;
|
||||
bool skip_prompt = false;
|
||||
bool ignore_validation = false;
|
||||
bool enable_file_logging;
|
||||
bool clean_temporary;
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
#include <variant>
|
||||
#include <future>
|
||||
#include <any>
|
||||
#include <algorithm>
|
||||
|
||||
namespace gdpm{
|
||||
class error;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ namespace gdpm::version{
|
|||
int major = 0;
|
||||
int minor = 0;
|
||||
int patch = 0;
|
||||
string commit = "";
|
||||
string description = "";
|
||||
};
|
||||
|
||||
std::string to_string(const context& context);
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
Subproject commit 02783b6782ebedbb2bebc2e6ceda738ee51c7df2
|
||||
1
modules/indicators
Submodule
1
modules/indicators
Submodule
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 222382c3a6abbce32503792c59826063660ddb56
|
||||
|
|
@ -17,6 +17,10 @@ namespace gdpm::cache{
|
|||
return utils::replace_all(s, "'", "''");
|
||||
}
|
||||
|
||||
bool exists(const params& params) {
|
||||
return std::filesystem::exists(params.cache_path);
|
||||
}
|
||||
|
||||
error create_package_database(
|
||||
bool overwrite,
|
||||
const params& params
|
||||
|
|
|
|||
13
src/main.cpp
13
src/main.cpp
|
|
@ -1,10 +1,7 @@
|
|||
|
||||
// Godot Package Manager (GPM)
|
||||
#include "constants.hpp"
|
||||
#include "log.hpp"
|
||||
#include "config.hpp"
|
||||
|
||||
#include "package_manager.hpp"
|
||||
#include "result.hpp"
|
||||
#include <cstdlib>
|
||||
|
||||
|
||||
|
|
@ -13,7 +10,13 @@ int main(int argc, char **argv){
|
|||
using namespace gdpm::package_manager;
|
||||
|
||||
error error = initialize(argc, argv);
|
||||
parse_arguments(argc, argv);
|
||||
if(error.has_occurred()) {
|
||||
log::error(error);
|
||||
}
|
||||
error = parse_arguments(argc, argv);
|
||||
if(error.has_occurred()) {
|
||||
log::error(error);
|
||||
}
|
||||
finalize();
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ namespace gdpm::package{
|
|||
if(p_cache.empty()){
|
||||
return log::error_rc(
|
||||
ec::NOT_FOUND, /* TODO: change to PACKAGE_NOT_FOUND */
|
||||
"package::install(): no packages found to install."
|
||||
"package::install(): no package(s) found to install."
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -147,6 +147,13 @@ namespace gdpm::package_manager{
|
|||
.help("set verbosity level")
|
||||
.nargs(nargs_pattern::optional);
|
||||
|
||||
program.add_argument("--ignore-validation")
|
||||
.action([&](const auto&){ config.ignore_validation = true; })
|
||||
.default_value(false)
|
||||
.implicit_value(true)
|
||||
.help("ignore checking if current directory is a Godot project")
|
||||
.nargs(0);
|
||||
|
||||
install_command.add_description("install package(s)");
|
||||
install_command.add_argument("packages")
|
||||
.required()
|
||||
|
|
@ -409,6 +416,13 @@ namespace gdpm::package_manager{
|
|||
return log::error_rc(ec::ARGPARSE_ERROR, e.what());
|
||||
}
|
||||
|
||||
/* Check if we're running in a directory with 'project.godot' file */
|
||||
if (!config.ignore_validation) {
|
||||
if(!std::filesystem::exists("project.godot")){
|
||||
return error(ec::FILE_NOT_FOUND, "no 'project.godot' file found in current directory");
|
||||
}
|
||||
}
|
||||
|
||||
if(program.is_subcommand_used(install_command)){
|
||||
action = action_e::install;
|
||||
// if(install_command.is_used("packages"))
|
||||
|
|
|
|||
|
|
@ -12,10 +12,6 @@
|
|||
#include <string>
|
||||
#include <ostream>
|
||||
|
||||
#include <curlpp/cURLpp.hpp>
|
||||
#include <curlpp/Easy.hpp>
|
||||
#include <curlpp/Options.hpp>
|
||||
#include <curlpp/Exception.hpp>
|
||||
|
||||
namespace gdpm::rest_api{
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
Subproject commit ef71abd9bc7254f7734fa84d5b1c336be2deb9f7
|
||||
Loading…
Add table
Add a link
Reference in a new issue