4
0
mirror of https://github.com/QuasarApp/LIEF.git synced 2025-05-07 17:29:34 +00:00

Enhance LIEF modules configuration

This commit is contained in:
Romain Thomas 2019-08-23 08:07:40 +02:00
parent 088951ddb7
commit 40570e6522
5 changed files with 190 additions and 39 deletions

@ -21,6 +21,7 @@ option(LIEF_DISABLE_FROZEN "Disable Frozen even if it is supported" OFF)
option(LIEF_ELF "Build LIEF with ELF module" ON)
option(LIEF_PE "Build LIEF with PE module" ON)
option(LIEF_MACHO "Build LIEF with MachO module" ON)
option(LIEF_OAT "Build LIEF with OAT module" ON)
option(LIEF_DEX "Build LIEF with DEX module" ON)
option(LIEF_VDEX "Build LIEF with VDEX module" ON)
@ -38,3 +39,56 @@ option(LIEF_FUZZING "Fuzz LIEF" OFF)
# Profiling
option(LIEF_PROFILING "Enable performance profiling" OFF)
set(LIEF_ELF_SUPPORT 0)
set(LIEF_PE_SUPPORT 0)
set(LIEF_MACHO_SUPPORT 0)
set(LIEF_OAT_SUPPORT 0)
set(LIEF_DEX_SUPPORT 0)
set(LIEF_VDEX_SUPPORT 0)
set(LIEF_ART_SUPPORT 0)
set(LIEF_JSON_SUPPORT 0)
set(LIEF_LOGGING_SUPPORT 0)
set(LIEF_FROZEN_ENABLED 0)
if (LIEF_ELF)
set(LIEF_ELF_SUPPORT 1)
endif()
if (LIEF_PE)
set(LIEF_PE_SUPPORT 1)
endif()
if (LIEF_MACHO)
set(LIEF_MACHO_SUPPORT 1)
endif()
if (LIEF_OAT)
set(LIEF_OAT_SUPPORT 1)
endif()
if (LIEF_DEX)
set(LIEF_DEX_SUPPORT 1)
endif()
if (LIEF_VDEX)
set(LIEF_VDEX_SUPPORT 1)
endif()
if (LIEF_ART)
set(LIEF_ART_SUPPORT 1)
endif()
if (LIEF_ENABLE_JSON)
set(LIEF_JSON_SUPPORT 1)
endif()
if (LIEF_LOGGING)
set(LIEF_LOGGING_SUPPORT 1)
endif()
if (NOT LIEF_DISABLE_FROZEN)
set(LIEF_FROZEN_ENABLED 1)
endif()

@ -1,6 +1,22 @@
Changelog
=========
0.10.0 - Not released yet
-------------------------
:ELF:
* Add build support for ELF notes (:commit:`f`)
* Add coredump support (:commit:`535623de3aa4f8ddc34536331b802e2cbdc44faf`)
:PE:
* Improve PE Authenticode parsing (:commit:`535623de3aa4f8ddc34536331b802e2cbdc44faf`)
:Misc:
* Enhance Python install (see: :ref:`v10-label`)
0.9.0 - June 11, 2018
---------------------

@ -16,6 +16,8 @@ Nightly build can be downloaded here: https://lief-project.github.io/packages/sd
Python
------
.. _v10-label:
Since 0.10.0
************
@ -42,6 +44,25 @@ Using ``setup.py``, one can build and install lief as follows:
$ python ./setup.py [--user] install
LIEF modules can also be parameterized using the following options:
$ python ./setup.py --help
...
--lief-test Build and make tests
--ninja Use Ninja as build system
--sdk Build SDK package
--lief-no-json Disable JSON module
--lief-no-logging Disable logging module
--lief-no-elf Disable ELF module
--lief-no-pe Disable PE module
--lief-no-macho Disable Mach-O module
--lief-no-android Disable Android formats
--lief-no-art Disable ART module
--lief-no-vdex Disable VDEX module
--lief-no-oat Disable OAT module
--lief-no-dex Disable DEX module
From 0.8.0 to 0.9.0
*******************

