Skip to content

Commit

Permalink
Merge pull request #78 from Faless/build/split_deps
Browse files Browse the repository at this point in the history
[SCons] Refactor build tools.
  • Loading branch information
Faless authored Jan 9, 2023
2 parents 5348407 + bdd9d50 commit 40962db
Show file tree
Hide file tree
Showing 8 changed files with 254 additions and 276 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ jobs:
- name: Compile Extension - template_debug - ${{ matrix.platform }} - ${{ matrix.arch }}
run: |
scons target=template_debug generate_bindings=yes
scons target=template_debug
- name: Compile Extension - template_release - ${{ matrix.platform }} - ${{ matrix.arch }}
run: |
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ bin/*
.sconsign.dblite
*.obj
*.swp
__pycache__/*
*.pyc
34 changes: 6 additions & 28 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import os, sys, platform, json, subprocess

import builders


def add_sources(sources, dirpath, extension):
for f in os.listdir(dirpath):
Expand Down Expand Up @@ -101,27 +99,12 @@ else:
result_path = os.path.join("bin", "extension", "webrtc")

# Dependencies
env.Append(BUILDERS={
"BuildOpenSSL": env.Builder(action=builders.ssl_action, emitter=builders.ssl_emitter),
"BuildLibDataChannel": env.Builder(action=builders.rtc_action, emitter=builders.rtc_emitter),
})

# SSL
ssl = env.BuildOpenSSL(env.Dir(builders.get_ssl_build_dir(env)), env.Dir(builders.get_ssl_source_dir(env)))
env.Depends(ssl, [env.File("builders.py"), env.File(builders.get_ssl_source_dir(env) + "/VERSION.dat")])
env.NoCache(ssl) # Needs refactoring to properly cache generated headers.

env.Prepend(CPPPATH=[builders.get_ssl_include_dir(env)])
env.Prepend(LIBPATH=[builders.get_ssl_build_dir(env)])
env.Append(LIBS=[builders.get_ssl_libs(env)])

# RTC
rtc = env.BuildLibDataChannel(env.Dir(builders.get_rtc_build_dir(env)), [env.Dir(builders.get_rtc_source_dir(env))] + ssl)
env.Depends(rtc, [env.File("builders.py"), env.File(builders.get_rtc_source_dir(env) + "/CMakeLists.txt")])
for tool in ["cmake", "common", "ssl", "rtc"]:
env.Tool(tool, toolpath=["tools"])

env.Append(LIBPATH=[builders.get_rtc_build_dir(env)])
env.Append(CPPPATH=[builders.get_rtc_include_dir(env)])
env.Prepend(LIBS=[builders.get_rtc_libs(env)])
ssl = env.BuildOpenSSL()
env.NoCache(ssl) # Needs refactoring to properly cache generated headers.
rtc = env.BuildLibDataChannel()

# Our includes and sources
env.Append(CPPPATH=["src/"])
Expand All @@ -140,15 +123,10 @@ else:
sources.append("src/init_gdnative.cpp")
add_sources(sources, "src/net/", "cpp")

env.Depends(sources, [builders.get_ssl_libs(env), builders.get_rtc_libs(env)])
env.Depends(sources, [ssl, rtc])

# Make the shared library
result_name = "webrtc_native{}{}".format(env["suffix"], env["SHLIBSUFFIX"])
env.Depends(sources, ssl)

if env["platform"] == "windows" and env["use_mingw"]:
env.Append(LIBS=["iphlpapi", "ws2_32", "bcrypt"])

library = env.SharedLibrary(target=os.path.join(result_path, "lib", result_name), source=sources)
Default(library)

Expand Down
247 changes: 0 additions & 247 deletions builders.py

This file was deleted.

27 changes: 27 additions & 0 deletions tools/cmake.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

def exists(env):
return True


def generate(env):
env.AddMethod(cmake_configure, "CMakeConfigure")
env.AddMethod(cmake_build, "CMakeBuild")


def cmake_configure(env, source, target, opt_args):
args = [
"-B",
target,
]
if env["platform"] == "windows" and env["use_mingw"]:
args.extend(["-G", "Unix Makefiles"])
for arg in opt_args:
args.append(arg)
args.append(source)
return env.Execute("cmake " + " ".join(['"%s"' % a for a in args]))


def cmake_build(env, source, target=""):
jobs = env.GetOption("num_jobs")
env = env.Clone()
return env.Execute("cmake --build %s %s -j%s" % (source, "-t %s" % target if target else "", jobs))
8 changes: 8 additions & 0 deletions tools/common.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

def exists(env):
return True


def generate(env):
env["DEPS_SOURCE"] = env.Dir("#thirdparty").abspath
env["DEPS_BUILD"] = env.Dir("#bin/thirdparty").abspath + "/{}.{}.dir".format(env["suffix"][1:], "RelWithDebInfo" if env["debug_symbols"] else "Release")
Loading

0 comments on commit 40962db

Please sign in to comment.