/xLights-macOS

macOS specific files for xLights

Primary LanguageObjective-C++OtherNOASSERTION

xLights macOS build instructions


This document describes how **developers** should set up their tool chain to build
xLights on macOS.

xLights is written in C++ and uses the wxWidgets library as a
compatibility layer across operating systems.

On macOS, compilation is done using Xcode. Code::Blocks is not used.
Xcode can be downloaded from the Apple developer web site or the App Store. Make
sure you install the version of Xcode that matches your version of
macOS. For example, I use macOS 11, so I installed Xcode 12.

The latest wxWidgets release (3.1.5) will not work anymore as we need some API's that have
been added since then.  We also have several other fixes in place that fix various
bugs we have encountered, configurations we need, etc...

To get the latest code that we've tested, do:
git clone  --recurse-submodules -b xlights_2021.30 https://github.com/xLightsSequencer/wxWidgets


First, setup the target directories:
sudo mkdir -p /opt/local/lib
sudo mkdir -p /opt/local/libdbg
sudo mkdir -p /opt/local/bin

#setup permissions on /opt/local
sudo chgrp -R staff /opt/local*
sudo chmod -R g+w /opt/local*

If you are planning on being able to build Release builds, you will need to a release build
wxWidgets first.  If not doing release builds, this can be skipped.
  cd <wxMac base dir>
  cd build
  export BINARY_PLATFORMS="x86_64"
  # export BINARY_PLATFORMS="x86_64,arm64"
  export CXXFLAGS=""
  export OBJCXXFLAGS=""
  export CPPFLAGS="-g -flto=thin"
  export LDFLAGS="-flto=thin"
  export CXX=clang++
  export CXXCPP="clang++ -E"
  export CC=clang
  export CPP="clang -E"
  export CFLAGS="-g"
  ../configure  --disable-debug_flag --enable-optimise --prefix=/opt/local --enable-universal_binary=${BINARY_PLATFORMS} \
                --with-osx_cocoa --with-macosx-version-min=10.12 --disable-dependency-tracking \
                --disable-compat30  --enable-mimetype --enable-aui --with-opengl \
                --disable-webview --disable-webviewwebkit --disable-richtext --disable-mdi --disable-mdidoc --disable-loggui \
                --disable-xrc --disable-stc --disable-ribbon --disable-htmlhelp \
                --with-cxx=17 --enable-cxx11 --enable-std_containers --enable-std_string --enable-std_string_conv_in_wxstring \
                --without-liblzma  --with-expat=builtin --with-zlib=builtin --with-libjpeg=builtin  --without-libtiff \
                --enable-backtrace --enable-exceptions --disable-shared
  make -j 8
  make install
  make clean

For debug builds:
  cd <wxMac base dir>
  cd build
  export BINARY_PLATFORMS=x86_64
  # export BINARY_PLATFORMS="x86_64,arm64"
  export CXXFLAGS=""
  export OBJCXXFLAGS=""
  export CPPFLAGS="-g"
  export LDFLAGS=""
  export CXX=clang++ 
  export CXXCPP="clang++ -E" 
  export CC=clang 
  export CPP="clang -E" 
  export CFLAGS="-g"
  ../configure  --prefix=/opt/local --libdir=/opt/local/libdbg \
                --enable-debug --enable-debug_info --disable-optimise --enable-universal_binary=${BINARY_PLATFORMS} \
                --with-osx_cocoa --with-macosx-version-min=10.12 --disable-dependency-tracking \
                --disable-compat30  --enable-mimetype --enable-aui --with-opengl \
                --disable-webview --disable-webviewwebkit --disable-richtext --disable-mdi --disable-mdidoc --disable-loggui \
                --disable-xrc --disable-stc --disable-ribbon --disable-htmlhelp \
                --with-cxx=17 --enable-cxx11 --enable-std_containers --enable-std_string --enable-std_string_conv_in_wxstring \
                --without-liblzma  --with-expat=builtin --with-zlib=builtin --with-libjpeg=builtin  --without-libtiff \
                --enable-backtrace --enable-exceptions
  make -j 8
  make install



Next, you will use Xcode to compile xLights. Most of the steps are listed here:

  http://wiki.wxwidgets.org/Creating_Xcode_projects_for_wxWidgets_applications

