Skip to content

Commit

Permalink
Merge pull request #543 from jongough/updates
Browse files Browse the repository at this point in the history
Updates
  • Loading branch information
jongough authored Dec 28, 2023
2 parents 2de032d + cd39867 commit fc93845
Show file tree
Hide file tree
Showing 12 changed files with 291 additions and 29 deletions.
47 changes: 42 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ workflows:
<<: *std-filters
- build-android-armhf:
<<: *std-filters
- build-macos-wx32:
<<: *std-filters
# Duplicate macos-universal covers this.
# - build-macos-wx32:
# <<: *std-filters
- build-flatpak-arm64-2208:
<<: *std-filters
- build-flatpak-x86-2208:
Expand All @@ -58,9 +59,13 @@ workflows:
## KEEP needed for Jammy with wx32
- build-ubuntu-x86_64-2204-jammy:
<<: *std-filters
- build-macos-universal:
<<: *std-filters

## -------------------------------------------
## OpenCPN 5.6.2 Plugins Frozen - 28/05/2023
## ------------------------------------------
## Circleci will not build for macos 11 so removed - 18/10/2023
- build-macos:
<<: *std-filters
## Appveyor no longer builds for Windows.
Expand All @@ -74,6 +79,7 @@ workflows:
<<: *std-filters
- build-debian-x86_64-10-buster:
<<: *std-filters

