cross-compilation.scm 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. ;;; Cross-compilation-case
  2. ;;; Copyright (C) 2024 Igalia, S.L.
  3. ;;;
  4. ;;; Licensed under the Apache License, Version 2.0 (the "License");
  5. ;;; you may not use this file except in compliance with the License.
  6. ;;; You may obtain a copy of the License at
  7. ;;;
  8. ;;; http://www.apache.org/licenses/LICENSE-2.0
  9. ;;;
  10. ;;; Unless required by applicable law or agreed to in writing, software
  11. ;;; distributed under the License is distributed on an "AS IS" BASIS,
  12. ;;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. ;;; See the License for the specific language governing permissions and
  14. ;;; limitations under the License.
  15. ;;; Commentary:
  16. ;;;
  17. ;;; A limited form of cond-expand, just for selecting code according to
  18. ;;; whether we are cross-compiling or not.
  19. ;;;
  20. ;;; Code:
  21. (library (hoot cross-compilation)
  22. (export cross-compilation-case)
  23. (import (hoot core-syntax)
  24. (only (hoot primitives) target-runtime))
  25. (define-syntax cross-compilation-case
  26. (lambda (stx)
  27. (syntax-case stx ()
  28. ((_) #'(begin))
  29. ((_ (#f . body) . clauses)
  30. (case (target-runtime)
  31. ((hoot) #'(begin . body))
  32. (else #'(cross-compilation-case . clauses))))
  33. ((_ (#t . body) . clauses)
  34. (case (target-runtime)
  35. ((hoot) #'(cross-compilation-case . clauses))
  36. (else #'(begin . body))))))))