Skip to content

Commit

Permalink
build+ci: support macOS on arm64
Browse files Browse the repository at this point in the history
Refs: #5135
Change-Id: Ifac57bf18dea805dc9eab06039806858bb3b6f20
  • Loading branch information
Pesa committed Aug 11, 2022
1 parent dc3575f commit f662500
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
os: macos-11
runs-on: ${{ matrix.os }}
env:
NODE_LABELS: OSX
NODE_LABELS: macos
WAF_JOBS: 3
steps:
- name: Set up Xcode
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
run: |
case ${RUNNER_OS} in
Linux) export NODE_LABELS="Linux Ubuntu" ;;
macOS) export NODE_LABELS="OSX" ;;
macOS) export NODE_LABELS="macos" ;;
esac
find .jenkins.d/ -type f -name '[1-9]*.sh' -exec chmod -x '{}' +
./.jenkins
Expand Down
2 changes: 2 additions & 0 deletions .jenkins
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ source .jenkins.d/util.sh

if has Linux $NODE_LABELS; then
export PATH="${HOME}/.local/bin${PATH:+:}${PATH}"
elif [[ -x /opt/homebrew/bin/brew ]]; then
eval "$(/opt/homebrew/bin/brew shellenv)"
fi
export CACHE_DIR=${CACHE_DIR:-/tmp}
export WAF_JOBS=${WAF_JOBS:-1}
Expand Down
2 changes: 1 addition & 1 deletion .jenkins.d/00-deps.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
set -ex

if has OSX $NODE_LABELS; then
if has macos $NODE_LABELS; then
FORMULAE=(boost openssl pkg-config)
if [[ $JOB_NAME == *"Docs" ]]; then
FORMULAE+=(doxygen graphviz)
Expand Down
5 changes: 4 additions & 1 deletion .jenkins.d/10-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ fi
if [[ $JOB_NAME == *"code-coverage" ]]; then
COVERAGE="--with-coverage"
fi
if has macos-12 $NODE_LABELS; then
KEYCHAIN="--without-osx-keychain"
fi
if [[ -n $DISABLE_PCH ]]; then
PCH="--without-pch"
fi
Expand All @@ -31,7 +34,7 @@ if [[ $JOB_NAME != *"code-coverage" && $JOB_NAME != *"limited-build" ]]; then
fi

# Build shared library in debug mode with tests and examples
./waf --color=yes configure --disable-static --enable-shared --debug --with-tests --with-examples $ASAN $COVERAGE $PCH
./waf --color=yes configure --disable-static --enable-shared --debug --with-tests --with-examples $ASAN $COVERAGE $KEYCHAIN $PCH
./waf --color=yes build -j$WAF_JOBS

# (tests will be run against the debug version)
Expand Down
2 changes: 1 addition & 1 deletion .jenkins.d/20-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -ex
# Prepare environment
rm -rf ~/.ndn

if has OSX $NODE_LABELS; then
if has macos-10.15 $NODE_LABELS; then
security unlock-keychain -p named-data
fi

Expand Down
8 changes: 4 additions & 4 deletions .jenkins.d/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# CONTINUOUS INTEGRATION SCRIPTS
# Continuous Integration Scripts

## Environment Variables Used in Build Scripts
## Environment Variables

- `NODE_LABELS`: space-separated list of platform properties. The included values are used by
the build scripts to select the proper behavior for different operating systems and versions.
Expand All @@ -9,9 +9,9 @@

Example values:

- `[OS_TYPE]`: `Linux`, `OSX`
- `[OS_TYPE]`: `Linux`, `macos`
- `[DISTRO_TYPE]`: `Ubuntu`, `CentOS`
- `[DISTRO_VERSION]`: `Ubuntu-16.04`, `Ubuntu-18.04`, `CentOS-8`, `OSX-10.14`, `OSX-10.15`
- `[DISTRO_VERSION]`: `ubuntu-20.04`, `ubuntu-22.04`, `centos-9`, `macos-10.15`, `macos-11`

- `JOB_NAME`: optional variable that defines the type of build job. Depending on the job type,
the build scripts can perform different tasks.
Expand Down
4 changes: 2 additions & 2 deletions .waf-tools/boost.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ def build(bld):
from waflib.Configure import conf
from waflib.TaskGen import feature, after_method

BOOST_LIBS = ['/usr/lib', '/usr/local/lib', '/opt/local/lib', '/sw/lib', '/lib']
BOOST_INCLUDES = ['/usr/include', '/usr/local/include', '/opt/local/include', '/sw/include']
BOOST_LIBS = ['/usr/lib', '/usr/local/lib', '/opt/homebrew/lib', '/opt/local/lib', '/sw/lib', '/lib']
BOOST_INCLUDES = ['/usr/include', '/usr/local/include', '/opt/homebrew/include', '/opt/local/include', '/sw/include']

