Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
5ea80ff
Configure Emacs' C++ language style
LiberalArtist Feb 15, 2023
42ecba7
tangerine/installation.cpp: use alias for std::filesystem
LiberalArtist Feb 22, 2023
69fc8b4
Linux: Save Bookmarks under `XDG_STATE_HOME`
LiberalArtist Feb 15, 2023
90bb424
Fix Removing All File Bookmarks
LiberalArtist Feb 22, 2023
4fc81db
Revert "guix.scm: remove racket stubs for now"
LiberalArtist Feb 14, 2023
b62ae3a
package/tangerine: use `vec-lib` instead of `vec`
LiberalArtist Feb 13, 2023
fe68f8d
unbundle Racket 8.5
LiberalArtist Feb 13, 2023
722068b
package/tangarine: avoid test failure when embedding
LiberalArtist Feb 14, 2023
168fc22
remove stray SDL2.dll
LiberalArtist Feb 13, 2023
08f8e2d
wip: FindRacket.cmake
LiberalArtist Feb 14, 2023
451cd1d
wip: FindRacket.cmake, again
LiberalArtist Feb 14, 2023
21696b7
wip: initial attempt at reading the config flile (not working)
LiberalArtist Feb 14, 2023
2325fe8
fixup file read and regex match
LiberalArtist Feb 14, 2023
ff4cfa4
wip: abstract over parsing (not working)
LiberalArtist Feb 14, 2023
8b0b429
fixup config parsing; more work needed
LiberalArtist Feb 14, 2023
b45b8f8
linux/cmake/script.cmake: experiment with improvements
LiberalArtist Feb 14, 2023
fb24475
FindRacket: find more things
LiberalArtist Feb 15, 2023
6dd23b4
wip RacketParseConfigFile.cmake more git-predicate trouble
LiberalArtist Feb 23, 2023
9bdfb54
unbreak FindRacket.cmake
LiberalArtist Feb 23, 2023
58b4053
split origins
LiberalArtist Feb 23, 2023
b564660
FindRacket.cmake basically works
LiberalArtist Feb 23, 2023
625ec0f
wip racket_boot needs 8.8 for system
LiberalArtist Feb 23, 2023
069a54b
it builds!
LiberalArtist Feb 23, 2023
a2e2861
guix: enable git-predicate again
LiberalArtist Feb 24, 2023
387c00a
.dir-locals.el: tweak c-basic-offset
LiberalArtist Feb 24, 2023
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
22 changes: 19 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ cmake_minimum_required(VERSION 3.24)
project(tangerine
DESCRIPTION "Procedural 3D model creation")

# Add find modules to the path
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/linux/cmake")

if (MSVC)
message(FATAL_ERROR
"Currently CMake is only used on the Linux platform.\
Expand All @@ -14,7 +17,8 @@ include(GNUInstallDirs)
## Build options:

option(EMBED_LUA "Embed Lua support" ON)
option(EMBED_RACKET "Embed Racket support" OFF)
option(EMBED_RACKET "Embed Racket support" ON) #FIXME for testing
option(SELF_CONTAINED "Use directory tree instead of XDG_STATE_HOME" OFF)

set(INSTALL_PKG_SUBPATH "tangerine" CACHE PATH
"Subdirectory to form PKGDATADIR from DATADIR")
Expand All @@ -28,7 +32,6 @@ find_package(Threads REQUIRED)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_C_STANDARD 17)


