Kaynağa Gözat

Added basic dependency system.

It lacks many features like adding automatically to a workspace the
dependency projects or solving possible circular dependencies. But it
does help a bit for includes/links for now.
Eiyeron Fulmincendii 5 yıl önce
ebeveyn
işleme
4c50508d93
1 değiştirilmiş dosya ile 20 ekleme ve 2 silme
  1. 20 2
      prelude/init.lua

+ 20 - 2
prelude/init.lua

@@ -41,6 +41,18 @@ local function base_workspace_settings()
     filter {}
 end
 
+local function selective_dependency_link(module_entries)
+    for _, mod in pairs(module_entries) do
+        if mod[1] ~= "None" then
+            links(mod.name)
+        end
+    end
+
+    for _, mod in pairs(module_entries) do
+        includedirs(mod[1].public_includes)
+    end
+end
+
 local function link_against_modules(modules)
     for _, mod in pairs(modules) do
         links(mod.name)
@@ -48,6 +60,9 @@ local function link_against_modules(modules)
     for _, mod in pairs(modules) do
         includedirs(mod.public_includes)
     end
+    for _, mod in pairs(modules) do
+        selective_dependency_link(mod.module_dependencies)
+    end
 end
 
 --- An attempt at making a common ground for multiple libraries I'd use
@@ -139,8 +154,9 @@ local function library_module(lib_name, folder)
         return self
     end
 
-    function mod:require_module(module)
-        self.module_dependencies:insert(module)
+    function mod:require_module(module, link_type)
+        table.insert(self.module_dependencies, {module, link_type})
+        return self
     end
 
     function mod:use_links(links)
@@ -170,6 +186,8 @@ local function library_module(lib_name, folder)
             includedirs(self.private_includes)
             links(self.links)
 
+            selective_dependency_link(self.module_dependencies)
+
             filter "system:windows"
                 defines(self.win_defines)
                 files(self.win_files)