Skip to content

Commit

Permalink
LibHTML: Make it possible to build LibHTML on the host.
Browse files Browse the repository at this point in the history
- "make" builds the normal Serenity libhtml.a
- "make -f Makefile.host" builds a test program for the host machine.
  • Loading branch information
awesomekling committed Jun 22, 2019
1 parent 04b2082 commit 7e1cb86
Show file tree
Hide file tree
Showing 12 changed files with 101 additions and 56 deletions.
2 changes: 1 addition & 1 deletion AK/Traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -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); }
};
Expand Down
1 change: 1 addition & 0 deletions AK/kstdio.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
#else
#include <stdio.h>
#define kprintf printf
#define dbgprintf printf
#endif
4 changes: 4 additions & 0 deletions Kernel/kstdio.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ int ksprintf(char* buf, const char* fmt, ...);
#ifndef USERLAND
# define printf dbgprintf
#endif

#ifndef __serenity__
#define dbgprintf printf
#endif
20 changes: 10 additions & 10 deletions LibCore/CEventLoop.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions LibCore/CFile.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <LibCore/CFile.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
Expand Down
1 change: 1 addition & 0 deletions LibCore/CIODevice.cpp
Original file line number Diff line number Diff line change
@@ -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>
Expand Down
14 changes: 14 additions & 0 deletions LibCore/CLock.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#ifdef __serenity__

#include <AK/Assertions.h>
#include <AK/Types.h>
#include <unistd.h>
Expand Down Expand Up @@ -109,3 +111,15 @@ class CLockable {
T m_resource;
CLock m_lock;
};

#else

class CLock {
public:
CLock() { }
~CLock() { }
};

#define LOCKER(x)

#endif
1 change: 1 addition & 0 deletions LibCore/CObject.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <AK/Assertions.h>
#include <AK/kstdio.h>
#include <LibCore/CEvent.h>
#include <LibCore/CEventLoop.h>
#include <LibCore/CObject.h>
Expand Down
47 changes: 3 additions & 44 deletions LibHTML/Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
20 changes: 20 additions & 0 deletions LibHTML/Makefile.host
Original file line number Diff line number Diff line change
@@ -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 changes: 45 additions & 0 deletions LibHTML/Makefile.shared
Original file line number Diff line number Diff line change
@@ -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)

1 change: 0 additions & 1 deletion LibHTML/Parser/CSSParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ NonnullRefPtr<StyleSheet> parse_css(const String& css)

auto parse_declaration = [&] {
consume_whitespace();

};

auto parse_declarations = [&] {
Expand Down

0 comments on commit 7e1cb86

Please sign in to comment.