Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 30 additions & 16 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,19 @@ jobs:
- name: Checkout sources
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Setup Fortran compiler
uses: fortran-lang/setup-fortran@8821f57b53846d35d62632eb51c60ac6c4bff4ce # v1.6.1
uses: fortran-lang/setup-fortran@2a1b9c55897d827a9dfeb114408f3615e53b2b72 # v1.9.0
with:
compiler: intel
- name: Setup MSVC environment
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0
with:
arch: amd64
- name: Build C library
# 1. Force to only build the 64-bit version since ITT API 32-bit support will be discontinued soon
# 2. Disable PT support for MacOS since we have x86 specific assembly instructions
# 3. Switch to use Ninja CMake Generator for Windows since setup-fortran action
# doesn't work in case of CMake + VS (https://github.com/fortran-lang/setup-fortran/issues/45)
run: python buildall.py --force_bits 64 -ft ${{ matrix.optional_args }}
# - Disable PT support for MacOS since we have x86 specific assembly instructions
# - Switch to use Ninja CMake Generator for Windows since setup-fortran action
# doesn't work in case of CMake + VS (https://github.com/fortran-lang/setup-fortran/issues/45)
run: python buildall.py -ft ${{ matrix.optional_args }}

refcol_smoke:
name: Reference collector smoke test
Expand All @@ -47,21 +51,26 @@ jobs:
matrix:
include:
- os: ubuntu-latest
lib: build_linux/64/bin/libittnotify_refcol.so
exe: build_linux/64/bin/refcol_smoke_test
build_dir: build_linux/64
lib: build_linux/bin/libittnotify_refcol.so
exe: build_linux/bin/refcol_smoke_test
build_dir: build_linux
- os: windows-latest
lib: build_win/64/bin/libittnotify_refcol.dll
exe: build_win/64/bin/refcol_smoke_test.exe
build_dir: build_win/64
lib: build_win/bin/libittnotify_refcol.dll
exe: build_win/bin/refcol_smoke_test.exe
build_dir: build_win
defaults:
run:
shell: bash
steps:
- name: Checkout sources
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Setup MSVC environment
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0
with:
arch: amd64
- name: Build reference collector library
run: python buildall.py --force_bits 64 --refcol ${{ runner.os == 'Windows' && '--cmake_gen ninja' || '' }}
run: python buildall.py --refcol ${{ runner.os == 'Windows' && '--cmake_gen ninja' || '' }}
- name: Build smoke test
run: |
cmake ${{ matrix.build_dir }} -DITT_API_REFCOL_SMOKE_TESTS=ON
Expand All @@ -81,13 +90,18 @@ jobs:
steps:
- name: Checkout sources
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Setup MSVC environment
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0
with:
arch: amd64
- name: Build C++ wrapper
run: python buildall.py --force_bits 64 -cpp
run: python buildall.py -cpp ${{ runner.os == 'Windows' && '--cmake_gen ninja' || '' }}
- name: Test (Linux)
run: ctest --test-dir build_linux/64/cpp --build-config Release --output-on-failure
run: ctest --test-dir build_linux/cpp --build-config Release --output-on-failure
if: runner.os == 'Linux'
- name: Test (Windows)
run: ctest --test-dir build_win/64/cpp --build-config Release --output-on-failure
run: ctest --test-dir build_win/cpp --build-config Release --output-on-failure
if: runner.os == 'Windows'

rust_format:
Expand Down
12 changes: 7 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ jobs:
steps:
- name: Checkout sources
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Config environment
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install gcc-multilib
- name: Setup Fortran compiler
uses: fortran-lang/setup-fortran@8821f57b53846d35d62632eb51c60ac6c4bff4ce # v1.6.1
uses: fortran-lang/setup-fortran@2a1b9c55897d827a9dfeb114408f3615e53b2b72 # v1.9.0
with:
compiler: intel
- name: Setup MSVC environment
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0
with:
arch: amd64
- name: Build C library
run: python buildall.py -ft ${{ matrix.optional_args }}
- name: Display structure of files
Expand All @@ -43,7 +45,7 @@ jobs:
build*/**/bin
build*/**/fortran

# build wheels for cpython versions 3.8+ on linux and windows 64-bits
# build wheels for cpython versions 3.8+ on linux and windows
python_build:
name: Build ittapi wheels
runs-on: ${{ matrix.os }}
Expand Down
34 changes: 4 additions & 30 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#
# Copyright (C) 2005-2023 Intel Corporation
# Copyright (C) 2005-2026 Intel Corporation
#
# SPDX-License-Identifier: GPL-2.0-only OR BSD-3-Clause
#

cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.10)

if(POLICY CMP0048)
# The `project()` command manages `VERSION` variables
Expand All @@ -23,28 +23,12 @@ endif()

project(ittapi)

