-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New Project generation feature (#124)
* Added minimal project generation * Print instructions * Process tags + lots of changes * Return gracefully instead of sys.exit * require Git to run new project * path override and help text * formatting * how is "website" not in the default dictionary ? * sp * Adding project.cmake * Review changes
- Loading branch information
Showing
11 changed files
with
173 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -265,6 +265,7 @@ vals | |
venv | ||
versioning | ||
viewcode | ||
Website | ||
whitelist | ||
whitespaces | ||
workdir | ||
|
6 changes: 6 additions & 0 deletions
6
src/fprime/cookiecutter_templates/cookiecutter-fprime-project/cookiecutter.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"project_name": "MyProject", | ||
"fprime_branch_or_tag": "devel", | ||
"install_venv": ["yes", "no"], | ||
"venv_install_path": "{% if cookiecutter.install_venv == 'yes' %}./venv{% else %}None{% endif %}" | ||
} |
82 changes: 82 additions & 0 deletions
82
src/fprime/cookiecutter_templates/cookiecutter-fprime-project/hooks/post_gen_project.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
""" | ||
This script is run as a cookiecutter hook after the project is generated. | ||
""" | ||
|
||
import subprocess | ||
|
||
DEFAULT_BRANCH = "devel" | ||
|
||
# Add F' as a submodule | ||
subprocess.run(["git", "init"]) | ||
subprocess.run( | ||
[ | ||
"git", | ||
"submodule", | ||
"add", | ||
"-b", | ||
DEFAULT_BRANCH, | ||
"https://github.com/nasa/fprime.git", | ||
] | ||
) | ||
|
||
# Checkout requested branch/tag | ||
res = subprocess.run( | ||
["git", "checkout", "{{cookiecutter.fprime_branch_or_tag}}"], | ||
cwd="./fprime", | ||
capture_output=True, | ||
) | ||
if res.returncode != 0: | ||
print( | ||
"[WARNING] Unable to checkout branch/tag: {{cookiecutter.fprime_branch_or_tag}}" | ||
) | ||
print(f"[WARNING] Reverted to default branch: {DEFAULT_BRANCH}") | ||
else: | ||
print( | ||
"[INFO] F' submodule checked out to branch/tag: {{cookiecutter.fprime_branch_or_tag}}" | ||
) | ||
|
||
# Install venv if requested | ||
if "{{cookiecutter.install_venv}}" == "yes": | ||
subprocess.run(["python", "-m", "venv", "{{cookiecutter.venv_install_path}}"]) | ||
subprocess.run( | ||
[ | ||
"{{cookiecutter.venv_install_path}}/bin/pip", | ||
"install", | ||
"-r", | ||
"fprime/requirements.txt", | ||
] | ||
) | ||
|
||
print( | ||
""" | ||
################################################################ | ||
Congratulations! You have successfully created a new F' project. | ||
A git repository has been initialized and F' has been added as a | ||
submodule, you can now create your first commit. | ||
Get started with your F' project: | ||
-- Activate the virtual environment -- | ||
Linux/MacOS: source venv/bin/activate | ||
-- Generate a new component -- | ||
fprime-util new --component | ||
-- Generate a new deployment -- | ||
fprime-util new --deployment | ||
################################################################ | ||
""" | ||
) | ||
|
||
if res.returncode != 0: | ||
print( | ||
"[WARNING] Unable to checkout branch/tag: {{cookiecutter.fprime_branch_or_tag}}" | ||
) | ||
print(f"[WARNING] Reverted to default branch: {DEFAULT_BRANCH}") | ||
else: | ||
print( | ||
"[INFO] F' submodule checked out to branch/tag: {{cookiecutter.fprime_branch_or_tag}}" | ||
) |
17 changes: 17 additions & 0 deletions
17
...cutter_templates/cookiecutter-fprime-project/{{cookiecutter.project_name}}/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#### | ||
# | ||
#### | ||
cmake_minimum_required(VERSION 3.13) | ||
project({{cookiecutter.project_name}} C CXX) | ||
|
||
### | ||
# F' Core Setup | ||
# This includes all of the F prime core components, and imports the make-system. | ||
### | ||
include("${CMAKE_CURRENT_LIST_DIR}/fprime/cmake/FPrime.cmake") | ||
# NOTE: register custom targets between these two lines | ||
include("${FPRIME_FRAMEWORK_PATH}/cmake/FPrime-Code.cmake") | ||
|
||
|
||
# This includes project-wide objects | ||
include("${CMAKE_CURRENT_LIST_DIR}/project.cmake") |
6 changes: 6 additions & 0 deletions
6
...r_templates/cookiecutter-fprime-project/{{cookiecutter.project_name}}/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# {{cookiecutter.project_name}} F' project | ||
|
||
This project was auto-generated by the F' utility tool. | ||
|
||
F´ (F Prime) is a component-driven framework that enables rapid development and deployment of spaceflight and other embedded software applications. | ||
**Please Visit the F´ Website:** https://nasa.github.io/fprime/. |
2 changes: 2 additions & 0 deletions
2
...ecutter_templates/cookiecutter-fprime-project/{{cookiecutter.project_name}}/project.cmake
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# This CMake file is intended to register project-wide objects so they can be | ||
# reused easily between deployments, but also by other projects. |
3 changes: 3 additions & 0 deletions
3
...iecutter_templates/cookiecutter-fprime-project/{{cookiecutter.project_name}}/settings.ini
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[fprime] | ||
project_root: . | ||
framework_path: ./fprime |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters