Skip to content

Commit 04b67af

Browse files
committed
Fix OHOS define
Signed-off-by: Jonathan Schwender <[email protected]>
1 parent 882d13a commit 04b67af

File tree

8 files changed

+37
-33
lines changed

8 files changed

+37
-33
lines changed

mozjs-sys/etc/patches/0034-build__Add_compile_definition_for_ohos.patch

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
diff --git a/build/moz.configure/init.configure b/build/moz.configure/init.configure
22
--- a/build/moz.configure/init.configure (revision dbffebd0937c14d3c73ce9be4798da15cb2f369d)
33
+++ b/build/moz.configure/init.configure (revision 8a1dbb7da45148151dbb0d05d969118103cfa8d0)
4-
@@ -950,6 +950,14 @@
4+
@@ -950,6 +950,16 @@
55
set_define("ANDROID", target_is_android)
66

77

88
+@depends(target)
99
+def target_is_ohos(target):
10-
+ return target.raw_os.endswith("-ohos")
10+
+ if target.raw_os.endswith("-ohos"):
11+
+ return True
12+
+ return None
1113
+
1214
+
1315
+set_define("XP_OHOS", target_is_ohos)

mozjs-sys/etc/patches/0036-Redirect_errors_to_hilog_on_OpenHarmony.patch

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ index 3cfc92533..9c487ac45 100644
3636

3737
#ifdef ANDROID
3838
# include <android/log.h>
39-
+#elif defined(OHOS)
39+
+#elif defined(XP_OHOS)
4040
+# include <hilog/log.h>
4141
#endif
4242
#ifdef MOZ_WIDGET_ANDROID
@@ -48,7 +48,7 @@ index 3cfc92533..9c487ac45 100644
4848
-#ifndef ANDROID
4949
+#ifdef ANDROID
5050
+ __android_log_print(ANDROID_LOG_ERROR, "Gecko", "mozalloc_abort: %s", msg);
51-
+#elif defined(OHOS)
51+
+#elif defined(XP_OHOS)
5252
+ (void) OH_LOG_Print(LOG_APP, LOG_ERROR, OHOS_LOG_DOMAIN, "Gecko",
5353
+ "mozalloc_abort: %{public}s\n", msg);
5454
+#else
@@ -67,7 +67,7 @@ index 0b7395177..e84d76aba 100644
6767
#endif
6868
#ifdef ANDROID
6969
# include <android/log.h>
70-
+#elif defined(OHOS)
70+
+#elif defined(XP_OHOS)
7171
+# include <hilog/log.h>
7272
#endif
7373

@@ -76,7 +76,7 @@ index 0b7395177..e84d76aba 100644
7676
MozWalkTheStackWithWriter(MOZ_ReportAssertionFailurePrintFrame, CallerPC(),
7777
/* aMaxFrames */ 0);
7878
# endif
79-
+#elif defined(OHOS)
79+
+#elif defined(XP_OHOS)
8080
+ (void) OH_LOG_Print(LOG_APP, LOG_FATAL, OHOS_LOG_DOMAIN, "MOZ_Assert",
8181
+ "Assertion failure: %{public}s, at %{public}s:%{public}d\n",
8282
+ aStr, aFilename, aLine);
@@ -87,7 +87,7 @@ index 0b7395177..e84d76aba 100644
8787
__android_log_print(ANDROID_LOG_FATAL, "MOZ_CRASH",
8888
"[%d] Hit MOZ_CRASH(%s) at %s:%d\n", MOZ_GET_PID(), aStr,
8989
aFilename, aLine);
90-
+#elif defined(OHOS)
90+
+#elif defined(XP_OHOS)
9191
+ (void) OH_LOG_Print(LOG_APP, LOG_FATAL, OHOS_LOG_DOMAIN, "MOZ_CRASH",
9292
+ "Hit MOZ_CRASH(%{public}s), at %{public}s:%{public}d\n",
9393
+ aStr, aFilename, aLine);
@@ -105,7 +105,7 @@ index 3247b993c..c7039d5f8 100644
105105
-#ifdef ANDROID
106106
+#if defined(ANDROID)
107107
# include <android/log.h>
108-
+#elif defined(OHOS)
108+
+#elif defined(XP_OHOS)
109109
+# include <hilog/log.h>
110110
#endif
111111

@@ -117,7 +117,7 @@ index 3247b993c..c7039d5f8 100644
117117
-#ifdef ANDROID
118118
+#if defined(ANDROID)
119119
__android_log_print(ANDROID_LOG_INFO, "Gecko", "%s", s.str().c_str());
120-
+#elif defined(OHOS)
120+
+#elif defined(XP_OHOS)
121121
+ (void) OH_LOG_Print(LOG_APP, LOG_INFO, OHOS_LOG_DOMAIN, "Gecko", "%{public}s\n", s.str().c_str());
122122
#else
123123
fputs(s.str().c_str(), stderr);
@@ -130,20 +130,20 @@ index c3a2ca89e..3fea33f4b 100644
130130

