Browse Source

LibHTML: Make it possible to build LibHTML on the host.

- "make" builds the normal Serenity libhtml.a
- "make -f Makefile.host" builds a test program for the host machine.
Andreas Kling 6 years ago
parent
commit
7e1cb86da7

+ 1 - 1
AK/Traits.h

@@ -31,7 +31,7 @@ template<typename T>
 struct Traits<T*> {
     static unsigned hash(const T* p)
     {
-        return int_hash((dword)p);
+        return int_hash((unsigned)(__PTRDIFF_TYPE__)p);
     }
     static void dump(const T* p) { kprintf("%p", p); }
 };

+ 1 - 0
AK/kstdio.h

@@ -5,4 +5,5 @@
 #else
 #include <stdio.h>
 #define kprintf printf
+#define dbgprintf printf
 #endif

+ 4 - 0
Kernel/kstdio.h

@@ -9,3 +9,7 @@ int ksprintf(char* buf, const char* fmt, ...);
 #ifndef USERLAND
 #    define printf dbgprintf
 #endif
+
+#ifndef __serenity__
+#define dbgprintf printf
+#endif

+ 10 - 10
LibCore/CEventLoop.cpp

@@ -1,19 +1,19 @@
 #include <AK/Time.h>
-#include <LibC/errno.h>
-#include <LibC/fcntl.h>
-#include <LibC/stdio.h>
-#include <LibC/stdlib.h>
-#include <LibC/string.h>
-#include <LibC/sys/select.h>
-#include <LibC/sys/socket.h>
-#include <LibC/sys/time.h>
-#include <LibC/time.h>
-#include <LibC/unistd.h>
 #include <LibCore/CEvent.h>
 #include <LibCore/CEventLoop.h>
 #include <LibCore/CLock.h>
 #include <LibCore/CNotifier.h>
 #include <LibCore/CObject.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/select.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <time.h>
+#include <unistd.h>
 
 //#define CEVENTLOOP_DEBUG
 //#define DEFERRED_INVOKE_DEBUG

+ 1 - 0
LibCore/CFile.cpp

@@ -1,4 +1,5 @@
 #include <LibCore/CFile.h>
+#include <errno.h>
 #include <fcntl.h>
 #include <stdio.h>
 #include <unistd.h>

+ 1 - 0
LibCore/CIODevice.cpp

@@ -1,5 +1,6 @@
 #include <AK/PrintfImplementation.h>
 #include <LibCore/CIODevice.h>
+#include <errno.h>
 #include <stdio.h>
 #include <sys/select.h>
 #include <sys/time.h>

+ 14 - 0
LibCore/CLock.h

@@ -1,5 +1,7 @@
 #pragma once
 
+#ifdef __serenity__
+
 #include <AK/Assertions.h>
 #include <AK/Types.h>
 #include <unistd.h>
@@ -109,3 +111,15 @@ private:
     T m_resource;
     CLock m_lock;
 };
+
+#else
+
+class CLock {
+public:
+    CLock() { }
+    ~CLock() { }
+};
+
+#define LOCKER(x)
+
+#endif

+ 1 - 0
LibCore/CObject.cpp

@@ -1,4 +1,5 @@
 #include <AK/Assertions.h>
+#include <AK/kstdio.h>
 #include <LibCore/CEvent.h>
 #include <LibCore/CEventLoop.h>
 #include <LibCore/CObject.h>

+ 3 - 44
LibHTML/Makefile

@@ -1,58 +1,17 @@
 include ../Makefile.common
 
-LIBHTML_OBJS = \
-    DOM/Node.o \
-    DOM/ParentNode.o \
-    DOM/Element.o \
-    DOM/Document.o \
-    DOM/Text.o \
-    CSS/Selector.o \
-    CSS/StyleSheet.o \
-    CSS/StyleRule.o \
-    CSS/StyleDeclaration.o \
-    CSS/StyleValue.o \
-    CSS/DefaultStyleSheetSource.o \
-    Parser/HTMLParser.o \
-    Parser/CSSParser.o \
-    Layout/LayoutNode.o \
-    Layout/LayoutText.o \
-    Layout/LayoutBlock.o \
-    Layout/LayoutInline.o \
-    Layout/LayoutDocument.o \
-    Layout/LayoutStyle.o \
-    Frame.o \
-    Dump.o
-
-GENERATED_SOURCES = \
-    CSS/DefaultStyleSheetSource.cpp
-
-TEST_OBJS = test.o
-TEST_PROGRAM = tho
-
-OBJS = $(LIBHTML_OBJS) $(TEST_OBJS)
-
 LIBRARY = libhtml.a
