New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
various fixes for cmake based find_package #10
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
|
||
#include <iostream> | ||
|
||
#include <.src/c_adapter.hpp> | ||
#include "c_adapter.hpp" | ||
|
||
extern "C" | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,18 +5,18 @@ | |
|
||
#include <julia.h> | ||
|
||
#include <memory> | ||
#include <sstream> | ||
#include <iostream> | ||
#include <fstream> | ||
|
||
#include <include/state.hpp> | ||
#include <include/exceptions.hpp> | ||
#include <include/julia_extension.hpp> | ||
#include <include/proxy.hpp> | ||
#include <.src/include_julia.inl> | ||
#include <include/module.hpp> | ||
#include <include/type.hpp> | ||
|
||
#include "state.hpp" | ||
#include "exceptions.hpp" | ||
#include "julia_extension.hpp" | ||
#include "proxy.hpp" | ||
#include "include_julia.inl" | ||
#include "module.hpp" | ||
#include "type.hpp" | ||
|
||
namespace jluna::detail | ||
{ | ||
|
@@ -42,7 +42,28 @@ namespace jluna::State | |
else | ||
jl_init_with_image(path.c_str(), NULL); | ||
|
||
jl_eval_string(jluna::detail::include); | ||
const char* julia_lib_load_template = R"julia( | ||
begin | ||
local dev_path = "%s/include/jluna.jl" | ||
local prod_path = "%s/jluna/jluna.jl" | ||
if isfile(dev_path) | ||
include(dev_path) | ||
else isfile(prod_path) | ||
include(prod_path) | ||
end | ||
end | ||
)julia"; | ||
std::vector<char> buf ( | ||
/* no need to account for null since %s takes 4 bytes accounted for | ||
* which is double counted by BUILD_RESOURCE_DIR and RUN_RESOURCE_DIR */ | ||
strlen(julia_lib_load_template) + | ||
strlen(BUILD_RESOURCE_DIR) + | ||
strlen(RUN_RESOURCE_DIR), | ||
/*c strings are null terminated*/ | ||
'\0' | ||
); | ||
snprintf(buf.data(), buf.size(), julia_lib_load_template, BUILD_RESOURCE_DIR, RUN_RESOURCE_DIR); | ||
jl_eval_string(buf.data()); | ||
Comment on lines
+45
to
+66
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While std::format would be nice, I feel like assembling this with std::stringstream and then calling There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also how come std::format is the single feature where clang is further than gcc, very odd, usually gcc is much faster at implementing the new stuff. |
||
forward_last_exception(); | ||
|
||
|
||
|
@@ -57,7 +78,14 @@ namespace jluna::State | |
)"); | ||
forward_last_exception(); | ||
|
||
jl_eval_string(("jluna._cppcall.eval(:(_library_name = \"" + std::string(RESOURCE_PATH) + "/libjluna_c_adapter.so\"))").c_str()); | ||
jl_eval_string( | ||
R"julia( | ||
begin | ||
import Libdl | ||
local lib_path = Libdl.dlpath("libjluna_c_adapter") | ||
jluna._cppcall._set_library_name(lib_path) | ||
end | ||
)julia"); | ||
forward_last_exception(); | ||
|
||
jl_eval_string(R"( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I'm misunderstanding the purpose of replacing <> with "" everywhere, but the reason I intentionally kept the
.src/
andinclude/
prefix was, so that when a user types in their IDE something like:then I don't want my .src files showing up in the recommended completions (the thingy where when you press tab it auto-completes the statement). This is especially true with c_adapter, I don't want any of the users to even be aware what functions are in there, as it can break things in very odd ways. All files in .src and the entire c_adapter should be as hidden from end-users as possible.
Idk if this is true, but it feels like your restructuring made it, so users would have an easier time accessing the source and inline files, which I don't like. Correct me if I am wrong, though, as I'm not super sure what the full reason for the switch to "" was
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In gcc, clang, (and I think msvc)
"
based brackets search the current directory of the current file before searching the global include path. Where as<
doesn't search locally first.I moved them because they have to be installed some where to build a downstream library based on libjluna. When using a package manager, you can't assume that you have the cloned repo available, only the files explicitly installed.
Unfortunately, even with the
<
style includes, I still get auto complete suggestions for things in.src
it's kind of unavoidable. There might be some other way to hide them, but it doesn't for me.In the case where I don't want user's touching things, I typically use the PIMPL idiom to hide the implemenation and leave the details in the shared object as much as possible. Unfortunately that can be difficult with highly templatized code like this. I can't wait for wide support for modules when this can be a thing of the past.