## -------------------------------------
## UBUNTU OS Frozen - 28/05/2023 DROP
## -------------------------------------
Expand Down Expand Up @@ -109,7 +115,7 @@ commands:
condition: <<parameters.install-python>>
steps:
- run: sudo apt install -y python3-pip
- run: python3.8 -m pip install cloudsmith-cli
- run: python3 -m pip install cloudsmith-cli
- when:
condition: <<parameters.DEPLOY-USE-ORB>>
steps:
Expand All @@ -129,7 +135,7 @@ jobs:
## ---------------------
build-android-arm64:
docker:
- image: cimg/android:2021.10.2-ndk
- image: cimg/android:2023.12-ndk
resource_class: large
environment:
- OCPN_TARGET: android-arm64
Expand All @@ -142,10 +148,11 @@ jobs:
install-python: true
build-android-armhf:
docker:
- image: cimg/android:2021.10.2-ndk
- image: cimg/android:2023.12-ndk
resource_class: large
environment:
- OCPN_TARGET: android-armhf
- DEPLOY_USE_ORB: true
steps:
- checkout
- run: chmod a+x ci/*.sh
Expand All @@ -165,6 +172,36 @@ jobs:
- run: chmod a+x ci/*.sh
- run: bash ci/circleci-build-macos.sh
- deploy-code

build-macos-universal:
macos:
xcode: "12.5.1"
environment:
- OCPN_TARGET: macos
- CMAKE_BUILD_PARALLEL_LEVEL: 2
- WX_VER: 32
steps:
- checkout
- run: sudo chmod go+w /usr/local
- restore_cache:
key: "{{checksum \"build-deps/macos-cache-stamp\"}}\
-{{checksum \"cmake/MacosWxwidgets.cmake\"}}\
-{{checksum \"ci/circleci-build-macos-universal.sh\"}}"
- run: chmod a+x ci/*.sh
- run: ci/circleci-build-macos-universal.sh
- save_cache:
key: "{{checksum \"build-deps/macos-cache-stamp\"}}\
-{{checksum \"cmake/MacosWxwidgets.cmake\"}}\
-{{checksum \"ci/circleci-build-macos-universal.sh\"}}"
paths:
- /tmp/local.cache.tar
- /Users/distiller/project/cache
- run: >
sh -c "otool -L build/*.dylib"
- run: >
sh -c "cat build/*.xml"
- deploy-code

build-msvc-wx32-2022:
executor:
name: win/server-2022
Expand Down
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
## * xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx *
#-----------------------------------------------------------------------------
# Frontend2 Author: Jon Gough
# Testplugn(TP) v1.0.283.0 03/11/2023 DD/MM/YYYY format
# Testplugn(TP) v1.0.289.0 29/12/2023 DD/MM/YYYY format
# buildCI:yes provideODAPI:yes validateJSON:yes
# ---------------------------------------------------------------------------
## -- When changing this file do NOT change the order of the sections. -- ##
Expand Down Expand Up @@ -60,9 +60,9 @@ set(PACKAGE "ocpn_draw")

set(VERSION_MAJOR "1")
set(VERSION_MINOR "8")
set(VERSION_PATCH "44")
set(VERSION_PATCH "46")
set(VERSION_TWEAK "0")
set(VERSION_DATE "26/11/2023") # DD/MM/YYYY forma0t
set(VERSION_DATE "29/12/2023") # DD/MM/YYYY forma0t
set(OCPN_MIN_VERSION "ov50")
set(OCPN_API_VERSION_MAJOR "1")
set(OCPN_API_VERSION_MINOR "17")
Expand Down
4 changes: 4 additions & 0 deletions build-deps/macos-cache-stamp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Any change in this file will cause the macos cache to be invalidated
# i. e., that the homebrew dependencies are downloaded and wxwidgets
# rebuilt. For example, change the stock 'v1' to 'v2'
v1
7 changes: 7 additions & 0 deletions build-deps/macos-deps
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# brew packages installed in macos ci build
cmake
gettext
libexif
python
wget
openssl@3
82 changes: 82 additions & 0 deletions ci/circleci-build-macos-universal.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#!/usr/bin/env bash


# Build the MacOS artifacts


# Copyright (c) 2021 Alec Leamas
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.

set -x

# Load local environment if it exists i. e., this is a local build
if [ -f ~/.config/local-build.rc ]; then source ~/.config/local-build.rc; fi

git submodule update --init opencpn-libs

# If applicable, restore /usr/local from cache.
if [[ -n "$CI" && -f /tmp/local.cache.tar ]]; then
sudo rm -rf /usr/local/*
sudo tar -C /usr -xf /tmp/local.cache.tar
fi

# Set up build directory
rm -rf build && mkdir build

# Create a log file.
exec > >(tee build/build.log) 2>&1

export MACOSX_DEPLOYMENT_TARGET=10.10

# Return latest version of $1, optionally using option $2
pkg_version() { brew list --versions $2 $1 | tail -1 | awk '{print $2}'; }

#
# Check if the cache is with us. If not, re-install brew.
brew list --versions libexif || brew update-reset

# Install packaged dependencies
for pkg in cmake gettext libarchive libexif python wget openssl@3; do
brew list --versions $pkg || brew install $pkg || brew install $pkg || :
brew link --overwrite $pkg || brew install $pkg
done

#Install prebuilt dependencies
wget -q https://dl.cloudsmith.io/public/nohal/opencpn-plugins/raw/files/macos_deps_universal.tar.xz \
-O /tmp/macos_deps_universal.tar.xz
sudo tar -C /usr/local -xJf /tmp/macos_deps_universal.tar.xz

export OPENSSL_ROOT_DIR='/usr/local'

# Build and package
cd build
cmake \
"-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-Release}" \
-DCMAKE_INSTALL_PREFIX= \
-DCMAKE_OSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET} \
-DOCPN_TARGET_TUPLE="darwin-wx32;10;universal" \
-DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \
..

if [[ -z "$CI" ]]; then
echo '$CI not found in environment, assuming local setup'
echo "Complete build using 'cd build; make tarball' or so."
exit 0
fi

# nor-reproducible error on first invocation, seemingly tarball-conf-stamp
# is not created as required.
#make VERBOSE=1 tarball || make VERBOSE=1 tarball
make
make install
make package
make package

# Create the cached /usr/local archive
if [ -n "$CI" ]; then
tar -C /usr -cf /tmp/local.cache.tar local
fi
90 changes: 90 additions & 0 deletions cmake/MacosWxwidgets.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# ~~~
# Summary: If required, rebuild wxwidgets for macos from source.
# License: GPLv3+
# Copyright (c) 2022 Alec Leamas
# ~~~

# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; either version 3 of the License, or (at your option) any later
# version.

cmake_minimum_required(VERSION 3.20.0)

set(wx_repo https://github.com/wxWidgets/wxWidgets.git)
set(wx_tag v3.2.2.1)

option(IGNORE_SYSTEM_WX "Never use system wxWidgets installation" FALSE)

# Check if we have done the wxWidgets build already
#
if(DEFINED wx_config)
return()
endif()

# Check if there is a usable wxwidgets anyway
#
set(cache_dir ${PROJECT_SOURCE_DIR}/cache)

if(IGNORE_SYSTEM_WX)
set(WX_CONFIG_PROG ${cache_dir}/lib/wx/config/osx_cocoa-unicode-3.2)
else()
find_program(
WX_CONFIG_PROG
NAMES wx-config osx_cocoa-unicode-3.2
HINTS ${PROJECT_SOURCE_DIR}/cache/lib/wx/config /usr/local/lib/wx/config)
endif()
if(WX_CONFIG_PROG)
execute_process(
COMMAND ${WX_CONFIG_PROG} --version
RESULT_VARIABLE wx_status
OUTPUT_VARIABLE wx_version
ERROR_FILE /dev/null COMMAND_ECHO STDOUT
OUTPUT_STRIP_TRAILING_WHITESPACE)
else()
set(wx_status 1)
endif()

if(${wx_status} EQUAL 0)
set(wx_config
${WX_CONFIG_PROG}
CACHE FILEPATH "")
set(ENV{WX_CONFIG} ${WX_CONFIG_PROG})
if(${wx_version} VERSION_GREATER_EQUAL 3.2)
return()
endif()
endif()

if(NOT EXISTS ${cache_dir})
file(MAKE_DIRECTORY ${cache_dir})
endif()

# Download sources and get the source directory
#
include(FetchContent)
FetchContent_Declare(
wxwidgets
GIT_REPOSITORY ${wx_repo}
GIT_TAG ${wx_tag})
FetchContent_Populate(wxwidgets)
FetchContent_GetProperties(wxwidgets SOURCE_DIR wxwidgets_src_dir)

execute_process(COMMAND git submodule update --init 3rdparty/pcre
WORKING_DIRECTORY ${wxwidgets_src_dir})
execute_process(
COMMAND
./configure --with-cxx=11 --with-macosx-version-min=10.10 --enable-unicode
--with-osx-cocoa --enable-aui --disable-debug --with-opengl
--enable-macosx_arch=arm64,x86_64 --enable-universal_binary=arm64,x86_64
--without-subdirs --prefix=${cache_dir}
WORKING_DIRECTORY ${wxwidgets_src_dir})
math(_nproc ${OCPN_NPROC} * 2) # Assuming two threads/cpu
execute_process(COMMAND make -j${_nproc} WORKING_DIRECTORY ${wxwidgets_src_dir})
execute_process(COMMAND sudo make install
WORKING_DIRECTORY ${wxwidgets_src_dir})

set(wx_config ${cache_dir}/lib/wx/config/osx_cocoa-unicode-3.2)
if(NOT EXISTS ${wx_config})
message(FATAL_ERROR "Cannot locate wx-config tool at ${wx_config}")
endif()
set(ENV{WX_CONFIG} ${wx_config})
19 changes: 11 additions & 8 deletions cmake/PluginConfigure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,10 @@ if(DEFINED ENV{OCPN_TARGET})
else()
set(PACKAGING_NAME "${PKG_NVR}-${PKG_TARGET}-${PKG_TARGET_VERSION}${PKG_BUILD_GTK}-$ENV{OCPN_TARGET}")
set(PACKAGING_NAME_XML "${PKG_NVR}-${PKG_TARGET}-${ARCH}-${PKG_TARGET_VERSION}${PKG_BUILD_GTK}-$ENV{OCPN_TARGET}")
endif()
if(APPLE AND CMAKE_OSX_ARCHITECTURES)
set(PACKAGING_NAME_XML "${PKG_NVR}-${PKG_TARGET}-${COMPOUND_ARCH_DASH}-${PKG_TARGET_VERSION}${PKG_BUILD_GTK}-$ENV{OCPN_TARGET}")
endif()
endif()
else()
if(OCPN_FLATPAK_CONFIG OR OCPN_FLATPAK_BUILD OR MINGW OR MSVC)
set(PACKAGING_NAME "${PKG_NVR}-${PKG_TARGET}-${ARCH}-${PKG_TARGET_VERSION}${PKG_BUILD_GTK}")
Expand Down Expand Up @@ -292,7 +295,7 @@ if(OCPN_FLATPAK_CONFIG)
message(STATUS "${CMLOC}FLATPAK_BRANCH: ${FLATPAK_BRANCH}")
set(RUNTIME_VERSION ${FLATPAK_BRANCH})

message(STATUS "${CMLOC}Checking OCPN_FLATPAK_CONFIG: ${OCPN_FLATPAK_CONFIG}, SDK_VER: ${SDK_VER}, WX_VER: ${WX_VER}")
message(STATUS "${CMLOC}Checking OCPN_FLATPAK_CONFIG: ${OCPN_FLATPAK_CONFIG}, SDK_VER: ${SDK_VER}, WX_VER: $ENV{WX_VER}")
configure_file(${PROJECT_SOURCE_DIR}/cmake/in-files/org.opencpn.OpenCPN.Plugin.yaml.in ${CMAKE_CURRENT_BINARY_DIR}/flatpak/org.opencpn.OpenCPN.Plugin.${PACKAGE}.yaml)

message(STATUS "${CMLOC}Done OCPN_FLATPAK CONFIG")
Expand Down Expand Up @@ -524,14 +527,14 @@ if(NOT QT_ANDROID)
set(wxWidgets_USE_STATIC OFF)

set(WXWIDGETS_FORCE_VERSION CACHE STRING "Force usage of a specific wxWidgets version.")
if(NOT "${WX_VER}" STREQUAL "")
string(LENGTH ${WX_VER} WX_VER_LEN)
string(SUBSTRING ${WX_VER} 0 1 MAJOR)
string(SUBSTRING ${WX_VER} 1 1 MINOR)
if(NOT "$ENV{WX_VER}" STREQUAL "")
string(LENGTH $ENV{WX_VER} WX_VER_LEN)
string(SUBSTRING $ENV{WX_VER} 0 1 MAJOR)
string(SUBSTRING $ENV{WX_VER} 1 1 MINOR)
string(CONCAT WXWIDGETS_FORCE_VERSION ${MAJOR} "." ${MINOR})
if(${WX_VER_LEN} EQUAL 3)
string(SUBSTRING ${WX_VER} 2 1 PATCH)
string(CONCAT WXWIDGETS_FORCE_VERSION ${WXWIDGETS_FORCE_VERSION} "." ${PATCH})
string(SUBSTRING $ENV{WX_VER} 2 1 PATCH)
#string(CONCAT WXWIDGETS_FORCE_VERSION ${WXWIDGETS_FORCE_VERSION} "." ${PATCH})
endif()
endif()
message(STATUS "${CMLOC}wxWidgets_Version: ${WXWIDGETS_FORCE_VERSION}")
Expand Down
18 changes: 18 additions & 0 deletions cmake/PluginInstall.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,24 @@ endif(UNIX AND NOT APPLE AND NOT QT_ANDROID)

set(PARENT opencpn)

if(APPLE)
install(
TARGETS ${PACKAGE_NAME}
RUNTIME
LIBRARY DESTINATION OpenCPN.app/Contents/PlugIns)
if(EXISTS ${PROJECT_SOURCE_DIR}/data)
install(DIRECTORY data DESTINATION OpenCPN.app/Contents/SharedSupport/plugins/${PACKAGE_NAME})
endif()

if(EXISTS ${PROJECT_SOURCE_DIR}/UserIcons)
install(DIRECTORY UserIcons DESTINATION OpenCPN.app/Contents/SharedSupport/plugins/${PACKAGE_NAME})
endif()

find_package(ZLIB REQUIRED)
target_link_libraries(${PACKAGE_NAME} ${ZLIB_LIBRARIES})

endif(APPLE)

# Based on code from nohal
if(NOT CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX ${TENTATIVE_PREFIX})
Expand Down
Loading

0 comments on commit fc93845

Please sign in to comment.