Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:

- name: Run tests
run: |
julia -e "import Pkg; Pkg.add(url=\"https://github.com/Taaitaaiger/JlrsCore.jl\", rev=\"0c0ce35ec27f228587b01b410d402506f3f0f35a\")"
julia -e "import Pkg; Pkg.add(url=\"https://github.com/Taaitaaiger/JlrsCore.jl\", rev=\"3fc603a1cf8d4e0c16a57027f15d00232f47ac4a\")"
export JLRS_JULIA_DIR="$(dirname $(dirname $(which julia)))"
export LD_LIBRARY_PATH="${JLRS_JULIA_DIR}/lib:${LD_LIBRARY_PATH}"
./generate_tests.py
Expand Down
4 changes: 2 additions & 2 deletions generate_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def cargo_toml_bin_template(jlrs_path):
panic = "abort"

[dependencies]
jlrs = {{version = "0.22", {jlrs_path}features = ["full", "ccall"]}}"""
jlrs = {{version = "0.23", {jlrs_path}features = ["full", "ccall"]}}"""


def cargo_toml_lib_template(name, jlrs_path):
Expand All @@ -63,7 +63,7 @@ def cargo_toml_lib_template(name, jlrs_path):
crate-type = ["cdylib"]

[dependencies]
jlrs = {{ {jlrs_path}version = "0.22", features = ["jlrs-derive", "ccall", "complex"] }}"""
jlrs = {{ {jlrs_path}version = "0.23", features = ["jlrs-derive", "ccall", "complex"] }}"""


def bin_fragment(bin_name):
Expand Down
4 changes: 2 additions & 2 deletions src/01-dependencies/julia.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Julia

jlrs currently supports Julia 1.10 up to and including Julia 1.12. Using the most recent stable version is recommended. If you use `juliaup` to manage your Julia installations, you should install [`jlrs-launcher`]. The reason is that to compile jlrs successfully, the path to the Julia's header files and library must be known and this can be tricky to achieve with `juliaup`. By using this launcher application, `juliaup`'s logic is used to find the location of the necessary files and propagated to the launched application.
jlrs currently supports Julia 1.10 up to and including Julia 1.13. Using the most recent stable version is recommended. If you use `juliaup` to manage your Julia installations, you should install [`jlrs-launcher`]. The reason is that to compile jlrs successfully, the path to the Julia's header files and library must be known and this can be tricky to achieve with `juliaup`. By using this launcher application, `juliaup`'s logic is used to find the location of the necessary files and propagated to the launched application.

There are several platform-dependent ways to make these paths known if Julia is installed manually:

Expand All @@ -22,4 +22,4 @@ If `julia` is on your `PATH` at `/path/to/bin/julia`, the main header file is ex

The directory that contains `libjulia.dylib` must be on the library search path. If this is not the case and the library lives at `/path/to/lib/libjulia.dylib`, you must add `/path/to/lib/` to the `DYLD_LIBRARY_PATH` environment variable.

[`jlrs-launcher`]: https://github.com/Taaitaaiger/jlrs-launcher
[`jlrs-launcher`]: https://github.com/Taaitaaiger/jlrs-launcher
2 changes: 1 addition & 1 deletion src/02-basics/project-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ panic = "abort"
panic = "abort"

[dependencies]
jlrs = {version = "0.22", features = ["local-rt"]}
jlrs = {version = "0.23", features = ["local-rt"]}
```

If Julia has been installed and we've configured our environment according to the steps in the [dependency chapter], building and running should succeed:
Expand Down
8 changes: 4 additions & 4 deletions src/07-bindings-and-derivable-traits/customizing-bindings.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ julia> renamestruct!(layouts, MyZST, "MyZeroSizedType")
julia> layouts
#[repr(C)]
#[derive(Clone, Debug, Unbox, ValidLayout, Typecheck, IntoJulia, ValidField, IsBits, ConstructType)]
#[jlrs(julia_type = "Main.MyZST", zero_sized_type)]
#[jlrs(julia_type = "MyZST", zero_sized_type)]
pub struct MyZeroSizedType {
}
```
Expand All @@ -35,7 +35,7 @@ julia> renamefields!(layouts, Food, [:burger => "hamburger"])
julia> layouts
#[repr(C)]
#[derive(Clone, Debug, Unbox, ValidLayout, Typecheck, IntoJulia, ValidField, IsBits, ConstructType, CCallArg, CCallReturn)]
#[jlrs(julia_type = "Main.Food")]
#[jlrs(julia_type = "Food")]
pub struct Food {
pub hamburger: ::jlrs::data::layout::bool::Bool,
}
Expand All @@ -48,12 +48,12 @@ julia> struct MyZeroSizedType end

