An Interest In:
Web News this Week
- March 20, 2024
- March 19, 2024
- March 18, 2024
- March 17, 2024
- March 16, 2024
- March 15, 2024
- March 14, 2024
How to become more productive using Makefile
Originally posted on my blog
Introduction
You want to become more productive, automate your workflow, there are many tools to help you achieve your goal.
make gives you the flexibility to run and compile a program from source.
In this guide, we will use it to automate our development workflow.
Note: I will use Django as an example, but the technics are applicable to other technologies.
In this guide, I will use Makefile to automate many things in Django like database migration, superuser, deployment, and more.
At the end of the guide, you'll be more productive in your development.
Before you continue, ensure that make is installed in your system.
Installation
In Order to use make we need two(2) things one(1) we need to install it in our system and finally we need to create a file called Makefile.
To install make in your system you can follow these links :
OSX
Windows
Basic examples
To explore make let's begin with this simple program, go to any directory, and create a Makefile.
Note: Don't give it an extension.
$ mkdir test_make && cd test_make$ touch Makefile
Open the file with your text editor and put this
say_hello: echo "Hello world"
run the file by typing make inside the directory test_make
$ make
What is the output?
Here is what I get.
echo "Hello world"Hello world
Django integration
If you're a Django developer, you know how tedious is to repeat again and again these commands :
python manage.py runserverpython manage.py makemigrationspython manage.py migrate...
Let's automate them with make
Clone the example project here and follow the README guide.
git clone https://github.com/xarala221/consume-restfull-api-with-django && cd consume-restfull-api-with-django
Run the application to ensure that everything is working fine.
python manage.py migratepython manage.py runserver
Open your browser and go to http://localhost:8000.
Inside the project, folder created a file called Makefile and add these lines.
touch Makefile
The final file will look like this
SHELL := /bin/bashhelp: @$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$'install: pipenv installactivate: pipenv shellrun: python manage.py runservermigration: python manage.py makemigrationsmigrate: python manage.py migratesuperuser: python manage.py createsuperuserheroku: git push heroku masterdeploy: docker-compose build docker-compose up -ddown: docker-compose down
you'll be more productive with these tips.
Conclusion
Become more productive and make things done is very important, in this guide you've learned how to automate your workflow by using make.
What do you think about this? Let us know in the comment section.
Original Link: https://dev.to/xarala221/how-to-become-more-productive-using-makefile-579b
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To