Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,20 @@ coverage/
.ddev/.homeadditions
.ddev/.ddev-docker-compose-full.yaml
Documentation-GENERATED-temp/

# Exclude large test files (regenerate with generator script)
Build/test-data/test_100mb.textdb_import.xlf
Resources/Private/Language/massive.textdb_import.xlf

# Exclude profiling dumps and large debugging files
Build/scripts/cachegrind.out.*.gz
*.cachegrind

# Serena MCP session data (user-specific)
.serena/

# Claude Code documentation (local development notes)
claudedocs/

# Test files (regenerate with Build/scripts/generate-test-xliff.php)
Build/test-data/
38 changes: 38 additions & 0 deletions Build/FunctionalTests.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
bootstrap="../.build/vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTestsBootstrap.php"
cacheDirectory="../.build/.phpunit.cache.functional"
executionOrder="depends,defects"
requireCoverageMetadata="false"
beStrictAboutOutputDuringTests="true"
failOnRisky="true"
failOnWarning="true"
backupGlobals="true"
colors="true"
>
<testsuites>
<testsuite name="nr-textdb-functional">
<directory>../Tests/Functional</directory>
</testsuite>
</testsuites>

<php>
<ini name="display_errors" value="1"/>
<env name="TYPO3_CONTEXT" value="Testing"/>
<env name="TYPO3_PATH_ROOT" value="../.build/public"/>
<env name="typo3DatabaseDriver" value="pdo_sqlite"/>
</php>

<logging>
<junit outputFile="../.build/phpunit-functional-report.xml"/>
</logging>

<source restrictDeprecations="true"
restrictNotices="true"
restrictWarnings="true">
<include>
<directory>../Classes</directory>
</include>
</source>
</phpunit>
10 changes: 10 additions & 0 deletions Build/Rust/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Rust build artifacts
/target/
Cargo.lock

# IDE files
.idea/
.vscode/
*.swp
*.swo
*~
37 changes: 37 additions & 0 deletions Build/Rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[package]
name = "xliff_parser"
version = "1.0.0"
edition = "2021"
authors = ["TYPO3 TextDB Contributors"]
description = "High-performance XLIFF parser for TYPO3 TextDB extension"
license = "GPL-3.0-or-later"

[lib]
crate-type = ["cdylib"] # Creates shared library (.so/.dll/.dylib)
name = "xliff_parser"

[dependencies]
quick-xml = { version = "0.36", features = ["serialize"] }
libc = "0.2"

# Database support (MySQL/MariaDB for TYPO3)
mysql = "25.0"
# Connection pooling
deadpool = "0.12"

# Serialization
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"

# Performance optimization
bumpalo = "3.14" # Arena allocator for reduced allocations

[profile.release]
opt-level = 3 # Maximum optimization
lto = true # Link-time optimization
codegen-units = 1 # Better optimization, slower compile
strip = true # Remove debug symbols
panic = "abort" # Smaller binary size

[profile.dev]
opt-level = 0
120 changes: 120 additions & 0 deletions Build/Rust/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
.PHONY: help build build-release clean test install check-deps generate-header build-all

# Default target
.DEFAULT_GOAL := help

# Detect platform
UNAME_S := $(shell uname -s)
UNAME_M := $(shell uname -m)

# Library naming
ifeq ($(UNAME_S),Linux)
LIB_NAME = libxliff_parser.so
PLATFORM_DIR = linux64
ifeq ($(UNAME_M),aarch64)
PLATFORM_DIR = linux-arm64
endif
else ifeq ($(UNAME_S),Darwin)
LIB_NAME = libxliff_parser.dylib
PLATFORM_DIR = darwin64
ifeq ($(UNAME_M),arm64)
PLATFORM_DIR = darwin-arm64
endif
else ifeq ($(OS),Windows_NT)
LIB_NAME = xliff_parser.dll
PLATFORM_DIR = win64
endif

# Paths
TARGET_DIR = target
OUTPUT_DIR = ../../Resources/Private/Bin/$(PLATFORM_DIR)
HEADER_FILE = xliff_parser.h

