diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1313feb6..8a6bdedb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -15,7 +15,7 @@ variables: doxygen: stage: build script: - - "./scripts/build-docs.sh" + - ./scripts/build-docs.sh artifacts: name: Doxygen paths: @@ -24,7 +24,8 @@ doxygen: linux_build: stage: build script: - - "./scripts/build-lnx-prod.sh" + - ./scripts/build-lnx-prod.sh + - ./scripts/create_source_archive.sh artifacts: name: Packages expire_in: 4 weeks @@ -32,18 +33,19 @@ linux_build: - build_prod/libreweb-browser-*.deb - build_prod/libreweb-browser-*.rpm - build_prod/libreweb-browser-*.tar.gz + - build_prod/libreweb-browser-source-*.tar.gz static_code_analysis: stage: build - script: "./scripts/cpp-check.sh" + script: ./scripts/cpp-check.sh code_style_guidelines: stage: build - script: "./scripts/check-format.sh" + script: ./scripts/check-format.sh unit_test: stage: test - script: "./scripts/build-run-tests.sh" + script: ./scripts/build-run-tests.sh sast: stage: test @@ -66,6 +68,8 @@ upload_and_release: ${PACKAGE_REGISTRY_URL}/libreweb-browser-v${CI_COMMIT_TAG}.rpm' - 'curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file build_prod/libreweb-browser-v${CI_COMMIT_TAG}.tar.gz ${PACKAGE_REGISTRY_URL}/libreweb-browser-v${CI_COMMIT_TAG}.tar.gz' + - 'curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file build_prod/libreweb-browser-source-v${CI_COMMIT_TAG}.tar.gz + ${PACKAGE_REGISTRY_URL}/libreweb-browser-source-v${CI_COMMIT_TAG}.tar.gz' - 'curl --header "PRIVATE-TOKEN: ${ACCESS_TOKEN}" --header "Content-Type: application/json" --request POST --data "{\"name\":\"LibreWeb Browser (Compressed binary)\",\"url\":\"${PACKAGE_REGISTRY_URL}/libreweb-browser-v${CI_COMMIT_TAG}.tar.gz\",\"link_type\":\"package\"}" ${RELEASE_LINKS_URL}' @@ -75,6 +79,9 @@ upload_and_release: - 'curl --header "PRIVATE-TOKEN: ${ACCESS_TOKEN}" --header "Content-Type: application/json" --request POST --data "{\"name\":\"LibreWeb Browser (Debian/Ubuntu/Linux Mint)\",\"url\":\"${PACKAGE_REGISTRY_URL}/libreweb-browser-v${CI_COMMIT_TAG}.deb\",\"link_type\":\"package\"}" ${RELEASE_LINKS_URL}' + - 'curl --header "PRIVATE-TOKEN: ${ACCESS_TOKEN}" --header "Content-Type: application/json" + --request POST --data "{\"name\":\"LibreWeb Browser Source Code Archive (tar.gz)\",\"url\":\"${PACKAGE_REGISTRY_URL}/libreweb-browser-source-v${CI_COMMIT_TAG}.tar.gz\",\"link_type\":\"package\"}" + ${RELEASE_LINKS_URL}' # Create new release #release: # stage: release diff --git a/CMakeLists.txt b/CMakeLists.txt index 3ef1fa20..45f576c2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,7 @@ cmake_minimum_required (VERSION 3.20) option(DOXYGEN "Build Doxygen documentation" ON) option(UNITTEST "Build unit tests") +option(PACKAGE "Build packages in release mode" OFF) set(CMAKE_OSX_DEPLOYMENT_TARGET "11.0" CACHE STRING "Minimum macOS deployment version") list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") @@ -13,8 +14,10 @@ project(libreweb-browser DESCRIPTION "LibreWeb Browser - Decentralized Web-Browser" LANGUAGES C CXX) -message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}") -message(STATUS "PROJECT_VERSION: ${PROJECT_VERSION}") +message(STATUS "Project version: ${PROJECT_VERSION}") +message(STATUS "Build type: ${CMAKE_BUILD_TYPE}") +message(STATUS "Create packages: ${PACKAGE}") +message(STATUS "Generate documentation: ${DOXYGEN}") if(UNITTEST) message(STATUS "Building the unit tests") endif() @@ -44,7 +47,7 @@ elseif(UNIX) endif() # Production build, let's include the CPack settings -if("${CMAKE_BUILD_TYPE}" STREQUAL "Release") +if("${CMAKE_BUILD_TYPE}" STREQUAL "Release" AND PACKAGE) include(Packaging) endif() @@ -54,10 +57,10 @@ endif() set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror -pedantic -Werror=incompatible-pointer-types") set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall") -set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 -DNDEBUG") +set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O2 -DNDEBUG") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g") -set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${WINDOWS_FLAGS} -O3 -DNDEBUG") +set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${WINDOWS_FLAGS} -O2 -DNDEBUG") # Disable CTest testcases & install in cpp-ipfs-http-client set (BUILD_TESTING OFF CACHE BOOL "Disable CTest" FORCE) diff --git a/kubo/ipfs b/kubo/ipfs new file mode 100755 index 00000000..0b929520 Binary files /dev/null and b/kubo/ipfs differ diff --git a/kubo/ipfs-darwin b/kubo/ipfs-darwin new file mode 100755 index 00000000..2609877d Binary files /dev/null and b/kubo/ipfs-darwin differ diff --git a/scripts/build-lnx-prod.sh b/scripts/build-lnx-prod.sh index 6c8af7e4..efa10cb1 100755 --- a/scripts/build-lnx-prod.sh +++ b/scripts/build-lnx-prod.sh @@ -7,7 +7,7 @@ # First build the application for Linux rm -rf build_prod -cmake -GNinja -DCMAKE_INSTALL_PREFIX:PATH=/usr -DDOXYGEN:BOOL=FALSE -DCMAKE_BUILD_TYPE=Release -B build_prod +cmake -GNinja -DCMAKE_INSTALL_PREFIX:PATH=/usr -DDOXYGEN:BOOL=FALSE -DPACKAGE=ON -DCMAKE_BUILD_TYPE=Release -B build_prod cmake --build ./build_prod --config Release # Build packages cd build_prod diff --git a/scripts/build-macos-prod.sh b/scripts/build-macos-prod.sh index fcfeadfb..36d0b5e1 100755 --- a/scripts/build-macos-prod.sh +++ b/scripts/build-macos-prod.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # By: Melroy van den Berg # Description: Build macOS 64-bit production release using Drag & Drop installer -cmake -GNinja -DDOXYGEN:BOOL=FALSE -DCMAKE_BUILD_TYPE=Release -B build_prod_macos +cmake -GNinja -DDOXYGEN:BOOL=FALSE -DPACKAGE=ON -DCMAKE_BUILD_TYPE=Release -B build_prod_macos # TODO: # cmake -G Xcode -DCODE_SIGN_IDENTITY="codesign ID..." -DDEVELOPMENT_TEAM_ID="team ID..." # xcodebuild \ diff --git a/scripts/build-win-prod.sh b/scripts/build-win-prod.sh index c8e6b072..538e9a8f 100755 --- a/scripts/build-win-prod.sh +++ b/scripts/build-win-prod.sh @@ -2,7 +2,7 @@ # By: Melroy van den Berg # Description: Build Windows 64-bit production release rm -rf build_prod_win -x86_64-w64-mingw32.static-cmake -GNinja -DDOXYGEN:BOOL=FALSE -DCMAKE_BUILD_TYPE=Release -B build_prod_win +x86_64-w64-mingw32.static-cmake -GNinja -DDOXYGEN:BOOL=FALSE -DPACKAGE=ON -DCMAKE_BUILD_TYPE=Release -B build_prod_win x86_64-w64-mingw32.static-cmake --build ./build_prod_win --config Release # Build packages cd build_prod_win diff --git a/scripts/create_source_archive.sh b/scripts/create_source_archive.sh new file mode 100755 index 00000000..c0073a26 --- /dev/null +++ b/scripts/create_source_archive.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +# By: Melroy van den Berg +# Description: Create custom source code archive with version.txt +# Depends on one environment variable: $CI_COMMIT_TAG + +if [ -z ${CI_COMMIT_TAG} ]; then + echo "ERROR: CI_COMMIT_TAG env. variable is not set! Do not build archive. Exiting..." + exit 0 +fi +# Create version.txt +echo -n "${CI_COMMIT_TAG}" > version.txt +# Create source archive (tar.gz) +git archive --format=tar.gz --output=build_prod/libreweb-browser-source-${CI_COMMIT_TAG}.tar.gz --add-file=version.txt HEAD diff --git a/scripts/get-ipfs.sh b/scripts/get-ipfs.sh deleted file mode 100755 index a6dba4e2..00000000 --- a/scripts/get-ipfs.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash -# By: Melroy van den Berg -# Description: Automatically download and unzip the IPFS CLI binaries for Linux & Windows - -## Provide the IPFS version below ## -IPFS_VERSION=0.24.0 - -############################## -# Leave the code alone below # -############################## -CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" - -# Download & untar/zip Go-IPFS -echo "INFO: Start downloading IPFS (version ${IPFS_VERSION})..." -wget --quiet "https://dist.ipfs.io/go-ipfs/v${IPFS_VERSION}/go-ipfs_v${IPFS_VERSION}_darwin-amd64.tar.gz" -O "$CURRENT_DIR/go-ipfs_darwin.tar.gz" -wget --quiet "https://dist.ipfs.io/go-ipfs/v${IPFS_VERSION}/go-ipfs_v${IPFS_VERSION}_linux-amd64.tar.gz" -O "$CURRENT_DIR/go-ipfs_linux.tar.gz" -wget --quiet "https://dist.ipfs.io/go-ipfs/v${IPFS_VERSION}/go-ipfs_v${IPFS_VERSION}_windows-amd64.zip" -O "$CURRENT_DIR/go-ipfs_windows.zip" - -# Extract on root level of the git repo -echo "INFO: Extracting Go IPFS..." -tar -xzf "$CURRENT_DIR/go-ipfs_darwin.tar.gz" go-ipfs/ipfs -C "$CURRENT_DIR/../" -# rename darwin binary -mv "$CURRENT_DIR/../go-ipfs/ipfs" "$CURRENT_DIR/../go-ipfs/ipfs-darwin" -tar -xzf "$CURRENT_DIR/go-ipfs_linux.tar.gz" go-ipfs/ipfs -C "$CURRENT_DIR/../" -unzip -q -o "$CURRENT_DIR/go-ipfs_windows.zip" go-ipfs/ipfs.exe -d "$CURRENT_DIR/../" - -# Clean-up -echo "INFO: Clean up" -rm -rf "$CURRENT_DIR/go-ipfs_darwin.tar.gz" -rm -rf "$CURRENT_DIR/go-ipfs_linux.tar.gz" -rm -rf "$CURRENT_DIR/go-ipfs_windows.zip" diff --git a/scripts/get-kubo.sh b/scripts/get-kubo.sh new file mode 100755 index 00000000..e10d0f73 --- /dev/null +++ b/scripts/get-kubo.sh @@ -0,0 +1,31 @@ +#!/bin/bash +# By: Melroy van den Berg +# Description: Automatically download and unzip the IPFS CLI (Kubo) binaries for Linux & Windows + +## Provide the Kubo version below ## +KUBO_VERSION=0.26.0 + +############################## +# Leave the code alone below # +############################## +CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" + +# Download & untar/zip Kubo +echo "INFO: Start downloading Kubo (v${KUBO_VERSION})..." +wget --quiet "https://dist.ipfs.tech/kubo/v${KUBO_VERSION}/kubo_v${KUBO_VERSION}_darwin-amd64.tar.gz" -O "$CURRENT_DIR/kubo_darwin.tar.gz" +wget --quiet "https://dist.ipfs.tech/kubo/v${KUBO_VERSION}/kubo_v${KUBO_VERSION}_linux-amd64.tar.gz" -O "$CURRENT_DIR/kubo_linux.tar.gz" +wget --quiet "https://dist.ipfs.tech/kubo/v${KUBO_VERSION}/kubo_v${KUBO_VERSION}_windows-amd64.zip" -O "$CURRENT_DIR/kubo_windows.zip" + +# Extract on root level of the git repo +echo "INFO: Extracting Kubo..." +tar -xzf "$CURRENT_DIR/kubo_darwin.tar.gz" kubo/ipfs -C "$CURRENT_DIR/../" +# rename darwin binary +mv "$CURRENT_DIR/../kubo/ipfs" "$CURRENT_DIR/../kubo/ipfs-darwin" +tar -xzf "$CURRENT_DIR/kubo_linux.tar.gz" kubo/ipfs -C "$CURRENT_DIR/../" +unzip -q -o "$CURRENT_DIR/kubo_windows.zip" kubo/ipfs.exe -d "$CURRENT_DIR/../" + +# Clean-up +echo "INFO: Clean up" +rm -rf "$CURRENT_DIR/kubo_darwin.tar.gz" +rm -rf "$CURRENT_DIR/kubo_linux.tar.gz" +rm -rf "$CURRENT_DIR/kubo_windows.zip"