Skip to content

Commit

Permalink
Test link to "external" libraries.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarod42 committed Jan 5, 2024
1 parent 4ae82c0 commit 4ea4427
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 0 deletions.
3 changes: 3 additions & 0 deletions projects/project-linkexternalproject/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## project-externalproject

Test [`externalproject`](https://premake.github.io/docs/externalproject)
32 changes: 32 additions & 0 deletions projects/project-linkexternalproject/pre-premake5.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
local Root = path.getabsolute(".")

if (_ACTION == nil) then
return
end

local LocationDir = path.join(Root, "external_solution", _ACTION)

workspace "Project"
location(LocationDir)
configurations {"Debug", "Release"}

objdir(path.join(LocationDir, "obj")) -- premake adds $(configName)/$(AppName)
startproject "externalStaticLib"

project "externalStaticLib"
filename "StaticLib"
kind "StaticLib"
language "C++"
targetdir(path.join(LocationDir, "bin/%{cfg.buildcfg}"))
targetname("externalStaticLib")

files { path.join(Root, "src/staticLib/**") }

project "externalSharedLib"
filename "SharedLib"
kind "SharedLib"
language "C++"
targetdir(path.join("solution", _ACTION, "bin/%{cfg.buildcfg}"))
targetname("externalSharedLib")

files { "src/sharedLib/**" }
25 changes: 25 additions & 0 deletions projects/project-linkexternalproject/premake5.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
local Root = path.getabsolute(".")

if (_ACTION == nil) then
return
end

local LocationDir = path.join(Root, "solution", _ACTION)

workspace "Project"
location(LocationDir)
configurations {"Debug", "Release"}

objdir(path.join(LocationDir, "obj")) -- premake adds $(configName)/$(AppName)
targetdir(path.join(LocationDir, "bin/%{cfg.buildcfg}"))
startproject "app"

project "app"
kind "ConsoleApp"
targetname "app"

files { "src/app/main.cpp" }

libdirs{path.join("external_solution", _ACTION, "bin", "%{cfg.buildcfg}")}
libdirs{path.join(LocationDir, "bin", "%{cfg.buildcfg}")}
links {"externalStaticLib", "externalSharedLib"}
14 changes: 14 additions & 0 deletions projects/project-linkexternalproject/src/app/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#ifdef _MSC_VER
# define DLL_IMPORT __declspec(dllimport) // used when called internally
#else
# define DLL_IMPORT
#endif

void staticLibFunction();
DLL_IMPORT void sharedLibFunction();

int main()
{
staticLibFunction();
sharedLibFunction();
}
7 changes: 7 additions & 0 deletions projects/project-linkexternalproject/src/sharedlib/lib.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#ifdef _MSC_VER
#define DLL_EXPORT __declspec(dllexport) // used when called from DLL
#else
#define DLL_EXPORT
#endif

DLL_EXPORT void sharedLibFunction() {}
1 change: 1 addition & 0 deletions projects/project-linkexternalproject/src/staticlib/lib.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
void staticLibFunction() {}
7 changes: 7 additions & 0 deletions test_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,13 @@ def select_action_runner(action):
print(project, 'KO (prephase)', flush=True)
ko_projects.append(project + ' (prephase)')
continue
oldcwd = os.getcwd()
os.chdir(os.path.join(project_dir, 'external_solution', action))
ret = run_action()
if ret != 0:
print(project, 'KO', ret, flush=True)
ko_projects.append(project + ' Generation (prephase)')
os.chdir(oldcwd)

print('run:', [premake, '--file=' + premake_lua, action] + options, flush=True)
ret = subprocess.run([premake, '--file=' + premake_lua, action] + options)
Expand Down

0 comments on commit 4ea4427

Please sign in to comment.