Skip to content

Commit 98b5f70

Browse files
committed
Modify the format of content_wxs_source.txt #172
1 parent adce02e commit 98b5f70

File tree

3 files changed

+32
-39
lines changed

3 files changed

+32
-39
lines changed

setup/installer/copy_libimage_files.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,25 @@ def _list_files(source_path: pathlib.Path) -> List[Tuple[pathlib.Path, pathlib.P
3232
with source_path.open(mode="r", encoding="UTF-8") as stream:
3333
for line in stream:
3434
matched: Optional[re.Match[str]] = re.match(
35-
"^([^ ]+)[ ]+([^ ]+)[ ]+([^ ]+)[ ]+([^ ]+)[ ]+([^ ]+)", line
35+
"^([^ ]+)[ ]+([^ ]+)[ ]+([^ ]+)[ ]+([^ ]+)[ ]+([^ ]+)[ ]+([^ ]+)", line
3636
)
3737
if not matched:
3838
continue
39-
feature: str = matched.group(1)
40-
source_directory = pathlib.Path(matched.group(2))
41-
source_path = pathlib.Path(matched.group(3))
42-
destination = pathlib.Path(matched.group(4))
43-
if (
44-
feature != "include"
45-
and feature != "lib.Release.Win32"
46-
and feature != "lib.Release.x64"
47-
):
48-
continue
49-
files.append(
50-
(source_directory / source_path, (destination / source_path).parent)
51-
)
39+
kind: str = matched.group(1)
40+
if kind == "file":
41+
feature: str = matched.group(2)
42+
source_directory = pathlib.Path(matched.group(3))
43+
source_path = pathlib.Path(matched.group(4))
44+
destination = pathlib.Path(matched.group(5))
45+
if (
46+
feature != "include"
47+
and feature != "lib.Release.Win32"
48+
and feature != "lib.Release.x64"
49+
):
50+
continue
51+
files.append(
52+
(source_directory / source_path, (destination / source_path).parent)
53+
)
5254
return files
5355

5456

setup/installer/generate_content_wxs.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def __init__(self, id: str, name: str, level: int):
7171
self.children: Dict[str, _DestinationDirectory] = {}
7272
self.files = []
7373

74-
def add(
74+
def add_file(
7575
self, path: pathlib.Path, feature: str, guid: str, source_path: pathlib.Path
7676
) -> None:
7777
if len(path.parents) > 1:
@@ -83,7 +83,7 @@ def add(
8383
child_id, child_name, self.level + 1
8484
)
8585
grandchild_path = pathlib.Path(str(path)[len(child_name) + 1 :])
86-
self.children[child_name].add(grandchild_path, feature, guid, source_path)
86+
self.children[child_name].add_file(grandchild_path, feature, guid, source_path)
8787
else:
8888
file_name: str = str(path)
8989
file_id: str = self.id + "." + file_name
@@ -97,18 +97,22 @@ def _build_destination_tree(source_path: pathlib.Path) -> _DestinationDirectory:
9797
for line in stream:
9898
line = line.rstrip("\r\n")
9999
matched: Optional[re.Match[str]] = re.match(
100-
"^([^ ]+)[ ]+([^ ]+)[ ]+([^ ]+)[ ]+([^ ]+)[ ]+([^ ]+)", line
100+
"^([^ ]+)[ ]+([^ ]+)[ ]+([^ ]+)[ ]+([^ ]+)[ ]+([^ ]+)[ ]+([^ ]+)", line
101101
)
102102
if not matched:
103103
continue
104-
feature: str = matched.group(1)
105-
source_directory = pathlib.Path(matched.group(2))
106-
source_path = pathlib.Path(matched.group(3))
107-
destination = pathlib.Path(matched.group(4))
108-
guid = matched.group(5)
109-
destination_tree.add(
110-
destination / source_path, feature, guid, source_directory / source_path
111-
)
104+
kind: str = matched.group(1)
105+
if kind == "file":
106+
feature: str = matched.group(2)
107+
source_directory = pathlib.Path(matched.group(3))
108+
source_path = pathlib.Path(matched.group(4))
109+
destination = pathlib.Path(matched.group(5))
110+
guid = matched.group(6)
111+
destination_tree.add_file(
112+
destination / source_path, feature, guid, source_directory / source_path
113+
)
114+
else:
115+
raise "error: " + kind
112116
return destination_tree
113117

114118

setup/installer/generate_content_wxs_source.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def _make_content_wxs_source(
106106
continue
107107
extended_file_name: str = extended[len(source_directory) + 1 :]
108108
print(
109-
"{} {} {} {} {}".format(
109+
"file {} {} {} {} {}".format(
110110
wildcard[0],
111111
source_directory,
112112
extended_file_name,
@@ -119,18 +119,5 @@ def _make_content_wxs_source(
119119
)
120120

121121

122-
def _remove_solution_path(
123-
path: pathlib.Path, solution_path: pathlib.Path
124-
) -> pathlib.Path:
125-
path_str = str(path)
126-
solution_path_str = str(solution_path)
127-
if path_str.find(solution_path_str) != 0:
128-
return path
129-
removed = path_str[len(solution_path_str) :]
130-
if len(solution_path_str) > 0 and removed[0] == "\\":
131-
removed = removed[1:]
132-
return pathlib.Path(removed)
133-
134-
135122
if __name__ == "__main__":
136123
main(sys.argv[1:])

0 commit comments

Comments
 (0)