@@ -52,6 +52,11 @@ func (s *GCCPreprocRunner) Run(context map[string]interface{}) error {
5252 return utils .WrapError (err )
5353 }
5454
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+
5560 verbose := context [constants .CTX_VERBOSE ].(bool )
5661 logger := context [constants .CTX_LOGGER ].(i18n.Logger )
5762 _ , 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
7782
7883 verbose := context [constants .CTX_VERBOSE ].(bool )
7984 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+
8091 stderr , err := builder_utils .ExecRecipeCollectStdErr (properties , constants .RECIPE_PREPROC_MACROS , true , verbose , false , logger )
8192 if err != nil {
8293 return utils .WrapError (err )
@@ -112,3 +123,12 @@ func prepareGCCPreprocRecipeProperties(context map[string]interface{}, sourceFil
112123
113124 return properties , targetFilePath , nil
114125}
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