However, if you have the XCode command line tools installed, you should just be able to run "xcodebuild" and it should build and compile xLights automatically.



Other library notes:
Note:  These instructions now assume Xcode 12 with support for Arm64.
You must set the env variables at the top first to setup the architecture and version targets


export MACOSX_DEPLOYMENT_TARGET=10.12
export OSX_VERSION_MIN="-mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET}"
export ARM64_TARGETS="-target arm64-apple-macos10.12 -arch arm64"
export X86_64_TARGETS="-target x86_64-apple-macos10.12 -arch x86_64"

#need ONE of these lines
export XL_TARGETS="${X86_64_TARGETS} ${ARM64_TARGETS}"
# export XL_TARGETS="${X86_64_TARGETS}"
# export XL_TARGETS="${ARM64_TARGETS}"

# need ONE of these
export BUILD_HOST=x86_64
# export BUILD_HOST=arm


libzstd:
git clone https://github.com/facebook/zstd
cd zstd
git checkout v1.5.0
export CFLAGS="-g -flto=thin  ${OSX_VERSION_MIN} ${XL_TARGETS}"
export LDFLAGS="-flto=thin  ${OSX_VERSION_MIN} ${XL_TARGETS} "
make clean
make -j 8 HAVE_LZMA=0 HAVE_LZ4=0 lib-mt
cp lib/libzstd.a /opt/local/lib
export CFLAGS="-g  ${OSX_VERSION_MIN} ${XL_TARGETS}"
export LDFLAGS=" ${OSX_VERSION_MIN} ${XL_TARGETS}"
make clean
make -j 8 HAVE_LZMA=0 HAVE_LZ4=0 lib-mt
cp lib/libzstd.a /opt/local/libdbg
unset CFLAGS
unset LDFLAGS



log4cpp:
Download latest src release (current 1.1.3)
patch -p1 < ~/working/xLights/macOS/patches/log4cpp.patch
export CXXFLAGS="-g -O2 -flto=thin ${OSX_VERSION_MIN} ${XL_TARGETS} -std=c++11 -stdlib=libc++ -fvisibility-inlines-hidden"
export LDFLAGS="-flto=thin ${XL_TARGETS} "
./configure --prefix=/opt/local -host ${BUILD_HOST}
make clean
make -j 8
cp src/.libs/liblog4cpp.a /opt/local/lib
export CXXFLAGS="-g ${OSX_VERSION_MIN} ${XL_TARGETS} -std=c++11 -stdlib=libc++ -fvisibility-inlines-hidden"
export LDFLAGS="${XL_TARGETS} "
./configure --prefix=/opt/local -host ${BUILD_HOST}
make clean
make -j 8
cp src/.libs/liblog4cpp.a /opt/local/libdbg
unset CXXFLAGS
unset LDFLAGS


liquidfun:
# requires cmake to be installed, most likely need to have
# homebrew installed and then "brew install cmake"
# aternatively, install CMAKE for OSX from https://cmake.org/download/
# and add the full path to cmake to PATH
# PATH=$PATH:/Applications/CMake.app/Contents/bin/
git clone https://github.com/google/liquidfun
cd liquidfun/liquidfun/Box2D
git status --ignored -s | colrm 1 2 | xargs rm -rf
export CXX=clang++
export CXXFLAGS="-g -O3 -flto=thin ${XL_TARGETS} ${OSX_VERSION_MIN}"
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DBOX2D_BUILD_EXAMPLES=OFF
make clean
make -j 8
cp ./Box2D/Release/libliquidfun.a /opt/local/lib
git status --ignored -s | colrm 1 2 | xargs rm -rf
export CXXFLAGS="-g ${XL_TARGETS} ${OSX_VERSION_MIN}"
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DBOX2D_BUILD_EXAMPLES=OFF
make clean
make -j 8
cp ./Box2D/Release/libliquidfun.a /opt/local/libdbg
unset CXXFLAGS
unset CXX


