Browse Source

Add Oniguruma regular expression library

master
Macoy Madson 8 months ago
parent
commit
ce523d0b30
  1. 3
      ReadMe.org
  2. 80
      src/Oniguruma.cake
  3. 3
      test/src/GameLibTests.cake

3
ReadMe.org

@ -91,6 +91,7 @@ Here are the known compatibility results, where blank means untested/unknown:
| Module | Linux x86_64 | Linux Arm v7 | Windows x64 | macOS |
|-----------------------------+--------------+--------------+-------------+-------|
| Allocator.cake | Yes | Yes | Yes | Yes |
| Aubio.cake | Yes | Probably | | |
| AutoTest.cake | Yes | Yes | Yes | Yes |
| Config_ZigCompile.cake | Yes | | | |
@ -108,6 +109,7 @@ Here are the known compatibility results, where blank means untested/unknown:
| Math.cake | Yes | Yes | Yes | Yes |
| Ogre.cake | Yes | | | |
| OgreInitialize.cake | Yes | | | |
| Oniguruma.cake | Yes | | | |
| OpenGL.cake | Yes | No[1] | Yes | |
| ProfilerAutoInstrument.cake | Yes | Yes | Yes | Yes |
| ProfilerNull.cake | Yes | Yes | Yes | Yes |
@ -136,6 +138,7 @@ The following modules will automatically download their dependencies if missing:
- Math.cake
- Ogre.cake
- OgreInitialize.cake
- Oniguruma.cake
- OpenGL.cake
- Raylib.cake
- SDL.cake

80
src/Oniguruma.cake

@ -0,0 +1,80 @@
;; Oniguruma: a regular expression engine with multiple encodings supported
(add-cakelisp-search-directory "Dependencies/cakelisp/runtime")
(import "CHelpers.cake" "BuildTools.cake" "Dependencies.cake")
(export-and-evaluate
(add-c-search-directory-module "cakelisp_cache/OnigurumaInstallDir/include")
(c-import "oniguruma.h"))
(comptime-cond
('auto-test
(defun test--oniguruma (&return int)
(var encodings ([] OnigEncoding) (array ONIG_ENCODING_UTF8))
(onig_initialize encodings (array-size encodings))
(onig_end)
(return 0))))
(defun-comptime build-oniguruma (manager (& ModuleManager) module (* Module) &return bool)
;; Already built?
;; We could enhance this by checking for modifications, but that's pretty rare
(when (and (fileExists "cakelisp_cache/OnigurumaInstallDir/lib/libonig.a"))
(return true))
(Log "Oniguruma: Building via Configure and Make\n")
(var working-dir (* (const char)) "cakelisp_cache/OnigurumaBuildDir")
(makeDirectory working-dir)
(var output-dir (* (const char)) "cakelisp_cache/OnigurumaInstallDir")
(makeDirectory output-dir)
(var configure-output-prefix ([] MAX_PATH_LENGTH char) (array 0))
(scope ;; Output must be absolute directory
(var absolute-output-path (* (const char))
(makeAbsolutePath_Allocated null output-dir))
(unless absolute-output-path
(Logf "error: failed to make Oniguruma output directory '%s'\n" output-dir)
(return false))
(PrintfBuffer configure-output-prefix "--prefix=%s" absolute-output-path)
(free (type-cast absolute-output-path (* void))))
(run-process-sequential-or
("autoreconf" "-vfi" :in-directory "Dependencies/oniguruma")
(Log
"failed at Oniguruma autoreconf step. This requires autoconf to execute.")
(return false))
(run-process-sequential-or
("sh" "../../Dependencies/oniguruma/configure" configure-output-prefix :in-directory working-dir)
(Log
"failed at Oniguruma configure step. This requires a sh/bash-style shell to execute.")
(return false))
(run-process-sequential-or
("make" "--jobs=8" :in-directory working-dir)
(Log "failed at Oniguruma make. This tool requires Makefile support.")
(return false))
(run-process-sequential-or
("make" "install" :in-directory working-dir)
(Log
"failed at Oniguruma make install. Was there a configuration issue with --prefix?")
(return false))
;; One final to check to ensure everything's good to go
(unless (fileExists "cakelisp_cache/OnigurumaInstallDir/lib/libonig.a")
(Log
"error: Raylib build sequence completed, but files are not where expected. Is there an issue
with the configuration?\nFile expected:\n\tcakelisp_cache/OnigurumaInstallDir/lib/libonig.a\n")
(return false))
(return true))
(add-compile-time-hook-module pre-build build-oniguruma)
(add-static-link-objects "cakelisp_cache/OnigurumaInstallDir/lib/libonig.a")
(add-dependency-git-submodule
clone-oniguruma
"https://github.com/kkos/oniguruma.git"
"Dependencies/oniguruma")

3
test/src/GameLibTests.cake

@ -54,7 +54,8 @@
"../src/AutoTest.cake" "../src/Introspection.cake"
"../src/Dictionary.cake" "../src/DynamicArray.cake"
"../src/TaskSystem.cake" "../src/Image.cake" "../src/DataBundle.cake"
"../src/TinyCCompiler.cake" "../src/FreeType.cake" "../src/Allocator.cake")))
"../src/TinyCCompiler.cake" "../src/FreeType.cake" "../src/Allocator.cake"
"../src/Oniguruma.cake")))
(test-opengl-only
(gamelib-run-test

Loading…
Cancel
Save