Skip to content

Commit

Permalink
Update devcontainer with newer clang and IWYU. Ran IWYU
Browse files Browse the repository at this point in the history
  • Loading branch information
Dannyj1 committed Dec 1, 2024
1 parent 8a42f30 commit 4872019
Show file tree
Hide file tree
Showing 15 changed files with 57 additions and 42 deletions.
22 changes: 18 additions & 4 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,21 @@ FROM mcr.microsoft.com/devcontainers/cpp:1-debian-12
ENV CC=clang
ENV CXX=clang++
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt install lsb-release wget software-properties-common gnupg -y \
&& bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" \
&& update-alternatives --install /usr/bin/cc cc /usr/bin/clang 100 \
&& update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++ 100
&& apt install lsb-release wget software-properties-common gnupg git -y \
&& wget https://apt.llvm.org/llvm.sh \
&& chmod +x llvm.sh \
&& ./llvm.sh 18 \
&& apt install llvm-18-dev libclang-18-dev clang-18 -y \
&& update-alternatives --install /usr/bin/cc cc /usr/bin/clang-18 100 \
&& update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++-18 100 \
&& update-alternatives --install /usr/bin/clang clang /usr/bin/clang-18 100 \
&& update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-18 100

RUN git clone https://github.com/include-what-you-use/include-what-you-use.git
WORKDIR include-what-you-use
RUN git checkout clang_18
WORKDIR ..
RUN mkdir build && cd build
RUN cmake -G "Unix Makefiles" -DCMAKE_PREFIX_PATH=/usr/lib/llvm-18 ./include-what-you-use
RUN make -j4
RUN make install
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ if (ENABLE_IWYU)

if (IWYU_PATH)
set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE "${IWYU_PATH}")
set_property(TARGET Zagreus PROPERTY CXX_INCLUDE_WHAT_YOU_USE "${IWYU_PATH}")
set_property(TARGET Zagreus PROPERTY CXX_INCLUDE_WHAT_YOU_USE "${IWYU_PATH};-Xiwyu;--error;-Xiwyu;--no_comments;-Xiwyu;--cxx17ns;-Xiwyu;--no_fwd_decls")
message(STATUS "IWYU found and enabled: ${IWYU_PATH}")
else ()
message(WARNING "IWYU requested but not found. Please install IWYU or disable ENABLE_IWYU.")
Expand Down
1 change: 1 addition & 0 deletions src/bitboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ This file is part of Zagreus.
*/

#include "bitboard.h"
#include <array>
#include "magics.h"

namespace Zagreus {
Expand Down
2 changes: 1 addition & 1 deletion src/bitboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

#pragma once

#include <cassert>
#include <cstdint>
#include <utility>

#include "bitwise.h"
#include "constants.h"
Expand Down
4 changes: 1 addition & 3 deletions src/board.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@
*/

#include "board.h"

#include <ctype.h>
#include <iostream>
#include <ostream>
#include <string_view>

#include "bitwise.h"
#include "pcg_random.hpp"

Expand Down
11 changes: 5 additions & 6 deletions src/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,16 @@

#pragma once

#include <cstdint>
#include <string_view>

#include <algorithm>
#include <array>
#include <cassert>
#include <utility>

#include <cstdint>
#include <string_view>
#include "bitboard.h"
#include "move.h"
#include "bitwise.h"
#include "constants.h"
#include "move.h"
#include "types.h"

namespace Zagreus {
/**
Expand Down
3 changes: 2 additions & 1 deletion src/eval.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
*/

#include "eval.h"

#include "constants.h"
#include "eval_features.h"
#include "types.h"

namespace Zagreus {
/**
Expand Down
5 changes: 3 additions & 2 deletions src/magics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@
*/

#include "magics.h"

#include <chrono>
#include <bits/chrono.h>
#include <stdio.h>
#include <cstdint>
#include <iostream>
#include <limits>
#include <random>

// Code for magic generation https://www.chessprogramming.org/Looking_for_Magics
Expand Down
5 changes: 3 additions & 2 deletions src/move.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@

#pragma once

#include <cassert>
#include <cstdint>
#include <array>
#include <iostream>
#include <string>

#include <string_view>
#include "constants.h"
#include "types.h"

Expand Down
10 changes: 6 additions & 4 deletions src/move_gen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,16 @@
along with Zagreus. If not, see <https://www.gnu.org/licenses/>.
*/

#include <array>

#include "move_gen.h"
#include <cassert>
#include <array>
#include <initializer_list>
#include "bitboard.h"
#include "bitwise.h"
#include "board.h"
#include "types.h"
#include "bitboard.h"
#include "constants.h"
#include "move.h"
#include "types.h"

namespace Zagreus {

Expand Down
3 changes: 0 additions & 3 deletions src/move_gen.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,10 @@
#pragma once

#include <cstdint>

#include "board.h"
#include "move.h"
#include "types.h"

enum PieceColor : uint8_t;

namespace Zagreus {
enum GenerationType : uint8_t {
ALL,
Expand Down
3 changes: 0 additions & 3 deletions src/move_picker.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@
#pragma once

#include <array>

#include "constants.h"
#include "move.h"
#include "types.h"

namespace Zagreus {
// TODO: Implement efficient sorting by score, after implementing score.
Expand Down
6 changes: 4 additions & 2 deletions src/perft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@
*/

#include "perft.h"

#include <cassert>
#include <array>
#include <iostream>

#include <string>
#include "move.h"
#include "move_gen.h"
#include "types.h"

namespace Zagreus {
/**
Expand Down
6 changes: 3 additions & 3 deletions src/search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
along with Zagreus. If not, see <https://www.gnu.org/licenses/>.
*/

#include <limits>

#include "search.h"

#include <limits>
#include "board.h"
#include "constants.h"
#include "eval.h"
#include "move.h"
#include "move_gen.h"
#include "move_picker.h"
#include "types.h"

namespace Zagreus {
Move search(Board& board) {
Expand Down
16 changes: 9 additions & 7 deletions src/uci.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,21 @@
along with Zagreus. If not, see <https://www.gnu.org/licenses/>.
*/

#include <chrono>
#include "uci.h"
#include <bits/chrono.h>
#include <stddef.h>
#include <stdint.h>
#include <algorithm>
#include <cctype>
#include <iostream>
#include <sstream>
#include <stdexcept>
#include <string>
#include <cctype>
#include <thread>

#include "magics.h"
#include "uci.h"

#include "board.h"
#include "bitboard.h"
#include "board.h"
#include "magics.h"
#include "move.h"
#include "perft.h"

namespace Zagreus {
Expand Down

0 comments on commit 4872019

Please sign in to comment.