Browse Source

Add ability to specify dependency branch

This allowed me to use ImGui docking branch by default, and will be
very useful for other git dependency branching needs.
windows-imgui
Macoy Madson 9 months ago
parent
commit
0d164e2077
  1. 28
      src/Dependencies.cake
  2. 15
      src/ImGui.cake

28
src/Dependencies.cake

@ -1,12 +1,31 @@
(skip-build)
(set-cakelisp-option cakelisp-src-dir "Dependencies/cakelisp/src")
(add-cakelisp-search-directory "Dependencies/cakelisp/runtime")
(import &comptime-only "ComptimeHelpers.cake" "BuildTools.cake")
(import &comptime-only "ComptimeHelpers.cake" "BuildTools.cake" "CHelpers.cake")
;; Define 'Dependencies-Clone-Only to clone only - useful if you don't want to or cannot use git
;; submodules. For example, gamelib/test clones so I don't need to keep removing the test Dependencies.
;; TODO This is pretty wasteful to output a whole new function for this. It should just be a
;; comptime function call with arguments
;; TODO Pitfall: This will pull master, which we might not know works. We need to specify a branch
(defmacro add-dependency-git-submodule (hook-name symbol repository-url string output-directory string)
(defmacro add-dependency-git-submodule (hook-name symbol repository-url string output-directory string
&optional remote-branch-name string)
(var branch-selection (<> std::vector Token))
(when remote-branch-name
(var remote-branch Token (deref remote-branch-name))
(var remote-branch-buffer ([] 256 char) (array 0))
(PrintfBuffer remote-branch-buffer "origin/%s"
(call-on c_str (path remote-branch-name > contents)))
(set (field remote-branch contents) remote-branch-buffer)
(tokenize-push branch-selection
(run-process-sequential-or
("git" "checkout" "--track" (token-splice-addr remote-branch)
:in-directory (token-splice output-directory))
(Logf "error: failed to check out %s branch %s\\n"
(token-splice output-directory) (token-splice-addr remote-branch))
(return false))))
(tokenize-push output
(defun-comptime (token-splice hook-name) (manager (& ModuleManager) module (* Module) &return bool)
(unless (fileExists (token-splice output-directory))
@ -27,9 +46,12 @@
(token-splice output-directory))
(return false))))
(token-splice-array branch-selection)
;; Initialize its submodules, in case it has them
(run-process-sequential-or
("git" "submodule" "update" "--init" "--recursive" :in-directory (token-splice output-directory))
("git" "submodule" "update" "--init" "--recursive"
:in-directory (token-splice output-directory))
(Logf "error: failed to initialize submodules belonging to %s\\n"
(token-splice output-directory))
(return false)))

15
src/ImGui.cake

@ -9,7 +9,9 @@
"imgui_tables.cpp"
"imgui_widgets.cpp")
(add-dependency-git-submodule clone-imgui "https://github.com/ocornut/imgui" "Dependencies/imgui")
(add-dependency-git-submodule clone-imgui "https://github.com/ocornut/imgui"
"Dependencies/imgui"
"docking")
(defmacro imgui-call (function symbol &rest &optional arguments any)
(if arguments
@ -60,8 +62,8 @@
(set (at ImGuiCol_TabActive colors) (ImVec4 0.19f 0.19f 0.19f 0.57f))
(set (at ImGuiCol_TabUnfocused colors) (ImVec4 0.05f 0.05f 0.05f 0.90f))
(set (at ImGuiCol_TabUnfocusedActive colors) (ImVec4 0.13f 0.13f 0.13f 0.74f))
;; (set (at ImGuiCol_DockingPreview colors) (ImVec4 0.47f 0.47f 0.47f 0.47f))
;; (set (at ImGuiCol_DockingEmptyBg colors) (ImVec4 0.20f 0.20f 0.20f 1.00f))
(set (at ImGuiCol_DockingPreview colors) (ImVec4 0.47f 0.47f 0.47f 0.47f))
(set (at ImGuiCol_DockingEmptyBg colors) (ImVec4 0.20f 0.20f 0.20f 1.00f))
(set (at ImGuiCol_PlotLines colors) (ImVec4 0.61f 0.61f 0.61f 1.00f))
(set (at ImGuiCol_PlotLinesHovered colors) (ImVec4 1.00f 0.43f 0.35f 1.00f))
(set (at ImGuiCol_PlotHistogram colors) (ImVec4 0.90f 0.70f 0.00f 1.00f))
@ -116,6 +118,11 @@
(imgui-call CreateContext)
(scope ;; Enable docking
(var imgui-io (& ImGuiIO) (imgui-call GetIO))
(set (field imgui-io ConfigFlags) (bit-or (field imgui-io ConfigFlags)
ImGuiConfigFlags_DockingEnable)))
(scope ;; Enable keyboard navigation
(var imgui-io (& ImGuiIO) (imgui-call GetIO))
(set (field imgui-io ConfigFlags) (bit-or (field imgui-io ConfigFlags)
@ -162,6 +169,8 @@
(ImGui_ImplSDL2_NewFrame window)
(imgui-call NewFrame)
(imgui-call DockSpaceOverViewport (imgui-call GetMainViewport))
(imgui-call ShowDemoWindow)
(imgui-call Render)

Loading…
Cancel
Save