Skip to content

Commit f67909f

Browse files
committed
Add clang on the CI for windows and linux + fix compilation
1 parent 5763090 commit f67909f

File tree

6 files changed

+45
-63
lines changed

6 files changed

+45
-63
lines changed

.github/workflows/cpp-ci-serial-programs.yml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,25 @@ jobs:
1010
fail-fast: false
1111
matrix:
1212
os: [windows-2025, macos-13, ubuntu-24.04]
13+
compiler: ['default', 'clang']
1314
qt_version: ['6.9.1']
1415
include:
15-
- qt_version: '6.9.1'
16-
qt_version_major: '6'
17-
qt_modules: 'qtmultimedia qtserialport'
16+
- qt_version: '6.9.1'
17+
qt_version_major: '6'
18+
qt_modules: 'qtmultimedia qtserialport'
19+
20+
- os: 'windows-2025'
21+
compiler: 'clang'
22+
cmake_additional_param: '-T ClangCL'
23+
24+
- os: 'ubuntu-24.04'
25+
compiler: 'clang'
26+
cmake_additional_param: '-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++'
27+
28+
exclude:
29+
- os: 'macos-13'
30+
compiler: 'clang'
31+
# Excluded because macos default toolset is already clang
1832

1933
steps:
2034
- uses: actions/checkout@v4
@@ -44,7 +58,7 @@ jobs:
4458
cd Arduino-Source/SerialPrograms
4559
mkdir bin
4660
cd bin
47-
cmake .. -DQT_MAJOR:STRING=${{ matrix.qt_version_major }}
61+
cmake .. -DQT_MAJOR:STRING=${{ matrix.qt_version_major }} ${{ matrix.cmake_additional_param }}
4862
cmake --build . --config Release --parallel 10
4963
- name: Copy resources
5064
if: startsWith(matrix.os, 'windows')

ClientSource/Connection/SerialConnectionWinAPI.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class SerialConnection : public StreamConnection{
4444
throw ConnectionException(nullptr, "Unable to open serial connection (" + name + "). Error = " + std::to_string(error));
4545
}
4646

47-
DCB serial_params{0};
47+
DCB serial_params{};
4848
serial_params.DCBlength = sizeof(serial_params);
4949

