Browse Source

Add OpenSSL and Curl libraries

I mainly have my eye on downloading files for an automatic update
system.
master
Macoy Madson 9 months ago
parent
commit
2fca3b70ba
  1. 4
      ReadMe.org
  2. 113
      src/Curl.cake
  3. 75
      src/OpenSSL.cake
  4. 4
      src/Raylib.cake
  5. 8
      test/src/GameLibTests.cake

4
ReadMe.org

@ -97,6 +97,7 @@ Here are the known compatibility results, where blank means untested/unknown:
| Config_ZigCompile.cake | Yes | | | |
| Config_ZigWindows.cake | Yes | | | |
| Cryptography.cake | Yes | | | |
| Curl.cake | Yes | | | |
| DataBundle.cake | Yes | Yes | Yes | |
| Dependencies.cake | Yes | Yes | Yes | |
| Dictionary.cake | Yes | Yes | Yes | Yes |
@ -112,6 +113,7 @@ Here are the known compatibility results, where blank means untested/unknown:
| OgreInitialize.cake | Yes | | | |
| Oniguruma.cake | Yes | | Yes | |
| OpenGL.cake | Yes | No[1] | Yes | |
| OpenSSL.cake | Yes | | | |
| ProfilerAutoInstrument.cake | Yes | Yes | Yes | Yes |
| ProfilerNull.cake | Yes | Yes | Yes | Yes |
| Raylib.cake | Yes | | | |
@ -131,6 +133,7 @@ The following modules will automatically download their dependencies if missing:
- Aubio.cake
- Cryptography.cake
- Curl.cake
- ZigCompile.cake[3]
- Dictionary.cake
- DynamicArray.cake
@ -142,6 +145,7 @@ The following modules will automatically download their dependencies if missing:
- OgreInitialize.cake
- Oniguruma.cake
- OpenGL.cake
- OpenSSL.cake
- Raylib.cake
- SDL.cake
- STB.cake

113
src/Curl.cake

@ -0,0 +1,113 @@
;; Curl.cake: Access curl for various networking tasks
;; NOTE: OpenSSL.cake must be imported before Curl so that it is built before curl builds
(add-cakelisp-search-directory "Dependencies/cakelisp/runtime")
(import "CHelpers.cake" "BuildTools.cake" "Dependencies.cake")
(export-and-evaluate
(add-c-search-directory-module "cakelisp_cache/CurlInstall/include/curl")
(c-import "curl.h"))
(comptime-cond
('auto-test
(defun test--curl (&return int)
(return 0))))
;;
;; Building
;;
;; TODO Move into BuildTools.cake
(defun-comptime format-absolute-path-into-buffer (buffer (* char) buffer-size size_t
prefix (* (const char))
relative-path (* (const char)) &return bool)
(var absolute-output-path (* (const char))
(makeAbsolutePath_Allocated null relative-path))
(unless absolute-output-path
(return false))
;; Allow passing in null for prefix
(var format-prefix (* (const char)) (? prefix prefix ""))
(SafeSnprintf buffer buffer-size "%s%s" format-prefix absolute-output-path)
(free (type-cast absolute-output-path (* void)))
(return true))
(defun-comptime build-curl (manager (& ModuleManager) module (* Module) &return bool)
(comptime-cond ('Windows
(comptime-error "Must port CURL to Windows.")))
;; Already built?
;; We could enhance this by checking for modifications, but that's pretty rare
(when (and (fileExists "cakelisp_cache/CurlInstall/lib/libcurl.a"))
(return true))
(Log "Curl: Building via Autotools and Make\n")
(var curl-build-dir (* (const char)) "cakelisp_cache/CurlBuild")
(makeDirectory curl-build-dir)
(var curl-install-dir (* (const char)) "cakelisp_cache/CurlInstall")
(makeDirectory curl-install-dir)
(run-process-sequential-or
("libtoolize" :in-directory "Dependencies/curl")
(Log "failed at Curl libtoolize. This requires libtoolize to execute.\n")
(return false))
(run-process-sequential-or
("aclocal" :in-directory "Dependencies/curl")
(Log "failed at Curl aclocal step. This requires aclocal to execute.\n")
(return false))
(run-process-sequential-or
("autoconf" :in-directory "Dependencies/curl")
(Log "failed at Curl autoconf step. This requires autoconf to execute.\n")
(return false))
(run-process-sequential-or
("autoheader" :in-directory "Dependencies/curl")
(Log "failed at Curl autoheader step. This requires autoheader to execute.\n")
(return false))
(run-process-sequential-or
("automake" "--add-missing" :in-directory "Dependencies/curl")
(Log "failed at Curl automake step. This requires automake to execute.\n")
(return false))
(var with-openssl ([] 1024 char) (array 0))
(unless (format-absolute-path-into-buffer with-openssl (sizeof with-openssl)
"--with-openssl=" "cakelisp_cache/OpenSSLInstall")
(Log "error: OpenSSL.cake must be imported before Curl so that it is built before curl builds")
(return false))
(var install-prefix ([] 1024 char) (array 0))
(unless (format-absolute-path-into-buffer install-prefix (sizeof install-prefix)
"--prefix=" curl-install-dir)
(return false))
(run-process-sequential-or
("sh" "../../Dependencies/curl/configure"
with-openssl install-prefix
:in-directory curl-build-dir)
(Log "failed at Curl configure step. This requires configure to execute.\n")
(return false))
(run-process-sequential-or
("make" "--jobs=8" :in-directory curl-build-dir)
(Log "failed at Curl make. This tool requires Makefile support.\n")
(return false))
(run-process-sequential-or
("make" "install" :in-directory curl-build-dir)
(Log "failed at Curl make install. This tool requires Makefile support.\n")
(return false))
;; One final to check to ensure everything's good to go
(unless (fileExists "cakelisp_cache/CurlInstall/lib/libcurl.a")
(Log
"error: Curl build sequence completed, but files are not where expected. Is there an issue
with the configuration?\nFile expected:\n\tcakelisp_cache/CurlInstall/lib/libcurl.a\n")
(return false))
(return true))
(add-compile-time-hook-module pre-build build-curl)
(add-static-link-objects "cakelisp_cache/CurlInstall/lib/libcurl.a")
(add-dependency-git-submodule
clone-curl
"https://github.com/curl/curl.git"
"Dependencies/curl")

75
src/OpenSSL.cake

@ -0,0 +1,75 @@
;; OpenSSL.cake: Access openssl
(add-cakelisp-search-directory "Dependencies/cakelisp/runtime")
(import "CHelpers.cake" "BuildTools.cake" "Dependencies.cake")
;; (export-and-evaluate
;; (add-c-search-directory-module "Dependencies/openssl/src")
;; (c-import "openssl.h"))
;; TODO
;; (comptime-cond
;; ('auto-test
;; (defun test--openssl (&return int)
;; (return 0))))
;;
;; Building
;;
(defun-comptime build-openssl (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/OpenSSLInstall/lib64/libcrypto.a"))
(return true))
(Log "OpenSSL: Building via Configure and Make\n")
(var openssl-output-dir (* (const char)) "cakelisp_cache/OpenSSLInstall")
(makeDirectory openssl-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 openssl-output-dir))
(unless absolute-output-path
(Logf "error: failed to make OpenSSL output directory '%s'\n" openssl-output-dir)
(return false))
(PrintfBuffer configure-output-prefix "--prefix=%s" absolute-output-path)
(free (type-cast absolute-output-path (* void))))
(run-process-sequential-or
("perl"
;; Enable file formats openssl normally disables, because if openssl defines stb image, we use
;; the same definitions.
;; "-DCUSTOMIZE_BUILD=ON" "-DSUPPORT_FILEFORMAT_JPG=ON"
;; "-DSUPPORT_FILEFORMAT_BMP=ON" "-DSUPPORT_FILEFORMAT_TGA=ON"
"Configure" configure-output-prefix :in-directory "Dependencies/openssl")
(Log "failed at OpenSSL CMake step. This requires CMake to execute.")
(return false))
(run-process-sequential-or
("make" "--jobs=8" :in-directory "Dependencies/openssl")
(Log "failed at OpenSSL make. This tool requires Makefile support.")
(return false))
(run-process-sequential-or
("make" "install" :in-directory "Dependencies/openssl")
(Log "failed at OpenSSL make. This tool requires Makefile support.")
(return false))
;; One final to check to ensure everything's good to go
(unless (fileExists "cakelisp_cache/OpenSSLInstall/lib64/libcrypto.a")
(Log
"error: OpenSSL build sequence completed, but files are not where expected. Is there an issue
with the configuration?\nFile expected:\n\tcakelisp_cache/OpenSSLInstall/lib64/libcrypto.a\n")
(return false))
(return true))
(add-compile-time-hook-module pre-build build-openssl)
;; (add-static-link-objects "cakelisp_cache/OpenSSLInstall/lib64/libcrypto.a")
(add-dependency-git-submodule
clone-openssl
"git://git.openssl.org/openssl.git"
"Dependencies/openssl")

