Skip to content

Commit

Permalink
More fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
pjreiniger committed Dec 18, 2023
1 parent 4b4dab5 commit b1769d9
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 14 deletions.
23 changes: 19 additions & 4 deletions robotbuild_generation/pybind_gen_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,17 @@ def _collect_wrappers(self, output_directory):

if cfg.generation_data:
# print("Has gen data", cfg.generation_data)
cfg.generation_data = (
f"{self.project.base_package}/src/main/python/" + cfg.generation_data
)
if self.project.base_package == "robotpy_apriltag":
cfg.generation_data = (
f"apriltag/src/main/python/" + cfg.generation_data
)
else:
cfg.generation_data = (
f"{self.project.base_package}/src/main/python/" + cfg.generation_data
)

# print(package_name, cfg)
# self._fix_downloads(cfg, False)
self._fix_downloads(cfg, False)
w = Wrapper(package_name, cfg, self, self.wwriter)
self.wrappers.append(w)
self.pkgcfg.add_pkg(w)
Expand All @@ -143,3 +148,13 @@ def _collect_wrappers(self, output_directory):

if ext_modules:
self.setup_kwargs["ext_modules"] = ext_modules

def _fix_downloads(self, cfg, static: bool):
print(cfg)
if cfg.maven_lib_download:
downloads = [Download(url="FAKE", incdir="FAKE INCLUDE", libdir = "FAKE LIB", libs=cfg.maven_lib_download.libs)]
cfg.maven_lib_download = None
if cfg.download:
cfg.download.append(downloads)
else:
cfg.download = downloads
14 changes: 10 additions & 4 deletions robotbuild_generation/pybind_on_build_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,16 @@ def main(argv):
args.output_directory, f"rpy-include/{project_name}"
)

shutil.copytree(
os.path.join(intermediate_directory, f"{project_name}"),
rpy_include_output_dir,
)
if "apriltag" in project_name:
shutil.copytree(
os.path.join(intermediate_directory, f"robotpy_apriltag"),
rpy_include_output_dir,
)
else:
shutil.copytree(
os.path.join(intermediate_directory, f"{project_name}"),
rpy_include_output_dir,
)

logging.info("Copying CPP files to src directory")
for root, _, files in os.walk(rpy_include_output_dir):
Expand Down
5 changes: 2 additions & 3 deletions rules_robotpy_utils/generate_robotpy_project_files.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ def generate_robotpy_project_files(
python_deps = [],
headers = [],
internal_project_dependencies = [],
disable = False,
disable_gen_test = False,
visibility = None,
init_file = None,
parent_folder = ""):
if disable:
return

py_binary(
name = name + ".pybind_on_build_dl_exe",
Expand Down Expand Up @@ -69,6 +67,7 @@ def generate_robotpy_project_files(
files = file_mapping,
suggested_update_target = "//:write_on_build_dl_files",
visibility = ["//visibility:public"],
diff_test = not disable_gen_test
)

native.filegroup(
Expand Down
7 changes: 5 additions & 2 deletions rules_robotpy_utils/generate_robotpy_source_files.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ def generate_robotpy_source_files(
projects = None,
headers = [],
internal_project_dependencies = [],
disable = False):
disable = False,
project_name = None):
if disable:
return

project_name = project_name or name

py_binary(
name = name + ".generate_pybind_exe",
main = "pybind_on_build_gen_shim.py",
Expand All @@ -34,7 +37,7 @@ def generate_robotpy_source_files(
gen_dir = "_gen_on_build",
headers = headers,
gen_files = "gen_files",
project_name = name,
project_name = project_name,
internal_project_dependencies = internal_project_dependencies,
)

Expand Down
4 changes: 3 additions & 1 deletion rules_robotpy_utils/pybind_rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def create_pybind_library(
extra_hdrs = [],
deps = [],
entry_point = [],
local_defines = [],
extension_visibility = None):
rpy_include_libs = [generation_helper_prefix + "_rpy_includes"]
generated_srcs = [generation_helper_prefix + "_generated_sources"]
Expand All @@ -34,7 +35,7 @@ def create_pybind_library(
"@rules_bzlmodrio_toolchains//constraints/is_roborio:roborio": ["@platforms//:incompatible"],
"//conditions:default": [],
}),
local_defines = ["RPYBUILD_MODULE_NAME=_{}".format(name), "PYBIND11_DETAILED_ERROR_MESSAGES=1"],
local_defines = local_defines + ["RPYBUILD_MODULE_NAME=_{}".format(name), "PYBIND11_DETAILED_ERROR_MESSAGES=1"],
defines = ["PYBIND11_USE_SMART_HOLDER_AS_DEFAULT=1"],
strip_include_prefix = strip_include_prefix,
includes = includes,
Expand Down Expand Up @@ -78,6 +79,7 @@ def create_pybind_library(
name = name + ".pyso",
actual = select({
"@rules_bazelrio//conditions:windows": name + ".win_pyd",
"//conditions:default": "_{}.so".format(name),
}),
visibility = extension_visibility,
)
Expand Down

0 comments on commit b1769d9

Please sign in to comment.