From d43cb8dbac22554423fcebb44492e6c0a37ceb0a Mon Sep 17 00:00:00 2001 From: Vivianne Langdon Date: Tue, 28 Jun 2022 01:11:39 -0700 Subject: [PATCH 1/9] initial changes, does not fully link yet --- linux/build_majuscule.sh | 43 +++++++++++++++++++++++++++++++++--- tangerine/embedding.h | 2 +- tangerine/export.cpp | 2 ++ tangerine/gl_boilerplate.cpp | 2 ++ tangerine/tangerine.cpp | 2 +- 5 files changed, 46 insertions(+), 5 deletions(-) mode change 100644 => 100755 linux/build_majuscule.sh diff --git a/linux/build_majuscule.sh b/linux/build_majuscule.sh old mode 100644 new mode 100755 index e2ac17e..2c53767 --- a/linux/build_majuscule.sh +++ b/linux/build_majuscule.sh @@ -2,6 +2,8 @@ cd `dirname $0` cd .. +LUA_DIR=third_party/lua-5.4.4/lua + clang++ \ -std=c++17 \ -fPIC \ @@ -9,16 +11,51 @@ clang++ \ -Ithird_party/fmt/include \ -Ithird_party/imgui \ -Ithird_party/imgui/backends \ + -Ithird_party/racket/include \ + -Ithird_party/lua-5.4.4 \ -Ithird_party \ -I/usr/include/racket \ -L/usr/lib/racket \ - -lracket \ `pkg-config --libs --cflags sdl2 gtk+-3.0` \ tangerine/*.cpp \ third_party/imgui/*.cpp \ third_party/imgui/backends/imgui_impl_opengl3.cpp \ third_party/imgui/backends/imgui_impl_sdl.cpp \ - third_party/fmt/src/format.cc \ - third_party/Glad/glad.c \ third_party/voxwriter/VoxWriter.cpp \ + third_party/fmt/src/format.cc \ + -xc \ + -std=c17 \ + third_party/glad/glad.c \ + $LUA_DIR/lapi.c \ + $LUA_DIR/ldebug.c \ + $LUA_DIR/llex.c \ + $LUA_DIR/lparser.c \ + $LUA_DIR/lauxlib.c \ + $LUA_DIR/ldo.c \ + $LUA_DIR/lmathlib.c \ + $LUA_DIR/lstate.c \ + $LUA_DIR/lbaselib.c \ + $LUA_DIR/ldump.c \ + $LUA_DIR/lmem.c \ + $LUA_DIR/lstring.c \ + $LUA_DIR/lundump.c + $LUA_DIR/lcode.c \ + $LUA_DIR/lfunc.c \ + $LUA_DIR/loadlib.c \ + $LUA_DIR/lstrlib.c \ + $LUA_DIR/lutf8lib.c + $LUA_DIR/lcorolib.c \ + $LUA_DIR/lgc.c \ + $LUA_DIR/lobject.c \ + $LUA_DIR/ltable.c \ + $LUA_DIR/lvm.c + $LUA_DIR/lctype.c \ + $LUA_DIR/linit.c \ + $LUA_DIR/lopcodes.c \ + $LUA_DIR/ltablib.c \ + $LUA_DIR/lzio.c + $LUA_DIR/ldblib.c \ + $LUA_DIR/liolib.c \ + $LUA_DIR/loslib.c \ + $LUA_DIR/ltm.c \ -o package/tangerine/tangerine.out diff --git a/tangerine/embedding.h b/tangerine/embedding.h index 9e02218..45f648e 100644 --- a/tangerine/embedding.h +++ b/tangerine/embedding.h @@ -15,7 +15,7 @@ #pragma once #define EMBED_LUA 1 -#define EMBED_RACKET 1 +#define EMBED_RACKET 0 #define EMBED_MULTI (EMBED_LUA + EMBED_RACKET) > 1 diff --git a/tangerine/export.cpp b/tangerine/export.cpp index c88ba46..da4d6de 100644 --- a/tangerine/export.cpp +++ b/tangerine/export.cpp @@ -24,8 +24,10 @@ #include #include #ifndef MINIMAL_DLL +#if _WIN64 #include #endif +#endif #include #include "threadpool.h" #include "extern.h" diff --git a/tangerine/gl_boilerplate.cpp b/tangerine/gl_boilerplate.cpp index 7ab5ccc..3b35802 100644 --- a/tangerine/gl_boilerplate.cpp +++ b/tangerine/gl_boilerplate.cpp @@ -246,6 +246,8 @@ StatusCode RouteSource(std::vector& BreadCrumbs, std::vector Date: Tue, 28 Jun 2022 22:11:59 -0700 Subject: [PATCH 2/9] initial cmake, gitignore for some generated files --- .gitignore | 1 + CMakeLists.txt | 51 ++++++++++++++++++++++++++++++++ linux/build_majuscule.sh | 63 +++++----------------------------------- tangerine/embedding.h | 2 +- 4 files changed, 60 insertions(+), 57 deletions(-) create mode 100644 CMakeLists.txt diff --git a/.gitignore b/.gitignore index fb615ca..dafc930 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ windows/.vs windows/x64 windows/enc_temp_folder windows/packages +linux/build/ racket/lib racket/modules third_party/racket/lib/x64 diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..ce04d39 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,51 @@ +cmake_minimum_required(VERSION 3.14) +project(tangerine) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_C_STANDARD 17) + +file(GLOB_RECURSE TANGERINE_FILES "tangerine/*.cpp") + +file(GLOB TANGERINE_LUA_FILES "third_party/lua-5.4.4/lua/*.c") +list(FILTER + TANGERINE_LUA_FILES + EXCLUDE REGEX + ".*/lua/(onelua|lua|luac)\.c") # these define main + +file(GLOB TANGERINE_IMGUI_FILES + "third_party/imgui/*.cpp") + +set(TANGERINE_THIRD_PARTY_FILES + ${TANGERINE_IMGUI_FILES} + "third_party/imgui/backends/imgui_impl_opengl3.cpp" + "third_party/imgui/backends/imgui_impl_sdl.cpp" + "third_party/voxwriter/VoxWriter.cpp" + "third_party/fmt/src/format.cc" + "third_party/glad/glad.c" + ${TANGERINE_LUA_FILES}) + +set(TANGERINE_INCLUDE_DIRS + "third_party" + "third_party/fmt/include" + "third_party/imgui" + "third_party/imgui/backends" + "third_party/racket/include" + "third_party/lua-5.4.4") + +add_executable(tangerine + ${TANGERINE_FILES} + ${TANGERINE_THIRD_PARTY_FILES}) + +find_package(SDL2 REQUIRED) + +find_package(PkgConfig REQUIRED) +pkg_check_modules(GTK2 REQUIRED gtk+-2.0) +include_directories( + ${TANGERINE_INCLUDE_DIRS} + ${GTK2_INCLUDE_DIRS}) + +target_link_libraries(tangerine + SDL2::SDL2 + racketcs + tinfo + ${GTK2_LIBRARIES}) diff --git a/linux/build_majuscule.sh b/linux/build_majuscule.sh index 2c53767..985e416 100755 --- a/linux/build_majuscule.sh +++ b/linux/build_majuscule.sh @@ -2,60 +2,11 @@ cd `dirname $0` cd .. -LUA_DIR=third_party/lua-5.4.4/lua +cmake -B linux/build/Debug -DCMAKE_BUILD_TYPE=Debug \ + -DCMAKE_CXX_COMPILER=clang++ \ + -DCMAKE_C_COMPILER=clang +cmake -B linux/build/Release -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_CXX_COMPILER=clang++ \ + -DCMAKE_C_COMPILER=clang -clang++ \ - -std=c++17 \ - -fPIC \ - -U_WIN64 \ - -Ithird_party/fmt/include \ - -Ithird_party/imgui \ - -Ithird_party/imgui/backends \ - -Ithird_party/racket/include \ - -Ithird_party/lua-5.4.4 \ - -Ithird_party \ - -I/usr/include/racket \ - -L/usr/lib/racket \ - `pkg-config --libs --cflags sdl2 gtk+-3.0` \ - tangerine/*.cpp \ - third_party/imgui/*.cpp \ - third_party/imgui/backends/imgui_impl_opengl3.cpp \ - third_party/imgui/backends/imgui_impl_sdl.cpp \ - third_party/voxwriter/VoxWriter.cpp \ - third_party/fmt/src/format.cc \ - -xc \ - -std=c17 \ - third_party/glad/glad.c \ - $LUA_DIR/lapi.c \ - $LUA_DIR/ldebug.c \ - $LUA_DIR/llex.c \ - $LUA_DIR/lparser.c \ - $LUA_DIR/lauxlib.c \ - $LUA_DIR/ldo.c \ - $LUA_DIR/lmathlib.c \ - $LUA_DIR/lstate.c \ - $LUA_DIR/lbaselib.c \ - $LUA_DIR/ldump.c \ - $LUA_DIR/lmem.c \ - $LUA_DIR/lstring.c \ - $LUA_DIR/lundump.c - $LUA_DIR/lcode.c \ - $LUA_DIR/lfunc.c \ - $LUA_DIR/loadlib.c \ - $LUA_DIR/lstrlib.c \ - $LUA_DIR/lutf8lib.c - $LUA_DIR/lcorolib.c \ - $LUA_DIR/lgc.c \ - $LUA_DIR/lobject.c \ - $LUA_DIR/ltable.c \ - $LUA_DIR/lvm.c - $LUA_DIR/lctype.c \ - $LUA_DIR/linit.c \ - $LUA_DIR/lopcodes.c \ - $LUA_DIR/ltablib.c \ - $LUA_DIR/lzio.c - $LUA_DIR/ldblib.c \ - $LUA_DIR/liolib.c \ - $LUA_DIR/loslib.c \ - $LUA_DIR/ltm.c \ - -o package/tangerine/tangerine.out +cmake --build linux/build/Release diff --git a/tangerine/embedding.h b/tangerine/embedding.h index 45f648e..9e02218 100644 --- a/tangerine/embedding.h +++ b/tangerine/embedding.h @@ -15,7 +15,7 @@ #pragma once #define EMBED_LUA 1 -#define EMBED_RACKET 0 +#define EMBED_RACKET 1 #define EMBED_MULTI (EMBED_LUA + EMBED_RACKET) > 1 From 5c30cdefcf5b28750b51db7abfd6cf4c5a45ef91 Mon Sep 17 00:00:00 2001 From: Vivianne Langdon Date: Tue, 28 Jun 2022 22:34:06 -0700 Subject: [PATCH 3/9] fatal error on windows side (probably have to update .sln to ignore cmake) --- CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index ce04d39..375cea2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,13 @@ cmake_minimum_required(VERSION 3.14) project(tangerine) +if (MSVC) + message( + FATAL_ERROR + "Currently CMake is only used on the Linux platform.\ + Visual Studio users should open the .sln file directly, instead.") +endif() + set(CMAKE_CXX_STANDARD 17) set(CMAKE_C_STANDARD 17) From 463d4af659dc7f7aa60eb6e47547b0b086333420 Mon Sep 17 00:00:00 2001 From: Vivianne Langdon Date: Tue, 28 Jun 2022 23:20:16 -0700 Subject: [PATCH 4/9] remove inline which was causing linker errors --- tangerine/gl_boilerplate.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tangerine/gl_boilerplate.cpp b/tangerine/gl_boilerplate.cpp index 3b35802..8c5e428 100644 --- a/tangerine/gl_boilerplate.cpp +++ b/tangerine/gl_boilerplate.cpp @@ -514,7 +514,7 @@ Buffer::~Buffer() } -inline void Buffer::Release() +void Buffer::Release() { if (BufferID != 0) { From d720e06e93158792f2d15edd15581585f8fa665a Mon Sep 17 00:00:00 2001 From: Vivianne Langdon Date: Tue, 28 Jun 2022 23:22:46 -0700 Subject: [PATCH 5/9] add a regen.sh in case it is needed. --- regen.sh | 3 +++ 1 file changed, 3 insertions(+) create mode 100755 regen.sh diff --git a/regen.sh b/regen.sh new file mode 100755 index 0000000..4e17404 --- /dev/null +++ b/regen.sh @@ -0,0 +1,3 @@ +raco exe -v -o delete_me --collects-dest racket/collects ++lib tangerine ++lib tangerine/smol ++lib vec ++lib racket/base/lang/reader ++lib s-exp/lang/reader ++lib at-exp/lang/reader ++lib racket/runtime-config ++lib ffi/unsafe models/basic_thing.rkt + +rm delete_me From cf63ec5397185929ffd970bb9f37997690550299 Mon Sep 17 00:00:00 2001 From: Vivianne Langdon Date: Tue, 28 Jun 2022 23:55:05 -0700 Subject: [PATCH 6/9] switch to gtk3 and support the new lua/racket definitions in cmake (todo: add to shell script) --- CMakeLists.txt | 45 +++++++++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 375cea2..18d2c57 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,22 +2,26 @@ cmake_minimum_required(VERSION 3.14) project(tangerine) if (MSVC) - message( - FATAL_ERROR - "Currently CMake is only used on the Linux platform.\ - Visual Studio users should open the .sln file directly, instead.") + message(FATAL_ERROR + "Currently CMake is only used on the Linux platform.\ + Visual Studio users should open the .sln file directly, instead.") endif() +option(EMBED_LUA "Embed Lua support" ON) +option(EMBED_RACKET "Embed Racket support" OFF) + set(CMAKE_CXX_STANDARD 17) set(CMAKE_C_STANDARD 17) file(GLOB_RECURSE TANGERINE_FILES "tangerine/*.cpp") -file(GLOB TANGERINE_LUA_FILES "third_party/lua-5.4.4/lua/*.c") -list(FILTER - TANGERINE_LUA_FILES - EXCLUDE REGEX - ".*/lua/(onelua|lua|luac)\.c") # these define main +if(EMBED_LUA) + file(GLOB TANGERINE_LUA_FILES "third_party/lua-5.4.4/lua/*.c") + list(FILTER + TANGERINE_LUA_FILES + EXCLUDE REGEX + ".*/lua/(onelua|lua|luac)\.c") # these define main +endif() file(GLOB TANGERINE_IMGUI_FILES "third_party/imgui/*.cpp") @@ -35,9 +39,14 @@ set(TANGERINE_INCLUDE_DIRS "third_party" "third_party/fmt/include" "third_party/imgui" - "third_party/imgui/backends" - "third_party/racket/include" - "third_party/lua-5.4.4") + "third_party/imgui/backends") + +if(EMBED_LUA) + list(APPEND TANGERINE_INCLUDE_DIRS "third_party/lua-5.4.4") +endif() +if(EMBED_RACKET) + list(APPEND TANGERINE_INCLUDE_DIRS "third_party/racket/include") +endif() add_executable(tangerine ${TANGERINE_FILES} @@ -46,13 +55,17 @@ add_executable(tangerine find_package(SDL2 REQUIRED) find_package(PkgConfig REQUIRED) -pkg_check_modules(GTK2 REQUIRED gtk+-2.0) +pkg_check_modules(GTK3 REQUIRED gtk+-3.0) include_directories( ${TANGERINE_INCLUDE_DIRS} - ${GTK2_INCLUDE_DIRS}) + ${GTK3_INCLUDE_DIRS}) + +target_compile_definitions(tangerine PRIVATE + "EMBED_LUA=$" + "EMBED_RACKET=$") target_link_libraries(tangerine SDL2::SDL2 - racketcs + "$<$:racketcs>" tinfo - ${GTK2_LIBRARIES}) + ${GTK3_LIBRARIES}) From 1a6428ffe8564a05e930d9b2d011936759fee391 Mon Sep 17 00:00:00 2001 From: Vivianne Langdon Date: Wed, 29 Jun 2022 00:47:40 -0700 Subject: [PATCH 7/9] support GTK dialog by initializing and running the main loop --- tangerine/tangerine.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tangerine/tangerine.cpp b/tangerine/tangerine.cpp index 3b1ebf0..d5e2ac2 100644 --- a/tangerine/tangerine.cpp +++ b/tangerine/tangerine.cpp @@ -1283,6 +1283,7 @@ void OpenModel() "_Open", GTK_RESPONSE_ACCEPT, nullptr); + gtk_window_present(GTK_WINDOW(Dialog)); gint Result = gtk_dialog_run(GTK_DIALOG(Dialog)); if (Result == GTK_RESPONSE_ACCEPT) { @@ -1953,6 +1954,10 @@ int main(int argc, char* argv[]) CreateLuaEnv(); #endif } + { + std::cout << "Initialize gtk+3.0... "; + gtk_init(&argc, &argv); + } { std::cout << "Setting up Dear ImGui... "; IMGUI_CHECKVERSION(); @@ -2214,6 +2219,7 @@ int main(int argc, char* argv[]) } } EndEvent(); + gtk_main_iteration_do(false); } } std::cout << "Shutting down...\n"; From 3aa9ca06a6ce26ced8654431ffd23e6515f5d85e Mon Sep 17 00:00:00 2001 From: Vivianne Langdon Date: Wed, 29 Jun 2022 00:50:25 -0700 Subject: [PATCH 8/9] revert unrelated change --- tangerine/gl_boilerplate.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/tangerine/gl_boilerplate.cpp b/tangerine/gl_boilerplate.cpp index 8c5e428..a2ac842 100644 --- a/tangerine/gl_boilerplate.cpp +++ b/tangerine/gl_boilerplate.cpp @@ -246,8 +246,6 @@ StatusCode RouteSource(std::vector& BreadCrumbs, std::vector Date: Wed, 29 Jun 2022 01:02:07 -0700 Subject: [PATCH 9/9] remove gtk_windodw_present as it does not do anything --- tangerine/tangerine.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/tangerine/tangerine.cpp b/tangerine/tangerine.cpp index d5e2ac2..b17150f 100644 --- a/tangerine/tangerine.cpp +++ b/tangerine/tangerine.cpp @@ -1283,7 +1283,6 @@ void OpenModel() "_Open", GTK_RESPONSE_ACCEPT, nullptr); - gtk_window_present(GTK_WINDOW(Dialog)); gint Result = gtk_dialog_run(GTK_DIALOG(Dialog)); if (Result == GTK_RESPONSE_ACCEPT) {