From: Olivier Dion via "Developers list for Guile, the GNU extensibility library" <guile-devel@gnu.org>
To: Jean Abou Samra <jean@abou-samra.fr>,
guile-user@gnu.org, guile-devel@gnu.org, 52230@debbugs.gnu.org
Subject: Re: 'guild compile' and C(++) extensions (in the context of LilyPond)
Date: Sat, 19 Feb 2022 16:25:41 -0500 [thread overview]
Message-ID: <875ypa7dm2.fsf@laura> (raw)
In-Reply-To: <1fbaea64-8a8f-ea4b-714c-68ced7e1eab8@abou-samra.fr>
On Sat, 19 Feb 2022, Jean Abou Samra <jean@abou-samra.fr> wrote:
I had similar problem with Jami. I added C++ primitives to Guile, but
these were not load using the foreign function interface. Note, I'm
using Guile 3.0.8, but I think the same could be done for Guile 2.0.
Basically what I do is to add a `compile` command to my program so to
speak.
So usually the program does this:
main -> install_scheme_primitives() -> Run the program
And for compilation
main -> compile_in_guile() -> install_scheme_primitives() -> compile-file
To be clear here's what install_scheme_primitives() does:
--------------------------------------------------------------------------------
void
install_scheme_primitives()
{
/* Define modules here */
auto load_module = [](auto name, auto init){
scm_c_define_module(name, init, NULL);
};
load_module("jami account", install_account_primitives);
load_module("jami call", install_call_primitives);
load_module("jami conversation", install_conversation_primitives);
load_module("jami logger bindings", install_logger_primitives);
load_module("jami signal bindings", install_signal_primitives);
}
--------------------------------------------------------------------------------
and here's what compile_in_guile() does:
--------------------------------------------------------------------------------
void*
compile_in_guile(void* args_raw)
{
// ...
install_scheme_primitives();
// This string is usually formatted
scm_c_eval_string("(use-modules (system base compile))"
"(compile-file \"foo.scm\" #:output-file \"foo.go\")")
// ..
}
--------------------------------------------------------------------------------
so now I can correctly compile any file in the project. I just add this
to Makefile.am:
--------------------------------------------------------------------------------
MODULES = foo.scm
GOBJECTS = $(MODULES:%=%.go)
%.go: %.scm | program
@echo GUILD; ./program compile $< $@
--------------------------------------------------------------------------------
Hope that can help.
--
Olivier Dion
Polymtl
next prev parent reply other threads:[~2022-02-19 21:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <24ba24dc-004e-7c00-96eb-ea2412d2e89b@abou-samra.fr>
2022-02-19 21:08 ` bug#52230: 'guild compile' and C(++) extensions (in the context of LilyPond) Jean Abou Samra
2022-02-19 21:25 ` Olivier Dion via Developers list for Guile, the GNU extensibility library [this message]
2022-02-22 6:34 ` Jean Abou Samra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=875ypa7dm2.fsf@laura \
--to=guile-devel@gnu.org \
--cc=52230@debbugs.gnu.org \
--cc=guile-user@gnu.org \
--cc=jean@abou-samra.fr \
--cc=olivier.dion@polymtl.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).