julia> layouts = reflect([MyZeroSizedType]);

julia> overridepath!(layouts, MyZeroSizedType, "Main.A.MyZeroSizedType")
julia> overridepath!(layouts, MyZeroSizedType, "A.MyZeroSizedType")

julia> layouts
#[repr(C)]
#[derive(Clone, Debug, Unbox, ValidLayout, Typecheck, IntoJulia, ValidField, IsBits, ConstructType)]
#[jlrs(julia_type = "Main.A.MyZeroSizedType", zero_sized_type)]
#[jlrs(julia_type = "A.MyZeroSizedType", zero_sized_type)]
pub struct MyZeroSizedType {
}
```
14 changes: 7 additions & 7 deletions src/07-bindings-and-derivable-traits/generating-bindings.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ julia> struct MyWrapper
julia> reflect([MyWrapper])
#[repr(C)]
#[derive(Clone, Debug, Unbox, ValidLayout, Typecheck, IntoJulia, ValidField, IsBits, ConstructType, CCallArg, CCallReturn)]
#[jlrs(julia_type = "Main.MyStruct")]
#[jlrs(julia_type = "MyStruct")]
pub struct MyStruct {
pub a: i8,
pub b: ::jlrs::data::layout::tuple::Tuple2<i8, u8>,
}

#[repr(C)]
#[derive(Clone, Debug, Unbox, ValidLayout, Typecheck, IntoJulia, ValidField, IsBits, ConstructType, CCallArg, CCallReturn)]
#[jlrs(julia_type = "Main.MyWrapper")]
#[jlrs(julia_type = "MyWrapper")]
pub struct MyWrapper {
pub ms: MyStruct,
}
Expand Down Expand Up @@ -57,7 +57,7 @@ julia> struct MyUnionStruct
julia> reflect([MyBitsUnionStruct, MyUnionStruct])
#[repr(C)]
#[derive(Clone, Debug, Unbox, ValidLayout, Typecheck, ValidField, ConstructType, CCallArg)]
#[jlrs(julia_type = "Main.MyBitsUnionStruct")]
#[jlrs(julia_type = "MyBitsUnionStruct")]
pub struct MyBitsUnionStruct {
#[jlrs(bits_union_align)]
_u_align: ::jlrs::data::layout::union::Align2,
Expand All @@ -69,7 +69,7 @@ pub struct MyBitsUnionStruct {

#[repr(C)]
#[derive(Clone, Debug, Unbox, ValidLayout, Typecheck, ValidField, ConstructType, CCallArg)]
#[jlrs(julia_type = "Main.MyUnionStruct")]
#[jlrs(julia_type = "MyUnionStruct")]
pub struct MyUnionStruct<'scope, 'data> {
pub u: ::std::option::Option<::jlrs::data::managed::value::ValueRef<'scope, 'data>>,
}
Expand All @@ -89,7 +89,7 @@ julia> struct MyParametricStruct{T}
julia> reflect([MyParametricStruct{UInt8}])
#[repr(C)]
#[derive(Clone, Debug, Unbox, ValidLayout, Typecheck, ValidField, IsBits, ConstructType, CCallArg, CCallReturn)]
#[jlrs(julia_type = "Main.MyParametricStruct")]
#[jlrs(julia_type = "MyParametricStruct")]
pub struct MyParametricStruct<T> {
pub a: T,
}
Expand All @@ -109,13 +109,13 @@ julia> struct MyElidedStruct{T}
julia> reflect([MyElidedStruct{UInt8}])
#[repr(C)]
#[derive(Clone, Debug, Unbox, ValidLayout, Typecheck, ValidField, IsBits)]
#[jlrs(julia_type = "Main.MyElidedStruct")]
#[jlrs(julia_type = "MyElidedStruct")]
pub struct MyElidedStruct {
pub a: u8,
}

#[derive(ConstructType, HasLayout)]
#[jlrs(julia_type = "Main.MyElidedStruct", constructor_for = "MyElidedStruct", scope_lifetime = false, data_lifetime = false, layout_params = [], elided_params = ["T"], all_params = ["T"])]
#[jlrs(julia_type = "MyElidedStruct", constructor_for = "MyElidedStruct", scope_lifetime = false, data_lifetime = false, layout_params = [], elided_params = ["T"], all_params = ["T"])]
pub struct MyElidedStructTypeConstructor<T> {
_t: ::std::marker::PhantomData<T>,
}
Expand Down
2 changes: 1 addition & 1 deletion src/11-julia-module/constants/constants.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@ help?> JuliaModuleTutorial.CONST_UINT8

An exported constant.
```
<!-- LIBTEST_JL END -->
<!-- LIBTEST_JL END -->
2 changes: 1 addition & 1 deletion src/11-julia-module/julia-module.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ panic = "abort"
crate-type = ["cdylib"]

