logic: Added PCH support to CDB source groups (issue #311)
* added PCH Flags list and checkbox to reuse compiler flags and cdb flags to source group setup * added UI tests for C++ and CDB source groups
This commit is contained in:
+19
@@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
# get absolute path to parent directory of script
|
||||
MY_PATH=`dirname "$0"`
|
||||
if [[ "${MY_PATH}" != *\\* ]]
|
||||
then
|
||||
cd $MY_PATH
|
||||
MY_PATH=`pwd`
|
||||
fi
|
||||
MY_PATH="${MY_PATH//\\//}"
|
||||
|
||||
SRC_PATH=$MY_PATH/data
|
||||
WORKING_COPY_PATH=$MY_PATH/working_copy
|
||||
|
||||
mkdir -p $WORKING_COPY_PATH
|
||||
|
||||
cp -a $SRC_PATH/. $WORKING_COPY_PATH
|
||||
|
||||
echo "Setup Complete"
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
|
||||
# get absolute path to parent directory of script
|
||||
MY_PATH=`dirname "$0"`
|
||||
if [[ "${MY_PATH}" != *\\* ]]
|
||||
then
|
||||
cd $MY_PATH
|
||||
MY_PATH=`pwd`
|
||||
fi
|
||||
MY_PATH="${MY_PATH//\\//}"
|
||||
|
||||
WORKING_COPY_PATH=$MY_PATH/working_copy
|
||||
|
||||
rm -rf $WORKING_COPY_PATH
|
||||
|
||||
echo "Teardown Complete"
|
||||
@@ -0,0 +1,25 @@
|
||||
* Run "1_setup.sh"
|
||||
* Start up Sourcetrail
|
||||
* Click "New Project"
|
||||
* Enter a project name
|
||||
* Set "./working_copy" as project location
|
||||
* Click "Add Source Group"
|
||||
* Select "C++" -> Empty C++ Source Group"
|
||||
* Click "Next"
|
||||
* Click "Next"
|
||||
* Add "./src" to "Files & Directories to Index"
|
||||
* Add "**/Foo.h" to "Excluded Files & Directories"
|
||||
* Click "Next"
|
||||
* Click "Next"
|
||||
* Click "Next"
|
||||
* Add "-DCOMPILER_FLAG" to "Compiler Flags"
|
||||
* Add "./src/pch.h" to "Precompiled Header File"
|
||||
* Add "-DPCH_FLAG" to "Precompiled Header Flags"
|
||||
* Click "Next"
|
||||
* Click "Create"
|
||||
* Validate "All files" is the only option selectable
|
||||
* Click "Start"
|
||||
* Validate Project indexed without error
|
||||
* Click "OK"
|
||||
* Close Sourcetrail
|
||||
* Run "2_teardown.sh"
|
||||
@@ -0,0 +1,10 @@
|
||||
#ifndef FOO_H
|
||||
#define FOO_H
|
||||
|
||||
#include "FooBar.h"
|
||||
|
||||
class Bar : public FooBar
|
||||
{
|
||||
};
|
||||
|
||||
#endif // FOO_H
|
||||
@@ -0,0 +1,10 @@
|
||||
#ifndef BAR_H
|
||||
#define BAR_H
|
||||
|
||||
#include "FooBar.h"
|
||||
|
||||
class Foo : public FooBar
|
||||
{
|
||||
};
|
||||
|
||||
#endif // FOO_BAR_H
|
||||
@@ -0,0 +1,12 @@
|
||||
#ifndef FOO_BAR_H
|
||||
#define FOO_BAR_H
|
||||
|
||||
#ifdef COMPILER_FLAG
|
||||
|
||||
class FooBar
|
||||
{
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif // FOO_BAR_H
|
||||
@@ -0,0 +1,7 @@
|
||||
#include "pch.h"
|
||||
|
||||
void test()
|
||||
{
|
||||
Foo foo;
|
||||
Bar bar;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
|
||||
#ifdef PCH_FLAG
|
||||
|
||||
#include "Foo.h"
|
||||
#include "Bar.h"
|
||||
|
||||
#endif
|
||||
@@ -21,7 +21,7 @@ cp -a $SRC_PATH/. $WORKING_COPY_PATH
|
||||
echo "[" >> $CDB_PATH
|
||||
echo " {" >> $CDB_PATH
|
||||
echo " \"directory\": \"${WORKING_COPY_PATH}\"," >> $CDB_PATH
|
||||
echo " \"command\": \"clang-tool -fms-extensions -fms-compatibility -fms-compatibility-version=19 -isystem \\\"${WORKING_COPY_SRC_PATH}/include\\\" -D _DEBUG -D _MT -D _DLL -D WIN32 -D _WINDOWS -D BUILD_TYPE=\\\"\\\" -D QT_WIDGETS_LIB -D QT_GUI_LIB -D QT_CORE_LIB -D QT_NETWORK_LIB -D QT_WINEXTRAS_LIB -D QT_SVG_LIB -D CMAKE_INTDIR=\\\"Debug\\\" -D _MBCS -std=c++14 \\\"${WORKING_COPY_SRC_PATH}/main.cpp\\\"\"" >> $CDB_PATH
|
||||
echo " \"command\": \"clang-tool -fms-extensions -fms-compatibility -fms-compatibility-version=19 -isystem \\\"${WORKING_COPY_SRC_PATH}/include\\\" -D _DEBUG -D _MT -D _DLL -D WIN32 -D _WINDOWS -D BUILD_TYPE=\\\"\\\" -D QT_WIDGETS_LIB -D QT_GUI_LIB -D QT_CORE_LIB -D QT_NETWORK_LIB -D QT_WINEXTRAS_LIB -D QT_SVG_LIB -D CMAKE_INTDIR=\\\"Debug\\\" -D _MBCS -std=c++14 \\\"${WORKING_COPY_SRC_PATH}/main.cpp\\\"\"," >> $CDB_PATH
|
||||
echo " \"file\": \"${WORKING_COPY_SRC_PATH}/main.cpp\"" >> $CDB_PATH
|
||||
echo " }" >> $CDB_PATH
|
||||
echo "]" >> $CDB_PATH
|
||||
|
||||
Executable
+29
@@ -0,0 +1,29 @@
|
||||
#!/bin/bash
|
||||
|
||||
# get absolute path to parent directory of script
|
||||
MY_PATH=`dirname "$0"`
|
||||
if [[ "${MY_PATH}" != *\\* ]]
|
||||
then
|
||||
cd $MY_PATH
|
||||
MY_PATH=`pwd`
|
||||
fi
|
||||
MY_PATH="${MY_PATH//\\//}"
|
||||
|
||||
SRC_PATH=$MY_PATH/data
|
||||
WORKING_COPY_PATH=$MY_PATH/working_copy
|
||||
WORKING_COPY_SRC_PATH=$WORKING_COPY_PATH/src
|
||||
CDB_PATH=$WORKING_COPY_PATH/compile_commands.json
|
||||
|
||||
mkdir -p $WORKING_COPY_PATH
|
||||
|
||||
cp -a $SRC_PATH/. $WORKING_COPY_PATH
|
||||
|
||||
echo "[" >> $CDB_PATH
|
||||
echo " {" >> $CDB_PATH
|
||||
echo " \"directory\": \"${WORKING_COPY_PATH}\"," >> $CDB_PATH
|
||||
echo " \"command\": \"clang-tool -fms-extensions -fms-compatibility -fms-compatibility-version=19 -isystem \\\"${WORKING_COPY_SRC_PATH}/include\\\" -DCDB_FLAG -D _DEBUG -D _MT -D _DLL -D WIN32 -D _WINDOWS -D BUILD_TYPE=\\\"\\\" -D QT_WIDGETS_LIB -D QT_GUI_LIB -D QT_CORE_LIB -D QT_NETWORK_LIB -D QT_WINEXTRAS_LIB -D QT_SVG_LIB -D CMAKE_INTDIR=\\\"Debug\\\" -D _MBCS -std=c++14 \\\"${WORKING_COPY_SRC_PATH}/main.cpp\\\"\"," >> $CDB_PATH
|
||||
echo " \"file\": \"${WORKING_COPY_SRC_PATH}/main.cpp\"" >> $CDB_PATH
|
||||
echo " }" >> $CDB_PATH
|
||||
echo "]" >> $CDB_PATH
|
||||
|
||||
echo "Setup Complete"
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
|
||||
# get absolute path to parent directory of script
|
||||
MY_PATH=`dirname "$0"`
|
||||
if [[ "${MY_PATH}" != *\\* ]]
|
||||
then
|
||||
cd $MY_PATH
|
||||
MY_PATH=`pwd`
|
||||
fi
|
||||
MY_PATH="${MY_PATH//\\//}"
|
||||
|
||||
WORKING_COPY_PATH=$MY_PATH/working_copy
|
||||
|
||||
rm -rf $WORKING_COPY_PATH
|
||||
|
||||
echo "Teardown Complete"
|
||||
@@ -0,0 +1,26 @@
|
||||
* Run "1_setup.sh"
|
||||
* Start up Sourcetrail
|
||||
* Click "New Project"
|
||||
* Enter a project name
|
||||
* Set "./working_copy" as project location
|
||||
* Click "Add Source Group"
|
||||
* Select "C++" -> C/C++ from Compilation Database"
|
||||
* Click "Next"
|
||||
* Pick "compile_commands.json" at "Compilation Database"
|
||||
* Click "show source files" button
|
||||
* Validate "Source Files" list contains "src/main.cpp"
|
||||
* Click "OK"
|
||||
* Validate "Header Files & Directories to Index" contains "src" entry
|
||||
* Add "**/Foo.h" to "Excluded Files & Directories"
|
||||
* Click "Next"
|
||||
* Click "Next"
|
||||
* Add "-DCOMPILER_FLAG" to "Additional Compiler Flags"
|
||||
* Add "./src/pch.h" to "Precompiled Header File"
|
||||
* Add "-DPCH_FLAG" to "Precompiled Header Flags"
|
||||
* Click "Create"
|
||||
* Validate "All files" is the only option selectable
|
||||
* Click "Start"
|
||||
* Validate Project indexed without error
|
||||
* Click "OK"
|
||||
* Close Sourcetrail
|
||||
* Run "2_teardown.sh"
|
||||
@@ -0,0 +1,17 @@
|
||||
#ifndef FOO_H
|
||||
#define FOO_H
|
||||
|
||||
#include "FooBar.h"
|
||||
|
||||
#ifndef COMPILER_FLAG
|
||||
#error "COMPILER_FLAG not defined"
|
||||
#else
|
||||
|
||||
class Bar : public FooBar
|
||||
{
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#endif // FOO_H
|
||||
@@ -0,0 +1,14 @@
|
||||
#ifndef BAR_H
|
||||
#define BAR_H
|
||||
|
||||
#include "FooBar.h"
|
||||
|
||||
#ifndef CDB_FLAG
|
||||
#error "CDB_FLAG not defined"
|
||||
#endif
|
||||
|
||||
class Foo : public FooBar
|
||||
{
|
||||
};
|
||||
|
||||
#endif // FOO_BAR_H
|
||||
@@ -0,0 +1,8 @@
|
||||
#ifndef FOO_BAR_H
|
||||
#define FOO_BAR_H
|
||||
|
||||
class FooBar
|
||||
{
|
||||
};
|
||||
|
||||
#endif // FOO_BAR_H
|
||||
@@ -0,0 +1,8 @@
|
||||
#include "pch.h"
|
||||
|
||||
void test()
|
||||
{
|
||||
Foo foo;
|
||||
Bar bar;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
|
||||
#ifndef PCH_FLAG
|
||||
#error "PCH_FLAG not defined"
|
||||
#else
|
||||
|
||||
#include "Foo.h"
|
||||
#include "Bar.h"
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<config>
|
||||
<source_groups>
|
||||
<source_group_ffef4a06-185d-4b00-99b1-5c32b26cecf9>
|
||||
<build_file_path>
|
||||
<compilation_db_path>compile_commands.json</compilation_db_path>
|
||||
</build_file_path>
|
||||
<compiler_flags>
|
||||
<compiler_flag>-DCOMPILER_FLAG</compiler_flag>
|
||||
</compiler_flags>
|
||||
<indexed_header_paths>
|
||||
<indexed_header_path>src</indexed_header_path>
|
||||
</indexed_header_paths>
|
||||
<name>C/C++ from Compilation Database</name>
|
||||
<pch_flags>
|
||||
<pch_flag>-DPCH_FLAG</pch_flag>
|
||||
<use_cdb_flags>1</use_cdb_flags>
|
||||
<use_compiler_flags>1</use_compiler_flags>
|
||||
</pch_flags>
|
||||
<pch_input_file_path>src/pch.hpp</pch_input_file_path>
|
||||
<status>enabled</status>
|
||||
<type>C/C++ from Compilation Database</type>
|
||||
</source_group_ffef4a06-185d-4b00-99b1-5c32b26cecf9>
|
||||
</source_groups>
|
||||
<version>8</version>
|
||||
</config>
|
||||
@@ -0,0 +1,7 @@
|
||||
[
|
||||
{
|
||||
"directory": "/Users/ebsi/Documents/Coati/testing/project_setup/cxx_cdb_pch/working_copy",
|
||||
"command": "clang-tool -fms-extensions -fms-compatibility -fms-compatibility-version=19 -isystem \"/Users/ebsi/Documents/Coati/testing/project_setup/cxx_cdb_pch/working_copy/src/include\" -DCDB_FLAG -D _DEBUG -D _MT -D _DLL -D WIN32 -D _WINDOWS -D BUILD_TYPE=\"\" -D QT_WIDGETS_LIB -D QT_GUI_LIB -D QT_CORE_LIB -D QT_NETWORK_LIB -D QT_WINEXTRAS_LIB -D QT_SVG_LIB -D CMAKE_INTDIR=\"Debug\" -D _MBCS -std=c++14 \"/Users/ebsi/Documents/Coati/testing/project_setup/cxx_cdb_pch/working_copy/src/main.cpp\"",
|
||||
"file": "/Users/ebsi/Documents/Coati/testing/project_setup/cxx_cdb_pch/working_copy/src/main.cpp"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,17 @@
|
||||
#ifndef FOO_H
|
||||
#define FOO_H
|
||||
|
||||
#include "FooBar.h"
|
||||
|
||||
#ifndef COMPILER_FLAG
|
||||
#error "COMPILER_FLAG not defined"
|
||||
#else
|
||||
|
||||
class Bar : public FooBar
|
||||
{
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#endif // FOO_H
|
||||
@@ -0,0 +1,14 @@
|
||||
#ifndef BAR_H
|
||||
#define BAR_H
|
||||
|
||||
#include "FooBar.h"
|
||||
|
||||
#ifndef CDB_FLAG
|
||||
#error "CDB_FLAG not defined"
|
||||
#endif
|
||||
|
||||
class Foo : public FooBar
|
||||
{
|
||||
};
|
||||
|
||||
#endif // FOO_BAR_H
|
||||
@@ -0,0 +1,8 @@
|
||||
#ifndef FOO_BAR_H
|
||||
#define FOO_BAR_H
|
||||
|
||||
class FooBar
|
||||
{
|
||||
};
|
||||
|
||||
#endif // FOO_BAR_H
|
||||
@@ -0,0 +1,8 @@
|
||||
#include "pch.hpp"
|
||||
|
||||
void test()
|
||||
{
|
||||
Foo foo;
|
||||
Bar bar;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
|
||||
#ifndef PCH_FLAG
|
||||
#error "PCH_FLAG not defined"
|
||||
#else
|
||||
|
||||
#include "Foo.h"
|
||||
#include "Bar.h"
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user