mirror of
https://github.com/yuzu-emu/discord-rpc.git
synced 2024-11-27 10:04:25 +01:00
Fix up doing builds script, add packaging up results.
This commit is contained in:
parent
3566190a01
commit
fa39179be7
@ -51,9 +51,4 @@ add_library(rapidjson STATIC IMPORTED ${RAPIDJSON})
|
||||
# add subdirs
|
||||
|
||||
add_subdirectory(src)
|
||||
add_subdirectory(examples/send-presence)
|
||||
|
||||
add_custom_target(bundle
|
||||
WORKING_DIRECTORY "${CMAKE_INSTALL_PREFIX}"
|
||||
COMMAND ${CMAKE_COMMAND} -E tar cfvz "${CMAKE_BINARY_DIR}/discord-rpc.tar.gz" .
|
||||
)
|
||||
add_subdirectory(examples/send-presence)
|
53
build.py
53
build.py
@ -1,7 +1,9 @@
|
||||
import click
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import shutil
|
||||
import zipfile
|
||||
from contextlib import contextmanager
|
||||
|
||||
|
||||
@ -25,10 +27,13 @@ def mkdir_p(path):
|
||||
os.makedirs(path)
|
||||
|
||||
|
||||
def build(build_path, generator, options):
|
||||
def build_lib(build_name, generator, options):
|
||||
build_path = os.path.join(SCRIPT_PATH, 'builds', build_name)
|
||||
install_path = os.path.join(SCRIPT_PATH, 'builds', 'install', build_name)
|
||||
mkdir_p(build_path)
|
||||
mkdir_p(install_path)
|
||||
with cd(build_path):
|
||||
initial_cmake = ['cmake', SCRIPT_PATH]
|
||||
initial_cmake = ['cmake', SCRIPT_PATH, '-DCMAKE_INSTALL_PREFIX=%s' % os.path.join('..', 'install', build_name)]
|
||||
if generator:
|
||||
initial_cmake.extend(['-G', generator])
|
||||
for key in options:
|
||||
@ -36,25 +41,47 @@ def build(build_path, generator, options):
|
||||
initial_cmake.append('-D%s=%s' %(key, val))
|
||||
subprocess.check_call(initial_cmake)
|
||||
subprocess.check_call(['cmake', '--build', '.', '--config', 'Debug'])
|
||||
subprocess.check_call(['cmake', '--build', '.', '--config', 'Release'])
|
||||
subprocess.check_call(['cmake', '--build', '.', '--config', 'Release', '--target', 'install'])
|
||||
|
||||
|
||||
def main():
|
||||
def create_archive():
|
||||
archive_file_path = os.path.join(SCRIPT_PATH, 'builds', 'discord-rpc.zip')
|
||||
archive_file = zipfile.ZipFile(archive_file_path, 'w', zipfile.ZIP_DEFLATED)
|
||||
archive_src_base_path = os.path.join(SCRIPT_PATH, 'builds', 'install')
|
||||
archive_dst_base_path = 'discord-rpc'
|
||||
with cd(archive_src_base_path):
|
||||
for path, subdirs, filenames in os.walk('.'):
|
||||
for fname in filenames:
|
||||
fpath = os.path.join(path, fname)
|
||||
archive_file.write(fpath, os.path.normpath(os.path.join(archive_dst_base_path, fpath)))
|
||||
|
||||
|
||||
@click.command()
|
||||
@click.option('--clean', is_flag=True)
|
||||
def main(clean):
|
||||
os.chdir(SCRIPT_PATH)
|
||||
|
||||
if clean:
|
||||
shutil.rmtree('builds', ignore_errors=True)
|
||||
|
||||
if sys.platform.startswith('win'):
|
||||
generator = 'Visual Studio 14 2015'
|
||||
build(os.path.join(SCRIPT_PATH, 'builds', 'win32-static'), generator, {})
|
||||
build(os.path.join(SCRIPT_PATH, 'builds', 'win32-dynamic'), generator, {'BUILD_DYNAMIC_LIB': True})
|
||||
generator = 'Visual Studio 14 2015 Win64'
|
||||
build(os.path.join(SCRIPT_PATH, 'builds', 'win64-static'), generator, {})
|
||||
build(os.path.join(SCRIPT_PATH, 'builds', 'win64-dynamic'), generator, {'BUILD_DYNAMIC_LIB': True})
|
||||
generator32 = 'Visual Studio 14 2015'
|
||||
generator64 = 'Visual Studio 14 2015 Win64'
|
||||
|
||||
build_lib('win32-static', generator32, {})
|
||||
build_lib('win32-dynamic', generator32, {'BUILD_DYNAMIC_LIB': True})
|
||||
build_lib('win64-static', generator64, {})
|
||||
build_lib('win64-dynamic', generator64, {'BUILD_DYNAMIC_LIB': True})
|
||||
|
||||
# todo: this in some better way
|
||||
src_dll = os.path.join(SCRIPT_PATH, 'builds', 'win64-dynamic', 'src', 'Release', 'discord-rpc.dll')
|
||||
dst_dll = os.path.join(SCRIPT_PATH, 'examples\\button-clicker\\Assets\\Resources\\discord-rpc.dll')
|
||||
dst_dll = os.path.join(SCRIPT_PATH, 'examples', 'button-clicker', 'Assets', 'Resources', 'discord-rpc.dll')
|
||||
shutil.copy(src_dll, dst_dll)
|
||||
dst_dll = os.path.join(SCRIPT_PATH, 'examples\\unrealstatus\\Plugins\\discordrpc\\Binaries\\ThirdParty\\discordrpcLibrary\\Win64\\discord-rpc.dll')
|
||||
dst_dll = os.path.join(SCRIPT_PATH, 'examples', 'unrealstatus', 'Plugins', 'discordrpc', 'Binaries', 'ThirdParty', 'discordrpcLibrary', 'Win64', 'discord-rpc.dll')
|
||||
shutil.copy(src_dll, dst_dll)
|
||||
|
||||
create_archive()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
sys.exit(main())
|
@ -1,3 +1,10 @@
|
||||
include_directories(${PROJECT_SOURCE_DIR}/include)
|
||||
add_executable(send-presence send-presence.c)
|
||||
target_link_libraries(send-presence discord-rpc)
|
||||
|
||||
install(
|
||||
TARGETS send-presence
|
||||
RUNTIME
|
||||
DESTINATION "bin"
|
||||
CONFIGURATIONS Release
|
||||
)
|
@ -3,10 +3,6 @@ include_directories(${PROJECT_SOURCE_DIR}/include)
|
||||
option(ENABLE_IO_THREAD "Start up a separate I/O thread, otherwise I'd need to call an update function" ON)
|
||||
option(BUILD_DYNAMIC_LIB "Build library as a DLL" OFF)
|
||||
|
||||
if (NOT ${ENABLE_IO_THREAD})
|
||||
add_definitions(-DDISCORD_DISABLE_IO_THREAD)
|
||||
endif (NOT ${ENABLE_IO_THREAD})
|
||||
|
||||
set(BASE_RPC_SRC
|
||||
${PROJECT_SOURCE_DIR}/include/discord-rpc.h
|
||||
discord-rpc.cpp
|
||||
@ -40,6 +36,10 @@ endif(UNIX)
|
||||
|
||||
target_include_directories(discord-rpc PRIVATE ${RAPIDJSON}/include)
|
||||
|
||||
if (NOT ${ENABLE_IO_THREAD})
|
||||
add_definitions(discord-rpc PUBLIC -DDISCORD_DISABLE_IO_THREAD)
|
||||
endif (NOT ${ENABLE_IO_THREAD})
|
||||
|
||||
if (${BUILD_DYNAMIC_LIB})
|
||||
target_compile_definitions(discord-rpc PUBLIC -DDISCORD_DYNAMIC_LIB)
|
||||
target_compile_definitions(discord-rpc PRIVATE -DDISCORD_BUILDING_SDK)
|
||||
@ -52,13 +52,21 @@ add_dependencies(discord-rpc clangformat)
|
||||
install(
|
||||
TARGETS discord-rpc
|
||||
EXPORT "discord-rpc"
|
||||
LIBRARY DESTINATION "lib"
|
||||
ARCHIVE DESTINATION "lib"
|
||||
INCLUDES DESTINATION "include"
|
||||
RUNTIME
|
||||
DESTINATION "bin"
|
||||
CONFIGURATIONS Release
|
||||
LIBRARY
|
||||
DESTINATION "lib"
|
||||
CONFIGURATIONS Release
|
||||
ARCHIVE
|
||||
DESTINATION "lib"
|
||||
CONFIGURATIONS Release
|
||||
INCLUDES
|
||||
DESTINATION "include"
|
||||
)
|
||||
|
||||
install(
|
||||
FILES
|
||||
"../include/discord-rpc.h"
|
||||
DESTINATION "include"
|
||||
)
|
||||
)
|
Loading…
Reference in New Issue
Block a user