Skip to content

Commit

Permalink
Update template
Browse files Browse the repository at this point in the history
  • Loading branch information
ThirdEyeSqueegee committed Oct 14, 2023
1 parent 1d41762 commit 02c2d2e
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 2 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ A python script, `project_setup.py`, is provided which automates several houseke
3. Choose how to consume CommonLibSF
1. Press `Enter` to use the default of consuming CommonLibSF via vcpkg
2. Enter `y` to consume CommonLibSF as a git submodule instead
4. Enter your project name (in CamelCase)
4. To use a local fork of CommonLibSF instead of the vcpkg port or a git submodule:
1. Create a Windows environment variable called `CommonLibSFPath` that points to your local fork of CommonLibSF
2. Enter `y` when the setup script asks if you'd like to use a local fork
5. Enter your project name (in CamelCase)

## Building your project

Expand Down
40 changes: 39 additions & 1 deletion project_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,45 @@
cwd = os.path.dirname(os.path.abspath(__file__))

if not use_submodule:
print("Using vcpkg port...\n")
use_local_fork_input = input("Use local fork? (y/n): ")
use_local_fork = (
False
if not use_local_fork_input
else (True if use_local_fork_input.lower() == "y" else False)
)
if use_local_fork:
print(
"NOTE: Remember to create an environment variable called CommonLibSFPath which points to your local fork\n"
)
with open(
os.path.join(cwd, "CMakeLists.txt"), "r", encoding="utf-8"
) as cmakelists_file:
cmakelists = cmakelists_file.read()

cmakelists = cmakelists.replace(
"find_package(CommonLibSF CONFIG REQUIRED)",
'add_subdirectory("$ENV{CommonLibSFPath}" CommonLibSF)\n'
'include("$ENV{CommonLibSFPath}/CommonLibSF/cmake/CommonLibSF.cmake")',
)

with open(
os.path.join(cwd, "CMakeLists.txt"), "w", encoding="utf-8"
) as cmakelists_file:
cmakelists_file.write(cmakelists)

with open(
os.path.join(cwd, "vcpkg.json"), "r", encoding="utf-8"
) as vcpkg_json_file:
vcpkg_json = json.load(vcpkg_json_file)

vcpkg_json["dependencies"] = ["simpleini", "spdlog", "xbyak"]

with open(
os.path.join(cwd, "vcpkg.json"), "w", encoding="utf-8"
) as vcpkg_json_file:
json.dump(vcpkg_json, vcpkg_json_file, indent=2)
else:
print("Using vcpkg port...\n")
else:
print("Using git submodule...\n")
subprocess.run(
Expand Down

0 comments on commit 02c2d2e

Please sign in to comment.