Skip to content

Commit

Permalink
Enable -Werror=dev|deprecated on build boxes (#501)
Browse files Browse the repository at this point in the history
* Enable CMake -Werror on build boxes

* Revert "Set CMP0069 in AwsCFlags so that other modules get it too (#500)"

This reverts commit a59297c.

Turns out this doesn't actually set the policy correctly.

* Add config param to builder.py build
  • Loading branch information
ColdenCullen authored Sep 10, 2019
1 parent c2019d1 commit 043b979
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 17 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ option(STATIC_CRT "Windows specific option that to specify static/dynamic run-ti

project(aws-c-common LANGUAGES C VERSION 0.1.0)

if (POLICY CMP0069)
cmake_policy(SET CMP0069 NEW) # Enable LTO/IPO if available in the compiler, see AwsCFlags
endif()

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(AwsCFlags)
include(AwsSharedLibSetup)
Expand Down
4 changes: 0 additions & 4 deletions cmake/AwsCFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ include(CheckCCompilerFlag)
include(CheckIncludeFile)
include(CMakeParseArguments) # needed for CMake v3.4 and lower

if (POLICY CMP0069)
cmake_policy(SET CMP0069 NEW) # Enable LTO/IPO if available in the compiler, see AwsCFlags
endif()

# This function will set all common flags on a target
# Options:
# NO_WGNU: Disable -Wgnu
Expand Down
24 changes: 13 additions & 11 deletions codebuild/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ def __repr__(self):
# DATA DEFINITIONS
########################################################################################################################

# CMake config to build with
BUILD_CONFIG = "RelWithDebInfo"

KEYS = {
# Build
'python': "",
Expand Down Expand Up @@ -492,15 +489,14 @@ def _get_git_branch():

return None

def run_build(build_spec, is_dryrun):
def run_build(build_spec, build_config, is_dryrun):

if not is_dryrun:
import tempfile, shutil

#TODO These platforms don't succeed when doing a RelWithDebInfo build
if build_spec.host in ("al2012", "manylinux"):
global BUILD_CONFIG
BUILD_CONFIG = "Debug"
build_config = "Debug"

source_dir = os.environ.get("CODEBUILD_SRC_DIR", os.getcwd())
sources = [os.path.join(source_dir, file) for file in glob.glob('**/*.c')]
Expand Down Expand Up @@ -656,19 +652,24 @@ def _build_project(project=None, build_tests=False, run_tests=False, build_downs

# Run CMake
cmake_args = [
"-Werror=dev",
"-Werror=deprecated",
"-DCMAKE_INSTALL_PREFIX=" + install_dir,
"-DCMAKE_PREFIX_PATH=" + install_dir,
# Each image has a custom installed openssl build, make sure CMake knows where to find it
"-DCMAKE_PREFIX_PATH=/opt/openssl;" + install_dir,
"-DCMAKE_BUILD_TYPE=" + BUILD_CONFIG,
"-DLibCrypto_INCLUDE_DIR=/opt/openssl/include",
"-DLibCrypto_SHARED_LIBRARY=/opt/openssl/lib/libcrypto.so",
"-DLibCrypto_STATIC_LIBRARY=/opt/openssl/lib/libcrypto.a",
"-DCMAKE_BUILD_TYPE=" + build_config,
"-DBUILD_TESTING=" + ("ON" if build_tests else "OFF"),
]
_run_command("cmake", config['build_args'], compiler_flags, cmake_args, project_source_dir)

# Run the build
_run_command("cmake", "--build", ".", "--config", BUILD_CONFIG)
_run_command("cmake", "--build", ".", "--config", build_config)

# Do install
_run_command("cmake", "--build", ".", "--config", BUILD_CONFIG, "--target", "install")
_run_command("cmake", "--build", ".", "--config", build_config, "--target", "install")

# Run the tests
if run_tests:
Expand Down Expand Up @@ -839,6 +840,7 @@ def create_codebuild_project(config, project, github_account, inplace_script):

build = commands.add_parser('build', help="Run the requested build")
build.add_argument('build', type=str)
build.add_argument('--config', type=str, default='RelWithDebInfo', help='The CMake configuration to build with')

codebuild = commands.add_parser('codebuild', help="Create codebuild jobs")
codebuild.add_argument('project', type=str, help='The name of the repo to create the projects for')
Expand All @@ -855,7 +857,7 @@ def create_codebuild_project(config, project, github_account, inplace_script):

print("Running build", build_spec.name, flush=True)

run_build(build_spec, args.dry_run)
run_build(build_spec, args.config, args.dry_run)

if args.command == 'codebuild':

Expand Down
27 changes: 25 additions & 2 deletions docker-images/linux-android/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ RUN yes | sdkmanager \
"build-tools;28.0.3" \
"extras;android;m2repository" \
"extras;google;m2repository" \
"cmake;3.6.4111459"
"cmake;3.6.4111459"

###############################################################################
# Gradle
Expand All @@ -126,7 +126,7 @@ RUN set -ex \
&& cd /tmp/android-ndk-tmp \
&& curl -LO https://dl.google.com/android/repository/android-ndk-${ANDROID_NDK_VERSION}-linux-x86_64.zip \
&& unzip -q android-ndk-${ANDROID_NDK_VERSION}-linux-x86_64.zip \
&& mv ./android-ndk-${ANDROID_NDK_VERSION} ${ANDROID_NDK_HOME}
&& mv ./android-ndk-${ANDROID_NDK_VERSION} ${ANDROID_NDK_HOME}

# add to PATH
ENV PATH ${PATH}:${ANDROID_NDK_HOME}
Expand All @@ -141,6 +141,29 @@ RUN set -ex \
&& tar xzf cmake-${CMAKE_VERSION}-Linux-x86_64.tar.gz --strip-components 1 -C /usr \
&& cmake --version

###############################################################################
# OpenSSL
###############################################################################
RUN set -ex \
&& ([ -d /opt/openssl ] && rm -rf /opt/openssl) || true \
&& mkdir -p /tmp/build \
&& cd /tmp/build \
&& git clone --branch OpenSSL_1_1_1-stable --depth 1 https://github.com/openssl/openssl.git \
&& cd openssl \
&& export CROSS_COMPILE=aarch64-linux-android- \
&& export OLD_PATH=$PATH \
&& export PATH=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/:$PATH \
&& ./Configure android-arm64 no-asm -fPIC \
no-md2 no-rc5 no-rfc3779 no-sctp no-ssl-trace no-zlib no-hw no-mdc2 \
no-seed no-idea no-camellia no-bf no-dsa no-ssl3 no-capieng \
no-unit-test no-tests \
-DSSL_FORBID_ENULL -DOPENSSL_NO_DTLS1 -DOPENSSL_NO_HEARTBEATS \
--prefix=/opt/openssl --openssldir=/opt/openssl \
&& make -j \
&& make install_sw \
&& export PATH=$OLD_PATH \
&& unset CROSS_COMPILE

###############################################################################
# Cleanup
###############################################################################
Expand Down

0 comments on commit 043b979

Please sign in to comment.