-DEFINES += -DUSERLAND
 
-all: $(LIBRARY) $(TEST_PROGRAM)
+all: $(LIBRARY) tho
 
-CSS/DefaultStyleSheetSource.cpp: CSS/Default.css Scripts/GenerateStyleSheetSource.sh
-	@echo "GENERATE $@"; Scripts/GenerateStyleSheetSource.sh default_stylesheet_source $< > $@
+include Makefile.shared
 
-$(TEST_PROGRAM): $(TEST_OBJS) $(LIBRARY)
+tho: $(TEST_OBJS) $(LIBRARY)
 	$(LD) -o $@ $(LDFLAGS) -L. $(TEST_OBJS) -lhtml -lgui -lcore -lc
 
 $(LIBRARY): $(LIBHTML_OBJS)
 	@echo "LIB $@"; $(AR) rcs $@ $(LIBHTML_OBJS)
 
-.cpp.o:
-	@echo "CXX $<"; $(CXX) $(CXXFLAGS) -o $@ -c $<
-
--include $(OBJS:%.o=%.d)
-
-clean:
-	@echo "CLEAN"; rm -f $(TEST_PROGRAM) $(LIBRARY) $(OBJS) *.d $(GENERATED_SOURCES)
-
 install: $(LIBRARY)
 	mkdir -p ../Root/usr/include/LibHTML
 	# Copy headers

+ 20 - 0
LibHTML/Makefile.host

@@ -0,0 +1,20 @@
+all: tho
+
+CXXFLAGS = -W -Wall -O -g -I. -I../ -std=c++17
+
+EXTRA_OBJS = \
+    ../AK/StringImpl.o \
+    ../AK/String.o \
+    ../AK/StringBuilder.o \
+    ../AK/StringView.o \
+    ../LibCore/CEventLoop.o \
+    ../LibCore/CObject.o \
+    ../LibCore/CEvent.o \
+    ../LibCore/CIODevice.o \
+    ../LibCore/CFile.o 
+
+include Makefile.shared
+
+tho: $(OBJS)
+	$(CXX) -o $@ $(LDFLAGS) $(OBJS)
+

+ 45 - 0
LibHTML/Makefile.shared

@@ -0,0 +1,45 @@
+LIBHTML_OBJS = \
+    DOM/Node.o \
+    DOM/ParentNode.o \
+    DOM/Element.o \
+    DOM/Document.o \
+    DOM/Text.o \
+    CSS/Selector.o \
+    CSS/StyleSheet.o \
+    CSS/StyleRule.o \
+    CSS/StyleDeclaration.o \
+    CSS/StyleValue.o \
+    CSS/DefaultStyleSheetSource.o \
+    Parser/HTMLParser.o \
+    Parser/CSSParser.o \
+    Layout/LayoutNode.o \
+    Layout/LayoutText.o \
+    Layout/LayoutBlock.o \
+    Layout/LayoutInline.o \
+    Layout/LayoutDocument.o \
+    Layout/LayoutStyle.o \
+    Frame.o \
+    Dump.o
+
+GENERATED_SOURCES = \
+    CSS/DefaultStyleSheetSource.cpp
+
+TEST_OBJS = test.o
+TEST_PROGRAM = tho
+
+OBJS = $(EXTRA_OBJS) $(LIBHTML_OBJS) $(TEST_OBJS)
+
+LIBRARY = libhtml.a
+DEFINES += -DUSERLAND
+
+CSS/DefaultStyleSheetSource.cpp: CSS/Default.css Scripts/GenerateStyleSheetSource.sh
+	@echo "GENERATE $@"; Scripts/GenerateStyleSheetSource.sh default_stylesheet_source $< > $@
+
+.cpp.o:
+	@echo "CXX $<"; $(CXX) $(CXXFLAGS) -o $@ -c $<
+
+-include $(OBJS:%.o=%.d)
+
+clean:
+	@echo "CLEAN"; rm -f $(TEST_PROGRAM) $(LIBRARY) $(OBJS) *.d $(GENERATED_SOURCES)
+

+ 0 - 1
LibHTML/Parser/CSSParser.cpp

@@ -80,7 +80,6 @@ NonnullRefPtr<StyleSheet> parse_css(const String& css)
 
     auto parse_declaration = [&] {
         consume_whitespace();
-
     };
 
     auto parse_declarations = [&] {