casbin-async-django-orm-adapter 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- async_casbin_adapter/__init__.py +0 -0
- async_casbin_adapter/adapter.py +100 -0
- async_casbin_adapter/apps.py +24 -0
- async_casbin_adapter/enforcer.py +81 -0
- async_casbin_adapter/migrations/0001_initial.py +37 -0
- async_casbin_adapter/migrations/__init__.py +0 -0
- async_casbin_adapter/models.py +48 -0
- async_casbin_adapter/utils.py +25 -0
- casbin_async_django_orm_adapter-1.0.0.dist-info/METADATA +116 -0
- casbin_async_django_orm_adapter-1.0.0.dist-info/RECORD +74 -0
- casbin_async_django_orm_adapter-1.0.0.dist-info/WHEEL +5 -0
- casbin_async_django_orm_adapter-1.0.0.dist-info/licenses/LICENSE +201 -0
- casbin_async_django_orm_adapter-1.0.0.dist-info/top_level.txt +3 -0
- node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py +45 -0
- node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/MSVSNew.py +365 -0
- node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/MSVSProject.py +206 -0
- node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/MSVSSettings.py +1272 -0
- node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/MSVSSettings_test.py +1547 -0
- node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/MSVSToolFile.py +59 -0
- node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/MSVSUserFile.py +152 -0
- node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/MSVSUtil.py +270 -0
- node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/MSVSVersion.py +574 -0
- node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py +704 -0
- node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/common.py +709 -0
- node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/common_test.py +173 -0
- node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/easy_xml.py +169 -0
- node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/easy_xml_test.py +113 -0
- node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/flock_tool.py +55 -0
- node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/__init__.py +0 -0
- node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/analyzer.py +805 -0
- node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/android.py +1172 -0
- node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/cmake.py +1319 -0
- node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/compile_commands_json.py +128 -0
- node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/dump_dependency_json.py +104 -0
- node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/eclipse.py +462 -0
- node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/gypd.py +89 -0
- node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/gypsh.py +56 -0
- node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py +2745 -0
- node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs.py +3976 -0
- node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs_test.py +44 -0
- node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja.py +2965 -0
- node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja_test.py +67 -0
- node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/xcode.py +1391 -0
- node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/xcode_test.py +26 -0
- node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py +3112 -0
- node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input_test.py +99 -0
- node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/mac_tool.py +767 -0
- node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/msvs_emulation.py +1260 -0
- node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/ninja_syntax.py +174 -0
- node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/simple_copy.py +61 -0
- node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/win_tool.py +373 -0
- node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py +1939 -0
- node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation_test.py +54 -0
- node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_ninja.py +303 -0
- node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xcodeproj_file.py +3196 -0
- node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xml_fix.py +65 -0
- node_modules/npm/node_modules/node-gyp/gyp/pylib/packaging/__init__.py +15 -0
- node_modules/npm/node_modules/node-gyp/gyp/pylib/packaging/_elffile.py +108 -0
- node_modules/npm/node_modules/node-gyp/gyp/pylib/packaging/_manylinux.py +252 -0
- node_modules/npm/node_modules/node-gyp/gyp/pylib/packaging/_musllinux.py +83 -0
- node_modules/npm/node_modules/node-gyp/gyp/pylib/packaging/_parser.py +359 -0
- node_modules/npm/node_modules/node-gyp/gyp/pylib/packaging/_structures.py +61 -0
- node_modules/npm/node_modules/node-gyp/gyp/pylib/packaging/_tokenizer.py +192 -0
- node_modules/npm/node_modules/node-gyp/gyp/pylib/packaging/markers.py +252 -0
- node_modules/npm/node_modules/node-gyp/gyp/pylib/packaging/metadata.py +825 -0
- node_modules/npm/node_modules/node-gyp/gyp/pylib/packaging/py.typed +0 -0
- node_modules/npm/node_modules/node-gyp/gyp/pylib/packaging/requirements.py +90 -0
- node_modules/npm/node_modules/node-gyp/gyp/pylib/packaging/specifiers.py +1030 -0
- node_modules/npm/node_modules/node-gyp/gyp/pylib/packaging/tags.py +553 -0
- node_modules/npm/node_modules/node-gyp/gyp/pylib/packaging/utils.py +172 -0
- node_modules/npm/node_modules/node-gyp/gyp/pylib/packaging/version.py +563 -0
- node_modules/npm/node_modules/node-gyp/gyp/test_gyp.py +261 -0
- node_modules/semantic-release-pypi/dist/py/set_version.py +32 -0
- node_modules/semantic-release-pypi/dist/py/verify_setup.py +24 -0
@@ -0,0 +1,201 @@
|
|
1
|
+
Apache License
|
2
|
+
Version 2.0, January 2004
|
3
|
+
http://www.apache.org/licenses/
|
4
|
+
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6
|
+
|
7
|
+
1. Definitions.
|
8
|
+
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
11
|
+
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
13
|
+
the copyright owner that is granting the License.
|
14
|
+
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
16
|
+
other entities that control, are controlled by, or are under common
|
17
|
+
control with that entity. For the purposes of this definition,
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
19
|
+
direction or management of such entity, whether by contract or
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
22
|
+
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
24
|
+
exercising permissions granted by this License.
|
25
|
+
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
27
|
+
including but not limited to software source code, documentation
|
28
|
+
source, and configuration files.
|
29
|
+
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
31
|
+
transformation or translation of a Source form, including but
|
32
|
+
not limited to compiled object code, generated documentation,
|
33
|
+
and conversions to other media types.
|
34
|
+
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
36
|
+
Object form, made available under the License, as indicated by a
|
37
|
+
copyright notice that is included in or attached to the work
|
38
|
+
(an example is provided in the Appendix below).
|
39
|
+
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
46
|
+
the Work and Derivative Works thereof.
|
47
|
+
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
49
|
+
the original version of the Work and any modifications or additions
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
61
|
+
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
64
|
+
subsequently incorporated within the Work.
|
65
|
+
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
72
|
+
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78
|
+
where such license applies only to those patent claims licensable
|
79
|
+
by such Contributor that are necessarily infringed by their
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
82
|
+
institute patent litigation against any entity (including a
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
85
|
+
or contributory patent infringement, then any patent licenses
|
86
|
+
granted to You under this License for that Work shall terminate
|
87
|
+
as of the date such litigation is filed.
|
88
|
+
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
91
|
+
modifications, and in Source or Object form, provided that You
|
92
|
+
meet the following conditions:
|
93
|
+
|
94
|
+
(a) You must give any other recipients of the Work or
|
95
|
+
Derivative Works a copy of this License; and
|
96
|
+
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
98
|
+
stating that You changed the files; and
|
99
|
+
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
102
|
+
attribution notices from the Source form of the Work,
|
103
|
+
excluding those notices that do not pertain to any part of
|
104
|
+
the Derivative Works; and
|
105
|
+
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
108
|
+
include a readable copy of the attribution notices contained
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
111
|
+
of the following places: within a NOTICE text file distributed
|
112
|
+
as part of the Derivative Works; within the Source form or
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
114
|
+
within a display generated by the Derivative Works, if and
|
115
|
+
wherever such third-party notices normally appear. The contents
|
116
|
+
of the NOTICE file are for informational purposes only and
|
117
|
+
do not modify the License. You may add Your own attribution
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
120
|
+
that such additional attribution notices cannot be construed
|
121
|
+
as modifying the License.
|
122
|
+
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
124
|
+
may provide additional or different license terms and conditions
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
128
|
+
the conditions stated in this License.
|
129
|
+
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
133
|
+
this License, without any additional terms or conditions.
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
135
|
+
the terms of any separate license agreement you may have executed
|
136
|
+
with Licensor regarding such Contributions.
|
137
|
+
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
140
|
+
except as required for reasonable and customary use in describing the
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
142
|
+
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
152
|
+
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
158
|
+
incidental, or consequential damages of any character arising as a
|
159
|
+
result of this License or out of the use or inability to use the
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
162
|
+
other commercial damages or losses), even if such Contributor
|
163
|
+
has been advised of the possibility of such damages.
|
164
|
+
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
168
|
+
or other liability obligations and/or rights consistent with this
|
169
|
+
License. However, in accepting such obligations, You may act only
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
174
|
+
of your accepting any such warranty or additional liability.
|
175
|
+
|
176
|
+
END OF TERMS AND CONDITIONS
|
177
|
+
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
179
|
+
|
180
|
+
To apply the Apache License to your work, attach the following
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
182
|
+
replaced with your own identifying information. (Don't include
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
184
|
+
comment syntax for the file format. We also recommend that a
|
185
|
+
file or class name and description of purpose be included on the
|
186
|
+
same "printed page" as the copyright notice for easier
|
187
|
+
identification within third-party archives.
|
188
|
+
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
190
|
+
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
192
|
+
you may not use this file except in compliance with the License.
|
193
|
+
You may obtain a copy of the License at
|
194
|
+
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
196
|
+
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
200
|
+
See the License for the specific language governing permissions and
|
201
|
+
limitations under the License.
|
@@ -0,0 +1,45 @@
|
|
1
|
+
#!/usr/bin/env python3
|
2
|
+
|
3
|
+
# Copyright (c) 2009 Google Inc. All rights reserved.
|
4
|
+
# Use of this source code is governed by a BSD-style license that can be
|
5
|
+
# found in the LICENSE file.
|
6
|
+
|
7
|
+
import os
|
8
|
+
import subprocess
|
9
|
+
import sys
|
10
|
+
|
11
|
+
|
12
|
+
def IsCygwin():
|
13
|
+
# Function copied from pylib/gyp/common.py
|
14
|
+
try:
|
15
|
+
out = subprocess.Popen(
|
16
|
+
"uname", stdout=subprocess.PIPE, stderr=subprocess.STDOUT
|
17
|
+
)
|
18
|
+
stdout, _ = out.communicate()
|
19
|
+
return "CYGWIN" in stdout.decode("utf-8")
|
20
|
+
except Exception:
|
21
|
+
return False
|
22
|
+
|
23
|
+
|
24
|
+
def UnixifyPath(path):
|
25
|
+
try:
|
26
|
+
if not IsCygwin():
|
27
|
+
return path
|
28
|
+
out = subprocess.Popen(
|
29
|
+
["cygpath", "-u", path], stdout=subprocess.PIPE, stderr=subprocess.STDOUT
|
30
|
+
)
|
31
|
+
stdout, _ = out.communicate()
|
32
|
+
return stdout.decode("utf-8")
|
33
|
+
except Exception:
|
34
|
+
return path
|
35
|
+
|
36
|
+
|
37
|
+
# Make sure we're using the version of pylib in this repo, not one installed
|
38
|
+
# elsewhere on the system. Also convert to Unix style path on Cygwin systems,
|
39
|
+
# else the 'gyp' library will not be found
|
40
|
+
path = UnixifyPath(sys.argv[0])
|
41
|
+
sys.path.insert(0, os.path.join(os.path.dirname(path), "pylib"))
|
42
|
+
import gyp # noqa: E402
|
43
|
+
|
44
|
+
if __name__ == "__main__":
|
45
|
+
sys.exit(gyp.script_main())
|
@@ -0,0 +1,365 @@
|
|
1
|
+
# Copyright (c) 2012 Google Inc. All rights reserved.
|
2
|
+
# Use of this source code is governed by a BSD-style license that can be
|
3
|
+
# found in the LICENSE file.
|
4
|
+
|
5
|
+
"""New implementation of Visual Studio project generation."""
|
6
|
+
|
7
|
+
import hashlib
|
8
|
+
import os
|
9
|
+
import random
|
10
|
+
from operator import attrgetter
|
11
|
+
|
12
|
+
import gyp.common
|
13
|
+
|
14
|
+
|
15
|
+
def cmp(x, y):
|
16
|
+
return (x > y) - (x < y)
|
17
|
+
|
18
|
+
|
19
|
+
# Initialize random number generator
|
20
|
+
random.seed()
|
21
|
+
|
22
|
+
# GUIDs for project types
|
23
|
+
ENTRY_TYPE_GUIDS = {
|
24
|
+
"project": "{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}",
|
25
|
+
"folder": "{2150E333-8FDC-42A3-9474-1A3956D46DE8}",
|
26
|
+
}
|
27
|
+
|
28
|
+
# ------------------------------------------------------------------------------
|
29
|
+
# Helper functions
|
30
|
+
|
31
|
+
|
32
|
+
def MakeGuid(name, seed="msvs_new"):
|
33
|
+
"""Returns a GUID for the specified target name.
|
34
|
+
|
35
|
+
Args:
|
36
|
+
name: Target name.
|
37
|
+
seed: Seed for MD5 hash.
|
38
|
+
Returns:
|
39
|
+
A GUID-line string calculated from the name and seed.
|
40
|
+
|
41
|
+
This generates something which looks like a GUID, but depends only on the
|
42
|
+
name and seed. This means the same name/seed will always generate the same
|
43
|
+
GUID, so that projects and solutions which refer to each other can explicitly
|
44
|
+
determine the GUID to refer to explicitly. It also means that the GUID will
|
45
|
+
not change when the project for a target is rebuilt.
|
46
|
+
"""
|
47
|
+
# Calculate a MD5 signature for the seed and name.
|
48
|
+
d = hashlib.md5((str(seed) + str(name)).encode("utf-8")).hexdigest().upper()
|
49
|
+
# Convert most of the signature to GUID form (discard the rest)
|
50
|
+
guid = (
|
51
|
+
"{"
|
52
|
+
+ d[:8]
|
53
|
+
+ "-"
|
54
|
+
+ d[8:12]
|
55
|
+
+ "-"
|
56
|
+
+ d[12:16]
|
57
|
+
+ "-"
|
58
|
+
+ d[16:20]
|
59
|
+
+ "-"
|
60
|
+
+ d[20:32]
|
61
|
+
+ "}"
|
62
|
+
)
|
63
|
+
return guid
|
64
|
+
|
65
|
+
|
66
|
+
# ------------------------------------------------------------------------------
|
67
|
+
|
68
|
+
|
69
|
+
class MSVSSolutionEntry:
|
70
|
+
def __cmp__(self, other):
|
71
|
+
# Sort by name then guid (so things are in order on vs2008).
|
72
|
+
return cmp((self.name, self.get_guid()), (other.name, other.get_guid()))
|
73
|
+
|
74
|
+
|
75
|
+
class MSVSFolder(MSVSSolutionEntry):
|
76
|
+
"""Folder in a Visual Studio project or solution."""
|
77
|
+
|
78
|
+
def __init__(self, path, name=None, entries=None, guid=None, items=None):
|
79
|
+
"""Initializes the folder.
|
80
|
+
|
81
|
+
Args:
|
82
|
+
path: Full path to the folder.
|
83
|
+
name: Name of the folder.
|
84
|
+
entries: List of folder entries to nest inside this folder. May contain
|
85
|
+
Folder or Project objects. May be None, if the folder is empty.
|
86
|
+
guid: GUID to use for folder, if not None.
|
87
|
+
items: List of solution items to include in the folder project. May be
|
88
|
+
None, if the folder does not directly contain items.
|
89
|
+
"""
|
90
|
+
if name:
|
91
|
+
self.name = name
|
92
|
+
else:
|
93
|
+
# Use last layer.
|
94
|
+
self.name = os.path.basename(path)
|
95
|
+
|
96
|
+
self.path = path
|
97
|
+
self.guid = guid
|
98
|
+
|
99
|
+
# Copy passed lists (or set to empty lists)
|
100
|
+
self.entries = sorted(entries or [], key=attrgetter("path"))
|
101
|
+
self.items = list(items or [])
|
102
|
+
|
103
|
+
self.entry_type_guid = ENTRY_TYPE_GUIDS["folder"]
|
104
|
+
|
105
|
+
def get_guid(self):
|
106
|
+
if self.guid is None:
|
107
|
+
# Use consistent guids for folders (so things don't regenerate).
|
108
|
+
self.guid = MakeGuid(self.path, seed="msvs_folder")
|
109
|
+
return self.guid
|
110
|
+
|
111
|
+
|
112
|
+
# ------------------------------------------------------------------------------
|
113
|
+
|
114
|
+
|
115
|
+
class MSVSProject(MSVSSolutionEntry):
|
116
|
+
"""Visual Studio project."""
|
117
|
+
|
118
|
+
def __init__(
|
119
|
+
self,
|
120
|
+
path,
|
121
|
+
name=None,
|
122
|
+
dependencies=None,
|
123
|
+
guid=None,
|
124
|
+
spec=None,
|
125
|
+
build_file=None,
|
126
|
+
config_platform_overrides=None,
|
127
|
+
fixpath_prefix=None,
|
128
|
+
):
|
129
|
+
"""Initializes the project.
|
130
|
+
|
131
|
+
Args:
|
132
|
+
path: Absolute path to the project file.
|
133
|
+
name: Name of project. If None, the name will be the same as the base
|
134
|
+
name of the project file.
|
135
|
+
dependencies: List of other Project objects this project is dependent
|
136
|
+
upon, if not None.
|
137
|
+
guid: GUID to use for project, if not None.
|
138
|
+
spec: Dictionary specifying how to build this project.
|
139
|
+
build_file: Filename of the .gyp file that the vcproj file comes from.
|
140
|
+
config_platform_overrides: optional dict of configuration platforms to
|
141
|
+
used in place of the default for this target.
|
142
|
+
fixpath_prefix: the path used to adjust the behavior of _fixpath
|
143
|
+
"""
|
144
|
+
self.path = path
|
145
|
+
self.guid = guid
|
146
|
+
self.spec = spec
|
147
|
+
self.build_file = build_file
|
148
|
+
# Use project filename if name not specified
|
149
|
+
self.name = name or os.path.splitext(os.path.basename(path))[0]
|
150
|
+
|
151
|
+
# Copy passed lists (or set to empty lists)
|
152
|
+
self.dependencies = list(dependencies or [])
|
153
|
+
|
154
|
+
self.entry_type_guid = ENTRY_TYPE_GUIDS["project"]
|
155
|
+
|
156
|
+
if config_platform_overrides:
|
157
|
+
self.config_platform_overrides = config_platform_overrides
|
158
|
+
else:
|
159
|
+
self.config_platform_overrides = {}
|
160
|
+
self.fixpath_prefix = fixpath_prefix
|
161
|
+
self.msbuild_toolset = None
|
162
|
+
|
163
|
+
def set_dependencies(self, dependencies):
|
164
|
+
self.dependencies = list(dependencies or [])
|
165
|
+
|
166
|
+
def get_guid(self):
|
167
|
+
if self.guid is None:
|
168
|
+
# Set GUID from path
|
169
|
+
# TODO(rspangler): This is fragile.
|
170
|
+
# 1. We can't just use the project filename sans path, since there could
|
171
|
+
# be multiple projects with the same base name (for example,
|
172
|
+
# foo/unittest.vcproj and bar/unittest.vcproj).
|
173
|
+
# 2. The path needs to be relative to $SOURCE_ROOT, so that the project
|
174
|
+
# GUID is the same whether it's included from base/base.sln or
|
175
|
+
# foo/bar/baz/baz.sln.
|
176
|
+
# 3. The GUID needs to be the same each time this builder is invoked, so
|
177
|
+
# that we don't need to rebuild the solution when the project changes.
|
178
|
+
# 4. We should be able to handle pre-built project files by reading the
|
179
|
+
# GUID from the files.
|
180
|
+
self.guid = MakeGuid(self.name)
|
181
|
+
return self.guid
|
182
|
+
|
183
|
+
def set_msbuild_toolset(self, msbuild_toolset):
|
184
|
+
self.msbuild_toolset = msbuild_toolset
|
185
|
+
|
186
|
+
|
187
|
+
# ------------------------------------------------------------------------------
|
188
|
+
|
189
|
+
|
190
|
+
class MSVSSolution:
|
191
|
+
"""Visual Studio solution."""
|
192
|
+
|
193
|
+
def __init__(
|
194
|
+
self, path, version, entries=None, variants=None, websiteProperties=True
|
195
|
+
):
|
196
|
+
"""Initializes the solution.
|
197
|
+
|
198
|
+
Args:
|
199
|
+
path: Path to solution file.
|
200
|
+
version: Format version to emit.
|
201
|
+
entries: List of entries in solution. May contain Folder or Project
|
202
|
+
objects. May be None, if the folder is empty.
|
203
|
+
variants: List of build variant strings. If none, a default list will
|
204
|
+
be used.
|
205
|
+
websiteProperties: Flag to decide if the website properties section
|
206
|
+
is generated.
|
207
|
+
"""
|
208
|
+
self.path = path
|
209
|
+
self.websiteProperties = websiteProperties
|
210
|
+
self.version = version
|
211
|
+
|
212
|
+
# Copy passed lists (or set to empty lists)
|
213
|
+
self.entries = list(entries or [])
|
214
|
+
|
215
|
+
if variants:
|
216
|
+
# Copy passed list
|
217
|
+
self.variants = variants[:]
|
218
|
+
else:
|
219
|
+
# Use default
|
220
|
+
self.variants = ["Debug|Win32", "Release|Win32"]
|
221
|
+
# TODO(rspangler): Need to be able to handle a mapping of solution config
|
222
|
+
# to project config. Should we be able to handle variants being a dict,
|
223
|
+
# or add a separate variant_map variable? If it's a dict, we can't
|
224
|
+
# guarantee the order of variants since dict keys aren't ordered.
|
225
|
+
|
226
|
+
# TODO(rspangler): Automatically write to disk for now; should delay until
|
227
|
+
# node-evaluation time.
|
228
|
+
self.Write()
|
229
|
+
|
230
|
+
def Write(self, writer=gyp.common.WriteOnDiff):
|
231
|
+
"""Writes the solution file to disk.
|
232
|
+
|
233
|
+
Raises:
|
234
|
+
IndexError: An entry appears multiple times.
|
235
|
+
"""
|
236
|
+
# Walk the entry tree and collect all the folders and projects.
|
237
|
+
all_entries = set()
|
238
|
+
entries_to_check = self.entries[:]
|
239
|
+
while entries_to_check:
|
240
|
+
e = entries_to_check.pop(0)
|
241
|
+
|
242
|
+
# If this entry has been visited, nothing to do.
|
243
|
+
if e in all_entries:
|
244
|
+
continue
|
245
|
+
|
246
|
+
all_entries.add(e)
|
247
|
+
|
248
|
+
# If this is a folder, check its entries too.
|
249
|
+
if isinstance(e, MSVSFolder):
|
250
|
+
entries_to_check += e.entries
|
251
|
+
|
252
|
+
all_entries = sorted(all_entries, key=attrgetter("path"))
|
253
|
+
|
254
|
+
# Open file and print header
|
255
|
+
f = writer(self.path)
|
256
|
+
f.write(
|
257
|
+
"Microsoft Visual Studio Solution File, "
|
258
|
+
"Format Version %s\r\n" % self.version.SolutionVersion()
|
259
|
+
)
|
260
|
+
f.write("# %s\r\n" % self.version.Description())
|
261
|
+
|
262
|
+
# Project entries
|
263
|
+
sln_root = os.path.split(self.path)[0]
|
264
|
+
for e in all_entries:
|
265
|
+
relative_path = gyp.common.RelativePath(e.path, sln_root)
|
266
|
+
# msbuild does not accept an empty folder_name.
|
267
|
+
# use '.' in case relative_path is empty.
|
268
|
+
folder_name = relative_path.replace("/", "\\") or "."
|
269
|
+
f.write(
|
270
|
+
'Project("%s") = "%s", "%s", "%s"\r\n'
|
271
|
+
% (
|
272
|
+
e.entry_type_guid, # Entry type GUID
|
273
|
+
e.name, # Folder name
|
274
|
+
folder_name, # Folder name (again)
|
275
|
+
e.get_guid(), # Entry GUID
|
276
|
+
)
|
277
|
+
)
|
278
|
+
|
279
|
+
# TODO(rspangler): Need a way to configure this stuff
|
280
|
+
if self.websiteProperties:
|
281
|
+
f.write(
|
282
|
+
"\tProjectSection(WebsiteProperties) = preProject\r\n"
|
283
|
+
'\t\tDebug.AspNetCompiler.Debug = "True"\r\n'
|
284
|
+
'\t\tRelease.AspNetCompiler.Debug = "False"\r\n'
|
285
|
+
"\tEndProjectSection\r\n"
|
286
|
+
)
|
287
|
+
|
288
|
+
if isinstance(e, MSVSFolder) and e.items:
|
289
|
+
f.write("\tProjectSection(SolutionItems) = preProject\r\n")
|
290
|
+
for i in e.items:
|
291
|
+
f.write(f"\t\t{i} = {i}\r\n")
|
292
|
+
f.write("\tEndProjectSection\r\n")
|
293
|
+
|
294
|
+
if isinstance(e, MSVSProject) and e.dependencies:
|
295
|
+
f.write("\tProjectSection(ProjectDependencies) = postProject\r\n")
|
296
|
+
for d in e.dependencies:
|
297
|
+
f.write(f"\t\t{d.get_guid()} = {d.get_guid()}\r\n")
|
298
|
+
f.write("\tEndProjectSection\r\n")
|
299
|
+
|
300
|
+
f.write("EndProject\r\n")
|
301
|
+
|
302
|
+
# Global section
|
303
|
+
f.write("Global\r\n")
|
304
|
+
|
305
|
+
# Configurations (variants)
|
306
|
+
f.write("\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\r\n")
|
307
|
+
for v in self.variants:
|
308
|
+
f.write(f"\t\t{v} = {v}\r\n")
|
309
|
+
f.write("\tEndGlobalSection\r\n")
|
310
|
+
|
311
|
+
# Sort config guids for easier diffing of solution changes.
|
312
|
+
config_guids = []
|
313
|
+
config_guids_overrides = {}
|
314
|
+
for e in all_entries:
|
315
|
+
if isinstance(e, MSVSProject):
|
316
|
+
config_guids.append(e.get_guid())
|
317
|
+
config_guids_overrides[e.get_guid()] = e.config_platform_overrides
|
318
|
+
config_guids.sort()
|
319
|
+
|
320
|
+
f.write("\tGlobalSection(ProjectConfigurationPlatforms) = postSolution\r\n")
|
321
|
+
for g in config_guids:
|
322
|
+
for v in self.variants:
|
323
|
+
nv = config_guids_overrides[g].get(v, v)
|
324
|
+
# Pick which project configuration to build for this solution
|
325
|
+
# configuration.
|
326
|
+
f.write(
|
327
|
+
"\t\t%s.%s.ActiveCfg = %s\r\n"
|
328
|
+
% (
|
329
|
+
g, # Project GUID
|
330
|
+
v, # Solution build configuration
|
331
|
+
nv, # Project build config for that solution config
|
332
|
+
)
|
333
|
+
)
|
334
|
+
|
335
|
+
# Enable project in this solution configuration.
|
336
|
+
f.write(
|
337
|
+
"\t\t%s.%s.Build.0 = %s\r\n"
|
338
|
+
% (
|
339
|
+
g, # Project GUID
|
340
|
+
v, # Solution build configuration
|
341
|
+
nv, # Project build config for that solution config
|
342
|
+
)
|
343
|
+
)
|
344
|
+
f.write("\tEndGlobalSection\r\n")
|
345
|
+
|
346
|
+
# TODO(rspangler): Should be able to configure this stuff too (though I've
|
347
|
+
# never seen this be any different)
|
348
|
+
f.write("\tGlobalSection(SolutionProperties) = preSolution\r\n")
|
349
|
+
f.write("\t\tHideSolutionNode = FALSE\r\n")
|
350
|
+
f.write("\tEndGlobalSection\r\n")
|
351
|
+
|
352
|
+
# Folder mappings
|
353
|
+
# Omit this section if there are no folders
|
354
|
+
if any(e.entries for e in all_entries if isinstance(e, MSVSFolder)):
|
355
|
+
f.write("\tGlobalSection(NestedProjects) = preSolution\r\n")
|
356
|
+
for e in all_entries:
|
357
|
+
if not isinstance(e, MSVSFolder):
|
358
|
+
continue # Does not apply to projects, only folders
|
359
|
+
for subentry in e.entries:
|
360
|
+
f.write(f"\t\t{subentry.get_guid()} = {e.get_guid()}\r\n")
|
361
|
+
f.write("\tEndGlobalSection\r\n")
|
362
|
+
|
363
|
+
f.write("EndGlobal\r\n")
|
364
|
+
|
365
|
+
f.close()
|