Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Re-pull-request] Build system - Replace *_build_externals and *-pre-copy-binaries bash scripts with CMake #3132

Merged
merged 14 commits into from
Jul 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 34 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ jobs:
CC: ${{ matrix.cc }}
QT_INSTALL_LOCATION: ${{env.Qt6_DIR}}
run: |
./linux-config.sh
./linux-config.sh --config ${{ matrix.build_type }}
if: matrix.os == 'ubuntu-latest'

# Run Configuration Config on Mac
Expand All @@ -166,7 +166,7 @@ jobs:
CC: ${{ matrix.cc }}
QT_INSTALL_LOCATION: ${{env.Qt6_DIR}}
run: |
./mac-config.sh
./mac-config.sh --config ${{ matrix.build_type }}
if: matrix.os == 'macos-latest'

# Run Configuration Config on Windows
Expand All @@ -181,9 +181,38 @@ jobs:
if: matrix.os == 'windows-latest'

# Finally: Build
- name: Do build
working-directory: ${{github.workspace}}/app/build
run: cmake --build . --config ${{ matrix.build_type }}
- name: Build Linux
working-directory: ${{github.workspace}}/app
run: ./linux-build-gui.sh
if: matrix.os == 'ubuntu-latest'

- name: Build Mac
working-directory: ${{github.workspace}}/app
run: ./mac-build-gui.sh
if: matrix.os == 'macos-latest'

- name: Build Windows
working-directory: ${{github.workspace}}/app
shell: cmd
run: win-build-gui.bat ${{ matrix.build_type }}
if: matrix.os == 'windows-latest'

# Build Tau server
- name: Build Tau Server (Linux)
working-directory: ${{github.workspace}}/app
run: ./linux-post-tau-prod-release.sh
if: matrix.os == 'ubuntu-latest'

- name: Build Tau Server (Mac)
working-directory: ${{github.workspace}}/app
run: ./mac-post-tau-prod-release.sh
if: matrix.os == 'macos-latest'

- name: Build Tau Server (Windows)
working-directory: ${{github.workspace}}/app
shell: cmd
run: win-post-tau-prod-release.bat
if: matrix.os == 'windows-latest'

- name: BEAM Tests Windows
shell: cmd
Expand Down
1 change: 1 addition & 0 deletions app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ include(cmake/common.cmake)

configure_file(${APP_ROOT}/cmake/config.h.cmake ${CMAKE_BINARY_DIR}/config.h)

add_subdirectory(external)
add_subdirectory(api)
add_subdirectory(api-tests)
add_subdirectory(gui)
47 changes: 44 additions & 3 deletions app/external/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,21 @@ cmake_minimum_required(VERSION 3.13)

message(STATUS " Aubio Builder")

if(WIN32)
set(ERLANG_INCLUDE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../prebuilt/windows/headers/erlang CACHE STRING "Path to the Erlang header files")
elseif(${CMAKE_SYSTEM_NAME} MATCHES Darwin) # macOS
set(ERLANG_INCLUDE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../prebuilt/macos/headers/erlang CACHE STRING "Path to the Erlang header files")
else()
execute_process(
COMMAND erl -noshell -eval "io:format(\"~s~n\", [filename:join([lists:concat([code:root_dir(), \"/erts-\", erlang:system_info(version)]), \"include\"])]), init:stop(0)."
OUTPUT_VARIABLE FOUND_ERLANG_INCLUDE_PATH OUTPUT_STRIP_TRAILING_WHITESPACE)
set(ERLANG_INCLUDE_PATH ${FOUND_ERLANG_INCLUDE_PATH} CACHE STRING "Path to the Erlang header files")
endif()
option(USE_SYSTEM_LIBS "Use system libraries instead of bundled libraries when building" OFF)

message(STATUS "ERLANG_INCLUDE_PATH: ${ERLANG_INCLUDE_PATH}")
message(STATUS "USE_SYSTEM_LIBS: ${USE_SYSTEM_LIBS}")

project(AubioBuilder
LANGUAGES CXX C
VERSION 1.0.0
Expand All @@ -17,8 +32,9 @@ project(AubioBuilder
ExternalProject_Add(sp_midi
PREFIX sp_midi-prefix
SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/sp_midi
INSTALL_COMMAND ""
INSTALL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../server/beam/tau/priv
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_SOURCE_DIR}/../server/beam/tau/priv
-DERLANG_INCLUDE_PATH=${ERLANG_INCLUDE_PATH}
-DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}
-DUSE_SYSTEM_RTMIDI=${USE_SYSTEM_LIBS}
Expand All @@ -28,8 +44,9 @@ ExternalProject_Add(sp_midi
ExternalProject_Add(sp_link
PREFIX sp_link-prefix
SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/sp_link
INSTALL_COMMAND ""
INSTALL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../server/beam/tau/priv
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_SOURCE_DIR}/../server/beam/tau/priv
-DERLANG_INCLUDE_PATH=${ERLANG_INCLUDE_PATH}
-DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}
BUILD_COMMAND ${CMAKE_COMMAND} --build . --config Release
Expand Down Expand Up @@ -142,11 +159,35 @@ ExternalProject_Add(aubio
-DPC_VORBISENC_INCLUDE_DIRS=${CMAKE_BINARY_DIR}/vorbis-package/include
-DPC_OPUS_INCLUDE_DIRS=${CMAKE_BINARY_DIR}/opus-package/include
-DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}
INSTALL_COMMAND ""
INSTALL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../server/native
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_SOURCE_DIR}/../server/native
)

