Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
122 views

Build Tools - Notes

The document discusses various build tools used for C/C++ and Java projects. It explains that Makefiles are used to generate executables from C/C++ source code, while ANT and Maven are build tools for Java projects. It also discusses key concepts like build vs release, patch builds vs load builds, and the directory structure and lifecycle of Maven projects.

Uploaded by

Rakeshdevang
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
122 views

Build Tools - Notes

The document discusses various build tools used for C/C++ and Java projects. It explains that Makefiles are used to generate executables from C/C++ source code, while ANT and Maven are build tools for Java projects. It also discusses key concepts like build vs release, patch builds vs load builds, and the directory structure and lifecycle of Maven projects.

Uploaded by

Rakeshdevang
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Build Tools

 Makefile  c and c++


 ANT or Maven  java
 c/c++ makeexecutable format (.exe)
 java ANT or Maven jar/war/ear

 compilers we use
 gcc-c
 g++-c++
 javac-java

 Makefile or makefile
It is used to generate executable from c and c++ source code.
 Syntax
Target: dep1 dep2 dep3
<TAB>system commands
Suppose there are 3 .c files you need to build .exe for those
Abc.exe:f1.o f2.o f3.o
<TAB>gcc –o abc.exe f1.o f2.o f3.o
F1.o:f1.c
<TAB>gcc –c f1.c
F2.o:f2.c
<TAB>gcc –c f2.c
F3.o:f3.c
<TAB>gcc –c f3.c

 Makefile
Abc.exe:big.o facr.o rev.o
<TAB>gcc –o abc.exe big.o facr.o rev.o
big.o:big.c
<TAB>gcc –c big.c
facr.o:facr.c
<TAB>gcc –c facr.c
rev.o:rev.c
<TAB>gcc –c rev.c

Build Tools Page 1


 Build
Is a executable or binary file, but not yet released to a testing team.

Is a untested build.

We deliver build to a testing team, not to a customer.


 Release
It is a tested build, which is ready to release to a customer.
 ANT
When I run ANT, it looks build.xml
 Maven
When I run maven, it looks pom.xml
 Hooks
.git hooks 2 sub topics. 1) pre commit 2)post commit

You need to trigger some task or action before commit or after commit, we go for hooks.

 Difference between git and cvs (other version control tool)


 Git
 Is a distributed version control system
 It means whole repository will be there in the local workspace
 If I want to go previous version of file, I can go directly in local workspace itself.
 Git has many advanced features like rebase,fetch,stash,merge etc.
 These advance features are not there in CVS.
 CVS
 Is a centralized repo and also SVN also.
  If I want to goto previous version of a file, I need to checkout from
centralised_repo because initially it will have only one version of a file in local repo.

 Makefile

Build Tools Page 2


 Works on time stamp basis, if target time is less than the dependencies time it will re-
generate the target, that means makefile will compare target time with its dependencies
time.
 If target time is latest than its dependencies it will not re-generate the target.
 If there are thousand files, if I change 5 files, only 5 files will get compiled and
incorporated at the build.
 Patch Build

 It is a critical fix which needs to be deliver to a customer within few hours. Developers
will change only required files, make will compile only changed files and changes will
get incorporated to the build so patch build will take less time.

 Load build
 We compile source code from the scratch, before we start this build we delete all
intermediate files (.o files), so that all files will get compile from scratch. So it take more
time.
 Which make
 Which gcc
 Mkdir srccode
 Vi big3.c
 Vi fact.c
 Vi main.c
Main () { fact(); big3(); }
 Vi makefile

1. Example code
Abc:main.o fact.o big3.o
Gcc –o abc main.o fact.o big3.o
Main.o:main.c
Gcc –c main.c
Fact.o:fact.c
Gcc –c fact.c
Big3.o:big3.c
Gcc –c big3.c
make

 The target file abc.exe will get created


 You can executed ./abc to get output of all files.
 You can add the files and related syntax in makefile.
 Even you can give your own makefile name as pradeepmakefile,but while making, you
should use,

Build Tools Page 3


• Make –f pradeepmakefile and while creating makefile use vi pradeepmakefile.
 If you want to remove .o and .exe
• Rm –rf *.o *.exe
o Vi makefile

2. Example code
Abc:main.o fact.o big3.o
Gcc –o abc main.o fact.o big3.o
Main.o:main.c
Gcc –c main.c
Fact.o:fact.c
Gcc –c fact.c
Big3.o:big3.c
Gcc –c big3.c
Clean:
Rm –rf *.o

While making, try Make clean It will remove all .o files.

 Branching Strategy or explain branching strategy in your company, explain which u


know?
 Branches can be created for multiple reasons, here we create branches for releases.
 Development team will be going on development branch, once the code is ready for the
first release, we create a release1 branch from dev branch and we make a release ( we do
build and release it) from this release1 branch.
 Whatever the issues specific to this release will be foxed on release1 brnach only. It will
act as a maintenance branch for release1.
 Simultaneously development will be going on dev branch for 2nd release. Once the code
is ready for 2nd releasebefore we create a branch for 2nd release, we merge, release 1
branch to dev branch and then we create release2 branch for dev branch for 2nd release.
 So whatever the issues we have seen in 1sr release should not be visible in the 2nd
release and so on.
 Buildbuild successBVT or sanity testsanity reportrelease notetest team
 Buildbuild faildev team

 BVT(build verification test) or sanity test.


 Is a basic functionality of a build which should never break.
 Sanity report.
 Is a report related to testing and should checkbox for test.
 Release note
  Tag name and description and known issues.

Build Tools Page 4


 Branch strategy example 2

 We have 2 branches, one is dev branch another one is master or production branch,
developers are allowed to commit changes on dev branch.
 Once developers commits the code on dev branch. We build it, we do sanity or BVT and
we release to a testing team.
 We merge this code to production branch. If the build is failed after developer commits
the changes, we don‘t merge the code from dev branch to production branch. We work
with development team to fix the issue.
 So we always merge good code to productive branch so that production branch will have
clean working branch always.
 If developer needs latest good code they can pull it from production branch, but they
can’t push it to production branch, because git push is restricted.

 Explain Maven build lifecycle?

 Maven is a project management tool which can manage complete build life cycle.
 Maven simplifies and standardizes the project build process.

Build process will be


o compile
o testing
o library dependency
o distribution
o documentation
o deployment

 maven - POM.xml (POM - Project Object Model)


 ant - build.xml

 Directory structure of maven


- src
- main (root directory for source code related application .java file)
- java (all source code of java files of main dir)
- resources (dependency libraries(jar files))
- webapp
- test (Test directory contains test code(Junit) related to your source code)
- java (all test code of java files of test dir)
- resources

- target (compiled output of source code Jar/War/Ear)

Build Tools Page 5


 mvn clean
 It will command will delete/clean target directory
 Note: If run run maven build without mvn clean command, it will generate target only
for newly added file called "Patch build".
 Which we use for the code in testing phase.

 Maven build life cycle


A build lifecyle is a sequence of task used to build the application.
1. Validate - validate the project is correct and all the necessary information is available.
2. Compile - compiles the source code and create obeject code in target folder.
3. Test - Test the compiled source code using unit testing (JUnit)
4. Package - All the compiled code is packages in to distribution format which is jar, war
and ear.
5. integration-test - deploy the package/build/artifact into an environment where
integration-test can be executed
6. Verify - verify the package is valid and it meets the configured criteria or not.
7. Install - install/copy the package into the local repository.
8. Deploy - If configured, deploy the application/build to integration or releqse
environment.

 Maven repository
Maven repository is a directory to store all the project jars, libraries, plugins and any artifacts
related to project.
1. Local Repository
 Is a local folder/directory on your machine (where we have installed or running
maven)
 The default location of maven local repository is HOME_DIRECTORY/.m2
directory
 .m2 is created whenever we run mvn command for the first time.

2. Central Repository
 Maven central repository is managed by maven community and it contains large
number commonly used libraries.
 We can also publish our own libraries to central repository.
 The default location is https://repo1.maven.org/maven2

Build Tools Page 6


3. Remote Repository
 A maven repository setup inside a company or a project related repository but not
public.
 This is a company maintained repository which can be accessed only inside the
company network.

 Maven dependency Search sequence


1. Search in local repo.
2. Search in central repo.
3. Search in remote repo.
Maven stops searching once it finds the library.

 Maven and ANT difference?

Ant Maven
Ant doesn't has formal Maven has a convention to place
conventions, so we need to provide source code, compiled code etc. So
information of the project structure we don't need to provide
in build.xml file. information about the project
structure in pom.xml file.
Ant is procedural, you need to Maven is declarative, everything
provide information about what to you define in the pom.xml file.
do and when to do through code.
You need to provide order.
There is no life cycle in Ant. There is life cycle in Maven.
It is a tool box. It is a framework.
It is mainly a build tool. It is mainly a project management
tool.
The ant scripts are not reusable. The maven plugins are reusable.
It is less preferred than Maven. It is more preferred than Ant.

Build Tools Page 7

You might also like