Skip to content

Commit 28738de

Browse files
authored
Revert "Fix OHOS define (#666)"
This reverts commit dfae36e.
1 parent dfae36e commit 28738de

File tree

10 files changed

+82
-121
lines changed

10 files changed

+82
-121
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,6 @@ jobs:
227227
strategy:
228228
matrix:
229229
target: ["aarch64-unknown-linux-ohos", "x86_64-unknown-linux-ohos"]
230-
features: [ "", "--features debugmozjs"]
231230
steps:
232231
- uses: actions/checkout@v4
233232
- name: Setup OpenHarmony SDK
@@ -246,15 +245,15 @@ jobs:
246245
env:
247246
OHOS_SDK_NATIVE: ${{ steps.setup_sdk.outputs.ohos_sdk_native }}
248247
run: |
249-
./ohos-build cargo +${{ steps.toolchain.outputs.name }} build --target="${{ matrix.target }}" ${{ matrix.features }}
248+
./ohos-build cargo +${{ steps.toolchain.outputs.name }} build --target="${{ matrix.target }}"
250249
- name: Generate artifact attestation
251250
uses: actions/attest-build-provenance@v1
252-
if: ${{ inputs.release && matrix.features == '' }}
251+
if: ${{ inputs.release }}
253252
with:
254253
subject-path: "./target/libmozjs-${{ matrix.target }}.tar.gz"
255254
- name: Upload artifact
256255
uses: actions/upload-artifact@v4
257-
if: ${{ env.NEW_RUST_CHECK == 'false' && matrix.features == '' }}
256+
if: ${{ env.NEW_RUST_CHECK == 'false' }}
258257
with:
259258
path: ./target/libmozjs-${{ matrix.target }}.tar.gz
260259
name: libmozjs-${{ matrix.target }}.tar.gz

mozjs-sys/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "mozjs_sys"
33
description = "System crate for the Mozilla SpiderMonkey JavaScript engine."
44
repository.workspace = true
5-
version = "0.140.5-4"
5+
version = "0.140.5-3"
66
authors = ["Mozilla", "The Servo Project Developers"]
77
links = "mozjs"
88
license.workspace = true

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
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,16 @@
4+
@@ -950,6 +950,14 @@
55
set_define("ANDROID", target_is_android)
66

77

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

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

Lines changed: 41 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,12 @@ diff --git a/memory/mozalloc/mozalloc_abort.cpp b/memory/mozalloc/mozalloc_abort
3030
index 3cfc92533..9c487ac45 100644
3131
--- a/memory/mozalloc/mozalloc_abort.cpp
3232
+++ b/memory/mozalloc/mozalloc_abort.cpp
33-
@@ -9,6 +9,11 @@
33+
@@ -9,6 +9,8 @@
3434

