Skip to content

Commit

Permalink
Merge pull request #1847 from lukaszstolarczuk/fix-generate-on-win
Browse files Browse the repository at this point in the history
[CMake] Enable clang-format command on Windows
  • Loading branch information
pbalcer authored Oct 8, 2024
2 parents 537d545 + 8128f79 commit 0112320
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 32 deletions.
16 changes: 1 addition & 15 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -241,20 +241,6 @@ jobs:
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
with:
python-version: 3.9

- name: Install prerequisites
run: python3 -m pip install -r third_party/requirements.txt

- name: Install doxygen
run: |
$WorkingDir = $PWD.Path
Invoke-WebRequest -Uri https://github.com/doxygen/doxygen/releases/download/Release_1_9_8/doxygen-1.9.8.windows.x64.bin.zip -OutFile "$WorkingDir\doxygen.zip"
Expand-Archive -Path "$WorkingDir\doxygen.zip"
Add-Content $env:GITHUB_PATH "$WorkingDir\doxygen"
- name: Install hwloc
run: vcpkg install hwloc:x64-windows

Expand All @@ -272,7 +258,7 @@ jobs:
-DUR_ENABLE_TRACING=ON
-DUR_DEVELOPER_MODE=ON
-DUR_BUILD_TESTS=ON
-DUR_FORMAT_CPP_STYLE=ON
-DUR_FORMAT_CPP_STYLE=OFF
${{matrix.adapter.var}}
- name: Build all
Expand Down
42 changes: 32 additions & 10 deletions .github/workflows/source-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,59 @@ permissions:
jobs:
source-checks:
name: Source Checks
# TODO: Make this run on Windows (#888)
runs-on: 'ubuntu-22.04'
strategy:
matrix:
os: ['ubuntu-22.04', 'windows-2022']

runs-on: ${{matrix.os}}

steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Install apt packages
- uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
with:
python-version: 3.9

- name: Install pip packages
run: pip install -r third_party/requirements.txt

- name: "[Lin] Install doxygen"
if: matrix.os == 'ubuntu-22.04'
run: |
sudo apt-get update
sudo apt-get install -y doxygen
- name: Setup PATH
run: echo "$HOME/.local/bin" >> $GITHUB_PATH

- name: Install pip packages
run: pip install -r third_party/requirements.txt
- name: "[Win] Install doxygen"
if: matrix.os == 'windows-2022'
run: |
$WorkingDir = $PWD.Path
Invoke-WebRequest -Uri https://github.com/doxygen/doxygen/releases/download/Release_1_9_8/doxygen-1.9.8.windows.x64.bin.zip -OutFile "$WorkingDir\doxygen.zip"
Expand-Archive -Path "$WorkingDir\doxygen.zip"
Add-Content $env:GITHUB_PATH "$WorkingDir\doxygen"
# Required for CMake
- name: Install libhwloc
- name: "[Lin] Install hwloc"
if: matrix.os == 'ubuntu-22.04'
run: .github/scripts/install_hwloc.sh

- name: "[Win] Install hwloc"
if: matrix.os == 'windows-2022'
run: vcpkg install hwloc:x64-windows

- name: Configure CMake
env:
VCPKG_PATH: "C:/vcpkg/packages/hwloc_x64-windows"
run: >
cmake
-B${{github.workspace}}/build
-DCMAKE_PREFIX_PATH="${{env.VCPKG_PATH}}"
-DUR_ENABLE_TRACING=OFF
-DCMAKE_BUILD_TYPE=Debug
-DUR_BUILD_TESTS=OFF
-DUR_FORMAT_CPP_STYLE=ON
# Verifying license should be enough on a single OS
- name: Verify that each source file contains a license
if: matrix.os == 'ubuntu-22.04'
run: cmake --build ${{github.workspace}}/build --target verify-licenses

- name: Generate source from spec, check for uncommitted diff
Expand Down
13 changes: 7 additions & 6 deletions cmake/helpers.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2023 Intel Corporation
# Copyright (C) 2023-2024 Intel Corporation
# Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions.
# See LICENSE.TXT
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Expand Down Expand Up @@ -28,13 +28,14 @@ function(add_cppformat name)
if(${ARGC} EQUAL 0)
return()
else()
# Split args into 2 parts (in Windows the list is probably too long)
list(SUBLIST ARGN 0 250 selected_files_1)
list(SUBLIST ARGN 251 -1 selected_files_2)
add_custom_target(cppformat-${name}
COMMAND ${CLANG_FORMAT}
--style=file
--i
${ARGN}
COMMAND ${CLANG_FORMAT} --style=file --i ${selected_files_1}
COMMAND ${CLANG_FORMAT} --style=file --i ${selected_files_2}
COMMENT "Format CXX source files"
)
)
endif()

add_dependencies(cppformat cppformat-${name})
Expand Down
3 changes: 2 additions & 1 deletion scripts/templates/stype_map_helpers.hpp.mako
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<%!
import os
import re
from templates import helper as th
%><%
Expand All @@ -7,7 +8,7 @@ from templates import helper as th
x=tags['$x']
X=x.upper()
%>
// This file is autogenerated from the template at ${self.template.filename}
// This file is autogenerated from the template at ${os.path.dirname(self.template.filename)}/${os.path.basename(self.template.filename)}

%for obj in th.extract_objs(specs, r"enum"):
%if obj["name"] == '$x_structure_type_t':
Expand Down

0 comments on commit 0112320

Please sign in to comment.