Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

M1 build fix #32

Merged
merged 13 commits into from
Jan 8, 2024
57 changes: 57 additions & 0 deletions .github/workflows/cmake-multi-platform.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# This starter workflow is for a CMake project running on multiple platforms. There is a different starter workflow if you just want a single platform.
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-single-platform.yml
name: Autolab CLI

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
merge_group:
branches: [ "master" ]

jobs:
build:
runs-on: ${{ matrix.os }}

strategy:
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable.
fail-fast: false

matrix:
os: [ubuntu-latest, macos-latest]
build_type: [Release]

steps:
- uses: actions/checkout@v3

- name: Set reusable strings
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
id: strings
shell: bash
run: |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"

# https://stackoverflow.com/questions/4247068/sed-command-with-i-option-failing-on-mac-but-works-on-linux
- name: Prepare app_credentials.h
run: |
cp ${{ github.workspace }}/src/app_credentials.h.template ${{ github.workspace }}/src/app_credentials.h
sed -i'' -e 's/\[ENTER STRING HERE\]/"placeholder"/g' ${{ github.workspace }}/src/app_credentials.h

- name: Install libcurl
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
sudo apt-get update
sudo apt-get -y install libcurl4-openssl-dev

- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: >
cmake -B ${{ steps.strings.outputs.build-output-dir }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-S ${{ github.workspace }}

- name: Build
# Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}
17 changes: 17 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,23 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra")
set(CMAKE_CXX_FLAGS_DEBUG "-g")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")

# For OS X
if (CMAKE_HOST_SYSTEM_NAME MATCHES "Darwin")
execute_process(
COMMAND brew --prefix openssl
RESULT_VARIABLE BREW_OPENSSL
OUTPUT_VARIABLE BREW_OPENSSL_PREFIX
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if (BREW_OPENSSL EQUAL 0 AND EXISTS "${BREW_OPENSSL_PREFIX}")
message(STATUS "OpenSSL keg: ${BREW_OPENSSL_PREFIX}")
include_directories("${BREW_OPENSSL_PREFIX}/include")
link_libraries("-L${BREW_OPENSSL_PREFIX}/lib")
else()
message(FATAL_ERROR "OpenSSL keg not found")
endif()
endif()

# configure a header file to pass the version number to the source code
configure_file(
"${PROJECT_SOURCE_DIR}/src/build_config.h.in"
Expand Down
2 changes: 1 addition & 1 deletion lib/autolab/json_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#define LIBAUTOLAB_JSON_HELPERS_H_

#include <cmath>

#include <string>
#include <rapidjson/document.h>

void require_is_array(rapidjson::Value &obj);
Expand Down
11 changes: 11 additions & 0 deletions src/file/file_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@

#include "logger.h"

#ifndef TEMP_FAILURE_RETRY
#define TEMP_FAILURE_RETRY(exp) \
({ \
decltype(exp) _rc; \
do { \
_rc = (exp); \
} while (_rc == -1 && errno == EINTR); \
_rc; \
})
#endif

const char *home_directory = NULL;
char curr_directory[MAX_DIR_LENGTH];

Expand Down