5050
if (!GetCommState(m_handle, &serial_params)){
@@ -67,7 +67,7 @@ class SerialConnection : public StreamConnection{
6767
}
6868

6969
#if 1
70-
COMMTIMEOUTS timeouts{0};
70+
COMMTIMEOUTS timeouts{};
7171
if (!GetCommTimeouts(m_handle, &timeouts)){
7272
DWORD error = GetLastError();
7373
CloseHandle(m_handle);

SerialPrograms/CMakeLists.txt

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2418,7 +2418,7 @@ if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../../Internal/SerialPrograms/Internal0.
24182418
endif()
24192419

24202420
#extract opencv_world4110d.dll from archive on Windows Debug builds
2421-
if (MSVC)
2421+
if (WIN32)
24222422
file(ARCHIVE_EXTRACT
24232423
INPUT ${CMAKE_CURRENT_SOURCE_DIR}/../3rdPartyBinaries/opencv_world4110d.zip
24242424
DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/../3rdPartyBinaries/
@@ -2433,7 +2433,7 @@ target_link_directories(SerialPrograms PRIVATE ../3rdPartyBinaries/)
24332433

24342434

24352435

2436-
if (MSVC)
2436+
if (WIN32)
24372437
add_library(OpenCV_lib IMPORTED UNKNOWN)
24382438
target_include_directories(SerialPrograms SYSTEM PRIVATE ../3rdParty/opencv-4.11.0/)
24392439
set_target_properties(OpenCV_lib PROPERTIES
@@ -2505,6 +2505,15 @@ if (MSVC)
25052505
set(ARCH_FLAGS_17_Skylake /arch:AVX512)
25062506
set(ARCH_FLAGS_19_IceLake /arch:AVX512)
25072507

2508+
if(CMAKE_GENERATOR_TOOLSET MATCHES "ClangCL")
2509+
target_compile_options(SerialPrograms PRIVATE -Wno-unused-function)
2510+
target_compile_options(SerialPrograms PRIVATE -march=nehalem)
2511+
set(ARCH_FLAGS_09_Nehalem -march=nehalem)
2512+
set(ARCH_FLAGS_13_Haswell -march=haswell)
2513+
set(ARCH_FLAGS_17_Skylake -march=skylake-avx512)
2514+
set(ARCH_FLAGS_19_IceLake -march=icelake-client)
2515+
endif()
2516+
25082517
# Run-time ISA dispatching
25092518
target_compile_definitions(SerialPrograms PRIVATE PA_AutoDispatch_x64_08_Nehalem)
25102519
target_compile_definitions(SerialPrograms PRIVATE PA_AutoDispatch_x64_13_Haswell)
@@ -2619,7 +2628,7 @@ else() # macOS and Linux
26192628

26202629
else()
26212630
# Intel CPU
2622-
target_compile_options(SerialPrograms PRIVATE -msse4.2)
2631+
target_compile_options(SerialPrograms PRIVATE -march=nehalem)
26232632
set(ARCH_FLAGS_09_Nehalem -march=nehalem)
26242633
set(ARCH_FLAGS_13_Haswell -march=haswell)
26252634
set(ARCH_FLAGS_17_Skylake -march=skylake-avx512)

SerialPrograms/Source/NintendoSwitch/DevPrograms/TestProgramSwitch.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ class TestProgram : public MultiSwitchProgramInstance, public ButtonListener{
7373
StringOption IMAGE_PATH;
7474

7575
StaticTextOption STATIC_TEXT;
76-
BoxFloatOption BOX;
7776

7877

7978
// PokemonSV::SinglesAIOption battle_AI;

SerialPrograms/Source/PokemonLA/Inference/Map/PokemonLA_PokemonMapSpriteReader.cpp

Lines changed: 12 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -86,18 +86,18 @@ FeatureType feature_distance(const FeatureVector& a, const FeatureVector& b){
8686
return sum;
8787
}
8888

89-
std::string feature_to_str(const FeatureVector& a){
90-
std::ostringstream os;
91-
os << "[";
92-
for(size_t i = 0; i < a.size(); i++){
93-
if (i != 0){
94-
os << ", ";
95-
}
96-
os << a[i];
97-
}
98-
os << "]";
99-
return os.str();
100-
}
89+
//std::string feature_to_str(const FeatureVector& a){
90+
// std::ostringstream os;
91+
// os << "[";
92+
// for(size_t i = 0; i < a.size(); i++){
93+
// if (i != 0){
94+
// os << ", ";
95+
// }
96+
// os << a[i];
97+
// }
98+
// os << "]";
99+
// return os.str();
100+
//}
101101

102102
void run_Sobel_gradient_filter(const ImageViewRGB32& image, std::function<void(size_t x, size_t y, int sum_x[3], int sum_y[3])> process_gradient){
103103
const size_t width = image.width();
@@ -275,47 +275,6 @@ ImageRGB32 compute_image_gradient(const ImageViewRGB32& image){
275275
return result;
276276
}
277277

278-
FeatureVector compute_gradient_histogram(const ImageViewRGB32& image){
279-
const int num_angle_divisions = 8;
280-
double division_angle = 2. * M_PI / num_angle_divisions;
281-
double inverse_division_angle = 1.0 / division_angle;
282-
283-
std::array<int, num_angle_divisions> bin = {0};
284-
285-
int num_grad = 0;
286-
287-
run_Sobel_gradient_filter(image, [&](size_t x, size_t y, int sum_x[3], int sum_y[3]){
288-
int gx = sum_x[0] + sum_x[1] + sum_x[2];
289-
int gy = sum_y[0] + sum_y[1] + sum_y[2];
290-
if (gx*gx + gy*gy <= 2000){
291-
return;
292-
}
293-
num_grad++;
294-
295-
// if (count == 0){
296-
// // cout << "gxy " << sum_x[0] << " " << sum_x[1] << " " << sum_x[2] << ", " <<
297-
// // sum_y[0] << " " << sum_y[1] << " " << sum_y[2] << endl;
298-
// int gxc = std::min(std::abs(gx), 255);
299-
// int gyc = std::min(std::abs(gy), 255);
300-
301-
// output_image->setPixelColor(x, y, QColor(gxc, gyc, 0));
302-
// }
303-
304-
double angle = std::atan2(gy, gx); // range in -pi, pi
305-
int bin_idx = int((angle + M_PI) * inverse_division_angle);
306-
// clamp bin to [0, 11]
307-
bin_idx = std::min(std::max(bin_idx, 0), num_angle_divisions-1);
308-
bin[bin_idx]++;
309-
});
310-
311-
FeatureVector result(num_angle_divisions);
312-
for(size_t i = 0; i < num_angle_divisions; i++){
313-
result[i] = bin[i] / (FeatureType)num_grad;
314-
}
315-
316-
return result;
317-
}
318-
319278
} // end anonymous namespace
320279

321280
FeatureVector compute_feature(const ImageViewRGB32& input_image){

SerialPrograms/Source/PokemonSwSh/MaxLair/Options/PokemonSwSh_MaxLair_Options.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ extern const std::chrono::milliseconds INFERENCE_RATE;
2727
class HostingSwitch : public IntegerEnumDropdownOption{
2828
public:
2929
HostingSwitch();
30+
using ConfigOption::check_validity;
3031
std::string check_validity(size_t consoles) const;
3132
};
3233

0 commit comments

Comments
 (0)