hare

The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit fd38afea0ac7c358127985940e8e66cb169db3ca
parent 1c30d94fbeaced55fb701c12bbbf5d9561e6bdc3
Author: Drew DeVault <sir@cmpwn.com>
Date:   Sat, 20 Mar 2021 17:47:27 -0400

cmd/hare: source platform from build

Diffstat:
MMakefile | 2++
Mcmd/hare/subcmds.ha | 4+---
Ascripts/platform | 13+++++++++++++
3 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile @@ -31,6 +31,7 @@ hare_srcs=\ $(HARECACHE)/hare.ssa: $(hare_srcs) $(hare_stdlib_deps) @printf 'HAREC\t$@\n' @HARECACHE=$(HARECACHE) $(HAREC) $(HAREFLAGS) \ + -D PLATFORM:str='"'"$$(./scripts/platform)"'"' \ -D VERSION:str='"'"$$(./scripts/version)"'"' \ -D HAREPATH:str='"'"$(HAREPATH)"'"' \ -o $@ $(hare_srcs) @@ -38,6 +39,7 @@ $(HARECACHE)/hare.ssa: $(hare_srcs) $(hare_stdlib_deps) $(TESTCACHE)/hare.ssa: $(hare_srcs) $(hare_testlib_deps) @printf 'HAREC\t$@\n' @HARECACHE=$(TESTCACHE) $(HAREC) $(TESTHAREFLAGS) \ + -D PLATFORM:str='"'"$$(./scripts/platform)"'"' \ -D VERSION:str='"'"$$(./scripts/version)"'"' \ -D HAREPATH:str='"'"$(HAREPATH)"'"' \ -o $@ $(hare_srcs) diff --git a/cmd/hare/subcmds.ha b/cmd/hare/subcmds.ha @@ -6,13 +6,11 @@ use os::exec; use path; fn default_tags() []module::tag = { - // TODO: Bake me into the executable once harec -D works return alloc([module::tag { name = os::machine(), mode = module::tag_mode::INCLUSIVE, }, module::tag { - // TEMP: - name = "linux", + name = PLATFORM, mode = module::tag_mode::INCLUSIVE, }]); }; diff --git a/scripts/platform b/scripts/platform @@ -0,0 +1,13 @@ +#!/bin/sh +# Prints the default build tags for the host +case $(uname) in + Linux) + platform="linux" + ;; + *) + printf "Warning: unknown target %s\n" "$(uname)" >&2 + platform="unknown" + ;; +esac + +printf "%s\n" "$platform"