[Android] Calin:
Android Build

​

So guys are you ready for the modifications?

Well, let's begin...

If you understood the last posts then you should be ready because now we will gonna work on the android_build files.

But what is android_build?

Android build is that Repo that includes all the files necessary in order to make the compilation, don't get me wrong i mean it doesn't include all the files for the compilation but includes the files which includes all the commands and strings necessary for the compilation.

So first thing to do is to fork this repo.

As in the previous post you need to go on the CM repo and to fork the android_build to your ROM organization.

And finally clone it to your computer.

So what you can modify here?

Well quite a lot of things because you can eliminate the CM name almost completely and to include your ROM name instead.

So the first file we will gonna take is the Makefile which is situated in the core folder.

So what we gonna need to modify here?

Here we will gonna modify the Target Device name + some more ones...

So first search this line:

CM_DEVICE

And change it with YourROMname_DEVICE

Done !

Now the second one is:

CM_BUILD

In the same way change the CM with your ROM name.

Now go and find these lines:

CM_TARGET_PACKAGE
CM_VERSION

In the same way change the CM with your ROM name.

On the same line which is this:

CM_TARGET_PACKAGE := $(PRODUCT_OUT)/cm-$(CM_VERSION).zip

Change also the red marked cm with your ROM name.

Now, go and find these lines:

.PHONY: otapackage bacon
CM_TARGET_PACKAGE

Ok so bacon agaain to be changed with your ROM name, and the same also for the Target Package

Tip!

That's only if want to....

If you want to include a cool banner with ascii art when the ROM has finished the compilation you can include one:

To generate strings with ascii art go HERE

Choose your prefered one and copy it.

Now go to this line:

@echo -e ${CL_CYN}"Package Complete:

Right after the line paste the generated ascii string.

But make sure to add also this little entry in order to print it in terminal:

@echo -e $(CL_CYN)

And add it for each line.

If you want to change the color of the line (cause now the color is the Cyano one)

You can choose from these ones:

@echo -e $ (CL_RED)
@echo -e $ (CL_GRN)
@echo -e $ (CL_YLW)
@echo -e $ (CL_BLU)
@echo -e $ (CL_MAG)
@echo -e $ (CL_CYN)
@echo -e $ (CL_RST)

This is just for personalize a bit your build environment :p

So this is it!

The Makefile is now modified and ready to be commited.

Now let's move to: config.mk which is situated still in the core folder.

Here we only need to modify one string:

ifneq ($(CM_BUILD),)

In the same way change the CM name with your ROM name.

Done !

Now let's move on dumpvar.mk which is also situated in the core folder.

If you are a maintainer you will for sure asking that i seen these lines before,

Yes you are correct!

Those lines are used to display the Compiling Info before the start process.

And those are displayed when you lunch the command: breakfast or of course brunch.

So why we are here?

We are here to change the ROM Version which it will be displayed so because in the Makefile we changed the CM_VERSION with our ROM name we need to change it also here.

Tip!

These lines are not necessary, so they can be deleted

ifeq ($(CYNGN_TARGET),true)
$(info CYNGN_TARGET=$(CYNGN_TARGET))
$(info CYNGN_FEATURES=$(CYNGN_FEATURES))
endif

So we are also done here. Now let's move on product_config.mk and envsetup.sh

Here we will change the mode about how the Compilation environment will recognize your device.

If you are a maintainer and you compiled Slim ROM or OmniROM, you will for sure notice that you need to change the cm.mk file from your device propper files with the name of the ROM for example if you want to compile SlimRom you need to change the cm.mk to slim.mk and so go on...

Soooo that's what we will gonna do.

First take the product_config.mk file located in teh core folder :

And now find these lines:

# A CM build needs only the CM product makefiles.
ifneq ($(CM_BUILD),)
all_product_configs := $(shell ls device/*/$(CM_BUILD)/cm.mk)

Now change the CM name with your ROM name (as always)

Now find this string:

CM_BUILD

And change it with your ROM name.

The same also for the next line.

Ok, so now we are done with the product_config.mk file so let's witch now on the envsetup.sh one:

Find this line:

if (echo -n $1 | grep -q -e "^cm_") ; then

Ok, now change the all the cm names with your ROM Name (as usual), after go and find this line:

CM_BUILD=

Change it as usual, the same also for the next one.

Now find this line:

if [ "z${CM_DEVICES_ONLY}" != "z" ]; then

And change it as usual. The same also for the upcoming one after 10 strings.

Again, find the bacon string and change it with your ROM Name.

Now find this line:

CM_DEVICES_ONLY

And change it as usual.

Now, go and find this line:

lunch cm_$target-$variant

And also this one change it as usual.

Now, find these lines:

MODVERSION=$(get_build_var CM_VERSION)

ZIPFILE=cm-$MODVERSION.zip

And change them as usual.

Don't worry we are nearly to the end.

The last strings which need to be modify at least are:

ro.cm.device=$CM_BUILD
CM_BUILD

So make CTRL F and search for those lines and change them with your ROM name.

So boom! Now when you will gonna compile for your device you will no longer see the CM name on it, of course that now you will need to change also the cm.mk name with your ROMName.mk situated in your Device common files.

Another thing which you can do is to add the dependencies which are an extra part and they will be explained in the Extra Part post.

Now close the two files and go and open buildinfo.sh which is situated in tools folder.

Now go and find this string:

echo "ro.cm.device=$CM_DEVICE"

Also here change it as we did in the lasts two files.

Close it, and now the last file which we will gonna modify is: roomservice.py which is situated in the tools folder.

So what this file do actually?

This file together with some others are responsible with the device build. I mean if for some reasons the device which you want to build for, isn't present in your local repo the build environment will automatically go and search in your ROM Organization (fetch) if there is such a device, so because we don't want that the build environment search in the CM Repo we need to change this file in order to search in your ROM Repo.

So first find this line:

githubreq = urllib.request.Request("https://api.github.com/search/repositories?q=%s+user:CyanogenMod+in:name+fork:true" % device)

And change the user with the ROM of the Organization from Github (exactly)

Now search for this line:

dependencies_path = repo_path + '/cm.dependencies'

And change the cm name with your ROM name (please make the ROM Name all lowercase to avoid confusion)

Now for the rest just search:

CM
CyanogenMod

And change it as we did earlier (your ROM Name)

So we finally done !

The build files are now modified and ready to be commited on Github, now when you will compile the ROM for your device you will not see anymore the CM Name :)