diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f1f6a38..baaa6b3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 diff --git a/generate_tests.py b/generate_tests.py index c0883ea..5494bc7 100755 --- a/generate_tests.py +++ b/generate_tests.py @@ -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): @@ -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): diff --git a/src/01-dependencies/julia.md b/src/01-dependencies/julia.md index fc0a861..ea4359c 100644 --- a/src/01-dependencies/julia.md +++ b/src/01-dependencies/julia.md @@ -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: @@ -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 \ No newline at end of file +[`jlrs-launcher`]: https://github.com/Taaitaaiger/jlrs-launcher diff --git a/src/02-basics/project-setup.md b/src/02-basics/project-setup.md index 9c40390..4c11948 100644 --- a/src/02-basics/project-setup.md +++ b/src/02-basics/project-setup.md @@ -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: diff --git a/src/07-bindings-and-derivable-traits/customizing-bindings.md b/src/07-bindings-and-derivable-traits/customizing-bindings.md index 0430d11..a8960d2 100644 --- a/src/07-bindings-and-derivable-traits/customizing-bindings.md +++ b/src/07-bindings-and-derivable-traits/customizing-bindings.md @@ -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 { } ``` @@ -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, } @@ -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 { } ``` diff --git a/src/07-bindings-and-derivable-traits/generating-bindings.md b/src/07-bindings-and-derivable-traits/generating-bindings.md index 9bd2345..2b89b13 100644 --- a/src/07-bindings-and-derivable-traits/generating-bindings.md +++ b/src/07-bindings-and-derivable-traits/generating-bindings.md @@ -17,7 +17,7 @@ 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, @@ -25,7 +25,7 @@ pub struct MyStruct { #[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, } @@ -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, @@ -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>>, } @@ -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 { pub a: T, } @@ -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: ::std::marker::PhantomData, } diff --git a/src/11-julia-module/constants/constants.md b/src/11-julia-module/constants/constants.md index 57dd6b9..e5599d6 100644 --- a/src/11-julia-module/constants/constants.md +++ b/src/11-julia-module/constants/constants.md @@ -65,4 +65,4 @@ help?> JuliaModuleTutorial.CONST_UINT8 An exported constant. ``` - \ No newline at end of file + diff --git a/src/11-julia-module/julia-module.md b/src/11-julia-module/julia-module.md index 07d5131..c3aa528 100644 --- a/src/11-julia-module/julia-module.md +++ b/src/11-julia-module/julia-module.md @@ -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. diff --git a/src/11-julia-module/public-items/public-items.md b/src/11-julia-module/public-items/public-items.md new file mode 100644 index 0000000..d2b4fd1 --- /dev/null +++ b/src/11-julia-module/public-items/public-items.md @@ -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`. + + +```rust,ignore +use jlrs::prelude::*; + +fn return_first_arg(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; +} +``` + diff --git a/src/11-julia-module/yggdrasil-and-jlrs/yggdrasil-and-jlrs.md b/src/11-julia-module/yggdrasil-and-jlrs/yggdrasil-and-jlrs.md index a976026..4034834 100644 --- a/src/11-julia-module/yggdrasil-and-jlrs/yggdrasil-and-jlrs.md +++ b/src/11-julia-module/yggdrasil-and-jlrs/yggdrasil-and-jlrs.md @@ -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 = [ @@ -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 @@ -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. diff --git a/src/SUMMARY.md b/src/SUMMARY.md index baa1357..a263b31 100644 --- a/src/SUMMARY.md +++ b/src/SUMMARY.md @@ -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