# Kick off a generation by making a dummy/empty project
add_library(AubioBuilder STATIC externals.cpp)

# Dependency ensures the externals are built
add_dependencies(AubioBuilder aubio)

# Copy prebuilt files
if(WIN32)
if(CMAKE_SIZEOF_VOID_P EQUAL 8) # 64-bit
add_custom_command(
TARGET AubioBuilder PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/../../prebuilt/windows/x64/ ${CMAKE_CURRENT_SOURCE_DIR}/../server/native/
)
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4) # 32-bit
add_custom_command(
TARGET AubioBuilder PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/../../prebuilt/windows/x86/ ${CMAKE_CURRENT_SOURCE_DIR}/../server/native/
)
endif()
elseif(${CMAKE_SYSTEM_NAME} MATCHES Darwin) # macOS
add_custom_command(
TARGET AubioBuilder PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/../../prebuilt/macos/x64/ ${CMAKE_CURRENT_SOURCE_DIR}/../server/native/
COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_CURRENT_SOURCE_DIR}/../server/native/supercollider/scsynth ${CMAKE_CURRENT_SOURCE_DIR}/../server/native/scsynth
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/../server/native/supercollider/extra-plugins/ ${CMAKE_CURRENT_SOURCE_DIR}/../server/native/supercollider/plugins/
COMMAND ${CMAKE_COMMAND} -E rm -rf ${CMAKE_CURRENT_SOURCE_DIR}/../server/native/supercollider/extra-plugins
)
endif()
5 changes: 5 additions & 0 deletions app/external/aubio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -250,3 +250,8 @@ elseif(${CMAKE_SYSTEM_NAME} MATCHES Darwin) # macOS
else()
message(FATAL_ERROR "Aubio is not supported on this platform.")
endif()

install(TARGETS ${PROJECT_NAME}
LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
install(TARGETS aubio_onset
RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX})
16 changes: 0 additions & 16 deletions app/external/linux_build_externals.sh

This file was deleted.

16 changes: 0 additions & 16 deletions app/external/mac_build_externals.sh

This file was deleted.

6 changes: 6 additions & 0 deletions app/external/sp_link/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,9 @@ elseif(UNIX)
include_directories(${ERLANG_INCLUDE_PATH})
target_link_libraries(libsp_link Ableton::Link)
endif(MSVC)

if(APPLE)
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libsp_link.dylib DESTINATION ${CMAKE_INSTALL_PREFIX} RENAME libsp_link.so)
else()
install(TARGETS libsp_link LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX})
endif()
5 changes: 5 additions & 0 deletions app/external/sp_midi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,8 @@ elseif(UNIX)
endif(USE_SYSTEM_RTMIDI)
endif(MSVC)

if(APPLE)
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libsp_midi.dylib DESTINATION ${CMAKE_INSTALL_PREFIX} RENAME libsp_midi.so)
else()
install(TARGETS libsp_midi LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX})
endif()
9 changes: 0 additions & 9 deletions app/external/win_x64_build_externals.bat

This file was deleted.

6 changes: 0 additions & 6 deletions app/external/win_x86_build_externals.bat

This file was deleted.

1 change: 1 addition & 0 deletions app/linux-build-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ WORKING_DIR="$(pwd)"
"${SCRIPT_DIR}"/linux-prebuild.sh "$@"
"${SCRIPT_DIR}"/linux-config.sh "$@"
"${SCRIPT_DIR}"/linux-build-gui.sh "$@"
"${SCRIPT_DIR}"/linux-post-tau-prod-release.sh "$@"

# Restore working directory as it was prior to this script running...
cd "${WORKING_DIR}"
2 changes: 1 addition & 1 deletion app/linux-build-gui.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
WORKING_DIR="$(pwd)"

cd "${SCRIPT_DIR}"/build
cmake --build . --config Release
cmake --build .

# Restore working directory as it was prior to this script running...
cd "${WORKING_DIR}"
5 changes: 1 addition & 4 deletions app/linux-clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@ cd "${SCRIPT_DIR}"
echo "Cleaning out build dir...."
rm -rf build

