diff --git a/.gitignore b/.gitignore index 713ec75..3af7f5a 100644 --- a/.gitignore +++ b/.gitignore @@ -17,4 +17,5 @@ GRAPH*.png SICK_JOKE* *.hi *_stub.h -copying_to_cpp.sh \ No newline at end of file +copying_to_cpp.sh +target \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..2888f51 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,14 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "alice_and_misc" +version = "0.1.0" + +[[package]] +name = "daria" +version = "0.1.0" +dependencies = [ + "alice_and_misc", +] diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..53d5582 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "daria" +version = "0.1.0" +edition = "2024" + +[[bin]] +name = "r4d" +path = "src/l3/r4/r4d.rs" + +[dependencies] +alice_and_misc = {path = "src/l2/allie_rs"} \ No newline at end of file diff --git a/Makefile b/Makefile index a96e775..997b5a2 100644 --- a/Makefile +++ b/Makefile @@ -123,7 +123,7 @@ out/l2/r3: src/l2/tests/r3/r3.c $(HEADERS_src_l2) $(l_wl_protocols) run_r3: out/l2/r3 ./out/l2/r3 -out/l3/r4b: src/l3/r4/r4.c $(HEADERS_src_l3) $(l_wl_protocols) $(ASSETS_gen_l_adele) +out/l3/r4b: src/l3/r4/r4b.c $(HEADERS_src_l3) $(l_wl_protocols) $(ASSETS_gen_l_adele) mkdir -p out/l3 $(cc) $(cflags) -o $@ $< $(xdg_shell_private_c) -lvulkan -lm -lxkbcommon -lwayland-client -lpng -lfreetype @@ -139,6 +139,17 @@ clean: # ============================================================= # ------------------------------------------------------------- +# ------------------------------------------------------------- +# ------------------------ ИНОАГЕНТЫ -------------------------- +out/l2/allie/glue.o: src/l2/allie_glue.c $(HEADERS_src_l2) $(xdg_shell_client_h) gen/l_adele/dorothy.txt $(HEADERS_gen_l2) + mkdir -p out/l2/allie + $(cc) $(cflags) -o $@ -c $< -lvulkan -lm -lxkbcommon -lwayland-client -lpng -lfreetype + +full_allie_obj := out/l2/allie/glue.o $(xdg_shell_private_o) + +out/l2/allie/liballie.a: $(full_allie_obj) + ar rcs $@ $^ + # ------------------------------------------------------------- # ============================================================= # ====================== ПЛЮСЫ ================================ @@ -146,6 +157,8 @@ clean: find_hpp_cpp = $(shell find src/$(1) -type f -name '*.hpp' ) HEADERS_src_l1_allie_cpp := $(call find_hpp_cpp,l1/allie_cpp) +HEADERS_src_l2_allie_hpp := $(call find_hpp_cpp,l2/allie_cpp) gen/l1/allie_cpp/dorothy.txt +HEADERS_src_l3_allie_hpp := $(call find_hpp_cpp,l3/allie_cpp) $(HEADERS_src_l2_allie_hpp) cxx_cpp := g++ cxxflags_cpp := -Wall -Wextra -Werror=return-type -Wno-unused-parameter \ @@ -167,8 +180,7 @@ out/l2/allie_cpp/glue.o: src/l2/allie_cpp/glue.c $(HEADERS_src_l2) $(xdg_shell_c full_allie_cpp_obj := out/l2/allie_cpp/glue.o $(xdg_shell_private_o) # todo: add a call to a function that obtains all .hpp files from l2/allie_cpp -out/l3/allie_cpp/r4c: src/l3/r4/r4c.cpp src/l1/allie_cpp/utils.hpp \ - src/l2/allie_cpp/alice.hpp $(full_allie_cpp_obj) +out/l3/allie_cpp/r4c: src/l3/r4/r4c.cpp $(HEADERS_src_l3_allie_hpp) $(full_allie_cpp_obj) mkdir -p out/l3/allie_cpp $(cxx_cpp) $(cxxflags_cpp) -o $@ $< $(full_allie_cpp_obj) \ -lvulkan -lm -lxkbcommon -lwayland-client -lpng -lfreetype @@ -185,26 +197,45 @@ run_r4c: out/l3/allie_cpp/r4c # ============================================================= # ========================== ХАСКЕЛЬ ========================== -find_haskell_hs = $(shell find src/$(1) -type f -name '*.hs' ) - -# Whoever needs this will also need out/l_wl_protocols -out/l2/allie_hs/glue.o: src/l2/allie_hs/glue.c $(HEADERS_src_l2) $(xdg_shell_client_h) gen/l_adele/dorothy.txt $(HEADERS_gen_l2) - mkdir -p out/l2/allie_hs/ - $(cc) $(cflags) -o $@ -c $< -lvulkan -lm -lxkbcommon -lwayland-client -lpng -lfreetype - -full_allie_hs_obj := out/l2/allie_hs/glue.o $(xdg_shell_private_o) - -# todo: write a function that gets all .hs files from l2/allie_hs. Call it -out/l3/allie_hs/r4: src/l3/r4/R4.hs src/l2/allie_hs/Alice.hs \ - src/l2/allie_hs/Geom.hs $(full_allie_hs_obj) - mkdir -p out/l3/allie_hs - ghc -isrc/l2/allie_hs -hidir out/l3/ -odir out/l3 -o $@ $< $(full_allie_hs_obj) \ - -lvulkan -lm -lxkbcommon -lwayland-client -lpng -lfreetype - -.PHONY: run_r4 -run_r4: out/l3/allie_hs/r4 - ./out/l3/allie_hs/r4 +#find_haskell_hs = $(shell find src/$(1) -type f -name '*.hs' ) +# +## Whoever needs this will also need out/l_wl_protocols +#out/l2/allie_hs/glue.o: src/l2/allie_hs/glue.c $(HEADERS_src_l2) $(xdg_shell_client_h) gen/l_adele/dorothy.txt $(HEADERS_gen_l2) +# mkdir -p out/l2/allie_hs/ +# $(cc) $(cflags) -o $@ -c $< -lvulkan -lm -lxkbcommon -lwayland-client -lpng -lfreetype +# +#full_allie_hs_obj := out/l2/allie_hs/glue.o $(xdg_shell_private_o) +# +## todo: write a function that gets all .hs files from l2/allie_hs. Call it +#out/l3/allie_hs/r4: src/l3/r4/R4.hs src/l2/allie_hs/Alice.hs \ +# src/l2/allie_hs/Geom.hs $(full_allie_hs_obj) +# mkdir -p out/l3/allie_hs +# ghc -isrc/l2/allie_hs -hidir out/l3/ -odir out/l3 -o $@ $< $(full_allie_hs_obj) \ +# -lvulkan -lm -lxkbcommon -lwayland-client -lpng -lfreetype +# +#.PHONY: run_r4 +#run_r4: out/l3/allie_hs/r4 +# ./out/l3/allie_hs/r4 # ========================== ХАСКЕЛЬ ВСЁ ====================== # ============================================================= # ------------------------------------------------------------- + +# ------------------------------------------------------------- +# ============================================================= +# ============================= РАСТ ========================== + +rustflags := -L native=$(abspath out/l2/allie/) -l static=allie + +target/debug/r4d: src/l3/r4/r4d.rs $(full_allie_obj) out/l2/allie/liballie.a + mkdir -p out/l3/allie_rs + echo "$(rustflags)" + RUSTFLAGS="$(rustflags)" cargo build --bin r4d + +.PHONY: run_r4d +run_r4d: target/debug/r4d + ./target/debug/r4d + +# ========================== РАСТ ВСЁ ========================= +# ============================================================= +# ------------------------------------------------------------- diff --git a/src/l1/allie_cpp/anne/geom.hpp b/src/l1/allie_cpp/anne/geom.hpp index 5559999..bbb5485 100644 --- a/src/l1/allie_cpp/anne/geom.hpp +++ b/src/l1/allie_cpp/anne/geom.hpp @@ -246,5 +246,6 @@ void l1_generate_geom_hpp() { } } } + std::filesystem::create_directories("l1/allie_cpp"); write_text_file("l1/allie_cpp/geom.hpp", res); } diff --git a/src/l1/allie_cpp/utils.hpp b/src/l1/allie_cpp/utils.hpp index 805993a..8117ac9 100644 --- a/src/l1/allie_cpp/utils.hpp +++ b/src/l1/allie_cpp/utils.hpp @@ -33,11 +33,6 @@ struct allie_VecU32 { U64 capacity; }; -struct allie_VecU8 { - const U8* buf; - U64 len; -}; - struct U32Segment { U32 start; U32 len; @@ -107,4 +102,17 @@ template void allie_form_cpp_vector_of_matching_types(std::vector& dst, const VecT& src) { dst.resize(src.len); memcpy(dst.data(), src.buf, src.len * sizeof(T)); -} \ No newline at end of file +} + + +struct allie_VecU8 { + U8* buf; + U64 len; + U64 capacity; + + explicit allie_VecU8(std::string_view src) { + len = capacity = src.size(); + buf = static_cast(safe_malloc( src.size() )); + memcpy(buf, src.data(), src.size()); + } +}; \ No newline at end of file diff --git a/src/l2/allie_cpp/alice.hpp b/src/l2/allie_cpp/alice.hpp index 36248db..eac386c 100644 --- a/src/l2/allie_cpp/alice.hpp +++ b/src/l2/allie_cpp/alice.hpp @@ -108,12 +108,12 @@ struct allie_AliceCallbacks { extern "C" { allie_Alice allie_Alice_new(); void allie_Alice_mainloop(allie_Alice, const allie_AliceCallbacks*); - allie_LucyFace allie_Alice_new_LucyFace(allie_Alice alice, allie_SpanU8 path); + allie_LucyFace allie_Alice_new_LucyFace(allie_Alice alice, allie_VecU8 path); void allie_Alice_lucy_cache_add_glyphs(allie_Alice alice, allie_VecLucyGlyphCachingRequest req); void allie_Alice_lucy_renderer_add_simple_label(allie_Alice alice, void* ffs, vec4 color, S32 additional_y_advance, allie_SpanU8 text, ivec2 start_pos); - U32 allie_Alice_load_r8g8b8a8_texture(allie_Alice alice, allie_SpanU8 file_path); - U32 allie_Alice_load_r8_texture(allie_Alice alice, allie_SpanU8 file_path); + U32 allie_Alice_load_r8g8b8a8_texture(allie_Alice alice, allie_VecU8 file_path); + U32 allie_Alice_load_r8_texture(allie_Alice alice, allie_VecU8 file_path); allie_AliceAcknGenericMesh allie_Alice_add_generic_mesh(allie_Alice alice, const allie_AliceGenericMeshTopology* topology, U32 diffuse_tex, U32 normal_tex, U32 specular_tex); allie_AliceAcknShinyMesh allie_Alice_add_shiny_mesh(allie_Alice alice, const allie_AliceShinyMeshTopology* top); @@ -172,7 +172,7 @@ struct Alice { } LucyFace new_lucy_face (std::string_view path) noexcept { - return LucyFace{allie_Alice_new_LucyFace(opa, allie_SpanU8(path))}; + return LucyFace{allie_Alice_new_LucyFace(opa, allie_VecU8(path))}; } void lucy_cache_add_glyphs(std::vector&& reqs) { @@ -194,11 +194,11 @@ struct Alice { } AliceTextureSlot load_r8g8b8a8_texture(std::string_view path) noexcept { - return {.id = allie_Alice_load_r8g8b8a8_texture(opa, allie_SpanU8(path))}; + return {.id = allie_Alice_load_r8g8b8a8_texture(opa, allie_VecU8(path))}; } AliceTextureSlot load_r8_texture(std::string_view path) noexcept { - return {.id = allie_Alice_load_r8_texture(opa, allie_SpanU8(path))}; + return {.id = allie_Alice_load_r8_texture(opa, allie_VecU8(path))}; } AliceAcknGenericMesh add_generic_mesh( diff --git a/src/l2/allie_cpp/assets.hpp b/src/l2/allie_cpp/assets.hpp index db725bb..02fc92d 100644 --- a/src/l2/allie_cpp/assets.hpp +++ b/src/l2/allie_cpp/assets.hpp @@ -24,7 +24,7 @@ struct allie_AliceGenericMeshTopology { }; extern "C" { - allie_AliceGenericMeshTopology allie_alice_expect_read_generic_mesh_from_file(allie_SpanU8 file_path); + allie_AliceGenericMeshTopology allie_alice_expect_read_generic_mesh_from_file(allie_VecU8 file_path); } struct AliceGenericMeshTopology { @@ -33,7 +33,7 @@ struct AliceGenericMeshTopology { }; AliceGenericMeshTopology alice_expect_read_generic_mesh_from_file(std::string_view file_path) { - allie_AliceGenericMeshTopology a_top = allie_alice_expect_read_generic_mesh_from_file(allie_SpanU8(file_path)); + allie_AliceGenericMeshTopology a_top = allie_alice_expect_read_generic_mesh_from_file(allie_VecU8(file_path)); AliceGenericMeshTopology top{}; allie_form_cpp_vector_of_matching_types(top.vertices, a_top.vertices); allie_form_cpp_vector_of_matching_types(top.indexes, a_top.indexes); @@ -65,7 +65,7 @@ struct allie_AliceShinyMeshTopology { }; extern "C" { - allie_AliceShinyMeshTopology allie_alice_expect_read_shiny_mesh_from_file(allie_SpanU8 file_path); + allie_AliceShinyMeshTopology allie_alice_expect_read_shiny_mesh_from_file(allie_VecU8 file_path); } struct AliceShinyMeshTopology { @@ -74,7 +74,7 @@ struct AliceShinyMeshTopology { }; AliceShinyMeshTopology alice_expect_read_shiny_mesh_from_file(std::string_view file_path) { - allie_AliceShinyMeshTopology a_top = allie_alice_expect_read_shiny_mesh_from_file(allie_SpanU8(file_path)); + allie_AliceShinyMeshTopology a_top = allie_alice_expect_read_shiny_mesh_from_file(allie_VecU8(file_path)); AliceShinyMeshTopology top; allie_form_cpp_vector_of_matching_types(top.vertices, a_top.vertices); allie_form_cpp_vector_of_matching_types(top.indexes, a_top.indexes); diff --git a/src/l2/allie_cpp/glue.c b/src/l2/allie_cpp/glue.c index 95e2169..6fcc9da 100644 --- a/src/l2/allie_cpp/glue.c +++ b/src/l2/allie_cpp/glue.c @@ -12,8 +12,8 @@ void allie_Alice_drop(Alice* self) { // todo: implment } -LucyFace* allie_Alice_new_LucyFace(Alice* alice, SpanU8 path) { - return Alice_new_LucyFace(alice, VecU8_from_span(path)); +LucyFace* allie_Alice_new_LucyFace(Alice* alice, VecU8 path) { + return Alice_new_LucyFace(alice, path); } @@ -32,20 +32,20 @@ void allie_Alice_lucy_renderer_add_simple_label(Alice* alice, RBTreeNodeLucyFace } /* This has nothing to do with game engine API, GenericMeshTopology is just a datatype that holds model data */ -GenericMeshTopology allie_alice_expect_read_generic_mesh_from_file(SpanU8 file_path) { - return alice_expect_read_generic_mesh_from_file(VecU8_from_span(file_path)); +GenericMeshTopology allie_alice_expect_read_generic_mesh_from_file(VecU8 file_path) { + return alice_expect_read_generic_mesh_from_file(file_path); } -ShinyMeshTopology allie_alice_expect_read_shiny_mesh_from_file(SpanU8 file_path) { - return alice_expect_read_shiny_mesh_from_file(VecU8_from_span(file_path)); +ShinyMeshTopology allie_alice_expect_read_shiny_mesh_from_file(VecU8 file_path) { + return alice_expect_read_shiny_mesh_from_file(file_path); } -U32 allie_Alice_load_r8g8b8a8_texture(Alice* alice, SpanU8 file_path) { - return Alice_load_r8g8b8a8_texture(alice, VecU8_from_span(file_path)); +U32 allie_Alice_load_r8g8b8a8_texture(Alice* alice, VecU8 file_path) { + return Alice_load_r8g8b8a8_texture(alice, file_path); } -U32 allie_Alice_load_r8_texture(Alice* alice, SpanU8 file_path) { - return Alice_load_r8_texture(alice, VecU8_from_span(file_path)); +U32 allie_Alice_load_r8_texture(Alice* alice, VecU8 file_path) { + return Alice_load_r8_texture(alice, file_path); } diff --git a/src/l2/allie_glue.c b/src/l2/allie_glue.c new file mode 100644 index 0000000..0f2051d --- /dev/null +++ b/src/l2/allie_glue.c @@ -0,0 +1,6 @@ +#include +#include + +void allie_funny_hello() { + printf("HIIIIII\n"); +} diff --git a/src/l2/allie_rs/Cargo.toml b/src/l2/allie_rs/Cargo.toml new file mode 100644 index 0000000..a679d14 --- /dev/null +++ b/src/l2/allie_rs/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "alice_and_misc" +version="0.1.0" +edition = "2024" + +[lib] +path = "lib.rs" \ No newline at end of file diff --git a/src/l2/allie_rs/lib.rs b/src/l2/allie_rs/lib.rs new file mode 100644 index 0000000..98a0b1b --- /dev/null +++ b/src/l2/allie_rs/lib.rs @@ -0,0 +1,12 @@ + +unsafe extern "C" { + fn allie_funny_hello(); +} + +pub fn funny_hello() { + unsafe { allie_funny_hello(); } +} + +pub fn funny_test(){ + println!("HELLOOOO\nHELLOOOOOOOO :3"); +} \ No newline at end of file diff --git a/src/l3/r4/r4.c b/src/l3/r4/r4b.c similarity index 100% rename from src/l3/r4/r4.c rename to src/l3/r4/r4b.c diff --git a/src/l3/r4/r4d.rs b/src/l3/r4/r4d.rs new file mode 100644 index 0000000..52f57ff --- /dev/null +++ b/src/l3/r4/r4d.rs @@ -0,0 +1,6 @@ +use alice_and_misc::{funny_test, funny_hello}; + +fn main() { + funny_test(); + funny_hello(); +}