generated from gvatsal60/project-template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from gvatsal60/feature/add_files
Added Files
- Loading branch information
Showing
13 changed files
with
188 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# ########################################################################## | ||
# File: Dockerfile | ||
# Author: Vatsal Gupta (gvatsal60) | ||
# Date: 08-Nov-2024 | ||
# Description: TBD | ||
# ########################################################################## | ||
|
||
# ########################################################################## | ||
# License | ||
# ########################################################################## | ||
# This Dockerfile is licensed under the Apache 2.0 License. | ||
|
||
# ########################################################################## | ||
# Base Image | ||
# ########################################################################## | ||
FROM gcr.io/bazel-public/bazel:latest AS base | ||
|
||
# ########################################################################## | ||
# Maintainer | ||
# ########################################################################## | ||
LABEL maintainer="Vatsal Gupta (gvatsal60)" | ||
|
||
# ########################################################################## | ||
# Install Dependencies | ||
# ########################################################################## | ||
USER root | ||
|
||
RUN apt-get update \ | ||
&& apt-get -y install --no-install-recommends \ | ||
apt-transport-https \ | ||
apt-utils \ | ||
bash-completion \ | ||
build-essential \ | ||
ca-certificates \ | ||
curl \ | ||
git \ | ||
&& apt-get -y clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Add buildifier | ||
ARG BUILDIFIER_BIN_PATH="/usr/local/bin/buildifier" | ||
ARG BUILDIFIER_VER=v7.3.1 | ||
ARG BUILDIFIER_LINK=https://github.com/bazelbuild/buildtools/releases/download/${BUILDIFIER_VER}/buildifier-linux-amd64 | ||
|
||
ADD ${BUILDIFIER_LINK} ${BUILDIFIER_BIN_PATH} | ||
RUN chmod +x ${BUILDIFIER_BIN_PATH} | ||
|
||
# ########################################################################## | ||
# USER | ||
# ########################################################################## | ||
USER ubuntu | ||
|
||
# ########################################################################## | ||
# Copy Files | ||
# ########################################################################## | ||
|
||
# ########################################################################## | ||
# Set Working Directory | ||
# ########################################################################## | ||
|
||
# ########################################################################## | ||
# Expose Port | ||
# ########################################################################## | ||
|
||
# ########################################################################## | ||
# Command to Run | ||
# ########################################################################## | ||
CMD ["/bin/bash"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
############################################################################### | ||
# Bazel now uses Bzlmod by default to manage external dependencies. | ||
# Please consider migrating your external dependencies from WORKSPACE to MODULE.bazel. | ||
# | ||
# For more details, please check https://github.com/bazelbuild/bazel/issues/18958 | ||
############################################################################### | ||
|
||
# Hedron's Compile Commands Extractor for Bazel | ||
# https://github.com/hedronvision/bazel-compile-commands-extractor | ||
bazel_dep(name = "hedron_compile_commands", dev_dependency = True) | ||
git_override( | ||
module_name = "hedron_compile_commands", | ||
remote = "https://github.com/hedronvision/bazel-compile-commands-extractor.git", | ||
commit = "4f28899228fb3ad0126897876f147ca15026151e", | ||
# Replace the commit hash (above) with the latest (https://github.com/hedronvision/bazel-compile-commands-extractor/commits/main). | ||
# Even better, set up Renovate and let it do the work for you (see "Suggestion: Updates" in the README). | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Targets | ||
.PHONY: all | ||
all: | ||
.PHONY: test | ||
test: | ||
.PHONY: clean | ||
clean: | ||
|
||
sonar: | ||
bazel run @hedron_compile_commands//:refresh_all -- --compilation_mode=dbg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
cc_library( | ||
name = "newlib", | ||
hdrs = glob([ | ||
"lib/inc/*.h", | ||
"inc/*.h", | ||
]), | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
cc_binary( | ||
name = "main", | ||
srcs = glob(["src/*.cc"]), # Automatically include all .cc files in src/ | ||
cxxopts = [ | ||
"-Iproject/inc", | ||
"-Iproject/lib/inc", | ||
], | ||
includes = [ | ||
"inc", # Add inc directory to search paths for header files | ||
"lib/inc", # Add lib/inc directory for hello-time headers | ||
], | ||
deps = [ | ||
":newlib", | ||
"//project/lib:hello-time", # Use the correct target name: //project/lib:hello-time | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
|
||
std::string get_greet(const std::string &thing); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
cc_library( | ||
name = "hello-time", | ||
srcs = glob(["src/*.cc"]), # Automatically include all .cc files in lib/src/ | ||
hdrs = glob(["inc/*.h"]), # Automatically include all .h files in lib/inc/ | ||
includes = ["inc"], # Include lib/inc in the include search path | ||
visibility = ["//project:__pkg__"], # Make hello-time visible to the main target | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#pragma once | ||
|
||
void print_localtime(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#include "hello-time.h" | ||
#include <ctime> | ||
#include <iostream> | ||
|
||
void print_localtime() { | ||
std::time_t result = std::time(nullptr); | ||
std::cout << std::asctime(std::localtime(&result)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#include "hello-greet.h" | ||
#include <string> | ||
|
||
std::string get_greet(const std::string &who) { return "Hello " + who; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#include "hello-greet.h" | ||
#include "hello-time.h" | ||
#include <iostream> | ||
#include <string> | ||
|
||
int main(int argc, char **argv) { | ||
std::string who = "world"; | ||
if (argc > 1) { | ||
who = argv[1]; | ||
} | ||
std::cout << get_greet(who) << std::endl; | ||
print_localtime(); | ||
|
||
return 0; | ||
} |