Zig hello-example
rename example - fix confusion-rename fixed zigflags added rm zigflag single-threaded zig rules added
This commit is contained in:
parent
2dde296d4f
commit
cdb04f6172
@ -73,19 +73,22 @@ CAOBJS = $(CASRCS:=$(SUFFIX)$(OBJEXT))
|
||||
COBJS = $(CSRCS:=$(SUFFIX)$(OBJEXT))
|
||||
CXXOBJS = $(CXXSRCS:=$(SUFFIX)$(OBJEXT))
|
||||
RUSTOBJS = $(RUSTSRCS:=$(SUFFIX)$(OBJEXT))
|
||||
ZIGOBJS = $(ZIGSRCS:=$(SUFFIX)$(OBJEXT))
|
||||
|
||||
MAINCXXSRCS = $(filter %$(CXXEXT),$(MAINSRC))
|
||||
MAINCSRCS = $(filter %.c,$(MAINSRC))
|
||||
MAINRUSTSRCS = $(filter %$(RUSTEXT),$(MAINSRC))
|
||||
MAINZIGSRCS = $(filter %$(ZIGEXT), $(MAINSRC))
|
||||
MAINCXXOBJ = $(MAINCXXSRCS:=$(SUFFIX)$(OBJEXT))
|
||||
MAINCOBJ = $(MAINCSRCS:=$(SUFFIX)$(OBJEXT))
|
||||
MAINRUSTOBJ = $(MAINRUSTSRCS:=$(SUFFIX)$(OBJEXT))
|
||||
MAINZIGOBJS = $(MAINZIGSRCS:=$(SUFFIX$(OBJEXT))
|
||||
|
||||
SRCS = $(ASRCS) $(CSRCS) $(CXXSRCS) $(MAINSRC)
|
||||
OBJS = $(RAOBJS) $(CAOBJS) $(COBJS) $(CXXOBJS) $(RUSTOBJS)
|
||||
OBJS = $(RAOBJS) $(CAOBJS) $(COBJS) $(CXXOBJS) $(RUSTOBJS) $(ZIGOBJS)
|
||||
|
||||
ifneq ($(BUILD_MODULE),y)
|
||||
OBJS += $(MAINCOBJ) $(MAINCXXOBJ) $(MAINRUSTOBJ)
|
||||
OBJS += $(MAINCOBJ) $(MAINCXXOBJ) $(MAINRUSTOBJ) $(MAINZIGOBJS)
|
||||
endif
|
||||
|
||||
DEPPATH += --dep-path .
|
||||
@ -119,6 +122,11 @@ define ELFCOMPILERUST
|
||||
$(Q) $(RUSTC) --emit obj $(RUSTELFFLAGS) $($(strip $1)_RUSTELFFLAGS) $1 -o $2
|
||||
endef
|
||||
|
||||
define ELFCOMPILEZIG
|
||||
@echo "ZIG: $1"
|
||||
$(Q) $(ZIG) build-obj $(ZIGELFFLAGS) $($(strip $1)_ZIGELFFLAGS) $1 --name $2
|
||||
endef
|
||||
|
||||
define ELFLD
|
||||
@echo "LD: $2"
|
||||
$(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) $(ARCHCRT0OBJ) $1 $(LDLIBS) -o $2
|
||||
@ -144,6 +152,10 @@ $(RUSTOBJS): %$(RUSTEXT)$(SUFFIX)$(OBJEXT): %$(RUSTEXT)
|
||||
$(if $(and $(CONFIG_BUILD_LOADABLE),$(CELFFLAGS)), \
|
||||
$(call ELFCOMPILERUST, $<, $@), $(call COMPILERUST, $<, $@))
|
||||
|
||||
$(ZIGOBJS): %$(ZIGEXT)$(SUFFIX)$(OBJEXT): %$(ZIGEXT)
|
||||
$(if $(and $(CONFIG_BUILD_LOADABLE), $(CELFFLAGS)), \
|
||||
$(call ELFCOMPILEZIG, $<, $@), $(call COMPILEZIG, $<, $@))
|
||||
|
||||
archive:
|
||||
$(call ARCHIVE_ADD, $(call CONVERT_PATH,$(BIN)), $(OBJS))
|
||||
|
||||
@ -195,6 +207,10 @@ $(MAINRUSTOBJ): %$(RUSTEXT)$(SUFFIX)$(OBJEXT): %$(RUSTEXT)
|
||||
$(if $(and $(CONFIG_BUILD_LOADABLE),$(CELFFLAGS)), \
|
||||
$(call ELFCOMPILERUST, $<, $@), $(call COMPILERUST, $<, $@))
|
||||
|
||||
$(MAINZIGOBJS): %$(ZIGEXT)$(SUFFIX)$(OBJEXT): %$(ZIGEXT)
|
||||
$(if $(and $(CONFIG_BUILD_LOADABLE),$(CELFFLAGS)), \
|
||||
$(call ELFCOMPILEZIG, $<, $@), $(call COMPILEZIG, $<, $@))
|
||||
|
||||
install::
|
||||
|
||||
endif # BUILD_MODULE
|
||||
|
@ -58,6 +58,7 @@ $(foreach BDIR, $(BUILDIRS), $(eval $(call Add_Application,$(BDIR))))
|
||||
|
||||
CXXEXT ?= .cxx
|
||||
RUSTEXT ?= .rs
|
||||
ZIGEXT ?= .zig
|
||||
|
||||
# Library path
|
||||
|
||||
|
29
examples/hello_zig/Kconfig
Normal file
29
examples/hello_zig/Kconfig
Normal file
@ -0,0 +1,29 @@
|
||||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see the file kconfig-language.txt in the NuttX tools repository.
|
||||
#
|
||||
|
||||
config EXAMPLES_HELLO_ZIG
|
||||
tristate "\"Hello, Zig!\" example"
|
||||
default n
|
||||
---help---
|
||||
Enable the \"Hello, Zig!\" example
|
||||
|
||||
if EXAMPLES_HELLO_ZIG
|
||||
|
||||
config EXAMPLES_HELLO_ZIG_PROGNAME
|
||||
string "Program name"
|
||||
default "hello_zig"
|
||||
---help---
|
||||
This is the name of the program that will be used when the
|
||||
program is installed.
|
||||
|
||||
config EXAMPLES_HELLO_ZIG_PRIORITY
|
||||
int "Hello Zig task priority"
|
||||
default 100
|
||||
|
||||
config EXAMPLES_HELLO_ZIG_STACKSIZE
|
||||
int "Hello Zig stack size"
|
||||
default DEFAULT_TASK_STACKSIZE
|
||||
|
||||
endif
|
23
examples/hello_zig/Make.defs
Normal file
23
examples/hello_zig/Make.defs
Normal file
@ -0,0 +1,23 @@
|
||||
############################################################################
|
||||
# apps/examples/hello_zig/Make.defs
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership. The
|
||||
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance with the
|
||||
# License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
ifneq ($(CONFIG_EXAMPLES_HELLO_ZIG),)
|
||||
CONFIGURED_APPS += $(APPDIR)/examples/hello_zig
|
||||
endif
|
34
examples/hello_zig/Makefile
Normal file
34
examples/hello_zig/Makefile
Normal file
@ -0,0 +1,34 @@
|
||||
############################################################################
|
||||
# apps/examples/hello_zig/Make.defs
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership. The
|
||||
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance with the
|
||||
# License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
include $(APPDIR)/Make.defs
|
||||
|
||||
# Hello, Zig! Example
|
||||
|
||||
MAINSRC = hello_zig_main.zig
|
||||
|
||||
# Hello, Zig! built-in application info
|
||||
|
||||
PROGNAME = $(CONFIG_EXAMPLES_HELLO_ZIG_PROGNAME)
|
||||
PRIORITY = $(CONFIG_EXAMPLES_HELLO_ZIG_PRIORITY)
|
||||
STACKSIZE = $(CONFIG_EXAMPLES_HELLO_ZIG_STACKSIZE)
|
||||
MODULE = $(CONFIG_EXAMPLES_HELLO_ZIG)
|
||||
|
||||
include $(APPDIR)/Application.mk
|
39
examples/hello_zig/hello_zig_main.zig
Normal file
39
examples/hello_zig/hello_zig_main.zig
Normal file
@ -0,0 +1,39 @@
|
||||
//***************************************************************************
|
||||
// examples/hello_zig/hello_zig_main.zig
|
||||
//
|
||||
// Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
// contributor license agreements. See the NOTICE file distributed with
|
||||
// this work for additional information regarding copyright ownership. The
|
||||
// ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance with the
|
||||
// License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
// License for the specific language governing permissions and limitations
|
||||
// under the License.
|
||||
//
|
||||
//***************************************************************************
|
||||
|
||||
//***************************************************************************
|
||||
// Included Files
|
||||
//***************************************************************************
|
||||
const std = @import("std");
|
||||
|
||||
//****************************************************************************
|
||||
//* Externs
|
||||
//****************************************************************************
|
||||
|
||||
pub extern fn printf(_format: [*:0]const u8) c_int;
|
||||
|
||||
//****************************************************************************
|
||||
//* hello_zig_main
|
||||
//****************************************************************************
|
||||
pub export fn hello_zig_main(_argc: c_int, _argv: [*]const [*]const u8) c_int {
|
||||
_ = _argc;
|
||||
_ = _argv;
|
||||
printf("Hello, Zig!\n");
|
||||
}
|
Loading…
Reference in New Issue
Block a user