diff options
| author | Carl Hetherington <cth@carlh.net> | 2024-03-02 23:22:59 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2024-03-02 23:22:59 +0100 |
| commit | d6191fcf465ee064ee27689e9f6e540e44219ae2 (patch) | |
| tree | 357f9234bbedb15b57a6e8cf8589b01e79c1e301 /cscript | |
| parent | 39e8c50a2f9bdcf36810ee3d41bcbf1cc78968ae (diff) | |
Add cscript.
Diffstat (limited to 'cscript')
| -rw-r--r-- | cscript | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/cscript b/cscript new file mode 100644 index 00000000..db08dd64 --- /dev/null +++ b/cscript @@ -0,0 +1,32 @@ +import os + +def build(target, options): + cmd = 'cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=%s -DBUILD_PKGCONFIG_FILES=ON -DBUILD_CODEC=OFF' % target.directory + if target.platform == 'windows': + # Hack: the build fails if PATH includes /opt/windows/64/bin; I don't know why: + # remove it + target.set('PATH', '%s:%s' % (target.tool_path, os.environ['PATH'])) + f = open('mingw.cmake', 'w') + print("SET(CMAKE_SYSTEM_NAME Windows)", file=f) + cc = target.get('CC') + cc = cc.replace("ccache ", "") + cc = cc.replace("\"", "") + if target.ccache: + print("set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)", file=f) + print("SET(CMAKE_C_COMPILER %s/%s)" % (target.tool_path, cc), file=f) + print("SET(CMAKE_RC_COMPILER %s/%s)" % (target.tool_path, target.get('WINRC')), file=f) + all = "%s " % target.library_prefix + print("SET(CMAKE_ROOT_FIND_PATH %s %s)" % (all, target.tool_path), file=f) + print("SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)", file=f) + print("SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)", file=f) + print("SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)", file=f) + cmd += ' -DCMAKE_TOOLCHAIN_FILE=mingw.cmake' + f.close() + if target.platform == 'linux': + cmd += ' -DBUILD_SHARED_LIBS=OFF' + if target.platform == 'osx': + cmd += ' -DCMAKE_OSX_SYSROOT=%s/MacOSX%s.sdk' % (target.sdk_prefix, target.sdk) + + target.command(cmd) + target.command('make -j%d VERBOSE=1' % target.parallel) + target.command('make install') |