BOOST_VERSION_FILE = 'boost/version.hpp'
BOOST_VERSION_CODE = '''
Expand Down
5 changes: 3 additions & 2 deletions .waf-tools/default-compiler-flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def configure(conf):
'The minimum supported clang version is 6.0.')
conf.flags = ClangFlags()
else:
warnmsg = '%s compiler is unsupported' % cxx
warnmsg = f'{cxx} compiler is unsupported'
conf.flags = CompilerFlags()

if errmsg:
Expand Down Expand Up @@ -200,7 +200,8 @@ def getGeneralFlags(self, conf):
flags = super(ClangFlags, self).getGeneralFlags(conf)
if Utils.unversioned_sys_platform() == 'darwin':
# Bug #4296
flags['CXXFLAGS'] += [['-isystem', '/usr/local/include'], # for Homebrew
brewdir = '/opt/homebrew' if platform.machine() == 'arm64' else '/usr/local'
flags['CXXFLAGS'] += [['-isystem', f'{brewdir}/include'], # for Homebrew
['-isystem', '/opt/local/include']] # for MacPorts
elif Utils.unversioned_sys_platform() == 'freebsd':
# Bug #4790
Expand Down
7 changes: 5 additions & 2 deletions .waf-tools/openssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ def build(bld):
from waflib import Utils
from waflib.Configure import conf

OPENSSL_DIR_OSX = ['/usr/local', '/opt/local', '/usr/local/opt/openssl']
OPENSSL_DIR = ['/usr', '/usr/local', '/opt/local', '/sw']
OPENSSL_DIR_MACOS = ['/usr/local',
'/opt/homebrew/opt/openssl', # Homebrew on arm64
'/usr/local/opt/openssl', # Homebrew on x86_64
'/opt/local'] # MacPorts

def options(opt):
opt.add_option('--with-openssl', type='string', default=None, dest='openssl_dir',
Expand All @@ -43,7 +46,7 @@ def __openssl_find_root_and_version_file(self, root):

openssl_dirs = OPENSSL_DIR
if Utils.unversioned_sys_platform() == 'darwin':
openssl_dirs = OPENSSL_DIR_OSX
openssl_dirs = OPENSSL_DIR_MACOS

for dir in openssl_dirs:
file = self.__openssl_get_version_file(dir)
Expand Down
48 changes: 24 additions & 24 deletions docs/INSTALL.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,37 @@ Supported platforms
ndn-cxx is built against a continuous integration system and has been tested on the
following platforms:

- Ubuntu 18.04 (amd64, armhf, i386)
- Ubuntu 20.04 (amd64)
- Ubuntu 21.10 (amd64)
- CentOS Stream 9
- macOS 10.15
- macOS 11 (Intel only)
- Ubuntu 18.04
- Ubuntu 20.04
- Ubuntu 22.04
- Debian 11
- CentOS Stream 9
- macOS 10.15
- macOS 11
- macOS 12

ndn-cxx is known to work on the following platforms, although they are not officially
supported:

- Alpine >= 3.12
- Debian >= 10
- Fedora >= 29
- Gentoo Linux
- Raspberry Pi OS (formerly Raspbian) >= 2019-06-20
- FreeBSD >= 12.0
- macOS 10.14
- Alpine >= 3.12
- Fedora >= 29
- Gentoo Linux
- Raspberry Pi OS (formerly Raspbian) >= 2019-06-20
- FreeBSD >= 12.0

Prerequisites
-------------

Required
~~~~~~~~

- GCC >= 7.4 or clang >= 6.0 (if you are on Linux or FreeBSD)
- Xcode >= 11.3 or corresponding version of Command Line Tools (if you are on macOS)
- Python >= 3.6
- pkg-config
- Boost >= 1.65.1
- OpenSSL >= 1.1.1
- SQLite 3.x
- GCC >= 7.4 or clang >= 6.0 (if you are on Linux or FreeBSD)
- Xcode >= 11.3 or corresponding version of Command Line Tools (if you are on macOS)
- Python >= 3.6
- pkg-config
- Boost >= 1.65.1
- OpenSSL >= 1.1.1
- SQLite 3.x

To build ndn-cxx from source, one must first install a C++ compiler and all necessary
development tools and libraries:
Expand Down Expand Up @@ -83,10 +83,10 @@ Optional
To build tutorials, man pages, and API documentation the following additional dependencies
need to be installed:

- doxygen
- graphviz
- sphinx >= 1.3
- sphinxcontrib-doxylink
- doxygen
- graphviz
- sphinx >= 1.3
- sphinxcontrib-doxylink

The following lists the steps to install these prerequisites on various common platforms.

Expand Down

0 comments on commit f662500

Please sign in to comment.