[OnePlus X Q&A, Help & Troubleshooting] Fap4k:
HI OnePlus X users, I know there are some thread about the same..but they are almost dead and the OP of that threads are busy in some other project like AOSP N (7.0),CM 14 ect..so i took an initiative to work on MIUI 8 (6.0.1).and working on it from last few days.

there is a build from a chinese dev shumxin which is out a day before.you can find that thread here

http://xdaforums.com/oneplus-x/general/rom-miui-8-oneplus-x-ported-shumxin-t3479012

So come to the point I started working on MIUI patchrom project and took a oxygenOS 3.1.3 as base so started here

first command for building and results

PATCHROM_BRANCH = marshmallow
ANDROID_PLATFORM = 23
PORT_ROOT = /home/faa/patchrom
ANDROID_TOP =
ANDROID_OUT =
PORT_PRODUCT = Unknown
USE_ANDROID_OUT =
ANDROID_BRANCH =
HOST_OS = linux

After that command for patching OxygenOS 3.1.3 framework to work with MIUI 8

faa@faa-MS-7592 ~/patchrom/onyx $ make firstpatch
/home/faa/patchrom/tools/patch_miui_framework.sh /home/faa/patchrom/android/base-framework /home/faa/patchrom/android `pwd`
<<< create temp directory to store the old, new source and destination smali code with .line removed
<<< compute the difference between /home/faa/patchrom/onyx/temp/old_smali/framework.jar.out and /home/faa/patchrom/onyx/temp/new_smali/framework.jar.out
<<< apply the patch into the /home/faa/patchrom/onyx/framework.jar.out
patching file /home/faa/patchrom/onyx/framework.jar.out/./smali/android/content/pm/PackageParser.smali
Hunk #1 succeeded at 9781 (offset 121 lines).
Hunk #2 succeeded at 9793 (offset 121 lines).
patching file /home/faa/patchrom/onyx/framework.jar.out/./smali/android/content/res/Resources.smali
Hunk #3 succeeded at 4580 (offset 53 lines).
patching file /home/faa/patchrom/onyx/framework.jar.out/./smali/android/app/ResourcesManager.smali
Hunk #1 FAILED at 213.
Hunk #2 succeeded at 1908 (offset 922 lines).
1 out of 2 hunks FAILED -- saving rejects to file /home/faa/patchrom/onyx/temp/reject/framework.jar.out/./smali/android/app/ResourcesManager.smali.rej
patching file /home/faa/patchrom/onyx/framework.jar.out/./smali/android/app/SystemServiceRegistry.smali
patching file /home/faa/patchrom/onyx/framework.jar.out/./smali/android/graphics/Bitmap.smali
patching file /home/faa/patchrom/onyx/framework.jar.out/./smali/com/android/internal/os/ZygoteInit.smali
Hunk #1 FAILED at 347.
patch: **** Can't reopen file /home/faa/patchrom/onyx/framework.jar.out/./smali/com/android/internal/os/ZygoteInit.smali : No such file or directory
<<< compute the difference between /home/faa/patchrom/onyx/temp/old_smali/services.jar.out and /home/faa/patchrom/onyx/temp/new_smali/services.jar.out
<<< apply the patch into the /home/faa/patchrom/onyx/services.jar.out
patching file /home/faa/patchrom/onyx/services.jar.out/./smali/com/android/server/wm/WindowManagerService.smali
Hunk #1 FAILED at 708.
1 out of 1 hunk FAILED -- saving rejects to file /home/faa/patchrom/onyx/temp/reject/services.jar.out/./smali/com/android/server/wm/WindowManagerService.smali.rej
patching file /home/faa/patchrom/onyx/services.jar.out/./smali/com/android/server/am/ActivityStack.smali
Hunk #1 FAILED at 6636.
1 out of 1 hunk FAILED -- saving rejects to file /home/faa/patchrom/onyx/temp/reject/services.jar.out/./smali/com/android/server/am/ActivityStack.smali.rej
patching file /home/faa/patchrom/onyx/services.jar.out/./smali/com/android/server/am/ActivityManagerService.smali
Hunk #1 succeeded at 94288 with fuzz 1 (offset 11309 lines).
patching file /home/faa/patchrom/onyx/services.jar.out/./smali/com/android/server/SystemServer.smali
Hunk #1 succeeded at 197 (offset 55 lines).
patching file /home/faa/patchrom/onyx/services.jar.out/./smali/com/android/server/policy/PhoneWindowManager.smali
Hunk #1 succeeded at 484 (offset 21 lines).
<<< compute the difference between /home/faa/patchrom/onyx/temp/old_smali/telephony-common.jar.out and /home/faa/patchrom/onyx/temp/new_smali/telephony-common.jar.out
<<< apply the patch into the /home/faa/patchrom/onyx/telephony-common.jar.out
<<< compute the difference between /home/faa/patchrom/onyx/temp/old_smali/wifi-service.jar.out and /home/faa/patchrom/onyx/temp/new_smali/wifi-service.jar.out
mv: cannot stat '/home/faa/patchrom/onyx/wifi-service.jar.out': No such file or directory
cp: cannot stat '/home/faa/patchrom/onyx/temp/dst_smali_orig/wifi-service.jar.out': No such file or directory
<<< apply the patch into the /home/faa/patchrom/onyx/wifi-service.jar.out
cp: cannot stat '/home/faa/patchrom/onyx/wifi-service.jar.out': No such file or directory
/home/faa/patchrom/tools/patch_miui_framework.sh: line 69: cd: /home/faa/patchrom/onyx/temp/dst_smali_orig/wifi-service.jar.out: No such file or directory

>>> patch miui into target framework is done. Please look at /home/faa/patchrom/onyx/temp/reject to resolve any conflicts!

After that got very few rejects(about 3-5) in temp/reject folder which I fixed(may be not) by following this thread

http://xdaforums.com/chef-central/android/guide-patchrom-rejects-fixing-tutorial-t3203287