Skip to content

Commit c5e9a09

Browse files
authored
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
1 parent 4b2aa73 commit c5e9a09

File tree

3 files changed

+51
-39
lines changed

3 files changed

+51
-39
lines changed

Diff for: Dockerfile

+4-3
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@ LABEL creator "Trail of Bits"
77
LABEL dockerfile_maintenance "William Woodruff <william@trailofbits>"
88
LABEL desc "Principled, lightweight C/C++ PE parser"
99

10-
RUN apk add --no-cache cmake icu-dev build-base
10+
RUN apk add --no-cache cmake icu-dev clang build-base
1111

1212
COPY . /app/pe-parse
1313
WORKDIR /app/pe-parse
14+
ENV CC=clang CXX=clang++
1415
RUN mkdir build && \
1516
cd build && \
1617
cmake -DCMAKE_BUILD_TYPE="${BUILD_TYPE}" .. && \
17-
cmake --build . --config "${BUILD_TYPE}" && \
18-
cmake --build . --config "${BUILD_TYPE}" --target install
18+
cmake --build . && \
19+
cmake --build . --target install
1920

2021
ENTRYPOINT [ "/usr/bin/dump-pe" ]
2122
CMD ["--help"]

Diff for: cmake/compilation_flags.cmake

+1-3
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,8 @@ else ()
3232
endif ()
3333

3434
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
35-
message(STATUS "This is a debug build; enabling -Weverything...")
36-
3735
list(APPEND DEFAULT_CXX_FLAGS
38-
-Weverything -Wno-c++98-compat -Wno-missing-prototypes
36+
-Wno-c++98-compat -Wno-missing-prototypes
3937
-Wno-missing-variable-declarations -Wno-global-constructors
4038
-Wno-exit-time-destructors -Wno-padded -Wno-error
4139
)

Diff for: python/setup.py

+46-33
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# 2. Redistributions in binary form must reproduce the above copyright
1111
# notice, this list of conditions and the following disclaimer in the
1212
# documentation and/or other materials provided with the distribution.
13-
#
13+
#
1414
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1515
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1616
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -30,40 +30,53 @@
3030

3131
here = os.path.abspath(os.path.dirname(__file__))
3232

33-
SOURCE_FILES = [os.path.join(here, 'pepy.cpp'),
34-
os.path.abspath(os.path.join(here, '..', 'pe-parser-library', 'src', 'parse.cpp')),
35-
os.path.abspath(os.path.join(here, '..', 'pe-parser-library', 'src', 'buffer.cpp')),
36-
os.path.abspath(os.path.join(here, '..', 'pe-parser-library', 'src', 'unicode_codecvt.cpp'))]
33+
SOURCE_FILES = [
34+
os.path.join(here, "pepy.cpp"),
35+
os.path.abspath(os.path.join(here, "..", "pe-parser-library", "src", "parse.cpp")),
36+
os.path.abspath(os.path.join(here, "..", "pe-parser-library", "src", "buffer.cpp")),
37+
os.path.abspath(
38+
os.path.join(here, "..", "pe-parser-library", "src", "unicode_codecvt.cpp")
39+
),
40+
]
3741

38-
if platform.system() == 'Windows':
39-
INCLUDE_DIRS = [os.path.abspath(os.path.join(os.path.dirname(sys.executable), 'include')),
40-
os.path.abspath(os.path.join(here, '..', 'pe-parser-library', 'include')),
41-
'C:\\usr\\include']
42-
LIBRARY_DIRS = [os.path.abspath(os.path.join(os.path.dirname(sys.executable), 'libs')),
43-
'C:\\usr\\lib']
44-
COMPILE_ARGS = ["/EHsc"]
42+
if platform.system() == "Windows":
43+
INCLUDE_DIRS = [
44+
os.path.abspath(os.path.join(os.path.dirname(sys.executable), "include")),
45+
os.path.abspath(os.path.join(here, "..", "pe-parser-library", "include")),
46+
"C:\\usr\\include",
47+
]
48+
LIBRARY_DIRS = [
49+
os.path.abspath(os.path.join(os.path.dirname(sys.executable), "libs")),
50+
"C:\\usr\\lib",
51+
]
52+
COMPILE_ARGS = ["/EHsc"]
4553
else:
46-
INCLUDE_DIRS = ['/usr/local/include',
47-
'/opt/local/include',
48-
'/usr/include',
49-
os.path.abspath(os.path.join(here, '..', 'pe-parser-library', 'include'))]
50-
LIBRARY_DIRS = ['/usr/lib',
51-
'/usr/local/lib']
52-
COMPILE_ARGS = ["-std=c++11", "-g", "-O0"] # Debug only
54+
INCLUDE_DIRS = [
55+
"/usr/local/include",
56+
"/opt/local/include",
57+
"/usr/include",
58+
os.path.abspath(os.path.join(here, "..", "pe-parser-library", "include")),
59+
]
60+
LIBRARY_DIRS = ["/usr/lib", "/usr/local/lib"]
61+
COMPILE_ARGS = ["-std=c++11", "-g", "-O0"] # Debug only
5362

54-
extension_mod = Extension('pepy',
55-
sources = SOURCE_FILES,
56-
extra_compile_args = COMPILE_ARGS,
57-
language='c++',
58-
include_dirs = INCLUDE_DIRS,
59-
library_dirs = LIBRARY_DIRS)
63+
extension_mod = Extension(
64+
"pepy",
65+
sources=SOURCE_FILES,
66+
extra_compile_args=COMPILE_ARGS,
67+
language="c++",
68+
include_dirs=INCLUDE_DIRS,
69+
library_dirs=LIBRARY_DIRS,
70+
)
6071

6172

62-
setup (name = 'pepy',
63-
version = '0.1',
64-
description = 'python bindings for pe-parse',
65-
author = 'Wesley Shields',
66-
author_email = '[email protected]',
67-
license = 'BSD',
68-
long_description = 'Python bindings for pe-parse',
69-
ext_modules = [extension_mod])
73+
setup(
74+
name="pepy",
75+
version="0.1",
76+
description="python bindings for pe-parse",
77+
author="Wesley Shields",
78+
author_email="[email protected]",
79+
license="BSD",
80+
long_description="Python bindings for pe-parse",
81+
ext_modules=[extension_mod],
82+
)

0 commit comments

Comments
 (0)