Dockerfile, cmake: Simplify build (#111)

* Dockerfile, cmake: Simplify build

Always use clang in the Dockerfile, and don't overspecify
the build type.

Additionally, drop -Weverything when building in Debug mode --
it has competing flags internally and isn't intended for actual
builds.

* Dockerfile: Set CC and CXX

Ensures that we build with clang(++).

* python/setup: Blacken
This commit is contained in:
William Woodruff 2020-03-09 15:18:54 -04:00 committed by GitHub
parent 4b2aa738cb
commit c5e9a09087
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 51 additions and 39 deletions

View File

@ -7,15 +7,16 @@ LABEL creator "Trail of Bits"
LABEL dockerfile_maintenance "William Woodruff <william@trailofbits>" LABEL dockerfile_maintenance "William Woodruff <william@trailofbits>"
LABEL desc "Principled, lightweight C/C++ PE parser" LABEL desc "Principled, lightweight C/C++ PE parser"
RUN apk add --no-cache cmake icu-dev build-base RUN apk add --no-cache cmake icu-dev clang build-base
COPY . /app/pe-parse COPY . /app/pe-parse
WORKDIR /app/pe-parse WORKDIR /app/pe-parse
ENV CC=clang CXX=clang++
RUN mkdir build && \ RUN mkdir build && \
cd build && \ cd build && \
cmake -DCMAKE_BUILD_TYPE="${BUILD_TYPE}" .. && \ cmake -DCMAKE_BUILD_TYPE="${BUILD_TYPE}" .. && \
cmake --build . --config "${BUILD_TYPE}" && \ cmake --build . && \
cmake --build . --config "${BUILD_TYPE}" --target install cmake --build . --target install
ENTRYPOINT [ "/usr/bin/dump-pe" ] ENTRYPOINT [ "/usr/bin/dump-pe" ]
CMD ["--help"] CMD ["--help"]

View File

@ -32,10 +32,8 @@ else ()
endif () endif ()
if (CMAKE_BUILD_TYPE STREQUAL "Debug") if (CMAKE_BUILD_TYPE STREQUAL "Debug")
message(STATUS "This is a debug build; enabling -Weverything...")
list(APPEND DEFAULT_CXX_FLAGS list(APPEND DEFAULT_CXX_FLAGS
-Weverything -Wno-c++98-compat -Wno-missing-prototypes -Wno-c++98-compat -Wno-missing-prototypes
-Wno-missing-variable-declarations -Wno-global-constructors -Wno-missing-variable-declarations -Wno-global-constructors
-Wno-exit-time-destructors -Wno-padded -Wno-error -Wno-exit-time-destructors -Wno-padded -Wno-error
) )

View File

@ -10,7 +10,7 @@
# 2. Redistributions in binary form must reproduce the above copyright # 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the # notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution. # documentation and/or other materials provided with the distribution.
# #
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@ -30,40 +30,53 @@ import platform
here = os.path.abspath(os.path.dirname(__file__)) here = os.path.abspath(os.path.dirname(__file__))
SOURCE_FILES = [os.path.join(here, 'pepy.cpp'), SOURCE_FILES = [
os.path.abspath(os.path.join(here, '..', 'pe-parser-library', 'src', 'parse.cpp')), os.path.join(here, "pepy.cpp"),
os.path.abspath(os.path.join(here, '..', 'pe-parser-library', 'src', 'buffer.cpp')), os.path.abspath(os.path.join(here, "..", "pe-parser-library", "src", "parse.cpp")),
os.path.abspath(os.path.join(here, '..', 'pe-parser-library', 'src', 'unicode_codecvt.cpp'))] os.path.abspath(os.path.join(here, "..", "pe-parser-library", "src", "buffer.cpp")),
os.path.abspath(
os.path.join(here, "..", "pe-parser-library", "src", "unicode_codecvt.cpp")
),
]
if platform.system() == 'Windows': if platform.system() == "Windows":
INCLUDE_DIRS = [os.path.abspath(os.path.join(os.path.dirname(sys.executable), 'include')), INCLUDE_DIRS = [
os.path.abspath(os.path.join(here, '..', 'pe-parser-library', 'include')), os.path.abspath(os.path.join(os.path.dirname(sys.executable), "include")),
'C:\\usr\\include'] os.path.abspath(os.path.join(here, "..", "pe-parser-library", "include")),
LIBRARY_DIRS = [os.path.abspath(os.path.join(os.path.dirname(sys.executable), 'libs')), "C:\\usr\\include",
'C:\\usr\\lib'] ]
COMPILE_ARGS = ["/EHsc"] LIBRARY_DIRS = [
os.path.abspath(os.path.join(os.path.dirname(sys.executable), "libs")),
"C:\\usr\\lib",
]
COMPILE_ARGS = ["/EHsc"]
else: else:
INCLUDE_DIRS = ['/usr/local/include', INCLUDE_DIRS = [
'/opt/local/include', "/usr/local/include",
'/usr/include', "/opt/local/include",
os.path.abspath(os.path.join(here, '..', 'pe-parser-library', 'include'))] "/usr/include",
LIBRARY_DIRS = ['/usr/lib', os.path.abspath(os.path.join(here, "..", "pe-parser-library", "include")),
'/usr/local/lib'] ]
COMPILE_ARGS = ["-std=c++11", "-g", "-O0"] # Debug only LIBRARY_DIRS = ["/usr/lib", "/usr/local/lib"]
COMPILE_ARGS = ["-std=c++11", "-g", "-O0"] # Debug only
extension_mod = Extension('pepy', extension_mod = Extension(
sources = SOURCE_FILES, "pepy",
extra_compile_args = COMPILE_ARGS, sources=SOURCE_FILES,
language='c++', extra_compile_args=COMPILE_ARGS,
include_dirs = INCLUDE_DIRS, language="c++",
library_dirs = LIBRARY_DIRS) include_dirs=INCLUDE_DIRS,
library_dirs=LIBRARY_DIRS,
)
setup (name = 'pepy', setup(
version = '0.1', name="pepy",
description = 'python bindings for pe-parse', version="0.1",
author = 'Wesley Shields', description="python bindings for pe-parse",
author_email = 'wxs@atarininja.org', author="Wesley Shields",
license = 'BSD', author_email="wxs@atarininja.org",
long_description = 'Python bindings for pe-parse', license="BSD",
ext_modules = [extension_mod]) long_description="Python bindings for pe-parse",
ext_modules=[extension_mod],
)