-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New Project generation feature #124
Merged
Merged
Changes from 10 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
71b8b02
Added minimal project generation
thomas-bc 9e76bae
Print instructions
thomas-bc 4941852
Process tags + lots of changes
thomas-bc e1adc8c
Return gracefully instead of sys.exit
thomas-bc d707ad5
require Git to run new project
thomas-bc 37cc5d6
path override and help text
thomas-bc 8127d4c
formatting
thomas-bc c0abe41
how is "website" not in the default dictionary ?
thomas-bc dc344b2
sp
thomas-bc d879936
Adding project.cmake
thomas-bc c96cbc7
Review changes
thomas-bc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 %}" | ||
} |
104 changes: 104 additions & 0 deletions
104
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,104 @@ | ||
""" | ||
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 | ||
available_tags = ( | ||
subprocess.run(["git", "tag", "-l"], cwd="./fprime", capture_output=True) | ||
.stdout.decode("utf-8") | ||
.split() | ||
) | ||
if "{{cookiecutter.fprime_branch_or_tag}}" in available_tags: | ||
res = subprocess.run( | ||
["git", "checkout", "tags/{{cookiecutter.fprime_branch_or_tag}}"], | ||
cwd="./fprime", | ||
capture_output=True, | ||
) | ||
print( | ||
"[INFO] F' submodule checked out to tag: {{cookiecutter.fprime_branch_or_tag}}" | ||
) | ||
else: | ||
res = subprocess.run( | ||
["git", "checkout", "{{cookiecutter.fprime_branch_or_tag}}"], | ||
cwd="./fprime", | ||
capture_output=True, | ||
) | ||
print( | ||
"[INFO] F' submodule checked out to branch: {{cookiecutter.fprime_branch_or_tag}}" | ||
) | ||
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}") | ||
|
||
# Install Venv | ||
if "{{cookiecutter.install_venv}}" == "yes": | ||
Check warning Code scanning / CodeQL Comparison of constants
Comparison of constants; use 'True' or 'False' instead.
|
||
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 | ||
Windows: venv\Scripts\\activate.bat | ||
thomas-bc marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
-- Generate a new component -- | ||
fprime-util new --component | ||
|
||
-- Generate a new deployment -- | ||
fprime-util new --deployment | ||
|
||
-- Run the base deployment -- | ||
thomas-bc marked this conversation as resolved.
Show resolved
Hide resolved
|
||
cd <DeploymentName> | ||
fprime-util generate | ||
fprime-util build | ||
fprime-gds | ||
|
||
################################################################ | ||
""" | ||
) | ||
|
||
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check warning
Code scanning / CodeQL
Constant in conditional expression or statement