3535
#ifdef ANDROID
3636
# include <android/log.h>
37-
+#elif defined(XP_OHOS)
38-
+ extern "C" {
39-
+ int OH_LOG_Print(unsigned int type, unsigned int level, unsigned int domain, const char *tag, const char *fmt, ...)
40-
+ __attribute__((__format__(os_log, 5, 6)));
41-
+ }
37+
+#elif defined(OHOS)
38+
+# include <hilog/log.h>
4239
#endif
4340
#ifdef MOZ_WIDGET_ANDROID
4441
# include "APKOpen.h"
@@ -49,8 +46,8 @@ index 3cfc92533..9c487ac45 100644
4946
-#ifndef ANDROID
5047
+#ifdef ANDROID
5148
+ __android_log_print(ANDROID_LOG_ERROR, "Gecko", "mozalloc_abort: %s", msg);
52-
+#elif defined(XP_OHOS)
53-
+ (void) OH_LOG_Print(0 /* LOG_APP */, 7 /* LOG_FATAL */, 0, "Gecko",
49+
+#elif defined(OHOS)
50+
+ (void) OH_LOG_Print(LOG_APP, LOG_ERROR, 0, "Gecko",
5451
+ "mozalloc_abort: %{public}s\n", msg);
5552
+#else
5653
fputs(msg, stderr);
@@ -64,58 +61,50 @@ diff --git a/mfbt/Assertions.h b/mfbt/Assertions.h
6461
index 0b7395177..e84d76aba 100644
6562
--- a/mfbt/Assertions.h
6663
+++ b/mfbt/Assertions.h
67-
@@ -88,6 +88,11 @@ MOZ_END_EXTERN_C
64+
@@ -88,6 +88,8 @@ MOZ_END_EXTERN_C
6865
#endif
6966
#ifdef ANDROID
7067
# include <android/log.h>
71-
+#elif defined(XP_OHOS)
72-
+MOZ_BEGIN_EXTERN_C
73-
+int OH_LOG_Print(unsigned int type, unsigned int level, unsigned int domain, const char *tag, const char *fmt, ...)
74-
+ __attribute__((__format__(os_log, 5, 6)));
75-
+MOZ_END_EXTERN_C
68+
+#elif defined(OHOS)
69+
+# include <hilog/log.h>
7670
#endif
7771

7872
MOZ_BEGIN_EXTERN_C
7973
@@ -120,6 +122,10 @@ MOZ_ReportAssertionFailure(const char* aStr, const char* aFilename,
8074
MozWalkTheStackWithWriter(MOZ_ReportAssertionFailurePrintFrame, CallerPC(),
8175
/* aMaxFrames */ 0);
8276
# endif
83-
+#elif defined(XP_OHOS)
84-
+ (void) OH_LOG_Print(0 /* LOG_APP */, 7 /* LOG_FATAL */, 0, "MOZ_Assert",
77+
+#elif defined(OHOS)
78+
+ (void) OH_LOG_Print(LOG_APP, LOG_FATAL, 0, "MOZ_Assert",
8579
+ "Assertion failure: %{public}s, at %{public}s:%{public}d\n",
8680
+ aStr, aFilename, aLine);
8781
#else
8882
# if defined(MOZ_BUFFER_STDERR)
8983
char msg[1024] = "";
90-
@@ -144,8 +150,12 @@ MOZ_MAYBE_UNUSED static MOZ_COLD MOZ_NEVER_INLINE void MOZ_ReportCrash(
84+
@@ -144,6 +150,10 @@ MOZ_MAYBE_UNUSED static MOZ_COLD MOZ_NEVER_INLINE void MOZ_ReportCrash(
9185
__android_log_print(ANDROID_LOG_FATAL, "MOZ_CRASH",
9286
"[%d] Hit MOZ_CRASH(%s) at %s:%d\n", MOZ_GET_PID(), aStr,
9387
aFilename, aLine);
88+
+#elif defined(OHOS)
89+
+ (void) OH_LOG_Print(LOG_APP, LOG_FATAL, 0, "MOZ_CRASH",
90+
+ "Hit MOZ_CRASH(%{public}s), at %{public}s:%{public}d\n",
91+
+ aStr, aFilename, aLine);
9492
# if defined(MOZ_DUMP_ASSERTION_STACK)
9593
MozWalkTheStackWithWriter(MOZ_CrashPrintFrame, CallerPC(),
9694
/* aMaxFrames */ 0);
97-
# endif
98-
+#elif defined(XP_OHOS)
99-
+ (void) OH_LOG_Print(0 /* LOG_APP */, 7 /* LOG_FATAL */, 0, "MOZ_CRASH",
100-
+ "Hit MOZ_CRASH(%{public}s), at %{public}s:%{public}d\n",
101-
+ aStr, aFilename, aLine);
102-
#else
10395
diff --git a/mfbt/DbgMacro.h b/mfbt/DbgMacro.h
10496
index 3247b993c..c7039d5f8 100644
10597
--- a/mfbt/DbgMacro.h
10698
+++ b/mfbt/DbgMacro.h
107-
@@ -18,8 +18,13 @@
99+
@@ -18,8 +18,10 @@
108100
template <typename T>
109101
class nsTSubstring;
110102

111103
-#ifdef ANDROID
112104
+#if defined(ANDROID)
113105
# include <android/log.h>
114-
+#elif defined(XP_OHOS)
115-
+ MOZ_BEGIN_EXTERN_C
116-
+ int OH_LOG_Print(unsigned int type, unsigned int level, unsigned int domain, const char *tag, const char *fmt, ...)
117-
+ __attribute__((__format__(os_log, 5, 6)));
118-
+ MOZ_END_EXTERN_C
106+
+#elif defined(OHOS)
107+
+# include <hilog/log.h>
119108
#endif
120109

121110
namespace mozilla {
@@ -126,41 +115,35 @@ index 3247b993c..c7039d5f8 100644
126115
-#ifdef ANDROID
127116
+#if defined(ANDROID)
128117
__android_log_print(ANDROID_LOG_INFO, "Gecko", "%s", s.str().c_str());
129-
+#elif defined(XP_OHOS)
130-
+ (void) OH_LOG_Print(0 /* LOG_APP */, 4 /* LOG_INFO */, 0, "Gecko", "%{public}s\n", s.str().c_str());
118+
+#elif defined(OHOS)
119+
+ (void) OH_LOG_Print(LOG_APP, LOG_INFO, 0, "Gecko", "%{public}s\n", s.str().c_str());
131120
#else
132121
fputs(s.str().c_str(), stderr);
133122
#endif
134123
diff --git a/mozglue/misc/Debug.cpp b/mozglue/misc/Debug.cpp
135124
index c3a2ca89e..3fea33f4b 100644
136125
--- a/mozglue/misc/Debug.cpp
137126
+++ b/mozglue/misc/Debug.cpp
138-
@@ -18,9 +18,14 @@
127+
@@ -18,9 +18,11 @@
139128

140129
#ifdef ANDROID
141130
# include <android/log.h>
142-
+#elif defined(XP_OHOS)
143-
+ extern "C" {
144-
+ int OH_LOG_Print(unsigned int type, unsigned int level, unsigned int domain, const char *tag, const char *fmt, ...)
145-
+ __attribute__((__format__(os_log, 5, 6)));
146-
+ }
131+
+#elif defined(OHOS)
132+
+# include <hilog/log.h>
147133
#endif
148134

149135
-#ifndef ANDROID
150-
+#if ! (defined(ANDROID) || defined(XP_OHOS))
136+
+#if ! (defined(ANDROID) || defined(OHOS))
151137
static void vprintf_stderr_buffered(const char* aFmt, va_list aArgs) {
152138
// Avoid interleaving by writing to an on-stack buffer and then writing in one
153139
// go with fputs, as long as the output fits into the buffer.
154-
@@ -66,6 +68,13 @@ MFBT_API void vprintf_stderr(const char* aFmt, va_list aArgs) {
140+
@@ -66,6 +68,10 @@ MFBT_API void vprintf_stderr(const char* aFmt, va_list aArgs) {
155141
MFBT_API void vprintf_stderr(const char* aFmt, va_list aArgs) {
156142
__android_log_vprint(ANDROID_LOG_INFO, "Gecko", aFmt, aArgs);
157143
}
158-
+#elif defined(XP_OHOS)
144+
+#elif defined(OHOS)
159145
+MFBT_API void vprintf_stderr(const char* aFmt, va_list aArgs) {
160-
+ // OH_LOG_VPrint is available with API-level 18 (19?) or higher.
161-
+ char buffer[1024];
162-
+ VsprintfBuf(buffer, 1024, aFmt, aArgs);
163-
+ (void) OH_LOG_Print(0 /* LOG_APP */, 4 /* LOG_INFO */, 0, "Gecko", "%{public}s", buffer);
146+
+ (void) OH_LOG_Print(LOG_APP, LOG_INFO, 0, "Gecko", aFmt, aArgs);
164147
+}
165148
#elif defined(FUZZING_SNAPSHOT)
166149
MFBT_API void vprintf_stderr(const char* aFmt, va_list aArgs) {
@@ -170,15 +153,15 @@ index c3a2ca89e..3fea33f4b 100644
170153

171154
MFBT_API void print_stderr(std::stringstream& aStr) {
172155
-#if defined(ANDROID)
173-
+#if defined(ANDROID) || defined(XP_OHOS)
156+
+#if defined(ANDROID) || defined(OHOS)
174157
// On Android logcat output is truncated to 1024 chars per line, and
175158
// we usually use std::stringstream to build up giant multi-line gobs
176159
// of output. So to avoid the truncation we find the newlines and
177160
// print the lines individually.
178161
std::string line;
179162
while (std::getline(aStr, line)) {
180-
+# ifdef XP_OHOS
181-
+ (void) OH_LOG_Print(0 /* LOG_APP */, 4 /* LOG_INFO */, 0, "Gecko", "%{public}s", line.c_str());
163+
+# ifdef OHOS
164+
+ printf_stderr("%{public}s\n", line.c_str());
182165
+# else
183166
printf_stderr("%s\n", line.c_str());
184167
+# endif
@@ -189,31 +172,30 @@ diff --git a/nsprpub/pr/src/io/prlog.c b/nsprpub/pr/src/io/prlog.c
189172
index 52bd6abc5..781402d56 100644
190173
--- a/nsprpub/pr/src/io/prlog.c
191174
+++ b/nsprpub/pr/src/io/prlog.c
192-
@@ -8,8 +8,11 @@
175+
@@ -8,8 +8,10 @@
193176
#include "prenv.h"
194177
#include "prprf.h"
195178
#include <string.h>
196179
-#ifdef ANDROID
197180
+#if defined(ANDROID)
198181
# include <android/log.h>
199-
+#elif defined(XP_OHOS)
200-
+ int OH_LOG_Print(unsigned int type, unsigned int level, unsigned int domain, const char *tag, const char *fmt, ...)
201-
+ __attribute__((__format__(os_log, 5, 6)));
182+
+#elif defined(OHOS)
183+
+# include <hilog/log.h>
202184
#endif
203185

204186
/*
205187
@@ -108,6 +110,19 @@ static void OutputDebugStringA(const char* msg) {
206188
PR_Write(fd, buf, nb); \
207189
} \
208190
PR_END_MACRO
209-
+#elif defined(XP_OHOS)
210-
+# define _PUT_LOG(fd, buf, nb) \
191+
+#elif defined(OHOS)
192+
+#define _PUT_LOG(fd, buf, nb) \
211193
+ PR_BEGIN_MACRO \
212194
+ if (fd == _pr_stderr) { \
213195
+ char savebyte = buf[nb]; \
214196
+ buf[nb] = '\0'; \
215-
+ (void) OH_LOG_Print(0 /* LOG_APP */, 4 /* LOG_INFO */, \
216-
+ 0, "PRLog", "%{public}s\n", buf); \
197+
+ (void) OH_LOG_Print(LOG_APP, LOG_INFO, 0, "PRLog", \
198+
+ "%{public}s\n", buf); \
217199
+ buf[nb] = savebyte; \
218200
+ } else { \
219201
+ PR_Write(fd, buf, nb); \
@@ -226,17 +208,17 @@ index 52bd6abc5..781402d56 100644
226208
PR_LogPrint("Aborting");
227209
#ifdef ANDROID
228210
__android_log_write(ANDROID_LOG_ERROR, "PRLog", "Aborting");
229-
+#elif defined(XP_OHOS)
230-
+ (void) OH_LOG_Print(0 /* LOG_APP */, 7 /* LOG_FATAL */, 0, "PRLog", "Aborting\n");
211+
+#elif defined(OHOS)
212+
+ (void) OH_LOG_Print(LOG_APP, LOG_ERROR, 0, "PRLog", "Aborting\n");
231213
#endif
232214
abort();
233215
}
234216
@@ -567,6 +584,9 @@ PR_IMPLEMENT(void) PR_Assert(const char *s, const char *file, PRIntn ln)
235217
#elif defined(ANDROID)
236218
__android_log_assert(NULL, "PRLog", "Assertion failure: %s, at %s:%d\n", s,
237219
file, ln);
238-
+#elif defined(XP_OHOS)
239-
+ (void) OH_LOG_Print(0 /* LOG_APP */, 7 /* LOG_FATAL */, 0, "PRLog",
220+
+#elif defined(OHOS)
221+
+ (void) OH_LOG_Print(LOG_APP, LOG_ERROR, 0, "PRLog",
240222
+ "Assertion failure: %{public}s, at %{public}s:%{public}d\n",s, file, ln);
241223
#endif
242224
abort();

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

Lines changed: 1 addition & 3 deletions
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: 4 additions & 7 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: 8 additions & 11 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: 4 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)