-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable shared libs compilation by compiling directly the lib
- Loading branch information
1 parent
b6a0900
commit 24d3476
Showing
4 changed files
with
79 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
This folder doesn't contain any Luos_engine code, you should have a look at: | ||
|
||
- [engine](../engine) folder if you are interested in the core code of Luos_engine. | ||
- [network](../network) folder if you are interested in the network code of Luos_engine. | ||
- [tool_services](../tool_services) folder if you are interested in the Gate or Pipe code of Luos_engine. | ||
- [examples](../../examples) folder if you are interested in examples of Luos_engine usage. | ||
|
||
This folder only contain specific files allowing to compile Luos_engine as a shared lib. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// This file only allow to compile the project. | ||
#include "serial_network.h" | ||
#include "ws_network.h" | ||
#include "robus_network.h" | ||
|
||
int main(void) | ||
{ | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
Import("env") | ||
import os | ||
import platform as pf | ||
import click | ||
|
||
def shared_lib(source, target, env): | ||
# Try to find the luos_engine.a somwhere on $BUILD_DIR/*/ archive and save it to a libPath variable | ||
libPath = None | ||
for root, dirs, files in os.walk(env.subst("$BUILD_DIR")): | ||
for file in files: | ||
if file.endswith("luos_engine.a"): | ||
libPath = os.path.join(root, file) | ||
break | ||
if libPath is not None: | ||
break | ||
# Try to find all the network libs | ||
networklibs = [] | ||
for root, dirs, files in os.walk(env.subst("$BUILD_DIR")): | ||
for file in files: | ||
if file.endswith("network.a"): | ||
networklibs.append(os.path.join(root, file)) | ||
break | ||
|
||
if libPath is not None: | ||
# Convert the luos_engine.a archive to a shared library | ||
if (pf.system() == 'Windows'): | ||
env.Execute("gcc -O2 -shared -o $BUILD_DIR/libluos_engine.dll " + libPath) | ||
click.secho("* Luos engine shared library available in " + str(env.subst("$BUILD_DIR")) + "/libluos_engine.dll .", fg="green") | ||
elif (pf.system() == 'Linux'): | ||
env.Execute("gcc -O2 -shared -o $BUILD_DIR/libluos_engine.so " + libPath) | ||
click.secho("* Luos engine shared library available in " + str(env.subst("$BUILD_DIR")) + "/libluos_engine.so .", fg="green") | ||
elif (pf.system() == 'Darwin'): | ||
for networklib in networklibs: | ||
env.Execute("gcc -O2 -shared -o $BUILD_DIR/" + os.path.basename(networklib)[0:-10] + "_luos_engine.dylib " + libPath + " " + networklib) | ||
|
||
click.secho("\n") | ||
click.secho("Luos engine shared libraries available in " + str(env.subst("$BUILD_DIR")) + "/ :", underline=True) | ||
for networklib in networklibs: | ||
click.secho("\t* " + os.path.basename(networklib)[0:-10] + "_luos_engine.dylib ", fg="green") | ||
|
||
env.AddPostAction("$PROGPATH", shared_lib) |