131131
#ifdef ANDROID
132132
# include <android/log.h>
133-
+#elif defined(OHOS)
133+
+#elif defined(XP_OHOS)
134134
+# include <hilog/log.h>
135135
#endif
136136

137137
-#ifndef ANDROID
138-
+#if ! (defined(ANDROID) || defined(OHOS))
138+
+#if ! (defined(ANDROID) || defined(XP_OHOS))
139139
static void vprintf_stderr_buffered(const char* aFmt, va_list aArgs) {
140140
// Avoid interleaving by writing to an on-stack buffer and then writing in one
141141
// go with fputs, as long as the output fits into the buffer.
142142
@@ -66,6 +68,10 @@ MFBT_API void vprintf_stderr(const char* aFmt, va_list aArgs) {
143143
MFBT_API void vprintf_stderr(const char* aFmt, va_list aArgs) {
144144
__android_log_vprint(ANDROID_LOG_INFO, "Gecko", aFmt, aArgs);
145145
}
146-
+#elif defined(OHOS)
146+
+#elif defined(XP_OHOS)
147147
+MFBT_API void vprintf_stderr(const char* aFmt, va_list aArgs) {
148148
+ (void) OH_LOG_Print(LOG_APP, LOG_INFO, OHOS_LOG_DOMAIN, "Gecko", aFmt, aArgs);
149149
+}
@@ -155,7 +155,7 @@ index c3a2ca89e..3fea33f4b 100644
155155

156156
MFBT_API void print_stderr(std::stringstream& aStr) {
157157
-#if defined(ANDROID)
158-
+#if defined(ANDROID) || defined(OHOS)
158+
+#if defined(ANDROID) || defined(XP_OHOS)
159159
// On Android logcat output is truncated to 1024 chars per line, and
160160
// we usually use std::stringstream to build up giant multi-line gobs
161161
// of output. So to avoid the truncation we find the newlines and
@@ -181,7 +181,7 @@ index 52bd6abc5..781402d56 100644
181181
-#ifdef ANDROID
182182
+#if defined(ANDROID)
183183
#include <android/log.h>
184-
+#elif defined(OHOS)
184+
+#elif defined(XP_OHOS)
185185
+# include <hilog/log.h>
186186
#endif
187187

@@ -190,7 +190,7 @@ index 52bd6abc5..781402d56 100644
190190
PR_Write(fd, buf, nb); \
191191
} \
192192
PR_END_MACRO
193-
+#elif defined(OHOS)
193+
+#elif defined(XP_OHOS)
194194
+#define _PUT_LOG(fd, buf, nb) \
195195
+ PR_BEGIN_MACRO \
196196
+ if (fd == _pr_stderr) { \
@@ -210,7 +210,7 @@ index 52bd6abc5..781402d56 100644
210210
PR_LogPrint("Aborting");
211211
#ifdef ANDROID
212212
__android_log_write(ANDROID_LOG_ERROR, "PRLog", "Aborting");
213-
+#elif defined(OHOS)
213+
+#elif defined(XP_OHOS)
214214
+ (void) OH_LOG_Print(LOG_APP, LOG_ERROR, OHOS_LOG_DOMAIN, "PRLog", "Aborting\n");
215215
#endif
216216
abort();
@@ -219,7 +219,7 @@ index 52bd6abc5..781402d56 100644
219219
#elif defined(ANDROID)
220220
__android_log_assert(NULL, "PRLog", "Assertion failure: %s, at %s:%d\n",
221221
s, file, ln);
222-
+#elif defined(OHOS)
222+
+#elif defined(XP_OHOS)
223223
+ (void) OH_LOG_Print(LOG_APP, LOG_ERROR, OHOS_LOG_DOMAIN, "PRLog",
224224
+ "Assertion failure: %{public}s, at %{public}s:%{public}d\n",s, file, ln);
225225
#endif

mozjs-sys/mozjs/build/moz.configure/init.configure

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mozjs-sys/mozjs/memory/mozalloc/mozalloc_abort.cpp

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mozjs-sys/mozjs/mfbt/Assertions.h

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mozjs-sys/mozjs/mfbt/DbgMacro.h

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mozjs-sys/mozjs/mozglue/misc/Debug.cpp

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mozjs-sys/mozjs/nsprpub/pr/src/io/prlog.c

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)