option(FORCE_32 "Force a 32-bit compile on 64-bit" OFF)
option(ITT_API_IPT_SUPPORT "ptmarks support" OFF)
option(ITT_API_FORTRAN_SUPPORT "fortran support" OFF)
option(ITT_API_CPP_SUPPORT "C++ wrapper support" OFF)
option(ITT_API_REFERENCE_COLLECTOR "Build reference collector shared library" OFF)
option(ITT_API_INSTALL "Enable ITT API installation rules" ON)

if(FORCE_32 AND UNIX)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
endif()

if(CMAKE_SIZEOF_VOID_P MATCHES "8" AND NOT(FORCE_32))
set(ARCH_64 ON)
endif()

if(FORCE_32 AND ITT_API_FORTRAN_SUPPORT)
# ifx dropped 32-bit support
message(WARNING "Fortran support for 32-bit has been discontinued")
set(ITT_API_FORTRAN_SUPPORT OFF)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "^(Apple)?Clang$")
# override default -O3
string(REPLACE "-O3" "-O2" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
Expand Down Expand Up @@ -75,20 +59,10 @@ if(ITT_API_IPT_SUPPORT)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DITT_API_IPT_SUPPORT")
if(NOT WIN32)
enable_language(ASM)
if(ARCH_64)
set(ITT_PT src/ittnotify/ittptmark64.S)
else()
set(ASM_OPTIONS "-m32")
set(ITT_PT src/ittnotify/ittptmark32.S)
endif()
set(CMAKE_ASM_FLAGS "${CFLAGS} ${ASM_OPTIONS}")
set(ITT_PT src/ittnotify/ittptmark64.S)
else()
enable_language(ASM_MASM)
if(ARCH_64)
set(ITT_PT src/ittnotify/ittptmark64.asm)
else()
set(ITT_PT src/ittnotify/ittptmark32.asm)
endif()
set(ITT_PT src/ittnotify/ittptmark64.asm)
endif()
endif()

Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ To build the library:

- Get general development tools, including C/C++ Compiler
- Install [Python](https://python.org) 3.6 or later
- Install [CMake](https://cmake.org) 3.5 or later
- Install [CMake](https://cmake.org) 3.10 or later
- For a Windows* system, install one of these:
- [Microsoft Visual Studio](https://visualstudio.microsoft.com) 2015 or later
- [Ninja](https://github.com/ninja-build/ninja/releases) 1.9 or later
Expand All @@ -41,7 +41,7 @@ To build the library:
- To list available build options execute: `python buildall.py -h`

```
usage: buildall.py [-h] [-d] [-c] [-v] [-pt] [-ft] [-cpp] [--force_bits]
usage: buildall.py [-h] [-d] [-c] [-v] [-pt] [-ft] [-cpp] [--refcol]

optional arguments:
-h, --help show this help message and exit
Expand All @@ -51,7 +51,6 @@ optional arguments:
-pt, --ptmark enable anomaly detection support
-ft, --fortran enable fortran support
-cpp, --cpp enable C++ wrapper support
--force_bits specify bit version for the target
--refcol enable reference collector build
--vs specify visual studio version (Windows only)
--cmake_gen specify cmake build generator (Windows only)
Expand Down
147 changes: 72 additions & 75 deletions buildall.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
#!/usr/bin/env python
#
# Copyright (C) 2005-2019 Intel Corporation
# Copyright (C) 2005-2026 Intel Corporation
#
# SPDX-License-Identifier: GPL-2.0-only OR BSD-3-Clause
#

from __future__ import print_function
import os
import sys
import shutil
import fnmatch
import subprocess


def run_shell(cmd):
print("\n>>", cmd)
code = os.system(cmd)
if code != 0:
sys.exit(">> failed to run shell command: %s" % cmd)
print(f"\n>> {cmd}")
try:
subprocess.run(cmd, shell=True, check=True)
except subprocess.CalledProcessError:
sys.exit(f">> failed to run shell command: {cmd}")


if sys.platform == 'win32':
Expand Down Expand Up @@ -91,15 +90,14 @@ def get_vs_versions(): # https://www.mztools.com/articles/2008/MZ2008003.aspx

def detect_cmake():
if sys.platform == 'darwin':
path, err = subprocess.Popen(
"which cmake", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
if not path.strip():
path, err = subprocess.Popen(
"which xcrun", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
if not path.strip():
print("No cmake and no XCode found...")
return None
cmake_path = shutil.which('cmake')
if cmake_path:
return 'cmake'
xcrun_path = shutil.which('xcrun')
if xcrun_path:
return 'xcrun cmake'
print("No cmake and no XCode found...")
return None
return 'cmake'


Expand All @@ -121,79 +119,78 @@ def main():
"-cpp", "--cpp", help="enable C++ wrapper support", action="store_true")
parser.add_argument(
"--refcol", help="enable reference collector build", action="store_true")
parser.add_argument(
"--force_bits", choices=["32", "64"], help="specify bit version for the target")
if sys.platform == 'win32' and vs_versions:
parser.add_argument(
"--vs", help="specify visual studio version {default}", choices=vs_versions, default=vs_versions[0])
if sys.platform == 'win32':
if vs_versions:
parser.add_argument(
"--vs", help="specify visual studio version {default}", choices=vs_versions, default=vs_versions[0])
parser.add_argument(
"--cmake_gen", choices=["vs", "ninja"], help="specify cmake build generator")
args = parser.parse_args()

if args.force_bits:
target_bits = [args.force_bits]
else:
target_bits = ['64']
if (sys.platform != 'darwin'): # on MAC OSX we produce FAT library including both 32 and 64 bits
target_bits.append('32')

print("target_bits", target_bits)
work_dir = os.getcwd()
if args.clean:
bin_dir = os.path.join(work_dir, 'bin')
if os.path.exists(bin_dir):
shutil.rmtree(bin_dir)
for bits in target_bits:
work_folder = os.path.join(
work_dir, "build_" + (sys.platform.replace('32', "")), bits)
already_there = os.path.exists(work_folder)
if already_there and args.clean:
work_dir, "build_" + sys.platform.replace('32', ""))
if os.path.exists(work_folder):
shutil.rmtree(work_folder)
already_there = False
if not already_there:
os.makedirs(work_folder)
print("work_folder: ", work_folder)
os.chdir(work_folder)
if args.clean:
continue

cmake = detect_cmake()
if not cmake:
print("Error: cmake is not found")
return

if sys.platform == 'win32':
# ninja does not support platform bit specification
use_ninja = args.cmake_gen == 'ninja' and bits =='64'
if vs_versions and not use_ninja:
generator = 'Visual Studio {}'.format(args.vs)
generator_args = '-A {}'.format('x64' if bits ==
'64' else 'Win32')
else:
generator = 'Ninja'
generator_args = ''
return

Comment thread
eparshut marked this conversation as resolved.
# Build folder: build_linux, build_win, build_darwin
work_folder = os.path.join(
work_dir, "build_" + sys.platform.replace('32', ""))
if not os.path.exists(work_folder):
os.makedirs(work_folder)
print("work_folder: ", work_folder)
os.chdir(work_folder)

cmake = detect_cmake()
if not cmake:
print("Error: cmake is not found")
return

if sys.platform == 'win32':
vs_year = {
'12': '2013', '14': '2015', '15': '2017',
'16': '2019', '17': '2022', '18': '2025',
}
use_ninja = getattr(args, 'cmake_gen', None) == 'ninja'
if vs_versions and not use_ninja:
year = vs_year.get(args.vs, '')
generator = f'Visual Studio {args.vs} {year}'.strip()
generator_args = '-A x64'
else:
generator = 'Unix Makefiles'
generator = 'Ninja'
generator_args = ''

run_shell('%s "%s" -G"%s" %s %s' % (cmake, work_dir, generator, generator_args, " ".join([
("-DFORCE_32=ON" if bits == '32' else ""),
("-DCMAKE_BUILD_TYPE=Debug" if args.debug else ""),
('-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON' if args.verbose else ''),
("-DITT_API_IPT_SUPPORT=1" if args.ptmark else ""),
("-DITT_API_FORTRAN_SUPPORT=1" if args.fortran else ""),
("-DITT_API_CPP_SUPPORT=ON" if args.cpp else ""),
("-DITT_API_REFERENCE_COLLECTOR=ON" if args.refcol else ""),
])))

if sys.platform == 'win32':
target_project = 'ALL_BUILD' if not use_ninja else 'all'
run_shell('%s --build . --config %s --target %s' %
(cmake, ('Debug' if args.debug else 'Release'), target_project))
else:
import glob
run_shell('%s --build . --config %s' %
(cmake, ('Debug' if args.debug else 'Release')))
else:
generator = 'Unix Makefiles'
generator_args = ''

cmake_options = [f'-G"{generator}"', generator_args]
if args.debug:
cmake_options.append('-DCMAKE_BUILD_TYPE=Debug')
if args.verbose:
cmake_options.append('-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON')
if args.ptmark:
cmake_options.append('-DITT_API_IPT_SUPPORT=1')
if args.fortran:
cmake_options.append('-DITT_API_FORTRAN_SUPPORT=1')
if args.cpp:
cmake_options.append('-DITT_API_CPP_SUPPORT=ON')
if args.refcol:
cmake_options.append('-DITT_API_REFERENCE_COLLECTOR=ON')

run_shell(f'{cmake} "{work_dir}" {" ".join(opt for opt in cmake_options if opt)}')

if sys.platform == 'win32':
target = 'ALL_BUILD' if not use_ninja else 'all'
config = 'Debug' if args.debug else 'Release'
run_shell(f'{cmake} --build . --config {config} --target {target}')
else:
config = 'Debug' if args.debug else 'Release'
run_shell(f'{cmake} --build . --config {config}')


if __name__ == "__main__":
Expand Down
Loading
Loading