1.2019秋招|菜鸟C++工程师秋招面经分享(上)
2.å¦ä½ä½¿ç¨bazel build
2019秋招|菜鸟C++工程师秋招面经分享(上)
作者:匿名 链接:/discuss/ 来源:牛客网 我在秋招中作为菜鸟级C++工程师经历了不少坎坷,最终拿到了4个小厂的码论码最offer,大厂的好用面试统统没过。这段经历让我深刻反思,坛源坛源http源码修复意识到早起早学的码论码最重要性。我选择从6月拿了一个vivo提前批的好用sp开始,之后主要瞄准互联网公司,坛源坛源幸运地拿到了两个互联网公司的码论码最offer。 现在,好用我愿意分享我的坛源坛源经验,希望对未来的码论码最基于CAF源码牛友们有所启发。面试过程中,好用主要考察了以下几个方面: C++基础 我参考了《Effective C++》、坛源坛源《C++ Prime》、码论码最《STL源码剖析》等书籍,好用深入理解了宏定义、转转客源码inline函数、字符串替换等概念。 数据结构与算法 《大话数据结构》、《数据结构浙大版》、《算法设计与分析》等书为我提供了理论基础,bootstrap源码视频而《算法导论》、《剑指offer》、《LeetCode》、《组合数学》等则帮助我实践和掌握算法技巧。 网络技术 从TCP/IP到UDP和TCP编程,机构拉升源码我了解了服务器和客户端的步骤和规范,熟悉了网络编程的底层逻辑。 操作系统 我学习了死锁的四个条件、避免与预防方法以及解除死锁的策略。 以上是我面试准备的重点内容。希望我的分享能够帮助你更好地准备面试,提升自己的竞争力。记得,多练习,多总结,坚持学习,你会在求职路上越走越远。记住,不经历秋招的你,不知道自己的潜力有多大。如果你有志于成为一名成功的程序员,那么现在就开始努力吧!å¦ä½ä½¿ç¨bazel build
å®è£
å®è£ è¿ç¨è¯·åè: /example
$ cat > src/main/java/com/example/ProjectRunner.java <<EOF
package com.example;
public class ProjectRunner {
public static void main(String args[]) {
Greeting.sayHi();
}
}
EOF
$ cat > src/main/java/com/example/Greeting.java <<EOF
package com.example;
public class Greeting {
public static void sayHi() {
System.out.println("Hi!");
}
}
EOF
Bazeléè¿å·¥ä½åºä¸ææå为 BUILD çæ件æ¥è§£æéè¦æ建ç项ç®ä¿¡æ¯ï¼å æ¤ï¼æ们éè¦å å¨ ~/gitroot/my-project ç®å½å建ä¸ä¸ª BUILD æ建æ件ãä¸é¢æ¯BUILDæ建æ件çå 容ï¼
# ~/gitroot/my-project/BUILD
java_binary(
name = "my-runner",
srcs = glob(["**/*.java"]),
main_class = "com.example.ProjectRunner",
)
BUILDæ件éç¨ç±»ä¼¼Pythonçè¯æ³ãè½ç¶ä¸è½å å«ä»»æçPythonè¯æ³ï¼ä½æ¯BUILDæ件ä¸çæ¯ä¸ªæ建è§åçèµ·æ¥é½è±¡æ¯ä¸ä¸ªPythonå½æ°è°ç¨ï¼èä¸ä½ ä¹å¯ä»¥ç¨ "#" å¼å¤´æ¥æ·»å åè¡æ³¨éã
java_binary æ¯ä¸ä¸ªæ建è§åãå ¶ä¸ name 对åºä¸ä¸ªæ建ç®æ çæ è¯ç¬¦ï¼å¯ç¨ç¨å®æ¥åBazelæå®æ建åªä¸ªé¡¹ç®ãsrcs 对åºä¸ä¸ªæºæ件å表ï¼Bazeléè¦å°è¿äºæºæ件ç¼è¯ä¸ºäºè¿å¶æ件ãå ¶ä¸ glob(["**/*.java"]) 表示éå½å å«æ¯ä¸ªåç®å½ä¸ä»¥æ¯ä¸ª .java 为åç¼åçæ件ãcom.example.ProjectRunner æå®å å«mainæ¹æ³çç±»ã
ç°å¨å¯ä»¥ç¨ä¸é¢çå½ä»¤æ建è¿ä¸ªJavaç¨åºäºï¼
$ cd ~/gitroot/my-project
$ bazel build //:my-runner
INFO: Found 1 target...
Target //:my-runner up-to-date:
bazel-bin/my-runner.jar
bazel-bin/my-runner
INFO: Elapsed time: 1.s, Critical Path: 0.s
$ bazel-bin/my-runner
Hi!
æåï¼ä½ å·²ç»æåæ建äºç¬¬ä¸ä¸ªBazel项ç®äºï¼
æ·»å ä¾èµå ³ç³»
对äºå°é¡¹ç®å建ä¸ä¸ªè§åæ¯å¯ä»¥çï¼ä½æ¯éç项ç®çå大ï¼åéè¦åå«æ建项ç®çä¸åçé¨ä»¶ï¼æç»åç»è£ æ产åãè¿ç§æ建æ¹å¼å¯ä»¥é¿å å 为å±é¨ç»å°çä¿®æ¹å¿å¯¼è´éç°æ建æ´ä¸ªåºç¨ï¼åæ¶ä¸åçæ建æ¥éª¤å¯ä»¥å¾å¥½å°å¹¶åæ§è¡ä»¥æé«æ建æçã
æ们ç°å¨å°ä¸ä¸ªé¡¹ç®æå为两个é¨åç¬ç«æ建ï¼åæ¶è®¾ç½®å®ä»¬ä¹é´çä¾èµå ³ç³»ãåºäºä¸é¢çä¾åï¼æ们éåäºBUILDæ建æ件ï¼
java_binary(
name = "my-other-runner",
srcs = ["src/main/java/com/example/ProjectRunner.java"],
main_class = "com.example.ProjectRunner",
deps = [":greeter"],
)
java_library(
name = "greeter",
srcs = ["src/main/java/com/example/Greeting.java"],
)
è½ç¶æºæ件æ¯ä¸æ ·çï¼ä½æ¯ç°å¨Bazelå°éç¨ä¸åçæ¹å¼æ¥æ建ï¼é¦å æ¯æ建 greeteråºï¼ç¶åæ¯æ建 my-other-runnerãå¯ä»¥å¨æ建æååç«å»è¿è¡ //:my-other-runnerï¼
$ bazel run //:my-other-runner
INFO: Found 1 target...
Target //:my-other-runner up-to-date:
bazel-bin/my-other-runner.jar
bazel-bin/my-other-runner
INFO: Elapsed time: 2.s, Critical Path: 1.s
INFO: Running command line: bazel-bin/my-other-runner
Hi!
ç°å¨å¦æä½ æ¹å¨ProjectRunner.java代ç 并éæ°æ建my-other-runnerç®æ ï¼Greeting.javaæ件å 为没æååèä¸ä¼éç°ç¼è¯ã
使ç¨å¤ä¸ªå ï¼Packagesï¼
对äºæ´å¤§ç项ç®ï¼æ们é常éè¦å°å®ä»¬æåå°å¤ä¸ªç®å½ä¸ãä½ å¯ä»¥ç¨ç±»ä¼¼//path/to/directory:target-nameçååå¼ç¨å¨å ¶ä»BUILDæ件å®ä¹çç®æ ãå设src/main/java/com/example/æä¸ä¸ªcmdline/åç®å½ï¼å å«ä¸é¢çæ件ï¼
$ mkdir -p src/main/java/com/example/cmdline
$ cat > src/main/java/com/example/cmdline/Runner.java <<EOF
package com.example.cmdline;
import com.example.Greeting;
public class Runner {
public static void main(String args[]) {
Greeting.sayHi();
}
}
EOF
Runner.javaä¾èµcom.example.Greetingï¼å æ¤æ们éè¦å¨src/main/java/com/example/cmdline/BUILDæ建æ件ä¸æ·»å ç¸åºçä¾èµè§åï¼
# ~/gitroot/my-project/src/main/java/com/example/cmdline/BUILD
java_binary(
name = "runner",
srcs = ["Runner.java"],
main_class = "com.example.cmdline.Runner",
deps = ["//:greeter"]
)
ç¶èï¼é»è®¤æ åµä¸æ建ç®æ é½æ¯ ç§æ çãä¹å°±æ¯è¯´ï¼æ们åªè½å¨åä¸ä¸ªBUILDæ件ä¸è¢«å¼ç¨ãè¿å¯ä»¥é¿å å°å¾å¤å®ç°çç»èæ´æ¼ç»å ¬å ±çæ¥å£ï¼ä½æ¯ä¹æå³çæ们éè¦æå·¥å 许runneræä¾èµç//:greeterç®æ ãå°±æ¯ç±»ä¼¼ä¸é¢è¿ä¸ªå¨æ建runnerç®æ æ¶éå°çé误ï¼
$ bazel build //src/main/java/com/example/cmdline:runner
ERROR: /home/user/gitroot/my-project/src/main/java/com/example/cmdline/BUILD:2:1:
Target '//:greeter' is not visible from target '//src/main/java/com/example/cmdline:runner'.
Check the visibility declaration of the former target if you think the dependency is legitimate.
ERROR: Analysis of target '//src/main/java/com/example/cmdline:runner' failed; build aborted.
INFO: Elapsed time: 0.s
å¯ç¨éè¿å¨BUILDæ件å¢å visibility = levelå±æ§æ¥æ¹åç®æ çå¯é´èå´ãä¸é¢æ¯éè¿å¨~/gitroot/my-project/BUILDæ件å¢å å¯è§è§åï¼æ¥æ¹ågreeterç®æ çå¯è§èå´ï¼
java_library(
name = "greeter",
srcs = ["src/main/java/com/example/Greeting.java"],
visibility = ["//src/main/java/com/example/cmdline:__pkg__"],
)
è¿ä¸ªè§å表示//:greeterç®æ 对äº//src/main/java/com/example/cmdlineå æ¯å¯è§çãç°å¨æ们å¯ä»¥éæ°æ建runnerç®æ ç¨åºï¼
$ bazel run //src/main/java/com/example/cmdline:runner
INFO: Found 1 target...
Target //src/main/java/com/example/cmdline:runner up-to-date:
bazel-bin/src/main/java/com/example/cmdline/runner.jar
bazel-bin/src/main/java/com/example/cmdline/runner
INFO: Elapsed time: 1.s, Critical Path: 0.s
INFO: Running command line: bazel-bin/src/main/java/com/example/cmdline/runner
Hi!
åèææ¡£ ä¸æå¯è§æ§é 置说æã
é¨ç½²
å¦æä½ æ¥ç bazel-bin/src/main/java/com/example/cmdline/runner.jar çå 容ï¼å¯ä»¥çå°éé¢åªå å«äºRunner.classï¼å¹¶æ²¡æä¿æ¤æä¾èµçGreeting.classï¼
$ jar tf bazel-bin/src/main/java/com/example/cmdline/runner.jar
META-INF/
META-INF/MANIFEST.MF
com/
com/example/
com/example/cmdline/
com/example/cmdline/Runner.class
è¿åªè½å¨æ¬æºæ£å¸¸å·¥ä½ï¼å 为Bazelçrunnerèæ¬å·²ç»å°greeter jaræ·»å å°äºclasspathï¼ï¼ä½æ¯å¦æå°runner.jaråç¬å¤å¶å°å¦ä¸å°æºå¨ä¸è®²ä¸è½æ£å¸¸è¿è¡ãå¦ææ³è¦æ建å¯ç¨äºé¨ç½²åå¸çèªå å«ææä¾èµçç®æ ï¼å¯ä»¥æ建runner_deploy.jarç®æ ï¼ç±»ä¼¼<target-name>_deploy.jar以_deploy为åç¼çåå对åºå¯é¨ç½²ç®æ ï¼ã
$ bazel build //src/main/java/com/example/cmdline:runner_deploy.jar
INFO: Found 1 target...
Target //src/main/java/com/example/cmdline:runner_deploy.jar up-to-date:
bazel-bin/src/main/java/com/example/cmdline/runner_deploy.jar
INFO: Elapsed time: 1.s, Critical Path: 0.s
runner_deploy.jarä¸å°å å«å ¨é¨çä¾èµã
ä¸ä¸æ¥
ç°å¨ï¼æ¨å¯ä»¥å建èªå·±çç®æ 并ç»è£ æç»äº§åäºãæ¥ä¸æ¥ï¼å¯æ¥ç ç¸å ³æç¨ åå«å¦ä¹ å¦ä½ç¨Bazelæ建ä¸ä¸ªæå¡å¨ãAndroidåiOSåºç¨ãä¹å¯ä»¥åè ç¨æ·æåè·å¾æ´å¤çä¿¡æ¯ãå¦ææé®é¢çè¯ï¼å¯ä»¥å° bazel-discuss 论åæé®ã