SDL2:  currently using 2.0.14
git clone https://github.com/SDL-mirror/SDL
cd SDL
git checkout release-2.0.14
export CXXFLAGS="-g -O3 -flto=thin ${XL_TARGETS} ${OSX_VERSION_MIN}"
export CFLAGS="-g -O3 -flto=thin ${XL_TARGETS} ${OSX_VERSION_MIN}"
export LDFLAGS="-g -O3 -flto=thin ${XL_TARGETS} ${OSX_VERSION_MIN}"
./configure --disable-shared --enable-static --disable-render-metal --disable-video-opengl --disable-video-opengles --disable-video-opengles2 --disable-video-vulkan --disable-haptic --disable-joystick
make clean
make -j 8
cp ./build/.libs/libSDL2.a /opt/local/lib
export CXXFLAGS="-g ${XL_TARGETS} ${OSX_VERSION_MIN}"
export CFLAGS="-g ${XL_TARGETS} ${OSX_VERSION_MIN}"
export LDFLAGS="-g ${XL_TARGETS} ${OSX_VERSION_MIN}"
./configure --disable-shared --enable-static --disable-render-metal --disable-video-opengl --disable-video-opengles --disable-video-opengles2 --disable-video-vulkan --disable-haptic --disable-joystick
make clean
make -j 8
cp ./build/.libs/libSDL2.a /opt/local/libdbg
unset CXXFLAGS
unset CFLAGS
unset LDFLAGS


ffmpeg:   currently using 4.4.1  plus patches
git clone https://git.ffmpeg.org/ffmpeg.git
cd ffmpeg
git checkout n4.4.1
git cherry-pick 55d9d6767967794edcdd6e1bbd8840fc6f4e9315
git cherry-pick b786bc7433dfe082441a57c1ba9ae9ea47904b78
git cherry-pick 7539a01bb0ea24998e1aa87706edf9785ddd3ac6
git cherry-pick 71ad83667d32f64c658034baa3cc56246ae67363
./configure --disable-asm --disable-x86asm --enable-static --disable-shared --disable-securetransport --extra-cflags="${OSX_VERSION_MIN}" --disable-indev=lavfi --disable-libx264 --disable-lzma --enable-gpl --enable-opengl --disable-programs
sed -i -e "s/^CFLAGS=/CFLAGS=-g -O3 ${XL_TARGETS} ${OSX_VERSION_MIN} /" ffbuild/config.mak
sed -i -e "s/^CXXFLAGS=/CXXFLAGS=-g -O3 ${XL_TARGETS} ${OSX_VERSION_MIN} /" ffbuild/config.mak
sed -i -e "s/^LDFLAGS=/LDFLAGS=-g -O3 ${XL_TARGETS} ${OSX_VERSION_MIN} /" ffbuild/config.mak
make clean
make -j 16
find . -name "*.a" -exec cp {} /opt/local/lib/ \;
make clean
./configure --disable-asm --disable-x86asm --enable-static --disable-shared --disable-securetransport --extra-cflags="${OSX_VERSION_MIN}" --disable-indev=lavfi --disable-libx264 --disable-lzma --enable-gpl --enable-opengl --disable-programs --disable-optimizations
sed -i -e "s/^CFLAGS=/CFLAGS=-g ${XL_TARGETS} ${OSX_VERSION_MIN} /" ffbuild/config.mak
sed -i -e "s/^CXXFLAGS=/CXXFLAGS=-g ${XL_TARGETS} ${OSX_VERSION_MIN} /" ffbuild/config.mak
sed -i -e "s/^LDFLAGS=/LDFLAGS=-g ${XL_TARGETS} ${OSX_VERSION_MIN} /" ffbuild/config.mak
make -j 8
find . -name "*.a" -exec cp {} /opt/local/libdbg/ \;






//TODO - stuff below is still todo

portmidi:
git clone https://github.com/AndrewBelt/portmidi
Remove i386 from CMakeLists.txt


Codeblocks:
Codeblocks needs to have wxWidgets compiled differently, specifically c++14, no lto-thin, and without the containers, shared libs

Set install dir:  needs to be separate from wxWidgets used for xLights:
export CB_INSTALL=${CB_INSTALL:=~/working/codeblocks/install_dir}

export CXXFLAGS="-stdlib=libc++ -std=c++14"
export OBJCXXFLAGS="-stdlib=libc++ -std=c++14"
export CPPFLAGS="-stdlib=libc++"
export LDFLAGS="-stdlib=libc++"
export CXX=clang++
export CXXCPP="clang++ -E"
export CC=clang
export CPP="clang -E"
export CFLAGS=""
mkdir -p $CB_INSTALL
../configure  --disable-debug --enable-optimise --prefix=$CB_INSTALL --enable-macosx_arch=x86_64 \
             --enable-mediactrl --with-osx_cocoa --with-opengl --disable-dependency-tracking \
             --disable-compat30 --with-macosx-version-min=10.12 --with-libjpeg=builtin  --without-libtiff --enable-mimetype \
             --with-cxx=14 --enable-cxx11  \
             --enable-backtrace --enable-exceptions --enable-aui --without-liblzma  --with-expat=builtin
