Skip to content

Commit

Permalink
Merge 4fcc152 into f3739c4
Browse files Browse the repository at this point in the history
  • Loading branch information
pasdVn committed Jan 18, 2019
2 parents f3739c4 + 4fcc152 commit bac3aee
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/CHANGES.txt
Expand Up @@ -19,6 +19,10 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
- Improved support for VC14.1 and Visual Studio 2017, as well as arm and arm64 targets.
- Update TempFileMunge class to use PRINT_CMD_LINE_FUNC

From Tobias Herzog
- Enhance cpp scanner regex logic to detect if/elif expressions without whitespaces but
parenthesis like "#if(defined FOO)" or "#elif!(BAR)" correctly.

RELEASE 3.0.3 - Mon, 07 Jan 2019 20:05:22 -0400
NOTE: 3.0.2 release was dropped because there was a packaging bug. Please consider all 3.0.2
content.
Expand Down
9 changes: 6 additions & 3 deletions src/engine/SCons/cpp.py
Expand Up @@ -43,10 +43,13 @@
# that we want to fetch, using the regular expressions to which the lists
# of preprocessor directives map.
cpp_lines_dict = {
# Fetch the rest of a #if/#elif/#ifdef/#ifndef as one argument,
# Fetch the rest of a #if/#elif as one argument,
# with white space optional.
('if', 'elif') : '\s*(.+)',

# Fetch the rest of a #ifdef/#ifndef as one argument,
# separated from the keyword by white space.
('if', 'elif', 'ifdef', 'ifndef',)
: '\s+(.+)',
('ifdef', 'ifndef',): '\s+(.+)',

# Fetch the rest of a #import/#include/#include_next line as one
# argument, with white space optional.
Expand Down
107 changes: 105 additions & 2 deletions src/engine/SCons/cppTests.py
Expand Up @@ -363,6 +363,62 @@
"""


if_defined_no_space_input = """
#define DEFINED 0
#if(defined DEFINED)
#include "file47-yes"
#endif
#if(!defined DEFINED)
#include <file48-no>
#elif(!defined DEFINED)
#include <file49-no>
#else
#include <file50-yes>
#endif
#if!(defined DEFINED)
#include "file51-no"
#elif!(defined DEFINED)
#include <file52-no>
#else
#include "file53-yes"
#endif
"""

if_no_space_input = """
#define DEFINED 0
#if(DEFINED)
#include "file54-no"
#endif
#if!(DEFINED)
#include <file55-yes>
#elif!(DEFINED)
#include <file56-no>
#endif
#if(DEFINED)
#include "file57-no"
#elif(!DEFINED)
#include <file58-yes>
#endif
#if!( DEFINED)
#include "file59-yes"
#elif!( DEFINED)
#include <file60-no>
#endif
#if( DEFINED)
#include "file61-no"
#elif(! DEFINED)
#include <file62-yes>
#endif
"""


# pp_class = PreProcessor
# #pp_class = DumbPreProcessor
Expand Down Expand Up @@ -450,6 +506,19 @@ def test_ifndef(self):
result = self.cpp.process_contents(ifndef_input)
assert expect == result, (expect, result)

def test_if_defined_no_space(self):
"""Test #if(defined, i.e.without space but parenthesis"""
expect = self.if_defined_no_space_expect
result = self.cpp.process_contents(if_defined_no_space_input)
assert expect == result, (expect, result)

def test_if_no_space(self):
"""Test #if(, i.e. without space but parenthesis"""
expect = self.if_no_space_expect
result = self.cpp.process_contents(if_no_space_input)
assert expect == result, (expect, result)


class cppAllTestCase(cppTestCase):
def setUp(self):
self.cpp = self.cpp_class(current = ".",
Expand Down Expand Up @@ -541,7 +610,20 @@ class PreProcessorTestCase(cppAllTestCase):
('include', '"', 'file45-yes'),
('include', '<', 'file46-yes'),
]


if_defined_no_space_expect = [
('include', '"', 'file47-yes'),
('include', '<', 'file50-yes'),
('include', '"', 'file53-yes'),
]

if_no_space_expect = [
('include', '<', 'file55-yes'),
('include', '<', 'file58-yes'),
('include', '"', 'file59-yes'),
('include', '<', 'file62-yes'),
]

class DumbPreProcessorTestCase(cppAllTestCase):
cpp_class = cpp.DumbPreProcessor

Expand Down Expand Up @@ -654,14 +736,35 @@ class DumbPreProcessorTestCase(cppAllTestCase):
('include', '"', 'file7-yes')
]


ifndef_expect = [
('include', '"', 'file45-no'),
('include', '"', 'file45-yes'),
('include', '<', 'file46-yes'),
('include', '<', 'file46-no'),
]

if_defined_no_space_expect = [
('include', '"', 'file47-yes'),
('include', '<', 'file48-no'),
('include', '<', 'file49-no'),
('include', '<', 'file50-yes'),
('include', '"', 'file51-no'),
('include', '<', 'file52-no'),
('include', '"', 'file53-yes'),
]

if_no_space_expect = [
('include', '"', 'file54-no'),
('include', '<', 'file55-yes'),
('include', '<', 'file56-no'),
('include', '"', 'file57-no'),
('include', '<', 'file58-yes'),
('include', '"', 'file59-yes'),
('include', '<', 'file60-no'),
('include', '"', 'file61-no'),
('include', '<', 'file62-yes'),
]

import os
import re
import shutil
Expand Down
Empty file modified src/script/scons.py 100644 → 100755
Empty file.

0 comments on commit bac3aee

Please sign in to comment.