Skip to content

Commit 3a0b626

Browse files
committed
Initial commit
0 parents  commit 3a0b626

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+15633
-0
lines changed

LICENSE

Lines changed: 339 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# MCPELinux - 在桌面 Linux 运行 MCPE for Android
2+
3+
## 目录
4+
- [简介](#简介)
5+
- [构建、运行与调试](#构建、运行与调试)
6+
- [许可](#许可)
7+
8+
## 简介
9+
本项目提供一个在桌面 Linux 上运行 MCPE 的环境。与 [mcpelauncher-linux](https://github.com/MCMrARM/mcpelauncher-linux/)
10+
以及 [minecraft-linux](https://github.com/minecraft-linux/) 类似,并参考了其 ABI 差异处理库
11+
[libc-shim](https://github.com/minecraft-linux/libc-shim)
12+
但本项目并*不是*上述项目的分支,相比之下本项目更加简单,实现思路也有所不同。
13+
只能运行 MCPE 0.14 至 1.1 的部分版本。1.2 以后的版本需要正版验证不能运行。
14+
欢迎有志之士折腾。
15+
## 构建、运行与调试
16+
通过 meson 可以轻松构建所有模块,请注意需要使用 i686-linux-gnu- 工具链以编译 32 位程序,需要安装一些 32 位的库如 Mesa,GLFW,libpng 等。
17+
```
18+
cd 本项目源码根目录
19+
meson 你的编译文件夹 --prefix=你的安装前缀 --cross-file=你的交叉编译描述文件
20+
cd 你的编译文件夹
21+
ninja install
22+
```
23+
随便找个文件夹即可,不要用系统目录。
24+
25+
编译完成之后会在`你的安装前缀/bin/`目录下得到一个`main`可执行文件,执行该文件以了解使用方法。其中`-mcpe`选项指定为你的 apk 安装包解压后的根目录。
26+
比如你在`/home/cosine/mcpe`解压了安装包,那么素材文件夹就是`/home/cosine/mcpe/assets`,而`libminecraftpe.so`应该在
27+
`/home/cosine/mcpe/lib/x86/libminecraftpe.so`
28+
29+
gdb 运行 main 之前用 `set solib-search-path <path>` 命令把`libminecraftpe.so`所在目录加进去即可在调试时看到 MCPE 的符号。
30+
## 许可
31+
本项目所有模块以 [GPL v2.0](http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) 授权。
32+
但 aglinker 是修改版的 Bionic libc linker,来自 AOSP,有其自己的许可。

aglinker/Android.mk

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
LOCAL_PATH:= $(call my-dir)
2+
include $(CLEAR_VARS)
3+
4+
ifeq ($(TARGET_ARCH),x86)
5+
linker_begin_extension := c
6+
else
7+
linker_begin_extension := S
8+
endif
9+
10+
LOCAL_SRC_FILES:= \
11+
arch/$(TARGET_ARCH)/begin.$(linker_begin_extension) \
12+
debugger.cpp \
13+
dlfcn.cpp \
14+
linker.cpp \
15+
linker_environ.cpp \
16+
linker_phdr.cpp \
17+
rt.cpp
18+
19+
LOCAL_LDFLAGS := -shared -Wl,--exclude-libs,ALL
20+
21+
LOCAL_CFLAGS += -fno-stack-protector \
22+
-Wstrict-overflow=5 \
23+
-fvisibility=hidden \
24+
-Wall -Wextra -Werror
25+
26+
# We need to access Bionic private headers in the linker.
27+
LOCAL_CFLAGS += -I$(LOCAL_PATH)/../libc/
28+
29+
ifeq ($(TARGET_ARCH),arm)
30+
LOCAL_CFLAGS += -DANDROID_ARM_LINKER
31+
endif
32+
33+
ifeq ($(TARGET_ARCH),x86)
34+
LOCAL_CFLAGS += -DANDROID_X86_LINKER
35+
endif
36+
37+
ifeq ($(TARGET_ARCH),mips)
38+
LOCAL_CFLAGS += -DANDROID_MIPS_LINKER
39+
endif
40+
41+
LOCAL_MODULE:= linker
42+
LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
43+
44+
LOCAL_STATIC_LIBRARIES := libc_nomalloc
45+
46+
#LOCAL_FORCE_STATIC_EXECUTABLE := true # not necessary when not including BUILD_EXECUTABLE
47+
48+
#
49+
# include $(BUILD_EXECUTABLE)
50+
#
51+
# Instead of including $(BUILD_EXECUTABLE), we execute the steps to create an executable by
52+
# hand, as we want to insert an extra step that is not supported by the build system, and
53+
# is probably specific the linker only, so there's no need to modify the build system for
54+
# the purpose.
55+
56+
LOCAL_MODULE_CLASS := EXECUTABLES
57+
LOCAL_MODULE_SUFFIX := $(TARGET_EXECUTABLE_SUFFIX)
58+
59+
# we don't want crtbegin.o (because we have begin.o), so unset it
60+
# just for this module
61+
LOCAL_NO_CRT := true
62+
63+
# TODO: split out the asflags.
64+
LOCAL_ASFLAGS := $(LOCAL_CFLAGS)
65+
66+
include $(BUILD_SYSTEM)/dynamic_binary.mk
67+
68+
# See build/core/executable.mk
69+
$(linked_module): PRIVATE_TARGET_GLOBAL_LD_DIRS := $(TARGET_GLOBAL_LD_DIRS)
70+
$(linked_module): PRIVATE_TARGET_GLOBAL_LDFLAGS := $(TARGET_GLOBAL_LDFLAGS)
71+
$(linked_module): PRIVATE_TARGET_FDO_LIB := $(TARGET_FDO_LIB)
72+
$(linked_module): PRIVATE_TARGET_LIBGCC := $(TARGET_LIBGCC)
73+
$(linked_module): PRIVATE_TARGET_CRTBEGIN_DYNAMIC_O := $(TARGET_CRTBEGIN_DYNAMIC_O)
74+
$(linked_module): PRIVATE_TARGET_CRTBEGIN_STATIC_O := $(TARGET_CRTBEGIN_STATIC_O)
75+
$(linked_module): PRIVATE_TARGET_CRTEND_O := $(TARGET_CRTEND_O)
76+
$(linked_module): $(TARGET_CRTBEGIN_STATIC_O) $(all_objects) $(all_libraries) $(TARGET_CRTEND_O)
77+
$(transform-o-to-static-executable)
78+
@echo "target PrefixSymbols: $(PRIVATE_MODULE) ($@)"
79+
$(hide) $(TARGET_OBJCOPY) --prefix-symbols=__dl_ $@
80+
81+
#
82+
# end of BUILD_EXECUTABLE hack
83+
#

aglinker/MODULE_LICENSE_APACHE2

Whitespace-only changes.

aglinker/NOTICE

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
Copyright (C) 2007 The Android Open Source Project
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.
14+
15+
-------------------------------------------------------------------
16+
17+
Copyright (C) 2008 The Android Open Source Project
18+
All rights reserved.
19+
20+
Redistribution and use in source and binary forms, with or without
21+
modification, are permitted provided that the following conditions
22+
are met:
23+
Redistributions of source code must retain the above copyright
24+
notice, this list of conditions and the following disclaimer.
25+
Redistributions in binary form must reproduce the above copyright
26+
notice, this list of conditions and the following disclaimer in
27+
the documentation and/or other materials provided with the
28+
distribution.
29+
30+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
33+
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
34+
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
35+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
36+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
37+
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
38+
AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
39+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
40+
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
41+
SUCH DAMAGE.
42+
43+
-------------------------------------------------------------------
44+
45+
Copyright (C) 2008, 2009 The Android Open Source Project
46+
All rights reserved.
47+
48+
Redistribution and use in source and binary forms, with or without
49+
modification, are permitted provided that the following conditions
50+
are met:
51+
Redistributions of source code must retain the above copyright
52+
notice, this list of conditions and the following disclaimer.
53+
Redistributions in binary form must reproduce the above copyright
54+
notice, this list of conditions and the following disclaimer in
55+
the documentation and/or other materials provided with the
56+
distribution.
57+
58+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
59+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
60+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
61+
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
62+
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
63+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
64+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
65+
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
66+
AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
67+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
68+
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
69+
SUCH DAMAGE.
70+
71+
-------------------------------------------------------------------
72+
73+
Copyright (C) 2008-2010 The Android Open Source Project
74+
All rights reserved.
75+
76+
Redistribution and use in source and binary forms, with or without
77+
modification, are permitted provided that the following conditions
78+
are met:
79+
Redistributions of source code must retain the above copyright
80+
notice, this list of conditions and the following disclaimer.
81+
Redistributions in binary form must reproduce the above copyright
82+
notice, this list of conditions and the following disclaimer in
83+
the documentation and/or other materials provided with the
84+
distribution.
85+
86+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
87+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
88+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
89+
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
90+
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
91+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
92+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
93+
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
94+
AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
95+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
96+
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
97+
SUCH DAMAGE.
98+
99+
-------------------------------------------------------------------
100+
101+
Copyright (C) 2010 The Android Open Source Project
102+
All rights reserved.
103+
104+
Redistribution and use in source and binary forms, with or without
105+
modification, are permitted provided that the following conditions
106+
are met:
107+
Redistributions of source code must retain the above copyright
108+
notice, this list of conditions and the following disclaimer.
109+
Redistributions in binary form must reproduce the above copyright
110+
notice, this list of conditions and the following disclaimer in
111+
the documentation and/or other materials provided with the
112+
distribution.
113+
114+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
115+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
116+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
117+
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
118+
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
119+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
120+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
121+
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
122+
AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
123+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
124+
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
125+
SUCH DAMAGE.
126+
127+
-------------------------------------------------------------------
128+
129+
Copyright (C) 2012 The Android Open Source Project
130+
All rights reserved.
131+
132+
Redistribution and use in source and binary forms, with or without
133+
modification, are permitted provided that the following conditions
134+
are met:
135+
Redistributions of source code must retain the above copyright
136+
notice, this list of conditions and the following disclaimer.
137+
Redistributions in binary form must reproduce the above copyright
138+
notice, this list of conditions and the following disclaimer in
139+
the documentation and/or other materials provided with the
140+
distribution.
141+
142+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
143+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
144+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
145+
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
146+
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
147+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
148+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
149+
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
150+
AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
151+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
152+
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
153+
SUCH DAMAGE.
154+
155+
-------------------------------------------------------------------
156+

aglinker/ScopedPthreadMutexLocker.h

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright (C) 2012 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#ifndef SCOPED_PTHREAD_MUTEX_LOCKER_H
18+
#define SCOPED_PTHREAD_MUTEX_LOCKER_H
19+
20+
#include <pthread.h>
21+
22+
class ScopedPthreadMutexLocker {
23+
public:
24+
explicit ScopedPthreadMutexLocker(pthread_mutex_t* mu) : mu_(mu) {
25+
pthread_mutex_lock(mu_);
26+
}
27+
28+
~ScopedPthreadMutexLocker() {
29+
pthread_mutex_unlock(mu_);
30+
}
31+
32+
private:
33+
pthread_mutex_t* mu_;
34+
35+
// Disallow copy and assignment.
36+
ScopedPthreadMutexLocker(const ScopedPthreadMutexLocker&);
37+
void operator=(const ScopedPthreadMutexLocker&);
38+
};
39+
40+
#endif // SCOPED_PTHREAD_MUTEX_LOCKER_H

aglinker/arch/arm/begin.S

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright (C) 2008 The Android Open Source Project
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions
7+
* are met:
8+
* * Redistributions of source code must retain the above copyright
9+
* notice, this list of conditions and the following disclaimer.
10+
* * Redistributions in binary form must reproduce the above copyright
11+
* notice, this list of conditions and the following disclaimer in
12+
* the documentation and/or other materials provided with the
13+
* distribution.
14+
*
15+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18+
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19+
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21+
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22+
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23+
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25+
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26+
* SUCH DAMAGE.
27+
*/
28+
29+
.text
30+
.align 4
31+
.type _start,#function
32+
.globl _start
33+
34+
_start:
35+
mov r0, sp
36+
mov r1, #0
37+
bl __linker_init
38+
39+
/* linker init returns the _entry address in the main image */
40+
mov pc, r0
41+
42+
.section .ctors, "wa"
43+
.globl __CTOR_LIST__
44+
__CTOR_LIST__:
45+
.long -1

0 commit comments

Comments
 (0)