help: ## Show this help message
@echo 'Usage: make [target]'
@echo ''
@echo 'Available targets:'
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}'

check-deps: ## Check required dependencies
@command -v cargo >/dev/null 2>&1 || { echo "Error: cargo not found. Install Rust from https://rustup.rs/"; exit 1; }
@command -v cbindgen >/dev/null 2>&1 || { echo "Warning: cbindgen not found. Run: cargo install cbindgen"; }
@echo "βœ“ Dependencies OK"

build: check-deps ## Build debug version
cargo build

build-release: check-deps ## Build optimized release version
cargo build --release

generate-header: ## Generate C header file
@command -v cbindgen >/dev/null 2>&1 || { echo "Installing cbindgen..."; cargo install cbindgen; }
cbindgen --config cbindgen.toml --crate xliff_parser --output $(HEADER_FILE)
@echo "Generated header: $(HEADER_FILE)"

test: ## Run tests
cargo test
cargo test --release

clean: ## Clean build artifacts
cargo clean
rm -f $(HEADER_FILE)
rm -rf ../../Resources/Private/Bin/*/

install: build-release generate-header ## Install library to extension directory
@echo "Installing to: $(OUTPUT_DIR)"
@mkdir -p $(OUTPUT_DIR)
@cp $(TARGET_DIR)/release/$(LIB_NAME) $(OUTPUT_DIR)/
@cp $(HEADER_FILE) ../../Build/Rust/
@echo "βœ“ Installed: $(OUTPUT_DIR)/$(LIB_NAME)"
@echo "βœ“ Header: ../../Build/Rust/$(HEADER_FILE)"

# Cross-compilation targets
build-linux-x64: ## Cross-compile for Linux x86_64
cargo build --release --target x86_64-unknown-linux-gnu
@mkdir -p ../../Resources/Private/Bin/linux64
@cp target/x86_64-unknown-linux-gnu/release/libxliff_parser.so ../../Resources/Private/Bin/linux64/

build-linux-arm64: ## Cross-compile for Linux ARM64
cargo build --release --target aarch64-unknown-linux-gnu
@mkdir -p ../../Resources/Private/Bin/linux-arm64
@cp target/aarch64-unknown-linux-gnu/release/libxliff_parser.so ../../Resources/Private/Bin/linux-arm64/

build-macos-x64: ## Cross-compile for macOS Intel
cargo build --release --target x86_64-apple-darwin
@mkdir -p ../../Resources/Private/Bin/darwin64
@cp target/x86_64-apple-darwin/release/libxliff_parser.dylib ../../Resources/Private/Bin/darwin64/

build-macos-arm64: ## Cross-compile for macOS Apple Silicon
cargo build --release --target aarch64-apple-darwin
@mkdir -p ../../Resources/Private/Bin/darwin-arm64
@cp target/aarch64-apple-darwin/release/libxliff_parser.dylib ../../Resources/Private/Bin/darwin-arm64/

build-windows-x64: ## Cross-compile for Windows x64
cargo build --release --target x86_64-pc-windows-msvc
@mkdir -p ../../Resources/Private/Bin/win64
@cp target/x86_64-pc-windows-msvc/release/xliff_parser.dll ../../Resources/Private/Bin/win64/

build-all: generate-header build-linux-x64 build-linux-arm64 build-macos-x64 build-macos-arm64 build-windows-x64 ## Build for all platforms
@echo "βœ“ Built for all platforms"

# Development helpers
dev: build ## Build and run tests in development mode
cargo test

watch: ## Watch for changes and rebuild
cargo watch -x build -x test

bench: ## Run benchmarks
cargo bench

size: build-release ## Show library size
@ls -lh $(TARGET_DIR)/release/$(LIB_NAME)

# CI/CD helpers
ci-test: check-deps ## Run tests in CI mode
cargo test --release --verbose

ci-build: check-deps generate-header build-release ## Build for CI
@echo "Build complete for $(PLATFORM_DIR)"
Loading
Loading