Skip to content

Commit

Permalink
Supported to specific header directories. [unverified]
Browse files Browse the repository at this point in the history
  • Loading branch information
dougpuob committed Mar 31, 2020
1 parent 6043c8a commit 4093df3
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion script/build-pack-win32.cmd
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@ECHO OFF

IF EXIST release (RD /S /Q release)
IF EXIST release (DIR /S /Q release/*)
python cppnamelint.py bldgpack .. .\release

ECHO.
Expand Down
11 changes: 4 additions & 7 deletions script/cppnamelint.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def make_cmd_table():
cmd_check.add_argument('src' , help='Input source code file')
cmd_check.add_argument('-cfg' , required=False , help="Config file path")
cmd_check.add_argument('-json' , required=False , help="Json result output file path")
cmd_check.add_argument('-inc' , required=False , help="<dir1:dir2:...>")
cmd_check.add_argument('-inc' , action='append' , help='None or more include directory. (-inc Dir1 -inc Dir2 ...)', required=False)

cmd_fmt = subparsers.add_parser(define_cmd_format, help="format cmd")
cmd_fmt.add_argument('projdir' , help='Project root directory(location of .clangformat).')
Expand Down Expand Up @@ -216,8 +216,8 @@ def convert_py_args_to_exe_args(py_args) -> str:
specific_cmd_args = specific_cmd_args + ' -jsonout ' + py_args.json

if py_args.inc:
if len(py_args.inc) > 0:
specific_cmd_args = specific_cmd_args + ' -includes ' + '<' + ':'.join(input_inc_list) + '>'
for inc in py_args.inc:
specific_cmd_args = specific_cmd_args + ' -include ' + inc

final_cmd_str = specific_cmd_args + common_args

Expand Down Expand Up @@ -351,10 +351,7 @@ def run_pack(file_name:str, root_dir:str, output_dir: str) -> int:
if '' == found_generated_binary:
return -3

if os.path.exists(output_dir):
shutil.rmtree(output_dir)
os.mkdir(output_dir)
else:
if not os.path.exists(output_dir):
os.mkdir(output_dir)


Expand Down
7 changes: 4 additions & 3 deletions source/CommandLine.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ static cl::opt<string> CheckOutputJson("jsonout", cl::desc("Generate result to a
cl::value_desc("FileName"), cl::cat(CppNameLintCategory),
cl::sub(CheckSubcommand));

static cl::opt<string> ChkIncludes("includes", cl::desc("Specific header folers."),
cl::value_desc("<Dir1:Dir2:...>"), cl::cat(CppNameLintCategory),
cl::sub(CheckSubcommand));
static cl::list<string> CheckIncludes("include", cl::desc("Specific header folers."),
cl::value_desc("-include Dir1 -include Dir2 ..."),
cl::ZeroOrMore, cl::cat(CppNameLintCategory),
cl::sub(CheckSubcommand));

//==-----------------------------------------------------------------------
// SubCommand: test
Expand Down
10 changes: 6 additions & 4 deletions source/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,10 @@ int RunCheck(namelint::MemoBoard &Memo) {
int iRet = 0;

string OutputJson = CheckOutputJson;
vector<string> InputIncs;

Memo.File.Source = CheckInputSrc;
Memo.File.Config = CheckInputConfig;
Memo.Dir.Includes = InputIncs;
Memo.Dir.Includes = CheckIncludes;

if (OutputJson.length() == 0) {
OutputJson = "cppnamelint.json";
Expand Down Expand Up @@ -75,8 +74,11 @@ int RunCheck(namelint::MemoBoard &Memo) {
//
vector<string> SingleFileInList = {Memo.File.Source};
ClangTool Tool(*Compilations, SingleFileInList);
// Tool.appendArgumentsAdjuster(getInsertArgumentAdjuster("--I./",
// ArgumentInsertPosition::BEGIN));
for (auto inc : Memo.Dir.Includes) {
auto arg = "--I" + inc;
Tool.appendArgumentsAdjuster(
getInsertArgumentAdjuster(arg.c_str(), ArgumentInsertPosition::BEGIN));
}
// Tool.appendArgumentsAdjuster(
// getInsertArgumentAdjuster("-v", ArgumentInsertPosition::BEGIN));
Tool.appendArgumentsAdjuster(
Expand Down

0 comments on commit 4093df3

Please sign in to comment.