@@ -52,6 +52,11 @@ func (s *GCCPreprocRunner) Run(context map[string]interface{}) error {
52
52
return utils .WrapError (err )
53
53
}
54
54
55
+ if properties [constants .RECIPE_PREPROC_MACROS ] == constants .EMPTY_STRING {
56
+ //generate PREPROC_MACROS from RECIPE_CPP_PATTERN
57
+ properties [constants .RECIPE_PREPROC_MACROS ] = GeneratePreprocPatternFromCompile (properties [constants .RECIPE_CPP_PATTERN ])
58
+ }
59
+
55
60
verbose := context [constants .CTX_VERBOSE ].(bool )
56
61
logger := context [constants .CTX_LOGGER ].(i18n.Logger )
57
62
_ , err = builder_utils .ExecRecipe (properties , constants .RECIPE_PREPROC_MACROS , true , verbose , false , logger )
@@ -77,6 +82,12 @@ func (s *GCCPreprocRunnerForDiscoveringIncludes) Run(context map[string]interfac
77
82
78
83
verbose := context [constants .CTX_VERBOSE ].(bool )
79
84
logger := context [constants .CTX_LOGGER ].(i18n.Logger )
85
+
86
+ if properties [constants .RECIPE_PREPROC_MACROS ] == constants .EMPTY_STRING {
87
+ //generate PREPROC_MACROS from RECIPE_CPP_PATTERN
88
+ properties [constants .RECIPE_PREPROC_MACROS ] = GeneratePreprocPatternFromCompile (properties [constants .RECIPE_CPP_PATTERN ])
89
+ }
90
+
80
91
stderr , err := builder_utils .ExecRecipeCollectStdErr (properties , constants .RECIPE_PREPROC_MACROS , true , verbose , false , logger )
81
92
if err != nil {
82
93
return utils .WrapError (err )
@@ -112,3 +123,12 @@ func prepareGCCPreprocRecipeProperties(context map[string]interface{}, sourceFil
112
123
113
124
return properties , targetFilePath , nil
114
125
}
126
+
127
+ func GeneratePreprocPatternFromCompile (compilePattern string ) string {
128
+ // add {preproc.macros.flags}
129
+ // replace "{object_file}" with "{preprocessed_file_path}"
130
+ returnString := compilePattern
131
+ returnString = strings .Replace (returnString , "{compiler.cpp.flags}" , "{compiler.cpp.flags} {preproc.macros.flags}" , 1 )
132
+ returnString = strings .Replace (returnString , "{object_file}" , "{preprocessed_file_path}" , 1 )
133
+ return returnString
134
+ }
0 commit comments