diff --git a/wscript b/wscript index 39f4307..62032bb 100644 --- a/wscript +++ b/wscript @@ -3,12 +3,14 @@ import os import shutil +import platform from waflib import Build, Errors, Logs APPNAME = "srt" VERSION = "1.1.0" CMAKE_BUILD_TYPE = "Debug" +lib_name = None def configure(conf): if conf.has_tool_option("cxx_debug"): @@ -17,23 +19,32 @@ def configure(conf): - -def build(bld): +def pre(bld): bld.find_program("cmake", mandatory=True, quiet=1, output=0) bld.post_mode = Build.POST_LAZY root_dir = bld.dependency_node("srt-source") - + if platform.system() == "Windows": + lib_name = "srt_static.lib" + elif platform.system() == "Darwin": + lib_name = "libsrt.a" + elif platform.system() == "Linux": + lib_name = "libsrt.a" + else: + Logs.error("Unsupported platform") + return -1 target = bld.bldnode.make_node("srt") - bld(rule=CMakeBuildTask, target=target.make_node('flag.lock'), source=root_dir) - bld.add_group() - lib_path = target.find_node("lib") - include_path = target.find_node("include") - print("lib path: ", lib_path) - print("include path: ", include_path) + bld(name="srt_lib",rule=CMakeBuildTask, target=target.make_node('flag.lock'), source=root_dir ) + + + +def post(bld): + lib_path = bld.path.find_node("srt/lib") + include_path = bld.path.find_node("srt/include") bld(name="srt_includes", export_includes=[include_path]) - bld.read_stlib('srt_static', paths=[lib_path], export_includes=[include_path]) - - + + bld.read_stlib(lib_name, paths=[lib_path], export_includes=[include_path]) + + if bld.is_toplevel(): bld.program( features="cxx test", @@ -43,6 +54,14 @@ def build(bld): use=["srt_static", "srt_includes", "gtest", "platform_includes" ], ) +def build(bld): + bld.add_pre_fun(pre) + bld.add_post_fun(post) + + + + + def CMakeBuildTask(task): output = task.outputs[0].parent