4
src/Raylib.cake

@ -32,7 +32,7 @@
(when (and (fileExists "cakelisp_cache/RaylibBuild/raylib/libraylib.a"))
(return true))
(Log "Raylib: Building via Configure and Make\n")
(Log "Raylib: Building via CMake and Make\n")
(var raylib-output-dir (* (const char)) "cakelisp_cache/RaylibBuild")
(makeDirectory raylib-output-dir)
@ -44,7 +44,7 @@
"-DCUSTOMIZE_BUILD=ON" "-DSUPPORT_FILEFORMAT_JPG=ON"
"-DSUPPORT_FILEFORMAT_BMP=ON" "-DSUPPORT_FILEFORMAT_TGA=ON"
"../../Dependencies/raylib" :in-directory raylib-output-dir)
(Log "failed at Raylib configure step. This requires a sh/bash-style shell to execute.")
(Log "failed at Raylib CMake step. This requires CMake to execute.")
(return false))
(run-process-sequential-or

8
test/src/GameLibTests.cake

@ -55,7 +55,9 @@
"../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/Oniguruma.cake" "../src/Cryptography.cake")))
"../src/Oniguruma.cake" "../src/Cryptography.cake"
;; Note: Must come before Curl because curl requires openssl
"../src/OpenSSL.cake" "../src/Curl.cake")))
(test-opengl-only
(gamelib-run-test
@ -74,8 +76,8 @@
;; Note that Raylib must come first so Image knows not to redefine stb_image implementation
"../src/Raylib.cake" "../src/Image.cake"
"../src/DataBundle.cake" "../src/TinyCCompiler.cake" "../src/FreeType.cake"
"../src/Cryptography.cake" "../src/ImGuiAutoColor.cake"
"../src/ProfilerAutoInstrument.cake"))
"../src/Cryptography.cake" "../src/OpenSSL.cake" "../src/Curl.cake"
"../src/ImGuiAutoColor.cake" "../src/ProfilerAutoInstrument.cake"))
(when test-ogre
(gamelib-run-test "Ogre" (array platform-config "src/OgreApp.cake"))

Loading…
Cancel
Save