Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

External packages #455

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ gdbinit
src/components/lib/libc/musl-1.2.0/include/asm/
src/components/lib/libc/musl-1.2.0/include/asm-generic/
src/components/lib/libc/musl-1.2.0/include/linux/
src/components/lib/libc/musl-1.2.0/include/sys/queue.h
src/components/lib/libc/musl-1.2.0/include/sys/queue.h
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@betahxy Is this an error? Looks like this comes from a merge with your code. I might have done this incorrectly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gparmer This is OK. I'll add this back. Not a big problem.

15 changes: 15 additions & 0 deletions composition_scripts/burn.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[system]
description = "Simple system running only a CPU-burn component."

[[components]]
name = "booter"
img = "no_interface.llbooter"
implements = [{interface = "init"}, {interface = "addr"}]
deps = [{srv = "kernel", interface = "init", variant = "kernel"}]
constructor = "kernel"

[[components]]
name = "burn"
img = "no_interface.burn"
deps = [{srv = "booter", interface = "init"}, {srv = "booter", interface = "addr"}]
constructor = "booter"
9 changes: 9 additions & 0 deletions composition_scripts/external_hello_world.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[system]
description = "Test for the hello world external component"

[[components]]
name = "hw1"
img = ""
repo = "github:gparmer/hello_world"
deps = [{srv = "kernel", interface = "init", variant = "kernel"}]
constructor = "kernel"
5 changes: 5 additions & 0 deletions src/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#MAKEFLAGS=--no-print-directory --section-alignment 0x1000 -I$(PWD)
# Note: can't use $(PWD) here if make -Ced from elsewhere.
MAKEOPTIONS=--no-print-directory -I$(shell pwd)
export MAKEOPTIONS
PLAT_FILE=.PLATFORM_ID

.PHONY: default all composer component comps platclean plat cpplat clean distclean init update config
Expand All @@ -20,6 +21,10 @@ composer:
component:
$(MAKE) $(MAKEOPTIONS) -C components component

# Download an external repository
repo_external:
$(MAKE) $(MAKEOPTIONS) -C components repo_external

comps:
$(info )
$(info ***********************************************)
Expand Down
6 changes: 6 additions & 0 deletions src/Makefile.src
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ KINC=$(TOP_DIR)/kernel/include/
SHAREDINC=$(TOP_DIR)/kernel/include/shared/
CHALSHAREDINC=$(TOP_DIR)/kernel/include/chal/shared/
CDIR=$(TOP_DIR)/components/
REPO_DIR=$(CDIR)/repos

# tools
MAKE=make
Expand All @@ -25,3 +26,8 @@ CP=cp
RM=rm
PLAT_FILE=$(TOP_DIR)/.PLATFORM_ID
PLATFORM=$(shell cat $(PLAT_FILE))

# disable the terminal prompts, and fail out instead; typically fails
# if ssh isn't set up (known hosts), or if the specified repo doesn't
# exist.
GITCLONE=GIT_TERMINAL_PROMPT=0 git clone
13 changes: 12 additions & 1 deletion src/components/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
MAKEOPTIONS=-I$(shell pwd)
include Makefile.src
MAKEOPTIONS+= -I$(shell pwd)
export MAKEOPTIONS

# Order of which subdirectories are built first matters here.
# Interface files rely on library files, and component implementations
Expand All @@ -24,3 +26,12 @@ init:

component:
$(MAKE) $(MAKEOPTIONS) -C implementation component

# Download a remote repository (e.g. from github). We're setting up a
# specific rule for the repo's path so that it won't redundantly clone
# the repo. Once it has been cloned, never clone it again.
REPO_ABSPATH = $(REPO_DIR)/$(REPO_PATH)
$(REPO_ABSPATH):
$(GITCLONE) $(REPO_URL) $@

repo_external: $(REPO_ABSPATH)
12 changes: 10 additions & 2 deletions src/components/implementation/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
include Makefile.src Makefile.comp

SUBDIRS=$(filter-out skel/, $(wildcard */))
MAKEOPTIONS=-I$(shell pwd)
MAKEOPTIONS+= -I$(shell pwd)
export MAKEOPTIONS

.PHONY: all
all:
Expand All @@ -23,5 +24,12 @@ clean:
init:
distclean:

# NOTE: we're skipping the compilation of the libraries in the
# interfaces directories (the immediate subdirectories here) on
# composer-directed compilation. Soon, we'll remove the need for
# interface directories, and will move all of their shared code into
# the `lib/` code.
#
# NOTE: COMP_PATH is relative to the `src/component` (CDIR) directory.
component:
$(MAKE) $(MAKEOPTIONS) -C $(COMP_INTERFACE) component
$(MAKE) $(MAKEOPTIONS) -C $(CDIR)/$(COMP_PATH) component
4 changes: 2 additions & 2 deletions src/components/implementation/Makefile.subdir
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ print:
.PHONY: subdirs
subdirs:
@for dir in $(SUBDIRS) ; do \
$(MAKE) -C $$dir ; \
$(MAKE) $(MAKEOPTIONS) -C $$dir ; \
done

$(CLIB):$(OBJS)
Expand Down Expand Up @@ -75,6 +75,6 @@ clean:

.PHONY: component
component:
$(MAKE) -C $(COMP_NAME) component
$(MAKE) $(MAKEOPTIONS) -C $(COMP_NAME) component

