Skip parcel from include dir if already processed

The parcel from the first source or include dir takes precedence.


Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/9422dcb8
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/9422dcb8
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/9422dcb8

Branch: refs/heads/master
Commit: 9422dcb837946d2a47719cf55f5f0a7b6b11bd2e
Parents: 64386ab
Author: Nick Wellnhofer <[email protected]>
Authored: Fri Aug 1 13:47:46 2014 +0200
Committer: Nick Wellnhofer <[email protected]>
Committed: Tue Aug 5 11:56:01 2014 +0200

----------------------------------------------------------------------
 compiler/src/CFCHierarchy.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/9422dcb8/compiler/src/CFCHierarchy.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCHierarchy.c b/compiler/src/CFCHierarchy.c
index 9cc1999..e336b29 100644
--- a/compiler/src/CFCHierarchy.c
+++ b/compiler/src/CFCHierarchy.c
@@ -273,17 +273,15 @@ S_parse_parcel_files(const char *source_dir, int 
is_included) {
         const char *name = CFCParcel_get_name(parcel);
         CFCParcel *existing = CFCParcel_fetch(name);
         if (existing) {
-            if (!CFCParcel_equals(parcel, existing)) {
-                if (is_included && !CFCParcel_included(existing)) {
-                    // Allow clash between source and include dirs.
-                    CFCUtil_warn("Warning: Parcel %s from source dir takes "
-                                 "precedence over parcel from include dir",
-                                 name);
-                }
-                else {
-                    CFCUtil_die("Incompatible parcel '%s' already registered",
-                                CFCParcel_get_name(parcel));
-                }
+            const char *existing_source_dir
+                = CFCParcel_get_source_dir(existing);
+            CFCUTIL_NULL_CHECK(existing_source_dir);
+            // Skip parcel if it's from an include dir and was already
+            // processed in another source or include dir.
+            if (!is_included || strcmp(source_dir, existing_source_dir) == 0) {
+                CFCUtil_die("Parcel '%s' defined twice in %s and %s",
+                            CFCParcel_get_name(parcel),
+                            CFCParcel_get_cfp_path(existing), path);
             }
         }
         else {

Reply via email to