@ -17,44 +17,37 @@
#ifndef LIEF_CONFIG_H_
#define LIEF_CONFIG_H_
#if @ENABLE_JSON_SUPPORT@
#define LIEF_JSON_SUPPORT
#endif
// Main formats
#cmakedefine LIEF_PE_SUPPORT @LIEF_PE_SUPPORT@
#cmakedefine LIEF_ELF_SUPPORT @LIEF_ELF_SUPPORT@
#cmakedefine LIEF_MACHO_SUPPORT @LIEF_MACHO_SUPPORT@
#if @ENABLE_PE_SUPPORT@
#define LIEF_PE_SUPPORT
#endif
// Android formats
#cmakedefine LIEF_OAT_SUPPORT @LIEF_OAT_SUPPORT@
#cmakedefine LIEF_DEX_SUPPORT @LIEF_DEX_SUPPORT@
#cmakedefine LIEF_VDEX_SUPPORT @LIEF_VDEX_SUPPORT@
#cmakedefine LIEF_ART_SUPPORT @LIEF_ART_SUPPORT@
#if @ENABLE_ELF_SUPPORT@
#define LIEF_ELF_SUPPORT
#endif
// LIEF options
#cmakedefine LIEF_JSON_SUPPORT @ENABLE_JSON_SUPPORT@
#cmakedefine LIEF_LOGGING_SUPPORT @LIEF_LOGGING_SUPPORT@
#cmakedefine LIEF_FROZEN_ENABLED @LIEF_FROZEN_ENABLED@
#if @ENABLE_MACHO_SUPPORT@
#define LIEF_MACHO_SUPPORT
#endif
#ifdef __cplusplus
#if @ENABLE_OAT_SUPPORT@
#define LIEF_OAT_SUPPORT
#endif
static constexpr bool lief_pe_support = @LIEF_PE_SUPPORT@;
static constexpr bool lief_elf_support = @LIEF_ELF_SUPPORT@;
static constexpr bool lief_macho_support = @LIEF_MACHO_SUPPORT@;
#if @ENABLE_DEX_SUPPORT@
#define LIEF_DEX_SUPPORT
#endif
static constexpr bool lief_oat_support = @LIEF_OAT_SUPPORT@;
static constexpr bool lief_dex_support = @LIEF_DEX_SUPPORT@;
static constexpr bool lief_vdex_support = @LIEF_VDEX_SUPPORT@;
static constexpr bool lief_art_support = @LIEF_ART_SUPPORT@;
#if @ENABLE_VDEX_SUPPORT@
#define LIEF_VDEX_SUPPORT
#endif
static constexpr bool lief_json_support = @LIEF_JSON_SUPPORT@;
static constexpr bool lief_logging_support = @LIEF_LOGGING_SUPPORT@;
static constexpr bool lief_frozen_enabled = @LIEF_FROZEN_ENABLED@;
#if @ENABLE_ART_SUPPORT@
#define LIEF_ART_SUPPORT
#endif
#if @ENABLE_LOGGING_SUPPORT@
#define LIEF_LOGGING_SUPPORT
#endif
#if @LIEF_FROZEN_ENABLED@
#define LIEF_FROZEN_ENABLED
#endif
#endif // __cplusplus
#endif

@ -1,9 +1,7 @@
import os
import re
import sys
import platform
import subprocess
import glob
import setuptools
import pathlib
from pkg_resources import Distribution, get_distribution
@ -25,12 +23,39 @@ class LiefDistribution(setuptools.Distribution):
('lief-test', None, 'Build and make tests'),
('ninja', None, 'Use Ninja as build system'),
('sdk', None, 'Build SDK package'),
]
('lief-no-json', None, 'Disable JSON module'),
('lief-no-logging', None, 'Disable logging module'),
('lief-no-elf', None, 'Disable ELF module'),
('lief-no-pe', None, 'Disable PE module'),
('lief-no-macho', None, 'Disable Mach-O module'),
('lief-no-android', None, 'Disable Android formats'),
('lief-no-art', None, 'Disable ART module'),
('lief-no-vdex', None, 'Disable VDEX module'),
('lief-no-oat', None, 'Disable OAT module'),
('lief-no-dex', None, 'Disable DEX module'),
]
def __init__(self, attrs=None):
self.lief_test = False
self.ninja = False
self.sdk = False
self.lief_test = False
self.ninja = False
self.sdk = False
self.lief_no_json = False
self.lief_no_logging = False
self.lief_no_elf = False
self.lief_no_pe = False
self.lief_no_macho = False
self.lief_no_art = False
self.lief_no_oat = False
self.lief_no_dex = False
self.lief_no_vdex = False
self.lief_no_android = False
super().__init__(attrs)
@ -43,7 +68,7 @@ class Module(Extension):
class BuildLibrary(build_ext):
def run(self):
try:
out = subprocess.check_output(['cmake', '--version'])
subprocess.check_output(['cmake', '--version'])
except OSError:
raise RuntimeError("CMake must be installed to build the following extensions: " +
", ".join(e.name for e in self.extensions))
@ -94,9 +119,51 @@ class BuildLibrary(build_ext):
'-DLIEF_PYTHON_API=on',
]
# LIEF options
# ============
if self.distribution.lief_test:
cmake_args += ["-DLIEF_TESTS=on"]
if self.distribution.lief_no_json:
log.info("LIEF JSON module disabled")
cmake_args += ["-DLIEF_ENABLE_JSON=off"]
if self.distribution.lief_no_logging:
log.info("LIEF logging module disabled")
cmake_args += ["-DLIEF_LOGGING=off"]
# Main formats
# ============
if self.distribution.lief_no_elf:
log.info("LIEF ELF module disabled")
cmake_args += ["-DLIEF_ELF=off"]
if self.distribution.lief_no_pe:
log.info("LIEF PE module disabled")
cmake_args += ["-DLIEF_PE=off"]
if self.distribution.lief_no_macho:
log.info("LIEF MACH-O module disabled")
cmake_args += ["-DLIEF_MACHO=off"]
# Android formats
# ===============
if self.distribution.lief_no_oat or self.distribution.lief_no_android:
log.info("LIEF OAT module disabled")
cmake_args += ["-DLIEF_OAT=off"]
if self.distribution.lief_no_dex or self.distribution.lief_no_android:
log.info("LIEF DEX module disabled")
cmake_args += ["-DLIEF_DEX=off"]
if self.distribution.lief_no_vdex or self.distribution.lief_no_android:
log.info("LIEF VDEX module disabled")
cmake_args += ["-DLIEF_VDEX=off"]
if self.distribution.lief_no_art or self.distribution.lief_no_android:
log.info("LIEF ART module disabled")
cmake_args += ["-DLIEF_ART=off"]
build_args = ['--config', cfg]
if platform.system() == "Windows":