-include $(SOURCE_DEPENDENCIES)
11 changes: 7 additions & 4 deletions src/components/implementation/Makefile.subsubdir
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ ifeq ($(PLATFORM), i386)
LINKFLAG=-Xlinker -melf_i386
COMP_LD_SCRIPT=$(IMPLDIR)/comp_i386.ld
else ifeq ($(PLATFORM), x86_64)
LINKFLAG=-Xlinker -melf_x86_64
LINKFLAG=-Xlinker -melf_x86_64
COMP_LD_SCRIPT=$(IMPLDIR)/comp_x86_64.ld
else ifeq ($(PLATFORM), armv7a)
LINKFLAG=-Xlinker -marmelf
Expand Down Expand Up @@ -82,13 +82,14 @@ COMP_DEP_OBJS=$(foreach D,$(COMP_IFDEPS_CLEAN),$(INTERDIR)/$(D)/cosrt_c_stub.o)
# NOTE: we're currently ignoring the *variants* library requirements,
# which will break if an interface's code requires a library


comp_header:
$(info | Composing $(COMP_INTERFACE).$(COMP_NAME) for variable $(COMP_VARNAME) by linking with:)
$(info | Composing component in src/components/$(COMP_PATH) for variable $(COMP_VARNAME) by linking with:)
$(info | Exported interfaces: $(COMP_INTERFACES_CLEAN))
$(info | Interface dependencies: $(COMP_IFDEPS_CLEAN))
$(info | Libraries: $(DEPENDENCY_LIBS) $(DEPENDENCY_LIBOBJS))

.PHONY: component
.PHONY: component comp_header
component: clean comp_header $(COMPOBJ)
$(if $(COMP_INITARGS_FILE), $(CC) $(INCLUDE) $(CFLAGS) -c -o $(COMP_INITARGS_FILE:%.c=%.o) $(COMP_INITARGS_FILE))
$(if $(COMP_TAR_FILE), cp $(COMP_TAR_FILE) $(TAR_SYMBOL_NAME))
Expand All @@ -97,6 +98,8 @@ component: clean comp_header $(COMPOBJ)
$(MUSLCC) $(COMPNAME).linked_libs_ifs.o $(MUSLCFLAGS) $(LINKFLAG) -o $(COMPNAME).linked_musl.o
$(LD) $(LDFLAGS) -Ttext=$(COMP_BASEADDR) -T $(COMP_LD_SCRIPT) -o $(COMP_OUTPUT) $(COMPNAME).linked_musl.o

component_external:

%.o:%.c
$(info | [CC] $<: Compiling)
@$(CC) $(INCLUDE) $(CFLAGS) -o $@ -c $<
Expand All @@ -112,7 +115,7 @@ component: clean comp_header $(COMPOBJ)
# see the make manual: create the .d dependencies from include
# statements.
# redirect error output to /dev/null so that it will not display
# errors when cleaning, this does not affect gcc's error output when
# errors when cleaning, this does not affect gcc's error output when
# building the system because that is in a different target path
%.d:%.c
@set +e; rm -f $@; \
Expand Down
18 changes: 18 additions & 0 deletions src/components/implementation/no_interface/burn/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Required variables used to drive the compilation process. It is OK
# for many of these to be empty.
#
# The set of interfaces that this component exports for use by other
# components. This is a list of the interface names.
INTERFACE_EXPORTS =
# The interfaces this component is dependent on for compilation (this
# is a list of directory names in interface/)
INTERFACE_DEPENDENCIES =
# The library dependencies this component is reliant on for
# compilation/linking (this is a list of directory names in lib/)
LIBRARY_DEPENDENCIES = component
# Note: Both the interface and library dependencies should be
# *minimal*. That is to say that removing a dependency should cause
# the build to fail. The build system does not validate this
# minimality; that's on you!

include Makefile.subsubdir
11 changes: 11 additions & 0 deletions src/components/implementation/no_interface/burn/burn.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <llprint.h>

void
cos_init(void)
{
/* Burn all of the cycles! CPUs are glorified space heaters, right? */
printc("CPU cycle burn: component %ld, thread id %ld, core %d.\n",
cos_compid(), cos_thdid(), cos_coreid());

while (1) ;
}
12 changes: 12 additions & 0 deletions src/components/implementation/no_interface/burn/doc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
## CPU Burn Component

A simple component that burns CPU cycles, nothing else.
Can be used in test scenarios as background, CPU-intensive computations.

### Description

Simple infinite loop, nothing more.

### Usage and Assumptions

Only depends on the `init` interface, so it can be used anywhere from on top of the constructor, all the way to as a component under the scheduler.
3 changes: 3 additions & 0 deletions src/components/repos/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*
!.gitignore
!README.md
24 changes: 24 additions & 0 deletions src/components/repos/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# External Repositories

Composite current enables components to be defined externally from the main repo, thus providing increased autonomy in development.
Each repository in this directory is pulled from github, and can contain a set of components and composition scripts.
These repositories can be thought of as part of the Composite ecosystem, but not as part of the "standard library" of necessary functionalities.

A number of awkward realities with the current system:

- Composite does *not* maintain the repos downloaded here in any way.
If the upstream repo is changed, you must manually do a `git pull` in the repo (or remove it so it is re-cloned).
Comparably, if you update the external repo, you should manually commit/push, etc...
- The Composite repo ignores all repos in here.
Never add them.
The proper course of action would be to do a PR to the main Composite repo adding your component instead.

## TODO: Libraries and Interfaces

It should be possible to also define libraries and interfaces in external repositories.
This is more complicated as the dependencies for these are

1. not properly maintained by the composer (libraries aren't properly rebuilt when one of their dependencies changed), and
2. these dependencies are tracked by the build system, so updating them to enable dependencies are repositories requires most structural updates to the build system.

There are no hard blockers to doing this; we just need more time and will!
Loading