wsba-hockey 1.0.3__py3-none-any.whl → 1.0.5__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.
- wsba_hockey/__init__.py +1 -1
- wsba_hockey/data_pipelines.py +183 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/duckdb/vendor.py +146 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/flatted/python/flatted.py +149 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/flatted/python/test.py +63 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/gyp_main.py +45 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/MSVSNew.py +367 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/MSVSProject.py +206 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/MSVSSettings.py +1270 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/MSVSSettings_test.py +1547 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/MSVSToolFile.py +59 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/MSVSUserFile.py +153 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/MSVSUtil.py +271 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/MSVSVersion.py +574 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/__init__.py +690 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/common.py +661 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/common_test.py +78 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/easy_xml.py +165 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/easy_xml_test.py +109 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/flock_tool.py +55 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/__init__.py +0 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/analyzer.py +808 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/android.py +1173 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/cmake.py +1321 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/compile_commands_json.py +120 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/dump_dependency_json.py +103 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/eclipse.py +464 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/gypd.py +89 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/gypsh.py +58 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py +2714 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs.py +3981 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs_test.py +44 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja.py +2936 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja_test.py +55 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/xcode.py +1394 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/xcode_test.py +25 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/input.py +3130 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/input_test.py +98 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/mac_tool.py +771 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/msvs_emulation.py +1271 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/ninja_syntax.py +174 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/simple_copy.py +61 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/win_tool.py +374 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py +1939 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/xcode_ninja.py +302 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/xcodeproj_file.py +3197 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/xml_fix.py +65 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/test_gyp.py +261 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/tools/graphviz.py +102 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/tools/pretty_gyp.py +156 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/tools/pretty_sln.py +181 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/tools/pretty_vcproj.py +339 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/test/fixtures/test-charmap.py +31 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/update-gyp.py +64 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/gyp_main.py +45 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/MSVSNew.py +367 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/MSVSProject.py +206 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/MSVSSettings.py +1270 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/MSVSSettings_test.py +1547 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/MSVSToolFile.py +59 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/MSVSUserFile.py +153 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/MSVSUtil.py +271 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/MSVSVersion.py +574 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/__init__.py +666 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/common.py +654 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/common_test.py +78 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/easy_xml.py +165 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/easy_xml_test.py +109 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/flock_tool.py +55 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/__init__.py +0 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/analyzer.py +808 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/android.py +1173 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/cmake.py +1321 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/compile_commands_json.py +120 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/dump_dependency_json.py +103 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/eclipse.py +464 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/gypd.py +89 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/gypsh.py +58 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py +2518 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs.py +3978 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs_test.py +44 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja.py +2936 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja_test.py +55 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/xcode.py +1394 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/xcode_test.py +25 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/input.py +3137 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/input_test.py +98 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/mac_tool.py +771 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/msvs_emulation.py +1271 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/ninja_syntax.py +174 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/simple_copy.py +61 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/win_tool.py +374 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py +1939 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/xcode_ninja.py +302 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/xcodeproj_file.py +3197 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/xml_fix.py +65 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/setup.py +42 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/test_gyp.py +260 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/tools/graphviz.py +102 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/tools/pretty_gyp.py +156 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/tools/pretty_sln.py +181 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/tools/pretty_vcproj.py +339 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/test/fixtures/test-charmap.py +31 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/update-gyp.py +46 -0
- wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/game_stats/app.py +400 -0
- wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/game_stats/name_fix.py +47 -0
- wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/heatmaps/app.py +108 -0
- wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/heatmaps/plot.py +93 -0
- wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/heatmaps/rink_plot.py +245 -0
- wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/matchups/app.py +145 -0
- wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/matchups/plot.py +77 -0
- wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/matchups/rink_plot.py +245 -0
- wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/pbp/app.py +389 -0
- wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/pbp/plot.py +70 -0
- wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/pbp/rink_plot.py +245 -0
- wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/skater/app.py +110 -0
- wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/skater/plot.py +58 -0
- wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/skater/rink_plot.py +245 -0
- wsba_hockey/tools/agg.py +243 -54
- wsba_hockey/tools/plotting.py +25 -25
- wsba_hockey/tools/scraping.py +154 -263
- wsba_hockey/tools/xg_model.py +369 -315
- wsba_hockey/workspace.py +22 -117
- wsba_hockey/wsba_main.py +499 -167
- {wsba_hockey-1.0.3.dist-info → wsba_hockey-1.0.5.dist-info}/METADATA +1 -1
- wsba_hockey-1.0.5.dist-info/RECORD +135 -0
- {wsba_hockey-1.0.3.dist-info → wsba_hockey-1.0.5.dist-info}/WHEEL +1 -1
- wsba_hockey/stats/calculate_viz/shot_impact.py +0 -2
- wsba_hockey-1.0.3.dist-info/RECORD +0 -19
- {wsba_hockey-1.0.3.dist-info → wsba_hockey-1.0.5.dist-info}/licenses/LICENSE +0 -0
- {wsba_hockey-1.0.3.dist-info → wsba_hockey-1.0.5.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,120 @@
|
|
1
|
+
# Copyright (c) 2016 Ben Noordhuis <info@bnoordhuis.nl>. 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
|
+
import gyp.common
|
6
|
+
import gyp.xcode_emulation
|
7
|
+
import json
|
8
|
+
import os
|
9
|
+
|
10
|
+
generator_additional_non_configuration_keys = []
|
11
|
+
generator_additional_path_sections = []
|
12
|
+
generator_extra_sources_for_rules = []
|
13
|
+
generator_filelist_paths = None
|
14
|
+
generator_supports_multiple_toolsets = True
|
15
|
+
generator_wants_sorted_dependencies = False
|
16
|
+
|
17
|
+
# Lifted from make.py. The actual values don't matter much.
|
18
|
+
generator_default_variables = {
|
19
|
+
"CONFIGURATION_NAME": "$(BUILDTYPE)",
|
20
|
+
"EXECUTABLE_PREFIX": "",
|
21
|
+
"EXECUTABLE_SUFFIX": "",
|
22
|
+
"INTERMEDIATE_DIR": "$(obj).$(TOOLSET)/$(TARGET)/geni",
|
23
|
+
"PRODUCT_DIR": "$(builddir)",
|
24
|
+
"RULE_INPUT_DIRNAME": "%(INPUT_DIRNAME)s",
|
25
|
+
"RULE_INPUT_EXT": "$(suffix $<)",
|
26
|
+
"RULE_INPUT_NAME": "$(notdir $<)",
|
27
|
+
"RULE_INPUT_PATH": "$(abspath $<)",
|
28
|
+
"RULE_INPUT_ROOT": "%(INPUT_ROOT)s",
|
29
|
+
"SHARED_INTERMEDIATE_DIR": "$(obj)/gen",
|
30
|
+
"SHARED_LIB_PREFIX": "lib",
|
31
|
+
"STATIC_LIB_PREFIX": "lib",
|
32
|
+
"STATIC_LIB_SUFFIX": ".a",
|
33
|
+
}
|
34
|
+
|
35
|
+
|
36
|
+
def IsMac(params):
|
37
|
+
return "mac" == gyp.common.GetFlavor(params)
|
38
|
+
|
39
|
+
|
40
|
+
def CalculateVariables(default_variables, params):
|
41
|
+
default_variables.setdefault("OS", gyp.common.GetFlavor(params))
|
42
|
+
|
43
|
+
|
44
|
+
def AddCommandsForTarget(cwd, target, params, per_config_commands):
|
45
|
+
output_dir = params["generator_flags"].get("output_dir", "out")
|
46
|
+
for configuration_name, configuration in target["configurations"].items():
|
47
|
+
if IsMac(params):
|
48
|
+
xcode_settings = gyp.xcode_emulation.XcodeSettings(target)
|
49
|
+
cflags = xcode_settings.GetCflags(configuration_name)
|
50
|
+
cflags_c = xcode_settings.GetCflagsC(configuration_name)
|
51
|
+
cflags_cc = xcode_settings.GetCflagsCC(configuration_name)
|
52
|
+
else:
|
53
|
+
cflags = configuration.get("cflags", [])
|
54
|
+
cflags_c = configuration.get("cflags_c", [])
|
55
|
+
cflags_cc = configuration.get("cflags_cc", [])
|
56
|
+
|
57
|
+
cflags_c = cflags + cflags_c
|
58
|
+
cflags_cc = cflags + cflags_cc
|
59
|
+
|
60
|
+
defines = configuration.get("defines", [])
|
61
|
+
defines = ["-D" + s for s in defines]
|
62
|
+
|
63
|
+
# TODO(bnoordhuis) Handle generated source files.
|
64
|
+
extensions = (".c", ".cc", ".cpp", ".cxx")
|
65
|
+
sources = [s for s in target.get("sources", []) if s.endswith(extensions)]
|
66
|
+
|
67
|
+
def resolve(filename):
|
68
|
+
return os.path.abspath(os.path.join(cwd, filename))
|
69
|
+
|
70
|
+
# TODO(bnoordhuis) Handle generated header files.
|
71
|
+
include_dirs = configuration.get("include_dirs", [])
|
72
|
+
include_dirs = [s for s in include_dirs if not s.startswith("$(obj)")]
|
73
|
+
includes = ["-I" + resolve(s) for s in include_dirs]
|
74
|
+
|
75
|
+
defines = gyp.common.EncodePOSIXShellList(defines)
|
76
|
+
includes = gyp.common.EncodePOSIXShellList(includes)
|
77
|
+
cflags_c = gyp.common.EncodePOSIXShellList(cflags_c)
|
78
|
+
cflags_cc = gyp.common.EncodePOSIXShellList(cflags_cc)
|
79
|
+
|
80
|
+
commands = per_config_commands.setdefault(configuration_name, [])
|
81
|
+
for source in sources:
|
82
|
+
file = resolve(source)
|
83
|
+
isc = source.endswith(".c")
|
84
|
+
cc = "cc" if isc else "c++"
|
85
|
+
cflags = cflags_c if isc else cflags_cc
|
86
|
+
command = " ".join(
|
87
|
+
(
|
88
|
+
cc,
|
89
|
+
defines,
|
90
|
+
includes,
|
91
|
+
cflags,
|
92
|
+
"-c",
|
93
|
+
gyp.common.EncodePOSIXShellArgument(file),
|
94
|
+
)
|
95
|
+
)
|
96
|
+
commands.append(dict(command=command, directory=output_dir, file=file))
|
97
|
+
|
98
|
+
|
99
|
+
def GenerateOutput(target_list, target_dicts, data, params):
|
100
|
+
per_config_commands = {}
|
101
|
+
for qualified_target, target in target_dicts.items():
|
102
|
+
build_file, target_name, toolset = gyp.common.ParseQualifiedTarget(
|
103
|
+
qualified_target
|
104
|
+
)
|
105
|
+
if IsMac(params):
|
106
|
+
settings = data[build_file]
|
107
|
+
gyp.xcode_emulation.MergeGlobalXcodeSettingsToSpec(settings, target)
|
108
|
+
cwd = os.path.dirname(build_file)
|
109
|
+
AddCommandsForTarget(cwd, target, params, per_config_commands)
|
110
|
+
|
111
|
+
output_dir = params["generator_flags"].get("output_dir", "out")
|
112
|
+
for configuration_name, commands in per_config_commands.items():
|
113
|
+
filename = os.path.join(output_dir, configuration_name, "compile_commands.json")
|
114
|
+
gyp.common.EnsureDirExists(filename)
|
115
|
+
fp = open(filename, "w")
|
116
|
+
json.dump(commands, fp=fp, indent=0, check_circular=False)
|
117
|
+
|
118
|
+
|
119
|
+
def PerformBuild(data, configurations, params):
|
120
|
+
pass
|
@@ -0,0 +1,103 @@
|
|
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
|
+
|
6
|
+
import os
|
7
|
+
import gyp
|
8
|
+
import gyp.common
|
9
|
+
import gyp.msvs_emulation
|
10
|
+
import json
|
11
|
+
|
12
|
+
generator_supports_multiple_toolsets = True
|
13
|
+
|
14
|
+
generator_wants_static_library_dependencies_adjusted = False
|
15
|
+
|
16
|
+
generator_filelist_paths = {}
|
17
|
+
|
18
|
+
generator_default_variables = {}
|
19
|
+
for dirname in [
|
20
|
+
"INTERMEDIATE_DIR",
|
21
|
+
"SHARED_INTERMEDIATE_DIR",
|
22
|
+
"PRODUCT_DIR",
|
23
|
+
"LIB_DIR",
|
24
|
+
"SHARED_LIB_DIR",
|
25
|
+
]:
|
26
|
+
# Some gyp steps fail if these are empty(!).
|
27
|
+
generator_default_variables[dirname] = "dir"
|
28
|
+
for unused in [
|
29
|
+
"RULE_INPUT_PATH",
|
30
|
+
"RULE_INPUT_ROOT",
|
31
|
+
"RULE_INPUT_NAME",
|
32
|
+
"RULE_INPUT_DIRNAME",
|
33
|
+
"RULE_INPUT_EXT",
|
34
|
+
"EXECUTABLE_PREFIX",
|
35
|
+
"EXECUTABLE_SUFFIX",
|
36
|
+
"STATIC_LIB_PREFIX",
|
37
|
+
"STATIC_LIB_SUFFIX",
|
38
|
+
"SHARED_LIB_PREFIX",
|
39
|
+
"SHARED_LIB_SUFFIX",
|
40
|
+
"CONFIGURATION_NAME",
|
41
|
+
]:
|
42
|
+
generator_default_variables[unused] = ""
|
43
|
+
|
44
|
+
|
45
|
+
def CalculateVariables(default_variables, params):
|
46
|
+
generator_flags = params.get("generator_flags", {})
|
47
|
+
for key, val in generator_flags.items():
|
48
|
+
default_variables.setdefault(key, val)
|
49
|
+
default_variables.setdefault("OS", gyp.common.GetFlavor(params))
|
50
|
+
|
51
|
+
flavor = gyp.common.GetFlavor(params)
|
52
|
+
if flavor == "win":
|
53
|
+
gyp.msvs_emulation.CalculateCommonVariables(default_variables, params)
|
54
|
+
|
55
|
+
|
56
|
+
def CalculateGeneratorInputInfo(params):
|
57
|
+
"""Calculate the generator specific info that gets fed to input (called by
|
58
|
+
gyp)."""
|
59
|
+
generator_flags = params.get("generator_flags", {})
|
60
|
+
if generator_flags.get("adjust_static_libraries", False):
|
61
|
+
global generator_wants_static_library_dependencies_adjusted
|
62
|
+
generator_wants_static_library_dependencies_adjusted = True
|
63
|
+
|
64
|
+
toplevel = params["options"].toplevel_dir
|
65
|
+
generator_dir = os.path.relpath(params["options"].generator_output or ".")
|
66
|
+
# output_dir: relative path from generator_dir to the build directory.
|
67
|
+
output_dir = generator_flags.get("output_dir", "out")
|
68
|
+
qualified_out_dir = os.path.normpath(
|
69
|
+
os.path.join(toplevel, generator_dir, output_dir, "gypfiles")
|
70
|
+
)
|
71
|
+
global generator_filelist_paths
|
72
|
+
generator_filelist_paths = {
|
73
|
+
"toplevel": toplevel,
|
74
|
+
"qualified_out_dir": qualified_out_dir,
|
75
|
+
}
|
76
|
+
|
77
|
+
|
78
|
+
def GenerateOutput(target_list, target_dicts, data, params):
|
79
|
+
# Map of target -> list of targets it depends on.
|
80
|
+
edges = {}
|
81
|
+
|
82
|
+
# Queue of targets to visit.
|
83
|
+
targets_to_visit = target_list[:]
|
84
|
+
|
85
|
+
while len(targets_to_visit) > 0:
|
86
|
+
target = targets_to_visit.pop()
|
87
|
+
if target in edges:
|
88
|
+
continue
|
89
|
+
edges[target] = []
|
90
|
+
|
91
|
+
for dep in target_dicts[target].get("dependencies", []):
|
92
|
+
edges[target].append(dep)
|
93
|
+
targets_to_visit.append(dep)
|
94
|
+
|
95
|
+
try:
|
96
|
+
filepath = params["generator_flags"]["output_dir"]
|
97
|
+
except KeyError:
|
98
|
+
filepath = "."
|
99
|
+
filename = os.path.join(filepath, "dump.json")
|
100
|
+
f = open(filename, "w")
|
101
|
+
json.dump(edges, f)
|
102
|
+
f.close()
|
103
|
+
print("Wrote json to %s." % filename)
|
wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/eclipse.py
ADDED
@@ -0,0 +1,464 @@
|
|
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
|
+
"""GYP backend that generates Eclipse CDT settings files.
|
6
|
+
|
7
|
+
This backend DOES NOT generate Eclipse CDT projects. Instead, it generates XML
|
8
|
+
files that can be imported into an Eclipse CDT project. The XML file contains a
|
9
|
+
list of include paths and symbols (i.e. defines).
|
10
|
+
|
11
|
+
Because a full .cproject definition is not created by this generator, it's not
|
12
|
+
possible to properly define the include dirs and symbols for each file
|
13
|
+
individually. Instead, one set of includes/symbols is generated for the entire
|
14
|
+
project. This works fairly well (and is a vast improvement in general), but may
|
15
|
+
still result in a few indexer issues here and there.
|
16
|
+
|
17
|
+
This generator has no automated tests, so expect it to be broken.
|
18
|
+
"""
|
19
|
+
|
20
|
+
from xml.sax.saxutils import escape
|
21
|
+
import os.path
|
22
|
+
import subprocess
|
23
|
+
import gyp
|
24
|
+
import gyp.common
|
25
|
+
import gyp.msvs_emulation
|
26
|
+
import shlex
|
27
|
+
import xml.etree.ElementTree as ET
|
28
|
+
|
29
|
+
generator_wants_static_library_dependencies_adjusted = False
|
30
|
+
|
31
|
+
generator_default_variables = {}
|
32
|
+
|
33
|
+
for dirname in ["INTERMEDIATE_DIR", "PRODUCT_DIR", "LIB_DIR", "SHARED_LIB_DIR"]:
|
34
|
+
# Some gyp steps fail if these are empty(!), so we convert them to variables
|
35
|
+
generator_default_variables[dirname] = "$" + dirname
|
36
|
+
|
37
|
+
for unused in [
|
38
|
+
"RULE_INPUT_PATH",
|
39
|
+
"RULE_INPUT_ROOT",
|
40
|
+
"RULE_INPUT_NAME",
|
41
|
+
"RULE_INPUT_DIRNAME",
|
42
|
+
"RULE_INPUT_EXT",
|
43
|
+
"EXECUTABLE_PREFIX",
|
44
|
+
"EXECUTABLE_SUFFIX",
|
45
|
+
"STATIC_LIB_PREFIX",
|
46
|
+
"STATIC_LIB_SUFFIX",
|
47
|
+
"SHARED_LIB_PREFIX",
|
48
|
+
"SHARED_LIB_SUFFIX",
|
49
|
+
"CONFIGURATION_NAME",
|
50
|
+
]:
|
51
|
+
generator_default_variables[unused] = ""
|
52
|
+
|
53
|
+
# Include dirs will occasionally use the SHARED_INTERMEDIATE_DIR variable as
|
54
|
+
# part of the path when dealing with generated headers. This value will be
|
55
|
+
# replaced dynamically for each configuration.
|
56
|
+
generator_default_variables["SHARED_INTERMEDIATE_DIR"] = "$SHARED_INTERMEDIATE_DIR"
|
57
|
+
|
58
|
+
|
59
|
+
def CalculateVariables(default_variables, params):
|
60
|
+
generator_flags = params.get("generator_flags", {})
|
61
|
+
for key, val in generator_flags.items():
|
62
|
+
default_variables.setdefault(key, val)
|
63
|
+
flavor = gyp.common.GetFlavor(params)
|
64
|
+
default_variables.setdefault("OS", flavor)
|
65
|
+
if flavor == "win":
|
66
|
+
gyp.msvs_emulation.CalculateCommonVariables(default_variables, params)
|
67
|
+
|
68
|
+
|
69
|
+
def CalculateGeneratorInputInfo(params):
|
70
|
+
"""Calculate the generator specific info that gets fed to input (called by
|
71
|
+
gyp)."""
|
72
|
+
generator_flags = params.get("generator_flags", {})
|
73
|
+
if generator_flags.get("adjust_static_libraries", False):
|
74
|
+
global generator_wants_static_library_dependencies_adjusted
|
75
|
+
generator_wants_static_library_dependencies_adjusted = True
|
76
|
+
|
77
|
+
|
78
|
+
def GetAllIncludeDirectories(
|
79
|
+
target_list,
|
80
|
+
target_dicts,
|
81
|
+
shared_intermediate_dirs,
|
82
|
+
config_name,
|
83
|
+
params,
|
84
|
+
compiler_path,
|
85
|
+
):
|
86
|
+
"""Calculate the set of include directories to be used.
|
87
|
+
|
88
|
+
Returns:
|
89
|
+
A list including all the include_dir's specified for every target followed
|
90
|
+
by any include directories that were added as cflag compiler options.
|
91
|
+
"""
|
92
|
+
|
93
|
+
gyp_includes_set = set()
|
94
|
+
compiler_includes_list = []
|
95
|
+
|
96
|
+
# Find compiler's default include dirs.
|
97
|
+
if compiler_path:
|
98
|
+
command = shlex.split(compiler_path)
|
99
|
+
command.extend(["-E", "-xc++", "-v", "-"])
|
100
|
+
proc = subprocess.Popen(
|
101
|
+
args=command,
|
102
|
+
stdin=subprocess.PIPE,
|
103
|
+
stdout=subprocess.PIPE,
|
104
|
+
stderr=subprocess.PIPE,
|
105
|
+
)
|
106
|
+
output = proc.communicate()[1].decode("utf-8")
|
107
|
+
# Extract the list of include dirs from the output, which has this format:
|
108
|
+
# ...
|
109
|
+
# #include "..." search starts here:
|
110
|
+
# #include <...> search starts here:
|
111
|
+
# /usr/include/c++/4.6
|
112
|
+
# /usr/local/include
|
113
|
+
# End of search list.
|
114
|
+
# ...
|
115
|
+
in_include_list = False
|
116
|
+
for line in output.splitlines():
|
117
|
+
if line.startswith("#include"):
|
118
|
+
in_include_list = True
|
119
|
+
continue
|
120
|
+
if line.startswith("End of search list."):
|
121
|
+
break
|
122
|
+
if in_include_list:
|
123
|
+
include_dir = line.strip()
|
124
|
+
if include_dir not in compiler_includes_list:
|
125
|
+
compiler_includes_list.append(include_dir)
|
126
|
+
|
127
|
+
flavor = gyp.common.GetFlavor(params)
|
128
|
+
if flavor == "win":
|
129
|
+
generator_flags = params.get("generator_flags", {})
|
130
|
+
for target_name in target_list:
|
131
|
+
target = target_dicts[target_name]
|
132
|
+
if config_name in target["configurations"]:
|
133
|
+
config = target["configurations"][config_name]
|
134
|
+
|
135
|
+
# Look for any include dirs that were explicitly added via cflags. This
|
136
|
+
# may be done in gyp files to force certain includes to come at the end.
|
137
|
+
# TODO(jgreenwald): Change the gyp files to not abuse cflags for this, and
|
138
|
+
# remove this.
|
139
|
+
if flavor == "win":
|
140
|
+
msvs_settings = gyp.msvs_emulation.MsvsSettings(target, generator_flags)
|
141
|
+
cflags = msvs_settings.GetCflags(config_name)
|
142
|
+
else:
|
143
|
+
cflags = config["cflags"]
|
144
|
+
for cflag in cflags:
|
145
|
+
if cflag.startswith("-I"):
|
146
|
+
include_dir = cflag[2:]
|
147
|
+
if include_dir not in compiler_includes_list:
|
148
|
+
compiler_includes_list.append(include_dir)
|
149
|
+
|
150
|
+
# Find standard gyp include dirs.
|
151
|
+
if "include_dirs" in config:
|
152
|
+
include_dirs = config["include_dirs"]
|
153
|
+
for shared_intermediate_dir in shared_intermediate_dirs:
|
154
|
+
for include_dir in include_dirs:
|
155
|
+
include_dir = include_dir.replace(
|
156
|
+
"$SHARED_INTERMEDIATE_DIR", shared_intermediate_dir
|
157
|
+
)
|
158
|
+
if not os.path.isabs(include_dir):
|
159
|
+
base_dir = os.path.dirname(target_name)
|
160
|
+
|
161
|
+
include_dir = base_dir + "/" + include_dir
|
162
|
+
include_dir = os.path.abspath(include_dir)
|
163
|
+
|
164
|
+
gyp_includes_set.add(include_dir)
|
165
|
+
|
166
|
+
# Generate a list that has all the include dirs.
|
167
|
+
all_includes_list = list(gyp_includes_set)
|
168
|
+
all_includes_list.sort()
|
169
|
+
for compiler_include in compiler_includes_list:
|
170
|
+
if compiler_include not in gyp_includes_set:
|
171
|
+
all_includes_list.append(compiler_include)
|
172
|
+
|
173
|
+
# All done.
|
174
|
+
return all_includes_list
|
175
|
+
|
176
|
+
|
177
|
+
def GetCompilerPath(target_list, data, options):
|
178
|
+
"""Determine a command that can be used to invoke the compiler.
|
179
|
+
|
180
|
+
Returns:
|
181
|
+
If this is a gyp project that has explicit make settings, try to determine
|
182
|
+
the compiler from that. Otherwise, see if a compiler was specified via the
|
183
|
+
CC_target environment variable.
|
184
|
+
"""
|
185
|
+
# First, see if the compiler is configured in make's settings.
|
186
|
+
build_file, _, _ = gyp.common.ParseQualifiedTarget(target_list[0])
|
187
|
+
make_global_settings_dict = data[build_file].get("make_global_settings", {})
|
188
|
+
for key, value in make_global_settings_dict:
|
189
|
+
if key in ["CC", "CXX"]:
|
190
|
+
return os.path.join(options.toplevel_dir, value)
|
191
|
+
|
192
|
+
# Check to see if the compiler was specified as an environment variable.
|
193
|
+
for key in ["CC_target", "CC", "CXX"]:
|
194
|
+
compiler = os.environ.get(key)
|
195
|
+
if compiler:
|
196
|
+
return compiler
|
197
|
+
|
198
|
+
return "gcc"
|
199
|
+
|
200
|
+
|
201
|
+
def GetAllDefines(target_list, target_dicts, data, config_name, params, compiler_path):
|
202
|
+
"""Calculate the defines for a project.
|
203
|
+
|
204
|
+
Returns:
|
205
|
+
A dict that includes explicit defines declared in gyp files along with all
|
206
|
+
of the default defines that the compiler uses.
|
207
|
+
"""
|
208
|
+
|
209
|
+
# Get defines declared in the gyp files.
|
210
|
+
all_defines = {}
|
211
|
+
flavor = gyp.common.GetFlavor(params)
|
212
|
+
if flavor == "win":
|
213
|
+
generator_flags = params.get("generator_flags", {})
|
214
|
+
for target_name in target_list:
|
215
|
+
target = target_dicts[target_name]
|
216
|
+
|
217
|
+
if flavor == "win":
|
218
|
+
msvs_settings = gyp.msvs_emulation.MsvsSettings(target, generator_flags)
|
219
|
+
extra_defines = msvs_settings.GetComputedDefines(config_name)
|
220
|
+
else:
|
221
|
+
extra_defines = []
|
222
|
+
if config_name in target["configurations"]:
|
223
|
+
config = target["configurations"][config_name]
|
224
|
+
target_defines = config["defines"]
|
225
|
+
else:
|
226
|
+
target_defines = []
|
227
|
+
for define in target_defines + extra_defines:
|
228
|
+
split_define = define.split("=", 1)
|
229
|
+
if len(split_define) == 1:
|
230
|
+
split_define.append("1")
|
231
|
+
if split_define[0].strip() in all_defines:
|
232
|
+
# Already defined
|
233
|
+
continue
|
234
|
+
all_defines[split_define[0].strip()] = split_define[1].strip()
|
235
|
+
# Get default compiler defines (if possible).
|
236
|
+
if flavor == "win":
|
237
|
+
return all_defines # Default defines already processed in the loop above.
|
238
|
+
if compiler_path:
|
239
|
+
command = shlex.split(compiler_path)
|
240
|
+
command.extend(["-E", "-dM", "-"])
|
241
|
+
cpp_proc = subprocess.Popen(
|
242
|
+
args=command, cwd=".", stdin=subprocess.PIPE, stdout=subprocess.PIPE
|
243
|
+
)
|
244
|
+
cpp_output = cpp_proc.communicate()[0].decode("utf-8")
|
245
|
+
cpp_lines = cpp_output.split("\n")
|
246
|
+
for cpp_line in cpp_lines:
|
247
|
+
if not cpp_line.strip():
|
248
|
+
continue
|
249
|
+
cpp_line_parts = cpp_line.split(" ", 2)
|
250
|
+
key = cpp_line_parts[1]
|
251
|
+
if len(cpp_line_parts) >= 3:
|
252
|
+
val = cpp_line_parts[2]
|
253
|
+
else:
|
254
|
+
val = "1"
|
255
|
+
all_defines[key] = val
|
256
|
+
|
257
|
+
return all_defines
|
258
|
+
|
259
|
+
|
260
|
+
def WriteIncludePaths(out, eclipse_langs, include_dirs):
|
261
|
+
"""Write the includes section of a CDT settings export file."""
|
262
|
+
|
263
|
+
out.write(
|
264
|
+
' <section name="org.eclipse.cdt.internal.ui.wizards.'
|
265
|
+
'settingswizards.IncludePaths">\n'
|
266
|
+
)
|
267
|
+
out.write(' <language name="holder for library settings"></language>\n')
|
268
|
+
for lang in eclipse_langs:
|
269
|
+
out.write(' <language name="%s">\n' % lang)
|
270
|
+
for include_dir in include_dirs:
|
271
|
+
out.write(
|
272
|
+
' <includepath workspace_path="false">%s</includepath>\n'
|
273
|
+
% include_dir
|
274
|
+
)
|
275
|
+
out.write(" </language>\n")
|
276
|
+
out.write(" </section>\n")
|
277
|
+
|
278
|
+
|
279
|
+
def WriteMacros(out, eclipse_langs, defines):
|
280
|
+
"""Write the macros section of a CDT settings export file."""
|
281
|
+
|
282
|
+
out.write(
|
283
|
+
' <section name="org.eclipse.cdt.internal.ui.wizards.'
|
284
|
+
'settingswizards.Macros">\n'
|
285
|
+
)
|
286
|
+
out.write(' <language name="holder for library settings"></language>\n')
|
287
|
+
for lang in eclipse_langs:
|
288
|
+
out.write(' <language name="%s">\n' % lang)
|
289
|
+
for key in sorted(defines):
|
290
|
+
out.write(
|
291
|
+
" <macro><name>%s</name><value>%s</value></macro>\n"
|
292
|
+
% (escape(key), escape(defines[key]))
|
293
|
+
)
|
294
|
+
out.write(" </language>\n")
|
295
|
+
out.write(" </section>\n")
|
296
|
+
|
297
|
+
|
298
|
+
def GenerateOutputForConfig(target_list, target_dicts, data, params, config_name):
|
299
|
+
options = params["options"]
|
300
|
+
generator_flags = params.get("generator_flags", {})
|
301
|
+
|
302
|
+
# build_dir: relative path from source root to our output files.
|
303
|
+
# e.g. "out/Debug"
|
304
|
+
build_dir = os.path.join(generator_flags.get("output_dir", "out"), config_name)
|
305
|
+
|
306
|
+
toplevel_build = os.path.join(options.toplevel_dir, build_dir)
|
307
|
+
# Ninja uses out/Debug/gen while make uses out/Debug/obj/gen as the
|
308
|
+
# SHARED_INTERMEDIATE_DIR. Include both possible locations.
|
309
|
+
shared_intermediate_dirs = [
|
310
|
+
os.path.join(toplevel_build, "obj", "gen"),
|
311
|
+
os.path.join(toplevel_build, "gen"),
|
312
|
+
]
|
313
|
+
|
314
|
+
GenerateCdtSettingsFile(
|
315
|
+
target_list,
|
316
|
+
target_dicts,
|
317
|
+
data,
|
318
|
+
params,
|
319
|
+
config_name,
|
320
|
+
os.path.join(toplevel_build, "eclipse-cdt-settings.xml"),
|
321
|
+
options,
|
322
|
+
shared_intermediate_dirs,
|
323
|
+
)
|
324
|
+
GenerateClasspathFile(
|
325
|
+
target_list,
|
326
|
+
target_dicts,
|
327
|
+
options.toplevel_dir,
|
328
|
+
toplevel_build,
|
329
|
+
os.path.join(toplevel_build, "eclipse-classpath.xml"),
|
330
|
+
)
|
331
|
+
|
332
|
+
|
333
|
+
def GenerateCdtSettingsFile(
|
334
|
+
target_list,
|
335
|
+
target_dicts,
|
336
|
+
data,
|
337
|
+
params,
|
338
|
+
config_name,
|
339
|
+
out_name,
|
340
|
+
options,
|
341
|
+
shared_intermediate_dirs,
|
342
|
+
):
|
343
|
+
gyp.common.EnsureDirExists(out_name)
|
344
|
+
with open(out_name, "w") as out:
|
345
|
+
out.write('<?xml version="1.0" encoding="UTF-8"?>\n')
|
346
|
+
out.write("<cdtprojectproperties>\n")
|
347
|
+
|
348
|
+
eclipse_langs = [
|
349
|
+
"C++ Source File",
|
350
|
+
"C Source File",
|
351
|
+
"Assembly Source File",
|
352
|
+
"GNU C++",
|
353
|
+
"GNU C",
|
354
|
+
"Assembly",
|
355
|
+
]
|
356
|
+
compiler_path = GetCompilerPath(target_list, data, options)
|
357
|
+
include_dirs = GetAllIncludeDirectories(
|
358
|
+
target_list,
|
359
|
+
target_dicts,
|
360
|
+
shared_intermediate_dirs,
|
361
|
+
config_name,
|
362
|
+
params,
|
363
|
+
compiler_path,
|
364
|
+
)
|
365
|
+
WriteIncludePaths(out, eclipse_langs, include_dirs)
|
366
|
+
defines = GetAllDefines(
|
367
|
+
target_list, target_dicts, data, config_name, params, compiler_path
|
368
|
+
)
|
369
|
+
WriteMacros(out, eclipse_langs, defines)
|
370
|
+
|
371
|
+
out.write("</cdtprojectproperties>\n")
|
372
|
+
|
373
|
+
|
374
|
+
def GenerateClasspathFile(
|
375
|
+
target_list, target_dicts, toplevel_dir, toplevel_build, out_name
|
376
|
+
):
|
377
|
+
"""Generates a classpath file suitable for symbol navigation and code
|
378
|
+
completion of Java code (such as in Android projects) by finding all
|
379
|
+
.java and .jar files used as action inputs."""
|
380
|
+
gyp.common.EnsureDirExists(out_name)
|
381
|
+
result = ET.Element("classpath")
|
382
|
+
|
383
|
+
def AddElements(kind, paths):
|
384
|
+
# First, we need to normalize the paths so they are all relative to the
|
385
|
+
# toplevel dir.
|
386
|
+
rel_paths = set()
|
387
|
+
for path in paths:
|
388
|
+
if os.path.isabs(path):
|
389
|
+
rel_paths.add(os.path.relpath(path, toplevel_dir))
|
390
|
+
else:
|
391
|
+
rel_paths.add(path)
|
392
|
+
|
393
|
+
for path in sorted(rel_paths):
|
394
|
+
entry_element = ET.SubElement(result, "classpathentry")
|
395
|
+
entry_element.set("kind", kind)
|
396
|
+
entry_element.set("path", path)
|
397
|
+
|
398
|
+
AddElements("lib", GetJavaJars(target_list, target_dicts, toplevel_dir))
|
399
|
+
AddElements("src", GetJavaSourceDirs(target_list, target_dicts, toplevel_dir))
|
400
|
+
# Include the standard JRE container and a dummy out folder
|
401
|
+
AddElements("con", ["org.eclipse.jdt.launching.JRE_CONTAINER"])
|
402
|
+
# Include a dummy out folder so that Eclipse doesn't use the default /bin
|
403
|
+
# folder in the root of the project.
|
404
|
+
AddElements("output", [os.path.join(toplevel_build, ".eclipse-java-build")])
|
405
|
+
|
406
|
+
ET.ElementTree(result).write(out_name)
|
407
|
+
|
408
|
+
|
409
|
+
def GetJavaJars(target_list, target_dicts, toplevel_dir):
|
410
|
+
"""Generates a sequence of all .jars used as inputs."""
|
411
|
+
for target_name in target_list:
|
412
|
+
target = target_dicts[target_name]
|
413
|
+
for action in target.get("actions", []):
|
414
|
+
for input_ in action["inputs"]:
|
415
|
+
if os.path.splitext(input_)[1] == ".jar" and not input_.startswith("$"):
|
416
|
+
if os.path.isabs(input_):
|
417
|
+
yield input_
|
418
|
+
else:
|
419
|
+
yield os.path.join(os.path.dirname(target_name), input_)
|
420
|
+
|
421
|
+
|
422
|
+
def GetJavaSourceDirs(target_list, target_dicts, toplevel_dir):
|
423
|
+
"""Generates a sequence of all likely java package root directories."""
|
424
|
+
for target_name in target_list:
|
425
|
+
target = target_dicts[target_name]
|
426
|
+
for action in target.get("actions", []):
|
427
|
+
for input_ in action["inputs"]:
|
428
|
+
if os.path.splitext(input_)[1] == ".java" and not input_.startswith(
|
429
|
+
"$"
|
430
|
+
):
|
431
|
+
dir_ = os.path.dirname(
|
432
|
+
os.path.join(os.path.dirname(target_name), input_)
|
433
|
+
)
|
434
|
+
# If there is a parent 'src' or 'java' folder, navigate up to it -
|
435
|
+
# these are canonical package root names in Chromium. This will
|
436
|
+
# break if 'src' or 'java' exists in the package structure. This
|
437
|
+
# could be further improved by inspecting the java file for the
|
438
|
+
# package name if this proves to be too fragile in practice.
|
439
|
+
parent_search = dir_
|
440
|
+
while os.path.basename(parent_search) not in ["src", "java"]:
|
441
|
+
parent_search, _ = os.path.split(parent_search)
|
442
|
+
if not parent_search or parent_search == toplevel_dir:
|
443
|
+
# Didn't find a known root, just return the original path
|
444
|
+
yield dir_
|
445
|
+
break
|
446
|
+
else:
|
447
|
+
yield parent_search
|
448
|
+
|
449
|
+
|
450
|
+
def GenerateOutput(target_list, target_dicts, data, params):
|
451
|
+
"""Generate an XML settings file that can be imported into a CDT project."""
|
452
|
+
|
453
|
+
if params["options"].generator_output:
|
454
|
+
raise NotImplementedError("--generator_output not implemented for eclipse")
|
455
|
+
|
456
|
+
user_config = params.get("generator_flags", {}).get("config", None)
|
457
|
+
if user_config:
|
458
|
+
GenerateOutputForConfig(target_list, target_dicts, data, params, user_config)
|
459
|
+
else:
|
460
|
+
config_names = target_dicts[target_list[0]]["configurations"]
|
461
|
+
for config_name in config_names:
|
462
|
+
GenerateOutputForConfig(
|
463
|
+
target_list, target_dicts, data, params, config_name
|
464
|
+
)
|