Skip to content

Commit

Permalink
use cmake to build js parts (#270)
Browse files Browse the repository at this point in the history
  • Loading branch information
hyperblast committed Jun 2, 2024
1 parent aef0104 commit cf9eb07
Show file tree
Hide file tree
Showing 29 changed files with 454 additions and 239 deletions.
23 changes: 10 additions & 13 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,20 @@ jobs:
runs-on: ubuntu-22.04

env:
BUILD_TYPE: release
BUILD_TYPE: Release

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Build docker images
run: ci/build-docker.sh
- name: Create docker images
run: ci/init-docker.sh

- name: Install tools
- name: Install apps
run: ci/install.sh

- name: Build server
run: ci/build-server.sh

- name: Build rest
run: ci/build-rest.sh
- name: Build
run: ci/build.sh

- name: Test
run: ci/test.sh
Expand All @@ -43,7 +40,7 @@ jobs:
with:
name: beefweb_linux
if-no-files-found: error
path: build/${{ env.BUILD_TYPE }}/*.tar.gz
path: build/${{ env.BUILD_TYPE }}.pkg/*.tar.gz

build_windows:

Expand Down Expand Up @@ -78,7 +75,7 @@ jobs:
vsversion: '2022'
arch: ${{ matrix.arch }}

- name: Install tools
- name: Install apps
run: cmd /c ci\install.cmd

- name: Build
Expand All @@ -93,8 +90,8 @@ jobs:
name: beefweb_windows
if-no-files-found: error
path: |
build\${{ env.BUILD_TYPE }}\*.fb2k-component
build\${{ env.BUILD_TYPE }}\*.zip
build\${{ env.BUILD_TYPE }}.pkg\*.fb2k-component
build\${{ env.BUILD_TYPE }}.pkg\*.zip
merge_packages:

Expand Down
28 changes: 15 additions & 13 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
apps/*
build/*
.idea
apps
build
cmake-build*

js/.idea/*
js/node_modules/*
js/.idea
js/node_modules

js/api_tests/node_modules/*
js/api_tests/tmp/*
js/api_tests/node_modules
js/api_tests/tmp

js/client/dist/*
js/client/node_modules/*
js/client/dist
js/client/node_modules

js/webui/build/*
js/webui/node_modules/*
js/webui/build
js/webui/node_modules

cpp/.idea/*
cpp/build/*
cpp/extlibs/.cache/*
cpp/.idea
cpp/build
cpp/extlibs/.cache

*.user
*.orig
Expand Down
50 changes: 50 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
cmake_minimum_required(VERSION 3.12)

project(beefweb)

set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH}")
set(EXTLIB_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/cpp/extlibs")
set(EXTLIB_INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/cpp/extlibs-root")

include(EnvInfo)
include(Utils)

option(ENABLE_TESTS "Build tests" OFF)
option(ENABLE_GIT_REV "Include Git revision in produced binaries" OFF)
option(ENABLE_WERROR "Treat warnings as errors" OFF)
option(ENABLE_LOCAL_LIBS "Build with local libraries" ON)
option(ENABLE_STATIC_STDLIB "Build with static libstdc++" OFF)
option(ENABLE_JS "Build JS parts" ON)

local_library_option(boost ENABLE_LOCAL_BOOST "")
local_library_option(nljson ENABLE_LOCAL_NLJSON "")
local_library_option(catch ENABLE_LOCAL_CATCH "ENABLE_TESTS")
local_library_option(stringencoders ENABLE_LOCAL_STRINGENCODERS "")

if(OS_POSIX)
option(ENABLE_PLAYER_DEADBEEF "Build plugin for deadbeef player" ON)

local_library_option(deadbeef ENABLE_LOCAL_DEADBEEF "ENABLE_PLAYER_DEADBEEF")
endif()

if(OS_WINDOWS)
option(ENABLE_PLAYER_FOOBAR2000 "Build plugin for foobar2000 player" ON)

if(ENABLE_PLAYER_FOOBAR2000)
local_library(foosdk)
endif()

local_library_option(zlib ENABLE_LOCAL_ZLIB "")
endif()

if(ENABLE_GIT_REV)
detect_git_revision(GIT_REV)
endif()

add_subdirectory(cpp)

if(ENABLE_JS)
add_subdirectory(js)
endif()

print_status()
11 changes: 11 additions & 0 deletions ci/build-modern.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

set -e

function main
{
scripts/build.sh --all --$BUILD_TYPE --tests --verbose \
-DENABLE_WERROR=ON -DENABLE_STATIC_STDLIB=OFF -DENABLE_GIT_REV=ON
}

source "$(dirname $0)/run-in-docker.sh"
4 changes: 2 additions & 2 deletions ci/build-server.sh → ci/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ set -e

function main
{
export PATH=$(pwd)/apps/cmake/bin:$PATH
export PATH=$(pwd)/apps/cmake/bin:$(pwd)/apps/node/bin:$PATH

scripts/build.sh --server --$BUILD_TYPE --tests --verbose \
scripts/build.sh --all --$BUILD_TYPE --tests --verbose \
-DENABLE_WERROR=ON -DENABLE_STATIC_STDLIB=ON -DENABLE_GIT_REV=ON
}

Expand Down
1 change: 0 additions & 1 deletion ci/build-docker.sh → ci/init-docker-modern.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ set -e

cd "$(dirname $0)"

docker build -t beefweb-dev:ubuntu-14.04 -f ubuntu-14.04.dockerfile .
docker build -t beefweb-dev:ubuntu-22.04 -f ubuntu-22.04.dockerfile .
7 changes: 7 additions & 0 deletions ci/init-docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

set -e

cd "$(dirname $0)"

docker build -t beefweb-dev:ubuntu-14.04 -f ubuntu-14.04.dockerfile .
3 changes: 2 additions & 1 deletion ci/build-rest.sh → ci/install-modern.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ set -e

function main
{
scripts/build.sh --webui --pkg --$BUILD_TYPE --tests --verbose
scripts/install/deadbeef.sh v1.8
scripts/install/deadbeef.sh v1.9
}

source "$(dirname $0)/run-in-docker.sh"
3 changes: 3 additions & 0 deletions ci/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ set -e
function main
{
scripts/install/cmake.sh
scripts/install/node.sh
scripts/install/deadbeef.sh v1.8
scripts/install/deadbeef.sh v1.9
}

DOCKER_IMAGE=beefweb-dev:ubuntu-14.04

source "$(dirname $0)/run-in-docker.sh"
37 changes: 37 additions & 0 deletions ci/test-modern.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash

set -e

function banner
{
echo
echo ">> $1 <<"
echo
}

function run_server_tests
{
banner 'Running server tests'
build/$BUILD_TYPE/cpp/server/tests/core_tests
}

function run_api_tests
{
(
banner "Running API tests on deadbeef $1"
export BEEFWEB_TEST_DEADBEEF_VERSION=$1
export BEEFWEB_TEST_BUILD_TYPE=$BUILD_TYPE
apps/deadbeef/$1/deadbeef --version
cd js/api_tests
yarn test
)
}

function main
{
run_server_tests
run_api_tests v1.8
run_api_tests v1.9
}

source "$(dirname $0)/run-in-docker.sh"
2 changes: 1 addition & 1 deletion ci/test.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set BEEFWEB_TEST_BUILD_TYPE=%BUILD_TYPE%
@echo.
@echo === Running server tests ===
@echo.
cpp\build\%BUILD_TYPE%\server\tests\%BUILD_TYPE%\core_tests.exe
build\%BUILD_TYPE%\cpp\server\tests\%BUILD_TYPE%\core_tests.exe
@if errorlevel 1 goto :end

set API_TEST_ERROR=0
Expand Down
6 changes: 5 additions & 1 deletion ci/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function banner
function run_server_tests
{
banner 'Running server tests'
cpp/build/$BUILD_TYPE/server/tests/core_tests
build/$BUILD_TYPE/cpp/server/tests/core_tests
}

function run_api_tests
Expand All @@ -29,9 +29,13 @@ function run_api_tests

function main
{
export PATH=$(pwd)/apps/node/bin:$PATH

run_server_tests
run_api_tests v1.8
run_api_tests v1.9
}

DOCKER_IMAGE=beefweb-dev:ubuntu-14.04

source "$(dirname $0)/run-in-docker.sh"
22 changes: 16 additions & 6 deletions cpp/cmake/EnvInfo.cmake → cmake/EnvInfo.cmake
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
set(OS_WINDOWS OFF)
set(OS_POSIX OFF)
set(OS_WINDOWS OFF)
set(OS_POSIX OFF)

if(WIN32 AND NOT CYGWIN)
set(OS_WINDOWS ON)
set(SCRIPT_SUFFIX .cmd)
elseif(UNIX)
set(OS_POSIX ON)
set(SCRIPT_SUFFIX .sh)
else()
message(SEND_ERROR "Target OS is not Windows or POSIX" )
endif()

set(CXX_GCC OFF)
set(CXX_CLANG OFF)
set(CXX_MSVC OFF)
set(HOST_OS_WINDOWS OFF)
set(HOST_OS_POSIX OFF)

if(CMAKE_HOST_SYSTEM_NAME MATCHES "^Windows.*")
set(HOST_OS_WINDOWS ON)
set(SCRIPT_SUFFIX .cmd)
else()
set(HOST_OS_POSIX ON)
set(SCRIPT_SUFFIX .sh)
endif()

set(CXX_GCC OFF)
set(CXX_CLANG OFF)
set(CXX_MSVC OFF)

if(CMAKE_CXX_COMPILER_ID STREQUAL GNU)
set(CXX_GCC ON)
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion cpp/cmake/Utils.cmake → cmake/Utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function(print_status)
get_cmake_property(NAMES VARIABLES)

foreach(NAME ${NAMES})
if(NAME MATCHES "^(ENABLE|OS|CXX)_")
if(NAME MATCHES "^(ENABLE|OS|HOST_OS|CXX)_")
message(STATUS "${NAME}: ${${NAME}}")
endif()
endforeach()
Expand Down
46 changes: 0 additions & 46 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,41 +1,3 @@
cmake_minimum_required(VERSION 3.6)

project(beefweb)

set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH}")
set(EXTLIB_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/extlibs")
set(EXTLIB_INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/extlibs-root")

include(EnvInfo)
include(Utils)

option(ENABLE_TESTS "Build tests" OFF)
option(ENABLE_GIT_REV "Include Git revision in produced binaries" OFF)
option(ENABLE_WERROR "Treat warnings as errors" OFF)
option(ENABLE_LOCAL_LIBS "Build with local libraries" ON)
option(ENABLE_STATIC_STDLIB "Build with static libstdc++" OFF)

local_library_option(boost ENABLE_LOCAL_BOOST "")
local_library_option(nljson ENABLE_LOCAL_NLJSON "")
local_library_option(catch ENABLE_LOCAL_CATCH "ENABLE_TESTS")
local_library_option(stringencoders ENABLE_LOCAL_STRINGENCODERS "")

if(OS_POSIX)
option(ENABLE_PLAYER_DEADBEEF "Build plugin for deadbeef player" ON)

local_library_option(deadbeef ENABLE_LOCAL_DEADBEEF "ENABLE_PLAYER_DEADBEEF")
endif()

if(OS_WINDOWS)
option(ENABLE_PLAYER_FOOBAR2000 "Build plugin for foobar2000 player" ON)

if(ENABLE_PLAYER_FOOBAR2000)
local_library(foosdk)
endif()

local_library_option(zlib ENABLE_LOCAL_ZLIB "")
endif()

set(COMMON_C_FLAGS "")

if(OS_POSIX)
Expand Down Expand Up @@ -66,13 +28,5 @@ if(CXX_MSVC)
endforeach()
endif()

if(ENABLE_GIT_REV)
detect_git_revision(GIT_REV)
endif()

print_status()

add_custom_target(ext_all)

add_subdirectory(extlibs)
add_subdirectory(server)
2 changes: 2 additions & 0 deletions cpp/extlibs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ endforeach()

option_dependency_check(ENABLE_STATIC_STDLIB ENABLE_LOCAL_BOOST)

add_custom_target(ext_all)

if(ENABLE_LOCAL_BOOST)
add_subdirectory(boost)
endif()
Expand Down
Loading

0 comments on commit cf9eb07

Please sign in to comment.