Fix up doing builds script, add packaging up results.

This commit is contained in:
Chris Marsh 2017-09-07 09:05:41 -07:00
parent 3566190a01
commit fa39179be7
4 changed files with 64 additions and 27 deletions

View File

@ -51,9 +51,4 @@ add_library(rapidjson STATIC IMPORTED ${RAPIDJSON})
# add subdirs # add subdirs
add_subdirectory(src) add_subdirectory(src)
add_subdirectory(examples/send-presence) 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" .
)

View File

@ -1,7 +1,9 @@
import click
import os import os
import subprocess import subprocess
import sys import sys
import shutil import shutil
import zipfile
from contextlib import contextmanager from contextlib import contextmanager
@ -25,10 +27,13 @@ def mkdir_p(path):
os.makedirs(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(build_path)
mkdir_p(install_path)
with cd(build_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: if generator:
initial_cmake.extend(['-G', generator]) initial_cmake.extend(['-G', generator])
for key in options: for key in options:
@ -36,25 +41,47 @@ def build(build_path, generator, options):
initial_cmake.append('-D%s=%s' %(key, val)) initial_cmake.append('-D%s=%s' %(key, val))
subprocess.check_call(initial_cmake) subprocess.check_call(initial_cmake)
subprocess.check_call(['cmake', '--build', '.', '--config', 'Debug']) 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) os.chdir(SCRIPT_PATH)
if clean:
shutil.rmtree('builds', ignore_errors=True)
if sys.platform.startswith('win'): if sys.platform.startswith('win'):
generator = 'Visual Studio 14 2015' generator32 = 'Visual Studio 14 2015'
build(os.path.join(SCRIPT_PATH, 'builds', 'win32-static'), generator, {}) generator64 = 'Visual Studio 14 2015 Win64'
build(os.path.join(SCRIPT_PATH, 'builds', 'win32-dynamic'), generator, {'BUILD_DYNAMIC_LIB': True})
generator = 'Visual Studio 14 2015 Win64' build_lib('win32-static', generator32, {})
build(os.path.join(SCRIPT_PATH, 'builds', 'win64-static'), generator, {}) build_lib('win32-dynamic', generator32, {'BUILD_DYNAMIC_LIB': True})
build(os.path.join(SCRIPT_PATH, 'builds', 'win64-dynamic'), generator, {'BUILD_DYNAMIC_LIB': True}) build_lib('win64-static', generator64, {})
build_lib('win64-dynamic', generator64, {'BUILD_DYNAMIC_LIB': True})
# todo: this in some better way # todo: this in some better way
src_dll = os.path.join(SCRIPT_PATH, 'builds', 'win64-dynamic', 'src', 'Release', 'discord-rpc.dll') 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) 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) shutil.copy(src_dll, dst_dll)
create_archive()
if __name__ == '__main__': if __name__ == '__main__':
sys.exit(main()) sys.exit(main())

View File

@ -1,3 +1,10 @@
include_directories(${PROJECT_SOURCE_DIR}/include) include_directories(${PROJECT_SOURCE_DIR}/include)
add_executable(send-presence send-presence.c) add_executable(send-presence send-presence.c)
target_link_libraries(send-presence discord-rpc) target_link_libraries(send-presence discord-rpc)
install(
TARGETS send-presence
RUNTIME
DESTINATION "bin"
CONFIGURATIONS Release
)

View File

@ -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(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) 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 set(BASE_RPC_SRC
${PROJECT_SOURCE_DIR}/include/discord-rpc.h ${PROJECT_SOURCE_DIR}/include/discord-rpc.h
discord-rpc.cpp discord-rpc.cpp
@ -40,6 +36,10 @@ endif(UNIX)
target_include_directories(discord-rpc PRIVATE ${RAPIDJSON}/include) 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}) if (${BUILD_DYNAMIC_LIB})
target_compile_definitions(discord-rpc PUBLIC -DDISCORD_DYNAMIC_LIB) target_compile_definitions(discord-rpc PUBLIC -DDISCORD_DYNAMIC_LIB)
target_compile_definitions(discord-rpc PRIVATE -DDISCORD_BUILDING_SDK) target_compile_definitions(discord-rpc PRIVATE -DDISCORD_BUILDING_SDK)
@ -52,13 +52,21 @@ add_dependencies(discord-rpc clangformat)
install( install(
TARGETS discord-rpc TARGETS discord-rpc
EXPORT "discord-rpc" EXPORT "discord-rpc"
LIBRARY DESTINATION "lib" RUNTIME
ARCHIVE DESTINATION "lib" DESTINATION "bin"
INCLUDES DESTINATION "include" CONFIGURATIONS Release
LIBRARY
DESTINATION "lib"
CONFIGURATIONS Release
ARCHIVE
DESTINATION "lib"
CONFIGURATIONS Release
INCLUDES
DESTINATION "include"
) )
install( install(
FILES FILES
"../include/discord-rpc.h" "../include/discord-rpc.h"
DESTINATION "include" DESTINATION "include"
) )