mirror of
https://github.com/QuasarApp/LIEF.git
synced 2025-04-26 20:34:32 +00:00
Setup Ninja for windows
This commit is contained in:
parent
d1a7b81120
commit
03ba40b735
@ -120,7 +120,7 @@ install:
|
||||
build_script:
|
||||
- cd %APPVEYOR_BUILD_FOLDER%
|
||||
- set MSBuildLogger="C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
|
||||
- python.exe .\setup.py --sdk --lief-test bdist_wheel && exit 0 # Ignore warnings...
|
||||
- python.exe .\setup.py --ninja --sdk --lief-test bdist_wheel && exit 0 # Ignore warnings...
|
||||
|
||||
after_build:
|
||||
- bash ./.github/deploy.sh
|
||||
|
33
.github/workflow/win.yml
vendored
Normal file
33
.github/workflow/win.yml
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
name: LIEF Windows Tests
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- enhancement/windows-ci
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: windows-latest
|
||||
strategy:
|
||||
matrix:
|
||||
python-version: [3.6, 3.7, 3.8, 3.9]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
- name: Install system dependencies
|
||||
run: |
|
||||
choco install ninja
|
||||
python -m pip install --upgrade pip setuptools
|
||||
python -m pip install wheel mako
|
||||
- uses: ilammy/msvc-dev-cmd@v1
|
||||
with:
|
||||
toolset: "14.16"
|
||||
- name: Build and Test
|
||||
run: |
|
||||
python ./setup.py --ninja --sdk bdist_wheel
|
||||
shell: cmd
|
@ -129,7 +129,9 @@ set_target_properties(pyLIEF PROPERTIES
|
||||
)
|
||||
|
||||
if (MSVC)
|
||||
target_compile_options(pyLIEF PUBLIC /FIiso646.h)
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||
target_compile_options(pyLIEF PUBLIC /FIiso646.h)
|
||||
endif()
|
||||
set_property(TARGET pyLIEF PROPERTY LINK_FLAGS /NODEFAULTLIB:MSVCRT)
|
||||
endif()
|
||||
|
||||
|
@ -36,7 +36,10 @@ endmacro()
|
||||
|
||||
if (MSVC)
|
||||
add_definitions(-DNOMINMAX)
|
||||
target_compile_options(LIB_LIEF PUBLIC /FIiso646.h)
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||
target_compile_options(LIB_LIEF PUBLIC /FIiso646.h)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
|
@ -74,11 +74,13 @@ foreach(example ${LIEF_CPP_EXAMPLES})
|
||||
|
||||
# Don't use default include dir
|
||||
set_property(TARGET "${output_name}" PROPERTY INCLUDE_DIRECTORIES "")
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||
target_compile_options("${output_name}" PUBLIC /FIiso646.h)
|
||||
endif()
|
||||
|
||||
if (MSVC)
|
||||
target_compile_options("${output_name}" PUBLIC /FIiso646.h)
|
||||
set_property(TARGET "${output_name}" PROPERTY LINK_FLAGS /NODEFAULTLIB:MSVCRT)
|
||||
target_compile_options("${output_name}" PUBLIC ${LIEF_CRT})
|
||||
set_property(TARGET "${output_name}" PROPERTY LINK_FLAGS /NODEFAULTLIB:MSVCRT)
|
||||
target_compile_options("${output_name}" PUBLIC ${LIEF_CRT})
|
||||
endif()
|
||||
|
||||
set_property(TARGET "${output_name}" PROPERTY CXX_STANDARD 11)
|
||||
|
50
setup.py
50
setup.py
@ -11,6 +11,7 @@ from distutils import log
|
||||
|
||||
from distutils.version import LooseVersion
|
||||
|
||||
|
||||
MIN_SETUPTOOLS_VERSION = "31.0.0"
|
||||
assert (LooseVersion(setuptools.__version__) >= LooseVersion(MIN_SETUPTOOLS_VERSION)), "LIEF requires a setuptools version '{}' or higher (pip install setuptools --upgrade)".format(MIN_SETUPTOOLS_VERSION)
|
||||
|
||||
@ -101,6 +102,7 @@ class BuildLibrary(build_ext):
|
||||
filename = self.get_ext_filename(fullname)
|
||||
|
||||
jobs = self.parallel if self.parallel else 1
|
||||
cmake_args = []
|
||||
|
||||
source_dir = ext.sourcedir
|
||||
build_temp = self.build_temp
|
||||
@ -109,7 +111,15 @@ class BuildLibrary(build_ext):
|
||||
cfg = 'RelWithDebInfo' if self.debug else 'Release'
|
||||
is64 = sys.maxsize > 2**32
|
||||
|
||||
cmake_args = [
|
||||
# Ninja ?
|
||||
build_with_ninja = False
|
||||
if self.has_ninja() and self.distribution.ninja:
|
||||
build_with_ninja = True
|
||||
|
||||
if build_with_ninja:
|
||||
cmake_args += ["-G", "Ninja"]
|
||||
|
||||
cmake_args += [
|
||||
'-DCMAKE_LIBRARY_OUTPUT_DIRECTORY={}'.format(cmake_library_output_directory),
|
||||
'-DPYTHON_EXECUTABLE={}'.format(sys.executable),
|
||||
'-DLIEF_PYTHON_API=on',
|
||||
@ -172,34 +182,30 @@ class BuildLibrary(build_ext):
|
||||
|
||||
build_args = ['--config', cfg]
|
||||
|
||||
env = os.environ
|
||||
|
||||
if platform.system() == "Windows":
|
||||
from setuptools import msvc
|
||||
|
||||
cmake_args += [
|
||||
'-DCMAKE_BUILD_TYPE={}'.format(cfg),
|
||||
'-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_{}={}'.format(cfg.upper(), cmake_library_output_directory),
|
||||
'-DLIEF_USE_CRT_RELEASE=MT',
|
||||
]
|
||||
cmake_args += ['-A', 'x64'] if is64 else ['-A', 'win32']
|
||||
|
||||
# Specific to appveyor
|
||||
#if os.getenv("APPVEYOR", False):
|
||||
# build_args += ['--', '/v:m']
|
||||
# logger = os.getenv("MSBuildLogger", None)
|
||||
# if logger:
|
||||
# build_args += ['/logger:{}'.format(logger)]
|
||||
#else:
|
||||
build_args += ['--', '/m']
|
||||
if build_with_ninja:
|
||||
arch = 'x64' if is64 else 'x86'
|
||||
ninja_env = msvc.msvc14_get_vc_env(arch)
|
||||
env.update(ninja_env)
|
||||
else:
|
||||
cmake_args += ['-A', 'x64'] if is64 else ['-A', 'win32']
|
||||
build_args += ['--', '/m']
|
||||
else:
|
||||
cmake_args += ['-DCMAKE_BUILD_TYPE={}'.format(cfg)]
|
||||
|
||||
env = os.environ.copy()
|
||||
|
||||
if not os.path.exists(self.build_temp):
|
||||
os.makedirs(self.build_temp)
|
||||
|
||||
build_with_ninja = False
|
||||
if self.has_ninja() and self.distribution.ninja:
|
||||
cmake_args += ["-G", "Ninja"]
|
||||
build_with_ninja = True
|
||||
|
||||
|
||||
# 1. Configure
|
||||
@ -224,7 +230,10 @@ class BuildLibrary(build_ext):
|
||||
if self.distribution.lief_test:
|
||||
subprocess.check_call(['cmake', '--build', '.', '--target', "lief_samples"] + build_args, cwd=self.build_temp, env=env)
|
||||
subprocess.check_call(configure_cmd, cwd=self.build_temp, env=env)
|
||||
subprocess.check_call(['cmake', '--build', '.', '--target', "ALL_BUILD"] + build_args, cwd=self.build_temp, env=env)
|
||||
if build_with_ninja:
|
||||
subprocess.check_call(['cmake', '--build', '.', '--target', "all"] + build_args, cwd=self.build_temp, env=env)
|
||||
else:
|
||||
subprocess.check_call(['cmake', '--build', '.', '--target', "ALL_BUILD"] + build_args, cwd=self.build_temp, env=env)
|
||||
subprocess.check_call(['cmake', '--build', '.', '--target', "check-lief"] + build_args, cwd=self.build_temp, env=env)
|
||||
else:
|
||||
subprocess.check_call(['cmake', '--build', '.', '--target', targets['python_bindings']] + build_args, cwd=self.build_temp, env=env)
|
||||
@ -275,7 +284,12 @@ class BuildLibrary(build_ext):
|
||||
|
||||
pylief_path = os.path.join(cmake_library_output_directory, "{}.{}".format(PACKAGE_NAME, libsuffix))
|
||||
if platform.system() == "Windows":
|
||||
pylief_path = os.path.join(cmake_library_output_directory, "Release", "api", "python", "Release", "{}.{}".format(PACKAGE_NAME, libsuffix))
|
||||
pylief_base = pathlib.Path(cmake_library_output_directory) / "Release" / "api" / "python"
|
||||
pylief_path = pylief_base / "Release" / "{}.{}".format(PACKAGE_NAME, libsuffix)
|
||||
if not pylief_path.is_file():
|
||||
pylief_path = pylief_base / "{}.{}".format(PACKAGE_NAME, libsuffix)
|
||||
|
||||
pylief_path = pylief_path.as_posix()
|
||||
|
||||
if not os.path.exists(self.build_lib):
|
||||
os.makedirs(self.build_lib)
|
||||
|
@ -1,42 +1,10 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
include(ExternalProject)
|
||||
|
||||
macro(ADD_ART_TEST name sources)
|
||||
|
||||
add_executable(${name} ${sources} ${CMAKE_CURRENT_SOURCE_DIR}/utils.cpp)
|
||||
|
||||
set_property(TARGET ${name} PROPERTY INCLUDE_DIRECTORIES "")
|
||||
|
||||
if (MSVC)
|
||||
target_compile_options(${name} PUBLIC /FIiso646.h)
|
||||
set_property(TARGET ${name} PROPERTY LINK_FLAGS /NODEFAULTLIB:MSVCRT)
|
||||
endif()
|
||||
|
||||
set_property(TARGET ${name} PROPERTY CXX_STANDARD 11)
|
||||
set_property(TARGET ${name} PROPERTY CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
|
||||
target_include_directories(${name} PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${DIRENT_INCLUDE_DIR}
|
||||
${CATCH_INCLUDE_DIR})
|
||||
|
||||
add_dependencies(${name} catch)
|
||||
|
||||
if (WIN32)
|
||||
add_dependencies(${name} dirent)
|
||||
target_compile_options("${name}" PUBLIC ${LIEF_CRT})
|
||||
endif()
|
||||
|
||||
add_test(${name} ${CMAKE_CURRENT_BINARY_DIR}/${name})
|
||||
endmacro()
|
||||
|
||||
|
||||
# Python tests
|
||||
# ============
|
||||
# ============
|
||||
if (PYTHON_TESTS_ENABLED)
|
||||
|
||||
|
||||
# Unit tests
|
||||
# ----------
|
||||
ADD_PYTHON_TEST(UNITTEST_PYTHON_art
|
||||
|
@ -1,40 +1,8 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
include(ExternalProject)
|
||||
|
||||
macro(ADD_DEX_TEST name sources)
|
||||
|
||||
add_executable(${name} ${sources} ${CMAKE_CURRENT_SOURCE_DIR}/utils.cpp)
|
||||
|
||||
set_property(TARGET ${name} PROPERTY INCLUDE_DIRECTORIES "")
|
||||
|
||||
if (MSVC)
|
||||
target_compile_options(${name} PUBLIC /FIiso646.h)
|
||||
set_property(TARGET ${name} PROPERTY LINK_FLAGS /NODEFAULTLIB:MSVCRT)
|
||||
endif()
|
||||
|
||||
set_property(TARGET ${name} PROPERTY CXX_STANDARD 11)
|
||||
set_property(TARGET ${name} PROPERTY CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
target_include_directories(${name} PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${DIRENT_INCLUDE_DIR}
|
||||
${CATCH_INCLUDE_DIR})
|
||||
|
||||
add_dependencies(${name} catch)
|
||||
|
||||
if (WIN32)
|
||||
add_dependencies(${name} dirent)
|
||||
target_compile_options("${name}" PUBLIC ${LIEF_CRT})
|
||||
endif()
|
||||
|
||||
target_link_libraries(${name} PUBLIC LIB_LIEF)
|
||||
add_test(${name} ${CMAKE_CURRENT_BINARY_DIR}/${name})
|
||||
|
||||
endmacro()
|
||||
|
||||
|
||||
# Python tests
|
||||
# ============
|
||||
# ============
|
||||
if (PYTHON_TESTS_ENABLED)
|
||||
|
||||
# Unit tests
|
||||
|
@ -1,43 +1,10 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
include(ExternalProject)
|
||||
|
||||
macro(ADD_OAT_TEST name sources)
|
||||
|
||||
add_executable(${name} ${sources} ${CMAKE_CURRENT_SOURCE_DIR}/utils.cpp)
|
||||
|
||||
set_property(TARGET ${name} PROPERTY INCLUDE_DIRECTORIES "")
|
||||
|
||||
if (MSVC)
|
||||
target_compile_options(${name} PUBLIC /FIiso646.h)
|
||||
set_property(TARGET ${name} PROPERTY LINK_FLAGS /NODEFAULTLIB:MSVCRT)
|
||||
endif()
|
||||
|
||||
set_property(TARGET ${name} PROPERTY CXX_STANDARD 11)
|
||||
set_property(TARGET ${name} PROPERTY CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
target_include_directories(${name} PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${DIRENT_INCLUDE_DIR}
|
||||
${CATCH_INCLUDE_DIR})
|
||||
|
||||
add_dependencies(${name} catch)
|
||||
|
||||
if (WIN32)
|
||||
add_dependencies(${name} dirent)
|
||||
target_compile_options("${name}" PUBLIC ${LIEF_CRT})
|
||||
endif()
|
||||
|
||||
target_link_libraries(${name} PUBLIC LIB_LIEF)
|
||||
add_test(${name} ${CMAKE_CURRENT_BINARY_DIR}/${name})
|
||||
|
||||
endmacro()
|
||||
|
||||
|
||||
# Python tests
|
||||
# ============
|
||||
# ============
|
||||
if (PYTHON_TESTS_ENABLED)
|
||||
|
||||
|
||||
# Unit tests
|
||||
# ----------
|
||||
ADD_PYTHON_TEST(UNITTEST_PYTHON_oat
|
||||
|
@ -1,43 +1,10 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
include(ExternalProject)
|
||||
|
||||
macro(ADD_VDEX_TEST name sources)
|
||||
|
||||
add_executable(${name} ${sources} ${CMAKE_CURRENT_SOURCE_DIR}/utils.cpp)
|
||||
set_property(TARGET ${name} PROPERTY INCLUDE_DIRECTORIES "")
|
||||
|
||||
if (MSVC)
|
||||
target_compile_options(${name} PUBLIC /FIiso646.h)
|
||||
set_property(TARGET ${name} PROPERTY LINK_FLAGS /NODEFAULTLIB:MSVCRT)
|
||||
endif()
|
||||
|
||||
set_property(TARGET ${name} PROPERTY CXX_STANDARD 11)
|
||||
set_property(TARGET ${name} PROPERTY CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
target_include_directories(${name} PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${YAMLCPP_INCLUDE_DIRS}
|
||||
${DIRENT_INCLUDE_DIR}
|
||||
${CATCH_INCLUDE_DIR})
|
||||
|
||||
add_dependencies(${name} catch YAMLCPP)
|
||||
|
||||
if (WIN32)
|
||||
add_dependencies(${name} dirent)
|
||||
target_compile_options("${name}" PUBLIC ${LIEF_CRT})
|
||||
endif()
|
||||
|
||||
target_link_libraries(${name} PUBLIC LIB_LIEF ${YAMLCPP_LIBRARY_RELEASE})
|
||||
add_test(${name} ${CMAKE_CURRENT_BINARY_DIR}/${name})
|
||||
|
||||
endmacro()
|
||||
|
||||
|
||||
# Python tests
|
||||
# ============
|
||||
# ============
|
||||
if (PYTHON_TESTS_ENABLED)
|
||||
|
||||
|
||||
# Unit tests
|
||||
# ----------
|
||||
ADD_PYTHON_TEST(UNITTEST_PYTHON_vdex
|
||||
|
Loading…
x
Reference in New Issue
Block a user