echo "Cleaning out external/build dir...."
rm -rf external/build

echo "Cleaning out BEAM distribution..."
rm -rf server/beam/tau/_build
rm -rf server/beam/tau/priv/*.{so,dylib,dll}
rm -f server/beam/tau/priv/*.{so,dylib,dll}
if [ "$MIX_ENV" == dev ]; then
rm -rf server/beam/tau/priv/static/assets
rm -rf server/beam/tau/priv/static/cache_manifest.json
Expand Down
File renamed without changes.
15 changes: 0 additions & 15 deletions app/linux-pre-copy-binaries.sh

This file was deleted.

6 changes: 0 additions & 6 deletions app/linux-prebuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,10 @@ if [ ! "$system_libs" == true ]; then
"${SCRIPT_DIR}"/linux-pre-vcpkg.sh "${args[@]}"
fi

# Build external dependencies and copy to build tree
echo "Building external binary dependencies..."
USE_SYSTEM_LIBS="$([ "$system_libs" == true ] && echo ON || echo OFF)" "${SCRIPT_DIR}"/external/linux_build_externals.sh

echo "Compiling native ruby extensions..."
ruby "${SCRIPT_DIR}"/server/ruby/bin/compile-extensions.rb

"${SCRIPT_DIR}"/linux-pre-translations.sh "${args[@]}"
"${SCRIPT_DIR}"/linux-pre-copy-binaries.sh "${args[@]}"
"${SCRIPT_DIR}"/linux-pre-tau-prod-release.sh "${args[@]}"

# Restore working directory as it was prior to this script running...
cd "${WORKING_DIR}"
7 changes: 4 additions & 3 deletions app/mac-build-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ set -e # Quit script on error
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
WORKING_DIR="$(pwd)"

"${SCRIPT_DIR}"/mac-prebuild.sh
"${SCRIPT_DIR}"/mac-config.sh
"${SCRIPT_DIR}"/mac-build-gui.sh
"${SCRIPT_DIR}"/mac-prebuild.sh "$@"
"${SCRIPT_DIR}"/mac-config.sh "$@"
"${SCRIPT_DIR}"/mac-build-gui.sh "$@"
"${SCRIPT_DIR}"/mac-post-tau-prod-release.sh "$@"

# Restore working directory as it was prior to this script running...
cd "${WORKING_DIR}"
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
WORKING_DIR="$(pwd)"

# Use generic linux clean script
"${SCRIPT_DIR}"/linux-pre-tau-prod-release.sh "$@"
"${SCRIPT_DIR}"/linux-post-tau-prod-release.sh "$@"

# Restore working directory as it was prior to this script running...
cd "${WORKING_DIR}"
32 changes: 0 additions & 32 deletions app/mac-pre-copy-binaries.sh

This file was deleted.

4 changes: 0 additions & 4 deletions app/mac-prebuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,10 @@ cd "${SCRIPT_DIR}"

"${SCRIPT_DIR}"/mac-pre-vcpkg.sh "$@"

"${SCRIPT_DIR}"/external/mac_build_externals.sh

echo "Compiling native ruby extensions..."
"$RUBY" "${SCRIPT_DIR}"/server/ruby/bin/compile-extensions.rb

"${SCRIPT_DIR}"/mac-pre-translations.sh
"${SCRIPT_DIR}"/mac-pre-copy-binaries.sh
"${SCRIPT_DIR}"/mac-pre-tau-prod-release.sh

# Restore working directory as it was prior to this script running...
cd "${WORKING_DIR}"
File renamed without changes.
1 change: 1 addition & 0 deletions app/win-build-all.bat
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ set WORKING_DIR=%CD%
call win-prebuild.bat
call win-config.bat
call win-build-gui.bat
call win-post-tau-prod-release.bat

cd %WORKING_DIR%
8 changes: 6 additions & 2 deletions app/win-build-gui.bat
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
set WORKING_DIR=%CD%

set WORKING_DIR=%CD%
set CONFIG=%1
cd %~dp0

if /I "%CONFIG%" == "" (set CONFIG=Release)

cd build
cmake --build . --config Release
cmake --build . --config %CONFIG%

cd %WORKING_DIR%
3 changes: 0 additions & 3 deletions app/win-clean.bat
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ cd %~dp0
@echo Cleaning out build dir....
rmdir build /s /q

@echo Cleaning out external\build dir....
rmdir external\build /s /q

@echo Cleaning out BEAM distribution....
rmdir server\beam\tau\_build /s /q
del server\beam\tau\priv\*.so server\beam\tau\priv\*.dylib server\beam\tau\priv\*.dll /s /q
Expand Down
Empty file modified app/win-config.bat
100644 → 100755
Empty file.
File renamed without changes.
Loading