Skip to content

Commit

Permalink
Add windows precompiled binary workflow and shared library to pre-com…
Browse files Browse the repository at this point in the history
…piled binary archive (#1686)

* Add windows precompiled binary workflow

* Normalize header paths parsed from the C++ files

On windows the headers may get added to the map with both types of path separators,
resulting in duplicated code in the merged header file.

* Use the basename of the parsed header files when sorting header dependencies
  • Loading branch information
benjaminwinger committed Jun 19, 2023
1 parent d7c2cab commit 4e3e9a7
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 19 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/windows-precompiled-bin-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Build-Windows-Precompiled-Binaries

on:
workflow_dispatch:
inputs:
packageVersion:
description: "Version of output package"
required: true
default: "0.0.1"

env:
PACKAGE_VERSION: ${{ github.event.inputs.packageVersion }}

jobs:
build-precompiled-bin:
runs-on: self-hosted-windows
steps:
- uses: actions/checkout@v3

- name: Install networkx
run: python.exe -m pip install networkx --user

- name: Build precompiled binaries
run: python.exe build.py
working-directory: ./scripts/pre-compiled-bins/

- uses: actions/upload-artifact@v3
with:
name: libkuzu-${{ github.event.inputs.packageVersion }}-windows-x86_64
path: |
./scripts/pre-compiled-bins/kuzu.h
./scripts/pre-compiled-bins/kuzu.hpp
./scripts/pre-compiled-bins/kuzu_shared.dll
./scripts/pre-compiled-bins/kuzu_shared.lib
- uses: actions/upload-artifact@v3
with:
name: kuzu_cli-${{ github.event.inputs.packageVersion }}-windows-x86_64
path: ./scripts/pre-compiled-bins/kuzu.exe

- name: Clean up
run: rm -rf ./scripts/pre-compiled-bins/kuzu ./scripts/pre-compiled-bins/headers ./scripts/pre-compiled-bins/kuzu_shared.dll ./scripts/pre-compiled-bins/kuzu_shared.lib ./scripts/pre-compiled-bins/kuzu.h ./scripts/pre-compiled-bins/kuzu.hpp
56 changes: 39 additions & 17 deletions scripts/pre-compiled-bins/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,23 +102,45 @@ def collect_binaries():
sys.exit(1)
shutil.copy(c_header_path, os.path.join(base_dir, "kuzu.h"))
logging.info("Copied kuzu.h")
so_exists = os.path.exists(so_path)
dylib_exists = os.path.exists(dylib_path)
if not so_exists and not dylib_exists:
logging.error("No shared object file found")
sys.exit(1)
if so_exists:
shutil.copy(so_path, os.path.join(base_dir, "libkuzu.so"))
logging.info("Copied libkuzu.so")
if dylib_exists:
shutil.copy(dylib_path, os.path.join(base_dir, "libkuzu.dylib"))
logging.info("Copied libkuzu.so")
shell_path = os.path.join(workspace_root, "build",
"release", "tools", "shell", "kuzu_shell")
if not os.path.exists(shell_path):
logging.error("No shell binary found")
sys.exit(1)
shutil.copy(shell_path, os.path.join(base_dir, "kuzu"))
if sys.platform == "win32":
dll_path = os.path.join(workspace_root, "build",
"release", "src", "kuzu_shared.dll")
lib_path = os.path.join(workspace_root, "build",
"release", "src", "kuzu_shared.lib")
if not os.path.exists(dll_path):
logging.error("No dll found")
sys.exit(1)
if not os.path.exists(lib_path):
logging.error("No import library found")
sys.exit(1)
shutil.copy(dll_path, os.path.join(base_dir, "kuzu_shared.dll"))
logging.info("Copied kuzu_shared.dll")
shutil.copy(lib_path, os.path.join(base_dir, "kuzu_shared.lib"))
logging.info("Copied kuzu_shared.lib")
shell_path = os.path.join(workspace_root, "build", "release",
"tools", "shell", "kuzu_shell.exe")
if not os.path.exists(shell_path):
logging.error("No shell binary found")
sys.exit(1)
shutil.copy(shell_path, os.path.join(base_dir, "kuzu.exe"))
else:
so_exists = os.path.exists(so_path)
dylib_exists = os.path.exists(dylib_path)
if not so_exists and not dylib_exists:
logging.error("No shared object file found")
sys.exit(1)
if so_exists:
shutil.copy(so_path, os.path.join(base_dir, "libkuzu.so"))
logging.info("Copied libkuzu.so")
if dylib_exists:
shutil.copy(dylib_path, os.path.join(base_dir, "libkuzu.dylib"))
logging.info("Copied libkuzu.so")
shell_path = os.path.join(workspace_root, "build",
"release", "tools", "shell", "kuzu_shell")
if not os.path.exists(shell_path):
logging.error("No shell binary found")
sys.exit(1)
shutil.copy(shell_path, os.path.join(base_dir, "kuzu"))
logging.info("Copied kuzu")
logging.info("Binaries collected")

Expand Down
2 changes: 1 addition & 1 deletion scripts/pre-compiled-bins/collect_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def collect_header_file_path_recurse(start_point):
for line in f.readlines():
if not line.startswith('#include "'):
continue
header_path = line.split('"')[1]
header_path = os.path.normpath(line.split('"')[1])
header_real_path = None
# Special case for json_fwd.hpp
if header_path == 'json_fwd.hpp':
Expand Down
2 changes: 1 addition & 1 deletion scripts/pre-compiled-bins/merge_headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def build_dependency_graph():
for line in f.readlines():
if not line.startswith('#include "'):
continue
contained_header_name = line.split('"')[1]
contained_header_name = Path(line.split('"')[1]).name
graph.add_edge(header_name, contained_header_name)
return graph

Expand Down

0 comments on commit 4e3e9a7

Please sign in to comment.