#######################################################################
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++##
#######################################################################
Expand Down Expand Up @@ -143,6 +146,7 @@ set_target_properties(tangerine
RUNTIME_OUTPUT_DIRECTORY
$<PATH:APPEND,${CMAKE_BINARY_DIR},${CMAKE_INSTALL_BINDIR}>)
target_compile_definitions(tangerine PRIVATE
$<$<BOOL:${SELF_CONTAINED}>:"TANGERINE_SELF_CONTAINED">
"TANGERINE_PKGDATADIR_FROM_BINDIR=${PKGDATADIR_FROM_BINDIR}")
target_link_libraries(tangerine PRIVATE
fmt
Expand Down Expand Up @@ -181,4 +185,16 @@ target_compile_definitions(tangerine PRIVATE
#######################################################################
## Racket:

# FIXME!
if(EMBED_RACKET)
find_package(Racket REQUIRED) #FIXME or build our own
target_link_libraries(tangerine PRIVATE Racket::LibRacketCS)
target_compile_definitions(tangerine PRIVATE
"TANGERINE_RACKET_PETITE_BOOT=${Racket_PETITE_BOOT}"
"TANGERINE_RACKET_SCHEME_BOOT=${Racket_SCHEME_BOOT}"
"TANGERINE_RACKET_RACKET_BOOT=${Racket_RACKET_BOOT}"
"TANGERINE_RACKET_COLLECTS_DIR=${Racket_COLLECTS_DIR}"
"TANGERINE_RACKET_CONFIG_DIR=${Racket_CONFIG_DIR}"
"TANGERINE_USE_SYSTEM_RACKET=1")
endif()
target_compile_definitions(tangerine PRIVATE
"EMBED_RACKET=$<BOOL:${EMBED_RACKET}>")
Binary file removed SDL2.dll
Binary file not shown.
31 changes: 21 additions & 10 deletions channels.scm
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
(list (channel
(name 'guix)
(url "https://git.savannah.gnu.org/git/guix.git")
(branch "master")
(commit
"67d2f688fb89553df53e73a4c584b1b9eb7d5c24")
(introduction
(make-channel-introduction
"9edb3f66fd807b096b48283debdcddccfea34bad"
(openpgp-fingerprint
"BBB0 2DDF 2CEA F6A8 0D1D E643 A2A0 6DF2 A33A 54FA")))))
(name 'guix-racket-experiment)
(url "https://gitlab.com/philip1/guix-racket-experiment.git")
(branch "main")
(commit
"7d3c3e2dbf72cf2dc9e89243b1de8a96f39dab8c")
(introduction
(make-channel-introduction
"ef0580fceb8d88453724b2a2aa6fc9631612033c"
(openpgp-fingerprint
"F465 ABAC D637 AEAC 1415 55CF CA03 638D FA3F 1C7A"))))
(channel
(name 'guix)
(url "https://git.savannah.gnu.org/git/guix.git")
(branch "master")
(commit
"8320c0c6b6486f1991aa99246460ec955add65c7")
(introduction
(make-channel-introduction
"9edb3f66fd807b096b48283debdcddccfea34bad"
(openpgp-fingerprint
"BBB0 2DDF 2CEA F6A8 0D1D E643 A2A0 6DF2 A33A 54FA")))))
184 changes: 161 additions & 23 deletions guix.scm
Original file line number Diff line number Diff line change
Expand Up @@ -3,53 +3,104 @@
(use-modules
(gnu packages cmake)
(gnu packages ncurses)
((gnu packages racket) #:select (racket-vm-cs))
(gnu packages sdl)
(guix build-system cmake)
(guix gexp)
(guix git-download)
((guix licenses) #:prefix license:)
(guix packages)
(guix utils)
(ice-9 regex))
(ice-9 ftw)
(ice-9 regex)
(ice-9 vlist)
(wip-gnu packages racket)
(wip-guix build-system racket))

(define-public %tangerine-origin
(local-file
"." "tangerine-src"
#:recursive? #t
#:select?
(let* ((src-dir (current-source-directory))
(checked-in?
(or (and src-dir
(git-predicate (canonicalize-path src-dir)))
(lambda (path stat)
#t)))
(so-dll-rx
(make-regexp "\\.(so|dll)$"))
(so-or-dll?
(lambda (path stat)
(regexp-exec so-dll-rx path)))
(source-file?
(lambda (path stat)
(and (checked-in? path stat)
(not (so-or-dll? path stat))))))
source-file?)))

(define %tangerine-revision "0")


(define-values (%tangerine-racket-origin %tangerine-cxx-origin)
;; separate origins to reduce rebuilds
(let ()
(define src-dir
(current-source-directory))
(define (stat->identity stat)
(cons (stat:dev stat) (stat:ino stat)))
(define racket-src-identities
(delay
(if src-dir
(let* ((enter? (const #t))
(leaf (lambda (path stat result)
(vhash-cons (stat->identity stat) #t result)))
(down leaf)
(up (lambda (path stat result)
result))
(skip up)
(error (lambda (name stat errno result)
result))
(ids
(file-system-fold enter? leaf down up skip error
vlist-null
(string-append src-dir "/package"))))
ids)
vlist-null)))
(define checked-in?
;; TODO: This excluded linux/cmake/FindRacket.scm before I
;; checked it in, which was very confusing. Probably better
;; to use a predicate like git-ignored-file?, or something
;; like the logic from `nix flake.
;; (It even excludes staged files.)
(if src-dir
(git-predicate (canonicalize-path src-dir))
(lambda (path stat)
#t)))
(define so-dll-rx
(make-regexp "\\.(so|dll)$"))
(define (so-or-dll? path stat)
(regexp-exec so-dll-rx path))
(define guix-file-rx
(make-regexp "(channels|guix)\\.scm$"))
(define (guix-file? path stat)
(regexp-exec guix-file-rx path))
(define (source-file? path stat)
(and (checked-in? path stat)
(not (guix-file? path stat))
(not (so-or-dll? path stat))))
(define (non-racket-source-file? path stat)
(and (source-file? path stat)
(not (vhash-assoc (stat->identity stat)
(force racket-src-identities)))))
(values
(local-file "package" "tangerine-racket-src"
#:recursive? #t
#:select? source-file?)
(local-file "." "tangerine-cxx-src"
#:recursive? #t
#:select? non-racket-source-file?))))

(define-public tangerine
(package
(name "tangerine")
(version "0.0")
(source %tangerine-origin)
(source %tangerine-cxx-origin)
(outputs '("out" "debug"))
(build-system cmake-build-system)
(inputs
(list ncurses/tinfo ; for -ltinfo
tangerine-racket-layer
racket-vm-cs
(lookup-package-input racket-vm-cs "zlib")
(lookup-package-input racket-vm-cs "lz4")
sdl2
;; are the rest needed?
sdl2-image
sdl2-mixer
sdl2-ttf))
(arguments
(list
;#:phases #~(modify-phases %standard-phases (add-before 'configure 'stop (lambda args (error "stop"))))
#:cmake cmake ; newer than cmake-minimal
#:tests? #f))
(home-page "https://github.com/Aeva/tangerine")
Expand All @@ -61,4 +112,91 @@ operators. Models are written in Lua, and may be either rendered
directly or exported to a variety of common 3D model file formats.")
(license license:asl2.0)))

(define-public racket-vec-lib
(let ((commit "7ed2f1e43668d230cc411b326f7ace746f5d76de")
(revision "1")) ; Guix package revision
(package
(name "racket-vec-lib")
(version (git-version "0.0" revision commit))
(source (origin
(method git-fetch)
(uri (git-reference
(url "https://github.com/Aeva/vec")
(commit commit)))
(sha256
(base32
"0l515l9kx39xqa9skj7pj54gwffypa1d9pri7daj7kdzqs6d8cc8"))
(file-name (git-file-name name version))))
(build-system racket-build-system)
(outputs `("out" "pkgs"))
(inputs
(list racket-base))
(arguments
(list #:path "vec-lib"))
(home-page "https://pkgs.racket-lang.org/package/vec-lib")
(synopsis "Simple vector math library (implementation part)")
(description
"This package provides a simple Racket library for vector math,
developed for Tangerine. For documentation, see the Racket package
@code{vec}.")
(license license:asl2.0))))

(define-public racket-tangerine-x86-64-linux
(package
(name "racket-tangerine-x86-64-linux")
(version (git-version "0.0" %tangerine-revision "develop"))
(source %tangerine-racket-origin)
(build-system racket-build-system)
(outputs `("out" "pkgs"))
(inputs
(list racket-base))
(arguments
(list
#:path "tangerine-x86_64-linux"
#:phases
#~(modify-phases %standard-phases
(add-after 'unpack 'patch-info-rkt
(lambda args
(substitute* "info.rkt"
(("[(]define copy-foreign-libs")
"#;(define copy-foreign-libs")))))))
(home-page "https://pkgs.racket-lang.org/package/tangerine-x86-64-linux")
(synopsis "")
(description "")
(license license:asl2.0)))

(define-public racket-tangerine
(package
(name "racket-tangerine")
(version (git-version "0.0" %tangerine-revision "develop"))
(source %tangerine-racket-origin)
(build-system racket-build-system)
(outputs `("out" "pkgs"))
(inputs
(list racket-base
racket-sandbox-lib
racket-tangerine-x86-64-linux
racket-vec-lib))
(arguments
(list #:path "tangerine"))
(home-page "https://pkgs.racket-lang.org/package/tangerine-x86-64-linux")
(synopsis "")
(description "")
(license license:asl2.0)))

(define-public tangerine-racket-layer
;; opt/racket-vm/lib/{libracketcs.a,*.boot}
;; opt/racket-vm/include/{chezscheme,racketcs,racketcsboot}.h
;; etc/racket/config.rktd
(package
(inherit (make-racket-installation
#:name "tangerine-racket-layer"
#:tethered? #f
#:racket racket-vm-cs
#:packages (delay (list racket-tangerine))))
(synopsis "Racket installation layer for Tangerine")
(description
"")
(license (list license:asl2.0 license:expat))))

tangerine
Binary file removed libracketcs_db9xz4.dll
Binary file not shown.
71 changes: 71 additions & 0 deletions linux/cmake/FindLZ4.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
# SPDX-FileCopyrightText: © 2023 Philip McGrath <philip@philipmcgrath.com>

#[=======================================================================[.rst:

FindLZ4
-------

Finds the LZ4 library.

Imported Targets
^^^^^^^^^^^^^^^^

This module provides the following imported targets, if found:

``LZ4::LZ4``
The LZ4 library

Output Variables
^^^^^^^^^^^^^^^^

The following output variables are set:

``Racket_FOUND``
True if the system has LZ4.

Cache Variables
^^^^^^^^^^^^^^^

The following cache variables may also be set:

``LZ4_LIBRARY``
Path to ``LZ4::LZ4``.
``LZ4_INCLUDE_DIR``
Include directory for ``<lz4.h>``, if found.

#]=======================================================================]

# Model: https://cmake.org/cmake/help/latest/manual/cmake-developer.7.html#find-modules

include(FindPackageHandleStandardArgs)

find_package(PkgConfig)
pkg_check_modules(PC_LZ4 QUIET liblz4)
set(LZ4_VERSION ${PC_LZ4_VERSION})
find_library(LZ4_LIBRARY
NAMES lz4
PATHS ${PC_LZ4_LIBRARY_DIRS}
PATH_SUFFIXES lz4
DOC "The LZ4 library."
)
find_path(LZ4_INCLUDE_DIR
NAMES lz4.h
PATHS ${PC_LZ4_INCLUDE_DIRS}
PATH_SUFFIXES lz4
DOC "The include directory for <lz4.h>."
)
find_package_handle_standard_args(LZ4
REQUIRED_VARS
LZ4_LIBRARY
VERSION_VAR LZ4_VERSION
)
if(LZ4_FOUND AND NOT TARGET LZ4::LZ4)
add_library(LZ4::LZ4 UNKNOWN IMPORTED)
set_target_properties(LZ4::LZ4 PROPERTIES
IMPORTED_LOCATION "${LZ4_LIBRARY}"
)
if(LZ4_INCLUDE_DIR)
target_include_directories(LZ4::LZ4 INTERFACE "${LZ4_INCLUDE_DIR}")
endif()
endif()
Loading