[dependencies]
jlrs = { version = "0.22", features = ["jlrs-derive", "ccall"] }
jlrs = { version = "0.23", features = ["jlrs-derive", "ccall"] }
```

It's important that we don't enable any runtime features like `local-rt` when we build a dynamic library.
Expand Down
20 changes: 20 additions & 0 deletions src/11-julia-module/public-items/public-items.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Public items

The items that can be exported with `julia_module!` can be marked with `pub`, these items will be exported by the generated module. If a function is exported multiple times, all these functions must be marked `pub`.

<!-- LIBTEST START -->
```rust,ignore
use jlrs::prelude::*;

fn return_first_arg<T>(a: T, _b: T) -> T {
a
}

julia_module! {
become julia_module_tutorial_init_fn;

pub fn return_first_arg(a: isize, b: isize) -> isize;
pub fn return_first_arg(a: f64, b: f64) -> f64;
}
```
<!-- LIBTEST END -->
14 changes: 4 additions & 10 deletions src/11-julia-module/yggdrasil-and-jlrs/yggdrasil-and-jlrs.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,11 @@ The recipe should look as follows:
```julia
# Note that this script can accept some limited command-line arguments, run
# `julia build_tarballs.jl --help` to see a usage message.
using BinaryBuilder, Pkg

# See https://github.com/JuliaLang/Pkg.jl/issues/2942
# Once this Pkg issue is resolved, this must be removed
uuid = Base.UUID("a83860b7-747b-57cf-bf1f-3e79990d037f")
delete!(Pkg.Types.get_last_stdlibs(v"1.6.3"), uuid)
using BinaryBuilder

name = "{{crate_name}}"
version = v"0.1.0"
julia_versions = [v"1.10", v"1.11", v"1.12"]
julia_versions = [v"1.10", v"1.11", v"1.12", v"1.13"]

# Collection of sources required to complete build
sources = [
Expand All @@ -35,8 +30,8 @@ install -Dvm 0755 "target/${rust_target}/release/"*{{crate_name}}".${dlext}" "${
include("../../L/libjulia/common.jl")
platforms = vcat(libjulia_platforms.(julia_versions)...)

# Rust toolchain for i686 Windows is unusable
is_excluded(p) = Sys.iswindows(p) && nbits(p) == 32
# 32-bit Windows, AArch64 FreeBSD, and riscv64 are not supported
is_excluded(p) = (Sys.iswindows(p) && nbits(p) == 32) || (Sys.isfreebsd(p) && arch(p) == "aarch64") || arch(p) == "riscv64"
filter!(!is_excluded, platforms)

# The products that we will ensure are always built
Expand All @@ -57,7 +52,6 @@ build_tarballs(ARGS, name, version, sources, script, platforms, products, depend

The main differences with the recipe for a crate that doesn't depend on jlrs are:

- The workaround for issue [#2942].
- The supported versions of Julia are set.
- Supported platforms are acquired via `libjulia_platforms`, not `supported_platforms`.
- `libjulia_jll` is added to the dependencies as a build dependency.
Expand Down
1 change: 1 addition & 0 deletions src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
- [Generic functions](./11-julia-module/generic-functions/generic-functions.md)
- [Type environment](./11-julia-module/generic-functions/type-environment.md)
- [`Type aliases`](./11-julia-module/type-aliases/type-aliases.md)
- [`Public items`](./11-julia-module/public-items/public-items.md)
- [Yggdrasil and jlrs](./11-julia-module/yggdrasil-and-jlrs/yggdrasil-and-jlrs.md)

# Other topics
Expand Down
Loading