3 Commits

Author SHA1 Message Date
07071aba66 fix mbedtls and make it staticly linked to shared object when fetchcontent is enabled 2026-06-19 22:36:58 -05:00
25f9ceba55 Use my new toolchain, fix a bug on mac/freebsd 2026-06-19 22:36:46 -05:00
41d503cfb5 Fix win32 printing, fix my stupid json vulnerability
All checks were successful
Build and Deploy on Tag / 🔨 Build for Arch Linux/Static Builds (push) Successful in 1m48s
Build and Deploy on Tag / 🔨 Build win32 and update the tap 🍺 (push) Successful in 1m35s
2026-06-01 06:37:14 -05:00
24 changed files with 647 additions and 249 deletions

View File

@@ -9,19 +9,50 @@ env:
VERSION: ${{ gitea.ref_name }}
jobs:
build-arch:
name: "🔨 Build for Arch Linux/Static Builds"
runs-on: arch-builder
build-ppc:
name: "🔨 Build for PowerPC"
runs-on: ubuntu-latest
container:
image: git.tesses.org/tesses50/linux-ppc:latest
steps:
- uses: actions/checkout@v4
- run: pacman --noconfirm -Sy mbedtls zip zig ninja
- run: pacman --config /opt/cross/ppc/pacman.conf --noconfirm -Sy mbedtls
- run: cp Packaging/Linux/PKGBUILD /home/build/PKGBUILD
- run: cp Packaging/Linux/build-arch.sh /home/build/build-arch.sh
- run: chmod 755 /home/build/build-arch.sh
- run: chown build:build /home/build/PKGBUILD
- run: chown build:build /home/build/build-arch.sh
- run: su build -c /home/build/build-arch.sh
- run: bash build-for-ppc.sh
- uses: akkuman/gitea-release-action@v1
env:
NODE_OPTIONS: '--experimental-fetch' # if nodejs < 18
with:
prerelease: true
files: |-
artifacts/**
build-packages:
name: "🔨 Build for everything else"
runs-on: fw13-ubuntu-latest
strategy:
fail-fast: true
matrix:
include:
- container: "git.tesses.org/tesses50/linux-x64:latest"
nfpmName: "amd64"
debianName: "x86_64-linux-gnu"
- container: "git.tesses.org/tesses50/linux-x86:latest"
nfpmName: "386"
debianName: "i386-linux-gnu"
- container: "git.tesses.org/tesses50/linux-arm:latest"
nfpmName: "arm7"
debianName: "arm-linux-gnueabihf"
- container: "git.tesses.org/tesses50/linux-arm64:latest"
nfpmName: "arm64"
debianName: "aarch64-linux-gnu"
- container: "git.tesses.org/tesses50/linux-riscv64:latest"
nfpmName: "riscv64"
debianName: "riscv64-linux-gnu"
container:
image: ${{ matrix.container }}
steps:
- uses: actions/checkout@v4
- run: bash build-for-nfpm.sh ${{ matrix.nfpmName }} ${{ matrix.debianName }}
- uses: akkuman/gitea-release-action@v1
env:
NODE_OPTIONS: '--experimental-fetch' # if nodejs < 18

View File

@@ -63,4 +63,11 @@ include(cmake/apps.cmake)
if(TESSESFRAMEWORK_INSTALL_DEVELOPMENT)
add_subdirectory(pkgconfig)
endif()
endif()
if(NOT TESSESFRAMEWORK_NFPM_ARCH STREQUAL "")
configure_file(nfpm.yaml.in nfpm.yaml @ONLY)
endif()
configure_file(ppc-pkgbuild.in ppc-pkgbuild @ONLY)

View File

@@ -1,48 +0,0 @@
# Maintainer: Mike Nolan <tesses@tesses.net>
pkgname=tessesframework # '-bzr', '-git', '-hg' or '-svn'
pkgver=0.0.4
pkgrel=1
pkgdesc=""
arch=('x86_64' 'powerpc')
url="https://git.tesses.org/tesses50/tessesframework"
license=('MIT')
groups=()
depends=('mbedtls')
makedepends=('git' 'cmake' 'make' 'base-devel' 'wget') # 'bzr', 'git', 'mercurial' or 'subversion'
install=
source=('tessesframework::git+https://git.tesses.org/tesses50/tessesframework')
noextract=()
sha256sums=('SKIP')
if [[ -z "$CMAKE_TOOLCHAIN" ]]; then
options=(!strip)
else
options=(!buildflags !strip)
fi
prepare() {
cd "$srcdir/${pkgname}"
}
build() {
cd "$srcdir/${pkgname}"
mkdir build
if [[ -z "$CMAKE_TOOLCHAIN" ]]; then
cmake -S . -B build -DCMAKE_INSTALL_PREFIX=/usr -DTESSESFRAMEWORK_VENDERCERTCHAIN=OFF -DTESSESFRAMEWORK_FETCHCONTENT=OFF -DCMAKE_BUILD_TYPE=Release
else
cmake -S . -B build -DCMAKE_INSTALL_PREFIX=/usr -DTESSESFRAMEWORK_VENDERCERTCHAIN=OFF -DTESSESFRAMEWORK_FETCHCONTENT=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE="$CMAKE_TOOLCHAIN"
fi
cd build
make -j`nproc`
}
package() {
cd "$srcdir/${pkgname}/build"
make install DESTDIR="$pkgdir/"
}

View File

@@ -1,17 +0,0 @@
#!/bin/bash
cd /home/build
mkdir x86_64
cd x86_64
cp ../PKGBUILD .
makepkg
curl --user tesses50:$PACKAGE_AND_BREW \
--upload-file *.pkg.tar.zst \
https://git.tesses.org/api/packages/tesses50/arch/core
cd ..
mkdir powerpc
cd powerpc
cp ../PKGBUILD .
CARCH=powerpc CMAKE_TOOLCHAIN=/opt/cross/ppc/toolchain.cmake makepkg
curl --user tesses50:$PACKAGE_AND_BREW \
--upload-file *.pkg.tar.zst \
https://git.tesses.org/api/packages/tesses50/arch/core

View File

@@ -5,7 +5,7 @@ echo " desc \"\"" >> "Formula/tessesframework.rb"
echo " homepage \"\"" >> "Formula/tessesframework.rb"
echo " url \"https://git.tesses.org/tesses50/tessesframework/archive/$VERSION.tar.gz\"" >> "Formula/tessesframework.rb"
echo " sha256 \"$HASH\"" >> "Formula/tessesframework.rb"
echo " license \"MIT\"" >> "Formula/tessesframework.rb"
echo " license \"GPLv3\"" >> "Formula/tessesframework.rb"
echo " depends_on \"cmake\" => :build" >> "Formula/tessesframework.rb"
echo " depends_on \"mbedtls@3\"" >> "Formula/tessesframework.rb"
echo " def install" >> "Formula/tessesframework.rb"

40
build-for-nfpm.sh Normal file
View File

@@ -0,0 +1,40 @@
if [ $# -lt 2 ]
then
echo "Not enough args, pass nfpm arch and debian tripple as argument"
echo "This script requires our docker container: git.tesses.org/tesses50/linux-*:latest"
else
mkdir -p build
cd build
cmake-cross -S .. -B . -DTESSESFRAMEWORK_NFPM_ARCH=$1 -DCMAKE_INSTALL_LIBDIR=lib/$2 -DCMAKE_BUILD_TYPE=Release
make -j`nproc`
make install DESTDIR=debian
cd debian
nfpm package -f ../nfpm.yaml -p deb
curl --user tesses50:$PACKAGE_AND_BREW \
--upload-file *.deb \
https://git.tesses.org/api/packages/tesses50/debian/pool/universal/main/upload
#debian/pool/bionic
cd ..
if [ "$1" = "386" ] || [ "$1" = "arm7" ]
then
cmake-cross -S .. -B . -DTESSESFRAMEWORK_NFPM_ARCH=$1 -DCMAKE_INSTALL_LIBDIR=lib32
else
cmake-cross -S .. -B . -DTESSESFRAMEWORK_NFPM_ARCH=$1 -DCMAKE_INSTALL_LIBDIR=lib64
fi
make install DESTDIR=fedora
cd fedora
nfpm package -f ../nfpm.yaml -p rpm
curl --user tesses50:$PACKAGE_AND_BREW \
--upload-file *.rpm \
https://git.tesses.org/api/packages/tesses50/rpm/upload
cd ..
cmake-cross -S .. -B . -DTESSESFRAMEWORK_NFPM_ARCH=$1 -DCMAKE_INSTALL_LIBDIR=lib
make install DESTDIR=arch
cd arch
nfpm package -f ../nfpm.yaml -p archlinux
curl --user tesses50:$PACKAGE_AND_BREW \
--upload-file *.pkg.tar.zst \
https://git.tesses.org/api/packages/tesses50/arch/core
mkdir -p ../../artifacts
tar czf ../../artifacts/tessesframework-$VERSION\-$1\.tar.gz -C usr/ .
fi

20
build-for-ppc.sh Normal file
View File

@@ -0,0 +1,20 @@
mkdir -p build
pushd build
cmake-cross -S .. -B . -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_BUILD_TYPE=Release
make -j`nproc`
mkdir -p /home/build/tf
chown build:build -R /home/build
make install DESTDIR=/home/build/tf/src
cp ppc-pkgbuild /home/build/tf/PKGBUILD
chmod 644 /home/build/tf/PKGBUILD
chown build:build -R /home/build/tf
pushd /home/build/tf
su build -c 'CARCH=powerpc makepkg -d'
curl --user tesses50:$PACKAGE_AND_BREW \
--upload-file *.pkg.tar.zst \
https://git.tesses.org/api/packages/tesses50/arch/core
popd
popd
mkdir -p artifacts
tar czf artifacts/tessesframework-$VERSION\-powerpc.tar.gz -C /home/build/tf/src/usr .

View File

@@ -1,5 +1,11 @@
# Changelog
## 0.0.6
Use my new toolchain, fix a bug on mac/freebsd
## 0.0.5
Fix win32 printing, fix my stupid json vulnerability
## 0.0.4
Overhaul cmake configuration, add console api, fix http code that caused issues with cgi-bin

View File

@@ -1,4 +1,7 @@
if(TESSESFRAMEWORK_ENABLE_EXAMPLES)
add_executable(start-my-website examples/start-my-website.cpp)
target_link_libraries(start-my-website PUBLIC tessesframework)
add_executable(echo-my-name examples/echo-my-name.cpp)
target_link_libraries(echo-my-name PUBLIC tessesframework)

View File

@@ -1,27 +1,40 @@
if(TESSESFRAMEWORK_ENABLE_MBED)
if(TESSESFRAMEWORK_FETCHCONTENT)
set(MBEDTLS_FATAL_WARNINGS OFF CACHE INTERNAL "For TessesFramework" FORCE)
set(ENABLE_TESTING OFF CACHE INTERNAL "For TessesFramework" FORCE)
set(ENABLE_PROGRAMS OFF CACHE INTERNAL "For TessesFramework" FORCE)
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build static libraries" FORCE)
if(NOT TESSESFRAMEWORK_STATIC)
set(CMAKE_POSITION_INDEPENDENT_CODE ON CACHE BOOL "Build with PIC" FORCE)
endif()
FetchContent_Declare(
mbedtls
URL https://downloads.tesses.net/cache/libraries/source/mbedtls-3.6.4.tar.bz2
)
if(TESSESFRAMEWORK_ENABLE_MBED AND TESSESFRAMEWORK_FETCHCONTENT)
set(MBEDTLS_FATAL_WARNINGS OFF CACHE INTERNAL "For TessesFramework" FORCE)
set(ENABLE_TESTING OFF CACHE INTERNAL "For TessesFramework" FORCE)
set(ENABLE_PROGRAMS OFF CACHE INTERNAL "For TessesFramework" FORCE)
if(TESSESFRAMEWORK_STATIC)
set(USE_STATIC_MBEDTLS_LIBRARY ON CACHE INTERNAL "For TessesFramework" FORCE)
set(USE_SHARED_MBEDTLS_LIBRARY OFF CACHE INTERNAL "For TessesFramework" FORCE)
else()
set(USE_STATIC_MBEDTLS_LIBRARY OFF CACHE INTERNAL "For TessesFramework" FORCE)
set(USE_SHARED_MBEDTLS_LIBRARY ON CACHE INTERNAL "For TessesFramework" FORCE)
endif()
if(NOT mbedtls_POPULATED)
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build static" FORCE)
if(NOT TESSESFRAMEWORK_STATIC)
set(CMAKE_POSITION_INDEPENDENT_CODE ON CACHE BOOL "Build PIC" FORCE)
set(CMAKE_SKIP_INSTALL_RULES ON)
set(DISABLE_PACKAGE_CONFIG_AND_INSTALL ON CACHE BOOL "" FORCE)
endif()
FetchContent_Populate(mbedtls)
if(NOT TESSESFRAMEWORK_STATIC)
install(CODE "set(CMAKE_INSTALL_LOCAL_ONLY TRUE)" ALL_COMPONENTS)
endif()
add_subdirectory(${mbedtls_SOURCE_DIR} ${mbedtls_BINARY_DIR})
if(NOT TESSESFRAMEWORK_STATIC)
set(CMAKE_SKIP_INSTALL_RULES OFF)
endif()
endif()
FetchContent_MakeAvailable(mbedtls)
else()
find_package(MbedTLS REQUIRED)
endif()
endif()

View File

@@ -46,7 +46,9 @@ endif()
if(TESSESFRAMEWORK_FETCHCONTENT)
target_link_libraries(tessesframework PRIVATE mbedtls mbedx509 mbedcrypto everest p256m)
if(TESSESFRAMEWORK_STATIC)
list(APPEND TessesFrameworkLibs mbedtls mbedx509 mbedcrypto everest p256m)
endif()
else()
target_link_libraries(tessesframework PRIVATE mbedtls mbedx509 mbedcrypto)

View File

@@ -14,3 +14,4 @@ option(TESSESFRAMEWORK_ENABLE_SETDATE "Enable setting date to file" ON)
option(TESSESFRAMEWORK_LOGTOFILE "TessesFramework Log to file" OFF)
option(TESSESFRAMEWORK_FETCHCONTENT "TessesFramework fetchcontent" ON)
option(TESSESFRAMEWORK_VENDERCERTCHAIN "Use the ca-certificates.crt in project rather than system" ON)
option(TESSESFRAMEWORK_NFPM_ARCH "Architecture for NFPM" "")

View File

@@ -1,3 +1,3 @@
set(TESSESFRAMEWORK_MAJOR_VERSION 0)
set(TESSESFRAMEWORK_MINOR_VERSION 0)
set(TESSESFRAMEWORK_PATCH_VERSION 4)
set(TESSESFRAMEWORK_PATCH_VERSION 6)

View File

@@ -0,0 +1,8 @@
#include "TessesFramework/TessesFramework.hpp"
int main(int argc, char **argv) {
Tesses::Framework::TF_Init();
Tesses::Framework::Platform::ShellFileOrUrl("https://tesses.net/");
return 0;
}

View File

@@ -20,60 +20,61 @@
#include <cstdio>
namespace Tesses::Framework {
enum class ConsoleColor {
CC_BLACK,
CC_RED,
CC_GREEN,
CC_YELLOW,
CC_BLUE,
CC_MAGENTA,
CC_CYAN,
CC_WHITE
};
enum class ClearBehaviour {
CB_CURSORANDBELOW,
CB_CURSORANDABOVE,
CB_ENTIRESCREEN
};
struct Console {
static bool IsTTY();
static std::pair<int,int> GetSize();
static void ProgressBar(double);
static void ProgressBar(int);
static void Write(std::string text);
static void WriteLine(std::string text);
static void WriteView(std::string_view text);
static void WriteLineView(std::string_view text);
static void Error(std::string text);
static void ErrorLine(std::string text);
static void ErrorView(std::string_view text);
static void ErrorLineView(std::string_view text);
static int Read();
static std::string ReadLine();
enum class ConsoleColor {
CC_BLACK,
CC_RED,
CC_GREEN,
CC_YELLOW,
CC_BLUE,
CC_MAGENTA,
CC_CYAN,
CC_WHITE
};
enum class ClearBehaviour {
CB_CURSORANDBELOW,
CB_CURSORANDABOVE,
CB_ENTIRESCREEN
};
struct Console {
static bool IsTTY();
static std::pair<int, int> GetSize();
static void ProgressBar(double);
static void ProgressBar(int);
static void Write(std::string text);
static void WriteLine(std::string text);
static void WriteView(std::string_view text);
static void WriteLineView(std::string_view text);
static void Error(std::string text);
static void ErrorLine(std::string text);
static void ErrorView(std::string_view text);
static void ErrorLineView(std::string_view text);
static int Read();
static std::string ReadLine();
static bool GetEcho();
static bool SetEcho(bool echo);
static bool GetCanonical();
static bool SetCanonical(bool can);
static bool GetSignals();
static bool SetSignals(bool sig);
static bool GetEcho();
static bool SetEcho(bool echo);
static bool GetCanonical();
static bool SetCanonical(bool can);
static bool GetSignals();
static bool SetSignals(bool sig);
static void SetPosition(int x, int y);
static void SetPosition(int x, int y);
static void SetBackgroundColor(ConsoleColor c, bool alt);
static void SetForegroundColor(ConsoleColor c, bool alt);
static void Clear();
static void MoveToHome();
static void ClearRetainPosition(ClearBehaviour clearBehaviour);
static void Flush();
static void SetBackgroundColor(ConsoleColor c, bool alt);
static void SetForegroundColor(ConsoleColor c, bool alt);
static void Clear();
static void MoveToHome();
static void ClearRetainPosition(ClearBehaviour clearBehaviour);
static void Reset();
static void SetInvertedColors(bool inverted);
static void Flush();
//returns std::string::npos if no tty
static size_t List(std::vector<std::string>& strs);
// returns std::string::npos if no tty
static size_t List(std::vector<std::string> &strs);
static std::string ReadPassword();
static std::string ReadPassword();
private:
static void WriteToStream(std::string_view text, bool isStderr);
};
}
private:
static void WriteToStream(std::string_view text, bool isStderr);
};
} // namespace Tesses::Framework

View File

@@ -68,4 +68,6 @@ class Process {
~Process();
};
void ShellFileOrUrl(std::string fileOrUrl);
} // namespace Tesses::Framework::Platform

172
nfpm.yaml.in Normal file
View File

@@ -0,0 +1,172 @@
# Name. (required)
name: tessesframework
# Architecture. (required)
# This will expand any env var you set in the field, e.g. arch: ${GOARCH}
# The architecture is specified using Go nomenclature (GOARCH) and translated
# to the platform specific equivalent. In order to manually set the architecture
# to a platform specific value, set `{format}.arch`.
# Examples: `all`, `amd64`, `386`, `arm5`, `arm6`, `arm7`, `arm64`, `mips`,
# `mipsle`, `mips64le`, `ppc64le`, `s390`, `riscv64`
arch: @TESSESFRAMEWORK_NFPM_ARCH@
# Platform.
# This will expand any env var you set in the field, e.g. platform: ${GOOS}
# This is only used by the rpm and deb packagers.
# Examples: `linux` (default), `darwin`
platform: linux
# Version. (required)
# This will expand any env var you set in the field, e.g. version: ${SEMVER}
# Some package managers, like deb, require the version to start with a digit.
# Hence, you should not prefix the version with 'v'.
version: @TESSESFRAMEWORK_MAJOR_VERSION@.@TESSESFRAMEWORK_MINOR_VERSION@.@TESSESFRAMEWORK_PATCH_VERSION@
# Version Schema allows you to specify how to parse the version string.
# Default is `semver`
# `semver` attempt to parse the version string as a valid semver version.
# The parser is lenient; it will strip a `v` prefix and will accept
# versions with fewer than 3 components, like `v1.2`.
# If parsing succeeds, then the version will be molded into a format
# compatible with the specific packager used.
# If parsing fails, then the version is used as-is.
# `none` skip trying to parse the version string and just use what is passed in
version_schema: semver
# Version Epoch.
# A package with a higher version epoch will always be considered newer.
# See: https://www.debian.org/doc/debian-policy/ch-controlfields.html#epochs-should-be-used-sparingly
epoch: 1
# Version Prerelease.
# Default is extracted from `version` if it is semver compatible.
# This is appended to the `version`, e.g. `1.2.3+beta1`. If the `version` is
# semver compatible, then this replaces the prerelease component of the semver.
prerelease: alpha
# Version Metadata (previously deb.metadata).
# Default is extracted from `version` if it is semver compatible.
# Setting metadata might interfere with version comparisons depending on the
# packager. If the `version` is semver compatible, then this replaces the
# version metadata component of the semver.
# version_metadata: git
# Version Release, aka revision.
# This will expand any env var you set in the field, e.g. release: ${VERSION_RELEASE}
# This is appended to the `version` after `prerelease`. This should be
# incremented if you release an updated package of the same upstream version,
# and it should reset to 1 when bumping the version.
release: 1
# Section.
# This is only used by the deb packager.
# See: https://www.debian.org/doc/debian-policy/ch-archive.html#sections
section: default
# Priority.
# Defaults to `optional` on deb
# Defaults to empty on rpm and apk
# See: https://www.debian.org/doc/debian-policy/ch-archive.html#priorities
priority: extra
# Maintainer. (required)
# This will expand any env var you set in the field, e.g. maintainer: ${GIT_COMMITTER_NAME} <${GIT_COMMITTER_EMAIL}>
# Defaults to empty on rpm and apk
# Leaving the 'maintainer' field unset will not be allowed in a future version
maintainer: Mike Nolan <tesses@tesses.net>
# Description.
# This will expand any env var you set in the field, e.g. description: ${DESCRIPTION}
# Defaults to `no description given`.
# Most packagers call for a one-line synopsis of the package. Some (like deb)
# also call for a multi-line description starting on the second line.
description: TessesFramework a library to make C++ easier for me, used in CrossLang
# Vendor.
# This will expand any env var you set in the field, e.g. vendor: ${VENDOR}
# This is only used by the rpm packager.
vendor: Tesses
# Package's homepage.
# This will expand any env var you set in the field, e.g. homepage: ${CI_PROJECT_URL}
homepage: https://git.tesses.org/tesses50/tessesframework
# License.
license: GPLv3
# Date to be used as mtime on internal files.
#
# Default is the value of $SOURCE_DATE_EPOCH (which should be an Unix time),
# or the current time.
# Read more about SOURCE_DATE_EPOCH at https://reproducible-builds.org/docs/source-date-epoch/
#mtime: "2009-11-10T23:00:00Z"
# Changelog YAML file, see: https://github.com/goreleaser/chglog
# changelog: "changelog.yaml"
# Disables globbing for files, config_files, etc.
# disable_globbing: false
# Packages it replaces. (overridable)
# This will expand any env var you set in the field, e.g. ${REPLACE_BLA}
# the env var approach can be used to account for differences in platforms
#replaces:
# - foobar
# - ${REPLACE_BLA}
# Packages it provides. (overridable)
# This will expand any env var you set in the field, e.g. ${PROVIDES_BLA}
# the env var approach can be used to account for differences in platforms
#provides:
# - bar
# - ${PROVIDES_BLA}
# Dependencies. (overridable)
# This will expand any env var you set in the field, e.g. ${DEPENDS_NGINX}
# the env var approach can be used to account for differences in platforms
# e.g. rhel needs nginx >= 1:1.18 and deb needs nginx (>= 1.18.0)
#depends:
# - git
# - ${DEPENDS_NGINX}
# Recommended packages. (overridable)
# This will expand any env var you set in the field, e.g. ${RECOMMENDS_BLA}
# the env var approach can be used to account for differences in platforms
#recommends:
# - golang
# - ${RECOMMENDS_BLA}
# Suggested packages. (overridable)
# This will expand any env var you set in the field, e.g. ${SUGGESTS_BLA}
# the env var approach can be used to account for differences in platforms
#suggests:
# - bzr
# Packages it conflicts with. (overridable)
# This will expand any env var you set in the field, e.g. ${CONFLICTS_BLA}
# the env var approach can be used to account for differences in platforms
#conflicts:
# - mercurial
# - ${CONFLICTS_BLA}
# Contents to add to the package
# This can be binaries or any other files.
contents:
- src: usr/
dst: /usr/
type: tree
# Umask to be used on files without explicit mode set.
#
# By default, nFPM will inherit the mode of the original file that's being
# added.
# This may lead to issues if these files are checkout out in Git, for example,
# as it won't keep all the permissions on fresh checkouts, or if the local
# system has a problematic umask setting.
#
# This setting allows to set the umask for all files that are added to the
# package without a specific file_info.mode set.
#
# Default: 0o002 (will remove world-writable permissions)
umask: 0o002

View File

@@ -4,7 +4,7 @@ set(PKGCONFIG_LIBDIR "\${prefix}/${CMAKE_INSTALL_LIBDIR}")
set(PKGCONFIG_PROJECT_DESCRIPTION "A cross platform wrapper library")
set(PKGCONFIG_PROJECT_HOMEPAGE_URL "https://git.tesses.org/tessesframework")
if(TESSESFRAMEWORK_ENABLE_MBED)
if(TESSESFRAMEWORK_ENABLE_MBED AND NOT (TESSESFRAMEWORK_FETCHCONTENT AND NOT TESSESFRAMEWORK_STATIC))
set(PKGCONFIG_DEPS "Requires: mbedtls")
else()
set(PKGCONFIG_DEPS "")

View File

@@ -7,5 +7,7 @@ Description: @PKGCONFIG_PROJECT_DESCRIPTION@
URL: @PKGCONFIG_PROJECT_HOMEPAGE_URL@
Version: @PROJECT_VERSION@
@PKGCONFIG_DEPS@
Cflags: -I"${includedir}"
Libs: -L"${libdir}" -ltessesframework

21
ppc-pkgbuild.in Normal file
View File

@@ -0,0 +1,21 @@
# Maintainer: Mike Nolan <tesses@tesses.net>
pkgname=tessesframework # '-bzr', '-git', '-hg' or '-svn'
pkgver=@TESSESFRAMEWORK_MAJOR_VERSION@.@TESSESFRAMEWORK_MINOR_VERSION@.@TESSESFRAMEWORK_PATCH_VERSION@
pkgrel=1
pkgdesc="TessesFramework a library to make C++ easier for me, used in CrossLang"
arch=('powerpc')
url="https://git.tesses.org/tesses50/tessesframework"
license=('GPLv3')
groups=()
depends=()
makedepends=('git' 'cmake' 'make' 'base-devel' 'wget') # 'bzr', 'git', 'mercurial' or 'subversion'
install=
source=()
noextract=()
sha256sums=()
options=(!buildflags !strip)
package() {
cp -r "${srcdir}/"* "${pkgdir}/"
}

View File

@@ -1,19 +1,19 @@
/*
TessesFramework a library to make C++ easier for me, used in CrossLang:
TessesFramework a library to make C++ easier for me, used in CrossLang:
https://git.tesses.org/tesses50/crosslang Copyright (C) 2026 Mike Nolan
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "TessesFramework/Console.hpp"
@@ -34,6 +34,58 @@
namespace Tesses::Framework {
class ConsoleHelpers {
bool canon;
bool echo;
bool signals;
#if defined(_WIN32)
WORD colorFlags;
#endif
public:
ConsoleHelpers() {
canon = Console::GetCanonical();
echo = Console::GetEcho();
signals = Console::GetSignals();
#if defined(_WIN32)
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
if (hConsole == INVALID_HANDLE_VALUE)
return;
CONSOLE_SCREEN_BUFFER_INFO bi;
GetConsoleScreenBufferInfo(hConsole, &bi);
colorFlags = bi.wAttributes;
#endif
}
void reset() {
#if defined(_WIN32)
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
if (hConsole == INVALID_HANDLE_VALUE)
return;
SetConsoleTextAttribute(hConsole, colorFlags);
#else
if (Console::IsTTY()) {
printf("\x1b[0m");
fflush(stdout);
}
#endif
}
~ConsoleHelpers() {
Console::SetCanonical(canon);
Console::SetEcho(echo);
Console::SetSignals(signals);
reset();
}
};
ConsoleHelpers consoleHelpers;
size_t Console::List(std::vector<std::string> &strs) {
if (!IsTTY())
return std::string::npos;
@@ -54,11 +106,9 @@ size_t Console::List(std::vector<std::string> &strs) {
for (int item = 0; item < size.second; ++item) {
if (item == offsetInPage) {
Console::SetBackgroundColor(ConsoleColor::CC_WHITE, true);
Console::SetForegroundColor(ConsoleColor::CC_BLACK, false);
Console::SetInvertedColors(true);
} else {
Console::SetBackgroundColor(ConsoleColor::CC_BLACK, false);
Console::SetForegroundColor(ConsoleColor::CC_WHITE, true);
Console::SetInvertedColors(false);
}
size_t myOffset = (size_t)item + page * (size.second);
@@ -72,8 +122,7 @@ size_t Console::List(std::vector<std::string> &strs) {
}
}
Console::SetBackgroundColor(ConsoleColor::CC_BLACK, false);
Console::SetForegroundColor(ConsoleColor::CC_WHITE, true);
Console::SetInvertedColors(false);
int code = Console::Read();
@@ -102,49 +151,82 @@ size_t Console::List(std::vector<std::string> &strs) {
}
Console::SetEcho(echo);
Console::SetCanonical(canonical);
Console::SetBackgroundColor(ConsoleColor::CC_BLACK, false);
Console::SetForegroundColor(ConsoleColor::CC_WHITE, true);
Console::SetInvertedColors(false);
return i;
}
void Console::Reset() { consoleHelpers.reset(); }
#if defined(_WIN32)
static bool vt100_inverted = false;
static void _setcol(ConsoleColor col, bool alt, bool bg) {
if (bg) {
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
if (hConsole == INVALID_HANDLE_VALUE)
return;
CONSOLE_SCREEN_BUFFER_INFO bi;
GetConsoleScreenBufferInfo(hConsole, &bi);
bi.wAttributes &= ~(BACKGROUND_RED | BACKGROUND_GREEN |
BACKGROUND_BLUE | BACKGROUND_INTENSITY);
if (col == ConsoleColor::CC_RED || col == ConsoleColor::CC_YELLOW ||
col == ConsoleColor::CC_MAGENTA || col == ConsoleColor::CC_WHITE)
bi.wAttributes |= BACKGROUND_RED;
if (col == ConsoleColor::CC_GREEN || col == ConsoleColor::CC_YELLOW ||
col == ConsoleColor::CC_CYAN || col == ConsoleColor::CC_WHITE)
bi.wAttributes |= BACKGROUND_GREEN;
if (col == ConsoleColor::CC_BLUE || col == ConsoleColor::CC_CYAN ||
col == ConsoleColor::CC_MAGENTA || col == ConsoleColor::CC_WHITE)
bi.wAttributes |= BACKGROUND_BLUE;
if (alt)
bi.wAttributes |= BACKGROUND_INTENSITY;
SetConsoleTextAttribute(hConsole, bi.wAttributes);
} else {
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
if (hConsole == INVALID_HANDLE_VALUE)
return;
CONSOLE_SCREEN_BUFFER_INFO bi;
GetConsoleScreenBufferInfo(hConsole, &bi);
bi.wAttributes &= ~(FOREGROUND_RED | FOREGROUND_GREEN |
FOREGROUND_BLUE | FOREGROUND_INTENSITY);
if (col == ConsoleColor::CC_RED || col == ConsoleColor::CC_YELLOW ||
col == ConsoleColor::CC_MAGENTA || col == ConsoleColor::CC_WHITE)
bi.wAttributes |= FOREGROUND_RED;
if (col == ConsoleColor::CC_GREEN || col == ConsoleColor::CC_YELLOW ||
col == ConsoleColor::CC_CYAN || col == ConsoleColor::CC_WHITE)
bi.wAttributes |= FOREGROUND_GREEN;
if (col == ConsoleColor::CC_BLUE || col == ConsoleColor::CC_CYAN ||
col == ConsoleColor::CC_MAGENTA || col == ConsoleColor::CC_WHITE)
bi.wAttributes |= FOREGROUND_BLUE;
if (alt)
bi.wAttributes |= FOREGROUND_INTENSITY;
SetConsoleTextAttribute(hConsole, bi.wAttributes);
}
}
#endif
void Console::SetForegroundColor(ConsoleColor col, bool alt) {
if (!IsTTY())
return;
#if __has_include(<termios.h>)
if (alt) {
printf("\x1b[%im", ((int)col) + 90); // this should be Write
} else {
printf("\x1b[%im", ((int)col) + 30); // this too
}
#elif defined(_WIN32)
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
if (hConsole == INVALID_HANDLE_VALUE)
return;
CONSOLE_SCREEN_BUFFER_INFO bi;
#if defined(_WIN32)
GetConsoleScreenBufferInfo(hConsole, &bi);
bi.wAttributes &= ~(FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE |
FOREGROUND_INTENSITY);
if (col == ConsoleColor::CC_RED || col == ConsoleColor::CC_YELLOW ||
col == ConsoleColor::CC_MAGENTA || col == ConsoleColor::CC_WHITE)
bi.wAttributes |= FOREGROUND_RED;
if (col == ConsoleColor::CC_GREEN || col == ConsoleColor::CC_YELLOW ||
col == ConsoleColor::CC_CYAN || col == ConsoleColor::CC_WHITE)
bi.wAttributes |= FOREGROUND_GREEN;
if (col == ConsoleColor::CC_BLUE || col == ConsoleColor::CC_CYAN ||
col == ConsoleColor::CC_MAGENTA || col == ConsoleColor::CC_WHITE)
bi.wAttributes |= FOREGROUND_BLUE;
if (alt)
bi.wAttributes |= FOREGROUND_INTENSITY;
SetConsoleTextAttribute(hConsole, bi.wAttributes);
_setcol(col, alt, vt100_inverted);
#else
if (alt) {
@@ -158,40 +240,9 @@ void Console::SetForegroundColor(ConsoleColor col, bool alt) {
void Console::SetBackgroundColor(ConsoleColor col, bool alt) {
if (!IsTTY())
return;
#if __has_include(<termios.h>)
if (alt) {
printf("\x1b[%im", ((int)col) + 100); // this should be Write
} else {
printf("\x1b[%im", ((int)col) + 40); // this too
}
#elif defined(_WIN32)
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
if (hConsole == INVALID_HANDLE_VALUE)
return;
CONSOLE_SCREEN_BUFFER_INFO bi;
GetConsoleScreenBufferInfo(hConsole, &bi);
bi.wAttributes &= ~(BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE |
BACKGROUND_INTENSITY);
if (col == ConsoleColor::CC_RED || col == ConsoleColor::CC_YELLOW ||
col == ConsoleColor::CC_MAGENTA || col == ConsoleColor::CC_WHITE)
bi.wAttributes |= BACKGROUND_RED;
if (col == ConsoleColor::CC_GREEN || col == ConsoleColor::CC_YELLOW ||
col == ConsoleColor::CC_CYAN || col == ConsoleColor::CC_WHITE)
bi.wAttributes |= BACKGROUND_GREEN;
if (col == ConsoleColor::CC_BLUE || col == ConsoleColor::CC_CYAN ||
col == ConsoleColor::CC_MAGENTA || col == ConsoleColor::CC_WHITE)
bi.wAttributes |= BACKGROUND_BLUE;
if (alt)
bi.wAttributes |= BACKGROUND_INTENSITY;
SetConsoleTextAttribute(hConsole, bi.wAttributes);
#if defined(_WIN32)
_setcol(col, alt, !vt100_inverted);
#else
if (alt) {
printf("\x1b[%im", ((int)col) + 100); // this should be Write
@@ -201,6 +252,41 @@ void Console::SetBackgroundColor(ConsoleColor col, bool alt) {
#endif
}
void Console::SetInvertedColors(bool inverted) {
if (!IsTTY())
return;
#if defined(_WIN32)
if (inverted != vt100_inverted) {
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
if (hConsole == INVALID_HANDLE_VALUE)
return;
CONSOLE_SCREEN_BUFFER_INFO bi;
GetConsoleScreenBufferInfo(hConsole, &bi);
bi.wAttributes =
(bi.wAttributes & 0xFF00) |
((bi.wAttributes & (FOREGROUND_RED | FOREGROUND_GREEN |
FOREGROUND_BLUE | FOREGROUND_INTENSITY))
<< 4) |
((bi.wAttributes & (BACKGROUND_RED | BACKGROUND_GREEN |
BACKGROUND_BLUE | BACKGROUND_INTENSITY)) >>
4);
SetConsoleTextAttribute(hConsole, bi.wAttributes);
}
vt100_inverted = inverted;
#else
if (inverted)
Write("\x1b[7m");
else
Write("\x1b[27m");
Flush();
#endif
}
bool Console::SetEcho(bool echo) {
if (!IsTTY())
return false;
@@ -607,24 +693,33 @@ void Console::WriteToStream(std::string_view view, bool isStderr) {
}
if (text.size() > 0 && text.back() == 'm') {
try {
auto num =
std::stol(text.substr(0, text.size() - 1));
if (num >= 30 && num <= 37) {
SetForegroundColor((ConsoleColor)(num - 30),
false);
} else if (num >= 40 && num <= 47) {
SetBackgroundColor((ConsoleColor)(num - 40),
false);
} else if (num >= 90 && num <= 97) {
SetForegroundColor((ConsoleColor)(num - 90),
true);
} else if (num >= 100 && num <= 107) {
SetBackgroundColor((ConsoleColor)(num - 100),
true);
if (text.size() == 1) {
consoleHelpers.reset();
} else {
try {
auto num =
std::stol(text.substr(0, text.size() - 1));
if (num == 0)
consoleHelpers.reset();
if (num == 7)
Console::SetInvertedColors(true);
if (num == 27)
Console::SetInvertedColors(false);
if (num >= 30 && num <= 37) {
SetForegroundColor((ConsoleColor)(num - 30),
false);
} else if (num >= 40 && num <= 47) {
SetBackgroundColor((ConsoleColor)(num - 40),
false);
} else if (num >= 90 && num <= 97) {
SetForegroundColor((ConsoleColor)(num - 90),
true);
} else if (num >= 100 && num <= 107) {
SetBackgroundColor(
(ConsoleColor)(num - 100), true);
}
} catch (...) {
}
} catch (...) {
}
}

View File

@@ -691,4 +691,38 @@ std::shared_ptr<Tesses::Framework::Streams::Stream> Process::GetStderrStream() {
#endif
}
void ShellFileOrUrl(std::string fileOrUrl) {
#if defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__)
throw std::runtime_error("Platform not supported");
#elif !defined(TESSESFRAMEWORK_ENABLE_PROCESS)
throw std::runtime_error("Process not enabled");
#elif defined(_WIN32)
auto exec = Tesses::Framework::Platform::Environment::GetRealExecutablePath(
(std::string) "cmd");
Process p(exec.ToString(), {"cmd", "/c", "start", fileOrUrl});
if (p.Start())
if (p.WaitForExit() != 0)
throw std::runtime_error("Exit code did not indicate success");
#elif defined(__APPLE__)
auto exec = Tesses::Framework::Platform::Environment::GetRealExecutablePath(
(std::string) "open");
Process p(exec.ToString(), {"open", fileOrUrl});
if (p.Start())
if (p.WaitForExit() != 0)
throw std::runtime_error("Exit code did not indicate success");
#else
if (fileOrUrl == "--help" || fileOrUrl == "--version" ||
fileOrUrl == "--manual")
throw std::invalid_argument(
"Invalid argument \"" + fileOrUrl +
"\", this function expects a file or url not xdg-open flags");
auto exec = Tesses::Framework::Platform::Environment::GetRealExecutablePath(
(std::string) "xdg-open");
Process p(exec.ToString(), {"xdg-open", fileOrUrl});
if (p.Start())
if (p.WaitForExit() != 0)
throw std::runtime_error("Exit code did not indicate success");
#endif
}
} // namespace Tesses::Framework::Platform

View File

@@ -15,9 +15,9 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "TessesFramework/Serialization/Json.hpp"
#include "TessesFramework/Http/HttpUtils.hpp"
#include "TessesFramework/TessesFramework.hpp"
#include <functional>
#include "TessesFramework/Common.hpp"
@@ -129,6 +129,7 @@ JToken Json::Decode(std::string str) {
v |= HttpUtils::HexToNibble(str[i])
<< ((3 - i2) * 4);
}
i--;
uint32_t v2 = v;
@@ -274,7 +275,8 @@ JToken Json::Decode(std::string str) {
break;
} else {
throw std::runtime_error("Invalid JSON object.");
throw std::runtime_error("Invalid JSON object. " +
std::to_string(tokenIndex));
}
}
return obj;

View File

@@ -510,7 +510,7 @@ std::string TF_GetExecutableName() {
if (sysctl(mib, 4, path.data(), &len, NULL, 0) < 0) {
return "";
}
path.resize(len-1);
return path;
#elif defined(__NetBSD__)
auto path = Filesystem::LocalFS->ReadLink(
@@ -523,15 +523,18 @@ std::string TF_GetExecutableName() {
return path.ToString();
#elif TARGET_OS_MAC && !TARGET_OS_IPHONE
std::string path;
path.resize(1024);
path.resize(1025);
uint32_t bufsize = (uint32_t)path.size();
if (_NSGetExecutablePath(path.data(), &bufsize) == 0) {
path.resize(bufsize);
path.resize(bufsize-1);
return path;
} else {
path.resize(bufsize);
if (_NSGetExecutablePath(path.data(), &bufsize) == 0)
{
path.resize(bufsize-1);
return path;
}
}
#endif