12 listopada 2013

include-what-you-use, podejście drugie

W sierpniu include-what-you-use doczekał się aktualizacji, a ja postanowiłem podjąć kolejną próbę kompilacji tego narzędzia. Wszystko wykonałem jak za ostatnim razem. Tym razem zaczęło działać! Dodatkowo zapisałem zmiany w llvm/tools/clang/tools/CMakeLists.txt ...
add_subdirectory(diagtool)
add_subdirectory(driver)
add_subdirectory(include-what-you-use)
if(CLANG_ENABLE_REWRITER)
  add_subdirectory(clang-format)
endif()

if(CLANG_ENABLE_ARCMT)
  add_subdirectory(libclang)
  add_subdirectory(c-index-test)
  add_subdirectory(arcmt-test)
  add_subdirectory(c-arcmt-test)
endif()
if(CLANG_ENABLE_STATIC_ANALYZER)
  add_subdirectory(clang-check)
endif()

# We support checking out the clang-tools-extra repository into the 'extra' ...
add_llvm_external_project(clang-tools-extra extra)
... oraz llvm/tools/clang/tools/Makefile
CLANG_LEVEL := ..

include $(CLANG_LEVEL)/../../Makefile.config

DIRS := include-what-you-use
PARALLEL_DIRS := driver diagtool

ifeq ($(ENABLE_CLANG_REWRITER),1)
  PARALLEL_DIRS += clang-format
endif

ifeq ($(ENABLE_CLANG_STATIC_ANALYZER), 1)
  PARALLEL_DIRS += clang-check
endif

ifeq ($(ENABLE_CLANG_ARCMT), 1)
  DIRS += libclang c-index-test c-arcmt-test
  PARALLEL_DIRS += arcmt-test
endif

# Recurse into the extra repository of tools if present.
OPTIONAL_PARALLEL_DIRS := extra

ifeq ($(BUILD_CLANG_ONLY),YES)
  DIRS := libclang c-index-test include-what-you-use
  PARALLEL_DIRS := driver
  OPTIONAL_PARALLEL_DIRS :=
endif

include $(CLANG_LEVEL)/Makefile
Poniżej plik, z którym eksperymentowałem.
#include <iostream>
#include <cstring>
#include <stdio.h>
#include <boost/optional.hpp>

using namespace std;

int main()
{
    cout << "Hello World!" << endl;
    return 0;
}
Niestety nie udało mi się zmusić CMake, aby wygenerował dla mnie odpowiedni plik Makefile z ustawionym include-what-you-use jako kompilator.
Najpierw próbowałem ustawić CMAKE_CXX_COMPILER w CMakeLists.txt (set dla CMAKE_CXX_COMPILER musi znaleźć się przed project!). Trzeba było też wyczyścić cały projekt (został kod i CMakeLists.txt) i zrestartować QtCreator-a, żeby pojawił się jakiś efekt. CMake poskarżył się tylko, że tym się nie da kompilować.
set(CMAKE_CXX_COMPILER "~/poligon/build/Debug+Asserts/bin/include-what-you-use")
project(include_test)
cmake_minimum_required(VERSION 2.8)
aux_source_directory(. SRC_LIST)
add_executable(${PROJECT_NAME} ${SRC_LIST})
Drugie podejście z linii komend, efekt niestety taki sam.
cmake CMakeLists.txt \
  -DCMAKE_CXX_COMPILER="~/poligon/build/Debug+Asserts/bin/include-what-you-use"
Skończyło się na własnej wersji Makefile.
make -k CXX=~/poligon/build/Debug+Asserts/bin/include-what-you-use
A oto wynik.
main.cpp should add these lines:

main.cpp should remove these lines:
- #include <stdio.h>  // lines 3-3
- #include <boost/optional.hpp>  // lines 4-4
- #include <cstring>  // lines 2-2

The full include-list for main.cpp:
#include <iostream>                     // for operator<<, basic_ostream, etc
---
make: *** [main] Error 1

Brak komentarzy:

Prześlij komentarz