make -j 8
make install

Then in codeblocks, after bootstrap:
PATH=$CB_INSTALL/bin:$PATH
./configure --with-contrib-plugins=all,-spellchecker,-FileManager,-NassiShneiderman,-profiler --prefix=$CB_INSTALL
make -j 8
make install
./bundle.sh



wxWidgets git hash history:
Feb 28, 2016 - cbb799b1ae3f309c99beb0d287e9bb3b62ea405c Update to 3.1.0 release from 3.0.x
Nov 23, 2016 - b28dd88994ec144c2235721ef8e1133b3651e790 Newer version fixing various bugs, also for 10.12 sdk support
Jun  1, 2017 - ff447038714f853a0bae1720e3e8d6f8da279c51 to be able to compile with 10.13 sdk
Aug 30, 2017 - 4a71ba820f085a3d5a7233e9fd0e23ae4e45af58 attempt to see if fixes #884
Sept 17, 2017 - a8b33bf08ed582a241071ff7fa876dec1911ed7a fix popup menus on dialogs
Jan 12, 2018 - 6bd8cb964bd625d7f974621cc9883ba52b58600a Start testing/preparing for wxWidgets 3.1.1/3.2, update to minver 10.10
Jan 24, 2018 - d8b3fc84c2239effb1824e7094c7bf24db45a7ba Fixes sorting in TreeListCtrl, also changed compile flags to
             --enable-std_containers  --enable-std_string_conv_in_wxstring
Feb 26, 2018 - switch to 3.1.1 release tar.bz2
June 17, 2018 - add notes about wxWidgets for OSX Mojave
July 16, 2018 - 85c2877a6c660c3b59c7a5400bab224374e3324a Fixes the native wxDataViewCtrl drag/drop
Aug  1, 2018 - c83f3b39424fd0d6690a64ba05277c77c077b861 Fixes sRGB <-> RGB color space issues
Oct 30, 2018 - move to dkulp/wxWidgets xlights_fixes branch to grab atomic ref counting, Mojave fixes, color fixes, etc...
Jan 6, 2019 - 81de073d3b06d61ed8959d417692e27d49ec17eb  Move to c++17, fixes for multitouch on OpenGL
Jun 30, 2019 - 51bce4ec0b2f1d6e38e1d5ae75e0ad1cec9bae13 Contains fixes for opengl window resizing
July 21, 2019 - 9ede90257fa5813bbb6c32f949b8d69619e14c03 add --enable-mimetype
July 27, 2019 - d50b91554ada145c8031db4540008b0f641bed28 fixes for some openGL issues, wxGrid crashes
Nov 17, 2019 - 099a4c8b77ccca16870d8761ba724be4e4d13643 Update to wxWidget 3.1.3
July 9, 2020 - tag: xlights_2020.28 - Update to prepare for moving to wxWidgets 3.1.4, start preparing for ARM builds
July 16, 2020 - tag: xlights_2020.29 - Update to prepare for moving to wxWidgets 3.1.4, start preparing for ARM builds, fixes socket issues
Oct  6, 2020 - tag: xlights_2020.41 - Fixes some Big Sur issues with fonts, colors
Dec 18, 2020 - tag: xlights_2020.56 - Fixes some make install things in wxwidgets, some osx graphics memory leaks, font handle leaks, various colors
Dec 21, 2020 - tag: xlights_2020.56b - Fixes potential crash when calling append/insert on wxCheckListBox
Mar 18, 2021 - tag: xlights_2020.09 - close to wxWidgets 3.1.5
Mar 18, 2021 - Move to macOS 10.12 as minimum
Apr 2, 2021 - Move wxWidgets fork to xLightsSequencer organization
Apr 20, 2021 - Move to xlights_2020.13 - wxWidgets 3.1.5 + patches
July 29, 2021 - Move to ffmpeg 4.4, zstd 1.5.0